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

Unified Diff: chrome/browser/resources/new_new_tab.js

Issue 160214: Merge 21480 - Adds the first run banner.... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/new_new_tab.js
===================================================================
--- chrome/browser/resources/new_new_tab.js (revision 21735)
+++ chrome/browser/resources/new_new_tab.js (working copy)
@@ -70,7 +70,7 @@
var gotMostVisited = false;
var gotShownSections = false;
-function mostVisitedPages(data) {
+function mostVisitedPages(data, firstRun) {
logEvent('received most visited pages');
// We append the class name with the "filler" so that we can style fillers
@@ -87,6 +87,11 @@
gotMostVisited = true;
onDataLoaded();
+
+ // Only show the first run notification if first run.
+ if (firstRun) {
+ showFirstRunNotification();
+ }
}
function downloadsList(data) {
@@ -801,29 +806,59 @@
// Notification
-function showNotification(text, actionText, f) {
+
+var notificationTimeout;
+
+function showNotification(text, actionText, opt_f) {
var notificationElement = $('notification');
+
+ function show() {
+ window.clearTimeout(notificationTimeout);
+ addClass(notificationElement, 'show');
+ }
+
+ function delayedHide() {
+ notificationTimeout = window.setTimeout(hideNotification, 10000);
+ }
+
+ function doAction() {
+ if (opt_f) {
+ opt_f();
+ }
+ hideNotification();
+ }
+
+ // Remove any possible first-run trails.
+ removeClass(notification, 'first-run');
+
var actionLink = notificationElement.querySelector('.link');
notificationElement.firstElementChild.textContent = text;
+ actionLink.textContent = actionText;
- actionLink.textContent = actionText;
- actionLink.onclick = function() {
- f();
- removeClass(notificationElement, 'show');
- // Since we have a :hover rule to not hide the notification banner when the
- // mouse is over we need force it to hide. We remove the hide class after
- // a short timeout to allow the banner to be shown again.
- addClass(notificationElement, 'hide');
- afterTransition(function() {
- removeClass(notificationElement, 'hide');
- })
- };
- addClass(notificationElement, 'show');
- window.setTimeout(function() {
- removeClass(notificationElement, 'show');
- }, 10000);
+ actionLink.onclick = doAction;
+ actionLink.onkeydown = handleIfEnterKey(doAction);
+ notificationElement.onmouseover = show;
+ notificationElement.onmouseout = delayedHide;
+ actionLink.onfocus = show;
+ actionLink.onblur = delayedHide;
+
+ show();
+ delayedHide();
}
+function hideNotification() {
+ var notificationElement = $('notification');
+ removeClass(notificationElement, 'show');
+}
+
+function showFirstRunNotification() {
+ showNotification(localStrings.getString('firstrunnotification'),
+ localStrings.getString('closefirstrunnotification'));
+ var notificationElement = $('notification');
+ addClass(notification, 'first-run');
+}
+
+
/**
* This handles the option menu.
* @param {Element} button The button element.
Property changes on: chrome\browser\resources\new_new_tab.js
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/resources/new_new_tab.js:r21480
« no previous file with comments | « chrome/browser/resources/new_new_tab.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698