8c37555a by Michael Richards

Build 0.3.3.

1 parent 07983619
// rivets.js
// version: 0.3.2
// version: 0.3.3
// author: Michael Richards
// license: MIT
(function() {
var Rivets, attributeBinding, bindEvent, eventBinding, getInputValue, iterationBinding, rivets, unbindEvent,
var Rivets, attributeBinding, bindEvent, classBinding, eventBinding, getInputValue, iterationBinding, rivets, unbindEvent,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__slice = [].slice,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
......@@ -38,6 +38,8 @@
switch (this.options.special) {
case "event":
return eventBinding(this.type);
case "class":
return classBinding(this.type);
case "iteration":
return iterationBinding(this.type);
default:
......@@ -161,13 +163,14 @@
};
View.prototype.build = function() {
var bindingRegExp, el, eventRegExp, iterationRegExp, iterator, node, parseNode, skipNodes, _i, _len, _ref, _results,
var bindingRegExp, classRegExp, el, eventRegExp, iterationRegExp, iterator, node, parseNode, skipNodes, _i, _len, _ref, _results,
_this = this;
this.bindings = [];
skipNodes = [];
iterator = null;
bindingRegExp = this.bindingRegExp();
eventRegExp = /^on-/;
classRegExp = /^class-/;
iterationRegExp = /^each-/;
parseNode = function(node) {
var a, attribute, binding, context, ctx, dependencies, keypath, model, n, options, path, pipe, pipes, splitPath, type, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _results;
......@@ -230,6 +233,10 @@
type = type.replace(eventRegExp, '');
options.special = "event";
}
if (classRegExp.test(type)) {
type = type.replace(classRegExp, '');
options.special = "class";
}
if (iterationRegExp.test(type)) {
type = type.replace(iterationRegExp, '');
options.special = "iteration";
......@@ -335,6 +342,17 @@
};
};
classBinding = function(name) {
return function(el, value) {
var elClass, hasClass;
elClass = " " + el.className + " ";
hasClass = elClass.indexOf(" " + name + " ") !== -1;
if (!value === hasClass) {
return el.className = value ? "" + el.className + " " + name : elClass.replace(" " + name + " ", " ").trim();
}
};
};
iterationBinding = function(name) {
return function(el, collection, binding) {
var data, item, itemEl, iteration, m, n, previous, _i, _j, _len, _len1, _ref, _ref1, _results;
......
{
"name" : "rivets",
"description" : "Declarative data binding facility.",
"version" : "0.3.2",
"version" : "0.3.3",
"author" : "Michael Richards",
"url" : "http://rivetsjs.com",
"main" : "./lib/rivets.js",
......
# rivets.js
# version : 0.3.2
# version : 0.3.3
# author : Michael Richards
# license : MIT
......