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

Side by Side Diff: chrome/browser/resources/ntp4/new_tab.js

Issue 7461160: ntp4 info bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: even more docs Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 * @fileoverview New tab page 6 * @fileoverview New tab page
7 * This is the main code for the new tab page used by touch-enabled Chrome 7 * This is the main code for the new tab page used by touch-enabled Chrome
8 * browsers. For now this is still a prototype. 8 * browsers. For now this is still a prototype.
9 */ 9 */
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 /** 104 /**
105 * If non-null, this is the ID of the app to highlight to the user the next 105 * If non-null, this is the ID of the app to highlight to the user the next
106 * time getAppsCallback runs. "Highlight" in this case means to switch to 106 * time getAppsCallback runs. "Highlight" in this case means to switch to
107 * the page and run the new tile animation. 107 * the page and run the new tile animation.
108 * @type {String} 108 * @type {String}
109 */ 109 */
110 var highlightAppId = null; 110 var highlightAppId = null;
111 111
112 /** 112 /**
113 * If non-null, an info bubble for showing messages to the user. It points at
114 * the Most Visited label, and is used to draw more attention to the
115 * navigation dot UI.
116 * @type {!Element|undefined}
Rick Byers 2011/08/12 21:54:00 type doesn't match initialization to null before.
Evan Stade 2011/08/12 22:35:13 Done.
117 */
118 var infoBubble = null;
119
120 /**
113 * The time in milliseconds for most transitions. This should match what's 121 * The time in milliseconds for most transitions. This should match what's
114 * in new_tab.css. Unfortunately there's no better way to try to time 122 * in new_tab.css. Unfortunately there's no better way to try to time
115 * something to occur until after a transition has completed. 123 * something to occur until after a transition has completed.
116 * @type {number} 124 * @type {number}
117 * @const 125 * @const
118 */ 126 */
119 var DEFAULT_TRANSITION_TIME = 500; 127 var DEFAULT_TRANSITION_TIME = 500;
120 128
121 /** 129 /**
122 * Invoked at startup once the DOM is available to initialize the app. 130 * Invoked at startup once the DOM is available to initialize the app.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 CardSlider.EventType.CARD_CHANGED, 192 CardSlider.EventType.CARD_CHANGED,
185 cardChangedHandler); 193 cardChangedHandler);
186 194
187 cr.ui.decorate($('recently-closed-menu-button'), ntp4.RecentMenuButton); 195 cr.ui.decorate($('recently-closed-menu-button'), ntp4.RecentMenuButton);
188 chrome.send('getRecentlyClosedTabs'); 196 chrome.send('getRecentlyClosedTabs');
189 197
190 mostVisitedPage = new ntp4.MostVisitedPage(); 198 mostVisitedPage = new ntp4.MostVisitedPage();
191 appendTilePage(mostVisitedPage, localStrings.getString('mostvisited')); 199 appendTilePage(mostVisitedPage, localStrings.getString('mostvisited'));
192 chrome.send('getMostVisited'); 200 chrome.send('getMostVisited');
193 201
202 if (localStrings.getString('ntp4_intro_message')) {
203 infoBubble = new cr.ui.Bubble;
204 infoBubble.attach(mostVisitedPage.navigationDot);
205 infoBubble.setText(localStrings.getString('ntp4_intro_message'));
206 infoBubble.show();
207
208 chrome.send('introMessageSeen');
209 }
210
194 bookmarksPage = new ntp4.BookmarksPage(); 211 bookmarksPage = new ntp4.BookmarksPage();
195 appendTilePage(bookmarksPage, localStrings.getString('bookmarksPage')); 212 appendTilePage(bookmarksPage, localStrings.getString('bookmarksPage'));
196 chrome.send('getBookmarks'); 213 chrome.send('getBookmarks');
197 } 214 }
198 215
199 /** 216 /**
200 * Simple common assertion API 217 * Simple common assertion API
201 * @param {*} condition The condition to test. Note that this may be used to 218 * @param {*} condition The condition to test. Note that this may be used to
202 * test whether a value is defined or not, and we don't want to force a 219 * test whether a value is defined or not, and we don't want to force a
203 * cast to Boolean. 220 * cast to Boolean.
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 * @param {string} title The title of the tile page. 418 * @param {string} title The title of the tile page.
402 */ 419 */
403 function appendTilePage(page, title) { 420 function appendTilePage(page, title) {
404 pageList.appendChild(page); 421 pageList.appendChild(page);
405 422
406 // Make a deep copy of the dot template to add a new one. 423 // Make a deep copy of the dot template to add a new one.
407 var newDot = new ntp4.NavDot(page, title, false, false); 424 var newDot = new ntp4.NavDot(page, title, false, false);
408 425
409 dotList.appendChild(newDot); 426 dotList.appendChild(newDot);
410 page.navigationDot = newDot; 427 page.navigationDot = newDot;
428 if (infoBubble)
429 window.setTimeout(infoBubble.reposition.bind(infoBubble), 0);
411 430
412 eventTracker.add(page, 'pagelayout', onPageLayout); 431 eventTracker.add(page, 'pagelayout', onPageLayout);
413 } 432 }
414 433
415 /** 434 /**
416 * Appends an apps page into the page list. This is like appendTilePage, 435 * Appends an apps page into the page list. This is like appendTilePage,
417 * but takes care to insert before the Bookmarks page. 436 * but takes care to insert before the Bookmarks page.
418 * TODO(csilv): Refactor this function with appendTilePage to avoid 437 * TODO(csilv): Refactor this function with appendTilePage to avoid
419 * duplication. 438 * duplication.
420 * 439 *
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 var page = e.cardSlider.currentCardValue; 608 var page = e.cardSlider.currentCardValue;
590 if (page.classList.contains('apps-page')) { 609 if (page.classList.contains('apps-page')) {
591 shownPage = templateData['apps_page_id']; 610 shownPage = templateData['apps_page_id'];
592 shownPageIndex = getAppsPageIndex(page); 611 shownPageIndex = getAppsPageIndex(page);
593 } else if (page.classList.contains('most-visited-page')) { 612 } else if (page.classList.contains('most-visited-page')) {
594 shownPage = templateData['most_visited_page_id']; 613 shownPage = templateData['most_visited_page_id'];
595 shownPageIndex = 0; 614 shownPageIndex = 0;
596 } else if (page.classList.contains('bookmarks-page')) { 615 } else if (page.classList.contains('bookmarks-page')) {
597 shownPage = templateData['bookmarks_page_id']; 616 shownPage = templateData['bookmarks_page_id'];
598 shownPageIndex = 0; 617 shownPageIndex = 0;
599 } else if (page.classList.contains('bookmarks-page')) {
600 shownPage = templateData['bookmarks_page_id'];
601 shownPageIndex = 0;
602 } else { 618 } else {
603 console.error('unknown page selected'); 619 console.error('unknown page selected');
604 } 620 }
605 chrome.send('pageSelected', [shownPage, shownPageIndex]); 621 chrome.send('pageSelected', [shownPage, shownPageIndex]);
606 622
607 // Update the active dot 623 // Update the active dot
608 var curDot = dotList.getElementsByClassName('selected')[0]; 624 var curDot = dotList.getElementsByClassName('selected')[0];
609 if (curDot) 625 if (curDot)
610 curDot.classList.remove('selected'); 626 curDot.classList.remove('selected');
611 var newPageIndex = e.cardSlider.currentCard; 627 var newPageIndex = e.cardSlider.currentCard;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 // TODO(estade): update the content handlers to use ntp namespace instead of 727 // TODO(estade): update the content handlers to use ntp namespace instead of
712 // making these global. 728 // making these global.
713 var assert = ntp4.assert; 729 var assert = ntp4.assert;
714 var getAppsCallback = ntp4.getAppsCallback; 730 var getAppsCallback = ntp4.getAppsCallback;
715 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback; 731 var appsPrefChangeCallback = ntp4.appsPrefChangeCallback;
716 var themeChanged = ntp4.themeChanged; 732 var themeChanged = ntp4.themeChanged;
717 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs; 733 var recentlyClosedTabs = ntp4.setRecentlyClosedTabs;
718 var setMostVisitedPages = ntp4.setMostVisitedPages; 734 var setMostVisitedPages = ntp4.setMostVisitedPages;
719 735
720 document.addEventListener('DOMContentLoaded', ntp4.initialize); 736 document.addEventListener('DOMContentLoaded', ntp4.initialize);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698