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

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

Issue 14685004: Add finch flag for rendering a recently closed link on the local ntp. (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Respond to comments. Created 7 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 (function() { 5 (function() {
6 <include src="../../../../ui/webui/resources/js/assert.js"> 6 <include src="../../../../ui/webui/resources/js/assert.js">
7 7
8 /** 8 /**
9 * True if this a Google page and not some other search provider. Used to 9 * True if this a Google page and not some other search provider. Used to
10 * determine whether to show the logo and fakebox. 10 * determine whether to show the logo and fakebox.
(...skipping 16 matching lines...) Expand all
27 BLACKLIST: 'mv-blacklist', // triggers tile blacklist animation 27 BLACKLIST: 'mv-blacklist', // triggers tile blacklist animation
28 BLACKLIST_BUTTON: 'mv-x', 28 BLACKLIST_BUTTON: 'mv-x',
29 CUSTOM_THEME: 'custom-theme', 29 CUSTOM_THEME: 'custom-theme',
30 DELAYED_HIDE_NOTIFICATION: 'mv-notice-delayed-hide', 30 DELAYED_HIDE_NOTIFICATION: 'mv-notice-delayed-hide',
31 DOMAIN: 'mv-domain', 31 DOMAIN: 'mv-domain',
32 FAKEBOX_ANIMATE: 'fakebox-animate', // triggers fakebox animation 32 FAKEBOX_ANIMATE: 'fakebox-animate', // triggers fakebox animation
33 FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox 33 FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox
34 FAVICON: 'mv-favicon', 34 FAVICON: 'mv-favicon',
35 FILLER: 'mv-filler', // filler tiles 35 FILLER: 'mv-filler', // filler tiles
36 GOOGLE_PAGE: 'google-page', // shows the Google logo and fakebox 36 GOOGLE_PAGE: 'google-page', // shows the Google logo and fakebox
37 HIDE_ATTRIBUTION: 'attribution-hide',
37 HIDE_BLACKLIST_BUTTON: 'mv-x-hide', // hides blacklist button during animation 38 HIDE_BLACKLIST_BUTTON: 'mv-x-hide', // hides blacklist button during animation
38 HIDE_NOTIFICATION: 'mv-notice-hide', 39 HIDE_NOTIFICATION: 'mv-notice-hide',
39 HIDE_NTP: 'hide-ntp', // hides NTP and disables scrollbars 40 HIDE_NTP: 'hide-ntp', // hides NTP and disables scrollbars
40 HIDE_TILE: 'mv-tile-hide', // hides tiles on small browser width 41 HIDE_TILE: 'mv-tile-hide', // hides tiles on small browser width
41 HOVERED: 'hovered', 42 HOVERED: 'hovered',
42 PENDING_SUGGESTIONS_CONTAINER: 'pending-suggestions-container', 43 PENDING_SUGGESTIONS_CONTAINER: 'pending-suggestions-container',
43 PAGE: 'mv-page', // page tiles 44 PAGE: 'mv-page', // page tiles
44 ROW: 'mv-row', // tile row 45 ROW: 'mv-row', // tile row
45 SEARCH: 'search', 46 SEARCH: 'search',
46 SELECTED: 'selected', // a selected suggestion (if any) 47 SELECTED: 'selected', // a selected suggestion (if any)
47 SUGGESTION: 'suggestion', 48 SUGGESTION: 'suggestion',
48 SUGGESTION_CONTENTS: 'suggestion-contents', 49 SUGGESTION_CONTENTS: 'suggestion-contents',
49 SUGGESTIONS_BOX: 'suggestions-box', 50 SUGGESTIONS_BOX: 'suggestions-box',
50 THUMBNAIL: 'mv-thumb', 51 THUMBNAIL: 'mv-thumb',
51 TILE: 'mv-tile', 52 TILE: 'mv-tile',
52 TITLE: 'mv-title' 53 TITLE: 'mv-title'
53 }; 54 };
54 55
55 /** 56 /**
56 * Enum for HTML element ids. 57 * Enum for HTML element ids.
57 * @enum {string} 58 * @enum {string}
58 * @const 59 * @const
59 */ 60 */
60 var IDS = { 61 var IDS = {
61 ATTRIBUTION: 'attribution', 62 ATTRIBUTION: 'attribution',
63 ATTRIBUTION_TEXT: 'attribution-text',
62 CURSOR: 'cursor', 64 CURSOR: 'cursor',
63 FAKEBOX: 'fakebox', 65 FAKEBOX: 'fakebox',
66 FOOTER: 'footer',
64 LOGO: 'logo', 67 LOGO: 'logo',
65 NOTIFICATION: 'mv-notice', 68 NOTIFICATION: 'mv-notice',
66 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x', 69 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x',
67 NOTIFICATION_MESSAGE: 'mv-msg', 70 NOTIFICATION_MESSAGE: 'mv-msg',
68 NTP_CONTENTS: 'ntp-contents', 71 NTP_CONTENTS: 'ntp-contents',
69 RESTORE_ALL_LINK: 'mv-restore', 72 RESTORE_ALL_LINK: 'mv-restore',
70 SUGGESTION_LOADER: 'suggestion-loader', 73 SUGGESTION_LOADER: 'suggestion-loader',
71 SUGGESTION_STYLE: 'suggestion-style', 74 SUGGESTION_STYLE: 'suggestion-style',
72 SUGGESTION_TEXT_PREFIX: 'suggestion-text-', 75 SUGGESTION_TEXT_PREFIX: 'suggestion-text-',
73 TILES: 'mv-tiles', 76 TILES: 'mv-tiles',
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 243 }
241 244
242 /** 245 /**
243 * Renders the attribution if the image is present and loadable. Otherwise 246 * Renders the attribution if the image is present and loadable. Otherwise
244 * hides it. 247 * hides it.
245 * @param {string} url The URL of the attribution image, if any. 248 * @param {string} url The URL of the attribution image, if any.
246 * @private 249 * @private
247 */ 250 */
248 function updateAttribution(url) { 251 function updateAttribution(url) {
249 if (!url) { 252 if (!url) {
250 attribution.hidden = true; 253 attribution.classList.add(CLASSES.HIDE_ATTRIBUTION);
251 return; 254 return;
252 } 255 }
253 var attributionImage = new Image(); 256 var attributionImage = new Image();
254 attributionImage.onload = function() { 257 attributionImage.onload = function() {
255 var oldAttributionImage = attribution.querySelector('img'); 258 var oldAttributionImage = attribution.querySelector('img');
256 if (oldAttributionImage) 259 if (oldAttributionImage)
257 removeNode(oldAttributionImage); 260 removeNode(oldAttributionImage);
258 attribution.appendChild(attributionImage); 261 attribution.appendChild(attributionImage);
259 attribution.hidden = false; 262 attribution.classList.remove(CLASSES.HIDE_ATTRIBUTION);
260 }; 263 };
261 attributionImage.onerror = function() { 264 attributionImage.onerror = function() {
262 attribution.hidden = true; 265 attribution.classList.add(CLASSES.HIDE_ATTRIBUTION);
263 }; 266 };
264 attributionImage.src = url; 267 attributionImage.src = url;
265 } 268 }
266 269
267 /** 270 /**
268 * Handles a new set of Most Visited page data. 271 * Handles a new set of Most Visited page data.
269 */ 272 */
270 function onMostVisitedChange() { 273 function onMostVisitedChange() {
271 var pages = ntpApiHandle.mostVisited; 274 var pages = ntpApiHandle.mostVisited;
272 275
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 fakebox = document.createElement('div'); 1402 fakebox = document.createElement('div');
1400 fakebox.id = IDS.FAKEBOX; 1403 fakebox.id = IDS.FAKEBOX;
1401 fakebox.innerHTML = 1404 fakebox.innerHTML =
1402 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' + 1405 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' +
1403 '<div id=cursor></div>'; 1406 '<div id=cursor></div>';
1404 1407
1405 ntpContents.insertBefore(fakebox, ntpContents.firstChild); 1408 ntpContents.insertBefore(fakebox, ntpContents.firstChild);
1406 ntpContents.insertBefore(logo, ntpContents.firstChild); 1409 ntpContents.insertBefore(logo, ntpContents.firstChild);
1407 } 1410 }
1408 1411
1412 var recentlyClosedText = templateData.recentlyClosed;
1413 if (recentlyClosedText) {
1414 var recentlyClosedLink = document.createElement('span');
1415 recentlyClosedLink.id = 'recently-closed';
1416 recentlyClosedLink.addEventListener('click', function() {
1417 ntpApiHandle.navigateContentWindow('chrome://history');
1418 });
1419 recentlyClosedLink.textContent = recentlyClosedText;
1420 var footer = $(IDS.FOOTER);
1421 footer.insertBefore(recentlyClosedLink, footer.firstChild);
1422 }
1409 1423
1410 // TODO(jeremycho): i18n. 1424 // TODO(jeremycho): i18n.
1411 var notificationMessage = $(IDS.NOTIFICATION_MESSAGE); 1425 var notificationMessage = $(IDS.NOTIFICATION_MESSAGE);
1412 notificationMessage.innerText = 'Thumbnail removed.'; 1426 notificationMessage.innerText = 'Thumbnail removed.';
1413 var undoLink = $(IDS.UNDO_LINK); 1427 var undoLink = $(IDS.UNDO_LINK);
1414 undoLink.addEventListener('click', onUndo); 1428 undoLink.addEventListener('click', onUndo);
1415 undoLink.innerText = 'Undo'; 1429 undoLink.innerText = 'Undo';
1416 var restoreAllLink = $(IDS.RESTORE_ALL_LINK); 1430 var restoreAllLink = $(IDS.RESTORE_ALL_LINK);
1417 restoreAllLink.addEventListener('click', onRestoreAll); 1431 restoreAllLink.addEventListener('click', onRestoreAll);
1418 restoreAllLink.innerText = 'Restore all'; 1432 restoreAllLink.innerText = 'Restore all';
1419 attribution.innerText = 'Theme created by'; 1433 $(IDS.ATTRIBUTION_TEXT).innerText = 'Theme created by';
1420 1434
1421 var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON); 1435 var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON);
1422 notificationCloseButton.addEventListener('click', hideNotification); 1436 notificationCloseButton.addEventListener('click', hideNotification);
1423 1437
1424 window.addEventListener('resize', onResize); 1438 window.addEventListener('resize', onResize);
1425 onResize(); 1439 onResize();
1426 1440
1427 var topLevelHandle = getEmbeddedSearchApiHandle(); 1441 var topLevelHandle = getEmbeddedSearchApiHandle();
1428 1442
1429 ntpApiHandle = topLevelHandle.newTabPage; 1443 ntpApiHandle = topLevelHandle.newTabPage;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 } 1489 }
1476 } 1490 }
1477 1491
1478 document.addEventListener('DOMContentLoaded', init); 1492 document.addEventListener('DOMContentLoaded', init);
1479 window.addEventListener('message', handleMessage, false); 1493 window.addEventListener('message', handleMessage, false);
1480 window.addEventListener('blur', function() { 1494 window.addEventListener('blur', function() {
1481 if (activeBox) 1495 if (activeBox)
1482 activeBox.clearHover(); 1496 activeBox.clearHover();
1483 }, false); 1497 }, false);
1484 })(); 1498 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698