| 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 /** | 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 // This will end up calling ntp.gotShouldShowApps. | 125 // This will end up calling ntp.gotShouldShowApps. |
| 126 chrome.send('getShouldShowApps'); | 126 chrome.send('getShouldShowApps'); |
| 127 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1; | 127 sectionsToWaitFor = loadTimeData.getBoolean('showApps') ? 2 : 1; |
| 128 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) | 128 if (loadTimeData.getBoolean('isDiscoveryInNTPEnabled')) |
| 129 sectionsToWaitFor++; | 129 sectionsToWaitFor++; |
| 130 measureNavDots(); | 130 measureNavDots(); |
| 131 layoutFooter(); |
| 131 | 132 |
| 132 // Load the current theme colors. | 133 // Load the current theme colors. |
| 133 themeChanged(); | 134 themeChanged(); |
| 134 | 135 |
| 135 newTabView = new NewTabView(); | 136 newTabView = new NewTabView(); |
| 136 | 137 |
| 137 notificationContainer = getRequiredElement('notification-container'); | 138 notificationContainer = getRequiredElement('notification-container'); |
| 138 notificationContainer.addEventListener( | 139 notificationContainer.addEventListener( |
| 139 'webkitTransitionEnd', onNotificationTransitionEnd); | 140 'webkitTransitionEnd', onNotificationTransitionEnd); |
| 140 | 141 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 var pxWidth = Math.max(measuringDiv.clientWidth * 1.15 + 4, 80); | 330 var pxWidth = Math.max(measuringDiv.clientWidth * 1.15 + 4, 80); |
| 330 | 331 |
| 331 var styleElement = document.createElement('style'); | 332 var styleElement = document.createElement('style'); |
| 332 styleElement.type = 'text/css'; | 333 styleElement.type = 'text/css'; |
| 333 // max-width is used because if we run out of space, the nav dots will be | 334 // max-width is used because if we run out of space, the nav dots will be |
| 334 // shrunk. | 335 // shrunk. |
| 335 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; | 336 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; |
| 336 document.querySelector('head').appendChild(styleElement); | 337 document.querySelector('head').appendChild(styleElement); |
| 337 } | 338 } |
| 338 | 339 |
| 340 /** |
| 341 * Layout the footer so that the nav dots stay centered. |
| 342 */ |
| 343 function layoutFooter() { |
| 344 var menu = $('footer-menu-container'); |
| 345 var logo = $('logo-img'); |
| 346 if (menu.clientWidth > logo.clientWidth) |
| 347 logo.style.width = menu.clientWidth + 'px'; |
| 348 } |
| 349 |
| 339 function themeChanged(opt_hasAttribution) { | 350 function themeChanged(opt_hasAttribution) { |
| 340 $('themecss').href = 'chrome://theme/css/new_tab_theme.css?' + Date.now(); | 351 $('themecss').href = 'chrome://theme/css/new_tab_theme.css?' + Date.now(); |
| 341 | 352 |
| 342 if (typeof opt_hasAttribution != 'undefined') { | 353 if (typeof opt_hasAttribution != 'undefined') { |
| 343 document.documentElement.setAttribute('hasattribution', | 354 document.documentElement.setAttribute('hasattribution', |
| 344 opt_hasAttribution); | 355 opt_hasAttribution); |
| 345 } | 356 } |
| 346 | 357 |
| 347 updateAttribution(); | 358 updateAttribution(); |
| 348 } | 359 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 setFaviconDominantColor: setFaviconDominantColor, | 663 setFaviconDominantColor: setFaviconDominantColor, |
| 653 showNotification: showNotification, | 664 showNotification: showNotification, |
| 654 themeChanged: themeChanged, | 665 themeChanged: themeChanged, |
| 655 updateLogin: updateLogin | 666 updateLogin: updateLogin |
| 656 }; | 667 }; |
| 657 }); | 668 }); |
| 658 | 669 |
| 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 |