OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 * Creates a CopiesSettings object. | 9 * Creates a CopiesSettings object. |
10 * @constructor | 10 * @constructor |
11 */ | 11 */ |
12 function CopiesSettings() { | 12 function CopiesSettings() { |
13 this.copiesOption_ = $('copies-option'); | 13 this.copiesOption_ = $('copies-option'); |
14 this.textfield_ = $('copies'); | 14 this.textfield_ = $('copies'); |
15 this.incrementButton_ = $('increment'); | 15 this.incrementButton_ = $('increment'); |
16 this.decrementButton_ = $('decrement'); | 16 this.decrementButton_ = $('decrement'); |
17 // Minimum allowed value for number of copies. | 17 // Minimum allowed value for number of copies. |
18 this.minValue_ = 1; | 18 this.minValue_ = 1; |
19 // Maximum allowed value for number of copies. | 19 // Maximum allowed value for number of copies. |
20 this.maxValue_ = 999; | 20 this.maxValue_ = 999; |
21 this.collateOption_ = $('collate-option'); | 21 this.collateOption_ = $('collate-option'); |
22 this.collateCheckbox_ = $('collate'); | 22 this.collateCheckbox_ = $('collate'); |
23 this.hint_ = $('copies-hint'); | 23 this.hint_ = $('copies-hint'); |
24 this.twoSidedCheckbox_ = $('two-sided'); | 24 this.twoSidedCheckbox_ = $('two-sided'); |
25 // Store the default duplex setting value which we got from the printer. | |
26 this.printerDefaultDuplexValue = -1; | |
dpapad
2011/09/02 03:01:07
Rename member var to printerDefaultDuplexValue_.
kmadhusu
2011/09/03 00:34:00
Done.
| |
25 } | 27 } |
26 | 28 |
27 cr.addSingletonGetter(CopiesSettings); | 29 cr.addSingletonGetter(CopiesSettings); |
28 | 30 |
29 CopiesSettings.prototype = { | 31 CopiesSettings.prototype = { |
30 /** | 32 /** |
31 * The number of copies represented by the contents of |this.textfield_|. | 33 * The number of copies represented by the contents of |this.textfield_|. |
32 * If the text is not valid returns |this.minValue_|. | 34 * If the text is not valid returns |this.minValue_|. |
33 * @type {number} | 35 * @type {number} |
34 */ | 36 */ |
(...skipping 14 matching lines...) Expand all Loading... | |
49 | 51 |
50 /** | 52 /** |
51 * Getter method for |twoSidedCheckbox_|. | 53 * Getter method for |twoSidedCheckbox_|. |
52 * @type {HTMLInputElement} | 54 * @type {HTMLInputElement} |
53 */ | 55 */ |
54 get twoSidedCheckbox() { | 56 get twoSidedCheckbox() { |
55 return this.twoSidedCheckbox_; | 57 return this.twoSidedCheckbox_; |
56 }, | 58 }, |
57 | 59 |
58 /** | 60 /** |
59 * Gets the duplex mode for printing. | 61 * Gets the duplex mode information for printing. |
60 * @return {number} duplex mode. | 62 * @return {object} duplex mode object specifies the printer specified |
dpapad
2011/09/02 03:01:07
Nit: s/{object}/{Object}
Nit (optional): Change @r
kmadhusu
2011/09/03 00:34:00
Reverted the code to return a number.
| |
63 * default value and user selected duplex mode value. | |
61 */ | 64 */ |
62 get duplexMode() { | 65 get duplexModeInfo() { |
63 // Constant values matches printing::DuplexMode enum. Not using const | 66 // Constant values matches printing::DuplexMode enum. Not using const |
64 // keyword because it is not allowed by JS strict mode. | 67 // keyword because it is not allowed by JS strict mode. |
65 var SIMPLEX = 0; | 68 var SIMPLEX = 0; |
dpapad
2011/09/02 03:01:07
You can define these constants as regular member v
kmadhusu
2011/09/03 00:34:00
Done.
| |
66 var LONG_EDGE = 1; | 69 var LONG_EDGE = 1; |
67 return !this.twoSidedCheckbox_.checked ? SIMPLEX : LONG_EDGE; | 70 return {'printerDefaultDuplexValue': this.printerDefaultDuplexValue, |
71 'userSelectedDuplexValue': !this.twoSidedCheckbox_.checked ? | |
72 SIMPLEX : LONG_EDGE}; | |
68 }, | 73 }, |
69 | 74 |
70 /** | 75 /** |
71 * @return {boolean} true if |this.textfield_| is empty, or represents a | 76 * @return {boolean} true if |this.textfield_| is empty, or represents a |
72 * positive integer value. | 77 * positive integer value. |
73 */ | 78 */ |
74 isValid: function() { | 79 isValid: function() { |
75 return !this.textfield_.value || isPositiveInteger(this.textfield_.value); | 80 return !this.textfield_.value || isPositiveInteger(this.textfield_.value); |
76 }, | 81 }, |
77 | 82 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 * @private | 156 * @private |
152 */ | 157 */ |
153 onPrinterCapabilitiesUpdated_: function(e) { | 158 onPrinterCapabilitiesUpdated_: function(e) { |
154 if (e.printerCapabilities.disableCopiesOption) { | 159 if (e.printerCapabilities.disableCopiesOption) { |
155 fadeOutElement(this.copiesOption_); | 160 fadeOutElement(this.copiesOption_); |
156 $('hr-before-copies').classList.remove('invisible'); | 161 $('hr-before-copies').classList.remove('invisible'); |
157 } else { | 162 } else { |
158 fadeInElement(this.copiesOption_); | 163 fadeInElement(this.copiesOption_); |
159 $('hr-before-copies').classList.add('invisible'); | 164 $('hr-before-copies').classList.add('invisible'); |
160 } | 165 } |
161 this.twoSidedCheckbox_.checked = e.printerCapabilities.setDuplexAsDefault; | 166 this.printerDefaultDuplexValue = |
167 e.printerCapabilities.printerDefaultDuplexValue; | |
168 if (this.printerDefaultDuplexValue >= 0) | |
dpapad
2011/09/02 03:01:07
I think this if statement is equivalent to
this.tw
kmadhusu
2011/09/03 00:34:00
No. this.printerDefaultDuplexValue is not a boolea
| |
169 this.twoSidedCheckbox_.checked = this.printerDefaultDuplexValue; | |
162 }, | 170 }, |
163 | 171 |
164 /** | 172 /** |
165 * Listener triggered when |incrementButton_| is clicked. | 173 * Listener triggered when |incrementButton_| is clicked. |
166 * @private | 174 * @private |
167 */ | 175 */ |
168 onIncrementButtonClicked_: function() { | 176 onIncrementButtonClicked_: function() { |
169 this.onButtonClicked_(1); | 177 this.onButtonClicked_(1); |
170 }, | 178 }, |
171 | 179 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 fadeOutElement(this.hint_); | 216 fadeOutElement(this.hint_); |
209 } | 217 } |
210 this.hint_.setAttribute('aria-hidden', this.isValid()); | 218 this.hint_.setAttribute('aria-hidden', this.isValid()); |
211 } | 219 } |
212 }; | 220 }; |
213 | 221 |
214 return { | 222 return { |
215 CopiesSettings: CopiesSettings, | 223 CopiesSettings: CopiesSettings, |
216 }; | 224 }; |
217 }); | 225 }); |
OLD | NEW |