transparency
Advanced tools
Comparing version 0.10.0 to 0.11.0
{ | ||
"name": "transparency", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"main": "./dist/transparency.js", | ||
"ignore": [ | ||
"**/*", | ||
"!bower.json", | ||
"!dist/transparency*.js" | ||
"!dist/transparency.js", | ||
"!dist/transparency.min.js" | ||
], | ||
@@ -10,0 +10,0 @@ "dependencies": {}, |
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var $, Context, Transparency, helpers, _, | ||
__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; }; | ||
var $, Context, Transparency, _, helpers, | ||
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; }; | ||
@@ -14,3 +14,3 @@ _ = require('../lib/lodash.js'); | ||
Transparency.render = function(context, models, directives, options) { | ||
var log, _base; | ||
var base, log; | ||
if (models == null) { | ||
@@ -33,3 +33,3 @@ models = []; | ||
} | ||
context = (_base = helpers.data(context)).context || (_base.context = new Context(context, Transparency)); | ||
context = (base = helpers.data(context)).context || (base.context = new Context(context, Transparency)); | ||
return context.render(models, directives, options).el; | ||
@@ -39,3 +39,3 @@ }; | ||
Transparency.matcher = function(element, key) { | ||
return element.el.id === key || __indexOf.call(element.classNames, key) >= 0 || element.el.name === key || element.el.getAttribute('data-bind') === key; | ||
return element.el.id === key || indexOf.call(element.classNames, key) >= 0 || element.el.name === key || element.el.getAttribute('data-bind') === key; | ||
}; | ||
@@ -48,9 +48,9 @@ | ||
Transparency.jQueryPlugin = helpers.chainable(function(models, directives, options) { | ||
var context, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = this.length; _i < _len; _i++) { | ||
context = this[_i]; | ||
_results.push(Transparency.render(context, models, directives, options)); | ||
var context, i, len, results; | ||
results = []; | ||
for (i = 0, len = this.length; i < len; i++) { | ||
context = this[i]; | ||
results.push(Transparency.render(context, models, directives, options)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
@@ -80,5 +80,5 @@ | ||
},{"../lib/lodash.js":7,"./context":3,"./helpers":5}],2:[function(require,module,exports){ | ||
var Attribute, AttributeFactory, BooleanAttribute, Class, Html, Text, helpers, _, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var Attribute, AttributeFactory, BooleanAttribute, Class, Html, Text, _, helpers, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -99,5 +99,5 @@ _ = require('../lib/lodash'); | ||
Attribute = (function() { | ||
function Attribute(el, name) { | ||
this.el = el; | ||
this.name = name; | ||
function Attribute(el1, name1) { | ||
this.el = el1; | ||
this.name = name1; | ||
this.templateValue = this.el.getAttribute(this.name) || ''; | ||
@@ -115,17 +115,17 @@ } | ||
BooleanAttribute = (function(_super) { | ||
var BOOLEAN_ATTRIBUTES, name, _i, _len; | ||
BooleanAttribute = (function(superClass) { | ||
var BOOLEAN_ATTRIBUTES, i, len, name; | ||
__extends(BooleanAttribute, _super); | ||
extend(BooleanAttribute, superClass); | ||
BOOLEAN_ATTRIBUTES = ['hidden', 'async', 'defer', 'autofocus', 'formnovalidate', 'disabled', 'autofocus', 'formnovalidate', 'multiple', 'readonly', 'required', 'checked', 'scoped', 'reversed', 'selected', 'loop', 'muted', 'autoplay', 'controls', 'seamless', 'default', 'ismap', 'novalidate', 'open', 'typemustmatch', 'truespeed']; | ||
for (_i = 0, _len = BOOLEAN_ATTRIBUTES.length; _i < _len; _i++) { | ||
name = BOOLEAN_ATTRIBUTES[_i]; | ||
for (i = 0, len = BOOLEAN_ATTRIBUTES.length; i < len; i++) { | ||
name = BOOLEAN_ATTRIBUTES[i]; | ||
AttributeFactory.Attributes[name] = BooleanAttribute; | ||
} | ||
function BooleanAttribute(el, name) { | ||
this.el = el; | ||
this.name = name; | ||
function BooleanAttribute(el1, name1) { | ||
this.el = el1; | ||
this.name = name1; | ||
this.templateValue = this.el.getAttribute(this.name) || false; | ||
@@ -147,22 +147,22 @@ } | ||
Text = (function(_super) { | ||
__extends(Text, _super); | ||
Text = (function(superClass) { | ||
extend(Text, superClass); | ||
AttributeFactory.Attributes['text'] = Text; | ||
function Text(el, name) { | ||
function Text(el1, name1) { | ||
var child; | ||
this.el = el; | ||
this.name = name; | ||
this.el = el1; | ||
this.name = name1; | ||
this.templateValue = ((function() { | ||
var _i, _len, _ref, _results; | ||
_ref = this.el.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
var i, len, ref, results; | ||
ref = this.el.childNodes; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
child = ref[i]; | ||
if (child.nodeType === helpers.TEXT_NODE) { | ||
_results.push(child.nodeValue); | ||
results.push(child.nodeValue); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)).join(''); | ||
@@ -178,3 +178,3 @@ this.children = _.toArray(this.el.children); | ||
Text.prototype.set = function(text) { | ||
var child, _i, _len, _ref, _results; | ||
var child, i, len, ref, results; | ||
while (child = this.el.firstChild) { | ||
@@ -185,9 +185,9 @@ this.el.removeChild(child); | ||
this.el.appendChild(this.textNode); | ||
_ref = this.children; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
_results.push(this.el.appendChild(child)); | ||
ref = this.children; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
child = ref[i]; | ||
results.push(this.el.appendChild(child)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -199,9 +199,9 @@ | ||
Html = (function(_super) { | ||
__extends(Html, _super); | ||
Html = (function(superClass) { | ||
extend(Html, superClass); | ||
AttributeFactory.Attributes['html'] = Html; | ||
function Html(el) { | ||
this.el = el; | ||
function Html(el1) { | ||
this.el = el1; | ||
this.templateValue = ''; | ||
@@ -212,3 +212,3 @@ this.children = _.toArray(this.el.children); | ||
Html.prototype.set = function(html) { | ||
var child, _i, _len, _ref, _results; | ||
var child, i, len, ref, results; | ||
while (child = this.el.firstChild) { | ||
@@ -218,9 +218,9 @@ this.el.removeChild(child); | ||
this.el.innerHTML = html + this.templateValue; | ||
_ref = this.children; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
_results.push(this.el.appendChild(child)); | ||
ref = this.children; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
child = ref[i]; | ||
results.push(this.el.appendChild(child)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -232,4 +232,4 @@ | ||
Class = (function(_super) { | ||
__extends(Class, _super); | ||
Class = (function(superClass) { | ||
extend(Class, superClass); | ||
@@ -247,5 +247,5 @@ AttributeFactory.Attributes['class'] = Class; | ||
},{"../lib/lodash":7,"./helpers":5}],3:[function(require,module,exports){ | ||
var Context, Instance, after, before, chainable, cloneNode, _ref; | ||
var Context, Instance, after, before, chainable, cloneNode, ref; | ||
_ref = require('./helpers'), before = _ref.before, after = _ref.after, chainable = _ref.chainable, cloneNode = _ref.cloneNode; | ||
ref = require('./helpers'), before = ref.before, after = ref.after, chainable = ref.chainable, cloneNode = ref.cloneNode; | ||
@@ -284,3 +284,3 @@ Instance = require('./instance'); | ||
Context.prototype.render = before(detach)(after(attach)(chainable(function(models, directives, options) { | ||
var children, index, instance, model, _i, _len, _results; | ||
var children, i, index, instance, len, model, results; | ||
while (models.length < this.instances.length) { | ||
@@ -293,10 +293,10 @@ this.instanceCache.push(this.instances.pop().remove()); | ||
} | ||
_results = []; | ||
for (index = _i = 0, _len = models.length; _i < _len; index = ++_i) { | ||
results = []; | ||
for (index = i = 0, len = models.length; i < len; index = ++i) { | ||
model = models[index]; | ||
instance = this.instances[index]; | ||
children = []; | ||
_results.push(instance.prepare(model, children).renderValues(model, children).renderDirectives(model, index, directives).renderChildren(model, children, directives, options)); | ||
results.push(instance.prepare(model, children).renderValues(model, children).renderDirectives(model, index, directives).renderChildren(model, children, directives, options)); | ||
} | ||
return _results; | ||
return results; | ||
}))); | ||
@@ -309,5 +309,5 @@ | ||
},{"./helpers":5,"./instance":6}],4:[function(require,module,exports){ | ||
var AttributeFactory, Checkbox, Element, ElementFactory, Input, Radio, Select, TextArea, VoidElement, helpers, _, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var AttributeFactory, Checkbox, Element, ElementFactory, Input, Radio, Select, TextArea, VoidElement, _, helpers, | ||
hasProp = {}.hasOwnProperty, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
@@ -336,4 +336,4 @@ _ = require('../lib/lodash.js'); | ||
Element = (function() { | ||
function Element(el) { | ||
this.el = el; | ||
function Element(el1) { | ||
this.el = el1; | ||
this.attributes = {}; | ||
@@ -355,10 +355,10 @@ this.childNodes = _.toArray(this.el.childNodes); | ||
Element.prototype.reset = function() { | ||
var attribute, name, _ref, _results; | ||
_ref = this.attributes; | ||
_results = []; | ||
for (name in _ref) { | ||
attribute = _ref[name]; | ||
_results.push(attribute.set(attribute.templateValue)); | ||
var attribute, name, ref, results; | ||
ref = this.attributes; | ||
results = []; | ||
for (name in ref) { | ||
attribute = ref[name]; | ||
results.push(attribute.set(attribute.templateValue)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -371,4 +371,4 @@ | ||
Element.prototype.attr = function(name, value) { | ||
var attribute, _base; | ||
attribute = (_base = this.attributes)[name] || (_base[name] = AttributeFactory.createAttribute(this.el, name, value)); | ||
var attribute, base; | ||
attribute = (base = this.attributes)[name] || (base[name] = AttributeFactory.createAttribute(this.el, name, value)); | ||
if (value != null) { | ||
@@ -381,6 +381,6 @@ attribute.set(value); | ||
Element.prototype.renderDirectives = function(model, index, attributes) { | ||
var directive, name, value, _results; | ||
_results = []; | ||
var directive, name, results, value; | ||
results = []; | ||
for (name in attributes) { | ||
if (!__hasProp.call(attributes, name)) continue; | ||
if (!hasProp.call(attributes, name)) continue; | ||
directive = attributes[name]; | ||
@@ -396,8 +396,8 @@ if (!(typeof directive === 'function')) { | ||
if (value != null) { | ||
_results.push(this.attr(name, value)); | ||
results.push(this.attr(name, value)); | ||
} else { | ||
_results.push(void 0); | ||
results.push(void 0); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -409,4 +409,4 @@ | ||
Select = (function(_super) { | ||
__extends(Select, _super); | ||
Select = (function(superClass) { | ||
extend(Select, superClass); | ||
@@ -421,13 +421,13 @@ ElementFactory.Elements['select'] = Select; | ||
Select.prototype.render = function(value) { | ||
var option, _i, _len, _ref, _results; | ||
var i, len, option, ref, results; | ||
value = value.toString(); | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
option = _ref[_i]; | ||
ref = this.elements; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
option = ref[i]; | ||
if (option.nodeName === 'option') { | ||
_results.push(option.attr('selected', option.el.value === value)); | ||
results.push(option.attr('selected', option.el.value === value)); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -439,6 +439,6 @@ | ||
VoidElement = (function(_super) { | ||
var VOID_ELEMENTS, nodeName, _i, _len; | ||
VoidElement = (function(superClass) { | ||
var VOID_ELEMENTS, i, len, nodeName; | ||
__extends(VoidElement, _super); | ||
extend(VoidElement, superClass); | ||
@@ -451,4 +451,4 @@ function VoidElement() { | ||
for (_i = 0, _len = VOID_ELEMENTS.length; _i < _len; _i++) { | ||
nodeName = VOID_ELEMENTS[_i]; | ||
for (i = 0, len = VOID_ELEMENTS.length; i < len; i++) { | ||
nodeName = VOID_ELEMENTS[i]; | ||
ElementFactory.Elements[nodeName] = VoidElement; | ||
@@ -467,4 +467,4 @@ } | ||
Input = (function(_super) { | ||
__extends(Input, _super); | ||
Input = (function(superClass) { | ||
extend(Input, superClass); | ||
@@ -483,4 +483,4 @@ function Input() { | ||
TextArea = (function(_super) { | ||
__extends(TextArea, _super); | ||
TextArea = (function(superClass) { | ||
extend(TextArea, superClass); | ||
@@ -497,4 +497,4 @@ function TextArea() { | ||
Checkbox = (function(_super) { | ||
__extends(Checkbox, _super); | ||
Checkbox = (function(superClass) { | ||
extend(Checkbox, superClass); | ||
@@ -515,4 +515,4 @@ function Checkbox() { | ||
Radio = (function(_super) { | ||
__extends(Radio, _super); | ||
Radio = (function(superClass) { | ||
extend(Radio, superClass); | ||
@@ -530,3 +530,3 @@ function Radio() { | ||
},{"../lib/lodash.js":7,"./attributeFactory":2,"./helpers":5}],5:[function(require,module,exports){ | ||
var ElementFactory, expando, html5Clone, _getElements; | ||
var ElementFactory, _getElements, expando, html5Clone; | ||
@@ -573,5 +573,5 @@ ElementFactory = require('./elementFactory'); | ||
_getElements = function(template, elements) { | ||
var child, _results; | ||
var child, results; | ||
child = template.firstChild; | ||
_results = []; | ||
results = []; | ||
while (child) { | ||
@@ -582,5 +582,5 @@ if (child.nodeType === exports.ELEMENT_NODE) { | ||
} | ||
_results.push(child = child.nextSibling); | ||
results.push(child = child.nextSibling); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -599,9 +599,9 @@ | ||
} : function(node) { | ||
var cloned, element, _i, _len, _ref; | ||
var cloned, element, i, len, ref; | ||
cloned = Transparency.clone(node); | ||
if (cloned.nodeType === exports.ELEMENT_NODE) { | ||
cloned.removeAttribute(expando); | ||
_ref = cloned.getElementsByTagName('*'); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
ref = cloned.getElementsByTagName('*'); | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
element.removeAttribute(expando); | ||
@@ -628,4 +628,4 @@ } | ||
},{"./elementFactory":4}],6:[function(require,module,exports){ | ||
var Instance, chainable, helpers, _, | ||
__hasProp = {}.hasOwnProperty; | ||
var Instance, _, chainable, helpers, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -645,64 +645,64 @@ _ = require('../lib/lodash.js'); | ||
Instance.prototype.remove = chainable(function() { | ||
var node, _i, _len, _ref, _results; | ||
_ref = this.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(node.parentNode.removeChild(node)); | ||
var i, len, node, ref, results; | ||
ref = this.childNodes; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
node = ref[i]; | ||
results.push(node.parentNode.removeChild(node)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.appendTo = chainable(function(parent) { | ||
var node, _i, _len, _ref, _results; | ||
_ref = this.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(parent.appendChild(node)); | ||
var i, len, node, ref, results; | ||
ref = this.childNodes; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
node = ref[i]; | ||
results.push(parent.appendChild(node)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.prepare = chainable(function(model) { | ||
var element, _i, _len, _ref, _results; | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
var element, i, len, ref, results; | ||
ref = this.elements; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
element.reset(); | ||
_results.push(helpers.data(element.el).model = model); | ||
results.push(helpers.data(element.el).model = model); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.renderValues = chainable(function(model, children) { | ||
var element, key, value, _results; | ||
var element, key, results, value; | ||
if (_.isElement(model) && (element = this.elements[0])) { | ||
return element.empty().el.appendChild(model); | ||
} else if (typeof model === 'object') { | ||
_results = []; | ||
results = []; | ||
for (key in model) { | ||
if (!__hasProp.call(model, key)) continue; | ||
if (!hasProp.call(model, key)) continue; | ||
value = model[key]; | ||
if (value != null) { | ||
if (_.isString(value) || _.isNumber(value) || _.isBoolean(value) || _.isDate(value)) { | ||
_results.push((function() { | ||
var _i, _len, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
_results1.push(element.render(value)); | ||
results.push((function() { | ||
var i, len, ref, results1; | ||
ref = this.matchingElements(key); | ||
results1 = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
results1.push(element.render(value)); | ||
} | ||
return _results1; | ||
return results1; | ||
}).call(this)); | ||
} else if (typeof value === 'object') { | ||
_results.push(children.push(key)); | ||
results.push(children.push(key)); | ||
} else { | ||
_results.push(void 0); | ||
results.push(void 0); | ||
} | ||
} | ||
} | ||
return _results; | ||
return results; | ||
} | ||
@@ -712,6 +712,6 @@ }); | ||
Instance.prototype.renderDirectives = chainable(function(model, index, directives) { | ||
var attributes, element, key, _results; | ||
_results = []; | ||
var attributes, element, key, results; | ||
results = []; | ||
for (key in directives) { | ||
if (!__hasProp.call(directives, key)) continue; | ||
if (!hasProp.call(directives, key)) continue; | ||
attributes = directives[key]; | ||
@@ -726,48 +726,48 @@ if (!(typeof attributes === 'object')) { | ||
} | ||
_results.push((function() { | ||
var _i, _len, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
_results1.push(element.renderDirectives(model, index, attributes)); | ||
results.push((function() { | ||
var i, len, ref, results1; | ||
ref = this.matchingElements(key); | ||
results1 = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
results1.push(element.renderDirectives(model, index, attributes)); | ||
} | ||
return _results1; | ||
return results1; | ||
}).call(this)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.renderChildren = chainable(function(model, children, directives, options) { | ||
var element, key, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = children.length; _i < _len; _i++) { | ||
key = children[_i]; | ||
_results.push((function() { | ||
var _j, _len1, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
element = _ref[_j]; | ||
_results1.push(this.Transparency.render(element.el, model[key], directives[key], options)); | ||
var element, i, key, len, results; | ||
results = []; | ||
for (i = 0, len = children.length; i < len; i++) { | ||
key = children[i]; | ||
results.push((function() { | ||
var j, len1, ref, results1; | ||
ref = this.matchingElements(key); | ||
results1 = []; | ||
for (j = 0, len1 = ref.length; j < len1; j++) { | ||
element = ref[j]; | ||
results1.push(this.Transparency.render(element.el, model[key], directives[key], options)); | ||
} | ||
return _results1; | ||
return results1; | ||
}).call(this)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.matchingElements = function(key) { | ||
var el, elements, _base; | ||
elements = (_base = this.queryCache)[key] || (_base[key] = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
el = _ref[_i]; | ||
var base, el, elements; | ||
elements = (base = this.queryCache)[key] || (base[key] = (function() { | ||
var i, len, ref, results; | ||
ref = this.elements; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
el = ref[i]; | ||
if (this.Transparency.matcher(el, key)) { | ||
_results.push(el); | ||
results.push(el); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)); | ||
@@ -774,0 +774,0 @@ helpers.log("Matching elements for '" + key + "':", elements); |
@@ -1,1 +0,1 @@ | ||
!function t(e,n,r){function i(s,u){if(!n[s]){if(!e[s]){var l="function"==typeof require&&require;if(!u&&l)return l(s,!0);if(o)return o(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var h=n[s]={exports:{}};e[s][0].call(h.exports,function(t){var n=e[s][1][t];return i(n?n:t)},h,h.exports,t,e,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e){var n,r,i,o,s,u=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};s=t("../lib/lodash.js"),o=t("./helpers"),r=t("./context"),i={},i.render=function(t,e,n,u){var l,a;return null==e&&(e=[]),null==n&&(n={}),null==u&&(u={}),l=u.debug&&console?o.consoleLogger:o.nullLogger,l("Transparency.render:",t,e,n,u),t?(s.isArray(e)||(e=[e]),t=(a=o.data(t)).context||(a.context=new r(t,i)),t.render(e,n,u).el):void 0},i.matcher=function(t,e){return t.el.id===e||u.call(t.classNames,e)>=0||t.el.name===e||t.el.getAttribute("data-bind")===e},i.clone=function(t){return n(t).clone()[0]},i.jQueryPlugin=o.chainable(function(t,e,n){var r,o,s,u;for(u=[],o=0,s=this.length;s>o;o++)r=this[o],u.push(i.render(r,t,e,n));return u}),("undefined"!=typeof jQuery&&null!==jQuery||"undefined"!=typeof Zepto&&null!==Zepto)&&(n=jQuery||Zepto,null!=n&&(n.fn.render=i.jQueryPlugin)),("undefined"!=typeof e&&null!==e?e.exports:void 0)&&(e.exports=i),"undefined"!=typeof window&&null!==window&&(window.Transparency=i),("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define(function(){return i})},{"../lib/lodash.js":7,"./context":3,"./helpers":5}],2:[function(t,e){var n,r,i,o,s,u,l,a,h={}.hasOwnProperty,c=function(t,e){function n(){this.constructor=t}for(var r in e)h.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};a=t("../lib/lodash"),l=t("./helpers"),e.exports=r={Attributes:{},createAttribute:function(t,e){var i;return new(i=r.Attributes[e]||n)(t,e)}},n=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.toString())},t}(),i=function(t){function e(t,e){this.el=t,this.name=e,this.templateValue=this.el.getAttribute(this.name)||!1}var n,i,o,s;for(c(e,t),n=["hidden","async","defer","autofocus","formnovalidate","disabled","autofocus","formnovalidate","multiple","readonly","required","checked","scoped","reversed","selected","loop","muted","autoplay","controls","seamless","default","ismap","novalidate","open","typemustmatch","truespeed"],o=0,s=n.length;s>o;o++)i=n[o],r.Attributes[i]=e;return 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}(n),u=function(t){function e(t,e){var n;this.el=t,this.name=e,this.templateValue=function(){var t,e,r,i;for(r=this.el.childNodes,i=[],t=0,e=r.length;e>t;t++)n=r[t],n.nodeType===l.TEXT_NODE&&i.push(n.nodeValue);return i}.call(this).join(""),this.children=a.toArray(this.el.children),(this.textNode=this.el.firstChild)?this.textNode.nodeType!==l.TEXT_NODE&&(this.textNode=this.el.insertBefore(this.el.ownerDocument.createTextNode(""),this.textNode)):this.el.appendChild(this.textNode=this.el.ownerDocument.createTextNode(""))}return c(e,t),r.Attributes.text=e,e.prototype.set=function(t){for(var e,n,r,i,o;e=this.el.firstChild;)this.el.removeChild(e);for(this.textNode.nodeValue=t,this.el.appendChild(this.textNode),i=this.children,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(this.el.appendChild(e));return o},e}(n),s=function(t){function e(t){this.el=t,this.templateValue="",this.children=a.toArray(this.el.children)}return c(e,t),r.Attributes.html=e,e.prototype.set=function(t){for(var e,n,r,i,o;e=this.el.firstChild;)this.el.removeChild(e);for(this.el.innerHTML=t+this.templateValue,i=this.children,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(this.el.appendChild(e));return o},e}(n),o=function(t){function e(t){e.__super__.constructor.call(this,t,"class")}return c(e,t),r.Attributes["class"]=e,e}(n)},{"../lib/lodash":7,"./helpers":5}],3:[function(t,e){var n,r,i,o,s,u,l;l=t("./helpers"),o=l.before,i=l.after,s=l.chainable,u=l.cloneNode,r=t("./instance"),e.exports=n=function(){function t(t,e){this.el=t,this.Transparency=e,this.template=u(this.el),this.instances=[new r(this.el,this.Transparency)],this.instanceCache=[]}var e,n;return n=s(function(){return this.parent=this.el.parentNode,this.parent?(this.nextSibling=this.el.nextSibling,this.parent.removeChild(this.el)):void 0}),e=s(function(){return this.parent?this.nextSibling?this.parent.insertBefore(this.el,this.nextSibling):this.parent.appendChild(this.el):void 0}),t.prototype.render=o(n)(i(e)(s(function(t,e,n){for(var i,o,s,l,a,h,c;t.length<this.instances.length;)this.instanceCache.push(this.instances.pop().remove());for(;t.length>this.instances.length;)s=this.instanceCache.pop()||new r(u(this.template),this.Transparency),this.instances.push(s.appendTo(this.el));for(c=[],o=a=0,h=t.length;h>a;o=++a)l=t[o],s=this.instances[o],i=[],c.push(s.prepare(l,i).renderValues(l,i).renderDirectives(l,o,e).renderChildren(l,i,e,n));return c}))),t}()},{"./helpers":5,"./instance":6}],4:[function(t,e){var n,r,i,o,s,u,l,a,h,c,p,f={}.hasOwnProperty,d=function(t,e){function n(){this.constructor=t}for(var r in e)f.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};p=t("../lib/lodash.js"),c=t("./helpers"),n=t("./attributeFactory"),e.exports=o={Elements:{input:{}},createElement:function(t){var e,n;return new(e="input"===(n=t.nodeName.toLowerCase())?o.Elements[n][t.type.toLowerCase()]||s:o.Elements[n]||i)(t)}},i=function(){function t(t){this.el=t,this.attributes={},this.childNodes=p.toArray(this.el.childNodes),this.nodeName=this.el.nodeName.toLowerCase(),this.classNames=this.el.className.split(" "),this.originalAttributes={}}return t.prototype.empty=function(){for(var t;t=this.el.firstChild;)this.el.removeChild(t);return this},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,e){var r,i;return r=(i=this.attributes)[t]||(i[t]=n.createAttribute(this.el,t,e)),null!=e&&r.set(e),r},t.prototype.renderDirectives=function(t,e,n){var r,i,o,s;s=[];for(i in n)f.call(n,i)&&(r=n[i],"function"==typeof r&&(o=r.call(t,{element:this.el,index:e,value:this.attr(i).templateValue}),s.push(null!=o?this.attr(i,o):void 0)));return s},t}(),l=function(t){function e(t){e.__super__.constructor.call(this,t),this.elements=c.getElements(t)}return d(e,t),o.Elements.select=e,e.prototype.render=function(t){var e,n,r,i,o;for(t=t.toString(),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}(i),h=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}var n,r,i,s;for(d(e,t),n=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],i=0,s=n.length;s>i;i++)r=n[i],o.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}(i),s=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return d(e,t),e.prototype.render=function(t){return this.attr("value",t)},e}(h),a=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return d(e,t),o.Elements.textarea=e,e}(s),r=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return d(e,t),o.Elements.input.checkbox=e,e.prototype.render=function(t){return this.attr("checked",Boolean(t))},e}(s),u=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return d(e,t),o.Elements.input.radio=e,e}(r)},{"../lib/lodash.js":7,"./attributeFactory":2,"./helpers":5}],5:[function(t,e,n){var r,i,o,s;r=t("./elementFactory"),n.before=function(t){return function(e){return function(){return t.apply(this,arguments),e.apply(this,arguments)}}},n.after=function(t){return function(e){return function(){return e.apply(this,arguments),t.apply(this,arguments)}}},n.chainable=n.after(function(){return this}),n.onlyWith$=function(t){return"undefined"!=typeof jQuery&&null!==jQuery||"undefined"!=typeof Zepto&&null!==Zepto?function(){return t(arguments)}(jQuery||Zepto):void 0},n.getElements=function(t){var e;return e=[],s(t,e),e},s=function(t,e){var i,o;for(i=t.firstChild,o=[];i;)i.nodeType===n.ELEMENT_NODE&&(e.push(new r.createElement(i)),s(i,e)),o.push(i=i.nextSibling);return o},n.ELEMENT_NODE=1,n.TEXT_NODE=3,o=function(){return"<:nav></:nav>"!==document.createElement("nav").cloneNode(!0).outerHTML},n.cloneNode="undefined"==typeof document||null===document||o()?function(t){return t.cloneNode(!0)}:function(t){var e,r,o,s,u;if(e=Transparency.clone(t),e.nodeType===n.ELEMENT_NODE)for(e.removeAttribute(i),u=e.getElementsByTagName("*"),o=0,s=u.length;s>o;o++)r=u[o],r.removeAttribute(i);return e},i="transparency",n.data=function(t){return t[i]||(t[i]={})},n.nullLogger=function(){},n.consoleLogger=function(){return console.log(arguments)},n.log=n.nullLogger},{"./elementFactory":4}],6:[function(t,e){var n,r,i,o,s={}.hasOwnProperty;o=t("../lib/lodash.js"),r=(i=t("./helpers")).chainable,e.exports=n=function(){function t(t,e){this.Transparency=e,this.queryCache={},this.childNodes=o.toArray(t.childNodes),this.elements=i.getElements(t)}return t.prototype.remove=r(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=r(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=r(function(t){var e,n,r,o,s;for(o=this.elements,s=[],n=0,r=o.length;r>n;n++)e=o[n],e.reset(),s.push(i.data(e.el).model=t);return s}),t.prototype.renderValues=r(function(t,e){var n,r,i,u;if(o.isElement(t)&&(n=this.elements[0]))return n.empty().el.appendChild(t);if("object"==typeof t){u=[];for(r in t)s.call(t,r)&&(i=t[r],null!=i&&u.push(o.isString(i)||o.isNumber(i)||o.isBoolean(i)||o.isDate(i)?function(){var t,e,o,s;for(o=this.matchingElements(r),s=[],t=0,e=o.length;e>t;t++)n=o[t],s.push(n.render(i));return s}.call(this):"object"==typeof i?e.push(r):void 0));return u}}),t.prototype.renderDirectives=r(function(t,e,n){var r,i,o,u;u=[];for(o in n)s.call(n,o)&&(r=n[o],"object"==typeof r&&("object"!=typeof t&&(t={value:t}),u.push(function(){var n,s,u,l;for(u=this.matchingElements(o),l=[],n=0,s=u.length;s>n;n++)i=u[n],l.push(i.renderDirectives(t,e,r));return l}.call(this))));return u}),t.prototype.renderChildren=r(function(t,e,n,r){var i,o,s,u,l;for(l=[],s=0,u=e.length;u>s;s++)o=e[s],l.push(function(){var e,s,u,l;for(u=this.matchingElements(o),l=[],e=0,s=u.length;s>e;e++)i=u[e],l.push(this.Transparency.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],this.Transparency.matcher(e,t)&&o.push(e);return o}.call(this)),i.log("Matching elements for '"+t+"':",n),n},t}()},{"../lib/lodash.js":7,"./helpers":5}],7:[function(t,e,n){var r={};r.toString=Object.prototype.toString,r.toArray=function(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e},r.isString=function(t){return"[object String]"==r.toString.call(t)},r.isNumber=function(t){return"[object Number]"==r.toString.call(t)},r.isArray=Array.isArray||function(t){return"[object Array]"===r.toString.call(t)},r.isDate=function(t){return"[object Date]"===r.toString.call(t)},r.isElement=function(t){return!(!t||1!==t.nodeType)},r.isPlainValue=function(t){var e;return e=typeof t,"object"!==e&&"function"!==e||n.isDate(t)},r.isBoolean=function(t){return t===!0||t===!1},e.exports=r},{}]},{},[1]); | ||
!function t(e,n,r){function i(s,u){if(!n[s]){if(!e[s]){var l="function"==typeof require&&require;if(!u&&l)return l(s,!0);if(o)return o(s,!0);var a=new Error("Cannot find module '"+s+"'");throw a.code="MODULE_NOT_FOUND",a}var h=n[s]={exports:{}};e[s][0].call(h.exports,function(t){var n=e[s][1][t];return i(n?n:t)},h,h.exports,t,e,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e,n){var r,i,o,s,u,l=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};s=t("../lib/lodash.js"),u=t("./helpers"),i=t("./context"),o={},o.render=function(t,e,n,r){var l,a;return null==e&&(e=[]),null==n&&(n={}),null==r&&(r={}),a=r.debug&&console?u.consoleLogger:u.nullLogger,a("Transparency.render:",t,e,n,r),t?(s.isArray(e)||(e=[e]),t=(l=u.data(t)).context||(l.context=new i(t,o)),t.render(e,n,r).el):void 0},o.matcher=function(t,e){return t.el.id===e||l.call(t.classNames,e)>=0||t.el.name===e||t.el.getAttribute("data-bind")===e},o.clone=function(t){return r(t).clone()[0]},o.jQueryPlugin=u.chainable(function(t,e,n){var r,i,s,u;for(u=[],i=0,s=this.length;s>i;i++)r=this[i],u.push(o.render(r,t,e,n));return u}),("undefined"!=typeof jQuery&&null!==jQuery||"undefined"!=typeof Zepto&&null!==Zepto)&&(r=jQuery||Zepto,null!=r&&(r.fn.render=o.jQueryPlugin)),("undefined"!=typeof e&&null!==e?e.exports:void 0)&&(e.exports=o),"undefined"!=typeof window&&null!==window&&(window.Transparency=o),("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define(function(){return o})},{"../lib/lodash.js":7,"./context":3,"./helpers":5}],2:[function(t,e,n){var r,i,o,s,u,l,a,h,c=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},p={}.hasOwnProperty;a=t("../lib/lodash"),h=t("./helpers"),e.exports=i={Attributes:{},createAttribute:function(t,e){var n;return new(n=i.Attributes[e]||r)(t,e)}},r=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.toString())},t}(),o=function(t){function e(t,e){this.el=t,this.name=e,this.templateValue=this.el.getAttribute(this.name)||!1}var n,r,o,s;for(c(e,t),n=["hidden","async","defer","autofocus","formnovalidate","disabled","autofocus","formnovalidate","multiple","readonly","required","checked","scoped","reversed","selected","loop","muted","autoplay","controls","seamless","default","ismap","novalidate","open","typemustmatch","truespeed"],r=0,o=n.length;o>r;r++)s=n[r],i.Attributes[s]=e;return 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}(r),l=function(t){function e(t,e){var n;this.el=t,this.name=e,this.templateValue=function(){var t,e,r,i;for(r=this.el.childNodes,i=[],t=0,e=r.length;e>t;t++)n=r[t],n.nodeType===h.TEXT_NODE&&i.push(n.nodeValue);return i}.call(this).join(""),this.children=a.toArray(this.el.children),(this.textNode=this.el.firstChild)?this.textNode.nodeType!==h.TEXT_NODE&&(this.textNode=this.el.insertBefore(this.el.ownerDocument.createTextNode(""),this.textNode)):this.el.appendChild(this.textNode=this.el.ownerDocument.createTextNode(""))}return c(e,t),i.Attributes.text=e,e.prototype.set=function(t){for(var e,n,r,i,o;e=this.el.firstChild;)this.el.removeChild(e);for(this.textNode.nodeValue=t,this.el.appendChild(this.textNode),i=this.children,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(this.el.appendChild(e));return o},e}(r),u=function(t){function e(t){this.el=t,this.templateValue="",this.children=a.toArray(this.el.children)}return c(e,t),i.Attributes.html=e,e.prototype.set=function(t){for(var e,n,r,i,o;e=this.el.firstChild;)this.el.removeChild(e);for(this.el.innerHTML=t+this.templateValue,i=this.children,o=[],n=0,r=i.length;r>n;n++)e=i[n],o.push(this.el.appendChild(e));return o},e}(r),s=function(t){function e(t){e.__super__.constructor.call(this,t,"class")}return c(e,t),i.Attributes["class"]=e,e}(r)},{"../lib/lodash":7,"./helpers":5}],3:[function(t,e,n){var r,i,o,s,u,l,a;a=t("./helpers"),s=a.before,o=a.after,u=a.chainable,l=a.cloneNode,i=t("./instance"),e.exports=r=function(){function t(t,e){this.el=t,this.Transparency=e,this.template=l(this.el),this.instances=[new i(this.el,this.Transparency)],this.instanceCache=[]}var e,n;return n=u(function(){return this.parent=this.el.parentNode,this.parent?(this.nextSibling=this.el.nextSibling,this.parent.removeChild(this.el)):void 0}),e=u(function(){return this.parent?this.nextSibling?this.parent.insertBefore(this.el,this.nextSibling):this.parent.appendChild(this.el):void 0}),t.prototype.render=s(n)(o(e)(u(function(t,e,n){for(var r,o,s,u,a,h,c;t.length<this.instances.length;)this.instanceCache.push(this.instances.pop().remove());for(;t.length>this.instances.length;)u=this.instanceCache.pop()||new i(l(this.template),this.Transparency),this.instances.push(u.appendTo(this.el));for(c=[],s=o=0,a=t.length;a>o;s=++o)h=t[s],u=this.instances[s],r=[],c.push(u.prepare(h,r).renderValues(h,r).renderDirectives(h,s,e).renderChildren(h,r,e,n));return c}))),t}()},{"./helpers":5,"./instance":6}],4:[function(t,e,n){var r,i,o,s,u,l,a,h,c,p,f,d={}.hasOwnProperty,m=function(t,e){function n(){this.constructor=t}for(var r in e)d.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};p=t("../lib/lodash.js"),f=t("./helpers"),r=t("./attributeFactory"),e.exports=s={Elements:{input:{}},createElement:function(t){var e,n;return new(e="input"===(n=t.nodeName.toLowerCase())?s.Elements[n][t.type.toLowerCase()]||u:s.Elements[n]||o)(t)}},o=function(){function t(t){this.el=t,this.attributes={},this.childNodes=p.toArray(this.el.childNodes),this.nodeName=this.el.nodeName.toLowerCase(),this.classNames=this.el.className.split(" "),this.originalAttributes={}}return t.prototype.empty=function(){for(var t;t=this.el.firstChild;)this.el.removeChild(t);return this},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,e){var n,i;return n=(i=this.attributes)[t]||(i[t]=r.createAttribute(this.el,t,e)),null!=e&&n.set(e),n},t.prototype.renderDirectives=function(t,e,n){var r,i,o,s;o=[];for(i in n)d.call(n,i)&&(r=n[i],"function"==typeof r&&(s=r.call(t,{element:this.el,index:e,value:this.attr(i).templateValue}),null!=s?o.push(this.attr(i,s)):o.push(void 0)));return o},t}(),a=function(t){function e(t){e.__super__.constructor.call(this,t),this.elements=f.getElements(t)}return m(e,t),s.Elements.select=e,e.prototype.render=function(t){var e,n,r,i,o;for(t=t.toString(),i=this.elements,o=[],e=0,n=i.length;n>e;e++)r=i[e],"option"===r.nodeName&&o.push(r.attr("selected",r.el.value===t));return o},e}(o),c=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}var n,r,i,o;for(m(e,t),n=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],r=0,i=n.length;i>r;r++)o=n[r],s.Elements[o]=e;return e.prototype.attr=function(t,n){return"text"!==t&&"html"!==t?e.__super__.attr.call(this,t,n):void 0},e}(o),u=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return m(e,t),e.prototype.render=function(t){return this.attr("value",t)},e}(c),h=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return m(e,t),s.Elements.textarea=e,e}(u),i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return m(e,t),s.Elements.input.checkbox=e,e.prototype.render=function(t){return this.attr("checked",Boolean(t))},e}(u),l=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return m(e,t),s.Elements.input.radio=e,e}(i)},{"../lib/lodash.js":7,"./attributeFactory":2,"./helpers":5}],5:[function(t,e,n){var r,i,o,s;r=t("./elementFactory"),n.before=function(t){return function(e){return function(){return t.apply(this,arguments),e.apply(this,arguments)}}},n.after=function(t){return function(e){return function(){return e.apply(this,arguments),t.apply(this,arguments)}}},n.chainable=n.after(function(){return this}),n.onlyWith$=function(t){return"undefined"!=typeof jQuery&&null!==jQuery||"undefined"!=typeof Zepto&&null!==Zepto?function(e){return t(arguments)}(jQuery||Zepto):void 0},n.getElements=function(t){var e;return e=[],i(t,e),e},i=function(t,e){var o,s;for(o=t.firstChild,s=[];o;)o.nodeType===n.ELEMENT_NODE&&(e.push(new r.createElement(o)),i(o,e)),s.push(o=o.nextSibling);return s},n.ELEMENT_NODE=1,n.TEXT_NODE=3,s=function(){return"<:nav></:nav>"!==document.createElement("nav").cloneNode(!0).outerHTML},n.cloneNode="undefined"==typeof document||null===document||s()?function(t){return t.cloneNode(!0)}:function(t){var e,r,i,s,u;if(e=Transparency.clone(t),e.nodeType===n.ELEMENT_NODE)for(e.removeAttribute(o),u=e.getElementsByTagName("*"),i=0,s=u.length;s>i;i++)r=u[i],r.removeAttribute(o);return e},o="transparency",n.data=function(t){return t[o]||(t[o]={})},n.nullLogger=function(){},n.consoleLogger=function(){return console.log(arguments)},n.log=n.nullLogger},{"./elementFactory":4}],6:[function(t,e,n){var r,i,o,s,u={}.hasOwnProperty;i=t("../lib/lodash.js"),o=(s=t("./helpers")).chainable,e.exports=r=function(){function t(t,e){this.Transparency=e,this.queryCache={},this.childNodes=i.toArray(t.childNodes),this.elements=s.getElements(t)}return t.prototype.remove=o(function(){var t,e,n,r,i;for(r=this.childNodes,i=[],t=0,e=r.length;e>t;t++)n=r[t],i.push(n.parentNode.removeChild(n));return i}),t.prototype.appendTo=o(function(t){var e,n,r,i,o;for(i=this.childNodes,o=[],e=0,n=i.length;n>e;e++)r=i[e],o.push(t.appendChild(r));return o}),t.prototype.prepare=o(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(s.data(e.el).model=t);return o}),t.prototype.renderValues=o(function(t,e){var n,r,o,s;if(i.isElement(t)&&(n=this.elements[0]))return n.empty().el.appendChild(t);if("object"==typeof t){o=[];for(r in t)u.call(t,r)&&(s=t[r],null!=s&&(i.isString(s)||i.isNumber(s)||i.isBoolean(s)||i.isDate(s)?o.push(function(){var t,e,i,o;for(i=this.matchingElements(r),o=[],t=0,e=i.length;e>t;t++)n=i[t],o.push(n.render(s));return o}.call(this)):"object"==typeof s?o.push(e.push(r)):o.push(void 0)));return o}}),t.prototype.renderDirectives=o(function(t,e,n){var r,i,o,s;s=[];for(o in n)u.call(n,o)&&(r=n[o],"object"==typeof r&&("object"!=typeof t&&(t={value:t}),s.push(function(){var n,s,u,l;for(u=this.matchingElements(o),l=[],n=0,s=u.length;s>n;n++)i=u[n],l.push(i.renderDirectives(t,e,r));return l}.call(this))));return s}),t.prototype.renderChildren=o(function(t,e,n,r){var i,o,s,u,l;for(l=[],o=0,u=e.length;u>o;o++)s=e[o],l.push(function(){var e,o,u,l;for(u=this.matchingElements(s),l=[],e=0,o=u.length;o>e;e++)i=u[e],l.push(this.Transparency.render(i.el,t[s],n[s],r));return l}.call(this));return l}),t.prototype.matchingElements=function(t){var e,n,r;return r=(e=this.queryCache)[t]||(e[t]=function(){var e,r,i,o;for(i=this.elements,o=[],e=0,r=i.length;r>e;e++)n=i[e],this.Transparency.matcher(n,t)&&o.push(n);return o}.call(this)),s.log("Matching elements for '"+t+"':",r),r},t}()},{"../lib/lodash.js":7,"./helpers":5}],7:[function(t,e,n){var r={};r.toString=Object.prototype.toString,r.toArray=function(t){for(var e=new Array(t.length),n=0;n<t.length;n++)e[n]=t[n];return e},r.isString=function(t){return"[object String]"==r.toString.call(t)},r.isNumber=function(t){return"[object Number]"==r.toString.call(t)},r.isArray=Array.isArray||function(t){return"[object Array]"===r.toString.call(t)},r.isDate=function(t){return"[object Date]"===r.toString.call(t)},r.isElement=function(t){return!(!t||1!==t.nodeType)},r.isPlainValue=function(t){var e;return e=typeof t,"object"!==e&&"function"!==e||n.isDate(t)},r.isBoolean=function(t){return t===!0||t===!1},e.exports=r},{}]},{},[1]); |
@@ -1,4 +0,4 @@ | ||
var Attribute, AttributeFactory, BooleanAttribute, Class, Html, Text, helpers, _, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var Attribute, AttributeFactory, BooleanAttribute, Class, Html, Text, _, helpers, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -19,5 +19,5 @@ _ = require('../lib/lodash'); | ||
Attribute = (function() { | ||
function Attribute(el, name) { | ||
this.el = el; | ||
this.name = name; | ||
function Attribute(el1, name1) { | ||
this.el = el1; | ||
this.name = name1; | ||
this.templateValue = this.el.getAttribute(this.name) || ''; | ||
@@ -35,17 +35,17 @@ } | ||
BooleanAttribute = (function(_super) { | ||
var BOOLEAN_ATTRIBUTES, name, _i, _len; | ||
BooleanAttribute = (function(superClass) { | ||
var BOOLEAN_ATTRIBUTES, i, len, name; | ||
__extends(BooleanAttribute, _super); | ||
extend(BooleanAttribute, superClass); | ||
BOOLEAN_ATTRIBUTES = ['hidden', 'async', 'defer', 'autofocus', 'formnovalidate', 'disabled', 'autofocus', 'formnovalidate', 'multiple', 'readonly', 'required', 'checked', 'scoped', 'reversed', 'selected', 'loop', 'muted', 'autoplay', 'controls', 'seamless', 'default', 'ismap', 'novalidate', 'open', 'typemustmatch', 'truespeed']; | ||
for (_i = 0, _len = BOOLEAN_ATTRIBUTES.length; _i < _len; _i++) { | ||
name = BOOLEAN_ATTRIBUTES[_i]; | ||
for (i = 0, len = BOOLEAN_ATTRIBUTES.length; i < len; i++) { | ||
name = BOOLEAN_ATTRIBUTES[i]; | ||
AttributeFactory.Attributes[name] = BooleanAttribute; | ||
} | ||
function BooleanAttribute(el, name) { | ||
this.el = el; | ||
this.name = name; | ||
function BooleanAttribute(el1, name1) { | ||
this.el = el1; | ||
this.name = name1; | ||
this.templateValue = this.el.getAttribute(this.name) || false; | ||
@@ -67,22 +67,22 @@ } | ||
Text = (function(_super) { | ||
__extends(Text, _super); | ||
Text = (function(superClass) { | ||
extend(Text, superClass); | ||
AttributeFactory.Attributes['text'] = Text; | ||
function Text(el, name) { | ||
function Text(el1, name1) { | ||
var child; | ||
this.el = el; | ||
this.name = name; | ||
this.el = el1; | ||
this.name = name1; | ||
this.templateValue = ((function() { | ||
var _i, _len, _ref, _results; | ||
_ref = this.el.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
var i, len, ref, results; | ||
ref = this.el.childNodes; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
child = ref[i]; | ||
if (child.nodeType === helpers.TEXT_NODE) { | ||
_results.push(child.nodeValue); | ||
results.push(child.nodeValue); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)).join(''); | ||
@@ -98,3 +98,3 @@ this.children = _.toArray(this.el.children); | ||
Text.prototype.set = function(text) { | ||
var child, _i, _len, _ref, _results; | ||
var child, i, len, ref, results; | ||
while (child = this.el.firstChild) { | ||
@@ -105,9 +105,9 @@ this.el.removeChild(child); | ||
this.el.appendChild(this.textNode); | ||
_ref = this.children; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
_results.push(this.el.appendChild(child)); | ||
ref = this.children; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
child = ref[i]; | ||
results.push(this.el.appendChild(child)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -119,9 +119,9 @@ | ||
Html = (function(_super) { | ||
__extends(Html, _super); | ||
Html = (function(superClass) { | ||
extend(Html, superClass); | ||
AttributeFactory.Attributes['html'] = Html; | ||
function Html(el) { | ||
this.el = el; | ||
function Html(el1) { | ||
this.el = el1; | ||
this.templateValue = ''; | ||
@@ -132,3 +132,3 @@ this.children = _.toArray(this.el.children); | ||
Html.prototype.set = function(html) { | ||
var child, _i, _len, _ref, _results; | ||
var child, i, len, ref, results; | ||
while (child = this.el.firstChild) { | ||
@@ -138,9 +138,9 @@ this.el.removeChild(child); | ||
this.el.innerHTML = html + this.templateValue; | ||
_ref = this.children; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
_results.push(this.el.appendChild(child)); | ||
ref = this.children; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
child = ref[i]; | ||
results.push(this.el.appendChild(child)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -152,4 +152,4 @@ | ||
Class = (function(_super) { | ||
__extends(Class, _super); | ||
Class = (function(superClass) { | ||
extend(Class, superClass); | ||
@@ -156,0 +156,0 @@ AttributeFactory.Attributes['class'] = Class; |
@@ -1,4 +0,4 @@ | ||
var Context, Instance, after, before, chainable, cloneNode, _ref; | ||
var Context, Instance, after, before, chainable, cloneNode, ref; | ||
_ref = require('./helpers'), before = _ref.before, after = _ref.after, chainable = _ref.chainable, cloneNode = _ref.cloneNode; | ||
ref = require('./helpers'), before = ref.before, after = ref.after, chainable = ref.chainable, cloneNode = ref.cloneNode; | ||
@@ -37,3 +37,3 @@ Instance = require('./instance'); | ||
Context.prototype.render = before(detach)(after(attach)(chainable(function(models, directives, options) { | ||
var children, index, instance, model, _i, _len, _results; | ||
var children, i, index, instance, len, model, results; | ||
while (models.length < this.instances.length) { | ||
@@ -46,10 +46,10 @@ this.instanceCache.push(this.instances.pop().remove()); | ||
} | ||
_results = []; | ||
for (index = _i = 0, _len = models.length; _i < _len; index = ++_i) { | ||
results = []; | ||
for (index = i = 0, len = models.length; i < len; index = ++i) { | ||
model = models[index]; | ||
instance = this.instances[index]; | ||
children = []; | ||
_results.push(instance.prepare(model, children).renderValues(model, children).renderDirectives(model, index, directives).renderChildren(model, children, directives, options)); | ||
results.push(instance.prepare(model, children).renderValues(model, children).renderDirectives(model, index, directives).renderChildren(model, children, directives, options)); | ||
} | ||
return _results; | ||
return results; | ||
}))); | ||
@@ -56,0 +56,0 @@ |
@@ -1,4 +0,4 @@ | ||
var AttributeFactory, Checkbox, Element, ElementFactory, Input, Radio, Select, TextArea, VoidElement, helpers, _, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var AttributeFactory, Checkbox, Element, ElementFactory, Input, Radio, Select, TextArea, VoidElement, _, helpers, | ||
hasProp = {}.hasOwnProperty, | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
@@ -27,4 +27,4 @@ _ = require('../lib/lodash.js'); | ||
Element = (function() { | ||
function Element(el) { | ||
this.el = el; | ||
function Element(el1) { | ||
this.el = el1; | ||
this.attributes = {}; | ||
@@ -46,10 +46,10 @@ this.childNodes = _.toArray(this.el.childNodes); | ||
Element.prototype.reset = function() { | ||
var attribute, name, _ref, _results; | ||
_ref = this.attributes; | ||
_results = []; | ||
for (name in _ref) { | ||
attribute = _ref[name]; | ||
_results.push(attribute.set(attribute.templateValue)); | ||
var attribute, name, ref, results; | ||
ref = this.attributes; | ||
results = []; | ||
for (name in ref) { | ||
attribute = ref[name]; | ||
results.push(attribute.set(attribute.templateValue)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -62,4 +62,4 @@ | ||
Element.prototype.attr = function(name, value) { | ||
var attribute, _base; | ||
attribute = (_base = this.attributes)[name] || (_base[name] = AttributeFactory.createAttribute(this.el, name, value)); | ||
var attribute, base; | ||
attribute = (base = this.attributes)[name] || (base[name] = AttributeFactory.createAttribute(this.el, name, value)); | ||
if (value != null) { | ||
@@ -72,6 +72,6 @@ attribute.set(value); | ||
Element.prototype.renderDirectives = function(model, index, attributes) { | ||
var directive, name, value, _results; | ||
_results = []; | ||
var directive, name, results, value; | ||
results = []; | ||
for (name in attributes) { | ||
if (!__hasProp.call(attributes, name)) continue; | ||
if (!hasProp.call(attributes, name)) continue; | ||
directive = attributes[name]; | ||
@@ -87,8 +87,8 @@ if (!(typeof directive === 'function')) { | ||
if (value != null) { | ||
_results.push(this.attr(name, value)); | ||
results.push(this.attr(name, value)); | ||
} else { | ||
_results.push(void 0); | ||
results.push(void 0); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -100,4 +100,4 @@ | ||
Select = (function(_super) { | ||
__extends(Select, _super); | ||
Select = (function(superClass) { | ||
extend(Select, superClass); | ||
@@ -112,13 +112,13 @@ ElementFactory.Elements['select'] = Select; | ||
Select.prototype.render = function(value) { | ||
var option, _i, _len, _ref, _results; | ||
var i, len, option, ref, results; | ||
value = value.toString(); | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
option = _ref[_i]; | ||
ref = this.elements; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
option = ref[i]; | ||
if (option.nodeName === 'option') { | ||
_results.push(option.attr('selected', option.el.value === value)); | ||
results.push(option.attr('selected', option.el.value === value)); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -130,6 +130,6 @@ | ||
VoidElement = (function(_super) { | ||
var VOID_ELEMENTS, nodeName, _i, _len; | ||
VoidElement = (function(superClass) { | ||
var VOID_ELEMENTS, i, len, nodeName; | ||
__extends(VoidElement, _super); | ||
extend(VoidElement, superClass); | ||
@@ -142,4 +142,4 @@ function VoidElement() { | ||
for (_i = 0, _len = VOID_ELEMENTS.length; _i < _len; _i++) { | ||
nodeName = VOID_ELEMENTS[_i]; | ||
for (i = 0, len = VOID_ELEMENTS.length; i < len; i++) { | ||
nodeName = VOID_ELEMENTS[i]; | ||
ElementFactory.Elements[nodeName] = VoidElement; | ||
@@ -158,4 +158,4 @@ } | ||
Input = (function(_super) { | ||
__extends(Input, _super); | ||
Input = (function(superClass) { | ||
extend(Input, superClass); | ||
@@ -174,4 +174,4 @@ function Input() { | ||
TextArea = (function(_super) { | ||
__extends(TextArea, _super); | ||
TextArea = (function(superClass) { | ||
extend(TextArea, superClass); | ||
@@ -188,4 +188,4 @@ function TextArea() { | ||
Checkbox = (function(_super) { | ||
__extends(Checkbox, _super); | ||
Checkbox = (function(superClass) { | ||
extend(Checkbox, superClass); | ||
@@ -206,4 +206,4 @@ function Checkbox() { | ||
Radio = (function(_super) { | ||
__extends(Radio, _super); | ||
Radio = (function(superClass) { | ||
extend(Radio, superClass); | ||
@@ -210,0 +210,0 @@ function Radio() { |
@@ -1,2 +0,2 @@ | ||
var ElementFactory, expando, html5Clone, _getElements; | ||
var ElementFactory, _getElements, expando, html5Clone; | ||
@@ -43,5 +43,5 @@ ElementFactory = require('./elementFactory'); | ||
_getElements = function(template, elements) { | ||
var child, _results; | ||
var child, results; | ||
child = template.firstChild; | ||
_results = []; | ||
results = []; | ||
while (child) { | ||
@@ -52,5 +52,5 @@ if (child.nodeType === exports.ELEMENT_NODE) { | ||
} | ||
_results.push(child = child.nextSibling); | ||
results.push(child = child.nextSibling); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -69,9 +69,9 @@ | ||
} : function(node) { | ||
var cloned, element, _i, _len, _ref; | ||
var cloned, element, i, len, ref; | ||
cloned = Transparency.clone(node); | ||
if (cloned.nodeType === exports.ELEMENT_NODE) { | ||
cloned.removeAttribute(expando); | ||
_ref = cloned.getElementsByTagName('*'); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
ref = cloned.getElementsByTagName('*'); | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
element.removeAttribute(expando); | ||
@@ -78,0 +78,0 @@ } |
@@ -1,3 +0,3 @@ | ||
var Instance, chainable, helpers, _, | ||
__hasProp = {}.hasOwnProperty; | ||
var Instance, _, chainable, helpers, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -17,64 +17,64 @@ _ = require('../lib/lodash.js'); | ||
Instance.prototype.remove = chainable(function() { | ||
var node, _i, _len, _ref, _results; | ||
_ref = this.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(node.parentNode.removeChild(node)); | ||
var i, len, node, ref, results; | ||
ref = this.childNodes; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
node = ref[i]; | ||
results.push(node.parentNode.removeChild(node)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.appendTo = chainable(function(parent) { | ||
var node, _i, _len, _ref, _results; | ||
_ref = this.childNodes; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
node = _ref[_i]; | ||
_results.push(parent.appendChild(node)); | ||
var i, len, node, ref, results; | ||
ref = this.childNodes; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
node = ref[i]; | ||
results.push(parent.appendChild(node)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.prepare = chainable(function(model) { | ||
var element, _i, _len, _ref, _results; | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
var element, i, len, ref, results; | ||
ref = this.elements; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
element.reset(); | ||
_results.push(helpers.data(element.el).model = model); | ||
results.push(helpers.data(element.el).model = model); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.renderValues = chainable(function(model, children) { | ||
var element, key, value, _results; | ||
var element, key, results, value; | ||
if (_.isElement(model) && (element = this.elements[0])) { | ||
return element.empty().el.appendChild(model); | ||
} else if (typeof model === 'object') { | ||
_results = []; | ||
results = []; | ||
for (key in model) { | ||
if (!__hasProp.call(model, key)) continue; | ||
if (!hasProp.call(model, key)) continue; | ||
value = model[key]; | ||
if (value != null) { | ||
if (_.isString(value) || _.isNumber(value) || _.isBoolean(value) || _.isDate(value)) { | ||
_results.push((function() { | ||
var _i, _len, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
_results1.push(element.render(value)); | ||
results.push((function() { | ||
var i, len, ref, results1; | ||
ref = this.matchingElements(key); | ||
results1 = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
results1.push(element.render(value)); | ||
} | ||
return _results1; | ||
return results1; | ||
}).call(this)); | ||
} else if (typeof value === 'object') { | ||
_results.push(children.push(key)); | ||
results.push(children.push(key)); | ||
} else { | ||
_results.push(void 0); | ||
results.push(void 0); | ||
} | ||
} | ||
} | ||
return _results; | ||
return results; | ||
} | ||
@@ -84,6 +84,6 @@ }); | ||
Instance.prototype.renderDirectives = chainable(function(model, index, directives) { | ||
var attributes, element, key, _results; | ||
_results = []; | ||
var attributes, element, key, results; | ||
results = []; | ||
for (key in directives) { | ||
if (!__hasProp.call(directives, key)) continue; | ||
if (!hasProp.call(directives, key)) continue; | ||
attributes = directives[key]; | ||
@@ -98,48 +98,48 @@ if (!(typeof attributes === 'object')) { | ||
} | ||
_results.push((function() { | ||
var _i, _len, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
element = _ref[_i]; | ||
_results1.push(element.renderDirectives(model, index, attributes)); | ||
results.push((function() { | ||
var i, len, ref, results1; | ||
ref = this.matchingElements(key); | ||
results1 = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
element = ref[i]; | ||
results1.push(element.renderDirectives(model, index, attributes)); | ||
} | ||
return _results1; | ||
return results1; | ||
}).call(this)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.renderChildren = chainable(function(model, children, directives, options) { | ||
var element, key, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = children.length; _i < _len; _i++) { | ||
key = children[_i]; | ||
_results.push((function() { | ||
var _j, _len1, _ref, _results1; | ||
_ref = this.matchingElements(key); | ||
_results1 = []; | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
element = _ref[_j]; | ||
_results1.push(this.Transparency.render(element.el, model[key], directives[key], options)); | ||
var element, i, key, len, results; | ||
results = []; | ||
for (i = 0, len = children.length; i < len; i++) { | ||
key = children[i]; | ||
results.push((function() { | ||
var j, len1, ref, results1; | ||
ref = this.matchingElements(key); | ||
results1 = []; | ||
for (j = 0, len1 = ref.length; j < len1; j++) { | ||
element = ref[j]; | ||
results1.push(this.Transparency.render(element.el, model[key], directives[key], options)); | ||
} | ||
return _results1; | ||
return results1; | ||
}).call(this)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
Instance.prototype.matchingElements = function(key) { | ||
var el, elements, _base; | ||
elements = (_base = this.queryCache)[key] || (_base[key] = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = this.elements; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
el = _ref[_i]; | ||
var base, el, elements; | ||
elements = (base = this.queryCache)[key] || (base[key] = (function() { | ||
var i, len, ref, results; | ||
ref = this.elements; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
el = ref[i]; | ||
if (this.Transparency.matcher(el, key)) { | ||
_results.push(el); | ||
results.push(el); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}).call(this)); | ||
@@ -146,0 +146,0 @@ helpers.log("Matching elements for '" + key + "':", elements); |
@@ -1,3 +0,3 @@ | ||
var $, Context, Transparency, helpers, _, | ||
__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; }; | ||
var $, Context, Transparency, _, helpers, | ||
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; }; | ||
@@ -13,3 +13,3 @@ _ = require('../lib/lodash.js'); | ||
Transparency.render = function(context, models, directives, options) { | ||
var log, _base; | ||
var base, log; | ||
if (models == null) { | ||
@@ -32,3 +32,3 @@ models = []; | ||
} | ||
context = (_base = helpers.data(context)).context || (_base.context = new Context(context, Transparency)); | ||
context = (base = helpers.data(context)).context || (base.context = new Context(context, Transparency)); | ||
return context.render(models, directives, options).el; | ||
@@ -38,3 +38,3 @@ }; | ||
Transparency.matcher = function(element, key) { | ||
return element.el.id === key || __indexOf.call(element.classNames, key) >= 0 || element.el.name === key || element.el.getAttribute('data-bind') === key; | ||
return element.el.id === key || indexOf.call(element.classNames, key) >= 0 || element.el.name === key || element.el.getAttribute('data-bind') === key; | ||
}; | ||
@@ -47,9 +47,9 @@ | ||
Transparency.jQueryPlugin = helpers.chainable(function(models, directives, options) { | ||
var context, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = this.length; _i < _len; _i++) { | ||
context = this[_i]; | ||
_results.push(Transparency.render(context, models, directives, options)); | ||
var context, i, len, results; | ||
results = []; | ||
for (i = 0, len = this.length; i < len; i++) { | ||
context = this[i]; | ||
results.push(Transparency.render(context, models, directives, options)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
@@ -56,0 +56,0 @@ |
{ | ||
"name": "transparency", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "Transparency is a minimal template engine for browsers. It maps JSON objects to DOM elements with zero configuration.", | ||
@@ -29,3 +29,2 @@ "homepage": "https://github.com/leonidas/transparency", | ||
], | ||
"main": "dist/transparency.js", | ||
"dependencies": { | ||
@@ -32,0 +31,0 @@ "jsdom": "^1.0.0" |
@@ -39,4 +39,2 @@ # Synopsis | ||
[![browser support](https://ci.testling.com/leonidas/transparency.png)](https://ci.testling.com/leonidas/transparency) | ||
## Community | ||
@@ -47,2 +45,8 @@ | ||
**We are looking for new maintainers**. Anyone with an accepted pull request will get commit rights. Current maintainers are | ||
* [pyykkis](https://github.com/pyykkis) | ||
* [rikukissa](https://github.com/rikukissa) | ||
## Fiddle | ||
@@ -49,0 +53,0 @@ |
@@ -11,9 +11,9 @@ (function() { | ||
toBeEqual: function(expected) { | ||
var actualAttr, actualChildren, attribute, child, expectedAttr, expectedChildren, i, _i, _j, _len, _len1, _ref, _results; | ||
var actualAttr, actualChildren, attribute, child, expectedAttr, expectedChildren, i, j, k, len, len1, ref, results; | ||
if (trim(actual.text()) !== trim(expected.text())) { | ||
throw new Error("ERROR: '" + (actual.text()) + "' is not equal to '" + (expected.text()) + "'"); | ||
} | ||
_ref = expected[0].attributes; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
attribute = _ref[_i]; | ||
ref = expected[0].attributes; | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
attribute = ref[j]; | ||
actualAttr = actual[0].getAttribute(attribute.name); | ||
@@ -34,12 +34,12 @@ if (actualAttr == null) { | ||
} | ||
_results = []; | ||
for (i = _j = 0, _len1 = expectedChildren.length; _j < _len1; i = ++_j) { | ||
results = []; | ||
for (i = k = 0, len1 = expectedChildren.length; k < len1; i = ++k) { | ||
child = expectedChildren[i]; | ||
_results.push(expect($(actualChildren[i])).toBeEqual($(child))); | ||
results.push(expect($(actualChildren[i])).toBeEqual($(child))); | ||
} | ||
return _results; | ||
return results; | ||
}, | ||
toEqual: function(expected) { | ||
if (actual !== expected) { | ||
throw new Error("" + actual + " != " + expected); | ||
throw new Error(actual + " != " + expected); | ||
} | ||
@@ -49,3 +49,3 @@ }, | ||
var message, passed; | ||
message = ("Expected " + actual.name + " (" + actual.stats.mean + " +/- " + actual.stats.moe + " to be less than ") + ("" + ballpark + " x " + expected.name + " (" + expected.stats.mean + " +/- " + expected.stats.moe); | ||
message = ("Expected " + actual.name + " (" + actual.stats.mean + " +/- " + actual.stats.moe + " to be less than ") + (ballpark + " x " + expected.name + " (" + expected.stats.mean + " +/- " + expected.stats.moe); | ||
console.log(actual.toString()); | ||
@@ -52,0 +52,0 @@ console.log(expected.toString()); |
@@ -14,3 +14,3 @@ (function() { | ||
text: function() { | ||
return "" + this.firstname + " " + this.lastname; | ||
return this.firstname + " " + this.lastname; | ||
} | ||
@@ -34,3 +34,3 @@ } | ||
html: function() { | ||
return "" + this.firstname + " " + this.lastname; | ||
return this.firstname + " " + this.lastname; | ||
} | ||
@@ -67,3 +67,3 @@ } | ||
nameDecorator = function() { | ||
return "" + this.firstname + " " + this.lastname; | ||
return this.firstname + " " + this.lastname; | ||
}; | ||
@@ -70,0 +70,0 @@ directives = { |
@@ -105,11 +105,11 @@ (function() { | ||
expectModelObjects = function(elements, data) { | ||
var i, object, _i, _len, _results; | ||
_results = []; | ||
for (i = _i = 0, _len = data.length; _i < _len; i = ++_i) { | ||
var i, j, len, object, results; | ||
results = []; | ||
for (i = j = 0, len = data.length; j < len; i = ++j) { | ||
object = data[i]; | ||
_results.push(expect(elements[i].transparency.model).toEqual(object)); | ||
results.push(expect(elements[i].transparency.model).toEqual(object)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
}).call(this); |
(function() { | ||
describe("Each element in a template instance", function() { | ||
return it("should have reference to the rendered model", function() { | ||
var data, directives, element, i, li, template, _i, _len, _ref, _results; | ||
var data, directives, element, i, j, len, li, ref, results, template; | ||
template = $("<div id=\"template\">\n <li><a class=\"name\"><span>Moar text</span></a></div>\n</div>"); | ||
@@ -22,18 +22,18 @@ data = [ | ||
template.render(data, directives); | ||
_ref = template.find('li'); | ||
_results = []; | ||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { | ||
li = _ref[i]; | ||
_results.push((function() { | ||
var _j, _len1, _ref1, _results1; | ||
_ref1 = $(li).add('*', li); | ||
_results1 = []; | ||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { | ||
element = _ref1[_j]; | ||
_results1.push(expect(data[i]).toEqual(element.transparency.model)); | ||
ref = template.find('li'); | ||
results = []; | ||
for (i = j = 0, len = ref.length; j < len; i = ++j) { | ||
li = ref[i]; | ||
results.push((function() { | ||
var k, len1, ref1, results1; | ||
ref1 = $(li).add('*', li); | ||
results1 = []; | ||
for (k = 0, len1 = ref1.length; k < len1; k++) { | ||
element = ref1[k]; | ||
results1.push(expect(data[i]).toEqual(element.transparency.model)); | ||
} | ||
return _results1; | ||
return results1; | ||
})()); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
@@ -40,0 +40,0 @@ }); |
@@ -14,10 +14,10 @@ (function() { | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -39,10 +39,10 @@ Transparency.render(template, { | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -69,27 +69,27 @@ }, | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push((function() { | ||
var _j, _results1; | ||
_results1 = []; | ||
for (j = _j = 1; _j <= 100; j = ++_j) { | ||
_results1.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push((function() { | ||
var l, results1; | ||
results1 = []; | ||
for (j = l = 1; l <= 100; j = ++l) { | ||
results1.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results1; | ||
return results1; | ||
})()); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
Transparency.render(template, (function() { | ||
var _i, _results; | ||
_results = []; | ||
for (j = _i = 1; _i <= 100; j = ++_i) { | ||
_results.push({ | ||
var k, results; | ||
results = []; | ||
for (j = k = 1; k <= 100; j = ++k) { | ||
results.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results; | ||
return results; | ||
})()); | ||
@@ -108,17 +108,17 @@ }, | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push((function() { | ||
var _j, _results1; | ||
_results1 = []; | ||
for (j = _j = 1; _j <= 100; j = ++_j) { | ||
_results1.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push((function() { | ||
var l, results1; | ||
results1 = []; | ||
for (j = l = 1; l <= 100; j = ++l) { | ||
results1.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results1; | ||
return results1; | ||
})()); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -144,19 +144,19 @@ }, | ||
template = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push($('<div class="template"><div class="todo"></div></div>')[0]); | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push($('<div class="template"><div class="todo"></div></div>')[0]); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
index = 0; | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -172,27 +172,27 @@ }, | ||
parser = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push($('<div></div>')[0]); | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push($('<div></div>')[0]); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
template = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push(Handlebars.compile('<div class="template"><div class="todo">{{todo}}</div></div>')); | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push(Handlebars.compile('<div class="template"><div class="todo">{{todo}}</div></div>')); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
index = 0; | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -216,26 +216,26 @@ }, | ||
template = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push($('<div class="template"><div class="todo"></div></div>')[0]); | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push($('<div class="template"><div class="todo"></div></div>')[0]); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
index = 0; | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push((function() { | ||
var _j, _results1; | ||
_results1 = []; | ||
for (j = _j = 1; _j <= 100; j = ++_j) { | ||
_results1.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push((function() { | ||
var l, results1; | ||
results1 = []; | ||
for (j = l = 1; l <= 100; j = ++l) { | ||
results1.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results1; | ||
return results1; | ||
})()); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -251,34 +251,34 @@ }, | ||
parser = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push($('<div></div>')[0]); | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push($('<div></div>')[0]); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
template = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push(Handlebars.compile('<div class="template">{{#each this}}<div class="todo">{{todo}}</div>{{/each}}</div>')); | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push(Handlebars.compile('<div class="template">{{#each this}}<div class="todo">{{todo}}</div>{{/each}}</div>')); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
index = 0; | ||
data = (function() { | ||
var _i, _ref, _results; | ||
_results = []; | ||
for (i = _i = 1, _ref = this.count; 1 <= _ref ? _i <= _ref : _i >= _ref; i = 1 <= _ref ? ++_i : --_i) { | ||
_results.push((function() { | ||
var _j, _results1; | ||
_results1 = []; | ||
for (j = _j = 1; _j <= 100; j = ++_j) { | ||
_results1.push({ | ||
var k, ref, results; | ||
results = []; | ||
for (i = k = 1, ref = this.count; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { | ||
results.push((function() { | ||
var l, results1; | ||
results1 = []; | ||
for (j = l = 1; l <= 100; j = ++l) { | ||
results1.push({ | ||
todo: Math.random() | ||
}); | ||
} | ||
return _results1; | ||
return results1; | ||
})()); | ||
} | ||
return _results; | ||
return results; | ||
}).call(this); | ||
@@ -285,0 +285,0 @@ }, |
@@ -12,5 +12,5 @@ (function() { | ||
return it("should work on node.js", function(done) { | ||
return jsdom.env("", [], function(errors, _arg) { | ||
return jsdom.env("", [], function(errors, arg) { | ||
var data, document, expected, template; | ||
document = _arg.document; | ||
document = arg.document; | ||
template = document.createElement('div'); | ||
@@ -17,0 +17,0 @@ template.innerHTML = "<div class=\"container\">\n <div class=\"hello\"></div>\n</div>"; |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
517
3958325