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..7c5f63ddd6d8d3be75b741c51e4b926faf1edb8a 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_ = null; |
kmadhusu
2011/11/02 20:40:05
Since this is a number, can you default to -1? Fro
kmadhusu
2011/11/02 20:40:05
optionToRestore_ => MarginValueToRestore_?
dpapad
2011/11/02 21:33:57
Margin value is confusing (sounds like it is a val
dpapad
2011/11/02 21:33:57
Done. In general though !!null returns false and i
|
// 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) { |
kmadhusu
2011/11/02 20:40:05
This function is called only from line 231. Can yo
dpapad
2011/11/02 21:33:57
I could but what is the benefit? Having one less f
|
+ 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) { |
kmadhusu
2011/11/02 20:40:05
"lastUsedMargins" param is optional. (Document thi
dpapad
2011/11/02 21:33:57
Any parameter not specified is initialized to unde
|
+ 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,23 @@ cr.define('print_preview', function() { |
* @private |
*/ |
onPDFLoaded_: function() { |
- if (!previewModifiable) |
+ if (!previewModifiable) { |
fadeOutOption(this.marginsOption_); |
+ return; |
+ } |
+ |
+ if (this.optionToRestore_ && |
+ this.optionToRestore_ == MarginSettings.MARGINS_VALUE_CUSTOM) { |
+ this.onCustomMarginsSelected_(); |
+ this.optionToRestore_ = null; |
+ } |
} |
}; |
return { |
MarginSettings: MarginSettings, |
PageLayout: PageLayout, |
+ setLastUsedMargins: MarginSettings.prototype.setLastUsedMargins, |
setNumberFormatAndMeasurementSystem: |
MarginSettings.setNumberFormatAndMeasurementSystem, |
}; |