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

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

Issue 6825052: Update the web store promo to be clearer and configurable at run-time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate Aaron's feedback. Created 9 years, 8 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
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | chrome/browser/resources/ntp/apps.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 span.appendChild(a); 80 span.appendChild(a);
81 menu.appendChild(span); 81 menu.appendChild(span);
82 } 82 }
83 83
84 function addClosedMenuEntry(menu, url, title, imageUrl, opt_pingUrl) { 84 function addClosedMenuEntry(menu, url, title, imageUrl, opt_pingUrl) {
85 var a = document.createElement('a'); 85 var a = document.createElement('a');
86 a.href = url; 86 a.href = url;
87 a.textContent = title; 87 a.textContent = title;
88 a.style.backgroundImage = 'url(' + imageUrl + ')'; 88 a.style.backgroundImage = 'url(' + imageUrl + ')';
89 if (opt_pingUrl) 89 if (opt_pingUrl)
90 a.setAttribute('ping', opt_pingUrl); 90 a.ping = opt_pingUrl;
91 addClosedMenuEntryWithLink(menu, a); 91 addClosedMenuEntryWithLink(menu, a);
92 } 92 }
93 93
94 function addClosedMenuFooter(menu, sectionId, mask, opt_section) { 94 function addClosedMenuFooter(menu, sectionId, mask, opt_section) {
95 menu.appendChild(document.createElement('hr')); 95 menu.appendChild(document.createElement('hr'));
96 96
97 var span = document.createElement('span'); 97 var span = document.createElement('span');
98 var a = span.appendChild(document.createElement('a')); 98 var a = span.appendChild(document.createElement('a'));
99 a.href = ''; 99 a.href = '';
100 if (cr.isChromeOS) { 100 if (cr.isChromeOS) {
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if (isWindow) { 280 if (isWindow) {
281 el = document.createElement('span'); 281 el = document.createElement('span');
282 el.className = 'item link window'; 282 el.className = 'item link window';
283 el.tabItems = data.tabs; 283 el.tabItems = data.tabs;
284 el.tabIndex = 0; 284 el.tabIndex = 0;
285 el.textContent = formatTabsText(data.tabs.length); 285 el.textContent = formatTabsText(data.tabs.length);
286 } else { 286 } else {
287 el = document.createElement('a'); 287 el = document.createElement('a');
288 el.className = 'item'; 288 el.className = 'item';
289 el.href = data.url; 289 el.href = data.url;
290 el.setAttribute('ping', 290 el.ping = getAppPingUrl(
291 getAppPingUrl('PING_BY_URL', data.url, 'NTP_RECENTLY_CLOSED')); 291 'PING_BY_URL', data.url, 'NTP_RECENTLY_CLOSED');
292 el.style.backgroundImage = url('chrome://favicon/' + data.url); 292 el.style.backgroundImage = url('chrome://favicon/' + data.url);
293 el.dir = data.direction; 293 el.dir = data.direction;
294 el.textContent = data.title; 294 el.textContent = data.title;
295 } 295 }
296 el.sessionId = data.sessionId; 296 el.sessionId = data.sessionId;
297 el.xtitle = data.title; 297 el.xtitle = data.title;
298 el.sessionTag = data.sessionTag; 298 el.sessionTag = data.sessionTag;
299 var wrapperEl = document.createElement('span'); 299 var wrapperEl = document.createElement('span');
300 wrapperEl.appendChild(el); 300 wrapperEl.appendChild(el);
301 return wrapperEl; 301 return wrapperEl;
302 } 302 }
303 303
304 function addRecentMenuItem(menu, data) { 304 function addRecentMenuItem(menu, data) {
305 var isWindow = data.type == 'window'; 305 var isWindow = data.type == 'window';
306 var a = document.createElement('a'); 306 var a = document.createElement('a');
307 if (isWindow) { 307 if (isWindow) {
308 a.textContent = formatTabsText(data.tabs.length); 308 a.textContent = formatTabsText(data.tabs.length);
309 a.className = 'window'; // To get the icon from the CSS .window rule. 309 a.className = 'window'; // To get the icon from the CSS .window rule.
310 a.href = ''; // To make underline show up. 310 a.href = ''; // To make underline show up.
311 } else { 311 } else {
312 a.href = data.url; 312 a.href = data.url;
313 a.setAttribute('ping', 313 a.ping = getAppPingUrl(
314 getAppPingUrl('PING_BY_URL', data.url, 'NTP_RECENTLY_CLOSED')); 314 'PING_BY_URL', data.url, 'NTP_RECENTLY_CLOSED');
315 a.style.backgroundImage = 'url(chrome://favicon/' + data.url + ')'; 315 a.style.backgroundImage = 'url(chrome://favicon/' + data.url + ')';
316 a.textContent = data.title; 316 a.textContent = data.title;
317 } 317 }
318 function clickHandler(e) { 318 function clickHandler(e) {
319 chrome.send('reopenTab', [String(data.sessionId)]); 319 chrome.send('reopenTab', [String(data.sessionId)]);
320 e.preventDefault(); 320 e.preventDefault();
321 } 321 }
322 a.addEventListener('click', clickHandler); 322 a.addEventListener('click', clickHandler);
323 addClosedMenuEntryWithLink(menu, a); 323 addClosedMenuEntryWithLink(menu, a);
324 } 324 }
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 if (actionLink) { 1069 if (actionLink) {
1070 actionLink.tabIndex = -1; 1070 actionLink.tabIndex = -1;
1071 actionLink.blur(); 1071 actionLink.blur();
1072 } 1072 }
1073 if (closeButton) { 1073 if (closeButton) {
1074 closeButton.tabIndex = -1; 1074 closeButton.tabIndex = -1;
1075 closeButton.blur(); 1075 closeButton.blur();
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 function showFirstRunNotification() {
1080 showNotification(localStrings.getString('firstrunnotification'),
1081 null, null, 30000);
1082 var notificationElement = $('notification');
1083 notification.classList.add('first-run');
1084 }
1085
1086 function showPromoNotification() { 1079 function showPromoNotification() {
1087 showNotification(parseHtmlSubset(localStrings.getString('serverpromo')), 1080 showNotification(parseHtmlSubset(localStrings.getString('serverpromo')),
1088 localStrings.getString('syncpromotext'), 1081 localStrings.getString('syncpromotext'),
1089 function () { chrome.send('SyncLinkClicked'); }, 1082 function () { chrome.send('SyncLinkClicked'); },
1090 60000); 1083 60000);
1091 var notificationElement = $('notification'); 1084 var notificationElement = $('notification');
1092 notification.classList.add('promo'); 1085 notification.classList.add('promo');
1093 } 1086 }
1094 1087
1095 $('main').addEventListener('click', function(e) { 1088 $('main').addEventListener('click', function(e) {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 mostVisited.layout(); 1436 mostVisited.layout();
1444 layoutSections(); 1437 layoutSections();
1445 1438
1446 // Remove class name in a timeout so that changes done in this JS thread are 1439 // Remove class name in a timeout so that changes done in this JS thread are
1447 // not animated. 1440 // not animated.
1448 window.setTimeout(function() { 1441 window.setTimeout(function() {
1449 mostVisited.ensureSmallGridCorrect(); 1442 mostVisited.ensureSmallGridCorrect();
1450 maybeDoneLoading(); 1443 maybeDoneLoading();
1451 }, 1); 1444 }, 1);
1452 1445
1453 // Only show the first run notification if first run. 1446 if (localStrings.getString('serverpromo')) {
1454 if (firstRun) {
1455 showFirstRunNotification();
1456 } else if (localStrings.getString('serverpromo')) {
1457 showPromoNotification(); 1447 showPromoNotification();
1458 } 1448 }
1459 } 1449 }
1460 1450
1461 function maybeDoneLoading() { 1451 function maybeDoneLoading() {
1462 if (mostVisited.data && apps.loaded) 1452 if (mostVisited.data && apps.loaded)
1463 document.body.classList.remove('loading'); 1453 document.body.classList.remove('loading');
1464 } 1454 }
1465 1455
1466 function isDoneLoading() { 1456 function isDoneLoading() {
1467 return !document.body.classList.contains('loading'); 1457 return !document.body.classList.contains('loading');
1468 } 1458 }
1469 1459
1470 // Initialize the apps promo. 1460 // Initialize the listener for the "hide this" link on the apps promo. We do
1461 // this outside of getAppsCallback because it only needs to be done once per
1462 // NTP load.
1471 document.addEventListener('DOMContentLoaded', function() { 1463 document.addEventListener('DOMContentLoaded', function() {
1472 var promoLink = document.querySelector('#apps-promo-text1 a');
1473 promoLink.id = 'apps-promo-link';
1474 promoLink.href = localStrings.getString('web_store_url');
1475
1476 $('apps-promo-hide').addEventListener('click', function() { 1464 $('apps-promo-hide').addEventListener('click', function() {
1477 chrome.send('hideAppsPromo', []); 1465 chrome.send('hideAppsPromo', []);
1478 document.documentElement.classList.remove('apps-promo-visible'); 1466 document.documentElement.classList.remove('apps-promo-visible');
1479 layoutSections(); 1467 layoutSections();
1480 }); 1468 });
1481 }); 1469 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | chrome/browser/resources/ntp/apps.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698