OLD | NEW |
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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * Creates a PageSettings object. This object encapsulates all settings and | 9 * Creates a PageSettings object. This object encapsulates all settings and |
10 * logic related to page selection. | 10 * logic related to page selection. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 * @private | 50 * @private |
51 */ | 51 */ |
52 this.allRadio_ = null; | 52 this.allRadio_ = null; |
53 | 53 |
54 /** | 54 /** |
55 * Container of a hint to show when the custom page range is invalid. | 55 * Container of a hint to show when the custom page range is invalid. |
56 * @type {HTMLElement} | 56 * @type {HTMLElement} |
57 * @private | 57 * @private |
58 */ | 58 */ |
59 this.customHintEl_ = null; | 59 this.customHintEl_ = null; |
60 }; | 60 } |
61 | 61 |
62 /** | 62 /** |
63 * CSS classes used by the page settings. | 63 * CSS classes used by the page settings. |
64 * @enum {string} | 64 * @enum {string} |
65 * @private | 65 * @private |
66 */ | 66 */ |
67 PageSettings.Classes_ = { | 67 PageSettings.Classes_ = { |
68 ALL_RADIO: 'page-settings-all-radio', | 68 ALL_RADIO: 'page-settings-all-radio', |
69 CUSTOM_HINT: 'page-settings-custom-hint', | 69 CUSTOM_HINT: 'page-settings-custom-hint', |
70 CUSTOM_INPUT: 'page-settings-custom-input', | 70 CUSTOM_INPUT: 'page-settings-custom-input', |
(...skipping 23 matching lines...) Expand all Loading... |
94 /** @override */ | 94 /** @override */ |
95 set isEnabled(isEnabled) { | 95 set isEnabled(isEnabled) { |
96 this.customInput_.disabled = !isEnabled; | 96 this.customInput_.disabled = !isEnabled; |
97 this.allRadio_.disabled = !isEnabled; | 97 this.allRadio_.disabled = !isEnabled; |
98 this.customRadio_.disabled = !isEnabled; | 98 this.customRadio_.disabled = !isEnabled; |
99 }, | 99 }, |
100 | 100 |
101 /** @override */ | 101 /** @override */ |
102 enterDocument: function() { | 102 enterDocument: function() { |
103 print_preview.SettingsSection.prototype.enterDocument.call(this); | 103 print_preview.SettingsSection.prototype.enterDocument.call(this); |
| 104 var customInput = assert(this.customInput_); |
104 this.tracker.add( | 105 this.tracker.add( |
105 this.allRadio_, 'click', this.onAllRadioClick_.bind(this)); | 106 assert(this.allRadio_), 'click', this.onAllRadioClick_.bind(this)); |
106 this.tracker.add( | 107 this.tracker.add( |
107 this.customRadio_, 'click', this.onCustomRadioClick_.bind(this)); | 108 assert(this.customRadio_), |
| 109 'click', |
| 110 this.onCustomRadioClick_.bind(this)); |
108 this.tracker.add( | 111 this.tracker.add( |
109 this.customInput_, 'blur', this.onCustomInputBlur_.bind(this)); | 112 customInput, |
| 113 'blur', |
| 114 this.onCustomInputBlur_.bind(this)); |
110 this.tracker.add( | 115 this.tracker.add( |
111 this.customInput_, 'focus', this.onCustomInputFocus_.bind(this)); | 116 customInput, |
| 117 'focus', |
| 118 this.onCustomInputFocus_.bind(this)); |
112 this.tracker.add( | 119 this.tracker.add( |
113 this.customInput_, 'keydown', this.onCustomInputKeyDown_.bind(this)); | 120 customInput, |
| 121 'keydown', |
| 122 this.onCustomInputKeyDown_.bind(this)); |
114 this.tracker.add( | 123 this.tracker.add( |
115 this.customInput_, 'input', this.onCustomInputChange_.bind(this)); | 124 customInput, |
| 125 'input', |
| 126 this.onCustomInputChange_.bind(this)); |
116 this.tracker.add( | 127 this.tracker.add( |
117 this.pageRangeTicketItem_, | 128 this.pageRangeTicketItem_, |
118 print_preview.ticket_items.TicketItem.EventType.CHANGE, | 129 print_preview.ticket_items.TicketItem.EventType.CHANGE, |
119 this.onPageRangeTicketItemChange_.bind(this)); | 130 this.onPageRangeTicketItemChange_.bind(this)); |
120 }, | 131 }, |
121 | 132 |
122 /** @override */ | 133 /** @override */ |
123 exitDocument: function() { | 134 exitDocument: function() { |
124 print_preview.SettingsSection.prototype.exitDocument.call(this); | 135 print_preview.SettingsSection.prototype.exitDocument.call(this); |
125 this.customInput_ = null; | 136 this.customInput_ = null; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 280 } |
270 this.updateUiStateInternal(); | 281 this.updateUiStateInternal(); |
271 } | 282 } |
272 }; | 283 }; |
273 | 284 |
274 // Export | 285 // Export |
275 return { | 286 return { |
276 PageSettings: PageSettings | 287 PageSettings: PageSettings |
277 }; | 288 }; |
278 }); | 289 }); |
OLD | NEW |