Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/resources/ntp_search/new_tab.js

Issue 10907065: NTP5: Fix page blacklisting and remove recently closed tabs when they're clicked. Fix the styling … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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. NewTabView manages page list, dot list, switcher buttons and 8 * browsers. NewTabView manages page list, dot list, switcher buttons and
9 * handles apps pages callbacks from backend. 9 * handles apps pages callbacks from backend.
10 * 10 *
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 function closeFunc(e) { 936 function closeFunc(e) {
937 if (opt_closeHandler) 937 if (opt_closeHandler)
938 opt_closeHandler(); 938 opt_closeHandler();
939 hideNotification(); 939 hideNotification();
940 } 940 }
941 941
942 document.querySelector('#notification button').onclick = closeFunc; 942 document.querySelector('#notification button').onclick = closeFunc;
943 document.addEventListener('dragstart', closeFunc); 943 document.addEventListener('dragstart', closeFunc);
944 944
945 notificationContainer.hidden = false; 945 notificationContainer.hidden = false;
946 showNotificationOnCurrentPage(); 946 window.setTimeout(function() {
947 947 notificationContainer.classList.remove('inactive');
948 newTabView.cardSlider.frame.addEventListener( 948 }, 0);
949 'cardSlider:card_change_ended', onCardChangeEnded);
950 949
951 var timeout = opt_timeout || 10000; 950 var timeout = opt_timeout || 10000;
952 notificationTimeout = window.setTimeout(hideNotification, timeout); 951 notificationTimeout = window.setTimeout(hideNotification, timeout);
953 } 952 }
954 953
955 /** 954 /**
956 * Hide the notification bubble. 955 * Hide the notification bubble.
957 */ 956 */
958 function hideNotification() { 957 function hideNotification() {
959 notificationContainer.classList.add('inactive'); 958 notificationContainer.classList.add('inactive');
960
961 newTabView.cardSlider.frame.removeEventListener(
962 'cardSlider:card_change_ended', onCardChangeEnded);
963 } 959 }
964 960
965 /** 961 /**
966 * Happens when 1 or more consecutive card changes end.
967 * @param {Event} e The cardSlider:card_change_ended event.
968 */
969 function onCardChangeEnded(e) {
970 // If we ended on the same page as we started, ignore.
971 if (newTabView.cardSlider.currentCardValue.notification)
972 return;
973
974 // Hide the notification the old page.
975 notificationContainer.classList.add('card-changed');
976
977 showNotificationOnCurrentPage();
978 }
979
980 /**
981 * Move and show the notification on the current page.
982 */
983 function showNotificationOnCurrentPage() {
984 var page = newTabView.cardSlider.currentCardValue;
985 doWhenAllSectionsReady(function() {
986 if (page != newTabView.cardSlider.currentCardValue)
987 return;
988
989 // NOTE: This moves the notification to inside of the current page.
990 page.notification = notificationContainer;
991
992 // Reveal the notification and instruct it to hide itself if ignored.
993 notificationContainer.classList.remove('inactive');
994
995 // Gives the browser time to apply this rule before we remove it (causing
996 // a transition).
997 window.setTimeout(function() {
998 notificationContainer.classList.remove('card-changed');
999 }, 0);
1000 });
1001 }
1002
1003 /**
1004 * When done fading out, set hidden to true so the notification can't be 962 * When done fading out, set hidden to true so the notification can't be
1005 * tabbed to or clicked. 963 * tabbed to or clicked.
1006 * @param {Event} e The webkitTransitionEnd event. 964 * @param {Event} e The webkitTransitionEnd event.
1007 */ 965 */
1008 function onNotificationTransitionEnd(e) { 966 function onNotificationTransitionEnd(e) {
1009 if (notificationContainer.classList.contains('inactive')) 967 if (notificationContainer.classList.contains('inactive'))
1010 notificationContainer.hidden = true; 968 notificationContainer.hidden = true;
1011 } 969 }
1012 970
1013 function setRecentlyClosedTabs(data) { 971 function setRecentlyClosedTabs(data) {
1014 newTabView.recentlyClosedPage.data = data; 972 newTabView.recentlyClosedPage.setData(data);
1015 } 973 }
1016 974
1017 function setMostVisitedPages(data, hasBlacklistedUrls) { 975 function setMostVisitedPages(data, hasBlacklistedUrls) {
1018 newTabView.mostVisitedPage.data = data; 976 newTabView.mostVisitedPage.setData(data);
1019 cr.dispatchSimpleEvent(document, 'sectionready', true, true); 977 cr.dispatchSimpleEvent(document, 'sectionready', true, true);
1020 } 978 }
1021 979
1022 function getThumbnailUrl(url) { 980 function getThumbnailUrl(url) {
1023 return 'chrome://thumb/' + url; 981 return 'chrome://thumb/' + url;
1024 } 982 }
1025 983
1026 /** 984 /**
1027 * Updates the text displayed in the login container. If there is no text then 985 * Updates the text displayed in the login container. If there is no text then
1028 * the login container is hidden. 986 * the login container is hidden.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 setRecentlyClosedTabs: setRecentlyClosedTabs, 1093 setRecentlyClosedTabs: setRecentlyClosedTabs,
1136 showNotification: showNotification, 1094 showNotification: showNotification,
1137 themeChanged: themeChanged, 1095 themeChanged: themeChanged,
1138 updateLogin: updateLogin 1096 updateLogin: updateLogin
1139 }; 1097 };
1140 }); 1098 });
1141 1099
1142 document.addEventListener('DOMContentLoaded', ntp.onLoad); 1100 document.addEventListener('DOMContentLoaded', ntp.onLoad);
1143 1101
1144 var toCssPx = cr.ui.toCssPx; 1102 var toCssPx = cr.ui.toCssPx;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698