OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 /** | 44 /** |
45 * Delay in milliseconds before dispatching a SEARCH event. | 45 * Delay in milliseconds before dispatching a SEARCH event. |
46 * @private {number} | 46 * @private {number} |
47 * @const | 47 * @const |
48 */ | 48 */ |
49 SearchBox.SEARCH_DELAY_ = 150; | 49 SearchBox.SEARCH_DELAY_ = 150; |
50 | 50 |
51 SearchBox.prototype = { | 51 SearchBox.prototype = { |
52 __proto__: print_preview.Component.prototype, | 52 __proto__: print_preview.Component.prototype, |
53 | 53 |
54 /** @param {string} query New query to set the search box's query to. */ | 54 /** @param {?string} query New query to set the search box's query to. */ |
55 setQuery: function(query) { | 55 setQuery: function(query) { |
56 query = query || ''; | 56 query = query || ''; |
57 this.input_.value = query.trim(); | 57 this.input_.value = query.trim(); |
58 }, | 58 }, |
59 | 59 |
60 /** Sets the input element of the search box in focus. */ | 60 /** Sets the input element of the search box in focus. */ |
61 focus: function() { | 61 focus: function() { |
62 this.input_.focus(); | 62 this.input_.focus(); |
63 }, | 63 }, |
64 | 64 |
65 /** @override */ | 65 /** @override */ |
66 createDom: function() { | 66 createDom: function() { |
67 this.setElementInternal(this.cloneTemplateInternal( | 67 this.setElementInternal(this.cloneTemplateInternal( |
68 'search-box-template')); | 68 'search-box-template')); |
69 this.input_ = this.getChildElement('.search-box-input'); | 69 this.input_ = this.getChildElement('.search-box-input'); |
70 this.input_.setAttribute('placeholder', this.searchBoxPlaceholderText_); | 70 this.input_.setAttribute('placeholder', this.searchBoxPlaceholderText_); |
71 }, | 71 }, |
72 | 72 |
73 /** @override */ | 73 /** @override */ |
74 enterDocument: function() { | 74 enterDocument: function() { |
75 print_preview.Component.prototype.enterDocument.call(this); | 75 print_preview.Component.prototype.enterDocument.call(this); |
76 this.tracker.add(this.input_, 'input', this.onInputInput_.bind(this)); | 76 this.tracker.add(assert(this.input_), 'input', |
| 77 this.onInputInput_.bind(this)); |
77 }, | 78 }, |
78 | 79 |
79 /** @override */ | 80 /** @override */ |
80 exitDocument: function() { | 81 exitDocument: function() { |
81 print_preview.Component.prototype.exitDocument.call(this); | 82 print_preview.Component.prototype.exitDocument.call(this); |
82 this.input_ = null; | 83 this.input_ = null; |
83 }, | 84 }, |
84 | 85 |
85 /** | 86 /** |
86 * @return {string} The current query of the search box. | 87 * @return {string} The current query of the search box. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 this.timeout_ = setTimeout( | 120 this.timeout_ = setTimeout( |
120 this.dispatchSearchEvent_.bind(this), SearchBox.SEARCH_DELAY_); | 121 this.dispatchSearchEvent_.bind(this), SearchBox.SEARCH_DELAY_); |
121 } | 122 } |
122 }; | 123 }; |
123 | 124 |
124 // Export | 125 // Export |
125 return { | 126 return { |
126 SearchBox: SearchBox | 127 SearchBox: SearchBox |
127 }; | 128 }; |
128 }); | 129 }); |
OLD | NEW |