Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1033)

Unified Diff: chrome/browser/resources/print_preview/layout_settings.js

Issue 7550022: Print Preview: Fixing behavior of event listeners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing obsolete code Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/layout_settings.js
diff --git a/chrome/browser/resources/print_preview/layout_settings.js b/chrome/browser/resources/print_preview/layout_settings.js
index 0932e21c566de0c0363a9a1bb2e74a02ef767b6c..d6894e6e811d618e4b76dcb88a23cacc6cf440d4 100644
--- a/chrome/browser/resources/print_preview/layout_settings.js
+++ b/chrome/browser/resources/print_preview/layout_settings.js
@@ -14,6 +14,8 @@ cr.define('print_preview', function() {
this.layoutOption_ = $('layout-option');
this.portraitRadioButton_ = $('portrait');
this.landscapeRadioButton_ = $('landscape');
+ this.wasLandscape_ = false;
+ this.updateState();
}
cr.addSingletonGetter(LayoutSettings);
@@ -44,18 +46,27 @@ cr.define('print_preview', function() {
},
/**
+ * @return {boolean} true if the chosen layout mode has changed since last
+ * time the state was updated.
+ */
+ hasChanged_ : function() {
+ return this.isLandscape() != this.wasLandscape_;
+ },
+
+ /**
+ * Saves the currently selected layout mode. Used in |this.hasChanged_|.
+ */
+ updateState : function() {
+ this.wasLandscape_ = this.isLandscape();
+ },
+
+ /**
* Adding listeners to all layout related controls. The listeners take care
* of altering their behavior depending on |hasPendingPreviewRequest|.
*/
addEventListeners: function() {
- this.landscapeRadioButton_.onclick = function() {
- if (!hasPendingPreviewRequest)
- this.onLayoutButtonClick_();
- }.bind(this);
- this.portraitRadioButton_.onclick = function() {
- if (!hasPendingPreviewRequest)
- this.onLayoutButtonClick_();
- }.bind(this);
+ this.landscapeRadioButton_.onclick = this.onLayoutButtonClick_.bind(this);
+ this.portraitRadioButton_.onclick = this.onLayoutButtonClick_.bind(this);
document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this));
document.addEventListener('printerCapabilitiesUpdated',
this.onPrinterCapabilitiesUpdated_.bind(this));
@@ -77,9 +88,8 @@ cr.define('print_preview', function() {
*/
onLayoutButtonClick_: function() {
// If the chosen layout is same as before, nothing needs to be done.
- if (printSettings.isLandscape == this.isLandscape())
- return;
- setDefaultValuesAndRegeneratePreview();
+ if (this.hasChanged_())
+ setDefaultValuesAndRegeneratePreview();
},
/**
@@ -87,8 +97,7 @@ cr.define('print_preview', function() {
* @private
*/
onPDFLoaded_: function() {
- if (!previewModifiable)
- fadeOutElement(this.layoutOption_);
+ this.fadeInOut_(!previewModifiable);
},
/**

Powered by Google App Engine
This is Rietveld 408576698