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

Side by Side Diff: chrome/browser/resources/new_new_tab.js

Issue 4804001: Add new promotional line for NTP.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // To avoid creating tons of unnecessary nodes. We assume we cannot fit more 5 // To avoid creating tons of unnecessary nodes. We assume we cannot fit more
6 // than this many items in the miniview. 6 // than this many items in the miniview.
7 var MAX_MINIVIEW_ITEMS = 15; 7 var MAX_MINIVIEW_ITEMS = 15;
8 8
9 // Extra spacing at the top of the layout. 9 // Extra spacing at the top of the layout.
10 var LAYOUT_SPACING_TOP = 25; 10 var LAYOUT_SPACING_TOP = 25;
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 807
808 function delayedHide() { 808 function delayedHide() {
809 notificationTimeout = window.setTimeout(hideNotification, delay); 809 notificationTimeout = window.setTimeout(hideNotification, delay);
810 } 810 }
811 811
812 function doAction() { 812 function doAction() {
813 f(); 813 f();
814 hideNotification(); 814 hideNotification();
815 } 815 }
816 816
817 // Remove any possible first-run trails. 817 // Remove classList entries from previous notifications.
818 notification.classList.remove('first-run'); 818 notification.classList.remove('first-run');
819 notification.classList.remove('promo');
820
821 var notificationNode = notificationElement.firstElementChild;
822 notificationNode.removeChild(notificationNode.firstChild);
819 823
820 var actionLink = notificationElement.querySelector('.link-color'); 824 var actionLink = notificationElement.querySelector('.link-color');
821 notificationElement.firstElementChild.textContent = text; 825 notificationElement.firstElementChild.appendChild(parseHtmlSubset(text));
arv (Not doing code reviews) 2010/11/24 00:02:43 I would prefer if the parsing could be done outsid
Miranda Callahan 2010/11/24 00:39:41 Done.
826
822 actionLink.textContent = actionText; 827 actionLink.textContent = actionText;
823 828
824 actionLink.onclick = doAction; 829 actionLink.onclick = doAction;
825 actionLink.onkeydown = handleIfEnterKey(doAction); 830 actionLink.onkeydown = handleIfEnterKey(doAction);
826 notificationElement.onmouseover = show; 831 notificationElement.onmouseover = show;
827 notificationElement.onmouseout = delayedHide; 832 notificationElement.onmouseout = delayedHide;
828 actionLink.onfocus = show; 833 actionLink.onfocus = show;
829 actionLink.onblur = delayedHide; 834 actionLink.onblur = delayedHide;
830 // Enable tabbing to the link now that it is shown. 835 // Enable tabbing to the link now that it is shown.
831 actionLink.tabIndex = 0; 836 actionLink.tabIndex = 0;
(...skipping 20 matching lines...) Expand all
852 } 857 }
853 858
854 function showFirstRunNotification() { 859 function showFirstRunNotification() {
855 showNotification(localStrings.getString('firstrunnotification'), 860 showNotification(localStrings.getString('firstrunnotification'),
856 localStrings.getString('closefirstrunnotification'), 861 localStrings.getString('closefirstrunnotification'),
857 null, 30000); 862 null, 30000);
858 var notificationElement = $('notification'); 863 var notificationElement = $('notification');
859 notification.classList.add('first-run'); 864 notification.classList.add('first-run');
860 } 865 }
861 866
867 function showPromoNotification() {
868 showNotification(localStrings.getString('serverpromo'),
869 localStrings.getString('closefirstrunnotification'),
870 function () { chrome.send('closePromo'); },
871 60000);
872 var notificationElement = $('notification');
873 notification.classList.add('promo');
874 }
875
862 $('main').addEventListener('click', function(e) { 876 $('main').addEventListener('click', function(e) {
863 var p = e.target; 877 var p = e.target;
864 while (p && p.tagName != 'H2') { 878 while (p && p.tagName != 'H2') {
865 // In case the user clicks on a button we do not want to expand/collapse a 879 // In case the user clicks on a button we do not want to expand/collapse a
866 // section. 880 // section.
867 if (p.tagName == 'BUTTON') 881 if (p.tagName == 'BUTTON')
868 return; 882 return;
869 p = p.parentNode; 883 p = p.parentNode;
870 } 884 }
871 885
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 // Remove class name in a timeout so that changes done in this JS thread are 1197 // Remove class name in a timeout so that changes done in this JS thread are
1184 // not animated. 1198 // not animated.
1185 window.setTimeout(function() { 1199 window.setTimeout(function() {
1186 mostVisited.ensureSmallGridCorrect(); 1200 mostVisited.ensureSmallGridCorrect();
1187 maybeDoneLoading(); 1201 maybeDoneLoading();
1188 }, 1); 1202 }, 1);
1189 1203
1190 // Only show the first run notification if first run. 1204 // Only show the first run notification if first run.
1191 if (firstRun) { 1205 if (firstRun) {
1192 showFirstRunNotification(); 1206 showFirstRunNotification();
1207 } else if (localStrings.getString('serverpromo')) {
1208 showPromoNotification();
1193 } 1209 }
1194 } 1210 }
1195 1211
1196 function maybeDoneLoading() { 1212 function maybeDoneLoading() {
1197 if (mostVisited.data && apps.loaded) 1213 if (mostVisited.data && apps.loaded)
1198 document.body.classList.remove('loading'); 1214 document.body.classList.remove('loading');
1199 } 1215 }
1200 1216
1201 function isDoneLoading() { 1217 function isDoneLoading() {
1202 return !document.body.classList.contains('loading'); 1218 return !document.body.classList.contains('loading');
1203 } 1219 }
1204 1220
1205 // Initialize the apps promo. 1221 // Initialize the apps promo.
1206 document.addEventListener('DOMContentLoaded', function() { 1222 document.addEventListener('DOMContentLoaded', function() {
1207 var promoText1 = $('apps-promo-text1'); 1223 var promoText1 = $('apps-promo-text1');
1208 promoText1.innerHTML = promoText1.textContent; 1224 promoText1.innerHTML = promoText1.textContent;
1209 1225
1210 var promoLink = promoText1.querySelector('a'); 1226 var promoLink = promoText1.querySelector('a');
1211 promoLink.id = 'apps-promo-link'; 1227 promoLink.id = 'apps-promo-link';
1212 promoLink.href = localStrings.getString('web_store_url'); 1228 promoLink.href = localStrings.getString('web_store_url');
1213 1229
1214 $('apps-promo-hide').addEventListener('click', function() { 1230 $('apps-promo-hide').addEventListener('click', function() {
1215 chrome.send('hideAppsPromo', []); 1231 chrome.send('hideAppsPromo', []);
1216 document.documentElement.classList.remove('apps-promo-visible'); 1232 document.documentElement.classList.remove('apps-promo-visible');
1217 layoutSections(); 1233 layoutSections();
1218 }); 1234 });
1219 }); 1235 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698