Chromium Code Reviews| Index: chrome/browser/resources/new_new_tab.js |
| =================================================================== |
| --- chrome/browser/resources/new_new_tab.js (revision 72151) |
| +++ chrome/browser/resources/new_new_tab.js (working copy) |
| @@ -789,7 +789,7 @@ |
| } |
| /** |
| - * Invoked when the link in the sync status section is clicked. |
| + * Invoked when the link in the sync promo or sync status section is clicked. |
| */ |
| function syncSectionLinkClicked(e) { |
| chrome.send('SyncLinkClicked'); |
| @@ -917,9 +917,10 @@ |
| * @param {function=} opt_f Function to call when the user clicks the action |
| * link. |
| * @param {number=} opt_delay The time in milliseconds before hiding the |
| - * i notification. |
| + * notification. |
| + * @param {bool=} close If true, show a close link next to the notification. |
|
arv (Not doing code reviews)
2011/01/24 18:15:11
boolean
Miranda Callahan
2011/01/24 18:39:22
Done.
|
| */ |
| -function showNotification(message, actionText, opt_f, opt_delay) { |
| +function showNotification(message, actionText, opt_f, opt_delay, opt_close) { |
|
arv (Not doing code reviews)
2011/01/24 18:15:11
I think we should create a component for this soon
Miranda Callahan
2011/01/24 18:39:22
Done.
|
| var notificationElement = $('notification'); |
| var f = opt_f || function() {}; |
| var delay = opt_delay || 10000; |
| @@ -939,13 +940,27 @@ |
| hideNotification(); |
| } |
| + function closeNotification() { |
| + chrome.send('closePromo'); |
| + hideNotification(); |
| + } |
| + |
| // Remove classList entries from previous notifications. |
| notification.classList.remove('first-run'); |
| notification.classList.remove('promo'); |
| var messageContainer = notificationElement.firstElementChild; |
| - var actionLink = notificationElement.querySelector('.link-color'); |
| + var actionLink = notificationElement.querySelector('#actionlink'); |
| + if (opt_close) { |
| + var closeLink = notificationElement.querySelector('#closelink'); |
| + closeLink.textContent = |
| + localStrings.getString('closefirstrunnotification'); |
| + closeLink.onclick = closeNotification; |
| + closeLink.onkeydown = handleIfEnterKey(closeNotification); |
| + closeLink.tabIndex = 1; |
| + } |
| + |
| if (typeof message == 'string') { |
| messageContainer.textContent = message; |
| } else { |
| @@ -975,14 +990,17 @@ |
| var notificationElement = $('notification'); |
| notificationElement.classList.remove('show'); |
| document.body.classList.remove('notification-shown'); |
| - var actionLink = notificationElement.querySelector('.link-color'); |
| + var actionLink = notificationElement.querySelector('#actionlink'); |
| + var closeLink = notificationElement.querySelector('#closelink'); |
| // Prevent tabbing to the hidden link. |
| actionLink.tabIndex = -1; |
| + closeLink.tabIndex = -1; |
| // Setting tabIndex to -1 only prevents future tabbing to it. If, however, the |
| // user switches window or a tab and then moves back to this tab the element |
| // may gain focus. We therefore make sure that we blur the element so that the |
| // element focus is not restored when coming back to this window. |
| actionLink.blur(); |
| + closeLink.blur(); |
| } |
| function showFirstRunNotification() { |
| @@ -995,9 +1013,10 @@ |
| function showPromoNotification() { |
| showNotification(parseHtmlSubset(localStrings.getString('serverpromo')), |
| - localStrings.getString('closefirstrunnotification'), |
| - function () { chrome.send('closePromo'); }, |
| - 60000); |
| + localStrings.getString('syncpromotext'), |
| + function () { chrome.send('SyncLinkClicked'); }, |
| + 60000, |
| + true); |
| var notificationElement = $('notification'); |
| notification.classList.add('promo'); |
| } |