transparency
Advanced tools
Comparing version 0.6.11 to 0.7.0
// Generated by CoffeeScript 1.3.3 | ||
(function() { | ||
var __slice = [].slice; | ||
var __slice = [].slice, | ||
__hasProp = {}.hasOwnProperty; | ||
(function(root, factory) { | ||
if (typeof define !== "undefined" && define !== null ? define.amd : void 0) { | ||
return define(['jquery'], factory); | ||
return define(factory); | ||
} else if (typeof module !== "undefined" && module !== null ? module.exports : void 0) { | ||
return module.exports = factory(typeof $ !== "undefined" && $ !== null ? $ : { | ||
fn: {} | ||
}); | ||
return module.exports = factory(); | ||
} else { | ||
return root.Transparency = factory(typeof $ !== "undefined" && $ !== null ? $ : { | ||
fn: {} | ||
}); | ||
return root.Transparency = factory(); | ||
} | ||
})(this, function($) { | ||
var ELEMENT_NODE, TEXT_NODE, attr, cloneNode, consoleLogger, data, elementNodes, expando, exports, getText, html5Clone, isDate, isDomElement, isPlainValue, log, logger, matcher, matchingElements, nullLogger, prepareContext, register, render, renderChildren, renderDirectives, renderValues, setContent, setHtml, setText, _base, _ref, _ref1; | ||
})(this, function() { | ||
var $, ELEMENT_NODE, Instance, TEXT_NODE, attr, cloneNode, consoleLogger, data, empty, expando, exports, getElementsAndChildNodes, getText, html5Clone, isDate, isDomElement, isPlainValue, log, matcher, matchingElements, nullLogger, prepareContext, register, render, renderDirectives, setHtml, setText, _base, _ref, _ref1; | ||
register = function($) { | ||
@@ -29,3 +26,6 @@ return $.fn.render = function(models, directives, config) { | ||
}; | ||
register($); | ||
$ = jQuery; | ||
if ($) { | ||
register($); | ||
} | ||
expando = 'transparency'; | ||
@@ -46,13 +46,6 @@ data = function(element) { | ||
}; | ||
log = null; | ||
logger = function(config) { | ||
if ((config != null ? config.debug : void 0) && (typeof console !== "undefined" && console !== null)) { | ||
return consoleLogger; | ||
} else { | ||
return nullLogger; | ||
} | ||
}; | ||
log = nullLogger; | ||
render = function(context, models, directives, config) { | ||
var contextData, e, index, instance, model, parent, sibling, _i, _j, _len, _len1, _ref; | ||
log = logger(config); | ||
var children, contextData, e, element, index, instance, key, model, parent, sibling, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2; | ||
log = (config != null ? config.debug : void 0) && (typeof console !== "undefined" && console !== null) ? consoleLogger : nullLogger; | ||
log("Context:", context, "Models:", models, "Directives:", directives, "Config:", config); | ||
@@ -67,5 +60,5 @@ if (!context) { | ||
} | ||
sibling = context.nextSibling; | ||
parent = context.parentNode; | ||
if (parent != null) { | ||
if (parent) { | ||
sibling = context.nextSibling; | ||
parent.removeChild(context); | ||
@@ -77,2 +70,3 @@ } | ||
model = models[index]; | ||
children = []; | ||
instance = contextData.instances[index]; | ||
@@ -85,12 +79,37 @@ log("Model:", model, "Template instance for the model:", instance); | ||
} | ||
renderValues(instance, model); | ||
if (isDomElement(model) && (element = instance.elements[0])) { | ||
empty(element).appendChild(model); | ||
} else if (typeof model === 'object') { | ||
for (key in model) { | ||
if (!__hasProp.call(model, key)) continue; | ||
value = model[key]; | ||
if (isPlainValue(value)) { | ||
_ref1 = matchingElements(instance, key); | ||
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) { | ||
element = _ref1[_k]; | ||
if (element.nodeName.toLowerCase() === 'input') { | ||
attr(element, 'value', value); | ||
} else { | ||
attr(element, 'text', value); | ||
} | ||
} | ||
} else if (typeof value === 'object') { | ||
children.push(key); | ||
} | ||
} | ||
} | ||
renderDirectives(instance, model, index, directives); | ||
renderChildren(instance, model, directives, config); | ||
for (_l = 0, _len3 = children.length; _l < _len3; _l++) { | ||
key = children[_l]; | ||
_ref2 = matchingElements(instance, key); | ||
for (_m = 0, _len4 = _ref2.length; _m < _len4; _m++) { | ||
element = _ref2[_m]; | ||
render(element, model[key], directives[key], config); | ||
} | ||
} | ||
} | ||
if (sibling) { | ||
if (parent != null) { | ||
if (parent) { | ||
if (sibling) { | ||
parent.insertBefore(context, sibling); | ||
} | ||
} else { | ||
if (parent != null) { | ||
} else { | ||
parent.appendChild(context); | ||
@@ -104,28 +123,11 @@ } | ||
contextData = data(context); | ||
contextData.template || (contextData.template = ((function() { | ||
var _results; | ||
_results = []; | ||
while (context.firstChild) { | ||
_results.push(context.removeChild(context.firstChild)); | ||
} | ||
return _results; | ||
})())); | ||
contextData.instanceCache || (contextData.instanceCache = []); | ||
contextData.instances || (contextData.instances = []); | ||
log("Original template", contextData.template); | ||
if (!contextData.template) { | ||
contextData.template = cloneNode(context); | ||
contextData.instanceCache = []; | ||
contextData.instances = [new Instance(context)]; | ||
} | ||
log("Template", contextData.template); | ||
while (models.length > contextData.instances.length) { | ||
instance = contextData.instanceCache.pop() || {}; | ||
instance.queryCache || (instance.queryCache = {}); | ||
instance.template || (instance.template = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = contextData.template; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
n = _ref[_i]; | ||
_results.push(cloneNode(n)); | ||
} | ||
return _results; | ||
})()); | ||
instance.elements || (instance.elements = elementNodes(instance.template)); | ||
_ref = instance.template; | ||
instance = contextData.instanceCache.pop() || new Instance(cloneNode(contextData.template)); | ||
_ref = instance.childNodes; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
@@ -142,3 +144,3 @@ n = _ref[_i]; | ||
var _j, _len1, _ref1, _results1; | ||
_ref1 = instance.template; | ||
_ref1 = instance.childNodes; | ||
_results1 = []; | ||
@@ -154,35 +156,36 @@ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { | ||
}; | ||
renderValues = function(instance, model) { | ||
var child, element, key, value, _results; | ||
if (isDomElement(model) && (element = instance.elements[0])) { | ||
while (child = element.firstChild) { | ||
element.removeChild(child); | ||
Instance = (function() { | ||
function Instance(template) { | ||
this.template = template; | ||
this.queryCache = {}; | ||
this.elements = []; | ||
this.childNodes = []; | ||
getElementsAndChildNodes(this.template, this.elements, this.childNodes); | ||
} | ||
return Instance; | ||
})(); | ||
getElementsAndChildNodes = function(template, elements, childNodes) { | ||
var child, _results; | ||
child = template.firstChild; | ||
_results = []; | ||
while (child) { | ||
if (childNodes != null) { | ||
childNodes.push(child); | ||
} | ||
return element.appendChild(model); | ||
} else { | ||
_results = []; | ||
for (key in model) { | ||
value = model[key]; | ||
if (typeof model === 'object' && isPlainValue(value)) { | ||
_results.push((function() { | ||
var _i, _len, _ref, _results1; | ||
_ref = matchingElements(instance, key); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
if (element.nodeName.toLowerCase() === 'input') { | ||
_results1.push(attr(element, 'value', value)); | ||
} else { | ||
_results1.push(attr(element, 'text', value)); | ||
} | ||
} | ||
return _results1; | ||
})()); | ||
} | ||
if (child.nodeType === ELEMENT_NODE) { | ||
elements.push(child); | ||
getElementsAndChildNodes(child, elements); | ||
} | ||
return _results; | ||
_results.push(child = child.nextSibling); | ||
} | ||
return _results; | ||
}; | ||
renderDirectives = function(instance, model, index, directives) { | ||
var attribute, attributes, directive, element, key, value, _results; | ||
if (!directives) { | ||
return; | ||
} | ||
model = typeof model === 'object' ? model : { | ||
@@ -193,2 +196,3 @@ value: model | ||
for (key in directives) { | ||
if (!__hasProp.call(directives, key)) continue; | ||
attributes = directives[key]; | ||
@@ -231,61 +235,47 @@ if (typeof attributes !== 'object') { | ||
}; | ||
renderChildren = function(instance, model, directives, config) { | ||
var element, key, value, _results; | ||
_results = []; | ||
for (key in model) { | ||
value = model[key]; | ||
if (typeof value === 'object' && !isDate(value)) { | ||
_results.push((function() { | ||
var _i, _len, _ref, _results1; | ||
_ref = matchingElements(instance, key, config); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
_results1.push(render(element, value, directives[key], config)); | ||
} | ||
return _results1; | ||
})()); | ||
} | ||
setHtml = function(element, html) { | ||
var child, elementData, n, _i, _len, _ref, _results; | ||
elementData = data(element); | ||
if (elementData.html === html) { | ||
return; | ||
} | ||
return _results; | ||
}; | ||
setContent = function(callback) { | ||
return function(element, content) { | ||
var c, elementData, n, _i, _len, _ref, _results; | ||
elementData = data(element); | ||
if (elementData.content === content) { | ||
return; | ||
} | ||
elementData.content = content; | ||
elementData.children || (elementData.children = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = element.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
n = _ref[_i]; | ||
if (n.nodeType === ELEMENT_NODE) { | ||
_results.push(n); | ||
} | ||
} | ||
return _results; | ||
})()); | ||
while (element.firstChild) { | ||
element.removeChild(element.firstChild); | ||
} | ||
callback(element, content); | ||
_ref = elementData.children; | ||
elementData.html = html; | ||
elementData.children || (elementData.children = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = element.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
c = _ref[_i]; | ||
_results.push(element.appendChild(c)); | ||
n = _ref[_i]; | ||
if (n.nodeType === ELEMENT_NODE) { | ||
_results.push(n); | ||
} | ||
} | ||
return _results; | ||
}; | ||
})()); | ||
empty(element); | ||
element.innerHTML = html; | ||
_ref = elementData.children; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
_results.push(element.appendChild(child)); | ||
} | ||
return _results; | ||
}; | ||
setHtml = setContent(function(element, html) { | ||
return element.innerHTML = html; | ||
}); | ||
setText = setContent(function(element, text) { | ||
return element.appendChild(element.ownerDocument.createTextNode(text)); | ||
}); | ||
setText = function(element, text) { | ||
var elementData, textNode; | ||
elementData = data(element); | ||
if (elementData.text === text) { | ||
return; | ||
} | ||
elementData.text = text; | ||
textNode = element.firstChild; | ||
if (!textNode) { | ||
return element.appendChild(element.ownerDocument.createTextNode(text)); | ||
} else if (textNode.nodeType !== TEXT_NODE) { | ||
return element.insertBefore(element.ownerDocument.createTextNode(text), textNode); | ||
} else { | ||
return textNode.nodeValue = text; | ||
} | ||
}; | ||
getText = function(element) { | ||
@@ -344,19 +334,2 @@ var child; | ||
}; | ||
elementNodes = function(template) { | ||
var child, e, elements, _i, _j, _len, _len1, _ref; | ||
elements = []; | ||
for (_i = 0, _len = template.length; _i < _len; _i++) { | ||
e = template[_i]; | ||
if (!(e.nodeType === ELEMENT_NODE)) { | ||
continue; | ||
} | ||
elements.push(e); | ||
_ref = e.getElementsByTagName('*'); | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
child = _ref[_j]; | ||
elements.push(child); | ||
} | ||
} | ||
return elements; | ||
}; | ||
matchingElements = function(instance, key) { | ||
@@ -382,2 +355,9 @@ var e, elements, _base; | ||
}; | ||
empty = function(element) { | ||
var child; | ||
while (child = element.firstChild) { | ||
element.removeChild(child); | ||
} | ||
return element; | ||
}; | ||
ELEMENT_NODE = 1; | ||
@@ -384,0 +364,0 @@ TEXT_NODE = 3; |
// Generated by CoffeeScript 1.3.3 | ||
(function(){var e=[].slice;(function(e,t){return(typeof define!="undefined"&&define!==null?define.amd:void 0)?define(["jquery"],t):(typeof module!="undefined"&&module!==null?module.exports:void 0)?module.exports=t(typeof $!="undefined"&&$!==null?$:{fn:{}}):e.Transparency=t(typeof $!="undefined"&&$!==null?$:{fn:{}})})(this,function(t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M,_;return S=function(e){return e.fn.render=function(e,t,n){var r,i,s;for(i=0,s=this.length;i<s;i++)r=this[i],x(r,e,t,n);return this}},S(t),f="transparency",u=function(e){return e[f]||(e[f]={})},w=function(){},o=function(){var t,n,r,i,s;n=1<=arguments.length?e.call(arguments,0):[],s=[];for(r=0,i=n.length;r<i;r++)t=n[r],s.push(console.log(t));return s},m=null,g=function(e){return(e!=null?e.debug:void 0)&&typeof console!="undefined"&&console!==null?o:w},x=function(e,t,n,r){var i,s,o,a,f,l,c,h,p,d,v,y;m=g(r),m("Context:",e,"Models:",t,"Directives:",n,"Config:",r);if(!e)return;t||(t=[]),n||(n={}),Array.isArray(t)||(t=[t]),c=e.nextSibling,l=e.parentNode,l!=null&&l.removeChild(e),E(e,t),i=u(e);for(o=h=0,d=t.length;h<d;o=++h){f=t[o],a=i.instances[o],m("Model:",f,"Template instance for the model:",a),y=a.elements;for(p=0,v=y.length;p<v;p++)s=y[p],u(s).model=f;C(a,f),N(a,f,o,n),T(a,f,n,r)}return c?l!=null&&l.insertBefore(e,c):l!=null&&l.appendChild(e),e},E=function(e,t){var n,r,i,o,f,l,c;n=u(e),n.template||(n.template=function(){var t;t=[];while(e.firstChild)t.push(e.removeChild(e.firstChild));return t}()),n.instanceCache||(n.instanceCache=[]),n.instances||(n.instances=[]),m("Original template",n.template);while(t.length>n.instances.length){r=n.instanceCache.pop()||{},r.queryCache||(r.queryCache={}),r.template||(r.template=function(){var e,t,r,o;r=n.template,o=[];for(e=0,t=r.length;e<t;e++)i=r[e],o.push(s(i));return o}()),r.elements||(r.elements=a(r.template)),l=r.template;for(o=0,f=l.length;o<f;o++)i=l[o],e.appendChild(i);n.instances.push(r)}c=[];while(t.length<n.instances.length)n.instanceCache.push(r=n.instances.pop()),c.push(function(){var e,t,n,s;n=r.template,s=[];for(e=0,t=n.length;e<t;e++)i=n[e],s.push(i.parentNode.removeChild(i));return s}());return c},C=function(e,t){var n,r,s,o,u;if(d(t)&&(r=e.elements[0])){while(n=r.firstChild)r.removeChild(n);return r.appendChild(t)}u=[];for(s in t)o=t[s],typeof t=="object"&&v(o)&&u.push(function(){var t,n,u,a;u=b(e,s),a=[];for(t=0,n=u.length;t<n;t++)r=u[t],r.nodeName.toLowerCase()==="input"?a.push(i(r,"value",o)):a.push(i(r,"text",o));return a}());return u},N=function(e,t,n,r){var s,o,u,a,f,l,c;t=typeof t=="object"?t:{value:t},c=[];for(f in r){o=r[f];if(typeof o!="object")throw new Error("Directive syntax is directive[element][attribute] = function(params)");c.push(function(){var r,c,h,p;h=b(e,f),p=[];for(r=0,c=h.length;r<c;r++)a=h[r],p.push(function(){var e;e=[];for(s in o){u=o[s];if(typeof u!="function")continue;l=u.call(t,{element:a,index:n,value:i(a,s)}),l!=null?e.push(i(a,s,l)):e.push(void 0)}return e}());return p}())}return c},T=function(e,t,n,r){var i,s,o,u;u=[];for(s in t)o=t[s],typeof o=="object"&&!p(o)&&u.push(function(){var t,u,a,f;a=b(e,s,r),f=[];for(t=0,u=a.length;t<u;t++)i=a[t],f.push(x(i,o,n[s],r));return f}());return u},k=function(e){return function(t,r){var i,s,o,a,f,l,c;s=u(t);if(s.content===r)return;s.content=r,s.children||(s.children=function(){var e,r,i,s;i=t.childNodes,s=[];for(e=0,r=i.length;e<r;e++)o=i[e],o.nodeType===n&&s.push(o);return s}());while(t.firstChild)t.removeChild(t.firstChild);e(t,r),l=s.children,c=[];for(a=0,f=l.length;a<f;a++)i=l[a],c.push(t.appendChild(i));return c}},L=k(function(e,t){return e.innerHTML=t}),A=k(function(e,t){return e.appendChild(e.ownerDocument.createTextNode(t))}),c=function(e){var t;return function(){var n,i,s,o;s=e.childNodes,o=[];for(n=0,i=s.length;n<i;n++)t=s[n],t.nodeType===r&&o.push(t.nodeValue);return o}().join("")},i=function(e,t,n){var r,i,s,o,a;n!=null&&typeof n!="string"&&(n=n.toString()),r=u(e),r.originalAttributes||(r.originalAttributes={});switch(t){case"text":(i=r.originalAttributes).text||(i.text=c(e)),n!=null&&A(e,n);break;case"html":(s=r.originalAttributes).html||(s.html=e.innerHTML),n!=null&&L(e,n);break;case"class":(o=r.originalAttributes)["class"]||(o["class"]=e.className),n!=null&&(e.className=n);break;default:(a=r.originalAttributes)[t]||(a[t]=e.getAttribute(t)),n!=null&&e.setAttribute(t,n)}return n!=null?n:r.originalAttributes[t]},a=function(e){var t,r,i,s,o,u,a,f;i=[];for(s=0,u=e.length;s<u;s++){r=e[s];if(r.nodeType!==n)continue;i.push(r),f=r.getElementsByTagName("*");for(o=0,a=f.length;o<a;o++)t=f[o],i.push(t)}return i},b=function(e,t){var n,r,i;return r=(i=e.queryCache)[t]||(i[t]=function(){var r,i,s,o;s=e.elements,o=[];for(r=0,i=s.length;r<i;r++)n=s[r],l.matcher(n,t)&&o.push(n);return o}()),m("Matching elements for '"+t+"':",r),r},y=function(e,t){return e.id===t||e.className.split(" ").indexOf(t)>-1||e.name===t||e.getAttribute("data-bind")===t},n=1,r=3,h=function(){return document.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>"},s=typeof document=="undefined"||document===null||h()?function(e){return e.cloneNode(!0)}:function(e){var r,i,s,o,u;r=t(e).clone()[0];if(r.nodeType===n){r.removeAttribute(f),u=r.getElementsByTagName("*");for(s=0,o=u.length;s<o;s++)i=u[s],i.removeAttribute(f)}return r},(M=Array.isArray)==null&&(Array.isArray=function(e){return t.isArray(e)}),(_=(O=Array.prototype).indexOf)==null&&(O.indexOf=function(e){return t.inArray(e,this)}),p=function(e){return Object.prototype.toString.call(e)==="[object Date]"},d=function(e){return(e!=null?e.nodeType:void 0)===n},v=function(e){return p(e)||typeof e!="object"&&typeof e!="function"},l={render:x,register:S,matcher:y}})}).call(this); | ||
(function(){var e=[].slice,t={}.hasOwnProperty;(function(e,t){return(typeof define!="undefined"&&define!==null?define.amd:void 0)?define(t):(typeof module!="undefined"&&module!==null?module.exports:void 0)?module.exports=t():e.Transparency=t()})(this,function(){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,C,k,L,A,O,M;return T=function(e){return e.fn.render=function(e,t,n){var r,i,s;for(i=0,s=this.length;i<s;i++)r=this[i],N(r,e,t,n);return this}},n=jQuery,n&&T(n),c="transparency",f=function(e){return e[c]||(e[c]={})},S=function(){},a=function(){var t,n,r,i,s;n=1<=arguments.length?e.call(arguments,0):[],s=[];for(r=0,i=n.length;r<i;r++)t=n[r],s.push(console.log(t));return s},b=S,N=function(e,n,r,i){var s,u,c,h,p,d,v,m,w,T,k,L,A,O,M,_,D,P,H,B,j,F,I,q;b=(i!=null?i.debug:void 0)&&typeof console!="undefined"&&console!==null?a:S,b("Context:",e,"Models:",n,"Directives:",r,"Config:",i);if(!e)return;n||(n=[]),r||(r={}),Array.isArray(n)||(n=[n]),w=e.parentNode,w&&(T=e.nextSibling,w.removeChild(e)),x(e,n),u=f(e);for(p=L=0,_=n.length;L<_;p=++L){m=n[p],s=[],d=u.instances[p],b("Model:",m,"Template instance for the model:",d),F=d.elements;for(A=0,D=F.length;A<D;A++)c=F[A],f(c).model=m;if(g(m)&&(h=d.elements[0]))l(h).appendChild(m);else if(typeof m=="object")for(v in m){if(!t.call(m,v))continue;k=m[v];if(y(k)){I=E(d,v);for(O=0,P=I.length;O<P;O++)h=I[O],h.nodeName.toLowerCase()==="input"?o(h,"value",k):o(h,"text",k)}else typeof k=="object"&&s.push(v)}C(d,m,p,r);for(M=0,H=s.length;M<H;M++){v=s[M],q=E(d,v);for(j=0,B=q.length;j<B;j++)h=q[j],N(h,m[v],r[v],i)}}return w&&(T?w.insertBefore(e,T):w.appendChild(e)),e},x=function(e,t){var n,r,s,o,a,l,c;n=f(e),n.template||(n.template=u(e),n.instanceCache=[],n.instances=[new i(e)]),b("Template",n.template);while(t.length>n.instances.length){r=n.instanceCache.pop()||new i(u(n.template)),l=r.childNodes;for(o=0,a=l.length;o<a;o++)s=l[o],e.appendChild(s);n.instances.push(r)}c=[];while(t.length<n.instances.length)n.instanceCache.push(r=n.instances.pop()),c.push(function(){var e,t,n,i;n=r.childNodes,i=[];for(e=0,t=n.length;e<t;e++)s=n[e],i.push(s.parentNode.removeChild(s));return i}());return c},i=function(){function e(e){this.template=e,this.queryCache={},this.elements=[],this.childNodes=[],p(this.template,this.elements,this.childNodes)}return e}(),p=function(e,t,n){var i,s;i=e.firstChild,s=[];while(i)n!=null&&n.push(i),i.nodeType===r&&(t.push(i),p(i,t)),s.push(i=i.nextSibling);return s},C=function(e,n,r,i){var s,u,a,f,l,c,h;if(!i)return;n=typeof n=="object"?n:{value:n},h=[];for(l in i){if(!t.call(i,l))continue;u=i[l];if(typeof u!="object")throw new Error("Directive syntax is directive[element][attribute] = function(params)");h.push(function(){var t,i,h,p;h=E(e,l),p=[];for(t=0,i=h.length;t<i;t++)f=h[t],p.push(function(){var e;e=[];for(s in u){a=u[s];if(typeof a!="function")continue;c=a.call(n,{element:f,index:r,value:o(f,s)}),c!=null?e.push(o(f,s,c)):e.push(void 0)}return e}());return p}())}return h},k=function(e,t){var n,i,s,o,u,a,c;i=f(e);if(i.html===t)return;i.html=t,i.children||(i.children=function(){var t,n,i,o;i=e.childNodes,o=[];for(t=0,n=i.length;t<n;t++)s=i[t],s.nodeType===r&&o.push(s);return o}()),l(e),e.innerHTML=t,a=i.children,c=[];for(o=0,u=a.length;o<u;o++)n=a[o],c.push(e.appendChild(n));return c},L=function(e,t){var n,r;n=f(e);if(n.text===t)return;return n.text=t,r=e.firstChild,r?r.nodeType!==s?e.insertBefore(e.ownerDocument.createTextNode(t),r):r.nodeValue=t:e.appendChild(e.ownerDocument.createTextNode(t))},d=function(e){var t;return function(){var n,r,i,o;i=e.childNodes,o=[];for(n=0,r=i.length;n<r;n++)t=i[n],t.nodeType===s&&o.push(t.nodeValue);return o}().join("")},o=function(e,t,n){var r,i,s,o,u;n!=null&&typeof n!="string"&&(n=n.toString()),r=f(e),r.originalAttributes||(r.originalAttributes={});switch(t){case"text":(i=r.originalAttributes).text||(i.text=d(e)),n!=null&&L(e,n);break;case"html":(s=r.originalAttributes).html||(s.html=e.innerHTML),n!=null&&k(e,n);break;case"class":(o=r.originalAttributes)["class"]||(o["class"]=e.className),n!=null&&(e.className=n);break;default:(u=r.originalAttributes)[t]||(u[t]=e.getAttribute(t)),n!=null&&e.setAttribute(t,n)}return n!=null?n:r.originalAttributes[t]},E=function(e,t){var n,r,i;return r=(i=e.queryCache)[t]||(i[t]=function(){var r,i,s,o;s=e.elements,o=[];for(r=0,i=s.length;r<i;r++)n=s[r],h.matcher(n,t)&&o.push(n);return o}()),b("Matching elements for '"+t+"':",r),r},w=function(e,t){return e.id===t||e.className.split(" ").indexOf(t)>-1||e.name===t||e.getAttribute("data-bind")===t},l=function(e){var t;while(t=e.firstChild)e.removeChild(t);return e},r=1,s=3,v=function(){return document.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>"},u=typeof document=="undefined"||document===null||v()?function(e){return e.cloneNode(!0)}:function(e){var t,i,s,o,u;t=n(e).clone()[0];if(t.nodeType===r){t.removeAttribute(c),u=t.getElementsByTagName("*");for(s=0,o=u.length;s<o;s++)i=u[s],i.removeAttribute(c)}return t},(O=Array.isArray)==null&&(Array.isArray=function(e){return n.isArray(e)}),(M=(A=Array.prototype).indexOf)==null&&(A.indexOf=function(e){return n.inArray(e,this)}),m=function(e){return Object.prototype.toString.call(e)==="[object Date]"},g=function(e){return(e!=null?e.nodeType:void 0)===r},y=function(e){return m(e)||typeof e!="object"&&typeof e!="function"},h={render:N,register:T,matcher:w}})}).call(this); |
{ | ||
"name" : "transparency", | ||
"version" : "0.6.11", | ||
"version" : "0.7.0", | ||
"main" : "lib/transparency", | ||
@@ -5,0 +5,0 @@ "description" : "Transparency is a minimal template engine for browsers. It maps JSON objects to DOM elements with zero configuration.", |
@@ -67,7 +67,9 @@ # Synopsis | ||
require(['jquery', 'transparency'], function($, transparency){ | ||
// With jQuery | ||
$('#template').render(data); | ||
// Without jQuery | ||
transparency.render(document.getElementById('template'), data); | ||
// With jQuery | ||
transparency.register($); // register Transparency as a jQuery plugin | ||
$('#template').render(data); | ||
}); | ||
@@ -454,3 +456,3 @@ ``` | ||
For example, one might want to bind only with `data-bind` attribute, but not with `class` or `id` attributes. | ||
Custom matcher function should take `key` and `element` as parameters and return `true` if the | ||
Custom matcher function should take `key` and `element` as parameters and return `true` if the | ||
corresponding value should be bind to the given DOM element. | ||
@@ -457,0 +459,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3987207
103
14589
501
8
1
26
12