Index: chrome/browser/resources/print_preview/margin_settings.js |
diff --git a/chrome/browser/resources/print_preview/margin_settings.js b/chrome/browser/resources/print_preview/margin_settings.js |
index 11577c22508f3aa6f908a88ef00cd7ed814efe20..e2b768d144b3a3ad0c7a13ce05946367b839104c 100644 |
--- a/chrome/browser/resources/print_preview/margin_settings.js |
+++ b/chrome/browser/resources/print_preview/margin_settings.js |
@@ -129,9 +129,9 @@ cr.define('print_preview', function() { |
this.pageWidth_ = -1; |
// Holds the height of the page in points. |
this.pageHeight_ = -1; |
- // The last selected margin option. |
- this.lastSelectedOption_ = MarginSettings.MARGINS_VALUE_DEFAULT; |
- |
+ // @type {boolean} True if the margins UI should be diplayed when the next |
kmadhusu
2011/11/03 17:35:38
As per the comments, Margins options will not be s
|
+ // |customEvents.PDF_LOADED| event occurs. |
+ this.forceMarginsUIOnPDFLoad_ = false; |
// Holds the currently updated default page layout values. |
this.currentDefaultPageLayout = null; |
// Holds the default page layout values when the custom margins was last |
@@ -203,6 +203,19 @@ cr.define('print_preview', function() { |
}, |
/** |
+ * Sets |this.customMargins_| according to |margins|. |
+ * @param {{marginLeft: number, marginTop: number, marginRight: bottom, |
+ * marginRight: number}} margins An object holding the four margin |
+ * values. |
+ */ |
+ set customMargins(margins) { |
+ this.customMargins_.left = margins.marginLeft; |
+ this.customMargins_.top = margins.marginTop; |
+ this.customMargins_.right = margins.marginRight; |
+ this.customMargins_.bottom = margins.marginBottom; |
+ }, |
+ |
+ /** |
* @return {number} The value of the selected margin option. |
*/ |
get selectedMarginsValue() { |
@@ -214,10 +227,17 @@ cr.define('print_preview', function() { |
* Sets the current margin selection to |lastUsedMarginsType|. |
* @param {number} lastUsedMarginsType An integer value identifying a margin |
* type according to MarginType enum in printing/print_job_constants.h. |
+ * @param {Object} lastUsedMargins The last used margins. It is undefined if |
vandebo (ex-Chrome)
2011/11/03 18:07:27
nit: It is only used if |lastUsedMarginsType| == M
dpapad
2011/11/03 18:48:27
Done.
|
+ * |lastUsedMarginsType| differs from |
+ * |MarginSettings.MARGINS_VALUE_CUSTOM|. |
*/ |
- setLastUsedMarginsType: function(lastUsedMarginsType) { |
+ setLastUsedMargins: function(lastUsedMarginsType, lastUsedMargins) { |
+ this.forceMarginsUIOnPDFLoad_ = |
+ lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM; |
this.marginList_.selectedIndex = |
this.getMarginOptionIndexByValue_(lastUsedMarginsType); |
+ if (lastUsedMargins) |
+ this.customMargins = lastUsedMargins; |
}, |
/** |
@@ -532,8 +552,6 @@ cr.define('print_preview', function() { |
this.onDefaultMinimumNoMarginsSelected_(); |
else if (this.isCustomMarginsSelected()) |
this.onCustomMarginsSelected_(); |
- |
- this.lastSelectedOption_ = this.selectedMarginsValue; |
}, |
/** |
@@ -627,7 +645,6 @@ cr.define('print_preview', function() { |
MarginSettings.OPTION_INDEX_DEFAULT].selected = true; |
this.removeCustomMarginEventListeners_(); |
this.forceDisplayingMarginLines_ = true; |
- this.lastSelectedOption_ = MarginSettings.MARGINS_VALUE_DEFAULT; |
} |
}, |
@@ -636,14 +653,22 @@ cr.define('print_preview', function() { |
* @private |
*/ |
onPDFLoaded_: function() { |
- if (!previewModifiable) |
+ if (!previewModifiable) { |
fadeOutOption(this.marginsOption_); |
+ return; |
+ } |
+ |
+ if (this.forceMarginsUIOnPDFLoad_) { |
+ this.onCustomMarginsSelected_(); |
+ this.forceMarginsUIOnPDFLoad_ = false; |
+ } |
} |
}; |
return { |
MarginSettings: MarginSettings, |
PageLayout: PageLayout, |
+ setLastUsedMargins: MarginSettings.prototype.setLastUsedMargins, |
setNumberFormatAndMeasurementSystem: |
MarginSettings.setNumberFormatAndMeasurementSystem, |
}; |