summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 21:53:50 +0000
committerdpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 21:53:50 +0000
commitca2e7208d1f662943849fbefecb88e38008881b8 (patch)
tree16c88c93768dbdaad61fda0c515195753bc69256
parentfabf36d21ced6e50aac3300f35316c4a9b3f9fa8 (diff)
downloadchromium_src-ca2e7208d1f662943849fbefecb88e38008881b8.zip
chromium_src-ca2e7208d1f662943849fbefecb88e38008881b8.tar.gz
chromium_src-ca2e7208d1f662943849fbefecb88e38008881b8.tar.bz2
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
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/resources/print_preview/margin_settings.html1
-rw-r--r--chrome/browser/resources/print_preview/margin_settings.js36
-rw-r--r--chrome/browser/ui/webui/print_preview_data_source.cc1
4 files changed, 20 insertions, 21 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 006e21f..649f0f2 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -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.">
Custom
</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.">
Top margin
</message>
diff --git a/chrome/browser/resources/print_preview/margin_settings.html b/chrome/browser/resources/print_preview/margin_settings.html
index a5c44bf..e1602fc 100644
--- a/chrome/browser/resources/print_preview/margin_settings.html
+++ b/chrome/browser/resources/print_preview/margin_settings.html
@@ -4,6 +4,7 @@
<select id="margin-list">
<option i18n-content="defaultMargins" value="0" selected></option>
<option i18n-content="noMargins" value="1"></option>
+ <option i18n-content="minimumMargins" value="3"></option>
<option i18n-content="customMargins" value="2"></option>
</select>
</div>
diff --git a/chrome/browser/resources/print_preview/margin_settings.js b/chrome/browser/resources/print_preview/margin_settings.js
index 0a70460..a81606c 100644
--- a/chrome/browser/resources/print_preview/margin_settings.js
+++ b/chrome/browser/resources/print_preview/margin_settings.js
@@ -155,6 +155,7 @@ cr.define('print_preview', function() {
MarginSettings.MARGINS_VALUE_DEFAULT = 0;
MarginSettings.MARGINS_VALUE_NO_MARGINS = 1;
MarginSettings.MARGINS_VALUE_CUSTOM = 2;
+ MarginSettings.MARGINS_VALUE_MINIMUM = 3;
// Default Margins option index.
MarginSettings.DEFAULT_MARGINS_OPTION_INDEX = 0;
// Group name corresponding to the top margin.
@@ -247,6 +248,13 @@ cr.define('print_preview', function() {
},
/**
+ * @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
* on the newly set margins.
* @private
@@ -491,10 +499,9 @@ cr.define('print_preview', function() {
* @private
*/
onMarginsChanged_: function() {
- if (this.isDefaultMarginsSelected())
- this.onDefaultMarginsSelected_();
- else if (this.isNoMarginsSelected())
- this.onNoMarginsSelected_();
+ if (this.isDefaultMarginsSelected() || this.isMinimumMarginsSelected() ||
+ this.isNoMarginsSelected())
+ this.onDefaultMinimumNoMarginsSelected_();
else if (this.isCustomMarginsSelected())
this.onCustomMarginsSelected_();
@@ -502,37 +509,24 @@ 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
*/
- onDefaultMarginsSelected_: function() {
+ onDefaultMinimumNoMarginsSelected_: function() {
this.removeCustomMarginEventListeners_();
this.forceDisplayingMarginLines_ = true;
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.
* @private
*/
onCustomMarginsSelected_: function() {
this.addCustomMarginEventListeners_();
- if (this.lastSelectedOption_ == MarginSettings.MARGINS_VALUE_DEFAULT) {
- this.customMargins_ = this.currentDefaultPageLayout.margins_;
- this.customMargins_.roundToLocaleUnits();
- }
+ this.customMargins_ = this.currentDefaultPageLayout.margins_;
+ this.customMargins_.roundToLocaleUnits();
this.previousCustomMargins_.copy(this.customMargins_);
if (this.previousDefaultPageLayout_ != this.currentDefaultPageLayout) {
diff --git a/chrome/browser/ui/webui/print_preview_data_source.cc b/chrome/browser/ui/webui/print_preview_data_source.cc
index 94241ae..3621859 100644
--- a/chrome/browser/ui/webui/print_preview_data_source.cc
+++ b/chrome/browser/ui/webui/print_preview_data_source.cc
@@ -123,6 +123,7 @@ PrintPreviewDataSource::PrintPreviewDataSource()
AddLocalizedString("defaultMargins", IDS_PRINT_PREVIEW_DEFAULT_MARGINS);
AddLocalizedString("noMargins", IDS_PRINT_PREVIEW_NO_MARGINS);
AddLocalizedString("customMargins", IDS_PRINT_PREVIEW_CUSTOM_MARGINS);
+ AddLocalizedString("minimumMargins", IDS_PRINT_PREVIEW_MINIMUM_MARGINS);
AddLocalizedString("top", IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL);
AddLocalizedString("bottom", IDS_PRINT_PREVIEW_BOTTOM_MARGIN_LABEL);
AddLocalizedString("left", IDS_PRINT_PREVIEW_LEFT_MARGIN_LABEL);