OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 /** @const */ var Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 /** | 9 /** |
10 * Encapsulated handling of a search bubble. | 10 * Encapsulated handling of a search bubble. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 * @private | 260 * @private |
261 */ | 261 */ |
262 setSearchText_: function(text) { | 262 setSearchText_: function(text) { |
263 // Prevent recursive execution of this method. | 263 // Prevent recursive execution of this method. |
264 if (this.insideSetSearchText_) return; | 264 if (this.insideSetSearchText_) return; |
265 this.insideSetSearchText_ = true; | 265 this.insideSetSearchText_ = true; |
266 | 266 |
267 // Cleanup the search query string. | 267 // Cleanup the search query string. |
268 text = SearchPage.canonicalizeQuery(text); | 268 text = SearchPage.canonicalizeQuery(text); |
269 | 269 |
270 // Set the hash on the current page, and the enclosing uber page | 270 // Set the hash on the current page, and the enclosing uber page. Only to |
Dan Beam
2014/08/06 18:34:03
s/to/do/
davidben
2014/08/06 18:38:13
Done.
| |
271 // this if the page is not current. See https://crbug.com/401004. | |
271 var hash = text ? '#' + encodeURIComponent(text) : ''; | 272 var hash = text ? '#' + encodeURIComponent(text) : ''; |
272 var path = text ? this.name : ''; | 273 var path = text ? this.name : ''; |
273 uber.pushState({}, path + hash); | 274 if (location.hash != hash || location.pathname != '/' + path) |
275 uber.pushState({}, path + hash); | |
274 | 276 |
275 // Toggle the search page if necessary. | 277 // Toggle the search page if necessary. |
276 if (text) { | 278 if (text) { |
277 if (!this.searchActive_) | 279 if (!this.searchActive_) |
278 PageManager.showPageByName(this.name, false); | 280 PageManager.showPageByName(this.name, false); |
279 } else { | 281 } else { |
280 if (this.searchActive_) | 282 if (this.searchActive_) |
281 PageManager.showDefaultPage(false); | 283 PageManager.showDefaultPage(false); |
282 | 284 |
283 this.insideSetSearchText_ = false; | 285 this.insideSetSearchText_ = false; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 // Trim beginning and ending whitespace. | 568 // Trim beginning and ending whitespace. |
567 return text.replace(/^\s+|\s+$/g, ''); | 569 return text.replace(/^\s+|\s+$/g, ''); |
568 }; | 570 }; |
569 | 571 |
570 // Export | 572 // Export |
571 return { | 573 return { |
572 SearchPage: SearchPage | 574 SearchPage: SearchPage |
573 }; | 575 }; |
574 | 576 |
575 }); | 577 }); |
OLD | NEW |