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

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: Rebase. 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 5
6 /** 6 /**
7 * @fileoverview The local InstantExtended NTP and suggestions dropdown. 7 * @fileoverview The local InstantExtended NTP and suggestions dropdown.
8 */ 8 */
9 9
10 (function() { 10 (function() {
(...skipping 21 matching lines...) Expand all
32 var CLASSES = { 32 var CLASSES = {
33 BLACKLIST: 'mv-blacklist', // triggers tile blacklist animation 33 BLACKLIST: 'mv-blacklist', // triggers tile blacklist animation
34 BLACKLIST_BUTTON: 'mv-x', 34 BLACKLIST_BUTTON: 'mv-x',
35 CUSTOM_THEME: 'custom-theme', 35 CUSTOM_THEME: 'custom-theme',
36 DELAYED_HIDE_NOTIFICATION: 'mv-notice-delayed-hide', 36 DELAYED_HIDE_NOTIFICATION: 'mv-notice-delayed-hide',
37 DOMAIN: 'mv-domain', 37 DOMAIN: 'mv-domain',
38 FAKEBOX_ANIMATE: 'fakebox-animate', // triggers fakebox animation 38 FAKEBOX_ANIMATE: 'fakebox-animate', // triggers fakebox animation
39 FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox 39 FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox
40 FAVICON: 'mv-favicon', 40 FAVICON: 'mv-favicon',
41 GOOGLE_PAGE: 'google-page', // shows the Google logo and fakebox 41 GOOGLE_PAGE: 'google-page', // shows the Google logo and fakebox
42 HIDE_ATTRIBUTION: 'attribution-hide',
42 HIDE_BLACKLIST_BUTTON: 'mv-x-hide', // hides blacklist button during animation 43 HIDE_BLACKLIST_BUTTON: 'mv-x-hide', // hides blacklist button during animation
43 HIDE_NOTIFICATION: 'mv-notice-hide', 44 HIDE_NOTIFICATION: 'mv-notice-hide',
44 HIDE_NTP: 'hide-ntp', // hides NTP and disables scrollbars 45 HIDE_NTP: 'hide-ntp', // hides NTP and disables scrollbars
45 HIDE_TILE: 'mv-tile-hide', // hides tiles on small browser width 46 HIDE_TILE: 'mv-tile-hide', // hides tiles on small browser width
46 HOVERED: 'hovered', 47 HOVERED: 'hovered',
47 PAGE: 'mv-page', // page tiles 48 PAGE: 'mv-page', // page tiles
48 PAGE_READY: 'mv-page-ready', // page tile when ready 49 PAGE_READY: 'mv-page-ready', // page tile when ready
49 ROW: 'mv-row', // tile row 50 ROW: 'mv-row', // tile row
50 SEARCH: 'search', 51 SEARCH: 'search',
51 SELECTED: 'selected', // a selected suggestion (if any) 52 SELECTED: 'selected', // a selected suggestion (if any)
52 SUGGESTION: 'suggestion', 53 SUGGESTION: 'suggestion',
53 SUGGESTION_CONTENTS: 'suggestion-contents', 54 SUGGESTION_CONTENTS: 'suggestion-contents',
54 SUGGESTIONS_BOX: 'suggestions-box', 55 SUGGESTIONS_BOX: 'suggestions-box',
55 THUMBNAIL: 'mv-thumb', 56 THUMBNAIL: 'mv-thumb',
56 TILE: 'mv-tile', 57 TILE: 'mv-tile',
57 TITLE: 'mv-title' 58 TITLE: 'mv-title'
58 }; 59 };
59 60
60 61
61 /** 62 /**
62 * Enum for HTML element ids. 63 * Enum for HTML element ids.
63 * @enum {string} 64 * @enum {string}
64 * @const 65 * @const
65 */ 66 */
66 var IDS = { 67 var IDS = {
67 ACTIVE_SUGGESTIONS_CONTAINER: 'active-suggestions-container', 68 ACTIVE_SUGGESTIONS_CONTAINER: 'active-suggestions-container',
68 ATTRIBUTION: 'attribution', 69 ATTRIBUTION: 'attribution',
70 ATTRIBUTION_TEXT: 'attribution-text',
69 CURSOR: 'cursor', 71 CURSOR: 'cursor',
70 FAKEBOX: 'fakebox', 72 FAKEBOX: 'fakebox',
73 FOOTER: 'footer',
71 LOGO: 'logo', 74 LOGO: 'logo',
72 NOTIFICATION: 'mv-notice', 75 NOTIFICATION: 'mv-notice',
73 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x', 76 NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x',
74 NOTIFICATION_MESSAGE: 'mv-msg', 77 NOTIFICATION_MESSAGE: 'mv-msg',
75 NTP_CONTENTS: 'ntp-contents', 78 NTP_CONTENTS: 'ntp-contents',
76 PENDING_SUGGESTIONS_CONTAINER: 'pending-suggestions-container', 79 PENDING_SUGGESTIONS_CONTAINER: 'pending-suggestions-container',
80 RECENT_TABS: 'recent-tabs',
77 RESTORE_ALL_LINK: 'mv-restore', 81 RESTORE_ALL_LINK: 'mv-restore',
78 SUGGESTION_LOADER: 'suggestion-loader', 82 SUGGESTION_LOADER: 'suggestion-loader',
79 SUGGESTION_STYLE: 'suggestion-style', 83 SUGGESTION_STYLE: 'suggestion-style',
80 SUGGESTION_TEXT_PREFIX: 'suggestion-text-', 84 SUGGESTION_TEXT_PREFIX: 'suggestion-text-',
81 TILES: 'mv-tiles', 85 TILES: 'mv-tiles',
82 TOP_MARGIN: 'mv-top-margin', 86 TOP_MARGIN: 'mv-top-margin',
83 UNDO_LINK: 'mv-undo' 87 UNDO_LINK: 'mv-undo'
84 }; 88 };
85 89
86 // ============================================================================= 90 // =============================================================================
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 323
320 324
321 /** 325 /**
322 * Renders the attribution if the image is present and loadable. Otherwise 326 * Renders the attribution if the image is present and loadable. Otherwise
323 * hides it. 327 * hides it.
324 * @param {string} url The URL of the attribution image, if any. 328 * @param {string} url The URL of the attribution image, if any.
325 * @private 329 * @private
326 */ 330 */
327 function updateAttribution(url) { 331 function updateAttribution(url) {
328 if (!url) { 332 if (!url) {
329 attribution.hidden = true; 333 attribution.classList.add(CLASSES.HIDE_ATTRIBUTION);
330 return; 334 return;
331 } 335 }
332 var attributionImage = new Image(); 336 var attributionImage = new Image();
333 attributionImage.onload = function() { 337 attributionImage.onload = function() {
334 var oldAttributionImage = attribution.querySelector('img'); 338 var oldAttributionImage = attribution.querySelector('img');
335 if (oldAttributionImage) 339 if (oldAttributionImage)
336 removeNode(oldAttributionImage); 340 removeNode(oldAttributionImage);
337 attribution.appendChild(attributionImage); 341 attribution.appendChild(attributionImage);
338 attribution.hidden = false; 342 attribution.classList.remove(CLASSES.HIDE_ATTRIBUTION);
339 }; 343 };
340 attributionImage.onerror = function() { 344 attributionImage.onerror = function() {
341 attribution.hidden = true; 345 attribution.classList.add(CLASSES.HIDE_ATTRIBUTION);
342 }; 346 };
343 attributionImage.src = url; 347 attributionImage.src = url;
344 } 348 }
345 349
346 350
347 /** 351 /**
348 * Handles a new set of Most Visited page data. 352 * Handles a new set of Most Visited page data.
349 */ 353 */
350 function onMostVisitedChange() { 354 function onMostVisitedChange() {
351 var pages = ntpApiHandle.mostVisited; 355 var pages = ntpApiHandle.mostVisited;
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 fakebox = document.createElement('div'); 1606 fakebox = document.createElement('div');
1603 fakebox.id = IDS.FAKEBOX; 1607 fakebox.id = IDS.FAKEBOX;
1604 fakebox.innerHTML = 1608 fakebox.innerHTML =
1605 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' + 1609 '<input autocomplete="off" tabindex="-1" aria-hidden="true">' +
1606 '<div id=cursor></div>'; 1610 '<div id=cursor></div>';
1607 1611
1608 ntpContents.insertBefore(fakebox, ntpContents.firstChild); 1612 ntpContents.insertBefore(fakebox, ntpContents.firstChild);
1609 ntpContents.insertBefore(logo, ntpContents.firstChild); 1613 ntpContents.insertBefore(logo, ntpContents.firstChild);
1610 } 1614 }
1611 1615
1616 var recentTabsText = templateData.recentTabs;
1617 if (recentTabsText) {
1618 var recentTabsLink = document.createElement('span');
samarth 2013/05/15 16:49:17 Can this just be an <a href="chrome://history">? O
jeremycho 2013/05/16 20:06:47 It would add a non-functioning "Open link in new t
1619 recentTabsLink.id = IDS.RECENT_TABS;
1620 recentTabsLink.addEventListener('click', function() {
samarth 2013/05/15 16:49:17 Can you also add logic to look for a modifier and
jeremycho 2013/05/16 20:06:47 Done.
1621 ntpApiHandle.navigateContentWindow('chrome://history');
1622 });
1623 recentTabsLink.textContent = recentTabsText;
1624 var footer = $(IDS.FOOTER);
1625 footer.insertBefore(recentTabsLink, footer.firstChild);
1626 }
1612 1627
1613 var notificationMessage = $(IDS.NOTIFICATION_MESSAGE); 1628 var notificationMessage = $(IDS.NOTIFICATION_MESSAGE);
1614 notificationMessage.textContent = templateData.thumbnailRemovedNotification; 1629 notificationMessage.textContent = templateData.thumbnailRemovedNotification;
1615 var undoLink = $(IDS.UNDO_LINK); 1630 var undoLink = $(IDS.UNDO_LINK);
1616 undoLink.addEventListener('click', onUndo); 1631 undoLink.addEventListener('click', onUndo);
1617 undoLink.textContent = templateData.undoThumbnailRemove; 1632 undoLink.textContent = templateData.undoThumbnailRemove;
1618 var restoreAllLink = $(IDS.RESTORE_ALL_LINK); 1633 var restoreAllLink = $(IDS.RESTORE_ALL_LINK);
1619 restoreAllLink.addEventListener('click', onRestoreAll); 1634 restoreAllLink.addEventListener('click', onRestoreAll);
1620 restoreAllLink.textContent = templateData.restoreThumbnailsShort; 1635 restoreAllLink.textContent = templateData.restoreThumbnailsShort;
1621 attribution.textContent = templateData.attributionIntro; 1636 $(IDS.ATTRIBUTION_TEXT).textContent = templateData.attributionIntro;
1622 1637
1623 var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON); 1638 var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON);
1624 notificationCloseButton.addEventListener('click', hideNotification); 1639 notificationCloseButton.addEventListener('click', hideNotification);
1625 1640
1626 window.addEventListener('resize', onResize); 1641 window.addEventListener('resize', onResize);
1627 onResize(); 1642 onResize();
1628 1643
1629 var topLevelHandle = getEmbeddedSearchApiHandle(); 1644 var topLevelHandle = getEmbeddedSearchApiHandle();
1630 1645
1631 ntpApiHandle = topLevelHandle.newTabPage; 1646 ntpApiHandle = topLevelHandle.newTabPage;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 } 1692 }
1678 } 1693 }
1679 1694
1680 document.addEventListener('DOMContentLoaded', init); 1695 document.addEventListener('DOMContentLoaded', init);
1681 window.addEventListener('message', handleMessage, false); 1696 window.addEventListener('message', handleMessage, false);
1682 window.addEventListener('blur', function() { 1697 window.addEventListener('blur', function() {
1683 if (activeBox) 1698 if (activeBox)
1684 activeBox.clearHover(); 1699 activeBox.clearHover();
1685 }, false); 1700 }, false);
1686 })(); 1701 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_ntp/local_ntp.html ('k') | chrome/browser/search/local_ntp_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698