| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 if (!request.finished) { |
| 170 // Nothing to do here. A previous search request was canceled |
| 171 // because a new search request was issued before the first one |
| 172 // completed. |
| 173 return; |
| 174 } |
| 175 |
| 176 this.toolbarSpinnerActive = false; |
| 177 this.showNoResultsFound_ = |
| 178 !request.isSame('') && !request.didFindMatches(); |
| 179 }.bind(this)); |
| 169 }.bind(this), 0); | 180 }.bind(this), 0); |
| 170 }, | 181 }, |
| 171 }); | 182 }); |
| OLD | NEW |