transparency
Advanced tools
Comparing version 0.9.7 to 0.9.8
@@ -0,16 +1,74 @@ | ||
;(function(e,t,n,r){function i(r){if(!n[r]){if(!t[r]){if(e)return e(r);throw new Error("Cannot find module '"+r+"'")}var s=n[r]={exports:{}};t[r][0](function(e){var n=t[r][1][e];return i(n?n:e)},s,s.exports)}return n[r].exports}for(var s=0;s<r.length;s++)i(r[s]);return i})(typeof require!=="undefined"&&require,{1:[function(require,module,exports){ | ||
(function() { | ||
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; }; | ||
/*! | ||
* transparency - v0.9.7 - 2013-03-04 | ||
* https://github.com/leonidas/transparency | ||
* Copyright (c) 2013 Jarno Keskikangas <jarno.keskikangas@leonidasoy.fi>; Licensed MIT | ||
*/ | ||
helpers = require('./helpers'); | ||
Context = require('./context'); | ||
Transparency = window.Transparency = {}; | ||
Transparency.render = function(context, models, directives, options) { | ||
var log, _base; | ||
if (models == null) { | ||
models = []; | ||
} | ||
if (directives == null) { | ||
directives = {}; | ||
} | ||
if (options == null) { | ||
options = {}; | ||
} | ||
log = options.debug && console ? helpers.consoleLogger : helpers.nullLogger; | ||
log("Transparency.render:", context, models, directives, options); | ||
if (!context) { | ||
return; | ||
} | ||
if (!helpers.isArray(models)) { | ||
models = [models]; | ||
} | ||
context = (_base = helpers.data(context)).context || (_base.context = new Context(context)); | ||
return context.render(models, directives, options).el; | ||
}; | ||
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)); | ||
} | ||
return _results; | ||
}); | ||
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; | ||
}; | ||
Transparency.clone = helpers.onlyWith$(function() { | ||
return function(node) { | ||
return $(node).clone()[0]; | ||
}; | ||
}); | ||
helpers.onlyWith$(function() { | ||
return $.fn.render = Transparency.jQueryPlugin; | ||
}); | ||
if (typeof define !== "undefined" && define !== null ? define.amd : void 0) { | ||
define(function() { | ||
return Transparency; | ||
}); | ||
} | ||
}).call(this); | ||
},{"./helpers":2,"./context":3}],2:[function(require,module,exports){ | ||
(function() { | ||
var Attribute, AttributeFactory, BooleanAttribute, Checkbox, Class, Context, ELEMENT_NODE, Element, ElementFactory, Html, Input, Instance, Radio, Select, TEXT_NODE, Text, TextArea, 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; }, | ||
__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 ElementFactory, expando, html5Clone, _getElements; | ||
before = function(decorator) { | ||
ElementFactory = require('./ElementFactory'); | ||
exports.before = function(decorator) { | ||
return function(method) { | ||
@@ -24,3 +82,3 @@ return function() { | ||
after = function(decorator) { | ||
exports.after = function(decorator) { | ||
return function(method) { | ||
@@ -34,15 +92,15 @@ return function() { | ||
chainable = after(function() { | ||
exports.chainable = exports.after(function() { | ||
return this; | ||
}); | ||
onlyWith$ = function(fn) { | ||
exports.onlyWith$ = function(fn) { | ||
if ((typeof jQuery !== "undefined" && jQuery !== null) || (typeof Zepto !== "undefined" && Zepto !== null)) { | ||
return (function($ ) { | ||
return (function($) { | ||
return fn(arguments); | ||
})(jQuery || Zepto); | ||
})(jQuery || Zepto); | ||
} | ||
}; | ||
getChildNodes = function(el) { | ||
exports.getChildNodes = function(el) { | ||
var child, childNodes; | ||
@@ -58,3 +116,3 @@ childNodes = []; | ||
getElements = function(el) { | ||
exports.getElements = function(el) { | ||
var elements; | ||
@@ -71,3 +129,3 @@ elements = []; | ||
while (child) { | ||
if (child.nodeType === ELEMENT_NODE) { | ||
if (child.nodeType === exports.ELEMENT_NODE) { | ||
elements.push(new ElementFactory.createElement(child)); | ||
@@ -81,5 +139,5 @@ _getElements(child, elements); | ||
ELEMENT_NODE = 1; | ||
exports.ELEMENT_NODE = 1; | ||
TEXT_NODE = 3; | ||
exports.TEXT_NODE = 3; | ||
@@ -90,3 +148,3 @@ html5Clone = function() { | ||
cloneNode = !(typeof document !== "undefined" && document !== null) || html5Clone() ? function(node) { | ||
exports.cloneNode = !(typeof document !== "undefined" && document !== null) || html5Clone() ? function(node) { | ||
return node.cloneNode(true); | ||
@@ -96,3 +154,3 @@ } : function(node) { | ||
cloned = Transparency.clone(node); | ||
if (cloned.nodeType === ELEMENT_NODE) { | ||
if (cloned.nodeType === exports.ELEMENT_NODE) { | ||
cloned.removeAttribute(expando); | ||
@@ -110,97 +168,52 @@ _ref = cloned.getElementsByTagName('*'); | ||
data = function(element) { | ||
exports.data = function(element) { | ||
return element[expando] || (element[expando] = {}); | ||
}; | ||
nullLogger = function() {}; | ||
exports.nullLogger = function() {}; | ||
consoleLogger = function() { | ||
exports.consoleLogger = function() { | ||
return console.log(arguments); | ||
}; | ||
log = nullLogger; | ||
exports.log = exports.nullLogger; | ||
toString = Object.prototype.toString; | ||
exports.toString = Object.prototype.toString; | ||
isArray = Array.isArray || function(obj) { | ||
return toString.call(obj) === '[object Array]'; | ||
exports.isArray = Array.isArray || function(obj) { | ||
return exports.toString.call(obj) === '[object Array]'; | ||
}; | ||
isDate = function(obj) { | ||
return toString.call(obj) === '[object Date]'; | ||
exports.isDate = function(obj) { | ||
return exports.toString.call(obj) === '[object Date]'; | ||
}; | ||
isDomElement = function(obj) { | ||
return obj.nodeType === ELEMENT_NODE; | ||
exports.isDomElement = function(obj) { | ||
return obj.nodeType === exports.ELEMENT_NODE; | ||
}; | ||
isPlainValue = function(obj) { | ||
exports.isPlainValue = function(obj) { | ||
var type; | ||
type = typeof obj; | ||
return (type !== 'object' && type !== 'function') || isDate(obj); | ||
return (type !== 'object' && type !== 'function') || exports.isDate(obj); | ||
}; | ||
isBoolean = function(obj) { | ||
exports.isBoolean = function(obj) { | ||
return obj === true || obj === false; | ||
}; | ||
Transparency = this.Transparency = {}; | ||
}).call(this); | ||
Transparency.render = function(context, models, directives, options) { | ||
var _base; | ||
if (models == null) { | ||
models = []; | ||
} | ||
if (directives == null) { | ||
directives = {}; | ||
} | ||
if (options == null) { | ||
options = {}; | ||
} | ||
log = options.debug && console ? consoleLogger : nullLogger; | ||
log("Transparency.render:", context, models, directives, options); | ||
if (!context) { | ||
return; | ||
} | ||
if (!isArray(models)) { | ||
models = [models]; | ||
} | ||
context = (_base = data(context)).context || (_base.context = new Context(context)); | ||
return context.render(models, directives, options).el; | ||
}; | ||
},{"./ElementFactory":4}],3:[function(require,module,exports){ | ||
(function() { | ||
var Context, Instance, helpers; | ||
Transparency.jQueryPlugin = 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)); | ||
} | ||
return _results; | ||
}); | ||
helpers = require('./helpers'); | ||
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; | ||
}; | ||
Instance = require('./instance'); | ||
Transparency.clone = onlyWith$(function() { | ||
return function(node) { | ||
return $(node).clone()[0]; | ||
}; | ||
}); | ||
onlyWith$(function() { | ||
return $.fn.render = Transparency.jQueryPlugin; | ||
}); | ||
if (typeof define !== "undefined" && define !== null ? define.amd : void 0) { | ||
define(function() { | ||
return Transparency; | ||
}); | ||
} | ||
Context = (function() { | ||
module.exports = Context = (function() { | ||
var attach, detach; | ||
detach = chainable(function() { | ||
detach = helpers.chainable(function() { | ||
this.parent = this.el.parentNode; | ||
@@ -213,3 +226,3 @@ if (this.parent) { | ||
attach = chainable(function() { | ||
attach = helpers.chainable(function() { | ||
if (this.parent) { | ||
@@ -226,3 +239,3 @@ if (this.nextSibling) { | ||
this.el = el; | ||
this.template = cloneNode(this.el); | ||
this.template = helpers.cloneNode(this.el); | ||
this.instances = [new Instance(this.el)]; | ||
@@ -232,3 +245,3 @@ this.instanceCache = []; | ||
Context.prototype.render = before(detach)(after(attach)(chainable(function(models, directives, options) { | ||
Context.prototype.render = helpers.before(detach)(helpers.after(attach)(helpers.chainable(function(models, directives, options) { | ||
var children, index, instance, model, _i, _len, _results; | ||
@@ -239,3 +252,3 @@ while (models.length < this.instances.length) { | ||
while (models.length > this.instances.length) { | ||
instance = this.instanceCache.pop() || new Instance(cloneNode(this.template)); | ||
instance = this.instanceCache.pop() || new Instance(helpers.cloneNode(this.template)); | ||
this.instances.push(instance.appendTo(this.el)); | ||
@@ -257,11 +270,234 @@ } | ||
Instance = (function() { | ||
}).call(this); | ||
},{"./helpers":2,"./instance":5}],4:[function(require,module,exports){ | ||
(function() { | ||
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; }; | ||
AttributeFactory = require('./attributeFactory'); | ||
helpers = require('./helpers'); | ||
module.exports = ElementFactory = { | ||
Elements: { | ||
input: {} | ||
}, | ||
createElement: function(el) { | ||
var El, name; | ||
if ('input' === (name = el.nodeName.toLowerCase())) { | ||
El = ElementFactory.Elements[name][el.type.toLowerCase()] || Input; | ||
} else { | ||
El = ElementFactory.Elements[name] || Element; | ||
} | ||
return new El(el); | ||
} | ||
}; | ||
Element = (function() { | ||
function Element(el) { | ||
this.el = el; | ||
this.attributes = {}; | ||
this.childNodes = helpers.getChildNodes(this.el); | ||
this.nodeName = this.el.nodeName.toLowerCase(); | ||
this.classNames = this.el.className.split(' '); | ||
this.originalAttributes = {}; | ||
} | ||
Element.prototype.empty = function() { | ||
var child; | ||
while (child = this.el.firstChild) { | ||
this.el.removeChild(child); | ||
} | ||
return this; | ||
}; | ||
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)); | ||
} | ||
return _results; | ||
}; | ||
Element.prototype.render = function(value) { | ||
return this.attr('text', value); | ||
}; | ||
Element.prototype.attr = function(name, value) { | ||
var attribute, _base; | ||
attribute = (_base = this.attributes)[name] || (_base[name] = AttributeFactory.createAttribute(this.el, name, value)); | ||
if (value != null) { | ||
attribute.set(value); | ||
} | ||
return attribute; | ||
}; | ||
Element.prototype.renderDirectives = function(model, index, attributes) { | ||
var directive, name, value, _results; | ||
_results = []; | ||
for (name in attributes) { | ||
if (!__hasProp.call(attributes, name)) continue; | ||
directive = attributes[name]; | ||
if (!(typeof directive === 'function')) { | ||
continue; | ||
} | ||
value = directive.call(model, { | ||
element: this.el, | ||
index: index, | ||
value: this.attr(name).templateValue | ||
}); | ||
if (value != null) { | ||
_results.push(this.attr(name, value)); | ||
} else { | ||
_results.push(void 0); | ||
} | ||
} | ||
return _results; | ||
}; | ||
return Element; | ||
})(); | ||
Select = (function(_super) { | ||
__extends(Select, _super); | ||
ElementFactory.Elements['select'] = Select; | ||
function Select(el) { | ||
Select.__super__.constructor.call(this, el); | ||
this.elements = helpers.getElements(el); | ||
} | ||
Select.prototype.render = function(value) { | ||
var option, _i, _len, _ref, _results; | ||
value = value.toString(); | ||
_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)); | ||
} | ||
} | ||
return _results; | ||
}; | ||
return Select; | ||
})(Element); | ||
VoidElement = (function(_super) { | ||
var VOID_ELEMENTS, nodeName, _i, _len; | ||
__extends(VoidElement, _super); | ||
function VoidElement() { | ||
return VoidElement.__super__.constructor.apply(this, arguments); | ||
} | ||
VOID_ELEMENTS = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; | ||
for (_i = 0, _len = VOID_ELEMENTS.length; _i < _len; _i++) { | ||
nodeName = VOID_ELEMENTS[_i]; | ||
ElementFactory.Elements[nodeName] = VoidElement; | ||
} | ||
VoidElement.prototype.attr = function(name, value) { | ||
if (name !== 'text' && name !== 'html') { | ||
return VoidElement.__super__.attr.call(this, name, value); | ||
} | ||
}; | ||
return VoidElement; | ||
})(Element); | ||
Input = (function(_super) { | ||
__extends(Input, _super); | ||
function Input() { | ||
return Input.__super__.constructor.apply(this, arguments); | ||
} | ||
Input.prototype.render = function(value) { | ||
return this.attr('value', value); | ||
}; | ||
return Input; | ||
})(VoidElement); | ||
TextArea = (function(_super) { | ||
__extends(TextArea, _super); | ||
function TextArea() { | ||
return TextArea.__super__.constructor.apply(this, arguments); | ||
} | ||
ElementFactory.Elements['textarea'] = TextArea; | ||
return TextArea; | ||
})(Input); | ||
Checkbox = (function(_super) { | ||
__extends(Checkbox, _super); | ||
function Checkbox() { | ||
return Checkbox.__super__.constructor.apply(this, arguments); | ||
} | ||
ElementFactory.Elements['input']['checkbox'] = Checkbox; | ||
Checkbox.prototype.render = function(value) { | ||
return this.attr('checked', Boolean(value)); | ||
}; | ||
return Checkbox; | ||
})(Input); | ||
Radio = (function(_super) { | ||
__extends(Radio, _super); | ||
function Radio() { | ||
return Radio.__super__.constructor.apply(this, arguments); | ||
} | ||
ElementFactory.Elements['input']['radio'] = Radio; | ||
return Radio; | ||
})(Checkbox); | ||
}).call(this); | ||
},{"./attributeFactory":6,"./helpers":2}],5:[function(require,module,exports){ | ||
(function() { | ||
var Instance, helpers, | ||
__hasProp = {}.hasOwnProperty; | ||
helpers = require('./helpers'); | ||
module.exports = Instance = (function() { | ||
function Instance(template) { | ||
this.queryCache = {}; | ||
this.childNodes = getChildNodes(template); | ||
this.elements = getElements(template); | ||
this.childNodes = helpers.getChildNodes(template); | ||
this.elements = helpers.getElements(template); | ||
} | ||
Instance.prototype.remove = chainable(function() { | ||
Instance.prototype.remove = helpers.chainable(function() { | ||
var node, _i, _len, _ref, _results; | ||
@@ -277,3 +513,3 @@ _ref = this.childNodes; | ||
Instance.prototype.appendTo = chainable(function(parent) { | ||
Instance.prototype.appendTo = helpers.chainable(function(parent) { | ||
var node, _i, _len, _ref, _results; | ||
@@ -289,3 +525,3 @@ _ref = this.childNodes; | ||
Instance.prototype.prepare = chainable(function(model) { | ||
Instance.prototype.prepare = helpers.chainable(function(model) { | ||
var element, _i, _len, _ref, _results; | ||
@@ -297,3 +533,3 @@ _ref = this.elements; | ||
element.reset(); | ||
_results.push(data(element.el).model = model); | ||
_results.push(helpers.data(element.el).model = model); | ||
} | ||
@@ -303,5 +539,5 @@ return _results; | ||
Instance.prototype.renderValues = chainable(function(model, children) { | ||
Instance.prototype.renderValues = helpers.chainable(function(model, children) { | ||
var element, key, value, _results; | ||
if (isDomElement(model) && (element = this.elements[0])) { | ||
if (helpers.isDomElement(model) && (element = this.elements[0])) { | ||
return element.empty().el.appendChild(model); | ||
@@ -314,3 +550,3 @@ } else if (typeof model === 'object') { | ||
if (value != null) { | ||
if (isPlainValue(value)) { | ||
if (helpers.isPlainValue(value)) { | ||
_results.push((function() { | ||
@@ -337,3 +573,3 @@ var _i, _len, _ref, _results1; | ||
Instance.prototype.renderDirectives = chainable(function(model, index, directives) { | ||
Instance.prototype.renderDirectives = helpers.chainable(function(model, index, directives) { | ||
var attributes, element, key, _results; | ||
@@ -366,3 +602,3 @@ _results = []; | ||
Instance.prototype.renderChildren = chainable(function(model, children, directives, options) { | ||
Instance.prototype.renderChildren = helpers.chainable(function(model, children, directives, options) { | ||
var element, key, _i, _len, _results; | ||
@@ -400,3 +636,3 @@ _results = []; | ||
}).call(this)); | ||
log("Matching elements for '" + key + "':", elements); | ||
helpers.log("Matching elements for '" + key + "':", elements); | ||
return elements; | ||
@@ -409,3 +645,13 @@ }; | ||
AttributeFactory = { | ||
}).call(this); | ||
},{"./helpers":2}],6:[function(require,module,exports){ | ||
(function() { | ||
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; }; | ||
helpers = require('./helpers'); | ||
module.exports = AttributeFactory = { | ||
Attributes: {}, | ||
@@ -479,7 +725,7 @@ createAttribute: function(element, name) { | ||
var _i, _len, _ref, _results; | ||
_ref = getChildNodes(this.el); | ||
_ref = helpers.getChildNodes(this.el); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
if (child.nodeType === TEXT_NODE) { | ||
if (child.nodeType === helpers.TEXT_NODE) { | ||
_results.push(child.nodeValue); | ||
@@ -492,3 +738,3 @@ } | ||
this.el.appendChild(this.textNode = this.el.ownerDocument.createTextNode('')); | ||
} else if (this.textNode.nodeType !== TEXT_NODE) { | ||
} else if (this.textNode.nodeType !== helpers.TEXT_NODE) { | ||
this.textNode = this.el.insertBefore(this.el.ownerDocument.createTextNode(''), this.textNode); | ||
@@ -513,4 +759,15 @@ } | ||
function Html(el) { | ||
Html.__super__.constructor.call(this, el, 'innerHTML'); | ||
this.children = Array.prototype.slice.call(this.el.children); | ||
var child; | ||
this.el = el; | ||
this.templateValue = ''; | ||
this.children = (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = this.el.children; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
_results.push(child); | ||
} | ||
return _results; | ||
}).call(this); | ||
} | ||
@@ -520,3 +777,6 @@ | ||
var child, _i, _len, _ref, _results; | ||
this.el.innerHTML = html; | ||
while (child = this.el.firstChild) { | ||
this.el.removeChild(child); | ||
} | ||
this.el.innerHTML = html + this.templateValue; | ||
_ref = this.children; | ||
@@ -549,205 +809,5 @@ _results = []; | ||
ElementFactory = { | ||
Elements: { | ||
input: {} | ||
}, | ||
createElement: function(el) { | ||
var El, name; | ||
if ('input' === (name = el.nodeName.toLowerCase())) { | ||
El = ElementFactory.Elements[name][el.type.toLowerCase()] || Input; | ||
} else { | ||
El = ElementFactory.Elements[name] || Element; | ||
} | ||
return new El(el); | ||
} | ||
}; | ||
}).call(this); | ||
Element = (function() { | ||
function Element(el) { | ||
this.el = el; | ||
this.attributes = {}; | ||
this.childNodes = getChildNodes(this.el); | ||
this.nodeName = this.el.nodeName.toLowerCase(); | ||
this.classNames = this.el.className.split(' '); | ||
this.originalAttributes = {}; | ||
} | ||
Element.prototype.empty = chainable(function() { | ||
var child, _results; | ||
_results = []; | ||
while (child = this.el.firstChild) { | ||
_results.push(this.el.removeChild(child)); | ||
} | ||
return _results; | ||
}); | ||
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)); | ||
} | ||
return _results; | ||
}; | ||
Element.prototype.render = function(value) { | ||
return this.attr('text', value); | ||
}; | ||
Element.prototype.attr = function(name, value) { | ||
var attribute, _base; | ||
attribute = (_base = this.attributes)[name] || (_base[name] = AttributeFactory.createAttribute(this.el, name, value)); | ||
if (value != null) { | ||
attribute.set(value); | ||
} | ||
return attribute; | ||
}; | ||
Element.prototype.renderDirectives = function(model, index, attributes) { | ||
var directive, name, value, _results; | ||
_results = []; | ||
for (name in attributes) { | ||
if (!__hasProp.call(attributes, name)) continue; | ||
directive = attributes[name]; | ||
if (!(typeof directive === 'function')) { | ||
continue; | ||
} | ||
value = directive.call(model, { | ||
element: this.el, | ||
index: index, | ||
value: this.attr(name).templateValue | ||
}); | ||
if (value != null) { | ||
_results.push(this.attr(name, value)); | ||
} else { | ||
_results.push(void 0); | ||
} | ||
} | ||
return _results; | ||
}; | ||
return Element; | ||
})(); | ||
Select = (function(_super) { | ||
__extends(Select, _super); | ||
ElementFactory.Elements['select'] = Select; | ||
function Select(el) { | ||
Select.__super__.constructor.call(this, el); | ||
this.elements = getElements(el); | ||
} | ||
Select.prototype.render = function(value) { | ||
var option, _i, _len, _ref, _results; | ||
value = value.toString(); | ||
_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)); | ||
} | ||
} | ||
return _results; | ||
}; | ||
return Select; | ||
})(Element); | ||
VoidElement = (function(_super) { | ||
var VOID_ELEMENTS, nodeName, _i, _len; | ||
__extends(VoidElement, _super); | ||
function VoidElement() { | ||
return VoidElement.__super__.constructor.apply(this, arguments); | ||
} | ||
VOID_ELEMENTS = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr']; | ||
for (_i = 0, _len = VOID_ELEMENTS.length; _i < _len; _i++) { | ||
nodeName = VOID_ELEMENTS[_i]; | ||
ElementFactory.Elements[nodeName] = VoidElement; | ||
} | ||
VoidElement.prototype.attr = function(name, value) { | ||
if (name !== 'text' && name !== 'html') { | ||
return VoidElement.__super__.attr.call(this, name, value); | ||
} | ||
}; | ||
return VoidElement; | ||
})(Element); | ||
Input = (function(_super) { | ||
__extends(Input, _super); | ||
function Input() { | ||
return Input.__super__.constructor.apply(this, arguments); | ||
} | ||
Input.prototype.render = function(value) { | ||
return this.attr('value', value); | ||
}; | ||
return Input; | ||
})(VoidElement); | ||
TextArea = (function(_super) { | ||
__extends(TextArea, _super); | ||
function TextArea() { | ||
return TextArea.__super__.constructor.apply(this, arguments); | ||
} | ||
ElementFactory.Elements['textarea'] = TextArea; | ||
return TextArea; | ||
})(Input); | ||
Checkbox = (function(_super) { | ||
__extends(Checkbox, _super); | ||
function Checkbox() { | ||
return Checkbox.__super__.constructor.apply(this, arguments); | ||
} | ||
ElementFactory.Elements['input']['checkbox'] = Checkbox; | ||
Checkbox.prototype.render = function(value) { | ||
return this.attr('checked', Boolean(value)); | ||
}; | ||
return Checkbox; | ||
})(Input); | ||
Radio = (function(_super) { | ||
__extends(Radio, _super); | ||
function Radio() { | ||
return Radio.__super__.constructor.apply(this, arguments); | ||
} | ||
ElementFactory.Elements['input']['radio'] = Radio; | ||
return Radio; | ||
})(Checkbox); | ||
}).call(this); | ||
},{"./helpers":2}]},{},[1]) | ||
; |
@@ -1,6 +0,1 @@ | ||
/*! | ||
* transparency - v0.9.7 - 2013-03-04 | ||
* 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,a,h,c,p,f,d,m,y,v,g,b,_,N,x,C,A,E,T,j,w,V,D,S,k,L,Q,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,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};_=function(t){return function(e){return function(){return t.apply(this,arguments),e.apply(this,arguments)}}},b=function(t){return function(e){return function(){return e.apply(this,arguments),t.apply(this,arguments)}}},N=b(function(){return this}),M=function(t){return"undefined"!=typeof jQuery&&null!==jQuery||"undefined"!=typeof Zepto&&null!==Zepto?function(){return t(arguments)}(jQuery||Zepto):void 0},T=function(t){var e,n;for(n=[],e=t.firstChild;e;)n.push(e),e=e.nextSibling;return n},j=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,w=function(){return"<:nav></:nav>"!==document.createElement("nav").cloneNode(!0).outerHTML},x="undefined"==typeof document||null===document||w()?function(t){return t.cloneNode(!0)}:function(t){var e,n,r,i,o;if(e=v.clone(t),e.nodeType===u)for(e.removeAttribute(E),o=e.getElementsByTagName("*"),r=0,i=o.length;i>r;r++)n=o[r],n.removeAttribute(E);return e},E="transparency",A=function(t){return t[E]||(t[E]={})},B=function(){},C=function(){return console.log(arguments)},Q=B,q=Object.prototype.toString,V=Array.isArray||function(t){return"[object Array]"===q.call(t)},S=function(t){return"[object Date]"===q.call(t)},k=function(t){return t.nodeType===u},L=function(t){var e;return e=typeof t,"object"!==e&&"function"!==e||S(t)},D=function(t){return t===!0||t===!1},v=this.Transparency={},v.render=function(t,e,n,r){var i;return null==e&&(e=[]),null==n&&(n={}),null==r&&(r={}),Q=r.debug&&console?C:B,Q("Transparency.render:",t,e,n,r),t?(V(e)||(e=[e]),t=(i=A(t)).context||(i.context=new o(t)),t.render(e,n,r).el):void 0},v.jQueryPlugin=N(function(t,e,n){var r,i,o,u;for(u=[],i=0,o=this.length;o>i;i++)r=this[i],u.push(v.render(r,t,e,n));return u}),v.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},v.clone=M(function(){return function(t){return $(t).clone()[0]}}),M(function(){return $.fn.render=v.jQueryPlugin}),("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define(function(){return v}),o=function(){function t(t){this.el=t,this.template=x(this.el),this.instances=[new c(this.el)],this.instanceCache=[]}var e,n;return n=N(function(){return this.parent=this.el.parentNode,this.parent?(this.nextSibling=this.el.nextSibling,this.parent.removeChild(this.el)):void 0}),e=N(function(){return this.parent?this.nextSibling?this.parent.insertBefore(this.el,this.nextSibling):this.parent.appendChild(this.el):void 0}),t.prototype.render=_(n)(b(e)(N(function(t,e,n){for(var r,i,o,u,s,l,a;t.length<this.instances.length;)this.instanceCache.push(this.instances.pop().remove());for(;t.length>this.instances.length;)o=this.instanceCache.pop()||new c(x(this.template)),this.instances.push(o.appendTo(this.el));for(a=[],i=s=0,l=t.length;l>s;i=++s)u=t[i],o=this.instances[i],r=[],a.push(o.prepare(u,r).renderValues(u,r).renderDirectives(u,i,e).renderChildren(u,r,e,n));return a}))),t}(),c=function(){function t(t){this.queryCache={},this.childNodes=T(t),this.elements=j(t)}return t.prototype.remove=N(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=N(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=N(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(A(e.el).model=t);return o}),t.prototype.renderValues=N(function(t,e){var n,r,i,o;if(k(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=N(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=N(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(v.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],v.matcher(e,t)&&o.push(e);return o}.call(this)),Q("Matching elements for '"+t+"':",n),n},t}(),e={Attributes:{},createAttribute:function(n,r){var i;return i=e.Attributes[r]||t,new i(n,r)}},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 n(t,e){this.el=t,this.name=e,this.templateValue=this.el.getAttribute(this.name)||!1}var r,i,o,u;for(Z(n,t),r=["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,u=r.length;u>o;o++)i=r[o],e.Attributes[i]=n;return n.prototype.set=function(t){return this.el[this.name]=t,t?this.el.setAttribute(this.name,this.name):this.el.removeAttribute(this.name)},n}(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=T(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),a=function(t){function n(t){n.__super__.constructor.call(this,t,"innerHTML"),this.children=Array.prototype.slice.call(this.el.children)}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.children,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()]||h:l.Elements[n]||s,new e(t)}},s=function(){function t(t){this.el=t,this.attributes={},this.childNodes=T(this.el),this.nodeName=this.el.nodeName.toLowerCase(),this.classNames=this.el.className.split(" "),this.originalAttributes={}}return t.prototype.empty=N(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)),null!=n&&r.set(n),r},t.prototype.renderDirectives=function(t,e,n){var r,i,o,u;u=[];for(i in n)P.call(n,i)&&(r=n[i],"function"==typeof r&&(o=r.call(t,{element:this.el,index:e,value:this.attr(i).templateValue}),null!=o?u.push(this.attr(i,o)):u.push(void 0)));return u},t}(),f=function(t){function e(t){e.__super__.constructor.call(this,t),this.elements=j(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),g=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),h=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}(g),y=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return Z(e,t),l.Elements.textarea=e,e}(h),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}(h),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); | ||
(function(t,e,n,r){function i(r){if(!n[r]){if(!e[r]){if(t)return t(r);throw Error("Cannot find module '"+r+"'")}var o=n[r]={exports:{}};e[r][0](function(t){var n=e[r][1][t];return i(n?n:t)},o,o.exports)}return n[r].exports}for(var o=0;r.length>o;o++)i(r[o]);return i})("undefined"!=typeof require&&require,{1:[function(t){(function(){var e,n,r,i=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};r=t("./helpers"),e=t("./context"),n=window.Transparency={},n.render=function(t,n,i,o){var s,u;return null==n&&(n=[]),null==i&&(i={}),null==o&&(o={}),s=o.debug&&console?r.consoleLogger:r.nullLogger,s("Transparency.render:",t,n,i,o),t?(r.isArray(n)||(n=[n]),t=(u=r.data(t)).context||(u.context=new e(t)),t.render(n,i,o).el):void 0},n.jQueryPlugin=r.chainable(function(t,e,r){var i,o,s,u;for(u=[],o=0,s=this.length;s>o;o++)i=this[o],u.push(n.render(i,t,e,r));return u}),n.matcher=function(t,e){return t.el.id===e||i.call(t.classNames,e)>=0||t.el.name===e||t.el.getAttribute("data-bind")===e},n.clone=r.onlyWith$(function(){return function(t){return $(t).clone()[0]}}),r.onlyWith$(function(){return $.fn.render=n.jQueryPlugin}),("undefined"!=typeof define&&null!==define?define.amd:void 0)&&define(function(){return n})}).call(this)},{"./helpers":2,"./context":3}],2:[function(t,e,n){(function(){var e,r,i,o;e=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.getChildNodes=function(t){var e,n;for(n=[],e=t.firstChild;e;)n.push(e),e=e.nextSibling;return n},n.getElements=function(t){var e;return e=[],o(t,e),e},o=function(t,r){var i,s;for(i=t.firstChild,s=[];i;)i.nodeType===n.ELEMENT_NODE&&(r.push(new e.createElement(i)),o(i,r)),s.push(i=i.nextSibling);return s},n.ELEMENT_NODE=1,n.TEXT_NODE=3,i=function(){return"<:nav></:nav>"!==document.createElement("nav").cloneNode(!0).outerHTML},n.cloneNode="undefined"==typeof document||null===document||i()?function(t){return t.cloneNode(!0)}:function(t){var e,i,o,s,u;if(e=Transparency.clone(t),e.nodeType===n.ELEMENT_NODE)for(e.removeAttribute(r),u=e.getElementsByTagName("*"),o=0,s=u.length;s>o;o++)i=u[o],i.removeAttribute(r);return e},r="transparency",n.data=function(t){return t[r]||(t[r]={})},n.nullLogger=function(){},n.consoleLogger=function(){return console.log(arguments)},n.log=n.nullLogger,n.toString=Object.prototype.toString,n.isArray=Array.isArray||function(t){return"[object Array]"===n.toString.call(t)},n.isDate=function(t){return"[object Date]"===n.toString.call(t)},n.isDomElement=function(t){return t.nodeType===n.ELEMENT_NODE},n.isPlainValue=function(t){var e;return e=typeof t,"object"!==e&&"function"!==e||n.isDate(t)},n.isBoolean=function(t){return t===!0||t===!1}}).call(this)},{"./ElementFactory":4}],3:[function(t,e){(function(){var n,r,i;i=t("./helpers"),r=t("./instance"),e.exports=n=function(){function t(t){this.el=t,this.template=i.cloneNode(this.el),this.instances=[new r(this.el)],this.instanceCache=[]}var e,n;return n=i.chainable(function(){return this.parent=this.el.parentNode,this.parent?(this.nextSibling=this.el.nextSibling,this.parent.removeChild(this.el)):void 0}),e=i.chainable(function(){return this.parent?this.nextSibling?this.parent.insertBefore(this.el,this.nextSibling):this.parent.appendChild(this.el):void 0}),t.prototype.render=i.before(n)(i.after(e)(i.chainable(function(t,e,n){for(var o,s,u,l,a,c,h;t.length<this.instances.length;)this.instanceCache.push(this.instances.pop().remove());for(;t.length>this.instances.length;)u=this.instanceCache.pop()||new r(i.cloneNode(this.template)),this.instances.push(u.appendTo(this.el));for(h=[],s=a=0,c=t.length;c>a;s=++a)l=t[s],u=this.instances[s],o=[],h.push(u.prepare(l,o).renderValues(l,o).renderDirectives(l,s,e).renderChildren(l,o,e,n));return h}))),t}()}).call(this)},{"./helpers":2,"./instance":5}],4:[function(t,e){(function(){var n,r,i,o,s,u,l,a,c,h,p={}.hasOwnProperty,f=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};n=t("./attributeFactory"),h=t("./helpers"),e.exports=o={Elements:{input:{}},createElement:function(t){var e,n;return e="input"===(n=t.nodeName.toLowerCase())?o.Elements[n][t.type.toLowerCase()]||s:o.Elements[n]||i,new e(t)}},i=function(){function t(t){this.el=t,this.attributes={},this.childNodes=h.getChildNodes(this.el),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)p.call(n,i)&&(r=n[i],"function"==typeof r&&(o=r.call(t,{element:this.el,index:e,value:this.attr(i).templateValue}),null!=o?s.push(this.attr(i,o)):s.push(void 0)));return s},t}(),l=function(t){function e(t){e.__super__.constructor.call(this,t),this.elements=h.getElements(t)}return f(e,t),o.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}(i),c=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}var n,r,i,s;for(f(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 f(e,t),e.prototype.render=function(t){return this.attr("value",t)},e}(c),a=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return f(e,t),o.Elements.textarea=e,e}(s),r=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return f(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 f(e,t),o.Elements.input.radio=e,e}(r)}).call(this)},{"./attributeFactory":6,"./helpers":2}],5:[function(t,e){(function(){var n,r,i={}.hasOwnProperty;r=t("./helpers"),e.exports=n=function(){function t(t){this.queryCache={},this.childNodes=r.getChildNodes(t),this.elements=r.getElements(t)}return t.prototype.remove=r.chainable(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.chainable(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.chainable(function(t){var e,n,i,o,s;for(o=this.elements,s=[],n=0,i=o.length;i>n;n++)e=o[n],e.reset(),s.push(r.data(e.el).model=t);return s}),t.prototype.renderValues=r.chainable(function(t,e){var n,o,s,u;if(r.isDomElement(t)&&(n=this.elements[0]))return n.empty().el.appendChild(t);if("object"==typeof t){u=[];for(o in t)i.call(t,o)&&(s=t[o],null!=s&&(r.isPlainValue(s)?u.push(function(){var t,e,r,i;for(r=this.matchingElements(o),i=[],t=0,e=r.length;e>t;t++)n=r[t],i.push(n.render(s));return i}.call(this)):"object"==typeof s?u.push(e.push(o)):u.push(void 0)));return u}}),t.prototype.renderDirectives=r.chainable(function(t,e,n){var r,o,s,u;u=[];for(s in n)i.call(n,s)&&(r=n[s],"object"==typeof r&&("object"!=typeof t&&(t={value:t}),u.push(function(){var n,i,u,l;for(u=this.matchingElements(s),l=[],n=0,i=u.length;i>n;n++)o=u[n],l.push(o.renderDirectives(t,e,r));return l}.call(this))));return u}),t.prototype.renderChildren=r.chainable(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(Transparency.render(i.el,t[o],n[o],r));return l}.call(this));return l}),t.prototype.matchingElements=function(t){var e,n,i;return n=(i=this.queryCache)[t]||(i[t]=function(){var n,r,i,o;for(i=this.elements,o=[],n=0,r=i.length;r>n;n++)e=i[n],Transparency.matcher(e,t)&&o.push(e);return o}.call(this)),r.log("Matching elements for '"+t+"':",n),n},t}()}).call(this)},{"./helpers":2}],6:[function(t,e){(function(){var n,r,i,o,s,u,l,a={}.hasOwnProperty,c=function(t,e){function n(){this.constructor=t}for(var r in e)a.call(e,r)&&(t[r]=e[r]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};l=t("./helpers"),e.exports=r={Attributes:{},createAttribute:function(t,e){var i;return i=r.Attributes[e]||n,new i(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)},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=l.getChildNodes(this.el),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.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){return this.textNode.nodeValue=t},e}(n),s=function(t){function e(t){var e;this.el=t,this.templateValue="",this.children=function(){var t,n,r,i;for(r=this.el.children,i=[],t=0,n=r.length;n>t;t++)e=r[t],i.push(e);return i}.call(this)}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)}).call(this)},{"./helpers":2}]},{},[1]); |
{ | ||
"name": "transparency", | ||
"version": "0.9.7", | ||
"version": "0.9.8", | ||
"main": "dist/transparency", | ||
@@ -31,3 +31,4 @@ "description": "Transparency is a minimal template engine for browsers. It maps JSON objects to DOM elements with zero configuration.", | ||
"dependencies": { | ||
"jsdom": "~0.5.0" | ||
"jsdom": "~0.5.0", | ||
"browserify": "~2.6.1" | ||
}, | ||
@@ -45,7 +46,33 @@ "devDependencies": { | ||
"grunt-contrib-concat": "~0.1.2", | ||
"grunt-template-jasmine-requirejs": "~0.1.0" | ||
"grunt-template-jasmine-requirejs": "~0.1.0", | ||
"james-coffee": "~0.1.1", | ||
"james": "~0.1.5", | ||
"james-uglify": "~0.1.0", | ||
"q": "~0.9.2", | ||
"coffeeify": "~0.1.0" | ||
}, | ||
"scripts": { | ||
"test": "grunt test" | ||
}, | ||
"testling": { | ||
"scripts": [ | ||
"spec/lib/jquery-1.9.1.min.js", | ||
"spec/lib/jasmine-1.3.1/jasmine.js", | ||
"spec/lib/jasmine-1.3.1/jasmine-html.js", | ||
"spec/lib/jasmine.tap_reporter.js", | ||
"dist/transparency.js", | ||
"spec/specHelper.js", | ||
"spec/!(amd*|performance*|browserGlobal*|nojQuery*)Spec.js", | ||
"spec/runner.js" | ||
], | ||
"browsers": [ | ||
"ie/8..latest", | ||
"chrome/20..latest", | ||
"firefox/10..latest", | ||
"safari/5.1..latest", | ||
"opera/11.0..latest", | ||
"iphone/6", | ||
"ipad/6" | ||
] | ||
} | ||
} |
@@ -37,5 +37,6 @@ # Synopsis | ||
Transparency is compatible with IE9+, Chrome, Firefox, iOS, Android and other mobile browsers. Support for older | ||
IE browsers requires jQuery. | ||
Transparency is compatible with IE9+, Chrome, Firefox, iOS, Android and other mobile browsers. Support for IE8 requires jQuery. | ||
[![browser support](https://ci.testling.com/leonidas/transparency.png)](https://ci.testling.com/leonidas/transparency) | ||
## Community | ||
@@ -42,0 +43,0 @@ |
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
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
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
135
513
4324645
2
16
25406
9
19
+ Addedbrowserify@~2.6.1
+ AddedJSONStream@0.4.4(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedastw@0.0.0(transitive)
+ Addedbase64-js@0.0.2(transitive)
+ Addedbrowser-pack@0.4.1(transitive)
+ Addedbrowser-resolve@0.0.5(transitive)
+ Addedbrowserify@2.6.1(transitive)
+ Addedbuffer-browserify@0.0.4(transitive)
+ Addedcommondir@0.0.2(transitive)
+ Addedconcat-stream@0.0.80.1.1(transitive)
+ Addedconsole-browserify@0.1.6(transitive)
+ Addedcrypto-browserify@0.2.1(transitive)
+ Addeddetective@2.0.0(transitive)
+ Addedduplexer@0.0.4(transitive)
+ Addedescodegen@0.0.15(transitive)
+ Addedesprima@0.9.91.0.2(transitive)
+ Addedhttp-browserify@0.1.6(transitive)
+ Addedinherits@1.0.2(transitive)
+ Addedinline-source-map@0.2.5(transitive)
+ Addedinsert-module-globals@0.2.1(transitive)
+ Addedjsonparse@0.0.5(transitive)
+ Addedlexical-scope@0.0.15(transitive)
+ Addedmodule-deps@0.5.3(transitive)
+ Addedoptimist@0.3.7(transitive)
+ Addedprocess@0.5.2(transitive)
+ Addedresolve@0.3.0(transitive)
+ Addedshell-quote@0.0.1(transitive)
+ Addedsource-map@0.1.43(transitive)
+ Addedsyntax-error@0.0.1(transitive)
+ Addedthrough@2.2.7(transitive)
+ Addeduglify-js@1.3.4(transitive)
+ Addedvm-browserify@0.0.1(transitive)
+ Addedwordwrap@0.0.3(transitive)
+ Addedzlib-browserify@0.0.1(transitive)