Commit ca2e7208 authored by dpapad@chromium.org's avatar dpapad@chromium.org

Print Preview: Adding "Minimum" option in margins dropdown.

BUG=101456
TEST=Select Minimum in the margins dropdown.

Review URL: http://codereview.chromium.org/8392012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107803 0039d316-1c4b-4281-b951-d872f2087c98
parent fabf36d2
...@@ -6408,6 +6408,9 @@ Keep your key file in a safe place. You will need it to create new versions of y ...@@ -6408,6 +6408,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_PRINT_PREVIEW_CUSTOM_MARGINS" desc="Option that specifies the page be printed with user-specified custom margins."> <message name="IDS_PRINT_PREVIEW_CUSTOM_MARGINS" desc="Option that specifies the page be printed with user-specified custom margins.">
Custom Custom
</message> </message>
<message name="IDS_PRINT_PREVIEW_MINIMUM_MARGINS" desc="Option that specifies the page be printed with the minimum allowed margins by the printer.">
Minimum
</message>
<message name="IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL" desc="ARIA label used by screen reader to explain the purpose of the top margin textbox."> <message name="IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL" desc="ARIA label used by screen reader to explain the purpose of the top margin textbox.">
Top margin Top margin
</message> </message>
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<select id="margin-list"> <select id="margin-list">
<option i18n-content="defaultMargins" value="0" selected></option> <option i18n-content="defaultMargins" value="0" selected></option>
<option i18n-content="noMargins" value="1"></option> <option i18n-content="noMargins" value="1"></option>
<option i18n-content="minimumMargins" value="3"></option>
<option i18n-content="customMargins" value="2"></option> <option i18n-content="customMargins" value="2"></option>
</select> </select>
</div> </div>
......
...@@ -155,6 +155,7 @@ cr.define('print_preview', function() { ...@@ -155,6 +155,7 @@ cr.define('print_preview', function() {
MarginSettings.MARGINS_VALUE_DEFAULT = 0; MarginSettings.MARGINS_VALUE_DEFAULT = 0;
MarginSettings.MARGINS_VALUE_NO_MARGINS = 1; MarginSettings.MARGINS_VALUE_NO_MARGINS = 1;
MarginSettings.MARGINS_VALUE_CUSTOM = 2; MarginSettings.MARGINS_VALUE_CUSTOM = 2;
MarginSettings.MARGINS_VALUE_MINIMUM = 3;
// Default Margins option index. // Default Margins option index.
MarginSettings.DEFAULT_MARGINS_OPTION_INDEX = 0; MarginSettings.DEFAULT_MARGINS_OPTION_INDEX = 0;
// Group name corresponding to the top margin. // Group name corresponding to the top margin.
...@@ -246,6 +247,13 @@ cr.define('print_preview', function() { ...@@ -246,6 +247,13 @@ cr.define('print_preview', function() {
return this.selectedMarginsValue == MarginSettings.MARGINS_VALUE_CUSTOM; return this.selectedMarginsValue == MarginSettings.MARGINS_VALUE_CUSTOM;
}, },
/**
* @return {boolean} True if minimum margins are selected.
*/
isMinimumMarginsSelected: function() {
return this.selectedMarginsValue == MarginSettings.MARGINS_VALUE_MINIMUM;
},
/** /**
* If the custom margin values have changed then request a new preview based * If the custom margin values have changed then request a new preview based
* on the newly set margins. * on the newly set margins.
...@@ -491,10 +499,9 @@ cr.define('print_preview', function() { ...@@ -491,10 +499,9 @@ cr.define('print_preview', function() {
* @private * @private
*/ */
onMarginsChanged_: function() { onMarginsChanged_: function() {
if (this.isDefaultMarginsSelected()) if (this.isDefaultMarginsSelected() || this.isMinimumMarginsSelected() ||
this.onDefaultMarginsSelected_(); this.isNoMarginsSelected())
else if (this.isNoMarginsSelected()) this.onDefaultMinimumNoMarginsSelected_();
this.onNoMarginsSelected_();
else if (this.isCustomMarginsSelected()) else if (this.isCustomMarginsSelected())
this.onCustomMarginsSelected_(); this.onCustomMarginsSelected_();
...@@ -502,26 +509,15 @@ cr.define('print_preview', function() { ...@@ -502,26 +509,15 @@ cr.define('print_preview', function() {
}, },
/** /**
* Executes when the default margins option is selected. * Executes when the default or minimum or no margins option is selected.
* @private * @private
*/ */
onDefaultMarginsSelected_: function() { onDefaultMinimumNoMarginsSelected_: function() {
this.removeCustomMarginEventListeners_(); this.removeCustomMarginEventListeners_();
this.forceDisplayingMarginLines_ = true; this.forceDisplayingMarginLines_ = true;
setDefaultValuesAndRegeneratePreview(false); setDefaultValuesAndRegeneratePreview(false);
}, },
/**
* Executes when the no margins option is selected.
* @private
*/
onNoMarginsSelected_: function() {
this.removeCustomMarginEventListeners_();
this.forceDisplayingMarginLines_ = true;
this.customMargins_ = new Margins(0, 0, 0, 0);
setDefaultValuesAndRegeneratePreview(false);
},
/** /**
* Executes when the custom margins option is selected. * Executes when the custom margins option is selected.
* @private * @private
...@@ -529,10 +525,8 @@ cr.define('print_preview', function() { ...@@ -529,10 +525,8 @@ cr.define('print_preview', function() {
onCustomMarginsSelected_: function() { onCustomMarginsSelected_: function() {
this.addCustomMarginEventListeners_(); this.addCustomMarginEventListeners_();
if (this.lastSelectedOption_ == MarginSettings.MARGINS_VALUE_DEFAULT) { this.customMargins_ = this.currentDefaultPageLayout.margins_;
this.customMargins_ = this.currentDefaultPageLayout.margins_; this.customMargins_.roundToLocaleUnits();
this.customMargins_.roundToLocaleUnits();
}
this.previousCustomMargins_.copy(this.customMargins_); this.previousCustomMargins_.copy(this.customMargins_);
if (this.previousDefaultPageLayout_ != this.currentDefaultPageLayout) { if (this.previousDefaultPageLayout_ != this.currentDefaultPageLayout) {
......
...@@ -123,6 +123,7 @@ PrintPreviewDataSource::PrintPreviewDataSource() ...@@ -123,6 +123,7 @@ PrintPreviewDataSource::PrintPreviewDataSource()
AddLocalizedString("defaultMargins", IDS_PRINT_PREVIEW_DEFAULT_MARGINS); AddLocalizedString("defaultMargins", IDS_PRINT_PREVIEW_DEFAULT_MARGINS);
AddLocalizedString("noMargins", IDS_PRINT_PREVIEW_NO_MARGINS); AddLocalizedString("noMargins", IDS_PRINT_PREVIEW_NO_MARGINS);
AddLocalizedString("customMargins", IDS_PRINT_PREVIEW_CUSTOM_MARGINS); AddLocalizedString("customMargins", IDS_PRINT_PREVIEW_CUSTOM_MARGINS);
AddLocalizedString("minimumMargins", IDS_PRINT_PREVIEW_MINIMUM_MARGINS);
AddLocalizedString("top", IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL); AddLocalizedString("top", IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL);
AddLocalizedString("bottom", IDS_PRINT_PREVIEW_BOTTOM_MARGIN_LABEL); AddLocalizedString("bottom", IDS_PRINT_PREVIEW_BOTTOM_MARGIN_LABEL);
AddLocalizedString("left", IDS_PRINT_PREVIEW_LEFT_MARGIN_LABEL); AddLocalizedString("left", IDS_PRINT_PREVIEW_LEFT_MARGIN_LABEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment