transparency
Advanced tools
Comparing version 0.9.2 to 0.9.3
{ | ||
"name": "transparency", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"main": "./dist/transparency.js" | ||
} |
/*! | ||
* transparency - v0.9.1 - 2013-02-21 | ||
* transparency - v0.9.2 - 2013-02-22 | ||
* https://github.com/leonidas/transparency | ||
@@ -10,3 +10,3 @@ * Copyright (c) 2013 Jarno Keskikangas <jarno.keskikangas@leonidasoy.fi>; Licensed MIT | ||
(function() { | ||
var Attribute, AttributeFactory, BooleanAttribute, Checkbox, Class, Context, ELEMENT_NODE, Element, ElementFactory, Html, Input, Instance, Radio, Select, TEXT_NODE, Text, Transparency, VoidElement, after, before, chainable, cloneNode, consoleLogger, data, expando, getChildNodes, getElements, html5Clone, isArray, isBoolean, isDate, isDomElement, isPlainValue, log, nullLogger, toString, _getElements, _ref, | ||
var Attribute, AttributeFactory, BooleanAttribute, Checkbox, Class, Context, ELEMENT_NODE, Element, ElementFactory, Html, Input, Instance, Radio, Select, TEXT_NODE, Text, Transparency, VoidElement, after, before, chainable, cloneNode, consoleLogger, data, expando, getChildNodes, getElements, html5Clone, isArray, isBoolean, isDate, isDomElement, isPlainValue, log, nullLogger, onlyWith$, toString, _getElements, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, | ||
@@ -38,2 +38,10 @@ __hasProp = {}.hasOwnProperty, | ||
onlyWith$ = function(fn) { | ||
if ((typeof jQuery !== "undefined" && jQuery !== null) || (typeof Zepto !== "undefined" && Zepto !== null)) { | ||
return (function($ ) { | ||
return fn(arguments); | ||
})(jQuery || Zepto); | ||
} | ||
}; | ||
getChildNodes = function(el) { | ||
@@ -172,10 +180,11 @@ var child, childNodes; | ||
Transparency.clone = function(node) { | ||
var _base; | ||
return typeof (_base = jQuery || Zepto) === "function" ? _base(node).clone()[0] : void 0; | ||
}; | ||
Transparency.clone = onlyWith$(function() { | ||
return function(node) { | ||
return $(node).clone()[0]; | ||
}; | ||
}); | ||
if ((_ref = jQuery || Zepto) != null) { | ||
_ref.fn.render = Transparency.jQueryPlugin; | ||
} | ||
onlyWith$(function() { | ||
return $.fn.render = Transparency.jQueryPlugin; | ||
}); | ||
@@ -247,7 +256,7 @@ if (typeof define !== "undefined" && define !== null ? define.amd : void 0) { | ||
Instance.prototype.remove = chainable(function() { | ||
var node, _i, _len, _ref1, _results; | ||
_ref1 = this.childNodes; | ||
var node, _i, _len, _ref, _results; | ||
_ref = this.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
node = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(node.parentNode.removeChild(node)); | ||
@@ -259,7 +268,7 @@ } | ||
Instance.prototype.appendTo = chainable(function(parent) { | ||
var node, _i, _len, _ref1, _results; | ||
_ref1 = this.childNodes; | ||
var node, _i, _len, _ref, _results; | ||
_ref = this.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
node = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(parent.appendChild(node)); | ||
@@ -271,7 +280,7 @@ } | ||
Instance.prototype.prepare = chainable(function(model) { | ||
var element, _i, _len, _ref1, _results; | ||
_ref1 = this.elements; | ||
var element, _i, _len, _ref, _results; | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
element = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
element.reset(); | ||
@@ -295,7 +304,7 @@ _results.push(data(element.el).model = model); | ||
_results.push((function() { | ||
var _i, _len, _ref1, _results1; | ||
_ref1 = this.matchingElements(key); | ||
var _i, _len, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
element = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
_results1.push(element.render(value)); | ||
@@ -331,7 +340,7 @@ } | ||
_results.push((function() { | ||
var _i, _len, _ref1, _results1; | ||
_ref1 = this.matchingElements(key); | ||
var _i, _len, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
element = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
_results1.push(element.renderDirectives(model, index, attributes)); | ||
@@ -351,7 +360,7 @@ } | ||
_results.push((function() { | ||
var _j, _len1, _ref1, _results1; | ||
_ref1 = this.matchingElements(key); | ||
var _j, _len1, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { | ||
element = _ref1[_j]; | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
element = _ref[_j]; | ||
_results1.push(Transparency.render(element.el, model[key], directives[key], options)); | ||
@@ -368,7 +377,7 @@ } | ||
elements = (_base = this.queryCache)[key] || (_base[key] = (function() { | ||
var _i, _len, _ref1, _results; | ||
_ref1 = this.elements; | ||
var _i, _len, _ref, _results; | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
el = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
el = _ref[_i]; | ||
if (Transparency.matcher(el, key)) { | ||
@@ -448,7 +457,7 @@ _results.push(el); | ||
this.templateValue = ((function() { | ||
var _i, _len, _ref1, _results; | ||
_ref1 = getChildNodes(this.el); | ||
var _i, _len, _ref, _results; | ||
_ref = getChildNodes(this.el); | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
child = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
if (child.nodeType === TEXT_NODE) { | ||
@@ -487,8 +496,8 @@ _results.push(child.nodeValue); | ||
Html.prototype.set = function(html) { | ||
var child, _i, _len, _ref1, _results; | ||
var child, _i, _len, _ref, _results; | ||
this.el.innerHTML = html; | ||
_ref1 = this.childNodes; | ||
_ref = this.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
child = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
_results.push(this.el.appendChild(child)); | ||
@@ -553,7 +562,7 @@ } | ||
Element.prototype.reset = function() { | ||
var attribute, name, _ref1, _results; | ||
_ref1 = this.attributes; | ||
var attribute, name, _ref, _results; | ||
_ref = this.attributes; | ||
_results = []; | ||
for (name in _ref1) { | ||
attribute = _ref1[name]; | ||
for (name in _ref) { | ||
attribute = _ref[name]; | ||
_results.push(attribute.set(attribute.templateValue)); | ||
@@ -575,3 +584,3 @@ } | ||
Element.prototype.renderDirectives = function(model, index, attributes) { | ||
var directive, name, value, _ref1, _results; | ||
var directive, name, value, _ref, _results; | ||
_results = []; | ||
@@ -587,3 +596,3 @@ for (name in attributes) { | ||
index: index, | ||
value: ((_ref1 = this.attributes[name]) != null ? _ref1.templateValue : void 0) || '' | ||
value: ((_ref = this.attributes[name]) != null ? _ref.templateValue : void 0) || '' | ||
}); | ||
@@ -615,8 +624,8 @@ if (value != null) { | ||
Select.prototype.render = function(value) { | ||
var option, _i, _len, _ref1, _results; | ||
var option, _i, _len, _ref, _results; | ||
value = value.toString(); | ||
_ref1 = this.elements; | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
option = _ref1[_i]; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
option = _ref[_i]; | ||
if (option.nodeName === 'option') { | ||
@@ -623,0 +632,0 @@ _results.push(option.attr('selected', option.el.value === value)); |
/*! | ||
* transparency - v0.9.1 - 2013-02-21 | ||
* transparency - v0.9.2 - 2013-02-22 | ||
* https://github.com/leonidas/transparency | ||
* Copyright (c) 2013 Jarno Keskikangas <jarno.keskikangas@leonidasoy.fi>; Licensed MIT | ||
*/ | ||
(function(){var t,e,n,r,i,o,u,s,l,h,a,c,p,f,d,m,y,v,g,b,_,N,x,C,A,E,T,w,j,V,D,S,L,k,B,M,Q,H,O=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},P={}.hasOwnProperty,q=function(t,e){function n(){this.constructor=t}for(var r in e)P.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};b=function(t){return function(e){return function(){return t.apply(this,arguments),e.apply(this,arguments)}}},g=function(t){return function(e){return function(){return e.apply(this,arguments),t.apply(this,arguments)}}},_=g(function(){return this}),E=function(t){var e,n;for(n=[],e=t.firstChild;e;)n.push(e),e=e.nextSibling;return n},T=function(t){var e;return e=[],Q(t,e),e},Q=function(t,e){var n,r;for(n=t.firstChild,r=[];n;)n.nodeType===u&&(e.push(new l.createElement(n)),Q(n,e)),r.push(n=n.nextSibling);return r},u=1,d=3,w=function(){return"<:nav></:nav>"!==document.createElement("nav").cloneNode(!0).outerHTML},N="undefined"==typeof document||null===document||w()?function(t){return t.cloneNode(!0)}:function(t){var e,n,r,i,o;if(e=y.clone(t),e.nodeType===u)for(e.removeAttribute(A),o=e.getElementsByTagName("*"),r=0,i=o.length;i>r;r++)n=o[r],n.removeAttribute(A);return e},A="transparency",C=function(t){return t[A]||(t[A]={})},B=function(){},x=function(){return console.log(arguments)},k=B,M=Object.prototype.toString,j=Array.isArray||function(t){return"[object Array]"===M.call(t)},D=function(t){return"[object Date]"===M.call(t)},S=function(t){return t.nodeType===u},L=function(t){var e;return e=typeof t,"object"!==e&&"function"!==e||D(t)},V=function(t){return t===!0||t===!1},y=this.Transparency={},y.render=function(t,e,n,r){var i;return null==e&&(e=[]),null==n&&(n={}),null==r&&(r={}),k=r.debug&&console?x:B,k("Transparency.render:",t,e,n,r),t?(j(e)||(e=[e]),t=(i=C(t)).context||(i.context=new o(t)),t.render(e,n,r).el):void 0},y.jQueryPlugin=_(function(t,e,n){var r,i,o,u;for(u=[],i=0,o=this.length;o>i;i++)r=this[i],u.push(y.render(r,t,e,n));return u}),y.matcher=function(t,e){return t.el.id===e||O.call(t.classNames,e)>=0||t.el.name===e||t.el.getAttribute("data-bind")===e},y.clone=function(t){var e;return"function"==typeof(e=jQuery||Zepto)?e(t).clone()[0]:void 0},null!=(H=jQuery||Zepto)&&(H.fn.render=y.jQueryPlugin),("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define(function(){return y}),o=function(){function t(t){this.el=t,this.template=N(this.el),this.instances=[new c(this.el)],this.instanceCache=[]}var e,n;return n=_(function(){return this.parent=this.el.parentNode,this.parent?(this.nextSibling=this.el.nextSibling,this.parent.removeChild(this.el)):void 0}),e=_(function(){return this.parent?this.nextSibling?this.parent.insertBefore(this.el,this.nextSibling):this.parent.appendChild(this.el):void 0}),t.prototype.render=b(n)(g(e)(_(function(t,e,n){for(var r,i,o,u,s,l,h;t.length<this.instances.length;)this.instanceCache.push(this.instances.pop().remove());for(h=[],i=s=0,l=t.length;l>s;i=++s)u=t[i],(o=this.instances[i])||(o=this.instanceCache.pop()||new c(N(this.template)),this.instances.push(o.appendTo(this.el))),r=[],h.push(o.prepare(u,r).renderValues(u,r).renderDirectives(u,i,e).renderChildren(u,r,e,n));return h}))),t}(),c=function(){function t(t){this.queryCache={},this.childNodes=E(t),this.elements=T(t)}return t.prototype.remove=_(function(){var t,e,n,r,i;for(r=this.childNodes,i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(t.parentNode.removeChild(t));return i}),t.prototype.appendTo=_(function(t){var e,n,r,i,o;for(i=this.childNodes,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(t.appendChild(e));return o}),t.prototype.prepare=_(function(t){var e,n,r,i,o;for(i=this.elements,o=[],n=0,r=i.length;r>n;n++)e=i[n],e.reset(),o.push(C(e.el).model=t);return o}),t.prototype.renderValues=_(function(t,e){var n,r,i,o;if(S(t)&&(n=this.elements[0]))return n.empty().el.appendChild(t);if("object"==typeof t){o=[];for(r in t)P.call(t,r)&&(i=t[r],null!=i&&(L(i)?o.push(function(){var t,e,o,u;for(o=this.matchingElements(r),u=[],t=0,e=o.length;e>t;t++)n=o[t],u.push(n.render(i));return u}.call(this)):"object"==typeof i?o.push(e.push(r)):o.push(void 0)));return o}}),t.prototype.renderDirectives=_(function(t,e,n){var r,i,o,u;u=[];for(o in n)P.call(n,o)&&(r=n[o],"object"==typeof r&&("object"!=typeof t&&(t={value:t}),u.push(function(){var n,u,s,l;for(s=this.matchingElements(o),l=[],n=0,u=s.length;u>n;n++)i=s[n],l.push(i.renderDirectives(t,e,r));return l}.call(this))));return u}),t.prototype.renderChildren=_(function(t,e,n,r){var i,o,u,s,l;for(l=[],u=0,s=e.length;s>u;u++)o=e[u],l.push(function(){var e,u,s,l;for(s=this.matchingElements(o),l=[],e=0,u=s.length;u>e;e++)i=s[e],l.push(y.render(i.el,t[o],n[o],r));return l}.call(this));return l}),t.prototype.matchingElements=function(t){var e,n,r;return n=(r=this.queryCache)[t]||(r[t]=function(){var n,r,i,o;for(i=this.elements,o=[],n=0,r=i.length;r>n;n++)e=i[n],y.matcher(e,t)&&o.push(e);return o}.call(this)),k("Matching elements for '"+t+"':",n),n},t}(),e={Attributes:{},createAttribute:function(r,i,o){var u;return u=e.Attributes[i]||(V(o)?n:t),new u(r,i)}},t=function(){function t(t,e){this.el=t,this.name=e,this.templateValue=this.el.getAttribute(this.name)||""}return t.prototype.set=function(t){return this.el[this.name]=t,this.el.setAttribute(this.name,""+t)},t}(),n=function(t){function e(t,e){this.el=t,this.name=e,this.templateValue=this.el.getAttribute(this.name)||!1}return q(e,t),e.prototype.set=function(t){return this.el[this.name]=t,t?this.el.setAttribute(this.name,this.name):this.el.removeAttribute(this.name)},e}(t),m=function(t){function n(t,e){var n;this.el=t,this.name=e,this.templateValue=function(){var t,e,r,i;for(r=E(this.el),i=[],t=0,e=r.length;e>t;t++)n=r[t],n.nodeType===d&&i.push(n.nodeValue);return i}.call(this).join(""),(this.textNode=this.el.firstChild)?this.textNode.nodeType!==d&&(this.textNode=this.el.insertBefore(this.el.ownerDocument.createTextNode(""),this.textNode)):this.el.appendChild(this.textNode=this.el.ownerDocument.createTextNode(""))}return q(n,t),e.Attributes.text=n,n.prototype.set=function(t){return this.textNode.nodeValue=t},n}(t),h=function(t){function n(t){n.__super__.constructor.call(this,t,"innerHTML"),this.childNodes=E(this.el)}return q(n,t),e.Attributes.html=n,n.prototype.set=function(t){var e,n,r,i,o;for(this.el.innerHTML=t,i=this.childNodes,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(this.el.appendChild(e));return o},n}(t),i=function(t){function n(t){n.__super__.constructor.call(this,t,"class")}return q(n,t),e.Attributes["class"]=n,n}(t),l={Elements:{input:{}},createElement:function(t){var e,n;return e="input"===(n=t.nodeName.toLowerCase())?l.Elements[n][t.type.toLowerCase()]||a:l.Elements[n]||s,new e(t)}},s=function(){function t(t){this.el=t,this.attributes={},this.childNodes=E(this.el),this.nodeName=this.el.nodeName.toLowerCase(),this.classNames=this.el.className.split(" "),this.originalAttributes={}}return t.prototype.empty=_(function(){var t,e;for(e=[];t=this.el.firstChild;)e.push(this.el.removeChild(t));return e}),t.prototype.reset=function(){var t,e,n,r;n=this.attributes,r=[];for(e in n)t=n[e],r.push(t.set(t.templateValue));return r},t.prototype.render=function(t){return this.attr("text",t)},t.prototype.attr=function(t,n){var r,i;return r=(i=this.attributes)[t]||(i[t]=e.createAttribute(this.el,t,n)),r.set(n)},t.prototype.renderDirectives=function(t,e,n){var r,i,o,u,s;s=[];for(i in n)P.call(n,i)&&(r=n[i],"function"==typeof r&&(o=r.call(t,{element:this.el,index:e,value:(null!=(u=this.attributes[i])?u.templateValue:void 0)||""}),null!=o?s.push(this.attr(i,o)):s.push(void 0)));return s},t}(),f=function(t){function e(t){e.__super__.constructor.call(this,t),this.elements=T(t)}return q(e,t),l.Elements.select=e,e.prototype.render=function(t){var e,n,r,i,o;for(t=""+t,i=this.elements,o=[],n=0,r=i.length;r>n;n++)e=i[n],"option"===e.nodeName&&o.push(e.attr("selected",e.el.value===t));return o},e}(s),v=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}var n,r,i,o;for(q(e,t),n=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],i=0,o=n.length;o>i;i++)r=n[i],l.Elements[r]=e;return e.prototype.attr=function(t,n){return"text"!==t&&"html"!==t?e.__super__.attr.call(this,t,n):void 0},e}(s),a=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return q(e,t),e.prototype.render=function(t){return this.attr("value",t)},e}(v),r=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return q(e,t),l.Elements.input.checkbox=e,e.prototype.render=function(t){return this.attr("checked",Boolean(t))},e}(a),p=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return q(e,t),l.Elements.input.radio=e,e}(r)}).call(this); | ||
(function(){var t,e,n,r,i,o,u,s,l,h,a,c,p,f,d,m,y,v,g,b,_,N,x,C,A,E,T,j,w,V,D,S,L,k,Q,B,M,H,O=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},P={}.hasOwnProperty,Z=function(t,e){function n(){this.constructor=t}for(var r in e)P.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};b=function(t){return function(e){return function(){return t.apply(this,arguments),e.apply(this,arguments)}}},g=function(t){return function(e){return function(){return e.apply(this,arguments),t.apply(this,arguments)}}},_=g(function(){return this}),B=function(t){return"undefined"!=typeof jQuery&&null!==jQuery||"undefined"!=typeof Zepto&&null!==Zepto?function(){return t(arguments)}(jQuery||Zepto):void 0},E=function(t){var e,n;for(n=[],e=t.firstChild;e;)n.push(e),e=e.nextSibling;return n},T=function(t){var e;return e=[],H(t,e),e},H=function(t,e){var n,r;for(n=t.firstChild,r=[];n;)n.nodeType===u&&(e.push(new l.createElement(n)),H(n,e)),r.push(n=n.nextSibling);return r},u=1,d=3,j=function(){return"<:nav></:nav>"!==document.createElement("nav").cloneNode(!0).outerHTML},N="undefined"==typeof document||null===document||j()?function(t){return t.cloneNode(!0)}:function(t){var e,n,r,i,o;if(e=y.clone(t),e.nodeType===u)for(e.removeAttribute(A),o=e.getElementsByTagName("*"),r=0,i=o.length;i>r;r++)n=o[r],n.removeAttribute(A);return e},A="transparency",C=function(t){return t[A]||(t[A]={})},Q=function(){},x=function(){return console.log(arguments)},k=Q,M=Object.prototype.toString,w=Array.isArray||function(t){return"[object Array]"===M.call(t)},D=function(t){return"[object Date]"===M.call(t)},S=function(t){return t.nodeType===u},L=function(t){var e;return e=typeof t,"object"!==e&&"function"!==e||D(t)},V=function(t){return t===!0||t===!1},y=this.Transparency={},y.render=function(t,e,n,r){var i;return null==e&&(e=[]),null==n&&(n={}),null==r&&(r={}),k=r.debug&&console?x:Q,k("Transparency.render:",t,e,n,r),t?(w(e)||(e=[e]),t=(i=C(t)).context||(i.context=new o(t)),t.render(e,n,r).el):void 0},y.jQueryPlugin=_(function(t,e,n){var r,i,o,u;for(u=[],i=0,o=this.length;o>i;i++)r=this[i],u.push(y.render(r,t,e,n));return u}),y.matcher=function(t,e){return t.el.id===e||O.call(t.classNames,e)>=0||t.el.name===e||t.el.getAttribute("data-bind")===e},y.clone=B(function(){return function(t){return $(t).clone()[0]}}),B(function(){return $.fn.render=y.jQueryPlugin}),("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define(function(){return y}),o=function(){function t(t){this.el=t,this.template=N(this.el),this.instances=[new c(this.el)],this.instanceCache=[]}var e,n;return n=_(function(){return this.parent=this.el.parentNode,this.parent?(this.nextSibling=this.el.nextSibling,this.parent.removeChild(this.el)):void 0}),e=_(function(){return this.parent?this.nextSibling?this.parent.insertBefore(this.el,this.nextSibling):this.parent.appendChild(this.el):void 0}),t.prototype.render=b(n)(g(e)(_(function(t,e,n){for(var r,i,o,u,s,l,h;t.length<this.instances.length;)this.instanceCache.push(this.instances.pop().remove());for(h=[],i=s=0,l=t.length;l>s;i=++s)u=t[i],(o=this.instances[i])||(o=this.instanceCache.pop()||new c(N(this.template)),this.instances.push(o.appendTo(this.el))),r=[],h.push(o.prepare(u,r).renderValues(u,r).renderDirectives(u,i,e).renderChildren(u,r,e,n));return h}))),t}(),c=function(){function t(t){this.queryCache={},this.childNodes=E(t),this.elements=T(t)}return t.prototype.remove=_(function(){var t,e,n,r,i;for(r=this.childNodes,i=[],e=0,n=r.length;n>e;e++)t=r[e],i.push(t.parentNode.removeChild(t));return i}),t.prototype.appendTo=_(function(t){var e,n,r,i,o;for(i=this.childNodes,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(t.appendChild(e));return o}),t.prototype.prepare=_(function(t){var e,n,r,i,o;for(i=this.elements,o=[],n=0,r=i.length;r>n;n++)e=i[n],e.reset(),o.push(C(e.el).model=t);return o}),t.prototype.renderValues=_(function(t,e){var n,r,i,o;if(S(t)&&(n=this.elements[0]))return n.empty().el.appendChild(t);if("object"==typeof t){o=[];for(r in t)P.call(t,r)&&(i=t[r],null!=i&&(L(i)?o.push(function(){var t,e,o,u;for(o=this.matchingElements(r),u=[],t=0,e=o.length;e>t;t++)n=o[t],u.push(n.render(i));return u}.call(this)):"object"==typeof i?o.push(e.push(r)):o.push(void 0)));return o}}),t.prototype.renderDirectives=_(function(t,e,n){var r,i,o,u;u=[];for(o in n)P.call(n,o)&&(r=n[o],"object"==typeof r&&("object"!=typeof t&&(t={value:t}),u.push(function(){var n,u,s,l;for(s=this.matchingElements(o),l=[],n=0,u=s.length;u>n;n++)i=s[n],l.push(i.renderDirectives(t,e,r));return l}.call(this))));return u}),t.prototype.renderChildren=_(function(t,e,n,r){var i,o,u,s,l;for(l=[],u=0,s=e.length;s>u;u++)o=e[u],l.push(function(){var e,u,s,l;for(s=this.matchingElements(o),l=[],e=0,u=s.length;u>e;e++)i=s[e],l.push(y.render(i.el,t[o],n[o],r));return l}.call(this));return l}),t.prototype.matchingElements=function(t){var e,n,r;return n=(r=this.queryCache)[t]||(r[t]=function(){var n,r,i,o;for(i=this.elements,o=[],n=0,r=i.length;r>n;n++)e=i[n],y.matcher(e,t)&&o.push(e);return o}.call(this)),k("Matching elements for '"+t+"':",n),n},t}(),e={Attributes:{},createAttribute:function(r,i,o){var u;return u=e.Attributes[i]||(V(o)?n:t),new u(r,i)}},t=function(){function t(t,e){this.el=t,this.name=e,this.templateValue=this.el.getAttribute(this.name)||""}return t.prototype.set=function(t){return this.el[this.name]=t,this.el.setAttribute(this.name,""+t)},t}(),n=function(t){function e(t,e){this.el=t,this.name=e,this.templateValue=this.el.getAttribute(this.name)||!1}return Z(e,t),e.prototype.set=function(t){return this.el[this.name]=t,t?this.el.setAttribute(this.name,this.name):this.el.removeAttribute(this.name)},e}(t),m=function(t){function n(t,e){var n;this.el=t,this.name=e,this.templateValue=function(){var t,e,r,i;for(r=E(this.el),i=[],t=0,e=r.length;e>t;t++)n=r[t],n.nodeType===d&&i.push(n.nodeValue);return i}.call(this).join(""),(this.textNode=this.el.firstChild)?this.textNode.nodeType!==d&&(this.textNode=this.el.insertBefore(this.el.ownerDocument.createTextNode(""),this.textNode)):this.el.appendChild(this.textNode=this.el.ownerDocument.createTextNode(""))}return Z(n,t),e.Attributes.text=n,n.prototype.set=function(t){return this.textNode.nodeValue=t},n}(t),h=function(t){function n(t){n.__super__.constructor.call(this,t,"innerHTML"),this.childNodes=E(this.el)}return Z(n,t),e.Attributes.html=n,n.prototype.set=function(t){var e,n,r,i,o;for(this.el.innerHTML=t,i=this.childNodes,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(this.el.appendChild(e));return o},n}(t),i=function(t){function n(t){n.__super__.constructor.call(this,t,"class")}return Z(n,t),e.Attributes["class"]=n,n}(t),l={Elements:{input:{}},createElement:function(t){var e,n;return e="input"===(n=t.nodeName.toLowerCase())?l.Elements[n][t.type.toLowerCase()]||a:l.Elements[n]||s,new e(t)}},s=function(){function t(t){this.el=t,this.attributes={},this.childNodes=E(this.el),this.nodeName=this.el.nodeName.toLowerCase(),this.classNames=this.el.className.split(" "),this.originalAttributes={}}return t.prototype.empty=_(function(){var t,e;for(e=[];t=this.el.firstChild;)e.push(this.el.removeChild(t));return e}),t.prototype.reset=function(){var t,e,n,r;n=this.attributes,r=[];for(e in n)t=n[e],r.push(t.set(t.templateValue));return r},t.prototype.render=function(t){return this.attr("text",t)},t.prototype.attr=function(t,n){var r,i;return r=(i=this.attributes)[t]||(i[t]=e.createAttribute(this.el,t,n)),r.set(n)},t.prototype.renderDirectives=function(t,e,n){var r,i,o,u,s;s=[];for(i in n)P.call(n,i)&&(r=n[i],"function"==typeof r&&(o=r.call(t,{element:this.el,index:e,value:(null!=(u=this.attributes[i])?u.templateValue:void 0)||""}),null!=o?s.push(this.attr(i,o)):s.push(void 0)));return s},t}(),f=function(t){function e(t){e.__super__.constructor.call(this,t),this.elements=T(t)}return Z(e,t),l.Elements.select=e,e.prototype.render=function(t){var e,n,r,i,o;for(t=""+t,i=this.elements,o=[],n=0,r=i.length;r>n;n++)e=i[n],"option"===e.nodeName&&o.push(e.attr("selected",e.el.value===t));return o},e}(s),v=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}var n,r,i,o;for(Z(e,t),n=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],i=0,o=n.length;o>i;i++)r=n[i],l.Elements[r]=e;return e.prototype.attr=function(t,n){return"text"!==t&&"html"!==t?e.__super__.attr.call(this,t,n):void 0},e}(s),a=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Z(e,t),e.prototype.render=function(t){return this.attr("value",t)},e}(v),r=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Z(e,t),l.Elements.input.checkbox=e,e.prototype.render=function(t){return this.attr("checked",Boolean(t))},e}(a),p=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Z(e,t),l.Elements.input.radio=e,e}(r)}).call(this); |
{ | ||
"name": "transparency", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"main": "dist/transparency", | ||
@@ -5,0 +5,0 @@ "description": "Transparency is a minimal template engine for browsers. It maps JSON objects to DOM elements with zero configuration.", |
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
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
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
4152047
114
21007