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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 showAboutPage_: { | 56 showAboutPage_: { |
| 57 type: Boolean, | 57 type: Boolean, |
| 58 value: false, | 58 value: false, |
| 59 }, | 59 }, |
| 60 | 60 |
| 61 toolbarSpinnerActive: { | 61 toolbarSpinnerActive: { |
| 62 type: Boolean, | 62 type: Boolean, |
| 63 value: false, | 63 value: false, |
| 64 notify: true, | 64 notify: true, |
| 65 }, | 65 }, |
| 66 | |
| 67 /** | |
| 68 * Dictionary defining page visibility. | |
| 69 */ | |
| 70 pageVisibility: { | |
| 71 type: Object, | |
| 72 }, | |
| 66 }, | 73 }, |
| 67 | 74 |
| 68 /** @override */ | 75 /** @override */ |
| 69 created: function() { | 76 created: function() { |
| 70 /** @private {!PromiseResolver} */ | 77 /** @private {!PromiseResolver} */ |
| 71 this.resolver_ = new PromiseResolver; | 78 this.resolver_ = new PromiseResolver; |
| 72 settings.main.rendered = this.resolver_.promise; | 79 settings.main.rendered = this.resolver_.promise; |
| 73 }, | 80 }, |
| 74 | 81 |
| 75 /** @override */ | 82 /** @override */ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 */ | 123 */ |
| 117 currentRouteChanged_: function(newRoute) { | 124 currentRouteChanged_: function(newRoute) { |
| 118 var isSubpage = !!newRoute.subpage.length; | 125 var isSubpage = !!newRoute.subpage.length; |
| 119 | 126 |
| 120 this.showAboutPage_ = newRoute.page == 'about'; | 127 this.showAboutPage_ = newRoute.page == 'about'; |
| 121 | 128 |
| 122 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; | 129 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
| 123 | 130 |
| 124 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | 131 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
| 125 | 132 |
| 133 if (newRoute.page == 'advanced') { | |
| 134 var pageVisibility = /** @type {{hideAdvancedSettings: boolean}} */ | |
| 135 (this.pageVisibility); | |
| 136 assert(!pageVisibility.hideAdvancedSettings); | |
| 137 } | |
| 138 | |
| 126 this.showAdvancedPage_ = | 139 this.showAdvancedPage_ = |
| 127 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 140 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 128 newRoute.page == 'advanced'; | 141 newRoute.page == 'advanced'; |
| 129 | 142 |
| 130 this.style.height = isSubpage ? '100%' : ''; | 143 this.style.height = isSubpage ? '100%' : ''; |
| 131 }, | 144 }, |
| 132 | 145 |
| 133 /** @private */ | 146 /** @private */ |
| 134 toggleAdvancedPage_: function() { | 147 toggleAdvancedPage_: function() { |
| 135 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 148 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 136 }, | 149 }, |
| 137 | 150 |
| 138 /** | 151 /** |
| 139 * Navigates to the default search page (if necessary). | 152 * Navigates to the default search page (if necessary). |
| 140 * @private | 153 * @private |
| 141 */ | 154 */ |
| 142 ensureInDefaultSearchPage_: function() { | 155 ensureInDefaultSearchPage_: function() { |
| 143 if (this.currentRoute.page != 'basic' || | 156 if (this.currentRoute.page != 'basic' || |
| 144 this.currentRoute.section != '' || | 157 this.currentRoute.section != '' || |
| 145 this.currentRoute.subpage.length != 0) { | 158 this.currentRoute.subpage.length != 0) { |
| 146 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; | 159 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; |
| 147 } | 160 } |
| 148 }, | 161 }, |
| 149 | 162 |
| 150 /** | 163 /** |
| 151 * @param {string} query | 164 * @param {string} query |
| 152 */ | 165 */ |
| 153 searchContents: function(query) { | 166 searchContents: function(query) { |
| 167 assert(! /** @type {{hideToolbarSearchField: boolean}} */ | |
|
michaelpg
2016/07/21 21:58:44
remove for now?
Moe
2016/07/22 16:59:56
done.
| |
| 168 (this.pageVisibility.hideToolbarSearchField)); | |
| 169 | |
| 154 this.ensureInDefaultSearchPage_(); | 170 this.ensureInDefaultSearchPage_(); |
| 155 | 171 |
| 156 // Trigger rendering of the basic and advanced pages and search once ready. | 172 // Trigger rendering of the basic and advanced pages and search once ready. |
| 157 // Even if those are already rendered, yield to the message loop before | 173 // Even if those are already rendered, yield to the message loop before |
| 158 // initiating searching. | 174 // initiating searching. |
| 159 this.showBasicPage_ = true; | 175 this.showBasicPage_ = true; |
| 160 setTimeout(function() { | 176 setTimeout(function() { |
| 161 settings.getSearchManager().search( | 177 settings.getSearchManager().search( |
| 162 query, assert(this.$$('settings-basic-page'))); | 178 query, assert(this.$$('settings-basic-page'))); |
| 163 }.bind(this), 0); | 179 }.bind(this), 0); |
| 164 | 180 |
| 165 this.showAdvancedPage_ = true; | 181 this.showAdvancedPage_ = true; |
| 166 setTimeout(function() { | 182 setTimeout(function() { |
| 167 settings.getSearchManager().search( | 183 settings.getSearchManager().search( |
| 168 query, assert(this.$$('settings-advanced-page'))); | 184 query, assert(this.$$('settings-advanced-page'))); |
| 169 }.bind(this), 0); | 185 }.bind(this), 0); |
| 170 }, | 186 }, |
| 171 }); | 187 }); |
| OLD | NEW |