Chromium Code Reviews| Index: chrome/browser/resources/local_ntp/local_ntp.js |
| diff --git a/chrome/browser/resources/local_ntp/local_ntp.js b/chrome/browser/resources/local_ntp/local_ntp.js |
| index e6747c55eaae760d3be58060a5e23313468d5091..717be1783d4d39d8addc6a0d6a3f1ddac340a722 100644 |
| --- a/chrome/browser/resources/local_ntp/local_ntp.js |
| +++ b/chrome/browser/resources/local_ntp/local_ntp.js |
| @@ -30,6 +30,7 @@ var CLASSES = { |
| FAKEBOX_DISABLE: 'fakebox-disable', // Makes fakebox non-interactive |
| FAKEBOX_FOCUS: 'fakebox-focused', // Applies focus styles to the fakebox |
| FAVICON: 'mv-favicon', |
| + HIDE_ATTRIBUTION: 'attribution-hide', |
| HIDE_BLACKLIST_BUTTON: 'mv-x-hide', // hides blacklist button during animation |
| HIDE_FAKEBOX_AND_LOGO: 'hide-fakebox-logo', |
| HIDE_NOTIFICATION: 'mv-notice-hide', |
| @@ -53,12 +54,15 @@ var CLASSES = { |
| */ |
| var IDS = { |
| ATTRIBUTION: 'attribution', |
| + ATTRIBUTION_TEXT: 'attribution-text', |
| FAKEBOX: 'fakebox', |
| + FOOTER: 'footer', |
| LOGO: 'logo', |
| NOTIFICATION: 'mv-notice', |
| NOTIFICATION_CLOSE_BUTTON: 'mv-notice-x', |
| NOTIFICATION_MESSAGE: 'mv-msg', |
| NTP_CONTENTS: 'ntp-contents', |
| + RECENT_TABS: 'recent-tabs', |
| RESTORE_ALL_LINK: 'mv-restore', |
| TILES: 'mv-tiles', |
| UNDO_LINK: 'mv-undo' |
| @@ -89,6 +93,24 @@ var NTP_DISPOSE_STATE = { |
| /** |
| + * The JavaScript button event value for a middle click. |
| + * @type {number} |
| + * @const |
| + */ |
| +var MIDDLE_MOUSE_BUTTON = 1; |
| + |
| + |
| +/** |
| + * Possible behaviors for navigateContentWindow. |
| + * @enum {number} |
| + */ |
| +var WindowOpenDisposition = { |
| + CURRENT_TAB: 1, |
| + NEW_BACKGROUND_TAB: 2 |
| +}; |
| + |
| + |
| +/** |
| * The container for the tile elements. |
| * @type {Element} |
| */ |
| @@ -343,7 +365,7 @@ function onThemeChange() { |
| */ |
| function updateAttribution(url) { |
| if (!url) { |
| - attribution.hidden = true; |
| + attribution.classList.add(CLASSES.HIDE_ATTRIBUTION); |
|
Jered
2013/06/24 17:42:26
nit: This change seems unnecessary in the context
jeremycho
2013/06/24 20:12:09
This is for setting display:none when no attributi
|
| return; |
| } |
| var attributionImage = new Image(); |
| @@ -352,10 +374,10 @@ function updateAttribution(url) { |
| if (oldAttributionImage) |
| removeNode(oldAttributionImage); |
| attribution.appendChild(attributionImage); |
| - attribution.hidden = false; |
| + attribution.classList.remove(CLASSES.HIDE_ATTRIBUTION); |
| }; |
| attributionImage.onerror = function() { |
| - attribution.hidden = true; |
| + attribution.classList.add(CLASSES.HIDE_ATTRIBUTION); |
| }; |
| attributionImage.src = url; |
| } |
| @@ -863,6 +885,19 @@ function isGooglePage() { |
| /** |
| + * Extract the desired navigation behavior from a click button. |
| + * @param {number} button The Event#button property of a click event. |
| + * @return {WindowOpenDisposition} The desired behavior for |
| + * navigateContentWindow. |
| + */ |
| +function getDispositionFromClickButton(button) { |
| + if (button == MIDDLE_MOUSE_BUTTON) |
| + return WindowOpenDisposition.NEW_BACKGROUND_TAB; |
| + return WindowOpenDisposition.CURRENT_TAB; |
| +} |
| + |
| + |
| +/** |
| * Prepares the New Tab Page by adding listeners, rendering the current |
| * theme, the most visited pages section, and Google-specific elements for a |
| * Google-provided page. |
| @@ -895,6 +930,18 @@ function init() { |
| document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); |
| } |
| + var recentTabsText = templateData.recentTabs; |
| + if (recentTabsText) { |
| + var recentTabsLink = document.createElement('span'); |
| + recentTabsLink.id = IDS.RECENT_TABS; |
| + recentTabsLink.addEventListener('click', function(event) { |
| + ntpApiHandle.navigateContentWindow( |
| + 'chrome://history', getDispositionFromClickButton(event.button)); |
| + }); |
| + recentTabsLink.textContent = recentTabsText; |
| + var footer = $(IDS.FOOTER); |
| + footer.insertBefore(recentTabsLink, footer.firstChild); |
| + } |
| var notificationMessage = $(IDS.NOTIFICATION_MESSAGE); |
| notificationMessage.textContent = templateData.thumbnailRemovedNotification; |
| @@ -906,7 +953,7 @@ function init() { |
| restoreAllLink.addEventListener('click', onRestoreAll); |
| registerKeyHandler(restoreAllLink, KEYCODE.ENTER, onUndo); |
| restoreAllLink.textContent = templateData.restoreThumbnailsShort; |
| - attribution.textContent = templateData.attributionIntro; |
| + $(IDS.ATTRIBUTION_TEXT).textContent = templateData.attributionIntro; |
| var notificationCloseButton = $(IDS.NOTIFICATION_CLOSE_BUTTON); |
| notificationCloseButton.addEventListener('click', hideNotification); |