| Index: chrome/browser/resources/print_preview/previewarea/margin_utils.js
|
| diff --git a/chrome/browser/resources/print_preview/margin_utils.js b/chrome/browser/resources/print_preview/previewarea/margin_utils.js
|
| similarity index 89%
|
| rename from chrome/browser/resources/print_preview/margin_utils.js
|
| rename to chrome/browser/resources/print_preview/previewarea/margin_utils.js
|
| index a93ef0e72083cd06bada7b2a4b39ad409188c700..68a6ca9afb8565034ebedab67625af7c85b1ae1f 100644
|
| --- a/chrome/browser/resources/print_preview/margin_utils.js
|
| +++ b/chrome/browser/resources/print_preview/previewarea/margin_utils.js
|
| @@ -13,20 +13,22 @@ cr.define('print_preview', function() {
|
| * Note: The inch symbol (") at the end of |text| is allowed.
|
| *
|
| * @param {string} text The text to check.
|
| + * @param {print_preview.MeasurementSystem} measurementSystem Used to handle
|
| + * parsing local units.
|
| * @return {number} The margin value represented by |text| or null if |text|
|
| * does not represent a valid number.
|
| */
|
| - function extractMarginValue(text) {
|
| + function extractMarginValue(text, measurementSystem) {
|
| // Removing whitespace anywhere in the string.
|
| text = text.replace(/\s*/g, '');
|
| if (text.length == 0)
|
| return -1;
|
| - var validationRegex = getValidationRegExp();
|
| + var validationRegex = getValidationRegExp(measurementSystem);
|
| if (validationRegex.test(text)) {
|
| // Replacing decimal point with the dot symbol in order to use
|
| // parseFloat() properly.
|
| - var replacementRegex = new RegExp('\\' +
|
| - print_preview.MarginSettings.decimalPoint + '{1}');
|
| + var replacementRegex =
|
| + new RegExp('\\' + measurementSystem.decimalDelimeter + '{1}');
|
| text = text.replace(replacementRegex, '.');
|
| return parseFloat(text);
|
| }
|
| @@ -34,14 +36,16 @@ cr.define('print_preview', function() {
|
| }
|
|
|
| /**
|
| + * @param {print_preview.MeasurementSystem} measurementSystem Contains the
|
| + * delimeters used in this system.
|
| * @return {RegExp} A regular expression for validating the input of the user.
|
| * It takes into account the user's locale.
|
| */
|
| - function getValidationRegExp() {
|
| + function getValidationRegExp(measurementSystem) {
|
| var regex = new RegExp('(^\\d+)(\\' +
|
| - print_preview.MarginSettings.thousandsPoint + '\\d{3})*(\\' +
|
| - print_preview.MarginSettings.decimalPoint + '\\d+)*' +
|
| - (!print_preview.MarginSettings.useMetricSystem ? '"?' : '(mm)?') + '$');
|
| + measurementSystem.thousandsDelimeter + '\\d{3})*(\\' +
|
| + measurementSystem.decimalDelimeter + '\\d+)*' +
|
| + '(' + measurementSystem.unitSymbol + ')?' + '$');
|
| return regex;
|
| }
|
|
|
|
|