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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2236723002: MD Settings: Hide the advanced page toggle control during searching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 6 * @fileoverview
7 * 'settings-main' displays the selected settings page. 7 * 'settings-main' displays the selected settings page.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-main', 10 is: 'settings-main',
(...skipping 25 matching lines...) Expand all
36 }, 36 },
37 37
38 /** 38 /**
39 * Controls which main pages are displayed via dom-ifs. 39 * Controls which main pages are displayed via dom-ifs.
40 * @type {!{about: boolean, basic: boolean, advanced: boolean}} 40 * @type {!{about: boolean, basic: boolean, advanced: boolean}}
41 * @private 41 * @private
42 */ 42 */
43 showPages_: { 43 showPages_: {
44 type: Object, 44 type: Object,
45 value: function() { 45 value: function() {
46 return {about: false, basic: false, advanced: false}; 46 return {about: false, basic: false, advanced: false};
Dan Beam 2016/08/10 23:17:41 can we just add the advanced toggle to this?
47 }, 47 },
48 }, 48 },
49 49
50 /**
51 * The main pages that were displayed before search was initiated.
52 * @type {?{about: boolean, basic: boolean, advanced: boolean}}
53 * @private
54 */
55 previousShowPages_: {
56 type: Object,
57 value: null,
58 },
59
50 /** @private */ 60 /** @private */
51 showNoResultsFound_: { 61 showNoResultsFound_: {
52 type: Boolean, 62 type: Boolean,
53 value: false, 63 value: false,
54 }, 64 },
55 65
56 toolbarSpinnerActive: { 66 toolbarSpinnerActive: {
57 type: Boolean, 67 type: Boolean,
58 value: false, 68 value: false,
59 notify: true, 69 notify: true,
60 }, 70 },
61 71
62 /** 72 /**
73 * Whether search results are being displayed. Used to hide the advanced
74 * page toggle.
75 */
76 showingSearchResults_: {
Dan Beam 2016/08/10 23:17:41 why do we need this if we can just check for previ
dpapad 2016/08/10 23:39:13 I am using showingSearchResults as a boolean var f
dpapad 2016/08/10 23:57:14 Done in latest patch.
77 type: Boolean,
78 value: false,
79 },
80
81 /**
63 * Dictionary defining page visibility. 82 * Dictionary defining page visibility.
64 * @type {!GuestModePageVisibility} 83 * @type {!GuestModePageVisibility}
65 */ 84 */
66 pageVisibility: { 85 pageVisibility: {
67 type: Object, 86 type: Object,
68 value: function() { return {}; }, 87 value: function() { return {}; },
69 }, 88 },
70 }, 89 },
71 90
72 /** @override */ 91 /** @override */
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 /** 124 /**
106 * @param {boolean} opened Whether the menu is expanded. 125 * @param {boolean} opened Whether the menu is expanded.
107 * @return {string} Which icon to use. 126 * @return {string} Which icon to use.
108 * @private 127 * @private
109 */ 128 */
110 arrowState_: function(opened) { 129 arrowState_: function(opened) {
111 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down'; 130 return opened ? 'settings:arrow-drop-up' : 'cr:arrow-drop-down';
112 }, 131 },
113 132
114 /** 133 /**
115 * @param {boolean} showBasicPage
116 * @param {boolean} inSubpage
117 * @return {boolean} 134 * @return {boolean}
118 * @private 135 * @private
119 */ 136 */
120 showAdvancedToggle_: function(showBasicPage, inSubpage) { 137 showAdvancedToggle_: function() {
121 return showBasicPage && !inSubpage; 138 return this.showPages_.basic && !this.inSubpage_ &&
139 !this.showingSearchResults_;
Dan Beam 2016/08/10 23:17:41 why is this part of the check needed?
dpapad 2016/08/10 23:39:13 This change causes the advanced toggle to be hidde
122 }, 140 },
123 141
124 /** @protected */ 142 /** @protected */
125 currentRouteChanged: function(newRoute) { 143 currentRouteChanged: function(newRoute) {
126 this.inSubpage_ = newRoute.subpage.length > 0; 144 this.inSubpage_ = newRoute.subpage.length > 0;
127 this.style.height = this.inSubpage_ ? '100%' : ''; 145 this.style.height = this.inSubpage_ ? '100%' : '';
128 146
129 if (settings.Route.ABOUT.contains(newRoute)) { 147 if (settings.Route.ABOUT.contains(newRoute)) {
130 this.showPages_ = {about: true, basic: false, advanced: false}; 148 this.showPages_ = {about: true, basic: false, advanced: false};
131 } else { 149 } else {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 */ 209 */
192 ensureInDefaultSearchPage_: function() { 210 ensureInDefaultSearchPage_: function() {
193 settings.navigateTo(settings.Route.BASIC); 211 settings.navigateTo(settings.Route.BASIC);
194 }, 212 },
195 213
196 /** 214 /**
197 * @param {string} query 215 * @param {string} query
198 * @return {!Promise} A promise indicating that searching finished. 216 * @return {!Promise} A promise indicating that searching finished.
199 */ 217 */
200 searchContents: function(query) { 218 searchContents: function(query) {
219 if (!this.showingSearchResults_) {
220 // Store which pages are shown before search, so that they can be restored
221 // after the user clears the search results.
222 this.previousShowPages_ = this.showPages_;
Dan Beam 2016/08/10 23:17:41 if this is available in the same scope, why do we
dpapad 2016/08/10 23:39:13 We need to cache the previousShowPages on this, be
223 this.showingSearchResults_ = true;
224 }
225
201 this.ensureInDefaultSearchPage_(); 226 this.ensureInDefaultSearchPage_();
202 this.toolbarSpinnerActive = true; 227 this.toolbarSpinnerActive = true;
203 228
204 // Trigger rendering of the basic and advanced pages and search once ready. 229 // Trigger rendering of the basic and advanced pages and search once ready.
205 this.showPages_ = {about: false, basic: true, advanced: true}; 230 this.showPages_ = {about: false, basic: true, advanced: true};
206 231
207 return new Promise(function(resolve, reject) { 232 return new Promise(function(resolve, reject) {
208 setTimeout(function() { 233 setTimeout(function() {
209 var whenSearchDone = settings.getSearchManager().search( 234 var whenSearchDone = settings.getSearchManager().search(
210 query, assert(this.$$('settings-basic-page'))); 235 query, assert(this.$$('settings-basic-page')));
211 assert( 236 assert(
212 whenSearchDone === 237 whenSearchDone ===
213 settings.getSearchManager().search( 238 settings.getSearchManager().search(
214 query, assert(this.$$('settings-advanced-page')))); 239 query, assert(this.$$('settings-advanced-page'))));
215 240
216 whenSearchDone.then(function(request) { 241 whenSearchDone.then(function(request) {
217 resolve(); 242 resolve();
218 if (!request.finished) { 243 if (!request.finished) {
219 // Nothing to do here. A previous search request was canceled 244 // Nothing to do here. A previous search request was canceled
220 // because a new search request was issued before the first one 245 // because a new search request was issued before the first one
221 // completed. 246 // completed.
222 return; 247 return;
223 } 248 }
224 249
225 this.toolbarSpinnerActive = false; 250 this.toolbarSpinnerActive = false;
251 this.showingSearchResults_ = !request.isSame('');
226 this.showNoResultsFound_ = 252 this.showNoResultsFound_ =
227 !request.isSame('') && !request.didFindMatches(); 253 this.showingSearchResults_ && !request.didFindMatches();
254
255 if (!this.showingSearchResults_) {
256 // Restore the pages that were shown before search was initiated.
257 this.showPages_ = assert(this.previousShowPages_);
258 this.previousShowPages_ = null;
259 }
228 }.bind(this)); 260 }.bind(this));
229 }.bind(this), 0); 261 }.bind(this), 0);
230 }.bind(this)); 262 }.bind(this));
231 }, 263 },
232 264
233 /** 265 /**
234 * @param {(boolean|undefined)} visibility 266 * @param {(boolean|undefined)} visibility
235 * @return {boolean} True unless visibility is false. 267 * @return {boolean} True unless visibility is false.
236 * @private 268 * @private
237 */ 269 */
238 showAdvancedSettings_: function(visibility) { 270 showAdvancedSettings_: function(visibility) {
239 return visibility !== false; 271 return visibility !== false;
240 }, 272 },
241 }); 273 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698