-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT.min.js
9 lines (9 loc) · 3.46 KB
/
T.min.js
1
2
3
4
5
6
7
8
9
/*
* Copyright (c) 2008-2011, nektixe, Hiraku NAKANO. All rights reserved.
* Code licensed under the MIT License:
* Original Code: http://code.nanigac.com/source/view/427
*
* T.js
* DOMBuilder-like template engine for JavaScript
* https://github.com/hirak/T.js
*/void function(e){function c(e){var t,n,r,i,s,o=[];for(t=0,n=e.length;t<n;++t){r=e[t];if(r instanceof a||r.length&&r.item)for(i=0,s=r.length;i<s;++i)o[o.length]=r[i];else o[o.length]=r}return o}function h(e){var t,n;typeof e==u?e=e.split(r):e instanceof a||(e=i.split(r));for(t=0;n=e[t++];)p[n]=p(n)}function p(e){function t(t){var r=e.cloneNode(!0),i,s,o,a,l,h,d,v=c(arguments);if(v.length==0)return r;if(v.length==1&&typeof t==u&&/^[.#][0-9A-Za-z.#\-_]+$/.exec(t)){if(h=t.match(/#[^.#]+/))h=h[0].slice(1),r.id=h;if(d=t.match(/\.[^.#]+/g))r.className=d.join("").replace(/\./g," ").slice(1);if(h||d)return p(r)}if(t.constructor===f){a=1;for(i in t){o=t[i];if(i=="style")for(s in o)r.style[s]=o[s];else r[i]=o}}else a=0;for(l=v.length;a<l;++a)r.appendChild(v[a].nodeType!=null?v[a]:n.createTextNode(v[a]));return r}return typeof e==u&&(e=n.createElement(e)),arguments.length==1?t:t(c(arguments).slice(1))}function d(e){var t=e.concat();return t.chunk=v,t.map=m,t}function v(e,t){if(typeof e!="number")throw new TypeError("parameter 'size' required");var n=this.length,r=n%e,i=Math.ceil(n/e),s=new a(i),o,u,f;for(o=f=0;o<i;o++){s[o]=new a(e);for(u=0;u<e;u++,f++)s[o][u]=this[f]}o--;if(r)if(t!==void 0)for(u=r;u<e;u++)s[o][u]=t;else s[o].length=r;return d(s)}function m(e){var t=this.length,n=l.call(arguments,1),r=new a(t),i,s;n.cachedLen=n.length;if(e instanceof a)for(i=0,j=0;i<t;i++)e[j].nodeType!=null&&(e[j]=p(e[j])),r[i]=e[j](g(this[i],n)),++j>=e.length&&(j=0);else if(e.middle){var o,u=0,f=t-1;e.first&&e.first.nodeType!=null&&(e.first=p(e.first)),e.middle.nodeType!=null&&(e.middle=p(e.middle)),e.last&&e.last.nodeType!=null&&(e.last=p(e.last));for(i=0;i<t;i++)o=g(this[i],n),r[i]=i===u&&e.first?e.first(o):i===f&&e.last?e.last(o):e.middle(o)}else{e.nodeType!=null&&(e=p(e));for(i=0;i<t;i++)r[i]=e(g(this[i],n))}return d(r)}function g(e,t){return t.cachedLen&&e instanceof a?m.apply(e,t):e}function y(){var e=l.call(arguments);for(var t=0,n=e.length;t<n;t++)e[t].nodeType!=null&&(e[t]=p(e[t]));return function(){var t=e.length-1,n=l.call(arguments);for(;t>=0;t--)n=e[t](n);return n}}var t=Function("return this")(),n,r=" ",i="a abbr address area b base bdo blockquote br button canvas comment cite code col colgroup del div dfn dl dt dd em fieldset form h1 h2 h3 h4 h5 h6 hr i iframe img input ins kbd label legend li link map noscript object ol optgroup option p param pre q samp script select small span strong style sub sup table tbody td textarea tfoot th thead tr ul var body html head meta title",s="acronym applet basefont big center dir font frame frameset isindex noframes s strike tt u wbr",o="article aside audio bdi caption command datalist details dialog embed figure figcaption footer header hgroup keygen m mark menu meter nav output progress ruby rp rt section source summary time video",u="string",a=t.Array,f=t.Object,l=a.prototype.slice;typeof window=="undefined"?(n=require("./document.js"),module.exports=p):(n=t.document,typeof define=="undefined"?t[e]=p:define(p)),p.Shorthand=h,h(),h.html4=function(){h(s)},h.html5=function(){h(o)},h.full=function(){h(s+r+o)},p.DF=p.DocumentFragment=p(n.createDocumentFragment()),p.Comment=function(t){return n.createComment(""+t)},p.Text=function(t){return n.createTextNode(""+t)},p.$=d,p.$nest=y}("T");