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 30 matching lines...) Expand all Loading... |
41 */ | 41 */ |
42 isLandscape: function() { | 42 isLandscape: function() { |
43 return this.landscapeRadioButton_.checked; | 43 return this.landscapeRadioButton_.checked; |
44 }, | 44 }, |
45 | 45 |
46 /** | 46 /** |
47 * Adding listeners to all layout related controls. The listeners take care | 47 * Adding listeners to all layout related controls. The listeners take care |
48 * of altering their behavior depending on |hasPendingPreviewRequest|. | 48 * of altering their behavior depending on |hasPendingPreviewRequest|. |
49 */ | 49 */ |
50 addEventListeners: function() { | 50 addEventListeners: function() { |
51 this.landscapeRadioButton_.onclick = function() { | 51 this.landscapeRadioButton_.onclick = this.onLayoutButtonClick_.bind(this); |
52 if (!hasPendingPreviewRequest) | 52 this.portraitRadioButton_.onclick = this.onLayoutButtonClick_.bind(this); |
53 this.onLayoutButtonClick_(); | |
54 }.bind(this); | |
55 this.portraitRadioButton_.onclick = function() { | |
56 if (!hasPendingPreviewRequest) | |
57 this.onLayoutButtonClick_(); | |
58 }.bind(this); | |
59 document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this)); | 53 document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this)); |
60 document.addEventListener('printerCapabilitiesUpdated', | 54 document.addEventListener('printerCapabilitiesUpdated', |
61 this.onPrinterCapabilitiesUpdated_.bind(this)); | 55 this.onPrinterCapabilitiesUpdated_.bind(this)); |
62 }, | 56 }, |
63 | 57 |
64 /** | 58 /** |
65 * Listener triggered when a printerCapabilitiesUpdated event occurs. | 59 * Listener triggered when a printerCapabilitiesUpdated event occurs. |
66 * @private | 60 * @private |
67 */ | 61 */ |
68 onPrinterCapabilitiesUpdated_: function(e) { | 62 onPrinterCapabilitiesUpdated_: function(e) { |
(...skipping 11 matching lines...) Expand all Loading... |
80 if (printSettings.isLandscape == this.isLandscape()) | 74 if (printSettings.isLandscape == this.isLandscape()) |
81 return; | 75 return; |
82 setDefaultValuesAndRegeneratePreview(); | 76 setDefaultValuesAndRegeneratePreview(); |
83 }, | 77 }, |
84 | 78 |
85 /** | 79 /** |
86 * Listener executing when a PDFLoaded event occurs. | 80 * Listener executing when a PDFLoaded event occurs. |
87 * @private | 81 * @private |
88 */ | 82 */ |
89 onPDFLoaded_: function() { | 83 onPDFLoaded_: function() { |
90 if (!previewModifiable) | 84 this.fadeInOut_(!previewModifiable); |
91 fadeOutElement(this.layoutOption_); | |
92 }, | 85 }, |
93 | 86 |
94 /** | 87 /** |
95 * @param {boolean} fadeOut True if |this.layoutOption_| should be faded | 88 * @param {boolean} fadeOut True if |this.layoutOption_| should be faded |
96 * out, false if it should be faded in. | 89 * out, false if it should be faded in. |
97 * @private | 90 * @private |
98 */ | 91 */ |
99 fadeInOut_: function(fadeOut) { | 92 fadeInOut_: function(fadeOut) { |
100 fadeOut ? fadeOutElement(this.layoutOption_) : | 93 fadeOut ? fadeOutElement(this.layoutOption_) : |
101 fadeInElement(this.layoutOption_); | 94 fadeInElement(this.layoutOption_); |
102 } | 95 } |
103 }; | 96 }; |
104 | 97 |
105 return { | 98 return { |
106 LayoutSettings: LayoutSettings, | 99 LayoutSettings: LayoutSettings, |
107 }; | 100 }; |
108 }); | 101 }); |
OLD | NEW |