-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathjasmine-fixture.min.js
5 lines (5 loc) · 5.79 KB
/
jasmine-fixture.min.js
1
2
3
4
5
/* jasmine-fixture - 1.3.4
* Makes injecting HTML snippets into the DOM easy & clean!
* https://github.com/searls/jasmine-fixture
*/
(function(){var a,b=[].slice;!function(c){var d,e,f,g,h,i,j;return h=(1,eval)("this"),g=h.jasmineFixture,f=null!=(j=h.jasmine)?j.fixture:void 0,e=h.affix,i=function(a){return{inject:function(b,c){var d,e,f,g;for(g=[],e=0,f=a.length;f>e;e++)d=a[e],g.push(c=b(c,d));return g}}},h.jasmineFixture=function(b){var c,d,j,k,l,m;return d=function(a){return j.call(this,a,!0)},j=function(d,e){var f;return f=null,i(d.trim().split(/[ ](?![^\{]*\})(?=[^\]]*?(?:\[|$))/)).inject(function(c,d){var g;return">"===d?c:(g=a(b,d),(e||f)&&g.appendTo(c),f||(f=g),g)},c(this)),f},m=function(){var a,b;return a=jasmine.fixture,h.jasmineFixture=g,null!=(b=h.jasmine)&&(b.fixture=f),h.affix=e,a},c=function(a){return null!=(null!=a?a.jquery:void 0)?a:b("#jasmine_content").length>0?b("#jasmine_content"):b('<div id="jasmine_content"></div>').appendTo("body")},k=function(a){var c;return null!=(c=h.jasmine)&&(c.fixture=a),b.fn.affix=h.affix=a.affix,afterEach(function(){return b("#jasmine_content").remove()})},l={affix:d,create:j,noConflict:m},k(l),l},c?d=h.jasmineFixture(c):h.affix=function(){var a;if(a=window.jQuery||window.$,null!=a)return d=h.jasmineFixture(a),affix.call.apply(affix,[this].concat(b.call(arguments)));throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$")}}(window.jQuery||window.$),a=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;return a=function(j,k,l,n,o){var p,q,r,s,t,v,x,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O;if(j.isPlainObject(k)?p=k.main:(p=k,k={main:p}),J=p,void 0===o&&(o={}),"!"===p.charAt(0)||j.isArray(l)){for(j.isArray(l)?E=p:(I=g(p,"!"),I=I.substring(I.indexOf(":")+1,I.length-1),E=i(p));"@"===E.charAt(0);)E=i("!for:!"+h(E,k));O=k,O.main=E,B=j(),"!for:"===p.substring(0,5)||j.isArray(l)?(!j.isArray(l)&&I.indexOf(":")>0&&(F=I.substring(0,I.indexOf(":")),I=I.substr(I.indexOf(":")+1)),q=j.isArray(l)?l:l[I],N=O.main,(j.isArray(q)||j.isPlainObject(q))&&j.map(q,function(b,c){var d;return O.main=N,void 0!==F&&(o[F]=c),j.isPlainObject(b)||(b={value:b}),d=a(j,O,b,n,o),0!==B.length?j.each(d,function(a,b){return B.push(b)}):void 0}),p=j.isArray(l)?"":p.substr(I.length+6+E.length)):"!if:"===p.substring(0,4)&&(L=f("!"+I+"!",l,o),("undefined"!==L||"false"!==L||""!==L)&&(B=a(j,O,l,n,o)),p=p.substr(I.length+5+E.length)),k.main=p}else if("("===p.charAt(0))K=g(p,"(",")"),G=K.substring(1,K.length-1),p=p.substr(K.length),O=k,O.main=G,B=a(j,O,l,n,o);else{if(A=p.match(y),r=A[0],0===r.length)return"";if(r.indexOf("@")>=0)return p=h(p,k),O=k,O.main=p,a(j,O,l,n,o);r=f(r,l,o),t=e(j,r),u.test(r)&&(x=u.exec(r)[1]),s=d(r,l),z="{"===r.charAt(0)?"span":"div","#"!==p.charAt(0)&&"."!==p.charAt(0)&&"{"!==p.charAt(0)&&(z=w.exec(r)[1]),-1!==r.search(m)&&(v=r.match(m)[1]),s=j.extend(s,{id:x,"class":t,html:v}),B=j("<"+z+">",s),B.attr(s),B=c(r,B,n),B=b(r,B,l),p=p.substr(A[0].length),k.main=p}return p.length>0&&(">"===p.charAt(0)&&("("===p.charAt(1)?(N=g(p.substr(1),"(",")"),p=p.substr(N.length+1)):"!"===p.charAt(1)?(I=g(p.substr(1),"!"),E=i(p.substr(1)),N=I+E,p=p.substr(N.length+1)):(H=Math.max(p.indexOf("+"),p.length),N=p.substring(1,H),p=p.substr(H)),O=k,O.main=N,D=j(a(j,O,l,n,o)),D.appendTo(B)),"+"===p.charAt(0)&&(O=k,O.main=p.substr(1),C=a(j,O,l,n,o),j.each(C,function(a,b){return B.push(b)}))),M=B},b=function(a,b,c){var d,e,f;if(0===a.search(q))return b;if(d=a.match(q),null===d)return b;for(e=0;e<d.length;)f=p.exec(d[e]),void 0===f[3]?$(b).data(f[1],c[f[1]]):$(b).data(f[1],c[f[3]]),e++;return b},c=function(a,b,c){var d,e,f,g;if(0===a.search(s))return b;if(d=a.match(s),null===d)return b;for(f=0;f<d.length;)g=r.exec(d[f]),e=void 0===g[2]?c[g[1]]:c[g[2]],$(b).bind(g[1],e),f++;return b},d=function(a,b){var c,d,e,g;if(-1===a.search(k))return void 0;for(c=a.match(k),d={},e=0;e<c.length;)g=j.exec(c[e]),d[g[1]]="",void 0!==g[3]&&(d[g[1]]=f(g[3],b)),e++;return d},e=function(a,b){var c,d,e;if(b=b.match(x)[0],-1===b.search(o))return void 0;for(c=b.match(o),d="",e=0;e<c.length;)d+=" "+n.exec(c[e])[1],e++;return a.trim(d)},f=function(a,b,c){var d;if(void 0===c&&(c={}),d=a,void 0===b)return d;for(;t.test(d);)d=d.replace(t,function(a,d){var e,f,g;return e="",a.indexOf("!for:")>0||a.indexOf("!if:")>0?a:("!"!==a.charAt(0)&&(e=a.charAt(0),a=a.substring(2,a.length-1)),f=new Function("data","indexes","var r=undefined;with(data){try{r="+a+";}catch(e){}}with(indexes){try{if(r===undefined)r="+a+";}catch(e){}}return r;"),g=unescape(f(b,c)),e+g)});return d=d.replace(/\\./g,function(a){return a.charAt(1)}),unescape(d)},g=function(a,b,c,d){var e,f;if(void 0===c&&(c=b),e=1,void 0===d&&(d=a.charAt(0)===b?1:0),0!==d){for(;d>0&&e<a.length;)a.charAt(e)===c&&"\\"!==a.charAt(e-1)?d--:a.charAt(e)===b&&"\\"!==a.charAt(e-1)&&d++,e++;return f=a.substring(0,e)}},h=function(a,b){return a=a.replace(v,function(a){var c;return a=a.substr(1),(c=new Function("objs",'var r="";with(objs){try{r='+a+";}catch(e){}}return r;"))(b,h)})},i=function(a){var b,c,d;return"!for:"!==a.substring(0,5)&&"!if:"!==a.substring(0,4)?void 0:(b=g(a,"!"),a=a.substr(b.length),"("===a.charAt(0)?g(a,"(",")"):(d=a.match(y)[0],a=a.substr(d.length),0===a.length||"+"===a.charAt(0)?d:">"===a.charAt(0)?(c="",c=g(a.substr(1),"(",")",1),d+">"+c):void 0))},y=/([#\.\@]?[\w-]+|\[([\w-!?=:"']+(="([^"]|\\")+")? {0,})+\]|\~[\w$]+=[\w$]+|&[\w$]+(=[\w$]+)?|[#\.\@]?!([^!]|\\!)+!){0,}(\{([^\}]|\\\})+\})?/i,w=/(\w+)/i,u=/(?:^|\b)#([\w-!]+)/i,x=/((([#\.]?[\w-]+)?(\[([\w!]+(="([^"]|\\")+")? {0,})+\])?)+)/i,o=/(\.[\w-]+)(?!["\w])/g,n=/\.([\w-]+)/i,v=/(@[\w$_][\w$_\d]+)/i,k=/(\[([\w-!]+(="?([^"]|\\")+"?)? {0,})+\])/gi,l=/([\w-!]+(="([^"]|\\")+")?)/g,j=/([\w-!]+)(="?((([\w]+(\[.*?\])+)|[^"\]]|\\")+)"?)?/i,m=/\{(([^\}]|\\\})+)\}/i,t=/(?:([^\\]|^))!([^!]|\\!)+!/g,s=/\~[\w$]+(=[\w$]+)?/g,r=/\~([\w$]+)=([\w$]+)/i,q=/&[\w$]+(=[\w$]+)?/g,p=/&([\w$]+)(=([\w$]+))?/i,a}()}).call(this);