| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 var pxWidth = Math.max(measuringDiv.clientWidth * 1.15, 80); | 254 var pxWidth = Math.max(measuringDiv.clientWidth * 1.15, 80); |
| 255 | 255 |
| 256 var styleElement = document.createElement('style'); | 256 var styleElement = document.createElement('style'); |
| 257 styleElement.type = 'text/css'; | 257 styleElement.type = 'text/css'; |
| 258 // max-width is used because if we run out of space, the nav dots will be | 258 // max-width is used because if we run out of space, the nav dots will be |
| 259 // shrunk. | 259 // shrunk. |
| 260 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; | 260 styleElement.textContent = '.dot { max-width: ' + pxWidth + 'px; }'; |
| 261 document.querySelector('head').appendChild(styleElement); | 261 document.querySelector('head').appendChild(styleElement); |
| 262 } | 262 } |
| 263 | 263 |
| 264 // TODO(estade): rename newtab.css to new_tab_theme.css | 264 function themeChanged(opt_hasAttribution) { |
| 265 function themeChanged(hasAttribution) { | 265 $('themecss').href = 'chrome://theme/css/new_tab_theme.css?' + Date.now(); |
| 266 $('themecss').href = 'chrome://theme/css/newtab.css?' + Date.now(); | 266 |
| 267 if (typeof hasAttribution != 'undefined') | 267 if (typeof opt_hasAttribution != 'undefined') { |
| 268 document.documentElement.setAttribute('hasattribution', hasAttribution); | 268 document.documentElement.setAttribute('hasattribution', |
| 269 opt_hasAttribution); |
| 270 } |
| 271 |
| 269 updateLogo(); | 272 updateLogo(); |
| 270 updateAttribution(); | 273 updateAttribution(); |
| 271 } | 274 } |
| 272 | 275 |
| 276 function setBookmarkBarAttached(attached) { |
| 277 document.documentElement.setAttribute('bookmarkbarattached', attached); |
| 278 } |
| 279 |
| 273 /** | 280 /** |
| 274 * Sets the proper image for the logo at the bottom left. | 281 * Sets the proper image for the logo at the bottom left. |
| 275 */ | 282 */ |
| 276 function updateLogo() { | 283 function updateLogo() { |
| 277 var imageId = 'IDR_PRODUCT_LOGO'; | 284 var imageId = 'IDR_PRODUCT_LOGO'; |
| 278 if (document.documentElement.getAttribute('customlogo') == 'true') | 285 if (document.documentElement.getAttribute('customlogo') == 'true') |
| 279 imageId = 'IDR_CUSTOM_PRODUCT_LOGO'; | 286 imageId = 'IDR_CUSTOM_PRODUCT_LOGO'; |
| 280 | 287 |
| 281 $('logo-img').src = 'chrome://theme/' + imageId + '?' + Date.now(); | 288 $('logo-img').src = 'chrome://theme/' + imageId + '?' + Date.now(); |
| 282 } | 289 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 appRemoved: appRemoved, | 539 appRemoved: appRemoved, |
| 533 appsPrefChangeCallback: appsPrefChangeCallback, | 540 appsPrefChangeCallback: appsPrefChangeCallback, |
| 534 enterRearrangeMode: enterRearrangeMode, | 541 enterRearrangeMode: enterRearrangeMode, |
| 535 getAppsCallback: getAppsCallback, | 542 getAppsCallback: getAppsCallback, |
| 536 getAppsPageIndex: getAppsPageIndex, | 543 getAppsPageIndex: getAppsPageIndex, |
| 537 getCardSlider: getCardSlider, | 544 getCardSlider: getCardSlider, |
| 538 onLoad: onLoad, | 545 onLoad: onLoad, |
| 539 leaveRearrangeMode: leaveRearrangeMode, | 546 leaveRearrangeMode: leaveRearrangeMode, |
| 540 saveAppPageName: saveAppPageName, | 547 saveAppPageName: saveAppPageName, |
| 541 setAppToBeHighlighted: setAppToBeHighlighted, | 548 setAppToBeHighlighted: setAppToBeHighlighted, |
| 549 setBookmarkBarAttached: setBookmarkBarAttached, |
| 542 setMostVisitedPages: setMostVisitedPages, | 550 setMostVisitedPages: setMostVisitedPages, |
| 543 setRecentlyClosedTabs: setRecentlyClosedTabs, | 551 setRecentlyClosedTabs: setRecentlyClosedTabs, |
| 544 setStripeColor: setStripeColor, | 552 setStripeColor: setStripeColor, |
| 545 showNotification: showNotification, | 553 showNotification: showNotification, |
| 546 themeChanged: themeChanged, | 554 themeChanged: themeChanged, |
| 547 updateLogin: updateLogin | 555 updateLogin: updateLogin |
| 548 }; | 556 }; |
| 549 }); | 557 }); |
| 550 | 558 |
| 551 // publish ntp globals | 559 // publish ntp globals |
| 552 // TODO(estade): update the content handlers to use ntp namespace instead of | 560 // TODO(estade): update the content handlers to use ntp namespace instead of |
| 553 // making these global. | 561 // making these global. |
| 554 var getAppsCallback = ntp4.getAppsCallback; | 562 var getAppsCallback = ntp4.getAppsCallback; |
| 555 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; | 563 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; |
| 556 var themeChanged = ntp4.themeChanged; | 564 var themeChanged = ntp4.themeChanged; |
| 557 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; | 565 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; |
| 558 var setMostVisitedPages = ntp4.setMostVisitedPages; | 566 var setMostVisitedPages = ntp4.setMostVisitedPages; |
| 559 var updateLogin = ntp4.updateLogin; | 567 var updateLogin = ntp4.updateLogin; |
| 560 | 568 |
| 561 document.addEventListener('DOMContentLoaded', ntp4.onLoad); | 569 document.addEventListener('DOMContentLoaded', ntp4.onLoad); |
| OLD | NEW |