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

Side by Side Diff: chrome/browser/resources/print_preview/common/search_box.js

Issue 540183002: Add search to Print Preview advanced options and enable them in the UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/common/search_bubble.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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('print_preview', function() { 5 cr.define('print_preview', function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Component that renders a search box for searching through destinations. 9 * Component that renders a search box for searching through destinations.
10 * @param {string} searchBoxPlaceholderText Search box placeholder text. 10 * @param {string} searchBoxPlaceholderText Search box placeholder text.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 return this.input_.value.trim(); 90 return this.input_.value.trim();
91 }, 91 },
92 92
93 /** 93 /**
94 * Dispatches a SEARCH event. 94 * Dispatches a SEARCH event.
95 * @private 95 * @private
96 */ 96 */
97 dispatchSearchEvent_: function() { 97 dispatchSearchEvent_: function() {
98 this.timeout_ = null; 98 this.timeout_ = null;
99 var searchEvent = new Event(SearchBox.EventType.SEARCH); 99 var searchEvent = new Event(SearchBox.EventType.SEARCH);
100 searchEvent.query = this.getQuery_(); 100 var query = this.getQuery_();
101 searchEvent.query = query;
102 // Generate regexp-safe query by escaping metacharacters.
103 var safeQuery = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
104 searchEvent.queryRegExp = new RegExp('(' + safeQuery + ')', 'ig');
101 this.dispatchEvent(searchEvent); 105 this.dispatchEvent(searchEvent);
102 }, 106 },
103 107
104 /** 108 /**
105 * Called when the input element's value changes. Dispatches a search event. 109 * Called when the input element's value changes. Dispatches a search event.
106 * @private 110 * @private
107 */ 111 */
108 onInputInput_: function() { 112 onInputInput_: function() {
109 if (this.timeout_) 113 if (this.timeout_)
110 clearTimeout(this.timeout_); 114 clearTimeout(this.timeout_);
111 this.timeout_ = setTimeout( 115 this.timeout_ = setTimeout(
112 this.dispatchSearchEvent_.bind(this), SearchBox.SEARCH_DELAY_); 116 this.dispatchSearchEvent_.bind(this), SearchBox.SEARCH_DELAY_);
113 } 117 }
114 }; 118 };
115 119
116 // Export 120 // Export
117 return { 121 return {
118 SearchBox: SearchBox 122 SearchBox: SearchBox
119 }; 123 };
120 }); 124 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/common/search_bubble.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698