| 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-basic-page' is the settings page containing the actual settings. | 7 * 'settings-basic-page' is the settings page containing the actual settings. |
| 8 */ | 8 */ |
| 9 Polymer({ | 9 Polymer({ |
| 10 is: 'settings-basic-page', | 10 is: 'settings-basic-page', |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 * @param {string} query The text to search for. | 133 * @param {string} query The text to search for. |
| 134 * @return {!Promise<!settings.SearchResult>} A signal indicating that | 134 * @return {!Promise<!settings.SearchResult>} A signal indicating that |
| 135 * searching finished. | 135 * searching finished. |
| 136 */ | 136 */ |
| 137 searchContents: function(query) { | 137 searchContents: function(query) { |
| 138 var whenSearchDone = [ | 138 var whenSearchDone = [ |
| 139 settings.getSearchManager().search(query, assert(this.$$('#basicPage'))), | 139 settings.getSearchManager().search(query, assert(this.$$('#basicPage'))), |
| 140 ]; | 140 ]; |
| 141 | 141 |
| 142 if (this.pageVisibility.advancedSettings !== false) { | 142 if (this.pageVisibility.advancedSettings !== false) { |
| 143 whenSearchDone.push(this.$$('#advancedPageTemplate').get().then( | 143 whenSearchDone.push( |
| 144 function(advancedPage) { | 144 this.$$('#advancedPageTemplate').get().then(function(advancedPage) { |
| 145 return settings.getSearchManager().search(query, advancedPage); | 145 return settings.getSearchManager().search(query, advancedPage); |
| 146 })); | 146 })); |
| 147 } | 147 } |
| 148 | 148 |
| 149 return Promise.all(whenSearchDone).then(function(requests) { | 149 return Promise.all(whenSearchDone).then(function(requests) { |
| 150 // Combine the SearchRequests results to a single SearchResult object. | 150 // Combine the SearchRequests results to a single SearchResult object. |
| 151 return { | 151 return { |
| 152 canceled: requests.some(function(r) { return r.canceled; }), | 152 canceled: requests.some(function(r) { |
| 153 return r.canceled; |
| 154 }), |
| 153 didFindMatches: requests.some(function(r) { | 155 didFindMatches: requests.some(function(r) { |
| 154 return r.didFindMatches(); | 156 return r.didFindMatches(); |
| 155 }), | 157 }), |
| 156 // All requests correspond to the same user query, so only need to check | 158 // All requests correspond to the same user query, so only need to check |
| 157 // one of them. | 159 // one of them. |
| 158 wasClearSearch: requests[0].isSame(''), | 160 wasClearSearch: requests[0].isSame(''), |
| 159 }; | 161 }; |
| 160 }); | 162 }); |
| 161 }, | 163 }, |
| 162 | 164 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 * @param {!settings.Route} currentRoute | 234 * @param {!settings.Route} currentRoute |
| 233 * @param {boolean} inSearchMode | 235 * @param {boolean} inSearchMode |
| 234 * @param {boolean} hasExpandedSection | 236 * @param {boolean} hasExpandedSection |
| 235 * @param {boolean} advancedToggleExpanded | 237 * @param {boolean} advancedToggleExpanded |
| 236 * @return {boolean} Whether to show the advanced page, taking into account | 238 * @return {boolean} Whether to show the advanced page, taking into account |
| 237 * both routing and search state. | 239 * both routing and search state. |
| 238 * @private | 240 * @private |
| 239 */ | 241 */ |
| 240 showAdvancedPage_: function( | 242 showAdvancedPage_: function( |
| 241 currentRoute, inSearchMode, hasExpandedSection, advancedToggleExpanded) { | 243 currentRoute, inSearchMode, hasExpandedSection, advancedToggleExpanded) { |
| 242 return hasExpandedSection ? | 244 return hasExpandedSection ? settings.Route.ADVANCED.contains(currentRoute) : |
| 243 settings.Route.ADVANCED.contains(currentRoute) : | 245 advancedToggleExpanded || inSearchMode; |
| 244 advancedToggleExpanded || inSearchMode; | |
| 245 }, | 246 }, |
| 246 | 247 |
| 247 /** | 248 /** |
| 248 * @param {(boolean|undefined)} visibility | 249 * @param {(boolean|undefined)} visibility |
| 249 * @return {boolean} True unless visibility is false. | 250 * @return {boolean} True unless visibility is false. |
| 250 * @private | 251 * @private |
| 251 */ | 252 */ |
| 252 showAdvancedSettings_: function(visibility) { | 253 showAdvancedSettings_: function(visibility) { |
| 253 return visibility !== false; | 254 return visibility !== false; |
| 254 }, | 255 }, |
| 255 | 256 |
| 256 /** | 257 /** |
| 257 * @param {boolean} opened Whether the menu is expanded. | 258 * @param {boolean} opened Whether the menu is expanded. |
| 258 * @return {string} Icon name. | 259 * @return {string} Icon name. |
| 259 * @private | 260 * @private |
| 260 */ | 261 */ |
| 261 getArrowIcon_: function(opened) { | 262 getArrowIcon_: function(opened) { |
| 262 return opened ? 'cr:arrow-drop-up' : 'cr:arrow-drop-down'; | 263 return opened ? 'cr:arrow-drop-up' : 'cr:arrow-drop-down'; |
| 263 }, | 264 }, |
| 264 }); | 265 }); |
| OLD | NEW |