OLD | NEW |
---|---|
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 sectionsToWaitFor++; | 121 sectionsToWaitFor++; |
122 if (loadTimeData.getBoolean('showAppLauncherPromo')) { | 122 if (loadTimeData.getBoolean('showAppLauncherPromo')) { |
123 $('app-launcher-promo-close-button').addEventListener('click', | 123 $('app-launcher-promo-close-button').addEventListener('click', |
124 function() { chrome.send('stopShowingAppLauncherPromo'); }); | 124 function() { chrome.send('stopShowingAppLauncherPromo'); }); |
125 $('apps-promo-learn-more').addEventListener('click', | 125 $('apps-promo-learn-more').addEventListener('click', |
126 function() { chrome.send('onLearnMore'); }); | 126 function() { chrome.send('onLearnMore'); }); |
127 } | 127 } |
128 } | 128 } |
129 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) | 129 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) |
130 sectionsToWaitFor++; | 130 sectionsToWaitFor++; |
131 measureNavDots(); | 131 measureNavDots(); |
Dan Beam
2014/01/09 18:58:19
^ you could do it here
| |
132 | 132 |
133 // Load the current theme colors. | 133 // Load the current theme colors. |
134 themeChanged(); | 134 themeChanged(); |
135 | 135 |
136 newTabView = new NewTabView(); | 136 newTabView = new NewTabView(); |
137 | 137 |
138 notificationContainer = getRequiredElement('notification-container'); | 138 notificationContainer = getRequiredElement('notification-container'); |
139 notificationContainer.addEventListener( | 139 notificationContainer.addEventListener( |
140 'webkitTransitionEnd', onNotificationTransitionEnd); | 140 'webkitTransitionEnd', onNotificationTransitionEnd); |
141 | 141 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 var measuringDiv = $('fontMeasuringDiv'); | 349 var measuringDiv = $('fontMeasuringDiv'); |
350 measuringDiv.textContent = loadTimeData.getString(id); | 350 measuringDiv.textContent = loadTimeData.getString(id); |
351 // The 4 is for border and padding. | 351 // The 4 is for border and padding. |
352 return Math.max(measuringDiv.clientWidth * 1.15 + 4, 80); | 352 return Math.max(measuringDiv.clientWidth * 1.15 + 4, 80); |
353 } | 353 } |
354 | 354 |
355 /** | 355 /** |
356 * Fills in an invisible div with the longest dot title string so that | 356 * Fills in an invisible div with the longest dot title string so that |
357 * its length may be measured and the nav dots sized accordingly. | 357 * its length may be measured and the nav dots sized accordingly. |
358 */ | 358 */ |
359 function measureNavDots() { | 359 function measureNavDots() { |
Dan Beam
2014/01/09 18:58:19
or here
| |
360 var pxWidth = measureNavDot('appDefaultPageName'); | 360 var pxWidth = measureNavDot('appDefaultPageName'); |
361 if (loadTimeData.getBoolean('showMostvisited')) | 361 if (loadTimeData.getBoolean('showMostvisited')) |
362 pxWidth = Math.max(measureNavDot('mostvisited'), pxWidth); | 362 pxWidth = Math.max(measureNavDot('mostvisited'), pxWidth); |
363 | 363 |
364 var styleElement = document.createElement('style'); | 364 var styleElement = document.createElement('style'); |
365 styleElement.type = 'text/css'; | 365 styleElement.type = 'text/css'; |
366 // max-width is used because if we run out of space, the nav dots will be | 366 // max-width is used because if we run out of space, the nav dots will be |
367 // shrunk. | 367 // shrunk. |
368 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; | 368 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; |
369 document.querySelector('head').appendChild(styleElement); | 369 document.querySelector('head').appendChild(styleElement); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
702 setMostVisitedPages: setMostVisitedPages, | 702 setMostVisitedPages: setMostVisitedPages, |
703 setSuggestionsPages: setSuggestionsPages, | 703 setSuggestionsPages: setSuggestionsPages, |
704 setRecentlyClosedTabs: setRecentlyClosedTabs, | 704 setRecentlyClosedTabs: setRecentlyClosedTabs, |
705 setFaviconDominantColor: setFaviconDominantColor, | 705 setFaviconDominantColor: setFaviconDominantColor, |
706 showNotification: showNotification, | 706 showNotification: showNotification, |
707 themeChanged: themeChanged, | 707 themeChanged: themeChanged, |
708 updateLogin: updateLogin | 708 updateLogin: updateLogin |
709 }; | 709 }; |
710 }); | 710 }); |
711 | 711 |
712 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 712 document.addEventListener('DOMContentLoaded', function() { |
713 var logo = $('logo-img').querySelector('img'); | |
714 if (logo.complete) | |
715 ntp.onLoad(); | |
716 else | |
717 logo.addEventListener('load', ntp.onLoad); | |
718 }); | |
Dan Beam
2014/01/09 18:58:19
^ you should not block the whole NTP on this.
dconnelly
2014/01/10 10:46:57
Done.
| |
713 | 719 |
714 var toCssPx = cr.ui.toCssPx; | 720 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |