| 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 * Creates a Margins object that holds four margin values. The units in which | 9 * Creates a Margins object that holds four margin values. The units in which |
| 10 * the values are expressed can be any numeric value. | 10 * the values are expressed can be any numeric value. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Group name corresponding to the left margin. | 160 // Group name corresponding to the left margin. |
| 161 MarginSettings.LEFT_GROUP = 'left'; | 161 MarginSettings.LEFT_GROUP = 'left'; |
| 162 // Group name corresponding to the right margin. | 162 // Group name corresponding to the right margin. |
| 163 MarginSettings.RIGHT_GROUP = 'right'; | 163 MarginSettings.RIGHT_GROUP = 'right'; |
| 164 // Group name corresponding to the bottom margin. | 164 // Group name corresponding to the bottom margin. |
| 165 MarginSettings.BOTTOM_GROUP = 'bottom'; | 165 MarginSettings.BOTTOM_GROUP = 'bottom'; |
| 166 | 166 |
| 167 /** | 167 /** |
| 168 * Extracts the number formatting and measurement system for the current | 168 * Extracts the number formatting and measurement system for the current |
| 169 * locale. | 169 * locale. |
| 170 * @param {string} numberFormat Is the formatted version of a sample number, | 170 * @param {string} numberFormat Is the formatted version of a sample number |
| 171 * sent from the backend. | 171 * sent from the backend. |
| 172 * @param {number} measurementSystem 0 for SI (aka metric system), 1 for the | 172 * @param {number} measurementSystem 0 for SI (aka metric system), 1 for the |
| 173 * system used in the US. Note: Mathces UMeasurementSystem enum in | 173 * system used in the US. Note: Mathces UMeasurementSystem enum in |
| 174 * third_party/icu/public/i18n/unicode/ulocdata.h. | 174 * third_party/icu/public/i18n/unicode/ulocdata.h. |
| 175 */ | 175 */ |
| 176 MarginSettings.setNumberFormatAndMeasurementSystem = function( | 176 MarginSettings.setNumberFormatAndMeasurementSystem = function( |
| 177 numberFormat, measurementSystem) { | 177 numberFormat, measurementSystem) { |
| 178 var regex = /^(\d+)(\.|\,)(\d+)(\.|\,)(\d+)$/; | 178 var symbols = parseNumberFormat(numberFormat); |
| 179 var matches = numberFormat.match(regex); | 179 MarginSettings.thousandsPoint = symbols[0]; |
| 180 MarginSettings.thousandsPoint = matches[2]; | 180 MarginSettings.decimalPoint = symbols[1]; |
| 181 MarginSettings.decimalPoint = matches[4]; | |
| 182 MarginSettings.useMetricSystem = measurementSystem == 0; | 181 MarginSettings.useMetricSystem = measurementSystem == 0; |
| 183 }; | 182 }; |
| 184 | 183 |
| 185 cr.addSingletonGetter(MarginSettings); | 184 cr.addSingletonGetter(MarginSettings); |
| 186 | 185 |
| 187 MarginSettings.prototype = { | 186 MarginSettings.prototype = { |
| 188 /** | 187 /** |
| 189 * Returns a dictionary of the four custom margin values. | 188 * Returns a dictionary of the four custom margin values. |
| 190 * @return {object} | 189 * @return {object} |
| 191 */ | 190 */ |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth; | 704 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth; |
| 706 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight; | 705 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight; |
| 707 } | 706 } |
| 708 }; | 707 }; |
| 709 | 708 |
| 710 return { | 709 return { |
| 711 MarginSettings: MarginSettings, | 710 MarginSettings: MarginSettings, |
| 712 PageLayout: PageLayout, | 711 PageLayout: PageLayout, |
| 713 }; | 712 }; |
| 714 }); | 713 }); |
| OLD | NEW |