This repository has been archived by the owner on Aug 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
angular-twig-pack.min.js
22 lines (22 loc) · 9.34 KB
/
angular-twig-pack.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var j=null,m=!1;
angular.module("twig.config",[]).value("twig.config",{macroCache:j,lowercase:function(a){return isString(a)?a.toLowerCase():a},toBoolean:function(a){a&&0!==a.length?(a=angular.isString(a)?(""+a).toLowerCase():a,a=!("f"==a||"0"==a||"false"==a||"no"==a||"n"==a||"[]"==a)):a=m;return a},random:function(a){return angular.isArray(a)||angular.isString(a)?a[Math.floor(Math.random()*a.length)]:angular.isNumber(a)?Math.floor(Math.random()*a):Math.floor(1E9*Math.random())},divisibleby:function(a,b){return angular.isNumber(a)&&
angular.isNumber(b)&&Math.floor(a/b)===a/b},even:function(a){return 0===a%2},odd:function(a){return 0!==a%2}});angular.module("twig.filters",["twig.config"]);angular.module("twig.directives",["twig.config"]).factory("twig",["twig.config",function(a){this.random=a.random;this.divisibleby=a.divisibleby;this.even=a.even;this.odd=a.odd;return this}]);angular.module("twig",["twig.filters","twig.directives","twig.config"]);
angular.isUndefined(Array.range)&&(Array.range=function(a,b,c){var e=[];if("number"===typeof a){e[0]=a;for(c=c||1;a+c<=b;)e[e.length]=a+=c}else c="abcdefghijklmnopqrstuvwxyz",a===a.toUpperCase()&&(b=b.toUpperCase(),c=c.toUpperCase()),c=c.substring(c.indexOf(a),c.indexOf(b)+1),e=c.split("");return e});String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});angular.module("twig.filters").filter("format",function(){return function(a,b){if(!a)return a;var c=a.toString(),e;if(void 0===b)return c;if(!angular.isArray(b)&&!angular.isObject(b))return c.split("$0").join(b);e=angular.isArray(b)&&"$"||":";angular.forEach(b,function(a,b){c=c.split(e+b).join(a)});return c}});angular.module("twig.filters").filter("url_encode",function(){return function(a){return!a?a:encodeURIComponent(a.toString())}});
angular.module("twig.filters").filter("json_decode",function(){return function(a){return!a?a:angular.fromJson(a.toString())}});angular.module("twig.filters").filter("title",function(){return function(a){return!a?a:a.toString().replace(/\w\S*/g,function(a){return a.charAt(0).toUpperCase()+a.substr(1).toLowerCase()})}});angular.module("twig.filters").filter("divisibleby",["twig.config",function(a){return function(b,c){return!b?b:a.b(b,c)}}]);
angular.module("twig.filters").filter("odd",["twig.config",function(a){return function(b){return!b?b:a.odd(b)}}]);angular.module("twig.filters").filter("even",["twig.config",function(a){return function(b){return!b?b:a.even(b)}}]);angular.module("twig.filters").filter("capitalize",function(){return function(a){if(!a)return a;a=a.toString().toLowerCase();return a.charAt(0).toUpperCase()+a.slice(1)}});angular.module("twig.filters").filter("upper",function(){return function(a){return!a?a:target=a.toString().toUpperCase()}});
angular.module("twig.filters").filter("lower",function(){return function(a){return!a?a:target=a.toString().toLowerCase()}});angular.module("twig.filters").filter("striptags",function(){return function(a,b){if(!a)return a;b=(((b||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join("");return a.replace(/\x3c!--[\s\S]*?--\x3e|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(a,e){return-1<b.indexOf("<"+e.toLowerCase()+">")?a:""})}});
angular.module("twig.filters").filter("join",function(){return function(a,b){return!a||!angular.isArray(a)?a:a.join(b||"")}});angular.module("twig.filters").filter("reverse",function(){return function(a){return!a?a:angular.isString(a)?a.split("").reverse().join(""):angular.isArray(a)?angular.copy(a).reverse():a}});angular.module("twig.filters").filter("length",function(){return function(a){return!a?0:angular.isString(a)?a.split("").length:angular.isArray(a)?a.length:0}});
angular.module("twig.filters").filter("sort",function(){return function(a){return!a||!angular.isArray(a)?a:angular.copy(a).sort()}});angular.module("twig.filters").filter("merge",function(){return function(a,b){if(!a||!b)return a;var c=angular.copy(a),e=angular.copy(b);return angular.isArray(a)&&angular.isArray(b)?c.concat(e):angular.isObject(a)&&angular.isObject(b)?angular.extend({},c,e):a}});
angular.module("twig.filters").filter("default",function(){return function(a,b){return!b?a:!a||""===a||a===j?b:a}});angular.module("twig.filters").filter("keys",function(){return function(a){if(!a||!angular.isArray(a)&&!angular.isObject(a))return[];a=angular.copy(a);var b=[],c;for(c in a)b.push(c);return b}});
angular.module("twig.filters").filter("escape",function(){return function(a,b){if(!a||!angular.isString(a))return a;angular.isUndefined(b)&&(b="html");switch(b){case "html":return a.replace(/[&<>"'`]/g,function(a){return"&#"+a.charCodeAt(0)+";"});case "js":return a.replace(/([\\"'])/g,"\\$1").replace(/\0/g,"\\0");case "url":return encodeURIComponent(a)}}});angular.module("twig.filters").filter("abs",function(){return function(a){return!a||!angular.isNumber(a)?a:Math.abs(a)}});
angular.module("twig.filters").filter("nl2br",function(){return function(a){return!a||!angular.isString(a)?a:a.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1<br />$2")}});
angular.module("twig.filters").filter("number_format",function(){return function(a,b,c,e){function d(a,b){var c=Math.pow(10,b);return""+Math.round(a*c)/c}if(!a)return a;a=(a+"").replace(/[^0-9+\-Ee.]/g,"");a=!isFinite(+a)?0:+a;b=!isFinite(+b)?0:Math.abs(b);e=angular.isUndefined(e)?",":e;c=angular.isUndefined(c)?".":c;var f="",f=(b?d(a,b):""+Math.round(a)).split(".");3<f[0].length&&(f[0]=f[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,e));if((f[1]||"").length<b)f[1]=f[1]||"",f[1]+=Array(b-f[1].length+1).join("0");
return f.join(c)}});angular.module("twig.filters").filter("slice",function(){return function(a,b,c){if(!angular.isString(a)&&!angular.isArray(a)||!angular.isNumber(b))return a;angular.isNumber(c)||(c=0);return a.slice(b,b+c)}});angular.module("twig.filters").filter("trim",function(){return function(a,b){if(!a)return a;var c=a.trim();return angular.isDefined(b)&&angular.isString(b)?c.replace(b,""):c}});angular.module("twig.directives").directive("for",["$compile","twig.config",function(a,b){return{scope:!0,a:"A",link:function(c,e,d){function f(d){c.items=[];angular.forEach(d,function(a){c[q]=a;var d=k?angular.isUndefined(c.$eval(k[2]))?eval(k[2]):c.$eval(k[2]):"";k&&b.toBoolean(d)===m||c.items.push(a)});angular.isUndefined(c.items)||angular.isArray(c.items)&&0===c.items.length?e.replaceWith(a(l.html(n))(c)):(l.attr("ng-repeat",q+" in items"),e.replaceWith(a(l)(c)))}var g=/([\w-'|]*)\.\.([\w-'|]*)/,
h="",n=angular.isDefined(d.forElse)?d.forElse:"No data",l=e.clone().removeAttr("for").removeAttr("for-else"),h=/(.*)\s*in\s*(.*)/.exec(d["for"]);if(h===j)throw Error("For attr no valid "+d["for"]);var q=h[1].trim(),k=/(.*) if (.*)/.exec(h[2]);d=j;k?(d=g.exec(k[1]),h[2]=k[2]):d=g.exec(h[2]);if(d){g=angular.isUndefined(c.$eval(d[1]))?d[1]:c.$eval(d[1]);h=angular.isUndefined(c.$eval(d[2]))?d[2]:c.$eval(d[2]);if(angular.isNumber(g)&&angular.isNumber(h)){if(g>h)throw Error("First number have to be lower than second number ("+
g+" <= "+h);}else if(angular.isString(g)&&angular.isString(h)){if(1!==g.length||1!==h.length)throw Error("First and second parameters have to be char and not string ("+g+", "+h);}else throw Error("Undefined values ("+g+", "+h);f(angular.copy(Array.range(g,h)))}else{var p=k?k[1]:h[2];c.$watch(p,function(a){f(angular.copy(a))});c.$watch(p+".length",function(a){0!==a&&f(angular.copy(c.$eval(p)))})}}}}]);
angular.module("twig.directives").directive("if",["twig.config",function(a){return{scope:!0,a:"A",link:function(b,c,e){function d(){var d=m;angular.forEach(l,function(c){if(d===m&&("_else_"===c.cdt||a.toBoolean(b.$eval(c.cdt))))d=c.html});d!==m&&c.html(d)}function f(a,b){return{cdt:a,html:b}}e=angular.isDefined(e["if"])?e["if"]:j;var g=c.clone().removeAttr("if"),h=g.find("else").first(),n=g.find("elseif"),l=[];g.find("elseif, else").remove();l.push(f(e,g.html()));n.each(function(){var a=$(this),b=
a.attr("on");l.push(f(b,a.html()))});l.push(f("_else_",h.html()));angular.forEach(l,function(a){b.$watch(a.cdt,d)})}}}]);
angular.module("twig.directives").directive("macroGet",["twig.config","$compile",function(a,b){return{scope:!0,a:"E",link:function(c,e,d){var f=angular.isDefined(d.name)?d.name:j,g=angular.isDefined(d.param)?d.param.split(","):j;if(!angular.isString(f)||!angular.isArray(g)||0===g.length)throw Error('The given expression is not valid "'+f+'" - "'+g+'". SYNTAX: macro name="nameMacro" param="\'param1\',\'param2\',paramFromScope".');angular.forEach(g,function(a,b){-1<a.indexOf("'")?g[b]=a.replace("'",
""):angular.isDefined(c[a])&&(g[b]=c.$eval(a))});d=a.macroCache.get(f);var h=c.$new();if(angular.isUndefined(d))return e.html(""),m;angular.forEach(d.param,function(a,b){angular.isDefined(g[b])&&(h[a]=g[b])});e.replaceWith(b(d.html)(h))}}}]);
angular.module("twig.directives").directive("macroSet",["twig.config","$cacheFactory",function(a,b){return{scope:!0,a:"E",d:!0,compile:function(){return{c:function(c,e,d){c=angular.isDefined(d.name)?d.name:j;d=angular.isDefined(d.param)?d.param.split(","):j;if(!angular.isString(c)||!angular.isArray(d)||0===d.length)throw Error('The given expression is not valid "'+c+'" - "'+d+'". SYNTAX: macro-set name="MacroName" param="paramName1,paramName2". ');if(angular.isUndefined(a.macroCache)||a.macroCache===
j)a.macroCache=b("twigMacros");var f=e.clone().removeAttr("macro-set");angular.isDefined(a.macroCache.get(c))&&console.error('The given macro name already exist! "'+c+'"');a.macroCache.put(c,{param:d,html:f.html()});e.css("display","none")}}}}}]);