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('print_preview', function() { | 5 cr.define('print_preview', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Component that displays a list of destinations with a heading, action link, | 9 * Component that displays a list of destinations with a heading, action link, |
10 * and "Show All..." button. An event is dispatched when the action link is | 10 * and "Show All..." button. An event is dispatched when the action link is |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 /** | 182 /** |
183 * Updates the destinations to render in the destination list. | 183 * Updates the destinations to render in the destination list. |
184 * @param {!Array.<print_preview.Destination>} destinations Destinations to | 184 * @param {!Array.<print_preview.Destination>} destinations Destinations to |
185 * render. | 185 * render. |
186 */ | 186 */ |
187 updateDestinations: function(destinations) { | 187 updateDestinations: function(destinations) { |
188 this.destinations_ = destinations; | 188 this.destinations_ = destinations; |
189 this.renderDestinations_(); | 189 this.renderDestinations_(); |
190 }, | 190 }, |
191 | 191 |
192 /** @param {?string} query Query to update the filter with. */ | 192 /** @param {RegExp} query Query to update the filter with. */ |
193 updateSearchQuery: function(query) { | 193 updateSearchQuery: function(query) { |
194 if (!query) { | 194 this.query_ = query; |
195 this.query_ = null; | |
196 } else { | |
197 // Generate regexp-safe query by escaping metacharacters. | |
198 var safeQuery = query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); | |
199 this.query_ = new RegExp('(' + safeQuery + ')', 'ig'); | |
200 } | |
201 this.renderDestinations_(); | 195 this.renderDestinations_(); |
202 }, | 196 }, |
203 | 197 |
204 /** | 198 /** |
205 * @param {string} text Text to set the action link to. | 199 * @param {string} text Text to set the action link to. |
206 * @protected | 200 * @protected |
207 */ | 201 */ |
208 setActionLinkTextInternal: function(text) { | 202 setActionLinkTextInternal: function(text) { |
209 this.actionLinkLabel_ = text; | 203 this.actionLinkLabel_ = text; |
210 this.getChildElement('.action-link').textContent = text; | 204 this.getChildElement('.action-link').textContent = text; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 cr.dispatchSimpleEvent(this, | 265 cr.dispatchSimpleEvent(this, |
272 DestinationList.EventType.ACTION_LINK_ACTIVATED); | 266 DestinationList.EventType.ACTION_LINK_ACTIVATED); |
273 } | 267 } |
274 }; | 268 }; |
275 | 269 |
276 // Export | 270 // Export |
277 return { | 271 return { |
278 DestinationList: DestinationList | 272 DestinationList: DestinationList |
279 }; | 273 }; |
280 }); | 274 }); |
OLD | NEW |