| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Checks if |text| has a valid margin value format. A valid format is | 9 * Checks if |text| has a valid margin value format. A valid format is |
| 10 * parsable as a number and is greater than zero. | 10 * parsable as a number and is greater than zero. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 print_preview.MarginSettings.decimalPoint + '\\d+)*' + | 43 print_preview.MarginSettings.decimalPoint + '\\d+)*' + |
| 44 (!print_preview.MarginSettings.useMetricSystem ? '"?' : '(mm)?') + '$'); | 44 (!print_preview.MarginSettings.useMetricSystem ? '"?' : '(mm)?') + '$'); |
| 45 return regex; | 45 return regex; |
| 46 } | 46 } |
| 47 | 47 |
| 48 var marginValidationStates = { | 48 var marginValidationStates = { |
| 49 TOO_SMALL: 0, | 49 TOO_SMALL: 0, |
| 50 WITHIN_RANGE: 1, | 50 WITHIN_RANGE: 1, |
| 51 TOO_BIG: 2, | 51 TOO_BIG: 2, |
| 52 NOT_A_NUMBER: 3 | 52 NOT_A_NUMBER: 3 |
| 53 } | 53 }; |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Checks whether |value| is within range [0, limit]. | 56 * Checks whether |value| is within range [0, limit]. |
| 57 * @return {number} An appropriate value from enum |marginValidationStates|. | 57 * @return {number} An appropriate value from enum |marginValidationStates|. |
| 58 */ | 58 */ |
| 59 function validateMarginValue(value, limit) { | 59 function validateMarginValue(value, limit) { |
| 60 if (value <= limit && value >= 0) | 60 if (value <= limit && value >= 0) |
| 61 return marginValidationStates.WITHIN_RANGE; | 61 return marginValidationStates.WITHIN_RANGE; |
| 62 else if (value < 0) | 62 else if (value < 0) |
| 63 return marginValidationStates.TOO_SMALL; | 63 return marginValidationStates.TOO_SMALL; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 convertPointsToLocaleUnitsAndBack, | 178 convertPointsToLocaleUnitsAndBack, |
| 179 convertPointsToLocaleUnitsText: convertPointsToLocaleUnitsText, | 179 convertPointsToLocaleUnitsText: convertPointsToLocaleUnitsText, |
| 180 convertLocaleUnitsToPoints: convertLocaleUnitsToPoints, | 180 convertLocaleUnitsToPoints: convertLocaleUnitsToPoints, |
| 181 extractMarginValue: extractMarginValue, | 181 extractMarginValue: extractMarginValue, |
| 182 marginValidationStates: marginValidationStates, | 182 marginValidationStates: marginValidationStates, |
| 183 Rect: Rect, | 183 Rect: Rect, |
| 184 validateMarginText: validateMarginText, | 184 validateMarginText: validateMarginText, |
| 185 validateMarginValue: validateMarginValue, | 185 validateMarginValue: validateMarginValue, |
| 186 }; | 186 }; |
| 187 }); | 187 }); |
| OLD | NEW |