Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 118 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 118 newRoute.page == 'advanced'; | 119 newRoute.page == 'advanced'; |
| 119 | 120 |
| 120 this.style.height = isSubpage ? '100%' : ''; | 121 this.style.height = isSubpage ? '100%' : ''; |
| 121 }, | 122 }, |
| 122 | 123 |
| 123 /** @private */ | 124 /** @private */ |
| 124 toggleAdvancedPage_: function() { | 125 toggleAdvancedPage_: function() { |
| 125 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 126 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 126 }, | 127 }, |
| 128 | |
| 129 /** | |
| 130 * Navigates to the default search page (if necessary). | |
| 131 * @private | |
| 132 */ | |
| 133 ensureInDefaultSearchPage_: function() { | |
| 134 if (this.currentRoute.page != 'basic' || | |
| 135 this.currentRoute.section != '' || | |
| 136 this.currentRoute.subpage.length != 0) { | |
| 137 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; | |
|
Dan Beam
2016/07/01 21:32:35
nit: can you just omit the URL? and maybe add a ro
dpapad
2016/07/01 21:59:42
The 'url' field is needed only for the Compiler. I
Dan Beam
2016/07/01 22:41:01
fun fact: it's only required if you:
a) depend set
Dan Beam
2016/07/01 22:48:27
or dschuyler@'s CL that makes url: (string|undefin
| |
| 138 } | |
| 139 }, | |
| 140 | |
| 141 /** | |
| 142 * @param {string} query | |
| 143 */ | |
| 144 searchContents: function(query) { | |
| 145 this.ensureInDefaultSearchPage_(); | |
| 146 | |
| 147 // Trigger rendering of the basic and advanced pages and search once ready. | |
| 148 // Even if those are already rendered, yield to the message loop before | |
| 149 // initiating searching. | |
| 150 this.showBasicPage_ = true; | |
| 151 setTimeout(function() { | |
| 152 settings.search(query, assert(this.$$('settings-basic-page'))); | |
| 153 }.bind(this), 0); | |
| 154 | |
| 155 this.showAdvancedPage_ = true; | |
| 156 setTimeout(function() { | |
| 157 settings.search(query, assert(this.$$('settings-advanced-page'))); | |
| 158 }.bind(this), 0); | |
| 159 }, | |
| 127 }); | 160 }); |
| OLD | NEW |