| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 fadeOutOption(this.getElement(), true); | 93 fadeOutOption(this.getElement(), true); |
| 94 this.tracker.add( | 94 this.tracker.add( |
| 95 this.allRadio_, 'click', this.onAllRadioClick_.bind(this)); | 95 this.allRadio_, 'click', this.onAllRadioClick_.bind(this)); |
| 96 this.tracker.add( | 96 this.tracker.add( |
| 97 this.customRadio_, 'click', this.onCustomRadioClick_.bind(this)); | 97 this.customRadio_, 'click', this.onCustomRadioClick_.bind(this)); |
| 98 this.tracker.add( | 98 this.tracker.add( |
| 99 this.customInput_, 'blur', this.onCustomInputBlur_.bind(this)); | 99 this.customInput_, 'blur', this.onCustomInputBlur_.bind(this)); |
| 100 this.tracker.add( | 100 this.tracker.add( |
| 101 this.customInput_, 'focus', this.onCustomInputFocus_.bind(this)); | 101 this.customInput_, 'focus', this.onCustomInputFocus_.bind(this)); |
| 102 this.tracker.add( | 102 this.tracker.add( |
| 103 this.customInput_, 'keydown', this.onCustomInputKeyDown_.bind(this)); |
| 104 this.tracker.add( |
| 103 this.customInput_, 'keyup', this.onCustomInputKeyUp_.bind(this)); | 105 this.customInput_, 'keyup', this.onCustomInputKeyUp_.bind(this)); |
| 104 this.tracker.add( | 106 this.tracker.add( |
| 105 this.pageRangeTicketItem_, | 107 this.pageRangeTicketItem_, |
| 106 print_preview.ticket_items.TicketItem.EventType.CHANGE, | 108 print_preview.ticket_items.TicketItem.EventType.CHANGE, |
| 107 this.onPageRangeTicketItemChange_.bind(this)); | 109 this.onPageRangeTicketItemChange_.bind(this)); |
| 108 }, | 110 }, |
| 109 | 111 |
| 110 /** @override */ | 112 /** @override */ |
| 111 exitDocument: function() { | 113 exitDocument: function() { |
| 112 print_preview.Component.prototype.exitDocument.call(this); | 114 print_preview.Component.prototype.exitDocument.call(this); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 onCustomInputFocus_: function() { | 183 onCustomInputFocus_: function() { |
| 182 this.customRadio_.checked = true; | 184 this.customRadio_.checked = true; |
| 183 this.pageRangeTicketItem_.updateValue(this.customInput_.value); | 185 this.pageRangeTicketItem_.updateValue(this.customInput_.value); |
| 184 }, | 186 }, |
| 185 | 187 |
| 186 /** | 188 /** |
| 187 * Called when a key is pressed on the custom input. | 189 * Called when a key is pressed on the custom input. |
| 188 * @param {Event} event Contains the key that was pressed. | 190 * @param {Event} event Contains the key that was pressed. |
| 189 * @private | 191 * @private |
| 190 */ | 192 */ |
| 193 onCustomInputKeyDown_: function(event) { |
| 194 if (event.keyCode == 13 /*enter*/) { |
| 195 if (this.customInputTimeout_) { |
| 196 clearTimeout(this.customInputTimeout_); |
| 197 this.customInputTimeout_ = null; |
| 198 } |
| 199 this.pageRangeTicketItem_.updateValue(this.customInput_.value); |
| 200 } |
| 201 }, |
| 202 |
| 203 /** |
| 204 * Called when a key is pressed on the custom input. |
| 205 * @param {Event} event Contains the key that was pressed. |
| 206 * @private |
| 207 */ |
| 191 onCustomInputKeyUp_: function(event) { | 208 onCustomInputKeyUp_: function(event) { |
| 192 if (this.customInputTimeout_) { | 209 if (this.customInputTimeout_) { |
| 193 clearTimeout(this.customInputTimeout_); | 210 clearTimeout(this.customInputTimeout_); |
| 211 this.customInputTimeout_ = null; |
| 194 } | 212 } |
| 195 if (event.keyIdentifier == 'Enter') { | 213 if (event.keyCode != 13 /*enter*/) { |
| 196 this.pageRangeTicketItem_.updateValue(this.customInput_.value); | |
| 197 } else { | |
| 198 this.customRadio_.checked = true; | 214 this.customRadio_.checked = true; |
| 199 this.customInputTimeout_ = setTimeout( | 215 this.customInputTimeout_ = setTimeout( |
| 200 this.onCustomInputTimeout_.bind(this), | 216 this.onCustomInputTimeout_.bind(this), |
| 201 PageSettings.CUSTOM_INPUT_DELAY_); | 217 PageSettings.CUSTOM_INPUT_DELAY_); |
| 202 } | 218 } |
| 203 }, | 219 }, |
| 204 | 220 |
| 205 /** | 221 /** |
| 206 * Called after a delay following a key press in the custom input. | 222 * Called after a delay following a key press in the custom input. |
| 207 * @private | 223 * @private |
| (...skipping 28 matching lines...) Expand all Loading... |
| 236 fadeOutOption(this.getElement()); | 252 fadeOutOption(this.getElement()); |
| 237 } | 253 } |
| 238 } | 254 } |
| 239 }; | 255 }; |
| 240 | 256 |
| 241 // Export | 257 // Export |
| 242 return { | 258 return { |
| 243 PageSettings: PageSettings | 259 PageSettings: PageSettings |
| 244 }; | 260 }; |
| 245 }); | 261 }); |
| OLD | NEW |