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} | |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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; |
119 | 128 |
120 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; | 129 this.showBasicPage_ = this.showAdvancedToggle_ || newRoute.page == 'basic'; |
121 | 130 |
131 if (newRoute.page == 'advanced') | |
michaelpg
2016/07/20 19:40:46
{} around multi-line if bodies
Moe
2016/07/21 18:27:32
Done.
| |
132 assert(! /** @type {{hideAdvancedSettings: boolean}} */ | |
michaelpg
2016/07/20 19:40:46
this cast isn't right: the thing in parens is a bo
Moe
2016/07/21 18:27:32
Done.
| |
133 (this.pageVisibility.hideAdvancedSettings)); | |
134 | |
122 this.showAdvancedPage_ = | 135 this.showAdvancedPage_ = |
123 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || | 136 (this.isAdvancedMenuOpen_ && this.showAdvancedToggle_) || |
124 newRoute.page == 'advanced'; | 137 newRoute.page == 'advanced'; |
125 | 138 |
126 this.style.height = isSubpage ? '100%' : ''; | 139 this.style.height = isSubpage ? '100%' : ''; |
127 }, | 140 }, |
128 | 141 |
129 /** @private */ | 142 /** @private */ |
130 toggleAdvancedPage_: function() { | 143 toggleAdvancedPage_: function() { |
131 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); | 144 this.fire('toggle-advanced-page', !this.isAdvancedMenuOpen_); |
132 }, | 145 }, |
133 | 146 |
134 /** | 147 /** |
135 * Navigates to the default search page (if necessary). | 148 * Navigates to the default search page (if necessary). |
136 * @private | 149 * @private |
137 */ | 150 */ |
138 ensureInDefaultSearchPage_: function() { | 151 ensureInDefaultSearchPage_: function() { |
139 if (this.currentRoute.page != 'basic' || | 152 if (this.currentRoute.page != 'basic' || |
140 this.currentRoute.section != '' || | 153 this.currentRoute.section != '' || |
141 this.currentRoute.subpage.length != 0) { | 154 this.currentRoute.subpage.length != 0) { |
142 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; | 155 this.currentRoute = {page: 'basic', section: '', subpage: [], url: ''}; |
143 } | 156 } |
144 }, | 157 }, |
145 | 158 |
146 /** | 159 /** |
147 * @param {string} query | 160 * @param {string} query |
148 */ | 161 */ |
149 searchContents: function(query) { | 162 searchContents: function(query) { |
163 assert(! /** @type {{hideToolbarSearchField: boolean}} */ | |
michaelpg
2016/07/20 19:40:46
ditto
Moe
2016/07/21 18:27:32
took search related parts out.
| |
164 (this.pageVisibility.hideToolbarSearchField)); | |
165 | |
150 this.ensureInDefaultSearchPage_(); | 166 this.ensureInDefaultSearchPage_(); |
151 | 167 |
152 // Trigger rendering of the basic and advanced pages and search once ready. | 168 // 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 | 169 // Even if those are already rendered, yield to the message loop before |
154 // initiating searching. | 170 // initiating searching. |
155 this.showBasicPage_ = true; | 171 this.showBasicPage_ = true; |
156 setTimeout(function() { | 172 setTimeout(function() { |
157 settings.search(query, assert(this.$$('settings-basic-page'))); | 173 settings.search(query, assert(this.$$('settings-basic-page'))); |
158 }.bind(this), 0); | 174 }.bind(this), 0); |
159 | 175 |
160 this.showAdvancedPage_ = true; | 176 this.showAdvancedPage_ = true; |
161 setTimeout(function() { | 177 setTimeout(function() { |
162 settings.search(query, assert(this.$$('settings-advanced-page'))); | 178 settings.search(query, assert(this.$$('settings-advanced-page'))); |
163 }.bind(this), 0); | 179 }.bind(this), 0); |
164 }, | 180 }, |
165 }); | 181 }); |
OLD | NEW |