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

Side by Side Diff: chrome/browser/resources/ntp_search/new_tab.js

Issue 10829131: Refactoring NTP5: new implementation of TilePage and MostVisitedPage (which now inherits from Thumb… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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
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 New tab page 6 * @fileoverview New tab page
7 * This is the main code for the new tab page used by touch-enabled Chrome 7 * This is the main code for the new tab page used by touch-enabled Chrome
8 * browsers. For now this is still a prototype. 8 * browsers. For now this is still a prototype.
9 */ 9 */
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 function NewTabView() { 80 function NewTabView() {
81 var pageSwitcherStart = null; 81 var pageSwitcherStart = null;
82 var pageSwitcherEnd = null; 82 var pageSwitcherEnd = null;
83 if (loadTimeData.getValue('showApps')) { 83 if (loadTimeData.getValue('showApps')) {
84 pageSwitcherStart = getRequiredElement('page-switcher-start'); 84 pageSwitcherStart = getRequiredElement('page-switcher-start');
85 pageSwitcherEnd = getRequiredElement('page-switcher-end'); 85 pageSwitcherEnd = getRequiredElement('page-switcher-end');
86 } 86 }
87 this.initialize(getRequiredElement('page-list'), 87 this.initialize(getRequiredElement('page-list'),
88 getRequiredElement('dot-list'), 88 getRequiredElement('dot-list'),
89 getRequiredElement('card-slider-frame'), 89 getRequiredElement('card-slider-frame'),
90 getRequiredElement('trash'), 90 getRequiredElement('trash'),
jeremycho_google 2012/08/02 00:19:11 Add a TODO for removing these non-1993 features?
pedrosimonetti2 2012/08/03 18:14:12 Done.
91 pageSwitcherStart, pageSwitcherEnd); 91 pageSwitcherStart, pageSwitcherEnd);
92 } 92 }
93 93
94 NewTabView.prototype = { 94 NewTabView.prototype = {
95 __proto__: ntp.PageListView.prototype, 95 __proto__: ntp.PageListView.prototype,
96 96
97 /** @inheritDoc */ 97 /** @inheritDoc */
98 appendTilePage: function(page, title, titleIsEditable, opt_refNode) { 98 appendTilePage: function(page, title, titleIsEditable, opt_refNode) {
99 ntp.PageListView.prototype.appendTilePage.apply(this, arguments); 99 ntp.PageListView.prototype.appendTilePage.apply(this, arguments);
100 100
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 // The anchor node won't be updated until updateLogin is called so don't 181 // The anchor node won't be updated until updateLogin is called so don't
182 // show the bubble yet. 182 // show the bubble yet.
183 shouldShowLoginBubble = true; 183 shouldShowLoginBubble = true;
184 } 184 }
185 185
186 var loginContainer = getRequiredElement('login-container'); 186 var loginContainer = getRequiredElement('login-container');
187 loginContainer.addEventListener('click', showSyncLoginUI); 187 loginContainer.addEventListener('click', showSyncLoginUI);
188 chrome.send('initializeSyncLogin'); 188 chrome.send('initializeSyncLogin');
189 189
190 doWhenAllSectionsReady(function() { 190 doWhenAllSectionsReady(function() {
191
192 // TODO(xci) new!
193 // TODO(pedrosimonetti): find a better place to put this code. Every,
194 // card needs to call layout the first time is shown.
195 newTabView.cardSlider.currentCardValue.layout_();
196
191 // Tell the slider about the pages. 197 // Tell the slider about the pages.
192 newTabView.updateSliderCards(); 198 newTabView.updateSliderCards();
193 // Mark the current page. 199 // Mark the current page.
194 newTabView.cardSlider.currentCardValue.navigationDot.classList.add( 200 newTabView.cardSlider.currentCardValue.navigationDot.classList.add(
195 'selected'); 201 'selected');
196 202
197 if (loadTimeData.valueExists('serverpromo')) { 203 if (loadTimeData.valueExists('serverpromo')) {
198 var promo = loadTimeData.getString('serverpromo'); 204 var promo = loadTimeData.getString('serverpromo');
199 var tags = ['IMG']; 205 var tags = ['IMG'];
200 var attrs = { 206 var attrs = {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 444
439 function setMostVisitedPages(data, hasBlacklistedUrls) { 445 function setMostVisitedPages(data, hasBlacklistedUrls) {
440 newTabView.mostVisitedPage.data = data; 446 newTabView.mostVisitedPage.data = data;
441 cr.dispatchSimpleEvent(document, 'sectionready', true, true); 447 cr.dispatchSimpleEvent(document, 'sectionready', true, true);
442 } 448 }
443 449
444 function setSuggestionsPages(data, hasBlacklistedUrls) { 450 function setSuggestionsPages(data, hasBlacklistedUrls) {
445 newTabView.suggestionsPage.data = data; 451 newTabView.suggestionsPage.data = data;
446 } 452 }
447 453
454 function getThumbnailUrl(url) {
455 return 'chrome://thumb/' + url;
456 }
457
448 /** 458 /**
449 * Set the dominant color for a node. This will be called in response to 459 * Set the dominant color for a node. This will be called in response to
450 * getFaviconDominantColor. The node represented by |id| better have a setter 460 * getFaviconDominantColor. The node represented by |id| better have a setter
451 * for stripeColor. 461 * for stripeColor.
452 * @param {string} id The ID of a node. 462 * @param {string} id The ID of a node.
453 * @param {string} color The color represented as a CSS string. 463 * @param {string} color The color represented as a CSS string.
454 */ 464 */
455 function setStripeColor(id, color) { 465 function setStripeColor(id, color) {
456 var node = $(id); 466 var node = $(id);
457 if (node) 467 if (node)
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 onLoad: onLoad, 586 onLoad: onLoad,
577 leaveRearrangeMode: leaveRearrangeMode, 587 leaveRearrangeMode: leaveRearrangeMode,
578 NtpFollowAction: NtpFollowAction, 588 NtpFollowAction: NtpFollowAction,
579 saveAppPageName: saveAppPageName, 589 saveAppPageName: saveAppPageName,
580 setAppToBeHighlighted: setAppToBeHighlighted, 590 setAppToBeHighlighted: setAppToBeHighlighted,
581 setBookmarkBarAttached: setBookmarkBarAttached, 591 setBookmarkBarAttached: setBookmarkBarAttached,
582 setForeignSessions: setForeignSessions, 592 setForeignSessions: setForeignSessions,
583 setMostVisitedPages: setMostVisitedPages, 593 setMostVisitedPages: setMostVisitedPages,
584 setSuggestionsPages: setSuggestionsPages, 594 setSuggestionsPages: setSuggestionsPages,
585 setRecentlyClosedTabs: setRecentlyClosedTabs, 595 setRecentlyClosedTabs: setRecentlyClosedTabs,
596 getThumbnailUrl: getThumbnailUrl,
jeremycho_google 2012/08/02 00:19:11 alphabetize
pedrosimonetti2 2012/08/03 18:14:12 Done.
586 setStripeColor: setStripeColor, 597 setStripeColor: setStripeColor,
587 showNotification: showNotification, 598 showNotification: showNotification,
588 themeChanged: themeChanged, 599 themeChanged: themeChanged,
589 updateLogin: updateLogin 600 updateLogin: updateLogin
590 }; 601 };
591 }); 602 });
592 603
593 document.addEventListener('DOMContentLoaded', ntp.onLoad); 604 document.addEventListener('DOMContentLoaded', ntp.onLoad);
594 605
595 var toCssPx = cr.ui.toCssPx; 606 var toCssPx = cr.ui.toCssPx;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698