| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Measurement system of the print preview. Used to parse and serialize point | 9 * Measurement system of the print preview. Used to parse and serialize point |
| 10 * measurements into the system's local units (e.g. millimeters, inches). | 10 * measurements into the system's local units (e.g. millimeters, inches). |
| 11 * @param {string} thousandsDelimeter Delimeter between thousands digits. | 11 * @param {string} thousandsDelimeter Delimeter between thousands digits. |
| 12 * @param {string} decimalDelimeter Delimeter between integers and decimals. | 12 * @param {string} decimalDelimeter Delimeter between integers and decimals. |
| 13 * @param {print_preview.MeasurementSystem.UnitType} unitType Measurement unit | 13 * @param {!print_preview.MeasurementSystem.UnitType} unitType Measurement |
| 14 * type of the system. | 14 * unit type of the system. |
| 15 * @constructor | 15 * @constructor |
| 16 */ | 16 */ |
| 17 function MeasurementSystem(thousandsDelimeter, decimalDelimeter, unitType) { | 17 function MeasurementSystem(thousandsDelimeter, decimalDelimeter, unitType) { |
| 18 this.thousandsDelimeter_ = thousandsDelimeter || ','; | 18 this.thousandsDelimeter_ = thousandsDelimeter || ','; |
| 19 this.decimalDelimeter_ = decimalDelimeter || '.'; | 19 this.decimalDelimeter_ = decimalDelimeter || '.'; |
| 20 this.unitType_ = unitType; | 20 this.unitType_ = unitType; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Parses |numberFormat| and extracts the symbols used for the thousands point | 24 * Parses |numberFormat| and extracts the symbols used for the thousands point |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 * Enumeration of measurement unit types. | 41 * Enumeration of measurement unit types. |
| 42 * @enum {number} | 42 * @enum {number} |
| 43 */ | 43 */ |
| 44 MeasurementSystem.UnitType = { | 44 MeasurementSystem.UnitType = { |
| 45 METRIC: 0, // millimeters | 45 METRIC: 0, // millimeters |
| 46 IMPERIAL: 1 // inches | 46 IMPERIAL: 1 // inches |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * Maximum resolution of local unit values. | 50 * Maximum resolution of local unit values. |
| 51 * @type {Object.<print_preview.MeasurementSystem.UnitType, number>} | 51 * @type {!Object.<!print_preview.MeasurementSystem.UnitType, number>} |
| 52 * @private | 52 * @private |
| 53 */ | 53 */ |
| 54 MeasurementSystem.Precision_ = {}; | 54 MeasurementSystem.Precision_ = {}; |
| 55 MeasurementSystem.Precision_[MeasurementSystem.UnitType.METRIC] = 0.5; | 55 MeasurementSystem.Precision_[MeasurementSystem.UnitType.METRIC] = 0.5; |
| 56 MeasurementSystem.Precision_[MeasurementSystem.UnitType.IMPERIAL] = 0.01; | 56 MeasurementSystem.Precision_[MeasurementSystem.UnitType.IMPERIAL] = 0.01; |
| 57 | 57 |
| 58 /** | 58 /** |
| 59 * Maximum number of decimal places to keep for local unit. | 59 * Maximum number of decimal places to keep for local unit. |
| 60 * @type {Object.<print_preview.MeasurementSystem.UnitType, number>} | 60 * @type {!Object.<!print_preview.MeasurementSystem.UnitType, number>} |
| 61 * @private | 61 * @private |
| 62 */ | 62 */ |
| 63 MeasurementSystem.DecimalPlaces_ = {}; | 63 MeasurementSystem.DecimalPlaces_ = {}; |
| 64 MeasurementSystem.DecimalPlaces_[MeasurementSystem.UnitType.METRIC] = 1; | 64 MeasurementSystem.DecimalPlaces_[MeasurementSystem.UnitType.METRIC] = 1; |
| 65 MeasurementSystem.DecimalPlaces_[MeasurementSystem.UnitType.IMPERIAL] = 2; | 65 MeasurementSystem.DecimalPlaces_[MeasurementSystem.UnitType.IMPERIAL] = 2; |
| 66 | 66 |
| 67 /** | 67 /** |
| 68 * Number of points per inch. | 68 * Number of points per inch. |
| 69 * @type {number} | 69 * @type {number} |
| 70 * @const | 70 * @const |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return localUnits * MeasurementSystem.PTS_PER_INCH_; | 150 return localUnits * MeasurementSystem.PTS_PER_INCH_; |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 // Export | 155 // Export |
| 156 return { | 156 return { |
| 157 MeasurementSystem: MeasurementSystem | 157 MeasurementSystem: MeasurementSystem |
| 158 }; | 158 }; |
| 159 }); | 159 }); |
| OLD | NEW |