Skip to content

Instantly share code, notes, and snippets.

@ggkrustev
Created January 7, 2016 15:06
Show Gist options
  • Save ggkrustev/52bf4558ecd1794e5d94 to your computer and use it in GitHub Desktop.
Save ggkrustev/52bf4558ecd1794e5d94 to your computer and use it in GitHub Desktop.
(function($) {
var kendo = window.kendo;
var globalize = window.Globalize;
function expandNumberFormat(numberFormat) {
numberFormat.groupSizes = numberFormat.groupSize;
numberFormat.percent.groupSizes = numberFormat.percent.groupSize;
numberFormat.currency.groupSizes = numberFormat.currency.groupSize;
}
kendo.culture = function (cultureName) {
var cultures = kendo.cultures, culture;
if (cultureName !== undefined) {
culture = kendo.findCulture(cultureName) || cultures[EN];
culture.calendar = culture.calendars.standard;
cultures.current = culture;
if (globalize && !globalize.load) {
expandNumberFormat(culture.numberFormat);
}
} else {
return cultures.current;
}
};
if (globalize && !globalize.load) {
kendo.toString = function (value, format, culture) {
if ($.isPlainObject(culture)) {
culture = culture.name;
}
return globalize.format(value, format, culture);
};
}
if (globalize && !globalize.load) {
kendo.parseDate = function (value, format, culture) {
if (objectToString.call(value) === '[object Date]') {
return value;
}
return globalize.parseDate(value, format, culture);
};
kendo.parseFloat = function (value, culture) {
if (typeof value === NUMBER) {
return value;
}
if (value === undefined || value === null) {
return null;
}
if ($.isPlainObject(culture)) {
culture = culture.name;
}
value = globalize.parseFloat(value, culture);
return isNaN(value) ? null : value;
};
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment