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 * Modal dialog for print destination's advanced settings. | 9 * Modal dialog for print destination's advanced settings. |
10 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the | 10 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 this.searchBox_.render(this.getChildElement('.search-box-area')); | 81 this.searchBox_.render(this.getChildElement('.search-box-area')); |
82 }, | 82 }, |
83 | 83 |
84 /** @override */ | 84 /** @override */ |
85 onSetVisibleInternal: function(isVisible) { | 85 onSetVisibleInternal: function(isVisible) { |
86 if (isVisible) { | 86 if (isVisible) { |
87 this.searchBox_.focus(); | 87 this.searchBox_.focus(); |
88 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket. | 88 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket. |
89 ADVANCED_SETTINGS_DIALOG_SHOWN); | 89 ADVANCED_SETTINGS_DIALOG_SHOWN); |
90 } else { | 90 } else { |
91 this.searchBox_.setQuery(null); | 91 this.resetSearch_(); |
92 this.filterLists_(null); | |
93 this.destination_ = null; | 92 this.destination_ = null; |
94 } | 93 } |
95 }, | 94 }, |
96 | 95 |
97 /** @override */ | 96 /** @override */ |
98 onCancelInternal: function() { | 97 onCancelInternal: function() { |
99 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket. | 98 this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket. |
100 ADVANCED_SETTINGS_DIALOG_CANCELED); | 99 ADVANCED_SETTINGS_DIALOG_CANCELED); |
101 }, | 100 }, |
102 | 101 |
(...skipping 17 matching lines...) Expand all Loading... |
120 this.getChildElement('.settings-area').offsetTop - | 119 this.getChildElement('.settings-area').offsetTop - |
121 this.getChildElement('.action-area').offsetHeight; | 120 this.getChildElement('.action-area').offsetHeight; |
122 }, | 121 }, |
123 | 122 |
124 /** | 123 /** |
125 * Filters displayed settings with the given query. | 124 * Filters displayed settings with the given query. |
126 * @param {?string} query Query to filter settings by. | 125 * @param {?string} query Query to filter settings by. |
127 * @private | 126 * @private |
128 */ | 127 */ |
129 filterLists_: function(query) { | 128 filterLists_: function(query) { |
| 129 this.items_.forEach(function(item) { |
| 130 item.updateSearchQuery(query); |
| 131 }); |
130 }, | 132 }, |
131 | 133 |
132 /** | 134 /** |
133 * Resets the filter query. | 135 * Resets the filter query. |
134 * @private | 136 * @private |
135 */ | 137 */ |
136 resetSearch_: function() { | 138 resetSearch_: function() { |
137 this.searchBox_.setQuery(null); | 139 this.searchBox_.setQuery(null); |
138 this.filterLists_(null); | 140 this.filterLists_(null); |
139 }, | 141 }, |
(...skipping 26 matching lines...) Expand all Loading... |
166 }.bind(this)); | 168 }.bind(this)); |
167 }, | 169 }, |
168 | 170 |
169 /** | 171 /** |
170 * Called when settings search query changes. Filters displayed settings | 172 * Called when settings search query changes. Filters displayed settings |
171 * with the given query. | 173 * with the given query. |
172 * @param {Event} evt Contains search query. | 174 * @param {Event} evt Contains search query. |
173 * @private | 175 * @private |
174 */ | 176 */ |
175 onSearch_: function(evt) { | 177 onSearch_: function(evt) { |
176 this.filterLists_(evt.query); | 178 this.filterLists_(evt.queryRegExp); |
177 }, | 179 }, |
178 | 180 |
179 /** | 181 /** |
180 * Called when current settings selection need to be stored in the ticket. | 182 * Called when current settings selection need to be stored in the ticket. |
181 * @private | 183 * @private |
182 */ | 184 */ |
183 onApplySettings_: function(evt) { | 185 onApplySettings_: function(evt) { |
184 this.setIsVisible(false); | 186 this.setIsVisible(false); |
185 | 187 |
186 var values = {}; | 188 var values = {}; |
187 this.items_.forEach(function(item) { | 189 this.items_.forEach(function(item) { |
188 if (item.isModified()) | 190 if (item.isModified()) |
189 values[item.id] = item.selectedValue; | 191 values[item.id] = item.selectedValue; |
190 }.bind(this)); | 192 }.bind(this)); |
191 | 193 |
192 this.printTicketStore_.vendorItems.updateValue(values); | 194 this.printTicketStore_.vendorItems.updateValue(values); |
193 } | 195 } |
194 }; | 196 }; |
195 | 197 |
196 // Export | 198 // Export |
197 return { | 199 return { |
198 AdvancedSettings: AdvancedSettings | 200 AdvancedSettings: AdvancedSettings |
199 }; | 201 }; |
200 }); | 202 }); |
OLD | NEW |