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

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

Issue 2176743004: MD Settings: Implementing a "no results" page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * @type {!{about: boolean, basic: boolean, advanced: boolean}} 42 * @type {!{about: boolean, basic: boolean, advanced: boolean}}
43 * @private 43 * @private
44 */ 44 */
45 showPages_: { 45 showPages_: {
46 type: Object, 46 type: Object,
47 value: function() { 47 value: function() {
48 return {about: false, basic: false, advanced: false}; 48 return {about: false, basic: false, advanced: false};
49 }, 49 },
50 }, 50 },
51 51
52 /** @private */
53 showNoResultsFound_: {
54 type: Boolean,
55 value: false,
56 },
57
52 toolbarSpinnerActive: { 58 toolbarSpinnerActive: {
53 type: Boolean, 59 type: Boolean,
54 value: false, 60 value: false,
55 notify: true, 61 notify: true,
56 }, 62 },
57 }, 63 },
58 64
59 /** @override */ 65 /** @override */
60 created: function() { 66 created: function() {
61 /** @private {!PromiseResolver} */ 67 /** @private {!PromiseResolver} */
62 this.resolver_ = new PromiseResolver; 68 this.resolver_ = new PromiseResolver;
63 settings.main.rendered = this.resolver_.promise; 69 settings.main.rendered = this.resolver_.promise;
64 }, 70 },
65 71
66 /** @override */ 72 /** @override */
67 ready: function() {
68 settings.getSearchManager().setCallback(function(isRunning) {
69 this.toolbarSpinnerActive = isRunning;
70 }.bind(this));
71 },
72
73 /** @override */
74 attached: function() { 73 attached: function() {
75 document.addEventListener('toggle-advanced-page', function(e) { 74 document.addEventListener('toggle-advanced-page', function(e) {
76 this.advancedToggleExpanded_ = e.detail; 75 this.advancedToggleExpanded_ = e.detail;
77 this.currentRoute = { 76 this.currentRoute = {
78 page: this.advancedToggleExpanded_ ? 'advanced' : 'basic', 77 page: this.advancedToggleExpanded_ ? 'advanced' : 'basic',
79 section: '', 78 section: '',
80 subpage: [], 79 subpage: [],
81 }; 80 };
82 }.bind(this)); 81 }.bind(this));
83 82
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 this.currentRoute.subpage.length != 0) { 146 this.currentRoute.subpage.length != 0) {
148 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; 147 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''};
149 } 148 }
150 }, 149 },
151 150
152 /** 151 /**
153 * @param {string} query 152 * @param {string} query
154 */ 153 */
155 searchContents: function(query) { 154 searchContents: function(query) {
156 this.ensureInDefaultSearchPage_(); 155 this.ensureInDefaultSearchPage_();
156 this.toolbarSpinnerActive = true;
157 157
158 // Trigger rendering of the basic and advanced pages and search once ready. 158 // Trigger rendering of the basic and advanced pages and search once ready.
159 // Even if those are already rendered, yield to the message loop before
160 // initiating searching.
161 this.showPages_ = {about: false, basic: true, advanced: true}; 159 this.showPages_ = {about: false, basic: true, advanced: true};
160
162 setTimeout(function() { 161 setTimeout(function() {
163 settings.getSearchManager().search( 162 settings.getSearchManager().search(
164 query, assert(this.$$('settings-basic-page'))); 163 query, assert(this.$$('settings-basic-page')));
165 }.bind(this), 0); 164 }.bind(this), 0);
166 setTimeout(function() { 165 setTimeout(function() {
167 settings.getSearchManager().search( 166 settings.getSearchManager().search(
168 query, assert(this.$$('settings-advanced-page'))); 167 query, assert(this.$$('settings-advanced-page'))).then(
168 function(request) {
169 this.toolbarSpinnerActive = false;
170 this.showNoResultsFound_ =
171 !request.isSame('') && !request.didFindMatches();
172 }.bind(this),
173 function() {
174 // Nothing to do here. A previous search request was canceled
175 // because a new search request was issued before the first one
176 // completed. This callback is necessary to avoid an "Uncaught
177 // Promise error" in the console.
Dan Beam 2016/07/26 02:39:31 it's arguable that we should just resolve(null) or
dpapad 2016/07/26 17:19:57 Done, added 'finished' boolean.
178 });
169 }.bind(this), 0); 179 }.bind(this), 0);
170 }, 180 },
171 }); 181 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698