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

Side by Side Diff: chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings_item.js

Issue 2861713004: Print Preview: Fix compile errors in settings/ directory (Closed)
Patch Set: Address comments and fix remaining lint errors Created 3 years, 7 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
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 /**
5 * Specifies a custom vendor capability.
6 * @typedef {{
7 * id: (string),
8 * display_name: (string),
9 * localized_display_name: (string | undefined),
10 * type: (string),
11 * select_cap: ({
12 * option: (Array<{
13 * display_name: (string),
14 * type: (string | undefined),
15 * value: (number | string | boolean),
16 * is_default: (boolean | undefined)
17 * }>|undefined)
18 * }|undefined)
19 * }}
20 */
21 print_preview.VendorCapability;
4 22
5 cr.define('print_preview', function() { 23 cr.define('print_preview', function() {
6 'use strict'; 24 'use strict';
7 25
8 /** 26 /**
9 * Component that renders a destination item in a destination list. 27 * Component that renders a destination item in a destination list.
10 * @param {!cr.EventTarget} eventTarget Event target to dispatch selection
11 * events to.
12 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the 28 * @param {!print_preview.PrintTicketStore} printTicketStore Contains the
13 * print ticket to print. 29 * print ticket to print.
14 * @param {!Object} capability Capability to render. 30 * @param {!print_preview.VendorCapability} capability Capability to render.
15 * @constructor 31 * @constructor
16 * @extends {print_preview.Component} 32 * @extends {print_preview.Component}
17 */ 33 */
18 function AdvancedSettingsItem(eventTarget, printTicketStore, capability) { 34 function AdvancedSettingsItem(printTicketStore, capability) {
19 print_preview.Component.call(this); 35 print_preview.Component.call(this);
20 36
21 /** 37 /**
22 * Event target to dispatch selection events to.
23 * @private {!cr.EventTarget}
24 */
25 this.eventTarget_ = eventTarget;
26
27 /**
28 * Contains the print ticket to print. 38 * Contains the print ticket to print.
29 * @private {!print_preview.PrintTicketStore} 39 * @private {!print_preview.PrintTicketStore}
30 */ 40 */
31 this.printTicketStore_ = printTicketStore; 41 this.printTicketStore_ = printTicketStore;
32 42
33 /** 43 /**
34 * Capability this component renders. 44 * Capability this component renders.
35 * @private {!Object} 45 * @private {!print_preview.VendorCapability}
36 */ 46 */
37 this.capability_ = capability; 47 this.capability_ = capability;
38 48
39 /** 49 /**
40 * Value selected by user. {@code null}, if user has not changed the default 50 * Value selected by user. {@code null}, if user has not changed the default
41 * value yet (still, the value can be the default one, if it is what user 51 * value yet (still, the value can be the default one, if it is what user
42 * selected). 52 * selected).
43 * @private {?string} 53 * @private {?string}
44 */ 54 */
45 this.selectedValue_ = null; 55 this.selectedValue_ = null;
46 56
47 /** 57 /**
48 * Active filter query. 58 * Active filter query.
49 * @private {RegExp} 59 * @private {RegExp}
50 */ 60 */
51 this.query_ = null; 61 this.query_ = null;
52 62
53 /** 63 /**
54 * Search hint for the control. 64 * Search hint for the control.
55 * @private {print_preview.SearchBubble} 65 * @private {print_preview.SearchBubble}
56 */ 66 */
57 this.searchBubble_ = null; 67 this.searchBubble_ = null;
58 68
59 /** @private {!EventTracker} */ 69 /** @private {!EventTracker} */
60 this.tracker_ = new EventTracker(); 70 this.tracker_ = new EventTracker();
61 }; 71 }
62 72
63 AdvancedSettingsItem.prototype = { 73 AdvancedSettingsItem.prototype = {
64 __proto__: print_preview.Component.prototype, 74 __proto__: print_preview.Component.prototype,
65 75
66 /** @override */ 76 /** @override */
67 createDom: function() { 77 createDom: function() {
68 this.setElementInternal(this.cloneTemplateInternal( 78 this.setElementInternal(this.cloneTemplateInternal(
69 'advanced-settings-item-template')); 79 'advanced-settings-item-template'));
70 80
71 this.tracker_.add( 81 this.tracker_.add(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 updateSearchQuery: function(query) { 115 updateSearchQuery: function(query) {
106 this.query_ = query; 116 this.query_ = query;
107 this.renderCapability_(); 117 this.renderCapability_();
108 }, 118 },
109 119
110 get searchBubbleShown() { 120 get searchBubbleShown() {
111 return getIsVisible(this.getElement()) && !!this.searchBubble_; 121 return getIsVisible(this.getElement()) && !!this.searchBubble_;
112 }, 122 },
113 123
114 /** 124 /**
115 * @return {HTMLSelectElement} Select element. 125 * @return {!HTMLSelectElement} Select element.
116 * @private 126 * @private
117 */ 127 */
118 get select_() { 128 get select_() {
119 return this.getChildElement( 129 return /** @type {!HTMLSelectElement} */ (
120 '.advanced-settings-item-value-select-control'); 130 this.getChildElement('.advanced-settings-item-value-select-control'));
121 }, 131 },
122 132
123 /** 133 /**
124 * @return {HTMLSelectElement} Text element. 134 * @return {!HTMLSelectElement} Text element.
125 * @private 135 * @private
126 */ 136 */
127 get text_() { 137 get text_() {
128 return this.getChildElement('.advanced-settings-item-value-text-control'); 138 return /** @type {!HTMLSelectElement} */(
139 this.getChildElement('.advanced-settings-item-value-text-control'));
129 }, 140 },
130 141
131 /** 142 /**
132 * Called when the select element value is changed. 143 * Called when the select element value is changed.
133 * @private 144 * @private
134 */ 145 */
135 onSelectChange_: function() { 146 onSelectChange_: function() {
136 this.selectedValue_ = this.select_.value; 147 this.selectedValue_ = this.select_.value;
137 }, 148 },
138 149
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 this.initializeSelectValue_(); 260 this.initializeSelectValue_();
250 else 261 else
251 this.initializeTextValue_(); 262 this.initializeTextValue_();
252 }, 263 },
253 264
254 /** 265 /**
255 * Initializes the select element. 266 * Initializes the select element.
256 * @private 267 * @private
257 */ 268 */
258 initializeSelectValue_: function() { 269 initializeSelectValue_: function() {
259 setIsVisible( 270 setIsVisible(assert(this.getChildElement(
260 this.getChildElement('.advanced-settings-item-value-select'), true); 271 '.advanced-settings-item-value-select')), true);
261 var selectEl = this.select_; 272 var selectEl = this.select_;
262 var indexToSelect = 0; 273 var indexToSelect = 0;
263 this.capability_.select_cap.option.forEach(function(option, index) { 274 this.capability_.select_cap.option.forEach(function(option, index) {
264 var item = document.createElement('option'); 275 var item = document.createElement('option');
265 item.text = this.getEntityDisplayName_(option); 276 item.text = this.getEntityDisplayName_(option);
266 item.value = option.value; 277 item.value = option.value;
267 if (option.is_default) 278 if (option.is_default)
268 indexToSelect = index; 279 indexToSelect = index;
269 selectEl.appendChild(item); 280 selectEl.appendChild(item);
270 }, this); 281 }, this);
271 for (var i = 0, option; option = selectEl.options[i]; i++) { 282 for (var i = 0, option; (option = selectEl.options[i]); i++) {
272 if (option.value == this.selectedValue_) { 283 if (option.value == this.selectedValue_) {
273 indexToSelect = i; 284 indexToSelect = i;
274 break; 285 break;
275 } 286 }
276 } 287 }
277 selectEl.selectedIndex = indexToSelect; 288 selectEl.selectedIndex = indexToSelect;
278 }, 289 },
279 290
280 /** 291 /**
281 * Initializes the text element. 292 * Initializes the text element.
282 * @private 293 * @private
283 */ 294 */
284 initializeTextValue_: function() { 295 initializeTextValue_: function() {
285 setIsVisible( 296 setIsVisible(assert(this.getChildElement(
286 this.getChildElement('.advanced-settings-item-value-text'), true); 297 '.advanced-settings-item-value-text')), true);
287 298
288 var defaultValue = null; 299 var defaultValue = null;
289 if (this.capability_.type == 'TYPED_VALUE' && 300 if (this.capability_.type == 'TYPED_VALUE' &&
290 this.capability_.typed_value_cap) { 301 this.capability_.typed_value_cap) {
291 defaultValue = this.capability_.typed_value_cap.default || null; 302 defaultValue = this.capability_.typed_value_cap.default || null;
292 } else if (this.capability_.type == 'RANGE' && 303 } else if (this.capability_.type == 'RANGE' &&
293 this.capability_.range_cap) { 304 this.capability_.range_cap) {
294 defaultValue = this.capability_.range_cap.default || null; 305 defaultValue = this.capability_.range_cap.default || null;
295 } 306 }
296 307
(...skipping 21 matching lines...) Expand all
318 } 329 }
319 }); 330 });
320 } 331 }
321 }; 332 };
322 333
323 // Export 334 // Export
324 return { 335 return {
325 AdvancedSettingsItem: AdvancedSettingsItem 336 AdvancedSettingsItem: AdvancedSettingsItem
326 }; 337 };
327 }); 338 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698