| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 /** | 117 /** |
| 118 * Rounds a value in the local system's units to the appropriate precision. | 118 * Rounds a value in the local system's units to the appropriate precision. |
| 119 * @param {number} value Value to round. | 119 * @param {number} value Value to round. |
| 120 * @return {number} Rounded value. | 120 * @return {number} Rounded value. |
| 121 */ | 121 */ |
| 122 roundValue: function(value) { | 122 roundValue: function(value) { |
| 123 var precision = MeasurementSystem.Precision_[this.unitType_]; | 123 var precision = MeasurementSystem.Precision_[this.unitType_]; |
| 124 var roundedValue = Math.round(value / precision) * precision; | 124 var roundedValue = Math.round(value / precision) * precision; |
| 125 // Truncate | 125 // Truncate |
| 126 return roundedValue.toFixed( | 126 return +roundedValue.toFixed( |
| 127 MeasurementSystem.DecimalPlaces_[this.unitType_]); | 127 MeasurementSystem.DecimalPlaces_[this.unitType_]); |
| 128 }, | 128 }, |
| 129 | 129 |
| 130 /** | 130 /** |
| 131 * @param {number} pts Value in points to convert to local units. | 131 * @param {number} pts Value in points to convert to local units. |
| 132 * @return {number} Value in local units. | 132 * @return {number} Value in local units. |
| 133 */ | 133 */ |
| 134 convertFromPoints: function(pts) { | 134 convertFromPoints: function(pts) { |
| 135 if (this.unitType_ == MeasurementSystem.UnitType.METRIC) { | 135 if (this.unitType_ == MeasurementSystem.UnitType.METRIC) { |
| 136 return pts / MeasurementSystem.PTS_PER_MM_; | 136 return pts / MeasurementSystem.PTS_PER_MM_; |
| (...skipping 13 matching lines...) Expand all 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 |