| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 * @oaram {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 regex = /^(\d+)(\.|\,)(\d+)(\.|\,)(\d+)$/; |
| 179 var matches = numberFormat.match(regex); | 179 var matches = numberFormat.match(regex); |
| 180 MarginSettings.thousandsPoint = matches[2]; | 180 MarginSettings.thousandsPoint = matches[2]; |
| 181 MarginSettings.decimalPoint = matches[4]; | 181 MarginSettings.decimalPoint = matches[4]; |
| 182 MarginSettings.useMetricSystem = measurementSystem == 0; | 182 MarginSettings.useMetricSystem = measurementSystem == 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 /** | 222 /** |
| 223 * Sets the current margin selection to |lastUsedMarginType|. | 223 * Sets the current margin selection to |lastUsedMarginType|. |
| 224 * @param {number} lastUsedMarginType An integer value identifying a margin | 224 * @param {number} lastUsedMarginType An integer value identifying a margin |
| 225 * type according to MarginType enum in printing/print_job_constants.h. | 225 * type according to MarginType enum in printing/print_job_constants.h. |
| 226 * @param {Object} lastUsedCustomMargins The last used custom margins. If | 226 * @param {Object} lastUsedCustomMargins The last used custom margins. If |
| 227 * custom margins have not been used before | 227 * custom margins have not been used before |
| 228 * |margin{Top|Bottom|Left|Right}| attributes are missing. | 228 * |margin{Top|Bottom|Left|Right}| attributes are missing. |
| 229 */ | 229 */ |
| 230 setLastUsedMargins: function(lastUsedMarginsSettings) { | 230 setLastUsedMargins: function(lastUsedMarginsSettings) { |
| 231 var lastUsedMarginsType = lastUsedMarginsSettings['marginsType'] | 231 var lastUsedMarginsType = lastUsedMarginsSettings['marginsType']; |
| 232 this.forceMarginsUIOnPDFLoad_ = | 232 this.forceMarginsUIOnPDFLoad_ = |
| 233 lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM; | 233 lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM; |
| 234 this.marginList_.selectedIndex = | 234 this.marginList_.selectedIndex = |
| 235 this.getMarginOptionIndexByValue_(lastUsedMarginsType); | 235 this.getMarginOptionIndexByValue_(lastUsedMarginsType); |
| 236 if (lastUsedMarginsSettings.hasOwnProperty('marginTop') && | 236 if (lastUsedMarginsSettings.hasOwnProperty('marginTop') && |
| 237 lastUsedMarginsSettings.hasOwnProperty('marginBottom') && | 237 lastUsedMarginsSettings.hasOwnProperty('marginBottom') && |
| 238 lastUsedMarginsSettings.hasOwnProperty('marginRight') && | 238 lastUsedMarginsSettings.hasOwnProperty('marginRight') && |
| 239 lastUsedMarginsSettings.hasOwnProperty('marginLeft')) { | 239 lastUsedMarginsSettings.hasOwnProperty('marginLeft')) { |
| 240 this.customMargins_ = new Margins(-1, -1, -1 , -1); | 240 this.customMargins_ = new Margins(-1, -1, -1 , -1); |
| 241 this.customMargins = lastUsedMarginsSettings; | 241 this.customMargins = lastUsedMarginsSettings; |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth; | 689 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth; |
| 690 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight; | 690 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight; |
| 691 } | 691 } |
| 692 }; | 692 }; |
| 693 | 693 |
| 694 return { | 694 return { |
| 695 MarginSettings: MarginSettings, | 695 MarginSettings: MarginSettings, |
| 696 PageLayout: PageLayout, | 696 PageLayout: PageLayout, |
| 697 }; | 697 }; |
| 698 }); | 698 }); |
| OLD | NEW |