Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2723)

Unified Diff: chrome/browser/resources/ntp4/page_list_view.js

Issue 9358031: Added new adaptive "Suggest" tab on the New Tab Page, behing the flag, for the experiments. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved suggestions before apps, fixed already present js bug, alphabetised .css Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/ntp4/page_list_view.js
diff --git a/chrome/browser/resources/ntp4/page_list_view.js b/chrome/browser/resources/ntp4/page_list_view.js
index fc50b56a7d14b807ff730242e542133f30d31ca9..ad859e0e679e049735c2baad30da539a3a2858d6 100644
--- a/chrome/browser/resources/ntp4/page_list_view.js
+++ b/chrome/browser/resources/ntp4/page_list_view.js
@@ -59,6 +59,12 @@ cr.define('ntp4', function() {
appsPages: undefined,
/**
+ * The Suggestions page.
+ * @type {!Element|undefined}
+ */
+ suggestionsPage: undefined,
+
+ /**
* The Most Visited page.
* @type {!Element|undefined}
*/
@@ -197,9 +203,15 @@ cr.define('ntp4', function() {
* the page list.
*/
appendTilePage: function(page, title, titleIsEditable, opt_refNode) {
+ if (typeof ntp4.SuggestionsPage != 'undefined' &&
Evan Stade 2012/02/24 23:28:01 this is a hack.
GeorgeY 2012/02/25 01:30:55 I will not argue with you what is a hack or not he
+ page instanceof ntp4.SuggestionsPage &&
+ typeof this.appsPages != 'undefined' && this.appsPages.length > 0) {
+ // Add suggestion page before the apps page(s).
+ opt_refNode = this.appsPages[0];
+ }
if (opt_refNode) {
var refIndex = this.getTilePageIndex(opt_refNode);
- this.cardSlider.insertCardAtIndex(page, refIndex);
+ this.cardSlider.addCardAtIndex(page, refIndex);
} else {
this.cardSlider.appendCard(page);
}
@@ -212,6 +224,11 @@ cr.define('ntp4', function() {
this.mostVisitedPage = page;
}
+ if (typeof ntp4.SuggestionsPage != 'undefined' &&
+ page instanceof ntp4.SuggestionsPage) {
+ this.suggestionsPage = page;
+ }
+
// If we're appending an AppsPage and it's a temporary page, animate it.
var animate = page instanceof ntp4.AppsPage &&
page.classList.contains('temporary');
@@ -429,6 +446,10 @@ cr.define('ntp4', function() {
if (this.mostVisitedPage)
this.cardSlider.selectCardByValue(this.mostVisitedPage);
break;
+ case templateData['suggestions_page_id']:
+ if (this.suggestionsPage)
+ this.cardSlider.selectCardByValue(this.suggestionsPage);
+ break;
}
},
@@ -543,6 +564,9 @@ cr.define('ntp4', function() {
} else if (page.classList.contains('most-visited-page')) {
this.shownPage = templateData.most_visited_page_id;
this.shownPageIndex = 0;
+ } else if (page.classList.contains('suggestions-page')) {
+ this.shownPage = templateData.suggestions_page_id;
+ this.shownPageIndex = 0;
} else {
console.error('unknown page selected');
}

Powered by Google App Engine
This is Rietveld 408576698