| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 value: true, | 52 value: true, |
| 53 }, | 53 }, |
| 54 | 54 |
| 55 /** @private */ | 55 /** @private */ |
| 56 showAboutPage_: { | 56 showAboutPage_: { |
| 57 type: Boolean, | 57 type: Boolean, |
| 58 value: false, | 58 value: false, |
| 59 }, | 59 }, |
| 60 }, | 60 }, |
| 61 | 61 |
| 62 /** @override */ |
| 62 created: function() { | 63 created: function() { |
| 63 /** @private {!PromiseResolver} */ | 64 /** @private {!PromiseResolver} */ |
| 64 this.resolver_ = new PromiseResolver; | 65 this.resolver_ = new PromiseResolver; |
| 65 settings.main.rendered = this.resolver_.promise; | 66 settings.main.rendered = this.resolver_.promise; |
| 66 }, | 67 }, |
| 67 | 68 |
| 68 attached: function() { | 69 attached: function() { |
| 69 document.addEventListener('toggle-advanced-page', function(e) { | 70 document.addEventListener('toggle-advanced-page', function(e) { |
| 70 this.showAdvancedPage_ = e.detail; | 71 this.showAdvancedPage_ = e.detail; |
| 71 this.isAdvancedMenuOpen_ = e.detail; | 72 this.isAdvancedMenuOpen_ = e.detail; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 123 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 123 newRoute.page == 'advanced'; | 124 newRoute.page == 'advanced'; |
| 124 | 125 |
| 125 this.style.height = isSubpage ? '100%' : ''; | 126 this.style.height = isSubpage ? '100%' : ''; |
| 126 }, | 127 }, |
| 127 | 128 |
| 128 /** @private */ | 129 /** @private */ |
| 129 toggleAdvancedPage_: function() { | 130 toggleAdvancedPage_: function() { |
| 130 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 131 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 131 }, | 132 }, |
| 133 |
| 134 /** |
| 135 * Navigates to the default search page (if necessary). |
| 136 * @private |
| 137 */ |
| 138 ensureInDefaultSearchPage_: function() { |
| 139 if (this.currentRoute.page != 'basic' || |
| 140 this.currentRoute.section != '' || |
| 141 this.currentRoute.subpage.length != 0) { |
| 142 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; |
| 143 } |
| 144 }, |
| 145 |
| 146 /** |
| 147 * @param {string} query |
| 148 */ |
| 149 searchContents: function(query) { |
| 150 this.ensureInDefaultSearchPage_(); |
| 151 |
| 152 // Trigger rendering of the basic and advanced pages and search once ready. |
| 153 // Even if those are already rendered, yield to the message loop before |
| 154 // initiating searching. |
| 155 this.showBasicPage_ = true; |
| 156 setTimeout(function() { |
| 157 settings.search(query, assert(this.$$('settings-basic-page'))); |
| 158 }.bind(this), 0); |
| 159 |
| 160 this.showAdvancedPage_ = true; |
| 161 setTimeout(function() { |
| 162 settings.search(query, assert(this.$$('settings-advanced-page'))); |
| 163 }.bind(this), 0); |
| 164 }, |
| 132 }); | 165 }); |
| OLD | NEW |