Skip to content

Commit 0bbfbd4

Browse files
committed
Updated global plugin to latest version.
1 parent 90a5906 commit 0bbfbd4

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

external/jquery.global.js

+31-33
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
/*
2-
* Globalization
3-
* http://github.com/nje/jquery-glob
1+
/*!
2+
* jQuery Globalization Plugin
3+
* http://github.com/jquery/jquery-global
4+
*
5+
* Copyright Software Freedom Conservancy, Inc.
6+
* Dual licensed under the MIT or GPL Version 2 licenses.
7+
* http://jquery.org/license
48
*/
59
(function() {
610

7-
var Globalization = {},
8-
localized = { en: {} };
11+
var Globalization = {}, localized = { en: {} };
912
localized["default"] = localized.en;
1013

1114
Globalization.extend = function( deep ) {
@@ -106,10 +109,12 @@ Globalization.preferCulture = function(name) {
106109
this.culture = this.findClosestCulture( name ) || this.cultures["default"];
107110
}
108111
Globalization.localize = function(key, culture, value) {
109-
if (typeof culture === 'string') {
110-
culture = culture || "default";
111-
culture = this.cultures[ culture ] || { name: culture };
112+
// usign default culture in case culture is not provided
113+
if (typeof culture !== 'string') {
114+
culture = this.culture.name || this.culture || "default";
112115
}
116+
culture = this.cultures[ culture ] || { name: culture };
117+
113118
var local = localized[ culture.name ];
114119
if ( arguments.length === 3 ) {
115120
if ( !local) {
@@ -146,6 +151,9 @@ Globalization.format = function(value, format, culture) {
146151
Globalization.parseInt = function(value, radix, culture) {
147152
return Math.floor( this.parseFloat( value, radix, culture ) );
148153
}
154+
Globalization.parseCurrency = function(value, culture) {
155+
return this.parseFloat(value.replace(/[^\d,.-]/g, ""), 10, culture);
156+
}
149157
Globalization.parseFloat = function(value, radix, culture) {
150158
culture = this.findClosestCulture( culture );
151159
var ret = NaN,
@@ -297,7 +305,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
297305
// And the 'zh-SG' culture is Simplified Chinese in Singapore, whose lanugage
298306
// field is "zh-CHS", not "zh".
299307
// This field should be used to navigate from a specific culture to it's
300-
// more general, neutral culture. If a culture is already as general as it
308+
// more general, neutral culture. If a culture is already as general as it
301309
// can get, the language may refer to itself.
302310
language: "en",
303311
// numberFormat defines general number formatting rules, like the digits in
@@ -307,7 +315,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
307315
// Note, numberFormat.pattern has no 'positivePattern' unlike percent and currency,
308316
// but is still defined as an array for consistency with them.
309317
// negativePattern: one of "(n)|-n|- n|n-|n -"
310-
pattern: ["-n"],
318+
pattern: ["-n"],
311319
// number of decimal places normally shown
312320
decimals: 2,
313321
// string that separates number groups, as in 1,000,000
@@ -325,7 +333,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
325333
// [negativePattern, positivePattern]
326334
// negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %"
327335
// positivePattern: one of "n %|n%|%n|% n"
328-
pattern: ["-n %","n %"],
336+
pattern: ["-n %","n %"],
329337
// number of decimal places normally shown
330338
decimals: 2,
331339
// array of numbers indicating the size of each number group.
@@ -389,7 +397,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
389397
},
390398
// AM and PM designators in one of these forms:
391399
// The usual view, and the upper and lower case versions
392-
// [standard,lowercase,uppercase]
400+
// [standard,lowercase,uppercase]
393401
// The culture does not use AM or PM (likely all standard date formats use 24 hour time)
394402
// null
395403
AM: ["AM", "am", "AM"],
@@ -443,7 +451,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
443451
Given the date as a parameter, return an array with parts [year, month, day]
444452
corresponding to the non-gregorian based year, month, and day for the calendar.
445453
toGregorian(year, month, day)
446-
Given the non-gregorian year, month, and day, return a new Date() object
454+
Given the non-gregorian year, month, and day, return a new Date() object
447455
set to the corresponding date in the gregorian calendar.
448456
*/
449457
}
@@ -512,7 +520,7 @@ function expandNumber(number, precision, formatInfo) {
512520
rounded = number;
513521
}
514522
number = rounded;
515-
523+
516524
var numberString = number+"",
517525
right = "",
518526
split = numberString.split(/e/i),
@@ -521,7 +529,7 @@ function expandNumber(number, precision, formatInfo) {
521529
split = numberString.split( "." );
522530
numberString = split[ 0 ];
523531
right = split.length > 1 ? split[ 1 ] : "";
524-
532+
525533
var l;
526534
if ( exponent > 0 ) {
527535
right = zeroPad( right, exponent, false );
@@ -728,7 +736,7 @@ function getEraYear(date, cal, era, sortable) {
728736
// convert normal gregorian year to era-shifted gregorian
729737
// year by subtracting the era offset
730738
year -= cal.eras[ era ].offset;
731-
}
739+
}
732740
return year;
733741
}
734742

@@ -764,7 +772,7 @@ function getMonthIndex(cal, value, abbr) {
764772
if ( !upperMonths ) {
765773
cal._upperMonths = upperMonths = [
766774
toUpperArray( months.names ),
767-
toUpperArray( months.namesAbbr ),
775+
toUpperArray( months.namesAbbr )
768776
];
769777
cal._upperMonthsGen = upperMonthsGen = [
770778
toUpperArray( monthsGen.names ),
@@ -1153,7 +1161,7 @@ function formatDate(value, format, culture) {
11531161
}
11541162
return r;
11551163
}
1156-
1164+
11571165
function hasDay() {
11581166
if ( foundDay || checkedDay ) {
11591167
return foundDay;
@@ -1162,7 +1170,7 @@ function formatDate(value, format, culture) {
11621170
checkedDay = true;
11631171
return foundDay;
11641172
}
1165-
1173+
11661174
function getPart( date, part ) {
11671175
if ( converted ) {
11681176
return converted[ part ];
@@ -1197,7 +1205,7 @@ function formatDate(value, format, culture) {
11971205
ret.push( ar[ 0 ] );
11981206
continue;
11991207
}
1200-
1208+
12011209
var current = ar[ 0 ],
12021210
clength = current.length;
12031211

@@ -1284,7 +1292,7 @@ function formatDate(value, format, culture) {
12841292
// Milliseconds
12851293
ret.push( padZeros( value.getMilliseconds(), 3 ).substr( 0, clength ) );
12861294
break;
1287-
case "z":
1295+
case "z":
12881296
// Time zone offset, no leading zero
12891297
case "zz":
12901298
// Time zone offset with leading zero
@@ -1317,17 +1325,7 @@ function formatDate(value, format, culture) {
13171325
}
13181326

13191327
// EXPORTS
1320-
1321-
window.Globalization = Globalization;
1322-
1323-
//jQuery.findClosestCulture = Globalization.findClosestCulture;
1324-
//jQuery.culture = Globalization.culture;
1325-
//jQuery.cultures = Globalization.cultures
1326-
//jQuery.preferCulture = Globalization.preferCulture
1327-
//jQuery.localize = Globalization.localize
1328-
//jQuery.format = Globalization.format
1329-
//jQuery.parseInt = Globalization.parseInt
1330-
//jQuery.parseFloat = Globalization.parseFloat
1331-
//jQuery.parseDate = Globalization.parseDate
1328+
jQuery.global = Globalization;
13321329

13331330
})();
1331+

0 commit comments

Comments
 (0)