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..9d5eecd300f869fb637cceaff63c5cf3b621d1a6 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 {number} The value of the margins type that needs to be restored |
+ // once the document loads. |
+ this.optionToRestore_ = -1; |
vandebo (ex-Chrome)
2011/11/02 22:36:54
As we discussed, a better name would be something
dpapad
2011/11/03 00:15:27
Done.
|
// Holds the currently updated default page layout values. |
this.currentDefaultPageLayout = null; |
// Holds the default page layout values when the custom margins was last |
@@ -202,6 +202,13 @@ cr.define('print_preview', function() { |
return margins; |
}, |
+ 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. |
*/ |
@@ -214,10 +221,14 @@ 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 |
*/ |
- setLastUsedMarginsType: function(lastUsedMarginsType) { |
+ setLastUsedMargins: function(lastUsedMarginsType, lastUsedMargins) { |
+ this.optionToRestore_ = lastUsedMarginsType; |
this.marginList_.selectedIndex = |
- this.getMarginOptionIndexByValue_(lastUsedMarginsType); |
+ this.getMarginOptionIndexByValue_(this.optionToRestore_); |
+ if (lastUsedMargins) |
+ this.customMargins = lastUsedMargins; |
}, |
/** |
@@ -532,8 +543,6 @@ cr.define('print_preview', function() { |
this.onDefaultMinimumNoMarginsSelected_(); |
else if (this.isCustomMarginsSelected()) |
this.onCustomMarginsSelected_(); |
- |
- this.lastSelectedOption_ = this.selectedMarginsValue; |
}, |
/** |
@@ -627,7 +636,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 +644,22 @@ cr.define('print_preview', function() { |
* @private |
*/ |
onPDFLoaded_: function() { |
- if (!previewModifiable) |
+ if (!previewModifiable) { |
fadeOutOption(this.marginsOption_); |
+ return; |
+ } |
+ |
+ if (this.optionToRestore_ == MarginSettings.MARGINS_VALUE_CUSTOM) { |
+ this.onCustomMarginsSelected_(); |
+ this.optionToRestore_ = -1; |
+ } |
} |
}; |
return { |
MarginSettings: MarginSettings, |
PageLayout: PageLayout, |
+ setLastUsedMargins: MarginSettings.prototype.setLastUsedMargins, |
setNumberFormatAndMeasurementSystem: |
MarginSettings.setNumberFormatAndMeasurementSystem, |
}; |