Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(831)

Side by Side Diff: chrome/browser/resources/print_preview/margin_settings.js

Issue 8922021: Print Preview: Fixing parsing of numberFormat for several locales. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing parsing of numberFormat Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 the sample number
171 * sent from the backend. 171 * 12345678 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 regex = /^(123)(\W{0,1})(456)(\W{0,1})(78)$/;
179 var matches = numberFormat.match(regex); 179 var matches = numberFormat.match(regex) || ['','','.','',','];
dpapad 2011/12/12 23:58:06 The fix has 2 parts. 1) Changing the regex to all
Lei Zhang 2011/12/13 00:16:02 Isn't this reversed? ',' for thousands and '.' for
dpapad1 2011/12/13 01:01:19 Well, I am not sure what the fallback should be. I
dpapad1 2011/12/13 01:11:32 Done.
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;
183 }; 183 };
184 184
185 cr.addSingletonGetter(MarginSettings); 185 cr.addSingletonGetter(MarginSettings);
186 186
187 MarginSettings.prototype = { 187 MarginSettings.prototype = {
188 /** 188 /**
189 * Returns a dictionary of the four custom margin values. 189 * Returns a dictionary of the four custom margin values.
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth; 705 this.pageWidth_ = this.currentDefaultPageLayout.pageWidth;
706 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight; 706 this.pageHeight_ = this.currentDefaultPageLayout.pageHeight;
707 } 707 }
708 }; 708 };
709 709
710 return { 710 return {
711 MarginSettings: MarginSettings, 711 MarginSettings: MarginSettings,
712 PageLayout: PageLayout, 712 PageLayout: PageLayout,
713 }; 713 };
714 }); 714 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698