| 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 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!this.isValid()) { | 111 if (!this.isValid()) { |
| 112 this.reset_(); | 112 this.reset_(); |
| 113 } else { | 113 } else { |
| 114 var newValue = this.numberOfCopies + sign; | 114 var newValue = this.numberOfCopies + sign; |
| 115 this.textfield_.value = newValue; | 115 this.textfield_.value = newValue; |
| 116 } | 116 } |
| 117 this.updateButtonsState_(); | 117 this.updateButtonsState_(); |
| 118 this.showHideCollateOption_(); | 118 this.showHideCollateOption_(); |
| 119 | 119 |
| 120 if (!hasPendingPreviewRequest) { | 120 if (!hasPendingPreviewRequest) { |
| 121 cr.dispatchSimpleEvent(document, 'updateSummary'); | 121 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); |
| 122 cr.dispatchSimpleEvent(document, 'updatePrintButton'); | 122 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); |
| 123 } | 123 } |
| 124 }, | 124 }, |
| 125 | 125 |
| 126 /** | 126 /** |
| 127 * Listener function to execute whenever a change occurs in |textfield_| | 127 * Listener function to execute whenever a change occurs in |textfield_| |
| 128 * textfield. | 128 * textfield. |
| 129 * @private | 129 * @private |
| 130 */ | 130 */ |
| 131 onTextfieldChanged_: function() { | 131 onTextfieldChanged_: function() { |
| 132 this.updateButtonsState_(); | 132 this.updateButtonsState_(); |
| 133 this.showHideCollateOption_(); | 133 this.showHideCollateOption_(); |
| 134 if (!hasPendingPreviewRequest) { | 134 if (!hasPendingPreviewRequest) { |
| 135 cr.dispatchSimpleEvent(document, 'updateSummary'); | 135 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); |
| 136 cr.dispatchSimpleEvent(document, 'updatePrintButton'); | 136 cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); |
| 137 } | 137 } |
| 138 }, | 138 }, |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Adding listeners to all copies related controls. The listeners take care | 141 * Adding listeners to all copies related controls. The listeners take care |
| 142 * of altering their behavior depending on |hasPendingPreviewRequest|. | 142 * of altering their behavior depending on |hasPendingPreviewRequest|. |
| 143 * @private | 143 * @private |
| 144 */ | 144 */ |
| 145 addEventListeners_: function() { | 145 addEventListeners_: function() { |
| 146 this.textfield_.oninput = this.onTextfieldChanged_.bind(this); | 146 this.textfield_.oninput = this.onTextfieldChanged_.bind(this); |
| 147 this.incrementButton_.onclick = this.onIncrementButtonClicked_.bind(this); | 147 this.incrementButton_.onclick = this.onIncrementButtonClicked_.bind(this); |
| 148 this.decrementButton_.onclick = this.onDecrementButtonClicked_.bind(this); | 148 this.decrementButton_.onclick = this.onDecrementButtonClicked_.bind(this); |
| 149 this.twoSidedCheckbox_.onclick = function() { | 149 this.twoSidedCheckbox_.onclick = function() { |
| 150 if (!hasPendingPreviewRequest) | 150 if (!hasPendingPreviewRequest) |
| 151 cr.dispatchSimpleEvent(document, 'updateSummary'); | 151 cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY); |
| 152 } | 152 } |
| 153 document.addEventListener('PDFLoaded', | 153 document.addEventListener(customEvents.PDF_LOADED, |
| 154 this.updateButtonsState_.bind(this)); | 154 this.updateButtonsState_.bind(this)); |
| 155 document.addEventListener('printerCapabilitiesUpdated', | 155 document.addEventListener(customEvents.PRINTER_CAPABILITIES_UPDATED, |
| 156 this.onPrinterCapabilitiesUpdated_.bind(this)); | 156 this.onPrinterCapabilitiesUpdated_.bind(this)); |
| 157 }, | 157 }, |
| 158 | 158 |
| 159 /** | 159 /** |
| 160 * Listener triggered when a printerCapabilitiesUpdated event occurs. | 160 * Executes when a |customEvents.PRINTER_CAPABILITIES_UPDATED| event occurs. |
| 161 * @private | 161 * @private |
| 162 */ | 162 */ |
| 163 onPrinterCapabilitiesUpdated_: function(e) { | 163 onPrinterCapabilitiesUpdated_: function(e) { |
| 164 if (e.printerCapabilities.disableCopiesOption) { | 164 if (e.printerCapabilities.disableCopiesOption) { |
| 165 fadeOutElement(this.copiesOption_); | 165 fadeOutElement(this.copiesOption_); |
| 166 $('hr-before-copies').classList.remove('invisible'); | 166 $('hr-before-copies').classList.remove('invisible'); |
| 167 } else { | 167 } else { |
| 168 fadeInElement(this.copiesOption_); | 168 fadeInElement(this.copiesOption_); |
| 169 $('hr-before-copies').classList.add('invisible'); | 169 $('hr-before-copies').classList.add('invisible'); |
| 170 } | 170 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 fadeOutElement(this.hint_); | 238 fadeOutElement(this.hint_); |
| 239 } | 239 } |
| 240 this.hint_.setAttribute('aria-hidden', this.isValid()); | 240 this.hint_.setAttribute('aria-hidden', this.isValid()); |
| 241 } | 241 } |
| 242 }; | 242 }; |
| 243 | 243 |
| 244 return { | 244 return { |
| 245 CopiesSettings: CopiesSettings, | 245 CopiesSettings: CopiesSettings, |
| 246 }; | 246 }; |
| 247 }); | 247 }); |
| OLD | NEW |