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

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

Issue 1754853002: NTP4: erase bubble promo UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@notification-promo-ui
Patch Set: todo Created 4 years, 9 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
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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
11 // Use an anonymous function to enable strict mode just for this file (which 11 // Use an anonymous function to enable strict mode just for this file (which
12 // will be concatenated with other files when embedded in Chrome 12 // will be concatenated with other files when embedded in Chrome
13 cr.define('ntp', function() { 13 cr.define('ntp', function() {
14 'use strict'; 14 'use strict';
15 15
16 /** 16 /**
17 * NewTabView instance. 17 * NewTabView instance.
18 * @type {!Object|undefined} 18 * @type {!Object|undefined}
19 */ 19 */
20 var newTabView; 20 var newTabView;
21 21
22 /** 22 /**
23 * If non-null, an info bubble for showing messages to the user. It points at
24 * the Most Visited label, and is used to draw more attention to the
25 * navigation dot UI.
26 * @type {!cr.ui.Bubble|undefined}
27 */
28 var promoBubble;
29
30 /**
31 * If non-null, an bubble confirming that the user has signed into sync. It 23 * If non-null, an bubble confirming that the user has signed into sync. It
32 * points at the login status at the top of the page. 24 * points at the login status at the top of the page.
33 * @type {!cr.ui.Bubble|undefined} 25 * @type {!cr.ui.Bubble|undefined}
34 */ 26 */
35 var loginBubble; 27 var loginBubble;
36 28
37 /** 29 /**
38 * true if |loginBubble| should be shown. 30 * true if |loginBubble| should be shown.
39 * @type {boolean} 31 * @type {boolean}
40 */ 32 */
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 pageSwitcherEnd = /** @type {!ntp.PageSwitcher} */( 73 pageSwitcherEnd = /** @type {!ntp.PageSwitcher} */(
82 getRequiredElement('page-switcher-end')); 74 getRequiredElement('page-switcher-end'));
83 } 75 }
84 this.initialize(getRequiredElement('page-list'), 76 this.initialize(getRequiredElement('page-list'),
85 getRequiredElement('dot-list'), 77 getRequiredElement('dot-list'),
86 getRequiredElement('card-slider-frame'), 78 getRequiredElement('card-slider-frame'),
87 getRequiredElement('trash'), 79 getRequiredElement('trash'),
88 pageSwitcherStart, pageSwitcherEnd); 80 pageSwitcherStart, pageSwitcherEnd);
89 } 81 }
90 82
91 NewTabView.prototype = { 83 // TODO(dbeam): NewTabView is now the only extender of PageListView; these
92 __proto__: ntp.PageListView.prototype, 84 // classes should be merged.
93 85 NewTabView.prototype = {__proto__: ntp.PageListView.prototype};
94 /** @override */
95 appendTilePage: function(page, title, titleIsEditable, opt_refNode) {
96 ntp.PageListView.prototype.appendTilePage.apply(this, arguments);
97
98 if (promoBubble)
99 window.setTimeout(promoBubble.reposition.bind(promoBubble), 0);
100 }
101 };
102 86
103 /** 87 /**
104 * Invoked at startup once the DOM is available to initialize the app. 88 * Invoked at startup once the DOM is available to initialize the app.
105 */ 89 */
106 function onLoad() { 90 function onLoad() {
107 sectionsToWaitFor = 0; 91 sectionsToWaitFor = 0;
108 if (loadTimeData.getBoolean('showApps')) { 92 if (loadTimeData.getBoolean('showApps')) {
109 sectionsToWaitFor++; 93 sectionsToWaitFor++;
110 if (loadTimeData.getBoolean('showAppLauncherPromo')) { 94 if (loadTimeData.getBoolean('showAppLauncherPromo')) {
111 $('app-launcher-promo-close-button').addEventListener('click', 95 $('app-launcher-promo-close-button').addEventListener('click',
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 $('login-status-dismiss').onclick = loginBubble.hide.bind(loginBubble); 137 $('login-status-dismiss').onclick = loginBubble.hide.bind(loginBubble);
154 138
155 var bubbleContent = $('login-status-bubble-contents'); 139 var bubbleContent = $('login-status-bubble-contents');
156 loginBubble.content = bubbleContent; 140 loginBubble.content = bubbleContent;
157 141
158 // The anchor node won't be updated until updateLogin is called so don't 142 // The anchor node won't be updated until updateLogin is called so don't
159 // show the bubble yet. 143 // show the bubble yet.
160 shouldShowLoginBubble = true; 144 shouldShowLoginBubble = true;
161 } 145 }
162 146
163 if (loadTimeData.valueExists('bubblePromoText')) {
164 promoBubble = new cr.ui.Bubble;
165 promoBubble.anchorNode = getRequiredElement('promo-bubble-anchor');
166 promoBubble.arrowLocation = cr.ui.ArrowLocation.BOTTOM_START;
167 promoBubble.bubbleAlignment = cr.ui.BubbleAlignment.ENTIRELY_VISIBLE;
168 promoBubble.deactivateToDismissDelay = 2000;
169 promoBubble.content = parseHtmlSubset(
170 loadTimeData.getString('bubblePromoText'), ['BR']);
171
172 var bubbleLink = promoBubble.querySelector('a');
173 if (bubbleLink) {
174 bubbleLink.addEventListener('click', function(e) {
175 chrome.send('bubblePromoLinkClicked');
176 });
177 }
178
179 promoBubble.handleCloseEvent = function() {
180 promoBubble.hide();
181 chrome.send('bubblePromoClosed');
182 };
183 promoBubble.show();
184 chrome.send('bubblePromoViewed');
185 }
186
187 $('login-container').addEventListener('click', showSyncLoginUI); 147 $('login-container').addEventListener('click', showSyncLoginUI);
188 if (loadTimeData.getBoolean('shouldShowSyncLogin')) 148 if (loadTimeData.getBoolean('shouldShowSyncLogin'))
189 chrome.send('initializeSyncLogin'); 149 chrome.send('initializeSyncLogin');
190 150
191 doWhenAllSectionsReady(function() { 151 doWhenAllSectionsReady(function() {
192 // Tell the slider about the pages. 152 // Tell the slider about the pages.
193 newTabView.updateSliderCards(); 153 newTabView.updateSliderCards();
194 // Mark the current page. 154 // Mark the current page.
195 newTabView.cardSlider.currentCardValue.navigationDot.classList.add( 155 newTabView.cardSlider.currentCardValue.navigationDot.classList.add(
196 'selected'); 156 'selected');
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 setBookmarkBarAttached: setBookmarkBarAttached, 457 setBookmarkBarAttached: setBookmarkBarAttached,
498 setFaviconDominantColor: setFaviconDominantColor, 458 setFaviconDominantColor: setFaviconDominantColor,
499 themeChanged: themeChanged, 459 themeChanged: themeChanged,
500 updateLogin: updateLogin 460 updateLogin: updateLogin
501 }; 461 };
502 }); 462 });
503 463
504 document.addEventListener('DOMContentLoaded', ntp.onLoad); 464 document.addEventListener('DOMContentLoaded', ntp.onLoad);
505 465
506 var toCssPx = cr.ui.toCssPx; 466 var toCssPx = cr.ui.toCssPx;
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698