| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 OptionsPage = options.OptionsPage; | 6 const OptionsPage = options.OptionsPage; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Encapsulated handling of a search bubble. | 9 * Encapsulated handling of a search bubble. |
| 10 * @constructor | 10 * @constructor |
| 11 */ | 11 */ |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 this.unhighlightMatches_(); | 234 this.unhighlightMatches_(); |
| 235 this.removeSearchBubbles_(); | 235 this.removeSearchBubbles_(); |
| 236 | 236 |
| 237 // Generate search text by applying lowercase and escaping any characters | 237 // Generate search text by applying lowercase and escaping any characters |
| 238 // that would be problematic for regular expressions. | 238 // that would be problematic for regular expressions. |
| 239 var searchText = | 239 var searchText = |
| 240 text.toLowerCase().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | 240 text.toLowerCase().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); |
| 241 | 241 |
| 242 // Generate a regular expression and replace string for hilighting | 242 // Generate a regular expression and replace string for hilighting |
| 243 // search terms. | 243 // search terms. |
| 244 var regEx = new RegExp('(\\b' + searchText + ')', 'ig'); | 244 var regEx = new RegExp('(' + searchText + ')', 'ig'); |
| 245 var replaceString = '<span class="search-highlighted">$1</span>'; | 245 var replaceString = '<span class="search-highlighted">$1</span>'; |
| 246 | 246 |
| 247 // Initialize all sections. If the search string matches a title page, | 247 // Initialize all sections. If the search string matches a title page, |
| 248 // show sections for that page. | 248 // show sections for that page. |
| 249 var page, pageMatch, childDiv, length; | 249 var page, pageMatch, childDiv, length; |
| 250 var pagesToSearch = this.getSearchablePages_(); | 250 var pagesToSearch = this.getSearchablePages_(); |
| 251 for (var key in pagesToSearch) { | 251 for (var key in pagesToSearch) { |
| 252 page = pagesToSearch[key]; | 252 page = pagesToSearch[key]; |
| 253 pageMatch = false; | 253 pageMatch = false; |
| 254 if (searchText.length) { | 254 if (searchText.length) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 474 } |
| 475 } | 475 } |
| 476 }; | 476 }; |
| 477 | 477 |
| 478 // Export | 478 // Export |
| 479 return { | 479 return { |
| 480 SearchPage: SearchPage | 480 SearchPage: SearchPage |
| 481 }; | 481 }; |
| 482 | 482 |
| 483 }); | 483 }); |
| OLD | NEW |