Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Throw an error when trying to loop the template root. Allow BODY as a…

… root.
  • Loading branch information...
commit 0cece996c66b687ca367757eac0c85ff7165d060 1 parent 1ab2cb2
@pure authored
Showing with 32 additions and 25 deletions.
  1. +7 −1 libs/pure.js
  2. +25 −24 libs/pure_min.js
View
8 libs/pure.js
@@ -7,7 +7,7 @@
Copyright (c) 2012 Michael Cvilic - BeeBole.com
Thanks to Rog Peppe for the functional JS jump
- revision: 2.75
+ revision: 2.76
*/
var $p, pure = $p = function(){
@@ -333,6 +333,8 @@ $p.core = function(sel, ctxt, plugins){
//replace node with s
pn.insertBefore(document.createTextNode(s), node.nextSibling);
pn.removeChild(node);
+ }else{
+ error('The template root, can\'t be looped.');
}
};
} else {
@@ -650,6 +652,10 @@ $p.core = function(sel, ctxt, plugins){
ep.appendChild(elm);
}
switch (elm.tagName) {
+ case 'BODY':
+ ep.removeChild(elm);
+ ep.innerHTML += html;
+ return ep.getElementsByTagName('BODY')[0];
case 'TBODY': case 'THEAD': case 'TFOOT':
html = '<TABLE>' + html + '</TABLE>';
depth = 1;
View
49 libs/pure_min.js
@@ -7,28 +7,29 @@
Copyright (c) 2012 Michael Cvilic - BeeBole.com
Thanks to Rog Peppe for the functional JS jump
- revision: 2.75
+ revision: 2.76
*/
-var $p,pure=$p=function(b,c){var f=b,k=!1;"string"===typeof f?k=c||!1:f&&(!f[0]&&!f.length)&&(f=[f]);return $p.core(f,k)};
-$p.core=function(b,c,f){function k(a){if("undefined"!==typeof console){console.log(a);debugger}throw"pure error: "+a;}function K(){var a=$p.plugins,d=function(){};d.prototype=a;d.prototype.compile=a.compile||L;d.prototype.render=a.render||M;d.prototype.autoRender=a.autoRender||N;d.prototype.find=a.find||O;d.prototype._compiler=x;d.prototype._error=k;return new d}function C(a){var d;if(!(d=a.outerHTML))d=document.createElement("div"),d.appendChild(a.cloneNode(!0)),d=d.innerHTML;return d}function y(a,
-d){return function(b){return a(""+d.call(b.item||b.context,b))}}function O(a,d){"string"===typeof a&&(d=a,a=!1);return"undefined"!==typeof document.querySelectorAll?(a||document).querySelectorAll(d):k("You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine")}function D(a,d){return function(b){var e=[a[0]],c=a.length,g,j,i,h;try{for(var m=1;m<c;m++){g=d[m].call(this,b);j=a[m];if(""===g&&(i=e[e.length-
-1],-1<(h=i.search(/[^\s]+=\"?$/))))e[e.length-1]=i.substring(0,h),j=j.substr(1);e[e.length]=g;e[e.length]=j}return e.join("")}catch(f){return console&&console.log&&console.log(f.stack?f.stack:f.message+" ("+f.type+", "+f.arguments.join("-")+"). Use Firefox or Chromium/Chrome to get a full stack of the error. "),""}}}function Q(a){var d=a.match(/^(\w+)\s*<-\s*(\S+)?$/);null===d&&k('bad loop spec: "'+a+'"');"item"===d[1]&&k('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
-!d[2]||"context"===d[2].toLowerCase()?d[2]=function(a){return a.context}:d[2]&&0===d[2].indexOf("context")&&(d[2]=v(d[2].replace(/^context\.?/,"")));return{name:d[1],sel:d[2]}}function v(a){if("function"===typeof a)return function(d){d=a.call(d.item||d.context||d,d);return!d&&0!==d?"":d};var d=a.match(/^[\da-zA-Z\$_\@][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);if(null===d){var b=!1,e=a,c=[],g=[],j=0,i;if(/\'|\"/.test(e.charAt(0))){if(/\'|\"/.test(e.charAt(e.length-1)))return i=e.substring(1,e.length-1),function(){return i}}else for(;null!==
-(d=e.match(/#\{([^{}]+)\}/));)b=!0,c[j++]=e.slice(0,d.index),g[j]=v(d[1]),e=e.slice(d.index+d[0].length,e.length);if(!b)return function(){return a};c[j]=e;return D(c,g)}d=a.split(".");return function(a){var b=a.context||a,e=a[d[0]],a=0;if(e&&"undefined"!==typeof e.item){a+=1;if("pos"===d[a])return e.pos;b=e.item}for(var e=d.length,c;a<e&&b;a++)c=b[d[a]],b="function"===typeof c?b[d[a]].call(b):c;return!b&&0!==b?"":b}}function z(a,d,b){var e,c,g,j,i,h=[];if("string"===typeof d){if(e=d,(i=d.match(E))||
-k("bad selector syntax: "+d),c=i[1],g=i[2],j=i[3],i=i[4],"."===g||!g&&j?h[0]=a:h=f.find(a,g),!h||0===h.length)return k('The node "'+d+'" was not found in the template:\n'+C(a).replace(/\t/g," "))}else c=d.prepend,j=d.attr,i=d.append,h=[a];if(c||i)c&&i?k("append/prepend cannot take place at the same time"):b?k("no append/prepend/replace modifiers allowed for loop target"):i&&b&&k("cannot append with loop (sel: "+e+")");var m,n,w,o,p;j?(w=/^style$/i.test(j),p=(o=/^class$/i.test(j))?"className":j,m=
-function(a,d){a.setAttribute(F+j,d);if(p in a&&!w)try{a[p]=""}catch(b){}1===a.nodeType&&(a.removeAttribute(j),o&&a.removeAttribute(p))},n=w||o?w?function(a){return a.style.cssText}:function(a){return a.className}:function(a){return a.getAttribute(j)},a=function(a){return a.replace(/\"/g,"&quot;")},c=c?function(a,d){m(a,d+n(a))}:i?function(a,d){m(a,n(a)+d)}:function(a,d){m(a,d)}):(c=b?function(a,d){var b=a.parentNode;b&&(b.insertBefore(document.createTextNode(d),a.nextSibling),b.removeChild(a))}:c?
-function(a,d){a.insertBefore(document.createTextNode(d),a.firstChild)}:i?function(a,d){a.appendChild(document.createTextNode(d))}:function(a,d){for(;a.firstChild;)a.removeChild(a.firstChild);a.appendChild(document.createTextNode(d))},a=function(a){return a});return{attr:j,nodes:h,set:c,sel:e,quotefn:a}}function A(a,d){for(var b=G+d+":",e=0;e<a.nodes.length;e++)a.set(a.nodes[e],b)}function H(a,d,b,e,c){return function(g){var j=d(g),i=g[a],h={items:j},f=0,n,w=[],o=function(a,d,e,c){var h=g.pos,i=g.item,
-P=g.items;g.pos=d.pos=a;g.item=d.item=j[a];g.items=j;"undefined"!==typeof c&&(g.length=c);"function"===typeof e&&!1===e.call(g.item,g)?f++:(w.push(b.call(g.item,g)),g.pos=h,g.item=i,g.items=P)};g[a]=h;if(B(j)){n=j.length||0;"function"===typeof e&&j.sort(e);for(var p=0;p<n;p++)o(p,h,c,n-f)}else for(n in j&&"undefined"!==typeof e&&k("sort is only available on arrays, not objects"),j)j.hasOwnProperty(n)&&o(n,h,c);"undefined"!==typeof i?g[a]=i:delete g[a];return w.join("")}}function I(a,d,b,e){var c=
-!1,g,f,i,h;for(h in b)b.hasOwnProperty(h)&&("sort"===h?f=b.sort:"filter"===h?i=b.filter:(c&&k("cannot have more than one loop on a target"),g=h,c=!0));g||k("Error in the selector: "+d+"\nA directive action must be a string, a function or a loop(<-)");c=b[g];if("string"===typeof c||"function"===typeof c)return b={},b[g]={root:c},I(a,d,b,e);b=Q(g);g=v(b.sel);a=z(a,d,!0);d=a.nodes;for(r=0;r<d.length;r++){h=d[r];var m=x(h,c);e[e.length]=y(a.quotefn,H(b.name,g,m,f,i));a.nodes=[h];A(a,e.length-1)}return a}
-function x(a,d,b,c){var f=[],g,j,i,h,m,n,k,o,p,r=[];if(!(h=c))if(h=b){h=a.getElementsByTagName("*");c=[];i=[];n={};var l,s,t;g=-1;for(j=h.length;g<j;g++)if(o=-1<g?h[g]:a,1===o.nodeType&&""!==o.className){t=o.className.split(" ");m=0;for(k=t.length;m<k;m++){l=t[m];a:{s=o.tagName;var u=l.match(E);l={prepend:!!u[1],prop:u[2],attr:u[3]||R[s],append:!!u[4],sel:l};var q=u=s=void 0,q=void 0;for(s=i.length-1;0<=s;s--)if(u=i[s],q=(q=u.l[0])&&q[l.prop],"undefined"!==typeof q){l.prop=u.p+"."+l.prop;!0===n[l.prop]&&
-(q=q[0]);break}if("undefined"===typeof q&&(q=v(l.prop)(B(b)?b[0]:b),""===q)){l=!1;break a}B(q)?(i.push({l:q,p:l.prop}),n[l.prop]=!0,l.t="loop"):l.t="str"}if(!1!==l){s=/nodevalue/i.test(l.attr);if(-1<l.sel.indexOf("@")||s)o.className=o.className.replace("@"+l.attr,""),s&&(l.attr=!1);c.push({n:o,cspec:l})}}}h=c}c=h;if(b)for(;0<c.length;)if(i=c[0].cspec,h=c[0].n,c.splice(0,1),"str"===i.t)h=z(h,i,!1),A(h,f.length),f[f.length]=y(h.quotefn,v(i.prop));else{n=v(i.sel);h=z(h,i,!0);m=h.nodes;g=0;for(j=m.length;g<
-j;g++)k=m[g],o=x(k,!1,b,c),f[f.length]=y(h.quotefn,H(i.sel,n,o)),h.nodes=[k],A(h,f.length-1)}for(p in d)if(d.hasOwnProperty(p)){b=0;c=d[p];i=p.split(/\s*,\s*/);n=i.length;do"function"===typeof c||"string"===typeof c?(p=i[b],h=z(a,p,!1),A(h,f.length),f[f.length]=y(h.quotefn,v(c))):I(a,p,c,f);while(++b<n)}a=C(a);a=a.replace(/<([^>]+)\s(value\=""|selected)\s?([^>]*)>/ig,"<$1 $3>");a=a.split(F).join("");a=a.split(G);for(b=1;b<a.length;b++)d=a[b],r[b]=f[parseInt(d,10)],a[b]=d.substring(d.indexOf(":")+
-1);return D(a,r)}function L(a,b,c){var e=x((c||this[0]).cloneNode(!0),a,b);return function(a){return e({context:a})}}function M(a,b){for(var c="function"===typeof b&&b,e=0,k=this.length;e<k;e++)this[e]=J(this[e],(c||f.compile(b,!1,this[e]))(a,!1));context=null;return this}function N(a,b){for(var c=f.compile(b,a,this[0]),e=0,k=this.length;e<k;e++)this[e]=J(this[e],c(a,!1));context=null;return this}function J(a,b){var c,e=a.parentNode,f=0;e||(e=document.createElement("DIV"),e.appendChild(a));switch(a.tagName){case "TBODY":case "THEAD":case "TFOOT":b=
-"<TABLE>"+b+"</TABLE>";f=1;break;case "TR":b="<TABLE><TBODY>"+b+"</TBODY></TABLE>";f=2;break;case "TD":case "TH":b="<TABLE><TBODY><TR>"+b+"</TR></TBODY></TABLE>",f=3}tmp=document.createElement("SPAN");tmp.style.display="none";document.body.appendChild(tmp);tmp.innerHTML=b;for(c=tmp.firstChild;f--;)c=c.firstChild;e.insertBefore(c,a);e.removeChild(a);document.body.removeChild(tmp);return c}var t=[],f=f||K();switch(typeof b){case "string":t=f.find(c||document,b);0===t.length&&k('The template "'+b+'" was not found');
-break;case "undefined":k("The root of the template is undefined, check your selector");break;default:t=b}for(var r=0,b=t.length;r<b;r++)f[r]=t[r];f.length=b;var G="_s"+Math.floor(1E6*Math.random())+"_",F="_a"+Math.floor(1E6*Math.random())+"_",E=/^(\+)?([^\@\+]+)?\@?([^\+]+)?(\+)?$/,R={IMG:"src",INPUT:"value"},B=Array.isArray?function(a){return Array.isArray(a)}:function(a){return"[object Array]"===Object.prototype.toString.call(a)};return f};$p.plugins={};
-$p.libs={dojo:function(){"undefined"===typeof document.querySelector&&($p.plugins.find=function(b,c){return dojo.query(c,b)})},domassistant:function(){"undefined"===typeof document.querySelector&&($p.plugins.find=function(b,c){return $(b).cssSelect(c)});DOMAssistant.attach({publicMethods:["compile","render","autoRender"],compile:function(b,c){return $p([this]).compile(b,c)},render:function(b,c){return $($p([this]).render(b,c))[0]},autoRender:function(b,c){return $($p([this]).autoRender(b,c))[0]}})},
-jquery:function(){"undefined"===typeof document.querySelector&&($p.plugins.find=function(b,c){return jQuery(b).find(c)});jQuery.fn.extend({directives:function(b){this._pure_d=b;return this},compile:function(b,c){return $p(this).compile(this._pure_d||b,c)},render:function(b,c){return jQuery($p(this).render(b,this._pure_d||c))},autoRender:function(b,c){return jQuery($p(this).autoRender(b,this._pure_d||c))}})},mootools:function(){"undefined"===typeof document.querySelector&&($p.plugins.find=function(b,
-c){return $(b).getElements(c)});Element.implement({compile:function(b,c){return $p(this).compile(b,c)},render:function(b,c){return $p([this]).render(b,c)},autoRender:function(b,c){return $p([this]).autoRender(b,c)}})},prototype:function(){"undefined"===typeof document.querySelector&&($p.plugins.find=function(b,c){b=b===document?b.body:b;return"string"===typeof b?$$(b):$(b).select(c)});Element.addMethods({compile:function(b,c,f){return $p([b]).compile(c,f)},render:function(b,c,f){return $p([b]).render(c,
-f)},autoRender:function(b,c,f){return $p([b]).autoRender(c,f)}})},sizzle:function(){"undefined"===typeof document.querySelector&&($p.plugins.find=function(b,c){return Sizzle(c,b)})},sly:function(){"undefined"===typeof document.querySelector&&($p.plugins.find=function(b,c){return Sly(c,b)})},yui:function(){"undefined"===typeof document.querySelector&&YUI().use("node",function(b){$p.plugins.find=function(c,f){return b.NodeList.getDOMNodes(b.one(c).all(f))}});YUI.add("pure-yui",function(b){b.Node.prototype.directives=
-function(b){this._pure_d=b;return this};b.Node.prototype.compile=function(b,f){return $p([this._node]).compile(this._pure_d||b,f)};b.Node.prototype.render=function(c,f){return b.one($p([this._node]).render(c,this._pure_d||f))};b.Node.prototype.autoRender=function(c,f){return b.one($p([this._node]).autoRender(c,this._pure_d||f))}},"0.1",{requires:["node"]})}};
-(function(){var b="undefined"!==typeof dojo&&"dojo"||"undefined"!==typeof DOMAssistant&&"domassistant"||"undefined"!==typeof jQuery&&"jquery"||"undefined"!==typeof MooTools&&"mootools"||"undefined"!==typeof Prototype&&"prototype"||"undefined"!==typeof Sizzle&&"sizzle"||"undefined"!==typeof Sly&&"sly"||"undefined"!==typeof YUI&&"yui";b&&$p.libs[b]();"undefined"!==typeof exports&&(exports.$p=$p)})();
+var $p,pure=$p=function(d,h){var n=d,s=false;if(typeof n==="string")s=h||false;else if(n&&!n[0]&&!n.length)n=[n];return $p.core(n,s)};
+$p.core=function(d,h,n){function s(a){if(typeof console!=="undefined"){console.log(a);debugger}throw"pure error: "+a;}function O(){var a=$p.plugins,b=function(){};b.prototype=a;b.prototype.compile=a.compile||P;b.prototype.render=a.render||Q;b.prototype.autoRender=a.autoRender||R;b.prototype.find=a.find||S;b.prototype._compiler=B;b.prototype._error=s;return new b}function G(a){return a.outerHTML||function(b){var f=document.createElement("div");f.appendChild(b.cloneNode(true));return f.innerHTML}(a)}
+function C(a,b){return function(f){return a(""+b.call(f.item||f.context,f))}}function S(a,b){if(typeof a==="string"){b=a;a=false}return typeof document.querySelectorAll!=="undefined"?(a||document).querySelectorAll(b):s("You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine")}function H(a,b){return function(f){var c=[a[0]],g=a.length,i,k,l,e;try{for(var o=1;o<g;o++){i=b[o].call(this,f);k=a[o];
+if(i===""){l=c[c.length-1];if((e=l.search(/[^\s]+=\"?$/))>-1){c[c.length-1]=l.substring(0,e);k=k.substr(1)}}c[c.length]=i;c[c.length]=k}return c.join("")}catch(m){if(console&&console.log)console.log(m.stack?m.stack:m.message+" ("+m.type+", "+m.arguments.join("-")+"). Use Firefox or Chromium/Chrome to get a full stack of the error. ");return""}}}function T(a){var b=a.match(/^(\w+)\s*<-\s*(\S+)?$/);b===null&&s('bad loop spec: "'+a+'"');b[1]==="item"&&s('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
+if(!b[2]||b[2].toLowerCase()==="context")b[2]=function(f){return f.context};else if(b[2]&&b[2].indexOf("context")===0)b[2]=x(b[2].replace(/^context\.?/,""));return{name:b[1],sel:b[2]}}function x(a){if(typeof a==="function")return function(e){e=a.call(e.item||e.context||e,e);return!e&&e!==0?"":e};var b=a.match(/^[\da-zA-Z\$_\@][\w\$:-]*(\.[\w\$:-]*[^\.])*$/);if(b===null){var f=false,c=a,g=[],i=[],k=0,l;if(/\'|\"/.test(c.charAt(0))){if(/\'|\"/.test(c.charAt(c.length-1))){l=c.substring(1,c.length-1);
+return function(){return l}}}else for(;(b=c.match(/#\{([^{}]+)\}/))!==null;){f=true;g[k++]=c.slice(0,b.index);i[k]=x(b[1]);c=c.slice(b.index+b[0].length,c.length)}if(!f)return function(){return a};g[k]=c;return H(g,i)}b=a.split(".");return function(e){var o=e.context||e,m=e[b[0]];e=0;if(m&&typeof m.item!=="undefined"){e+=1;if(b[e]==="pos")return m.pos;else o=m.item}m=b.length;for(var t;e<m;e++){if(!o)break;t=o[b[e]];o=typeof t==="function"?o[b[e]].call(o):t}return!o&&o!==0?"":o}}function D(a,b,f){var c,
+g,i,k,l,e=[];if(typeof b==="string"){c=b;(l=b.match(I))||s("bad selector syntax: "+b);g=l[1];i=l[2];k=l[3];l=l[4];if(i==="."||!i&&k)e[0]=a;else e=n.find(a,i);if(!e||e.length===0)return s('The node "'+b+'" was not found in the template:\n'+G(a).replace(/\t/g," "))}else{g=b.prepend;k=b.attr;l=b.append;e=[a]}if(g||l)if(g&&l)s("append/prepend cannot take place at the same time");else if(f)s("no append/prepend/replace modifiers allowed for loop target");else l&&f&&s("cannot append with loop (sel: "+c+
+")");var o,m,t,u,q;if(k){t=/^style$/i.test(k);q=(u=/^class$/i.test(k))?"className":k;o=function(j,r){j.setAttribute(J+k,r);if(q in j&&!t)try{j[q]=""}catch(p){}if(j.nodeType===1){j.removeAttribute(k);u&&j.removeAttribute(q)}};m=t||u?t?function(j){return j.style.cssText}:function(j){return j.className}:function(j){return j.getAttribute(k)};a=function(j){return j.replace(/\"/g,"&quot;")};g=g?function(j,r){o(j,r+m(j))}:l?function(j,r){o(j,m(j)+r)}:function(j,r){o(j,r)}}else{g=f?function(j,r){var p=j.parentNode;
+if(p){p.insertBefore(document.createTextNode(r),j.nextSibling);p.removeChild(j)}else s("The template root, can't be looped.")}:g?function(j,r){j.insertBefore(document.createTextNode(r),j.firstChild)}:l?function(j,r){j.appendChild(document.createTextNode(r))}:function(j,r){for(;j.firstChild;)j.removeChild(j.firstChild);j.appendChild(document.createTextNode(r))};a=function(j){return j}}return{attr:k,nodes:e,set:g,sel:c,quotefn:a}}function E(a,b){for(var f=K+b+":",c=0;c<a.nodes.length;c++)a.set(a.nodes[c],
+f)}function L(a,b,f,c,g){return function(i){var k=b(i),l=i[a],e={items:k},o=0,m,t=[],u=function(j,r,p,y){var z=i.pos,v=i.item,U=i.items;i.pos=r.pos=j;i.item=r.item=k[j];i.items=k;typeof y!=="undefined"&&(i.length=y);if(typeof p==="function"&&p.call(i.item,i)===false)o++;else{t.push(f.call(i.item,i));i.pos=z;i.item=v;i.items=U}};i[a]=e;if(F(k)){m=k.length||0;typeof c==="function"&&k.sort(c);for(var q=0;q<m;q++)u(q,e,g,m-o)}else{k&&typeof c!=="undefined"&&s("sort is only available on arrays, not objects");
+for(m in k)k.hasOwnProperty(m)&&u(m,e,g)}typeof l!=="undefined"?i[a]=l:delete i[a];return t.join("")}}function M(a,b,f,c){var g=false,i,k,l,e;for(e in f)if(f.hasOwnProperty(e))if(e==="sort")k=f.sort;else if(e==="filter")l=f.filter;else{g&&s("cannot have more than one loop on a target");i=e;g=true}i||s("Error in the selector: "+b+"\nA directive action must be a string, a function or a loop(<-)");g=f[i];if(typeof g==="string"||typeof g==="function"){f={};f[i]={root:g};return M(a,b,f,c)}f=T(i);i=x(f.sel);
+a=D(a,b,true);b=a.nodes;for(w=0;w<b.length;w++){e=b[w];var o=B(e,g);c[c.length]=C(a.quotefn,L(f.name,i,o,k,l));a.nodes=[e];E(a,c.length-1)}return a}function V(a,b){function f(j,r){var p=j.match(I);p={prepend:!!p[1],prop:p[2],attr:p[3]||W[r],append:!!p[4],sel:j};var y,z,v;for(y=i.a.length-1;y>=0;y--){z=i.a[y];v=(v=z.l[0])&&v[p.prop];if(typeof v!=="undefined"){p.prop=z.p+"."+p.prop;if(i.l[p.prop]===true)v=v[0];break}}if(typeof v==="undefined"){v=x(p.prop)(F(b)?b[0]:b);if(v==="")return false}if(F(v)){i.a.push({l:v,
+p:p.prop});i.l[p.prop]=true;p.t="loop"}else p.t="str";return p}var c=a.getElementsByTagName("*"),g=[],i={a:[],l:{}},k,l,e,o,m,t,u,q;e=-1;for(o=c.length;e<o;e++){u=e>-1?c[e]:a;if(u.nodeType===1&&u.className!==""){q=u.className.split(" ");m=0;for(t=q.length;m<t;m++){k=q[m];k=f(k,u.tagName);if(k!==false){l=/nodevalue/i.test(k.attr);if(k.sel.indexOf("@")>-1||l){u.className=u.className.replace("@"+k.attr,"");if(l)k.attr=false}g.push({n:u,cspec:k})}}}}return g}function B(a,b,f,c){var g=[],i,k,l,e,o,m,t,
+u,q,j=[];c=c||f&&V(a,f);if(f)for(;c.length>0;){l=c[0].cspec;e=c[0].n;c.splice(0,1);if(l.t==="str"){e=D(e,l,false);E(e,g.length);g[g.length]=C(e.quotefn,x(l.prop))}else{m=x(l.sel);e=D(e,l,true);o=e.nodes;i=0;for(k=o.length;i<k;i++){t=o[i];u=B(t,false,f,c);g[g.length]=C(e.quotefn,L(l.sel,m,u));e.nodes=[t];E(e,g.length-1)}}}for(q in b)if(b.hasOwnProperty(q)){f=0;c=b[q];l=q.split(/\s*,\s*/);m=l.length;do if(typeof c==="function"||typeof c==="string"){q=l[f];e=D(a,q,false);E(e,g.length);g[g.length]=C(e.quotefn,
+x(c))}else M(a,q,c,g);while(++f<m)}a=G(a);a=a.replace(/<([^>]+)\s(value\=""|selected)\s?([^>]*)>/ig,"<$1 $3>");a=a.split(J).join("");a=a.split(K);for(f=1;f<a.length;f++){b=a[f];j[f]=g[parseInt(b,10)];a[f]=b.substring(b.indexOf(":")+1)}return H(a,j)}function P(a,b,f){var c=B((f||this[0]).cloneNode(true),a,b);return function(g){return c({context:g})}}function Q(a,b){for(var f=typeof b==="function"&&b,c=0,g=this.length;c<g;c++)this[c]=N(this[c],(f||n.compile(b,false,this[c]))(a,false));context=null;
+return this}function R(a,b){for(var f=n.compile(b,a,this[0]),c=0,g=this.length;c<g;c++)this[c]=N(this[c],f(a,false));context=null;return this}function N(a,b){var f,c=a.parentNode,g=0;if(!c){c=document.createElement("DIV");c.appendChild(a)}switch(a.tagName){case "BODY":c.removeChild(a);c.innerHTML+=b;return c.getElementsByTagName("BODY")[0];case "TBODY":case "THEAD":case "TFOOT":b="<TABLE>"+b+"</TABLE>";g=1;break;case "TR":b="<TABLE><TBODY>"+b+"</TBODY></TABLE>";g=2;break;case "TD":case "TH":b="<TABLE><TBODY><TR>"+
+b+"</TR></TBODY></TABLE>";g=3;break}tmp=document.createElement("SPAN");tmp.style.display="none";document.body.appendChild(tmp);tmp.innerHTML=b;for(f=tmp.firstChild;g--;)f=f.firstChild;c.insertBefore(f,a);c.removeChild(a);document.body.removeChild(tmp);return a=f}var A=[];n=n||O();switch(typeof d){case "string":A=n.find(h||document,d);A.length===0&&s('The template "'+d+'" was not found');break;case "undefined":s("The root of the template is undefined, check your selector");break;default:A=d}var w=
+0;for(d=A.length;w<d;w++)n[w]=A[w];n.length=d;var K="_s"+Math.floor(Math.random()*1E6)+"_",J="_a"+Math.floor(Math.random()*1E6)+"_",I=/^(\+)?([^\@\+]+)?\@?([^\+]+)?(\+)?$/,W={IMG:"src",INPUT:"value"},F=Array.isArray?function(a){return Array.isArray(a)}:function(a){return Object.prototype.toString.call(a)==="[object Array]"};return n};$p.plugins={};
+$p.libs={dojo:function(){if(typeof document.querySelector==="undefined")$p.plugins.find=function(d,h){return dojo.query(h,d)}},domassistant:function(){if(typeof document.querySelector==="undefined")$p.plugins.find=function(d,h){return $(d).cssSelect(h)};DOMAssistant.attach({publicMethods:["compile","render","autoRender"],compile:function(d,h){return $p([this]).compile(d,h)},render:function(d,h){return $($p([this]).render(d,h))[0]},autoRender:function(d,h){return $($p([this]).autoRender(d,h))[0]}})},
+jquery:function(){if(typeof document.querySelector==="undefined")$p.plugins.find=function(d,h){return jQuery(d).find(h)};jQuery.fn.extend({directives:function(d){this._pure_d=d;return this},compile:function(d,h){return $p(this).compile(this._pure_d||d,h)},render:function(d,h){return jQuery($p(this).render(d,this._pure_d||h))},autoRender:function(d,h){return jQuery($p(this).autoRender(d,this._pure_d||h))}})},mootools:function(){if(typeof document.querySelector==="undefined")$p.plugins.find=function(d,
+h){return $(d).getElements(h)};Element.implement({compile:function(d,h){return $p(this).compile(d,h)},render:function(d,h){return $p([this]).render(d,h)},autoRender:function(d,h){return $p([this]).autoRender(d,h)}})},prototype:function(){if(typeof document.querySelector==="undefined")$p.plugins.find=function(d,h){d=d===document?d.body:d;return typeof d==="string"?$$(d):$(d).select(h)};Element.addMethods({compile:function(d,h,n){return $p([d]).compile(h,n)},render:function(d,h,n){return $p([d]).render(h,
+n)},autoRender:function(d,h,n){return $p([d]).autoRender(h,n)}})},sizzle:function(){if(typeof document.querySelector==="undefined")$p.plugins.find=function(d,h){return Sizzle(h,d)}},sly:function(){if(typeof document.querySelector==="undefined")$p.plugins.find=function(d,h){return Sly(h,d)}},yui:function(){typeof document.querySelector==="undefined"&&YUI().use("node",function(d){$p.plugins.find=function(h,n){return d.NodeList.getDOMNodes(d.one(h).all(n))}});YUI.add("pure-yui",function(d){d.Node.prototype.directives=
+function(h){this._pure_d=h;return this};d.Node.prototype.compile=function(h,n){return $p([this._node]).compile(this._pure_d||h,n)};d.Node.prototype.render=function(h,n){return d.one($p([this._node]).render(h,this._pure_d||n))};d.Node.prototype.autoRender=function(h,n){return d.one($p([this._node]).autoRender(h,this._pure_d||n))}},"0.1",{requires:["node"]})}};
+(function(){var d=typeof dojo!=="undefined"&&"dojo"||typeof DOMAssistant!=="undefined"&&"domassistant"||typeof jQuery!=="undefined"&&"jquery"||typeof MooTools!=="undefined"&&"mootools"||typeof Prototype!=="undefined"&&"prototype"||typeof Sizzle!=="undefined"&&"sizzle"||typeof Sly!=="undefined"&&"sly"||typeof YUI!=="undefined"&&"yui";d&&$p.libs[d]();if(typeof exports!=="undefined")exports.$p=$p})();
Please sign in to comment.
Something went wrong with that request. Please try again.