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

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

Issue 7358002: Print Preview: Refactoring layout mode related logic to LayoutSettings class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing nits Created 9 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/layout_settings.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/print_preview/copies_settings.js
diff --git a/chrome/browser/resources/print_preview/copies_settings.js b/chrome/browser/resources/print_preview/copies_settings.js
index 72893b6cad693fca74e50f0093a8ec9a0349e48e..566fbefebb4fa98d2256c31524aae036a41b1067 100644
--- a/chrome/browser/resources/print_preview/copies_settings.js
+++ b/chrome/browser/resources/print_preview/copies_settings.js
@@ -10,6 +10,7 @@ cr.define('print_preview', function() {
* @constructor
*/
function CopiesSettings() {
+ this.copiesOption_ = $('copies-option');
this.textfield_ = $('copies');
this.incrementButton_ = $('increment');
this.decrementButton_ = $('decrement');
@@ -18,6 +19,7 @@ cr.define('print_preview', function() {
// Maximum allowed value for number of copies.
this.maxValue_ = 999;
this.collateOption_ = $('collate-option');
+ this.collateCheckbox_ = $('collate');
this.hint_ = $('copies-hint');
this.twoSidedCheckbox_ = $('two-sided');
}
@@ -54,6 +56,18 @@ cr.define('print_preview', function() {
},
/**
+ * Gets the duplex mode for printing.
+ * @return {number} duplex mode.
+ */
+ get duplexMode() {
+ // Constant values matches printing::DuplexMode enum. Not using const
+ // keyword because it is not allowed by JS strict mode.
+ var SIMPLEX = 0;
+ var LONG_EDGE = 1;
+ return !this.twoSidedCheckbox_.checked ? SIMPLEX : LONG_EDGE;
+ },
+
+ /**
* @return {boolean} true if |this.textfield_| is empty, or represents a
* positive integer value.
*/
@@ -62,6 +76,14 @@ cr.define('print_preview', function() {
},
/**
+ * Checks whether the preview collate setting value is set or not.
+ * @return {boolean} true if collate option is enabled and checked.
+ */
+ isCollated: function() {
+ return !this.collateOption_.hidden && this.collateCheckbox_.checked;
+ },
+
+ /**
* Resets |this.textfield_| to |this.minValue_|.
* @private
*/
@@ -120,6 +142,23 @@ cr.define('print_preview', function() {
}
document.addEventListener('PDFLoaded',
this.updateButtonsState_.bind(this));
+ document.addEventListener('printerCapabilitiesUpdated',
+ this.onPrinterCapabilitiesUpdated_.bind(this));
+ },
+
+ /**
+ * Listener triggered when a printerCapabilitiesUpdated event occurs.
+ * @private
+ */
+ onPrinterCapabilitiesUpdated_: function(e) {
+ if (e.printerCapabilities.disableCopiesOption) {
+ fadeOutElement(this.copiesOption_);
+ $('hr-before-copies').classList.remove('invisible');
+ } else {
+ fadeInElement(this.copiesOption_);
+ $('hr-before-copies').classList.add('invisible');
+ }
+ this.twoSidedCheckbox_.checked = e.printerCapabilities.setDuplexAsDefault;
},
/**
« no previous file with comments | « no previous file | chrome/browser/resources/print_preview/layout_settings.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698