Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: chrome/browser/resources/options/search_page.js

Issue 6361011: dom-ui settings: Change search regex to not search for word-boundaries to imp... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: bump copyright date Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698