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

Side by Side 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: Adressed comments 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview PageListView implementation. 6 * @fileoverview PageListView implementation.
7 * PageListView manages page list, dot list, switcher buttons and handles apps 7 * PageListView manages page list, dot list, switcher buttons and handles apps
8 * pages callbacks from backend. 8 * pages callbacks from backend.
9 * 9 *
10 * Note that you need to have AppLauncherHandler in your WebUI to use this code. 10 * Note that you need to have AppLauncherHandler in your WebUI to use this code.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 */ 52 */
53 tilePages: undefined, 53 tilePages: undefined,
54 54
55 /** 55 /**
56 * A list of all 'apps-page' elements. 56 * A list of all 'apps-page' elements.
57 * @type {!NodeList|undefined} 57 * @type {!NodeList|undefined}
58 */ 58 */
59 appsPages: undefined, 59 appsPages: undefined,
60 60
61 /** 61 /**
62 * The Suggestions page.
63 * @type {!Element|undefined}
64 */
65 suggestionsPage: undefined,
66
67 /**
62 * The Most Visited page. 68 * The Most Visited page.
63 * @type {!Element|undefined} 69 * @type {!Element|undefined}
64 */ 70 */
65 mostVisitedPage: undefined, 71 mostVisitedPage: undefined,
66 72
67 /** 73 /**
68 * The 'dots-list' element. 74 * The 'dots-list' element.
69 * @type {!Element|undefined} 75 * @type {!Element|undefined}
70 */ 76 */
71 dotList: undefined, 77 dotList: undefined,
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 211 }
206 212
207 // Remember special MostVisitedPage. 213 // Remember special MostVisitedPage.
208 if (typeof ntp4.MostVisitedPage != 'undefined' && 214 if (typeof ntp4.MostVisitedPage != 'undefined' &&
209 page instanceof ntp4.MostVisitedPage) { 215 page instanceof ntp4.MostVisitedPage) {
210 assert(this.tilePages.length == 1, 216 assert(this.tilePages.length == 1,
211 'MostVisitedPage should be added as first tile page'); 217 'MostVisitedPage should be added as first tile page');
212 this.mostVisitedPage = page; 218 this.mostVisitedPage = page;
213 } 219 }
214 220
221 if (typeof ntp4.SuggestionsPage != 'undefined' &&
222 page instanceof ntp4.SuggestionsPage) {
223 this.suggestionsPage = page;
224 }
225
215 // If we're appending an AppsPage and it's a temporary page, animate it. 226 // If we're appending an AppsPage and it's a temporary page, animate it.
216 var animate = page instanceof ntp4.AppsPage && 227 var animate = page instanceof ntp4.AppsPage &&
217 page.classList.contains('temporary'); 228 page.classList.contains('temporary');
218 // Make a deep copy of the dot template to add a new one. 229 // Make a deep copy of the dot template to add a new one.
219 var newDot = new ntp4.NavDot(page, title, titleIsEditable, animate); 230 var newDot = new ntp4.NavDot(page, title, titleIsEditable, animate);
220 page.navigationDot = newDot; 231 page.navigationDot = newDot;
221 this.dotList.insertBefore(newDot, 232 this.dotList.insertBefore(newDot,
222 opt_refNode ? opt_refNode.navigationDot : null); 233 opt_refNode ? opt_refNode.navigationDot : null);
223 // Set a tab index on the first dot. 234 // Set a tab index on the first dot.
224 if (this.dotList.dots.length == 1) 235 if (this.dotList.dots.length == 1)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 appAdded: function(appData, opt_highlight) { 381 appAdded: function(appData, opt_highlight) {
371 if (appData.id == this.highlightAppId) { 382 if (appData.id == this.highlightAppId) {
372 opt_highlight = true; 383 opt_highlight = true;
373 this.highlightAppId = null; 384 this.highlightAppId = null;
374 } 385 }
375 386
376 var pageIndex = appData.page_index || 0; 387 var pageIndex = appData.page_index || 0;
377 388
378 if (pageIndex >= this.appsPages.length) { 389 if (pageIndex >= this.appsPages.length) {
379 while (pageIndex >= this.appsPages.length) { 390 while (pageIndex >= this.appsPages.length) {
380 this.appendTilePage(new ntp4.AppsPage(), 391 this.appendTilePage(new ntp4.AppsPage(),
Evan Stade 2012/02/24 22:49:45 this is still just appending the new apps page...
GeorgeY 2012/02/24 23:14:19 I changed the code above to add suggestions page p
381 localStrings.getString('appDefaultPageName'), 392 localStrings.getString('appDefaultPageName'),
382 true); 393 true);
383 } 394 }
384 this.updateSliderCards(); 395 this.updateSliderCards();
385 } 396 }
386 397
387 var page = this.appsPages[pageIndex]; 398 var page = this.appsPages[pageIndex];
388 var app = $(appData.id); 399 var app = $(appData.id);
389 if (app) 400 if (app)
390 app.replaceAppData(appData); 401 app.replaceAppData(appData);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 switch (this.shownPage) { 433 switch (this.shownPage) {
423 case templateData['apps_page_id']: 434 case templateData['apps_page_id']:
424 this.cardSlider.selectCardByValue( 435 this.cardSlider.selectCardByValue(
425 this.appsPages[Math.min(this.shownPageIndex, 436 this.appsPages[Math.min(this.shownPageIndex,
426 this.appsPages.length - 1)]); 437 this.appsPages.length - 1)]);
427 break; 438 break;
428 case templateData['most_visited_page_id']: 439 case templateData['most_visited_page_id']:
429 if (this.mostVisitedPage) 440 if (this.mostVisitedPage)
430 this.cardSlider.selectCardByValue(this.mostVisitedPage); 441 this.cardSlider.selectCardByValue(this.mostVisitedPage);
431 break; 442 break;
443 case templateData['suggestions_page_id']:
444 if (this.suggestionsPage)
445 this.cardSlider.selectCardByValue(this.suggestionsPage);
446 break;
432 } 447 }
433 }, 448 },
434 449
435 /** 450 /**
436 * Called whenever tiles should be re-arranging themselves out of the way 451 * Called whenever tiles should be re-arranging themselves out of the way
437 * of a moving or insert tile. 452 * of a moving or insert tile.
438 */ 453 */
439 enterRearrangeMode: function() { 454 enterRearrangeMode: function() {
440 var tempPage = new ntp4.AppsPage(); 455 var tempPage = new ntp4.AppsPage();
441 tempPage.classList.add('temporary'); 456 tempPage.classList.add('temporary');
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 551
537 // Don't change shownPage until startup is done (and page changes actually 552 // Don't change shownPage until startup is done (and page changes actually
538 // reflect user actions). 553 // reflect user actions).
539 if (!this.isStartingUp_()) { 554 if (!this.isStartingUp_()) {
540 if (page.classList.contains('apps-page')) { 555 if (page.classList.contains('apps-page')) {
541 this.shownPage = templateData.apps_page_id; 556 this.shownPage = templateData.apps_page_id;
542 this.shownPageIndex = this.getAppsPageIndex(page); 557 this.shownPageIndex = this.getAppsPageIndex(page);
543 } else if (page.classList.contains('most-visited-page')) { 558 } else if (page.classList.contains('most-visited-page')) {
544 this.shownPage = templateData.most_visited_page_id; 559 this.shownPage = templateData.most_visited_page_id;
545 this.shownPageIndex = 0; 560 this.shownPageIndex = 0;
561 } else if (page.classList.contains('suggestions-page')) {
562 this.shownPage = templateData.suggestions_page_id;
563 this.shownPageIndex = 0;
546 } else { 564 } else {
547 console.error('unknown page selected'); 565 console.error('unknown page selected');
548 } 566 }
549 chrome.send('pageSelected', [this.shownPage, this.shownPageIndex]); 567 chrome.send('pageSelected', [this.shownPage, this.shownPageIndex]);
550 } 568 }
551 569
552 // Update the active dot 570 // Update the active dot
553 var curDot = this.dotList.getElementsByClassName('selected')[0]; 571 var curDot = this.dotList.getElementsByClassName('selected')[0];
554 if (curDot) 572 if (curDot)
555 curDot.classList.remove('selected'); 573 curDot.classList.remove('selected');
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if (page.navigationDot) 680 if (page.navigationDot)
663 page.navigationDot.remove(opt_animate); 681 page.navigationDot.remove(opt_animate);
664 this.cardSlider.removeCard(page); 682 this.cardSlider.removeCard(page);
665 }, 683 },
666 }; 684 };
667 685
668 return { 686 return {
669 PageListView: PageListView 687 PageListView: PageListView
670 }; 688 };
671 }); 689 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.js ('k') | chrome/browser/resources/ntp4/suggestions_page.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698