| 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 destination item in a destination list. | 9 * Component that renders a destination item in a destination list. |
| 10 * @param {!cr.EventTarget} eventTarget Event target to dispatch selection | 10 * @param {!cr.EventTarget} eventTarget Event target to dispatch selection |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 /** @private {!EventTracker} */ | 59 /** @private {!EventTracker} */ |
| 60 this.tracker_ = new EventTracker(); | 60 this.tracker_ = new EventTracker(); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 AdvancedSettingsItem.prototype = { | 63 AdvancedSettingsItem.prototype = { |
| 64 __proto__: print_preview.Component.prototype, | 64 __proto__: print_preview.Component.prototype, |
| 65 | 65 |
| 66 /** @override */ | 66 /** @override */ |
| 67 createDom: function() { | 67 createDom: function() { |
| 68 this.setElementInternal(this.cloneTemplateInternal( | 68 this.setElementInternal( |
| 69 'advanced-settings-item-template')); | 69 this.cloneTemplateInternal('advanced-settings-item-template')); |
| 70 | 70 |
| 71 this.tracker_.add( | 71 this.tracker_.add( |
| 72 this.select_, 'change', this.onSelectChange_.bind(this)); | 72 this.select_, 'change', this.onSelectChange_.bind(this)); |
| 73 this.tracker_.add(this.text_, 'input', this.onTextInput_.bind(this)); | 73 this.tracker_.add(this.text_, 'input', this.onTextInput_.bind(this)); |
| 74 | 74 |
| 75 this.initializeValue_(); | 75 this.initializeValue_(); |
| 76 | 76 |
| 77 this.renderCapability_(); | 77 this.renderCapability_(); |
| 78 }, | 78 }, |
| 79 | 79 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 // Whether capability name matches the query. | 177 // Whether capability name matches the query. |
| 178 var nameMatches = this.query_ ? !!textContent.match(this.query_) : true; | 178 var nameMatches = this.query_ ? !!textContent.match(this.query_) : true; |
| 179 // An array of text segments of the capability value matching the query. | 179 // An array of text segments of the capability value matching the query. |
| 180 var optionMatches = null; | 180 var optionMatches = null; |
| 181 if (this.query_) { | 181 if (this.query_) { |
| 182 if (this.capability_.type == 'SELECT') { | 182 if (this.capability_.type == 'SELECT') { |
| 183 // Look for the first option that matches the query. | 183 // Look for the first option that matches the query. |
| 184 for (var i = 0; i < this.select_.length && !optionMatches; i++) | 184 for (var i = 0; i < this.select_.length && !optionMatches; i++) |
| 185 optionMatches = this.select_.options[i].text.match(this.query_); | 185 optionMatches = this.select_.options[i].text.match(this.query_); |
| 186 } else { | 186 } else { |
| 187 optionMatches = (this.text_.value || this.text_.placeholder || '') | 187 optionMatches = (this.text_.value || this.text_.placeholder || |
| 188 .match(this.query_); | 188 '').match(this.query_); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 var matches = nameMatches || !!optionMatches; | 191 var matches = nameMatches || !!optionMatches; |
| 192 | 192 |
| 193 if (!optionMatches) | 193 if (!optionMatches) |
| 194 this.hideSearchBubble_(); | 194 this.hideSearchBubble_(); |
| 195 | 195 |
| 196 setIsVisible(this.getElement(), matches); | 196 setIsVisible(this.getElement(), matches); |
| 197 if (!matches) | 197 if (!matches) |
| 198 return; | 198 return; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 * @private | 282 * @private |
| 283 */ | 283 */ |
| 284 initializeTextValue_: function() { | 284 initializeTextValue_: function() { |
| 285 setIsVisible( | 285 setIsVisible( |
| 286 this.getChildElement('.advanced-settings-item-value-text'), true); | 286 this.getChildElement('.advanced-settings-item-value-text'), true); |
| 287 | 287 |
| 288 var defaultValue = null; | 288 var defaultValue = null; |
| 289 if (this.capability_.type == 'TYPED_VALUE' && | 289 if (this.capability_.type == 'TYPED_VALUE' && |
| 290 this.capability_.typed_value_cap) { | 290 this.capability_.typed_value_cap) { |
| 291 defaultValue = this.capability_.typed_value_cap.default || null; | 291 defaultValue = this.capability_.typed_value_cap.default || null; |
| 292 } else if (this.capability_.type == 'RANGE' && | 292 } else if ( |
| 293 this.capability_.range_cap) { | 293 this.capability_.type == 'RANGE' && this.capability_.range_cap) { |
| 294 defaultValue = this.capability_.range_cap.default || null; | 294 defaultValue = this.capability_.range_cap.default || null; |
| 295 } | 295 } |
| 296 | 296 |
| 297 this.text_.placeholder = defaultValue || ''; | 297 this.text_.placeholder = defaultValue || ''; |
| 298 | 298 |
| 299 this.text_.value = this.selectedValue; | 299 this.text_.value = this.selectedValue; |
| 300 }, | 300 }, |
| 301 | 301 |
| 302 /** | 302 /** |
| 303 * Adds text to parent element wrapping search query matches in highlighted | 303 * Adds text to parent element wrapping search query matches in highlighted |
| (...skipping 10 matching lines...) Expand all Loading... |
| 314 var span = document.createElement('span'); | 314 var span = document.createElement('span'); |
| 315 span.className = 'advanced-settings-item-query-highlight'; | 315 span.className = 'advanced-settings-item-query-highlight'; |
| 316 span.textContent = section; | 316 span.textContent = section; |
| 317 parent.appendChild(span); | 317 parent.appendChild(span); |
| 318 } | 318 } |
| 319 }); | 319 }); |
| 320 } | 320 } |
| 321 }; | 321 }; |
| 322 | 322 |
| 323 // Export | 323 // Export |
| 324 return { | 324 return {AdvancedSettingsItem: AdvancedSettingsItem}; |
| 325 AdvancedSettingsItem: AdvancedSettingsItem | |
| 326 }; | |
| 327 }); | 325 }); |
| OLD | NEW |