forked from lgalfaso/angular-dynamic-locale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmhDynamicLocale.min.js
8 lines (7 loc) · 3.04 KB
/
tmhDynamicLocale.min.js
1
2
3
4
5
6
7
8
/**
* Angular Dynamic Locale - 0.1.32
* https://github.com/lgalfaso/angular-dynamic-locale
* License: MIT
*/
!function(a,b){"function"==typeof define&&define.amd?define([],function(){return b()}):"object"==typeof exports?module.exports=b():b()}(this,function(){"use strict";return angular.module("tmh.dynamicLocale",[]).config(["$provide",function(a){function b(a){return a.$stateful=!0,a}a.decorator("dateFilter",["$delegate",b]),a.decorator("numberFilter",["$delegate",b]),a.decorator("currencyFilter",["$delegate",b])}]).constant("tmhDynamicLocale.STORAGE_KEY","tmhDynamicLocale.locale").provider("tmhDynamicLocale",["tmhDynamicLocale.STORAGE_KEY",function(a){function b(a,b,c,d){var f=document.createElement("script"),g=e?e:document.getElementsByTagName("body")[0],h=!1;f.type="text/javascript",f.readyState?f.onreadystatechange=function(){("complete"===f.readyState||"loaded"===f.readyState)&&(f.onreadystatechange=null,d(function(){h||(h=!0,g.removeChild(f),b())},30,!1))}:(f.onload=function(){h||(h=!0,g.removeChild(f),b())},f.onerror=function(){h||(h=!0,g.removeChild(f),c())}),f.src=a,f.async=!0,g.appendChild(f)}function c(a,c,d,e,h,i,l){function m(a,b){g===d&&(angular.forEach(a,function(c,d){b[d]?angular.isArray(b[d])&&(a[d].length=b[d].length):delete a[d]}),angular.forEach(b,function(c,d){angular.isArray(b[d])||angular.isObject(b[d])?(a[d]||(a[d]=angular.isArray(b[d])?[]:{}),m(a[d],b[d])):a[d]=b[d]}))}if(k[d])return g=d,k[d];var n,o=h.defer();return d===g?o.resolve(c):(n=i.get(d))?(g=d,e.$evalAsync(function(){m(c,n),f.put(j,d),e.$broadcast("$localeChangeSuccess",d,c),o.resolve(c)})):(g=d,k[d]=o.promise,b(a,function(){var a=angular.injector(["ngLocale"]),b=a.get("$locale");m(c,b),i.put(d,b),delete k[d],e.$applyAsync(function(){f.put(j,d),e.$broadcast("$localeChangeSuccess",d,c),o.resolve(c)})},function(){delete k[d],e.$applyAsync(function(){g===d&&(g=c.id),e.$broadcast("$localeChangeError",d),o.reject(d)})},l)),o.promise}var d,e,f,g,h="angular/i18n/angular-locale_{{locale}}.js",i="tmhDynamicLocaleStorageCache",j=a,k={},l={};this.localeLocationPattern=function(a){return a?(h=a,this):h},this.appendScriptTo=function(a){e=a},this.useStorage=function(a){i=a},this.useCookieStorage=function(){this.useStorage("$cookieStore")},this.defaultLocale=function(a){d=a},this.storageKey=function(a){return a?(j=a,this):j},this.addLocalePatternValue=function(a,b){l[a]=b},this.$get=["$rootScope","$injector","$interpolate","$locale","$q","tmhDynamicLocaleCache","$timeout",function(a,b,e,k,m,n,o){function p(b){var d={locale:b,angularVersion:angular.version.full};return c(q(angular.extend({},l,d)),k,b,a,m,n,o)}var q=e(h);return f=b.get(i),a.$evalAsync(function(){var a;(a=f.get(j)||d)&&p(a)}),{set:p,get:function(){return g}}}]}]).provider("tmhDynamicLocaleCache",function(){this.$get=["$cacheFactory",function(a){return a("tmh.dynamicLocales")}]}).provider("tmhDynamicLocaleStorageCache",function(){this.$get=["$cacheFactory",function(a){return a("tmh.dynamicLocales.store")}]}).run(["tmhDynamicLocale",angular.noop]),"tmh.dynamicLocale"});
//# sourceMappingURL=tmhDynamicLocale.min.js.map