Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3229)

Unified Diff: chrome/browser/resources/print_preview/margin_textbox.js

Issue 8345025: Print Preview: Adding support for localized margin units and format. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing tests Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/margin_textbox.js
diff --git a/chrome/browser/resources/print_preview/margin_textbox.js b/chrome/browser/resources/print_preview/margin_textbox.js
index 733d46b4023638d39a881f20a5e5e1d89a307c0d..3f3e80d344a6c800888498f13df1fba3358a1be7 100644
--- a/chrome/browser/resources/print_preview/margin_textbox.js
+++ b/chrome/browser/resources/print_preview/margin_textbox.js
@@ -44,6 +44,16 @@ cr.define('print_preview', function() {
},
/**
+ * Sets the contents of the textbox.
+ * @param {number} newValueInPoints The value to be displayed in points.
+ * @private
+ */
+ setValue_: function(newValueInPoints) {
+ this.value =
+ print_preview.convertPointsToLocaleUnitsText(newValueInPoints);
+ },
+
+ /**
* Updates the state of |this|.
* @param {number} value The margin value in points.
* @param {number} valueLimit The upper allowed value for the margin.
@@ -52,10 +62,8 @@ cr.define('print_preview', function() {
*/
update: function(value, valueLimit, keepDisplayedValue) {
this.lastValidValueInPoints = value;
- if (!keepDisplayedValue) {
- this.value = print_preview.convertPointsToInchesText(
- this.lastValidValueInPoints);
- }
+ if (!keepDisplayedValue)
+ this.setValue_(this.lastValidValueInPoints);
this.valueLimit = valueLimit;
this.validate();
@@ -69,14 +77,12 @@ cr.define('print_preview', function() {
updateWhileDragging: function(dragDeltaInPoints) {
var validity = this.validateDelta(dragDeltaInPoints);
- if (validity == print_preview.marginValidationStates.WITHIN_RANGE) {
- this.value = print_preview.convertPointsToInchesText(
- this.lastValidValueInPoints + dragDeltaInPoints);
- } else if (validity == print_preview.marginValidationStates.TOO_SMALL) {
- this.value = print_preview.convertPointsToInchesText(0);
- } else if (validity == print_preview.marginValidationStates.TOO_BIG) {
- this.value = print_preview.convertPointsToInchesText(this.valueLimit);
- }
+ if (validity == print_preview.marginValidationStates.WITHIN_RANGE)
+ this.setValue_(this.lastValidValueInPoints + dragDeltaInPoints);
+ else if (validity == print_preview.marginValidationStates.TOO_SMALL)
+ this.setValue_(0);
+ else if (validity == print_preview.marginValidationStates.TOO_BIG)
+ this.setValue_(this.valueLimit);
this.validate();
this.updateColor();
@@ -99,8 +105,6 @@ cr.define('print_preview', function() {
this.isValid =
print_preview.validateMarginText(this.value, this.valueLimit) ==
print_preview.marginValidationStates.WITHIN_RANGE;
- if (this.isValid)
- this.value = print_preview.convertInchesToInchesText(this.margin);
},
/**
@@ -139,8 +143,7 @@ cr.define('print_preview', function() {
clearTimeout(this.timerId_);
this.validate();
if (!this.isValid) {
- this.value = print_preview.convertPointsToInchesText(
- this.lastValidValueInPoints);
+ this.setValue_(this.lastValidValueInPoints);
this.validate();
}
@@ -170,8 +173,7 @@ cr.define('print_preview', function() {
*/
onKeyUp_: function(e) {
if (e.keyCode == MarginTextbox.ESCAPE_KEYCODE) {
- this.value = print_preview.convertPointsToInchesText(
- this.lastValidValueInPoints);
+ this.setValue_(this.lastValidValueInPoints);
this.validate();
this.updateColor();
cr.dispatchSimpleEvent(document, 'updateSummary');
« no previous file with comments | « chrome/browser/resources/print_preview/margin_settings.js ('k') | chrome/browser/resources/print_preview/margin_utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698