aboutsummaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2011-01-17 19:26:59 +0100
committerjzaefferer <joern.zaefferer@gmail.com>2011-01-17 19:26:59 +0100
commit0bbfbd431c8701adb8ed8caf439eaa73216628e0 (patch)
treeb7df59a3952adf354dcedcfb975ff9fd57ddbea2 /external
parent90a5906af538b57fc3f69c0b84c2e11d5b742c6e (diff)
downloadjquery-ui-0bbfbd431c8701adb8ed8caf439eaa73216628e0.tar.gz
jquery-ui-0bbfbd431c8701adb8ed8caf439eaa73216628e0.zip
Updated global plugin to latest version.
Diffstat (limited to 'external')
-rw-r--r--external/jquery.global.js64
1 files changed, 31 insertions, 33 deletions
diff --git a/external/jquery.global.js b/external/jquery.global.js
index 8075ee2bd..fcaacf9c7 100644
--- a/external/jquery.global.js
+++ b/external/jquery.global.js
@@ -1,11 +1,14 @@
-/*
- * Globalization
- * http://github.com/nje/jquery-glob
+/*!
+ * jQuery Globalization Plugin
+ * http://github.com/jquery/jquery-global
+ *
+ * Copyright Software Freedom Conservancy, Inc.
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
*/
(function() {
-var Globalization = {},
- localized = { en: {} };
+var Globalization = {}, localized = { en: {} };
localized["default"] = localized.en;
Globalization.extend = function( deep ) {
@@ -106,10 +109,12 @@ Globalization.preferCulture = function(name) {
this.culture = this.findClosestCulture( name ) || this.cultures["default"];
}
Globalization.localize = function(key, culture, value) {
- if (typeof culture === 'string') {
- culture = culture || "default";
- culture = this.cultures[ culture ] || { name: culture };
+ // usign default culture in case culture is not provided
+ if (typeof culture !== 'string') {
+ culture = this.culture.name || this.culture || "default";
}
+ culture = this.cultures[ culture ] || { name: culture };
+
var local = localized[ culture.name ];
if ( arguments.length === 3 ) {
if ( !local) {
@@ -146,6 +151,9 @@ Globalization.format = function(value, format, culture) {
Globalization.parseInt = function(value, radix, culture) {
return Math.floor( this.parseFloat( value, radix, culture ) );
}
+Globalization.parseCurrency = function(value, culture) {
+ return this.parseFloat(value.replace(/[^\d,.-]/g, ""), 10, culture);
+}
Globalization.parseFloat = function(value, radix, culture) {
culture = this.findClosestCulture( culture );
var ret = NaN,
@@ -297,7 +305,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
// And the 'zh-SG' culture is Simplified Chinese in Singapore, whose lanugage
// field is "zh-CHS", not "zh".
// This field should be used to navigate from a specific culture to it's
- // more general, neutral culture. If a culture is already as general as it
+ // more general, neutral culture. If a culture is already as general as it
// can get, the language may refer to itself.
language: "en",
// numberFormat defines general number formatting rules, like the digits in
@@ -307,7 +315,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
// Note, numberFormat.pattern has no 'positivePattern' unlike percent and currency,
// but is still defined as an array for consistency with them.
// negativePattern: one of "(n)|-n|- n|n-|n -"
- pattern: ["-n"],
+ pattern: ["-n"],
// number of decimal places normally shown
decimals: 2,
// string that separates number groups, as in 1,000,000
@@ -325,7 +333,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
// [negativePattern, positivePattern]
// negativePattern: one of "-n %|-n%|-%n|%-n|%n-|n-%|n%-|-% n|n %-|% n-|% -n|n- %"
// positivePattern: one of "n %|n%|%n|% n"
- pattern: ["-n %","n %"],
+ pattern: ["-n %","n %"],
// number of decimal places normally shown
decimals: 2,
// array of numbers indicating the size of each number group.
@@ -389,7 +397,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
},
// AM and PM designators in one of these forms:
// The usual view, and the upper and lower case versions
- // [standard,lowercase,uppercase]
+ // [standard,lowercase,uppercase]
// The culture does not use AM or PM (likely all standard date formats use 24 hour time)
// null
AM: ["AM", "am", "AM"],
@@ -443,7 +451,7 @@ var en = cultures["default"] = cultures.en = Globalization.extend(true, {
Given the date as a parameter, return an array with parts [year, month, day]
corresponding to the non-gregorian based year, month, and day for the calendar.
toGregorian(year, month, day)
- Given the non-gregorian year, month, and day, return a new Date() object
+ Given the non-gregorian year, month, and day, return a new Date() object
set to the corresponding date in the gregorian calendar.
*/
}
@@ -512,7 +520,7 @@ function expandNumber(number, precision, formatInfo) {
rounded = number;
}
number = rounded;
-
+
var numberString = number+"",
right = "",
split = numberString.split(/e/i),
@@ -521,7 +529,7 @@ function expandNumber(number, precision, formatInfo) {
split = numberString.split( "." );
numberString = split[ 0 ];
right = split.length > 1 ? split[ 1 ] : "";
-
+
var l;
if ( exponent > 0 ) {
right = zeroPad( right, exponent, false );
@@ -728,7 +736,7 @@ function getEraYear(date, cal, era, sortable) {
// convert normal gregorian year to era-shifted gregorian
// year by subtracting the era offset
year -= cal.eras[ era ].offset;
- }
+ }
return year;
}
@@ -764,7 +772,7 @@ function getMonthIndex(cal, value, abbr) {
if ( !upperMonths ) {
cal._upperMonths = upperMonths = [
toUpperArray( months.names ),
- toUpperArray( months.namesAbbr ),
+ toUpperArray( months.namesAbbr )
];
cal._upperMonthsGen = upperMonthsGen = [
toUpperArray( monthsGen.names ),
@@ -1153,7 +1161,7 @@ function formatDate(value, format, culture) {
}
return r;
}
-
+
function hasDay() {
if ( foundDay || checkedDay ) {
return foundDay;
@@ -1162,7 +1170,7 @@ function formatDate(value, format, culture) {
checkedDay = true;
return foundDay;
}
-
+
function getPart( date, part ) {
if ( converted ) {
return converted[ part ];
@@ -1197,7 +1205,7 @@ function formatDate(value, format, culture) {
ret.push( ar[ 0 ] );
continue;
}
-
+
var current = ar[ 0 ],
clength = current.length;
@@ -1284,7 +1292,7 @@ function formatDate(value, format, culture) {
// Milliseconds
ret.push( padZeros( value.getMilliseconds(), 3 ).substr( 0, clength ) );
break;
- case "z":
+ case "z":
// Time zone offset, no leading zero
case "zz":
// Time zone offset with leading zero
@@ -1317,17 +1325,7 @@ function formatDate(value, format, culture) {
}
// EXPORTS
-
-window.Globalization = Globalization;
-
-//jQuery.findClosestCulture = Globalization.findClosestCulture;
-//jQuery.culture = Globalization.culture;
-//jQuery.cultures = Globalization.cultures
-//jQuery.preferCulture = Globalization.preferCulture
-//jQuery.localize = Globalization.localize
-//jQuery.format = Globalization.format
-//jQuery.parseInt = Globalization.parseInt
-//jQuery.parseFloat = Globalization.parseFloat
-//jQuery.parseDate = Globalization.parseDate
+jQuery.global = Globalization;
})();
+