| 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-ui' implements the UI for the Settings page. | 7 * 'settings-ui' implements the UI for the Settings page. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * | 10 * |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 this.$.main.searchContents(urlSearchQuery); | 155 this.$.main.searchContents(urlSearchQuery); |
| 156 }, | 156 }, |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * Handles the 'search-changed' event fired from the toolbar. | 159 * Handles the 'search-changed' event fired from the toolbar. |
| 160 * @param {!Event} e | 160 * @param {!Event} e |
| 161 * @private | 161 * @private |
| 162 */ | 162 */ |
| 163 onSearchChanged_: function(e) { | 163 onSearchChanged_: function(e) { |
| 164 var query = e.detail; | 164 // Trim leading whitespace only, to prevent searching for empty string. This |
| 165 // still allows the user to search for 'foo bar', while taking a long pause |
| 166 // after typing 'foo '. |
| 167 var query = e.detail.replace(/^\s+/, ''); |
| 168 // Prevent duplicate history entries. |
| 169 if (query == this.lastSearchQuery_) |
| 170 return; |
| 171 |
| 165 settings.navigateTo( | 172 settings.navigateTo( |
| 166 settings.Route.BASIC, | 173 settings.Route.BASIC, |
| 167 query.length > 0 ? | 174 query.length > 0 ? |
| 168 new URLSearchParams(`search=${query}`) : undefined); | 175 new URLSearchParams(`search=${query}`) : undefined); |
| 169 }, | 176 }, |
| 170 | 177 |
| 171 /** | 178 /** |
| 172 * @param {Event} event | 179 * @param {Event} event |
| 173 * @private | 180 * @private |
| 174 */ | 181 */ |
| 175 onIronActivate_: function(event) { | 182 onIronActivate_: function(event) { |
| 176 if (event.detail.item.id != 'advancedPage') | 183 if (event.detail.item.id != 'advancedPage') |
| 177 this.$$('app-drawer').close(); | 184 this.$$('app-drawer').close(); |
| 178 }, | 185 }, |
| 179 | 186 |
| 180 /** @private */ | 187 /** @private */ |
| 181 onMenuButtonTap_: function() { | 188 onMenuButtonTap_: function() { |
| 182 this.$$('app-drawer').toggle(); | 189 this.$$('app-drawer').toggle(); |
| 183 }, | 190 }, |
| 184 | 191 |
| 185 /** @private */ | 192 /** @private */ |
| 186 directionDelegateChanged_: function() { | 193 directionDelegateChanged_: function() { |
| 187 this.$$('app-drawer').align = this.directionDelegate.isRtl() ? | 194 this.$$('app-drawer').align = this.directionDelegate.isRtl() ? |
| 188 'right' : 'left'; | 195 'right' : 'left'; |
| 189 }, | 196 }, |
| 190 }); | 197 }); |
| OLD | NEW |