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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 showBasicPage_: { | 50 showBasicPage_: { |
| 51 type: Boolean, | 51 type: Boolean, |
| 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 | |
| 61 /** | |
| 62 * Dictionary defining page visibility. | |
| 63 * @type {Object<boolean>} | |
| 64 */ | |
| 65 pageVisibility: { | |
| 66 type: Object, | |
| 67 value: function() { return {}; }, | |
| 68 }, | |
| 60 }, | 69 }, |
| 61 | 70 |
| 62 /** @override */ | 71 /** @override */ |
| 63 created: function() { | 72 created: function() { |
| 64 /** @private {!PromiseResolver} */ | 73 /** @private {!PromiseResolver} */ |
| 65 this.resolver_ = new PromiseResolver; | 74 this.resolver_ = new PromiseResolver; |
| 66 settings.main.rendered = this.resolver_.promise; | 75 settings.main.rendered = this.resolver_.promise; |
| 67 }, | 76 }, |
| 68 | 77 |
| 69 attached: function() { | 78 attached: function() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 117 |
| 109 /** | 118 /** |
| 110 * @param {!SettingsRoute} newRoute | 119 * @param {!SettingsRoute} newRoute |
| 111 * @private | 120 * @private |
| 112 */ | 121 */ |
| 113 currentRouteChanged_: function(newRoute) { | 122 currentRouteChanged_: function(newRoute) { |
| 114 var isSubpage = !!newRoute.subpage.length; | 123 var isSubpage = !!newRoute.subpage.length; |
| 115 | 124 |
| 116 this.showAboutPage_ = newRoute.page == 'about'; | 125 this.showAboutPage_ = newRoute.page == 'about'; |
| 117 | 126 |
| 118 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; | 127 this.showAdvancedToggle_ = !this.showAboutPage_ && !isSubpage; |
|
michaelpg
2016/07/13 00:01:35
&& !this.pageVisibility.hideAdvancedSettings
Moe
2016/07/13 20:17:17
the logic should probably be more like (which IMO
michaelpg
2016/07/14 00:31:28
Acknowledged.
| |
| 119 | 128 |
| 120 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | 129 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
| 121 | 130 |
| 122 this.showAdvancedPage_ = | 131 this.showAdvancedPage_ = |
| 123 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 132 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
| 124 newRoute.page == 'advanced'; | 133 newRoute.page == 'advanced'; |
|
michaelpg
2016/07/13 00:01:36
It's probably worth asserting
!pageVisibility.
Moe
2016/07/13 20:17:17
do you think this is this still needed if we go wi
michaelpg
2016/07/14 00:31:28
Yeah. My reasoning is that asking for an Advanced
Moe
2016/07/14 17:19:55
We should be good here. chrome://md-settings/advan
| |
| 125 | 134 |
| 126 this.style.height = isSubpage ? '100%' : ''; | 135 this.style.height = isSubpage ? '100%' : ''; |
| 127 }, | 136 }, |
| 128 | 137 |
| 129 /** @private */ | 138 /** @private */ |
| 130 toggleAdvancedPage_: function() { | 139 toggleAdvancedPage_: function() { |
| 131 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 140 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
| 132 }, | 141 }, |
| 133 | 142 |
| 134 /** | 143 /** |
| 135 * Navigates to the default search page (if necessary). | 144 * Navigates to the default search page (if necessary). |
| 136 * @private | 145 * @private |
| 137 */ | 146 */ |
| 138 ensureInDefaultSearchPage_: function() { | 147 ensureInDefaultSearchPage_: function() { |
| 139 if (this.currentRoute.page != 'basic' || | 148 if (this.currentRoute.page != 'basic' || |
| 140 this.currentRoute.section != '' || | 149 this.currentRoute.section != '' || |
| 141 this.currentRoute.subpage.length != 0) { | 150 this.currentRoute.subpage.length != 0) { |
| 142 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; | 151 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; |
| 143 } | 152 } |
| 144 }, | 153 }, |
| 145 | 154 |
| 146 /** | 155 /** |
| 147 * @param {string} query | 156 * @param {string} query |
| 148 */ | 157 */ |
| 149 searchContents: function(query) { | 158 searchContents: function(query) { |
| 150 this.ensureInDefaultSearchPage_(); | 159 this.ensureInDefaultSearchPage_(); |
|
michaelpg
2016/07/13 00:01:36
assert !hideSearch
if that's a thing.
Moe
2016/07/13 20:17:17
Done.
| |
| 151 | 160 |
| 152 // Trigger rendering of the basic and advanced pages and search once ready. | 161 // 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 | 162 // Even if those are already rendered, yield to the message loop before |
| 154 // initiating searching. | 163 // initiating searching. |
| 155 this.showBasicPage_ = true; | 164 this.showBasicPage_ = true; |
| 156 setTimeout(function() { | 165 setTimeout(function() { |
| 157 settings.search(query, assert(this.$$('settings-basic-page'))); | 166 settings.search(query, assert(this.$$('settings-basic-page'))); |
| 158 }.bind(this), 0); | 167 }.bind(this), 0); |
| 159 | 168 |
| 160 this.showAdvancedPage_ = true; | 169 this.showAdvancedPage_ = true; |
| 161 setTimeout(function() { | 170 setTimeout(function() { |
| 162 settings.search(query, assert(this.$$('settings-advanced-page'))); | 171 settings.search(query, assert(this.$$('settings-advanced-page'))); |
| 163 }.bind(this), 0); | 172 }.bind(this), 0); |
| 164 }, | 173 }, |
| 165 }); | 174 }); |
| OLD | NEW |