OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 */ | 49 */ |
50 var bookmarksPage; | 50 var bookmarksPage; |
51 | 51 |
52 /** | 52 /** |
53 * The 'dots-list' element. | 53 * The 'dots-list' element. |
54 * @type {!Element|undefined} | 54 * @type {!Element|undefined} |
55 */ | 55 */ |
56 var dotList; | 56 var dotList; |
57 | 57 |
58 /** | 58 /** |
| 59 * The 'notification-container' element. |
| 60 * @type {!Element|undefined} |
| 61 */ |
| 62 var notificationContainer; |
| 63 |
| 64 /** |
59 * The left and right paging buttons. | 65 * The left and right paging buttons. |
60 * @type {!Element|undefined} | 66 * @type {!Element|undefined} |
61 */ | 67 */ |
62 var pageSwitcherStart; | 68 var pageSwitcherStart; |
63 var pageSwitcherEnd; | 69 var pageSwitcherEnd; |
64 | 70 |
65 /** | 71 /** |
66 * The 'trash' element. Note that technically this is unnecessary, | 72 * The 'trash' element. Note that technically this is unnecessary, |
67 * JavaScript creates the object for us based on the id. But I don't want | 73 * JavaScript creates the object for us based on the id. But I don't want |
68 * to rely on the ID being the same, and JSCompiler doesn't know about it. | 74 * to rely on the ID being the same, and JSCompiler doesn't know about it. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 }, true); | 154 }, true); |
149 | 155 |
150 tilePages = pageList.getElementsByClassName('tile-page'); | 156 tilePages = pageList.getElementsByClassName('tile-page'); |
151 appsPages = pageList.getElementsByClassName('apps-page'); | 157 appsPages = pageList.getElementsByClassName('apps-page'); |
152 | 158 |
153 pageSwitcherStart = getRequiredElement('page-switcher-start'); | 159 pageSwitcherStart = getRequiredElement('page-switcher-start'); |
154 ntp4.initializePageSwitcher(pageSwitcherStart); | 160 ntp4.initializePageSwitcher(pageSwitcherStart); |
155 pageSwitcherEnd = getRequiredElement('page-switcher-end'); | 161 pageSwitcherEnd = getRequiredElement('page-switcher-end'); |
156 ntp4.initializePageSwitcher(pageSwitcherEnd); | 162 ntp4.initializePageSwitcher(pageSwitcherEnd); |
157 | 163 |
| 164 notificationContainer = getRequiredElement('notification-container'); |
| 165 notificationContainer.addEventListener( |
| 166 'webkitTransitionEnd', onNotificationTransitionEnd); |
| 167 |
158 // Initialize the cardSlider without any cards at the moment | 168 // Initialize the cardSlider without any cards at the moment |
159 var sliderFrame = getRequiredElement('card-slider-frame'); | 169 var sliderFrame = getRequiredElement('card-slider-frame'); |
160 cardSlider = new CardSlider(sliderFrame, pageList, sliderFrame.offsetWidth); | 170 cardSlider = new CardSlider(sliderFrame, pageList, sliderFrame.offsetWidth); |
161 cardSlider.initialize(); | 171 cardSlider.initialize(); |
162 | 172 |
163 // Ensure the slider is resized appropriately with the window | 173 // Ensure the slider is resized appropriately with the window |
164 window.addEventListener('resize', function() { | 174 window.addEventListener('resize', function() { |
165 cardSlider.resize(sliderFrame.offsetWidth); | 175 cardSlider.resize(sliderFrame.offsetWidth); |
166 updatePageSwitchers(); | 176 updatePageSwitchers(); |
167 }); | 177 }); |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 linksBin.appendChild(link); | 714 linksBin.appendChild(link); |
705 } | 715 } |
706 | 716 |
707 document.querySelector('#notification button').onclick = function(e) { | 717 document.querySelector('#notification button').onclick = function(e) { |
708 if (opt_closeHandler) | 718 if (opt_closeHandler) |
709 opt_closeHandler(); | 719 opt_closeHandler(); |
710 hideNotification(); | 720 hideNotification(); |
711 }; | 721 }; |
712 | 722 |
713 var timeout = opt_timeout || 10000; | 723 var timeout = opt_timeout || 10000; |
714 $('notification').classList.remove('inactive'); | 724 notificationContainer.hidden = false; |
| 725 notificationContainer.classList.remove('inactive'); |
715 notificationTimeout_ = window.setTimeout(hideNotification, timeout); | 726 notificationTimeout_ = window.setTimeout(hideNotification, timeout); |
716 } | 727 } |
717 | 728 |
718 /** | 729 /** |
719 * Hide the notification bubble. | 730 * Hide the notification bubble. |
720 */ | 731 */ |
721 function hideNotification() { | 732 function hideNotification() { |
722 $('notification').classList.add('inactive'); | 733 notificationContainer.classList.add('inactive'); |
| 734 } |
| 735 |
| 736 /** |
| 737 * When done fading out, set hidden to true so the notification can't be |
| 738 * tabbed to or clicked. |
| 739 */ |
| 740 function onNotificationTransitionEnd(e) { |
| 741 if (notificationContainer.classList.contains('inactive')); |
| 742 notificationContainer.hidden = true; |
723 } | 743 } |
724 | 744 |
725 function setRecentlyClosedTabs(dataItems) { | 745 function setRecentlyClosedTabs(dataItems) { |
726 $('recently-closed-menu-button').dataItems = dataItems; | 746 $('recently-closed-menu-button').dataItems = dataItems; |
727 } | 747 } |
728 | 748 |
729 function setMostVisitedPages(data, hasBlacklistedUrls) { | 749 function setMostVisitedPages(data, hasBlacklistedUrls) { |
730 mostVisitedPage.data = data; | 750 mostVisitedPage.data = data; |
731 } | 751 } |
732 | 752 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 var assert = ntp4.assert; | 853 var assert = ntp4.assert; |
834 var getAppsCallback = ntp4.getAppsCallback; | 854 var getAppsCallback = ntp4.getAppsCallback; |
835 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; | 855 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; |
836 var themeChanged = ntp4.themeChanged; | 856 var themeChanged = ntp4.themeChanged; |
837 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; | 857 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; |
838 var setMostVisitedPages = ntp4.setMostVisitedPages; | 858 var setMostVisitedPages = ntp4.setMostVisitedPages; |
839 | 859 |
840 document.addEventListener('DOMContentLoaded', ntp4.initialize); | 860 document.addEventListener('DOMContentLoaded', ntp4.initialize); |
841 window.addEventListener('online', ntp4.updateOfflineEnabledApps); | 861 window.addEventListener('online', ntp4.updateOfflineEnabledApps); |
842 window.addEventListener('offline', ntp4.updateOfflineEnabledApps); | 862 window.addEventListener('offline', ntp4.updateOfflineEnabledApps); |
OLD | NEW |