META-INF.resources.bower_components.globalize.dist.globalize.min.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jwebmp-globalize Show documentation
Show all versions of jwebmp-globalize Show documentation
The JWebSwing implementation for a full Globalization
The newest version!
(function(root,factory){if(typeof define==="function"&&define.amd){define(["cldr","cldr/event"],factory)}else if(typeof exports==="object"){module.exports=factory(require("cldrjs"))}else{root.Globalize=factory(root.Cldr)}})(this,function(Cldr){var toString=function(variable){return typeof variable==="string"?variable:typeof variable==="number"?""+variable:JSON.stringify(variable)};var formatMessage=function(message,data){message=message.replace(/{[0-9a-zA-Z-_. ]+}/g,function(name){name=name.replace(/^{([^}]*)}$/,"$1");return toString(data[name])});return message};var objectExtend=function(){var destination=arguments[0],sources=[].slice.call(arguments,1);sources.forEach(function(source){var prop;for(prop in source){destination[prop]=source[prop]}});return destination};var createError=function(code,message,attributes){var error;message=code+(message?": "+formatMessage(message,attributes):"");error=new Error(message);error.code=code;objectExtend(error,attributes);return error};var stringHash=function(str){return[].reduce.call(str,function(hash,i){var chr=i.charCodeAt(0);hash=(hash<<5)-hash+chr;return hash|0},0)};var runtimeKey=function(fnName,locale,args,argsStr){var hash;argsStr=argsStr||JSON.stringify(args);hash=stringHash(fnName+locale+argsStr);return hash>0?"a"+hash:"b"+Math.abs(hash)};var functionName=function(fn){if(fn.name!==undefined){return fn.name}var matches=/^function\s+([\w\$]+)\s*\(/.exec(fn.toString());if(matches&&matches.length>0){return matches[1]}};var runtimeBind=function(args,cldr,fn,runtimeArgs){var argsStr=JSON.stringify(args),fnName=functionName(fn),locale=cldr.locale;if(!fnName){return fn}fn.runtimeKey=runtimeKey(fnName,locale,null,argsStr);fn.generatorString=function(){return'Globalize("'+locale+'").'+fnName+"("+argsStr.slice(1,-1)+")"};fn.runtimeArgs=runtimeArgs;return fn};var validate=function(code,message,check,attributes){if(!check){throw createError(code,message,attributes)}};var alwaysArray=function(stringOrArray){return Array.isArray(stringOrArray)?stringOrArray:stringOrArray?[stringOrArray]:[]};var validateCldr=function(path,value,options){var skipBoolean;options=options||{};skipBoolean=alwaysArray(options.skip).some(function(pathRe){return pathRe.test(path)});validate("E_MISSING_CLDR","Missing required CLDR content `{path}`.",value||skipBoolean,{path:path})};var validateDefaultLocale=function(value){validate("E_DEFAULT_LOCALE_NOT_DEFINED","Default locale has not been defined.",value!==undefined,{})};var validateParameterPresence=function(value,name){validate("E_MISSING_PARAMETER","Missing required parameter `{name}`.",value!==undefined,{name:name})};var validateParameterRange=function(value,name,minimum,maximum){validate("E_PAR_OUT_OF_RANGE","Parameter `{name}` has value `{value}` out of range [{minimum}, {maximum}].",value===undefined||value>=minimum&&value<=maximum,{maximum:maximum,minimum:minimum,name:name,value:value})};var validateParameterType=function(value,name,check,expected){validate("E_INVALID_PAR_TYPE","Invalid `{name}` parameter ({value}). {expected} expected.",check,{expected:expected,name:name,value:value})};var validateParameterTypeLocale=function(value,name){validateParameterType(value,name,value===undefined||typeof value==="string"||value instanceof Cldr,"String or Cldr instance")};var isPlainObject=function(obj){return obj!==null&&""+obj==="[object Object]"};var validateParameterTypePlainObject=function(value,name){validateParameterType(value,name,value===undefined||isPlainObject(value),"Plain Object")};var alwaysCldr=function(localeOrCldr){return localeOrCldr instanceof Cldr?localeOrCldr:new Cldr(localeOrCldr)};var regexpEscape=function(string){return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")};var stringPad=function(str,count,right){var length;if(typeof str!=="string"){str=String(str)}for(length=str.length;length