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

Side by Side Diff: chrome/browser/resources/print_preview/data/ticket_items/ticket_item.js

Issue 588713002: Compile print_preview, part 3: reduce down to 185 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview_2
Patch Set: Created 6 years, 3 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 (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 /**
6 * @typedef {Object|number|boolean|string}
7 */
8 print_preview.ValueType;
9
5 cr.define('print_preview.ticket_items', function() { 10 cr.define('print_preview.ticket_items', function() {
6 'use strict'; 11 'use strict';
7 12
8 /** 13 /**
9 * An object that represents a user modifiable item in a print ticket. Each 14 * An object that represents a user modifiable item in a print ticket. Each
10 * ticket item has a value which can be set by the user. Ticket items can also 15 * ticket item has a value which can be set by the user. Ticket items can also
11 * be unavailable for modifying if the print destination doesn't support it or 16 * be unavailable for modifying if the print destination doesn't support it or
12 * if other ticket item constraints are not met. 17 * if other ticket item constraints are not met.
13 * @param {print_preview.AppState=} appState Application state model to update 18 * @param {?print_preview.AppState} appState Application state model to update
14 * when ticket items update. 19 * when ticket items update.
15 * @param {print_preview.AppState.Field=} field Field of the app state to 20 * @param {?print_preview.AppState.Field} field Field of the app state to
16 * update when ticket item is updated. 21 * update when ticket item is updated.
17 * @param {print_preview.DestinationStore=} destinationStore Used listen for 22 * @param {?print_preview.DestinationStore} destinationStore Used listen for
18 * changes in the currently selected destination's capabilities. Since 23 * changes in the currently selected destination's capabilities. Since
19 * this is a common dependency of ticket items, it's handled in the base 24 * this is a common dependency of ticket items, it's handled in the base
20 * class. 25 * class.
21 * @param {print_preview.DocumentInfo=} documentInfo Used to listen for 26 * @param {?print_preview.DocumentInfo=} opt_documentInfo Used to listen for
22 * changes in the document. Since this is a common dependency of ticket 27 * changes in the document. Since this is a common dependency of ticket
23 * items, it's handled in the base class. 28 * items, it's handled in the base class.
24 * @constructor 29 * @constructor
25 * @extends {cr.EventTarget} 30 * @extends {cr.EventTarget}
26 */ 31 */
27 function TicketItem(appState, field, destinationStore, documentInfo) { 32 function TicketItem(appState, field, destinationStore, opt_documentInfo) {
28 cr.EventTarget.call(this); 33 cr.EventTarget.call(this);
29 34
30 /** 35 /**
31 * Application state model to update when ticket items update. 36 * Application state model to update when ticket items update.
32 * @type {print_preview.AppState} 37 * @type {print_preview.AppState}
33 * @private 38 * @private
34 */ 39 */
35 this.appState_ = appState || null; 40 this.appState_ = appState || null;
36 41
37 /** 42 /**
38 * Field of the app state to update when ticket item is updated. 43 * Field of the app state to update when ticket item is updated.
39 * @type {?print_preview.AppState.Field} 44 * @type {?print_preview.AppState.Field}
40 * @private 45 * @private
41 */ 46 */
42 this.field_ = field || null; 47 this.field_ = field || null;
43 48
44 /** 49 /**
45 * Used listen for changes in the currently selected destination's 50 * Used listen for changes in the currently selected destination's
46 * capabilities. 51 * capabilities.
47 * @type {print_preview.DestinationStore} 52 * @type {print_preview.DestinationStore}
48 * @private 53 * @private
49 */ 54 */
50 this.destinationStore_ = destinationStore || null; 55 this.destinationStore_ = destinationStore || null;
51 56
52 /** 57 /**
53 * Used to listen for changes in the document. 58 * Used to listen for changes in the document.
54 * @type {print_preview.DocumentInfo} 59 * @type {print_preview.DocumentInfo}
55 * @private 60 * @private
56 */ 61 */
57 this.documentInfo_ = documentInfo || null; 62 this.documentInfo_ = opt_documentInfo || null;
58 63
59 /** 64 /**
60 * Backing store of the print ticket item. 65 * Backing store of the print ticket item.
61 * @type {Object} 66 * @type {Object}
62 * @private 67 * @private
63 */ 68 */
64 this.value_ = null; 69 this.value_ = null;
65 70
66 /** 71 /**
67 * Keeps track of event listeners for the ticket item. 72 * Keeps track of event listeners for the ticket item.
(...skipping 11 matching lines...) Expand all
79 */ 84 */
80 TicketItem.EventType = { 85 TicketItem.EventType = {
81 CHANGE: 'print_preview.ticket_items.TicketItem.CHANGE' 86 CHANGE: 'print_preview.ticket_items.TicketItem.CHANGE'
82 }; 87 };
83 88
84 TicketItem.prototype = { 89 TicketItem.prototype = {
85 __proto__: cr.EventTarget.prototype, 90 __proto__: cr.EventTarget.prototype,
86 91
87 /** 92 /**
88 * Determines whether a given value is valid for the ticket item. 93 * Determines whether a given value is valid for the ticket item.
89 * @param {Object} value The value to check for validity. 94 * @param {print_preview.ValueType} value The value to check for validity.
90 * @return {boolean} Whether the given value is valid for the ticket item. 95 * @return {boolean} Whether the given value is valid for the ticket item.
91 */ 96 */
92 wouldValueBeValid: function(value) { 97 wouldValueBeValid: function(value) {
93 throw Error('Abstract method not overridden'); 98 throw Error('Abstract method not overridden');
94 }, 99 },
95 100
96 /** 101 /**
97 * @return {boolean} Whether the print destination capability is available. 102 * @return {boolean} Whether the print destination capability is available.
98 */ 103 */
99 isCapabilityAvailable: function() { 104 isCapabilityAvailable: function() {
(...skipping 20 matching lines...) Expand all
120 125
121 /** @return {boolean} Whether the ticket item's value is valid. */ 126 /** @return {boolean} Whether the ticket item's value is valid. */
122 isValid: function() { 127 isValid: function() {
123 if (!this.isUserEdited()) { 128 if (!this.isUserEdited()) {
124 return true; 129 return true;
125 } 130 }
126 return this.wouldValueBeValid(this.value_); 131 return this.wouldValueBeValid(this.value_);
127 }, 132 },
128 133
129 /** 134 /**
130 * @param {Object} value Value to compare to the value of this ticket item. 135 * @param {print_preview.ValueType} value Value to compare to the value of
136 * this ticket item.
131 * @return {boolean} Whether the given value is equal to the value of the 137 * @return {boolean} Whether the given value is equal to the value of the
132 * ticket item. 138 * ticket item.
133 */ 139 */
134 isValueEqual: function(value) { 140 isValueEqual: function(value) {
135 return this.getValue() == value; 141 return this.getValue() == value;
136 }, 142 },
137 143
138 /** @param {!Object} value Value to set as the value of the ticket item. */ 144 /**
145 * @param {print_preview.ValueType} value Value to set as the value of the
146 * ticket item.
147 */
139 updateValue: function(value) { 148 updateValue: function(value) {
140 // Use comparison with capabilities for event. 149 // Use comparison with capabilities for event.
141 var sendUpdateEvent = !this.isValueEqual(value); 150 var sendUpdateEvent = !this.isValueEqual(value);
142 // Don't lose requested value if capability is not available. 151 // Don't lose requested value if capability is not available.
143 this.updateValueInternal(value); 152 this.updateValueInternal(value);
144 if (this.appState_) { 153 if (this.appState_) {
145 this.appState_.persistField(this.field_, value); 154 this.appState_.persistField(this.field_, value);
146 } 155 }
147 if (sendUpdateEvent) 156 if (sendUpdateEvent)
148 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE); 157 cr.dispatchSimpleEvent(this, TicketItem.EventType.CHANGE);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 this.dispatchChangeEventInternal.bind(this)); 239 this.dispatchChangeEventInternal.bind(this));
231 } 240 }
232 }, 241 },
233 }; 242 };
234 243
235 // Export 244 // Export
236 return { 245 return {
237 TicketItem: TicketItem 246 TicketItem: TicketItem
238 }; 247 };
239 }); 248 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698