| 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 LayoutSettings object. This object encapsulates all settings and | 9 * Creates a LayoutSettings object. This object encapsulates all settings and |
| 10 * logic related to layout mode (portrait/landscape). | 10 * logic related to layout mode (portrait/landscape). |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Adding listeners to all layout related controls. The listeners take care | 65 * Adding listeners to all layout related controls. The listeners take care |
| 66 * of altering their behavior depending on |hasPendingPreviewRequest|. | 66 * of altering their behavior depending on |hasPendingPreviewRequest|. |
| 67 * @private | 67 * @private |
| 68 */ | 68 */ |
| 69 addEventListeners_: function() { | 69 addEventListeners_: function() { |
| 70 this.landscapeRadioButton_.onclick = this.onLayoutButtonClick_.bind(this); | 70 this.landscapeRadioButton_.onclick = this.onLayoutButtonClick_.bind(this); |
| 71 this.portraitRadioButton_.onclick = this.onLayoutButtonClick_.bind(this); | 71 this.portraitRadioButton_.onclick = this.onLayoutButtonClick_.bind(this); |
| 72 document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this)); | 72 document.addEventListener(customEvents.PDF_LOADED, |
| 73 document.addEventListener('printerCapabilitiesUpdated', | 73 this.onPDFLoaded_.bind(this)); |
| 74 document.addEventListener(customEvents.PRINTER_CAPABILITIES_UPDATED, |
| 74 this.onPrinterCapabilitiesUpdated_.bind(this)); | 75 this.onPrinterCapabilitiesUpdated_.bind(this)); |
| 75 }, | 76 }, |
| 76 | 77 |
| 77 /** | 78 /** |
| 78 * Listener triggered when a printerCapabilitiesUpdated event occurs. | 79 * Executes when a |customEvents.PRINTER_CAPABILITIES_UPDATED| event occurs. |
| 79 * @private | 80 * @private |
| 80 */ | 81 */ |
| 81 onPrinterCapabilitiesUpdated_: function(e) { | 82 onPrinterCapabilitiesUpdated_: function(e) { |
| 82 if (e.printerCapabilities.disableLandscapeOption) | 83 if (e.printerCapabilities.disableLandscapeOption) |
| 83 this.fadeInOut_(e.printerCapabilities.disableLandscapeOption); | 84 this.fadeInOut_(e.printerCapabilities.disableLandscapeOption); |
| 84 }, | 85 }, |
| 85 | 86 |
| 86 /** | 87 /** |
| 87 * Listener executing when |this.landscapeRadioButton_| or | 88 * Listener executing when |this.landscapeRadioButton_| or |
| 88 * |this.portraitRadioButton_| is clicked. | 89 * |this.portraitRadioButton_| is clicked. |
| 89 * @private | 90 * @private |
| 90 */ | 91 */ |
| 91 onLayoutButtonClick_: function() { | 92 onLayoutButtonClick_: function() { |
| 92 // If the chosen layout is same as before, nothing needs to be done. | 93 // If the chosen layout is same as before, nothing needs to be done. |
| 93 if (this.hasChanged_()) | 94 if (this.hasChanged_()) |
| 94 setDefaultValuesAndRegeneratePreview(true); | 95 setDefaultValuesAndRegeneratePreview(true); |
| 95 }, | 96 }, |
| 96 | 97 |
| 97 /** | 98 /** |
| 98 * Listener executing when a PDFLoaded event occurs. | 99 * Listener executing when a |customEvents.PDF_LOADED| event occurs. |
| 99 * @private | 100 * @private |
| 100 */ | 101 */ |
| 101 onPDFLoaded_: function() { | 102 onPDFLoaded_: function() { |
| 102 this.fadeInOut_(!previewModifiable); | 103 this.fadeInOut_(!previewModifiable); |
| 103 }, | 104 }, |
| 104 | 105 |
| 105 /** | 106 /** |
| 106 * @param {boolean} fadeOut True if |this.layoutOption_| should be faded | 107 * @param {boolean} fadeOut True if |this.layoutOption_| should be faded |
| 107 * out, false if it should be faded in. | 108 * out, false if it should be faded in. |
| 108 * @private | 109 * @private |
| 109 */ | 110 */ |
| 110 fadeInOut_: function(fadeOut) { | 111 fadeInOut_: function(fadeOut) { |
| 111 fadeOut ? fadeOutElement(this.layoutOption_) : | 112 fadeOut ? fadeOutElement(this.layoutOption_) : |
| 112 fadeInElement(this.layoutOption_); | 113 fadeInElement(this.layoutOption_); |
| 113 } | 114 } |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 return { | 117 return { |
| 117 LayoutSettings: LayoutSettings, | 118 LayoutSettings: LayoutSettings, |
| 118 }; | 119 }; |
| 119 }); | 120 }); |
| OLD | NEW |