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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 } | 119 } |
120 | 120 |
121 /** | 121 /** |
122 * Invoked at startup once the DOM is available to initialize the app. | 122 * Invoked at startup once the DOM is available to initialize the app. |
123 */ | 123 */ |
124 function onLoad() { | 124 function onLoad() { |
125 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1; | 125 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1; |
126 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) | 126 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) |
127 sectionsToWaitFor++; | 127 sectionsToWaitFor++; |
128 measureNavDots(); | 128 measureNavDots(); |
129 layoutFooter(); | |
129 | 130 |
130 // Load the current theme colors. | 131 // Load the current theme colors. |
131 themeChanged(); | 132 themeChanged(); |
132 | 133 |
133 newTabView = new NewTabView(); | 134 newTabView = new NewTabView(); |
134 | 135 |
135 notificationContainer = getRequiredElement('notification-container'); | 136 notificationContainer = getRequiredElement('notification-container'); |
136 notificationContainer.addEventListener( | 137 notificationContainer.addEventListener( |
137 'webkitTransitionEnd', onNotificationTransitionEnd); | 138 'webkitTransitionEnd', onNotificationTransitionEnd); |
138 | 139 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 var pxWidth = Math.max(measuringDiv.clientWidth * 1.15 + 4, 80); | 328 var pxWidth = Math.max(measuringDiv.clientWidth * 1.15 + 4, 80); |
328 | 329 |
329 var styleElement = document.createElement('style'); | 330 var styleElement = document.createElement('style'); |
330 styleElement.type = 'text/css'; | 331 styleElement.type = 'text/css'; |
331 // max-width is used because if we run out of space, the nav dots will be | 332 // max-width is used because if we run out of space, the nav dots will be |
332 // shrunk. | 333 // shrunk. |
333 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; | 334 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; |
334 document.querySelector('head').appendChild(styleElement); | 335 document.querySelector('head').appendChild(styleElement); |
335 } | 336 } |
336 | 337 |
338 /** | |
339 * Layout the footer so that the nav dots stay centered. | |
340 */ | |
341 function layoutFooter() { | |
342 var menu = $('footer-menu-container'); | |
343 var logo = $('logo-img'); | |
344 if (menu.clientWidth > logo.clientWidth) | |
345 logo.style.width = menu.clientWidth + 'px'; | |
Dan Beam
2013/01/31 20:22:11
this shouldn't be necessary and can be done in CSS
dconnelly
2013/02/01 14:34:14
Continuing from the previous comment, even with th
| |
346 } | |
347 | |
337 function themeChanged(opt_hasAttribution) { | 348 function themeChanged(opt_hasAttribution) { |
338 $('themecss').href = 'chrome://theme/css/new_tab_theme.css?' + Date.now(); | 349 $('themecss').href = 'chrome://theme/css/new_tab_theme.css?' + Date.now(); |
339 | 350 |
340 if (typeof opt_hasAttribution != 'undefined') { | 351 if (typeof opt_hasAttribution != 'undefined') { |
341 document.documentElement.setAttribute('hasattribution', | 352 document.documentElement.setAttribute('hasattribution', |
342 opt_hasAttribution); | 353 opt_hasAttribution); |
343 } | 354 } |
344 | 355 |
345 updateAttribution(); | 356 updateAttribution(); |
346 } | 357 } |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 themeChanged: themeChanged, | 663 themeChanged: themeChanged, |
653 updateLogin: updateLogin | 664 updateLogin: updateLogin |
654 }; | 665 }; |
655 }); | 666 }); |
656 | 667 |
657 // This will end up calling ntp.gotShouldShowApps. | 668 // This will end up calling ntp.gotShouldShowApps. |
658 chrome.send('getShouldShowApps'); | 669 chrome.send('getShouldShowApps'); |
659 document.addEventListener('DOMContentLoaded', ntp.onLoad); | 670 document.addEventListener('DOMContentLoaded', ntp.onLoad); |
660 | 671 |
661 var toCssPx = cr.ui.toCssPx; | 672 var toCssPx = cr.ui.toCssPx; |
OLD | NEW |