| 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). |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 var regex = /^(\d+)(\W?)(\d+)(\W?)(\d+)$/; | 35 var regex = /^(\d+)(\W?)(\d+)(\W?)(\d+)$/; |
| 36 var matches = numberFormat.match(regex) || ['', '', ',', '', '.']; | 36 var matches = numberFormat.match(regex) || ['', '', ',', '', '.']; |
| 37 return [matches[2], matches[4]]; | 37 return [matches[2], matches[4]]; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 /** | 40 /** |
| 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; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 convertToPoints: function(localUnits) { | 146 convertToPoints: function(localUnits) { |
| 147 if (this.unitType_ == MeasurementSystem.UnitType.METRIC) { | 147 if (this.unitType_ == MeasurementSystem.UnitType.METRIC) { |
| 148 return localUnits * MeasurementSystem.PTS_PER_MM_; | 148 return localUnits * MeasurementSystem.PTS_PER_MM_; |
| 149 } else { | 149 } else { |
| 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 {MeasurementSystem: MeasurementSystem}; |
| 157 MeasurementSystem: MeasurementSystem | |
| 158 }; | |
| 159 }); | 157 }); |
| OLD | NEW |