serenade_rails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Serenade.js JavaScript Framework v0.1.2
2
+ * Serenade.js JavaScript Framework v0.1.3
3
3
  * http://github.com/elabs/serenade.js
4
4
  *
5
5
  * Copyright 2011, Jonas Nicklas, Elabs AB
6
6
  * Released under the MIT License
7
7
  */
8
- (function(a){var b=function(){function a(b){return a[b]}return a["./events"]=new function(){var a=this;((function(){var b=Array.prototype.slice;a.Events={bind:function(a,b){var c,d,e,f,g;d=a.split(" "),c=this.hasOwnProperty("_callbacks")&&this._callbacks||(this._callbacks={});for(f=0,g=d.length;f<g;f++)e=d[f],c[e]||(c[e]=[]),c[e].push(b);return this},one:function(a,b){return this.bind(a,function(){return this.unbind(a,arguments.callee),b.apply(this,arguments)})},trigger:function(){var a,c,d,e,f,g,h;a=1<=arguments.length?b.call(arguments,0):[],d=a.shift(),typeof recordEvents!="undefined"&&recordEvents!==null&&(this._triggeredEvents||(this._triggeredEvents={}),this._triggeredEvents[d]=a),e=this.hasOwnProperty("_callbacks")&&((h=this._callbacks)!=null?h[d]:void 0);if(!e)return!1;for(f=0,g=e.length;f<g;f++)c=e[f],c.apply(this,a);return!0},unbind:function(a,b){var c,d,e,f,g;if(!a)return this._callbacks={},this;e=(g=this._callbacks)!=null?g[a]:void 0;if(!e)return this;if(!b)return delete this._callbacks[a],this;for(d=0,f=e.length;d<f;d++){c=e[d];if(c!==b)continue;e=e.slice(),e.splice(d,1),this._callbacks[a]=e;break}return this}}})).call(this)},a["./helpers"]=new function(){var a=this;((function(){var b;b={extend:function(a,b){var c,d,e;e=[];for(c in b)d=b[c],Object.prototype.hasOwnProperty.call(b,c)?e.push(a[c]=d):e.push(void 0);return e},get:function(a,b,c){return c==null&&(c=!0),c&&(a!=null?a.get:void 0)?a.get(b):c?a!=null?a[b]:void 0:b},format:function(a,c,d){return d==null&&(d=!0),d&&a.format?a.format(c):b.get(a,c,d)},forEach:function(a,b){var c,d,e,f;if(typeof a.forEach=="function")return a.forEach(b);f=[];for(d=0,e=a.length;d<e;d++)c=a[d],f.push(b(c));return f},map:function(a,b){var c,d,e,f;if(typeof a.map=="function")return a.map(b);f=[];for(d=0,e=a.length;d<e;d++)c=a[d],f.push(b(c));return f},isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},pairToObject:function(a,b){var c;return c={},c[a]=b,c},serializeObject:function(a){return a&&typeof a.serialize=="function"?a.serialize():b.isArray(a)?b.map(a,function(a){return b.serializeObject(a)}):a},indexOf:function(a,b){var c,d,e;if(a.indexOf)return a.indexOf(b);for(c=0,e=a.length;c<e;c++){d=a[c];if(d===b)return c}return-1},deleteItem:function(a,c){return a.splice(b.indexOf(c),1)},getFunctionName:function(a){var b,c,d;return b=a.modelName,b||(b=a.name),b||(b=(c=a.toString().match(/\[object (.+?)\]/))!=null?c[1]:void 0),b||(b=(d=a.toString().match(/function (.+?)\(\)/))!=null?d[1]:void 0),b},preventDefault:function(a){return a.preventDefault?a.preventDefault():a.returnValue=!1}},b.extend(a,b)})).call(this)},a["./cache"]=new function(){var b=this;((function(){var c,d,e,f;f=a("./helpers"),e=f.serializeObject,d=f.getFunctionName,c={_storage:typeof window!="undefined"&&window!==null?window.localStorage:void 0,_identityMap:{},get:function(a,b){var c,e;c=d(a);if(c&&b)return((e=this._identityMap[c])!=null?e[b]:void 0)||this.retrieve(a,b)},set:function(a,b,c){var e,f;e=d(a);if(e&&b)return(f=this._identityMap)[e]||(f[e]={}),this._identityMap[e][b]=c},store:function(a,b,c){var f;f=d(a);if(f&&b&&typeof JSON!="undefined"&&JSON!==null)return this._storage.setItem(""+f+"_"+b,JSON.stringify(e(c)))},retrieve:function(a,b){var c,e;e=d(a);if(e&&b&&a.localStorage&&typeof JSON!="undefined"&&JSON!==null){c=this._storage.getItem(""+e+"_"+b);if(c)return new a(JSON.parse(c),!0)}}},b.Cache=c})).call(this)},a["./collection"]=new function(){var b=this;((function(){var c,d,e,f,g,h,i;c=a("./events").Events,i=a("./helpers"),e=i.extend,f=i.forEach,h=i.serializeObject,d=i.deleteItem,g=i.indexOf,b.Collection=function(){function a(a){var b=this;this.list=a,this.length=this.list.length,this.bind("change",function(){return b.length=b.list.length})}return e(a.prototype,c),a.prototype.get=function(a){return this.list[a]},a.prototype.set=function(a,b){return this._notIn(this.list[a]),this.list[a]=b,this._in(b),this.trigger("change:"+a,b),this.trigger("set",a,b),this.trigger("change",this.list)},a.prototype.push=function(a){return this.list.push(a),this._in(a),this.trigger("add",a),this.trigger("change",this.list)},a.prototype.update=function(a){var b,c,d,e,f,g;g=this.list;for(c=0,e=g.length;c<e;c++)b=g[c],this._notIn(b);this.list=a;for(d=0,f=a.length;d<f;d++)b=a[d],this._in(b);return this.trigger("update",a),this.trigger("change",this.list)},a.prototype.forEach=function(a){return f(this.list,a)},a.prototype.map=function(a){var b,c,d,e,f;e=this.list,f=[];for(c=0,d=e.length;c<d;c++)b=e[c],f.push(a(b));return f},a.prototype.indexOf=function(a){return g(this.list,a)},a.prototype.deleteAt=function(a){return this._notIn(this.list[a]),this.list.splice(a,1),this.trigger("delete",a),this.trigger("change",this.list)},a.prototype["delete"]=function(a){return this.deleteAt(this.indexOf(a))},a.prototype.serialize=function(){return h(this.list)},a.prototype.select=function(a){var b,c,d,e,f;e=this.list,f=[];for(c=0,d=e.length;c<d;c++)b=e[c],a(b)&&f.push(b);return f},a.prototype._in=function(a){var b;if(typeof a=="object"&&a._triggerChangesTo)return a._inCollections||(a._inCollections=[]),(b=a._inCollections)!=null?b.push(this):void 0},a.prototype._notIn=function(a){if(a!=null?a._inCollections:void 0)return d(a._inCollections,this)},a}()})).call(this)},a["./association_collection"]=new function(){var b=this;((function(){var c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=a("./collection").Collection,c=function(a){function b(a,c){var d;this.ctor=a,this.list=c,b.__super__.constructor.call(this,function(){var a,b,e;e=[];for(a=0,b=c.length;a<b;a++)d=c[a],e.push(this._convert(d));return e}.call(this))}return f(b,a),b.prototype.set=function(a,c){return b.__super__.set.call(this,a,this._convert(c))},b.prototype.push=function(a){return b.__super__.push.call(this,this._convert(a))},b.prototype.update=function(a){var c;return b.__super__.update.call(this,function(){var b,d,e;e=[];for(b=0,d=a.length;b<d;b++)c=a[b],e.push(this._convert(c));return e}.call(this))},b.prototype._convert=function(a){var b;return b=this.ctor(),a.constructor===b?a:new b(a)},b}(d),b.AssociationCollection=c})).call(this)},a["./associations"]=new function(){var b=this;((function(){var c,d,e,f,g,h,i;c=a("./association_collection").AssociationCollection,e=a("./collection").Collection,i=a("./helpers"),f=i.extend,h=i.map,g=i.get,d=function(){function a(){}return a.belongsTo=function(a,b){var c;return b==null&&(b={}),c=b.as||function(){return Object},f(b,{set:function(b){return this.attributes[a]=new(c())(b)}}),this.property(a,b),this.property(a+"Id",{get:function(){return g(this.get(a),"id")},set:function(b){return this.attributes[a]=c().find(b)},dependsOn:a})},a.hasMany=function(a,b){var d;return b==null&&(b={}),d=b.as||function(){return Object},f(b,{get:function(){var b=this;return this.attributes[a]||(this.attributes[a]=new c(d,[]),this.attributes[a].bind("change",function(){return b._triggerChangesTo([a])})),this.attributes[a]},set:function(b){return this.get(a).update(b)}}),this.property(a,b),this.property(a+"Ids",{get:function(){return new e(this.get(a).map(function(a){return g(a,"id")}))},set:function(b){var e;return e=h(b,function(a){return d().find(a)}),this.attributes[a]=new c(d,e)},dependsOn:a})},a}(),b.Associations=d})).call(this)},a["./serenade"]=new function(){var b=this;((function(){var c,d,e;c=a("./cache").Cache,e=a("./helpers").extend,d={VERSION:"0.1.2",_views:{},_controllers:{},_formats:{},document:typeof window!="undefined"&&window!==null?window.document:void 0,view:function(b,c){var d;return d=a("./view").View,c?this._views[b]=new d(c):new d(b)},render:function(a,b,c){return b||(b={}),c||(c=this.controllerFor(a,b)),c||(c={}),this._views[a].render(b,c)},controller:function(a,b){return this._controllers[a]=b},controllerFor:function(a,b){if(this._controllers[a])return new this._controllers[a](b)},registerFormat:function(a,b){return this._formats[a]=b},clearIdentityMap:function(){return c._identityMap={}},clearLocalStorage:function(){return c._storage.clear()},clearCache:function(){return d.clearIdentityMap(),d.clearLocalStorage()},unregisterAll:function(){return d._views={},d._controllers={},d._formats={}},bindEvent:function(a,b,c){return typeof a.addEventListener=="function"?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)},useJQuery:function(){return this.bindEvent=function(a,b,c){return jQuery(a).bind(b,c)}},extend:e,Events:a("./events").Events,Collection:a("./collection").Collection,Helpers:{}},b.Serenade=d,b.compile=function(){var b,c,e;return b=a("jsdom").jsdom(null,null,{}),c=a("fs"),e=b.createWindow(),d.document=b,function(a){var e,f,g,h;return g=a.model,h=a.filename.split("/").reverse()[0].replace(/\.serenade$/,""),d.view(h,c.readFileSync(a.filename).toString()),e=d.render(h,g,{}),b.body.appendChild(e),f=b.body.innerHTML,a.doctype!==!1&&(f="<!DOCTYPE html>\n"+f),f}}})).call(this)},a["./lexer"]=new function(){var a=this;((function(){var b,c,d,e,f,g;b=/^[a-zA-Z][a-zA-Z0-9\-_]*/,c=/^[\[\]=\:\-!#\.@]/,f=/^"((?:\\.|[^"])*)"/,e=/^(?:\n[^\n\S]*)+/,g=/^[^\n\S]+/,d=function(){function a(){}return a.prototype.tokenize=function(a,b){var c,d;b==null&&(b={}),this.code=a.replace(/^\s*/,""),this.line=b.line||0,this.indent=0,this.indents=[],this.ends=[],this.tokens=[],c=0;while(this.chunk=this.code.slice(c))c+=this.identifierToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.literalToken();while(d=this.ends.pop())d==="OUTDENT"?this.token("OUTDENT"):this.error("missing "+d);return this.tokens},a.prototype.whitespaceToken=function(){var a;return(a=g.exec(this.chunk))?(this.token("WHITESPACE",a[0].length),a[0].length):0},a.prototype.token=function(a,b){return this.tokens.push([a,b,this.line])},a.prototype.identifierToken=function(){var a;return(a=b.exec(this.chunk))?(this.token("IDENTIFIER",a[0]),a[0].length):0},a.prototype.stringToken=function(){var a;return(a=f.exec(this.chunk))?(this.token("STRING_LITERAL",a[1]),a[0].length):0},a.prototype.lineToken=function(){var a,b,c,d,f;if(!(c=e.exec(this.chunk)))return 0;b=c[0],this.line+=this.count(b,"\n"),d=this.last(this.tokens,1),f=b.length-1-b.lastIndexOf("\n"),a=f-this.indent;if(f===this.indent)this.newlineToken();else if(f>this.indent)this.token("INDENT"),this.indents.push(a),this.ends.push("OUTDENT");else{while(a<0)this.last(this.ends)!=="OUTDENT"&&this.error("Should be an OUTDENT, yo"),this.ends.pop(),a+=this.indents.pop(),this.token("OUTDENT");this.token("TERMINATOR","\n")}return this.indent=f,b.length},a.prototype.literalToken=function(){var a;return(a=c.exec(this.chunk))?(this.token(a[0]),1):this.error("WUT??? is '"+this.chunk.charAt(0)+"'")},a.prototype.newlineToken=function(){if(this.tag()!=="TERMINATOR")return this.token("TERMINATOR","\n")},a.prototype.tag=function(a,b){var c;return(c=this.last(this.tokens,a))&&(b?c[0]=b:c[0])},a.prototype.value=function(a,b){var c;return(c=this.last(this.tokens,a))&&(b?c[1]=b:c[1])},a.prototype.error=function(a){throw SyntaxError(""+a+" on line "+(this.line+1))},a.prototype.count=function(a,b){var c,d;c=d=0;if(!b.length)return 1/0;while(d=1+a.indexOf(b,d))c++;return c},a.prototype.last=function(a,b){return a[a.length-(b||0)-1]},a}(),a.Lexer=d})).call(this)},a["./nodes"]=new function(){var b=this;((function(){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u=function(a,b){return function(){return a.apply(b,arguments)}};l=a("./serenade").Serenade,t=a("./helpers"),q=t.format,r=t.get,p=t.forEach,s=t.preventDefault,j=function(){function a(a,b,c,d){var e,f,g,h,i,j,l,m,n;this.ast=a,this.document=b,this.model=c,this.controller=d,this.element=this.document.createElement(this.ast.name),this.ast.id&&this.element.setAttribute("id",this.ast.id),((l=this.ast.classes)!=null?l.length:void 0)&&this.element.setAttribute("class",this.ast.classes.join(" ")),m=this.ast.properties;for(g=0,i=m.length;g<i;g++)f=m[g],k.property(f,this,this.document,this.model,this.controller);n=this.ast.children;for(h=0,j=n.length;h<j;h++)e=n[h],k.compile(e,this.document,this.model,this.controller).append(this.element)}return a.prototype.append=function(a){return a.appendChild(this.element)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.element,a.nextSibling)},a.prototype.remove=function(){return this.element.parentNode.removeChild(this.element)},a.prototype.lastElement=function(){return this.element},a}(),m=function(){function a(a,b,c,d,e){var f,g=this;this.ast=a,this.node=b,this.document=c,this.model=d,this.controller=e,this.element=this.node.element,this.update(),this.ast.bound&&typeof (f=this.model).bind=="function"&&f.bind("change:"+this.ast.value,function(a){return g.update()})}return a.prototype.update=function(){return this.element.style[this.ast.name]=this.get()},a.prototype.get=function(){return q(this.model,this.ast.value,this.ast.bound)},a}(),f=function(){function a(a,b,c,d,e){var f,g;this.ast=a,this.node=b,this.document=c,this.model=d,this.controller=e,this.element=this.node.element,g=this,f=function(a){return g.ast.preventDefault&&s(a),g.controller[g.ast.value](a)},l.bindEvent(this.element,this.ast.name,f)}return a}(),c=function(){function a(a,b,c,d,e){var f,g=this;this.ast=a,this.node=b,this.document=c,this.model=d,this.controller=e,this.element=this.node.element,this.update(),this.ast.bound&&typeof (f=this.model).bind=="function"&&f.bind("change:"+this.ast.value,function(a){return g.update()})}return a.prototype.update=function(){var a,b;return b=this.get(),this.ast.name==="value"?this.element.value=b||"":this.node.ast.name==="input"&&this.ast.name==="checked"?this.element.checked=!!b:this.ast.name==="class"?(a=this.node.ast.classes,b!==void 0&&(a=a.concat(b)),a.length?this.element.setAttribute(this.ast.name,a.join(" ")):this.element.removeAttribute(this.ast.name)):b===void 0?this.element.removeAttribute(this.ast.name):(b===0&&(b="0"),this.element.setAttribute(this.ast.name,b))},a.prototype.get=function(){return q(this.model,this.ast.value,this.ast.bound)},a}(),n=function(){function a(a,b,c,d){var e=this;this.ast=a,this.document=b,this.model=c,this.controller=d,this.textNode=b.createTextNode(this.get()),this.ast.bound&&typeof c.bind=="function"&&c.bind("change:"+this.ast.value,function(){return e.textNode.nodeValue=e.get()})}return a.prototype.append=function(a){return a.appendChild(this.textNode)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.textNode,a.nextSibling)},a.prototype.remove=function(){return this.textNode.parentNode.removeChild(this.textNode)},a.prototype.lastElement=function(){return this.textNode},a.prototype.get=function(){var a;return a=q(this.model,this.ast.value,this.ast.bound),a===0&&(a="0"),a||""},a}(),o=function(){function a(a,b,c,d){this.ast=a,this.document=b,this.model=c,this.parentController=d,this.controller=l.controllerFor(this.ast.arguments[0],this.model),this.controller&&(this.controller.parent=this.parentController),this.view=l.render(this.ast.arguments[0],this.model,this.controller||this.parentController,this.document)}return a.prototype.append=function(a){return a.appendChild(this.view)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.view,a.nextSibling)},a.prototype.remove=function(){return this.view.parentNode.removeChild(this.view)},a.prototype.lastElement=function(){return this.view},a}(),h=function(){function a(a,b,c,d){var e;this.ast=a,this.document=b,this.model=c,this.controller=d,this.build=u(this.build,this),this.anchor=b.createTextNode(""),typeof (e=this.model).bind=="function"&&e.bind("change:"+this.ast.arguments[0],this.build)}return a.prototype.build=function(){var a,b,c,d,e,f;if(r(this.model,this.ast.arguments[0])){this.nodes||(this.nodes=function(){var b,c,d,e;d=this.ast.children,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(k.compile(a,this.document,this.model,this.controller));return e}.call(this)),e=this.nodes,f=[];for(b=0,d=e.length;b<d;b++)c=e[b],f.push(c.insertAfter(this.nodes[b-1]||this.anchor));return f}return this.removeNodes()},a.prototype.append=function(a){return a.appendChild(this.anchor),this.build()},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.anchor,a.nextSibling),this.build()},a.prototype.remove=function(){return this.removeNodes(),this.anchor.parentNode.removeChild(this.anchor)},a.prototype.removeNodes=function(){var a,b,c,d;if(this.nodes){d=this.nodes;for(b=0,c=d.length;b<c;b++)a=d[b],a.remove()}return this.nodes=void 0},a.prototype.lastElement=function(){return this.nodes[this.nodes.length-1].lastElement()},a}(),i=function(){function a(a,b,c,d){var e;this.ast=a,this.document=b,this.model=c,this.controller=d,this.build=u(this.build,this),this.anchor=b.createTextNode(""),typeof (e=this.model).bind=="function"&&e.bind("change:"+this.ast.arguments[0],this.build)}return a.prototype.build=function(){var a,b,c,d,e,f,g;this.removeNodes(),d=r(this.model,this.ast.arguments[0]),this.nodes=function(){var b,c,e,f;e=this.ast.children,f=[];for(b=0,c=e.length;b<c;b++)a=e[b],f.push(k.compile(a,this.document,d,this.controller));return f}.call(this),f=this.nodes,g=[];for(b=0,e=f.length;b<e;b++)c=f[b],g.push(c.insertAfter(this.nodes[b-1]||this.anchor));return g},a.prototype.append=function(a){return a.appendChild(this.anchor),this.build()},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.anchor,a.nextSibling),this.build()},a.prototype.remove=function(){return this.removeNodes(),this.anchor.parentNode.removeChild(this.anchor)},a.prototype.removeNodes=function(){var a,b,c,d;if(this.nodes){d=this.nodes;for(b=0,c=d.length;b<c;b++)a=d[b],a.remove()}return this.nodes=void 0},a.prototype.lastElement=function(){return this.nodes[this.nodes.length-1].lastElement()},a}(),d=function(){function a(a,b,c,d){var e=this;this.ast=a,this.document=b,this.model=c,this.controller=d,this.anchor=b.createTextNode(""),this.collection=this.get(),this.collection.bind&&(this.collection.bind("update",function(){return e.rebuild()}),this.collection.bind("set",function(){return e.rebuild()}),this.collection.bind("add",function(a){return e.appendItem(a)}),this.collection.bind("delete",function(a){return e["delete"](a)}))}return a.prototype.rebuild=function(){var a,b,c,d;d=this.items;for(b=0,c=d.length;b<c;b++)a=d[b],a.remove();return this.build()},a.prototype.build=function(){var a=this;return this.items=[],p(this.collection,function(b){return a.appendItem(b)})},a.prototype.appendItem=function(a){var b;return b=new e(this.ast.children,this.document,a,this.controller),b.insertAfter(this.lastElement()),this.items.push(b)},a.prototype["delete"]=function(a){return this.items[a].remove(),this.items.splice(a,1)},a.prototype.lastItem=function(){return this.items[this.items.length-1]},a.prototype.lastElement=function(){var a;return a=this.lastItem(),a?a.lastElement():this.anchor},a.prototype.remove=function(){var a,b,c,d,e;this.anchor.parentNode.removeChild(this.anchor),d=this.items,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.remove());return e},a.prototype.append=function(a){return a.appendChild(this.anchor),this.build()},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.anchor,a.nextSibling),this.build()},a.prototype.get=function(){return r(this.model,this.ast.arguments[0])},a}(),g=function(){function a(a,b,c,d){this.ast=a,this.document=b,this.model=c,this.controller=d,this.render=u(this.render,this),this.helperFunction=l.Helpers[this.ast.command]||function(){throw SyntaxError("no helper "+this.ast.command+" defined")}.call(this),this.context={document:this.document,render:this.render,model:this.model,controller:this.controller},this.element=this.helperFunction.apply(this.context,this.ast.arguments)}return a.prototype.render=function(a,b,c){var d,e,f,g,h,i;b==null&&(b=this.model),c==null&&(c=this.controller),h=this.ast.children,i=[];for(f=0,g=h.length;f<g;f++)d=h[f],e=k.compile(d,this.document,b,c),i.push(e.append(a));return i},a.prototype.lastElement=function(){var a;return a=this.lastItem(),a?a.lastElement():this.anchor},a.prototype.remove=function(){var a,b,c,d,e;this.element.parentNode.removeChild(this.element),d=this.items,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.remove());return e},a.prototype.append=function(a){return a.appendChild(this.element)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.element,a.nextSibling)},a}(),e=function(){function a(a,b,c,d){var e;this.children=a,this.document=b,this.model=c,this.controller=d,this.nodes=function(){var a,b,c,d;c=this.children,d=[];for(a=0,b=c.length;a<b;a++)e=c[a],d.push(k.compile(e,this.document,this.model,this.controller));return d}.call(this)}return a.prototype.insertAfter=function(a){var b,c,d,e,f,g;b=a,f=this.nodes,g=[];for(d=0,e=f.length;d<e;d++)c=f[d],c.insertAfter(b),g.push(b=c.lastElement());return g},a.prototype.lastElement=function(){return this.nodes[this.nodes.length-1].lastElement()},a.prototype.remove=function(){var a,b,c,d,e;d=this.nodes,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.remove());return e},a}(),k={compile:function(a,b,c,e){switch(a.type){case"element":return new j(a,b,c,e);case"text":return new n(a,b,c,e);case"instruction":switch(a.command){case"view":return new o(a,b,c,e);case"collection":return new d(a,b,c,e);case"if":return new h(a,b,c,e);case"in":return new i(a,b,c,e);default:return new g(a,b,c,e)}break;default:throw SyntaxError("unknown type '"+a.type+"'")}},property:function(a,b,d,e,g){switch(a.scope){case"attribute":return new c(a,b,d,e,g);case"style":return new m(a,b,d,e,g);case"event":return new f(a,b,d,e,g);default:throw SyntaxError(""+a.scope+" is not a valid scope")}}},b.Nodes=k})).call(this)},a["./parser"]=new function(){var b=this,c=function(){undefined;var a={trace:function(){},yy:{},symbols_:{error:2,Root:3,Element:4,TERMINATOR:5,ElementIdentifier:6,IDENTIFIER:7,"#":8,".":9,"[":10,"]":11,PropertyList:12,WHITESPACE:13,Text:14,INDENT:15,ChildList:16,OUTDENT:17,TextList:18,Bound:19,STRING_LITERAL:20,Child:21,Instruction:22,Property:23,"=":24,"!":25,":":26,"-":27,"@":28,$accept:0,$end:1},terminals_:{2:"error",5:"TERMINATOR",7:"IDENTIFIER",8:"#",9:".",10:"[",11:"]",13:"WHITESPACE",15:"INDENT",17:"OUTDENT",20:"STRING_LITERAL",24:"=",25:"!",26:":",27:"-",28:"@"},productions_:[0,[3,0],[3,1],[3,2],[6,1],[6,3],[6,2],[6,2],[6,3],[4,1],[4,3],[4,4],[4,3],[4,4],[18,1],[18,3],[14,1],[14,1],[16,1],[16,3],[21,1],[21,1],[21,1],[12,1],[12,3],[23,3],[23,3],[23,4],[23,4],[23,3],[23,3],[22,3],[22,3],[22,4],[19,2]],performAction:function(b,c,d,e,f,g,h){var i=g.length-1;switch(f){case 1:this.$=null;break;case 2:return this.$;case 3:return this.$;case 4:this.$={name:g[i],classes:[]};break;case 5:this.$={name:g[i-2],id:g[i],classes:[]};break;case 6:this.$={name:"div",id:g[i],classes:[]};break;case 7:this.$={name:"div",classes:[g[i]]};break;case 8:this.$=function(){return g[i-2].classes.push(g[i]),g[i-2]}();break;case 9:this.$={name:g[i].name,id:g[i].id,classes:g[i].classes,properties:[],children:[],type:"element"};break;case 10:this.$=g[i-2];break;case 11:this.$=function(){return g[i-3].properties=g[i-1],g[i-3]}();break;case 12:this.$=function(){return g[i-2].children=g[i-2].children.concat(g[i]),g[i-2]}();break;case 13:this.$=function(){return g[i-3].children=g[i-3].children.concat(g[i-1]),g[i-3]}();break;case 14:this.$=[g[i]];break;case 15:this.$=g[i-2].concat(g[i]);break;case 16:this.$={type:"text",value:g[i],bound:!0};break;case 17:this.$={type:"text",value:g[i],bound:!1};break;case 18:this.$=[].concat(g[i]);break;case 19:this.$=g[i-2].concat(g[i]);break;case 20:this.$=g[i];break;case 21:this.$=g[i];break;case 22:this.$=g[i];break;case 23:this.$=[g[i]];break;case 24:this.$=g[i-2].concat(g[i]);break;case 25:this.$={name:g[i-2],value:g[i],bound:!0,scope:"attribute"};break;case 26:this.$={name:g[i-2],value:g[i],bound:!0,scope:"attribute"};break;case 27:this.$={name:g[i-3],value:g[i-1],bound:!0,scope:"attribute",preventDefault:!0};break;case 28:this.$={name:g[i-3],value:g[i-1],bound:!0,scope:"attribute",preventDefault:!0};break;case 29:this.$={name:g[i-2],value:g[i],bound:!1,scope:"attribute"};break;case 30:this.$=function(){return g[i].scope=g[i-2],g[i]}();break;case 31:this.$={command:g[i],arguments:[],children:[],type:"instruction"};break;case 32:this.$=function(){return g[i-2].arguments.push(g[i].value),g[i-2]}();break;case 33:this.$=function(){return g[i-3].children=g[i-1],g[i-3]}();break;case 34:this.$=g[i]}},table:[{1:[2,1],3:1,4:2,6:3,7:[1,4],8:[1,5],9:[1,6]},{1:[3]},{1:[2,2],5:[1,7],10:[1,8],13:[1,9],15:[1,10]},{1:[2,9],5:[2,9],9:[1,11],10:[2,9],13:[2,9],15:[2,9],17:[2,9]},{1:[2,4],5:[2,4],8:[1,12],9:[2,4],10:[2,4],13:[2,4],15:[2,4],17:[2,4]},{7:[1,13]},{7:[1,14]},{1:[2,3]},{7:[1,18],11:[1,15],12:16,23:17},{14:19,19:20,20:[1,21],28:[1,22]},{4:25,6:3,7:[1,4],8:[1,5],9:[1,6],14:29,16:23,18:27,19:20,20:[1,21],21:24,22:26,27:[1,28],28:[1,22]},{7:[1,30]},{7:[1,31]},{1:[2,6],5:[2,6],9:[2,6],10:[2,6],13:[2,6],15:[2,6],17:[2,6]},{1:[2,7],5:[2,7],9:[2,7],10:[2,7],13:[2,7],15:[2,7],17:[2,7]},{1:[2,10],5:[2,10],10:[2,10],13:[2,10],15:[2,10],17:[2,10]},{11:[1,32],13:[1,33]},{11:[2,23],13:[2,23]},{24:[1,34],26:[1,35]},{1:[2,12],5:[2,12],10:[2,12],13:[2,12],15:[2,12],17:[2,12]},{1:[2,16],5:[2,16],10:[2,16],13:[2,16],15:[2,16],17:[2,16]},{1:[2,17],5:[2,17],10:[2,17],13:[2,17],15:[2,17],17:[2,17]},{7:[1,36]},{5:[1,38],17:[1,37]},{5:[2,18],17:[2,18]},{5:[2,20],10:[1,8],13:[1,9],15:[1,10],17:[2,20]},{5:[2,21],13:[1,39],15:[1,40],17:[2,21]},{5:[2,22],13:[1,41],17:[2,22]},{13:[1,42]},{5:[2,14],13:[2,14],17:[2,14]},{1:[2,8],5:[2,8],9:[2,8],10:[2,8],13:[2,8],15:[2,8],17:[2,8]},{1:[2,5],5:[2,5],9:[2,5],10:[2,5],13:[2,5],15:[2,5],17:[2,5]},{1:[2,11],5:[2,11],10:[2,11],13:[2,11],15:[2,11],17:[2,11]},{7:[1,18],23:43},{7:[1,44],19:45,20:[1,46],28:[1,22]},{7:[1,18],23:47},{1:[2,34],5:[2,34],10:[2,34],11:[2,34],13:[2,34],15:[2,34],17:[2,34],25:[2,34]},{1:[2,13],5:[2,13],10:[2,13],13:[2,13],15:[2,13],17:[2,13]},{4:25,6:3,7:[1,4],8:[1,5],9:[1,6],14:29,18:27,19:20,20:[1,21],21:48,22:26,27:[1,28],28:[1,22]},{14:49,19:20,20:[1,21],28:[1,22]},{4:25,6:3,7:[1,4],8:[1,5],9:[1,6],14:29,16:50,18:27,19:20,20:[1,21],21:24,22:26,27:[1,28],28:[1,22]},{14:51,19:20,20:[1,21],28:[1,22]},{7:[1,52]},{11:[2,24],13:[2,24]},{11:[2,25],13:[2,25],25:[1,53]},{11:[2,26],13:[2,26],25:[1,54]},{11:[2,29],13:[2,29]},{11:[2,30],13:[2,30]},{5:[2,19],17:[2,19]},{5:[2,32],13:[2,32],15:[2,32],17:[2,32]},{5:[1,38],17:[1,55]},{5:[2,15],13:[2,15],17:[2,15]},{5:[2,31],13:[2,31],15:[2,31],17:[2,31]},{11:[2,27],13:[2,27]},{11:[2,28],13:[2,28]},{5:[2,33],13:[2,33],15:[2,33],17:[2,33]}],defaultActions:{7:[2,3]},parseError:function(b,c){throw new Error(b)},parse:function(b){function o(a){d.length=d.length-2*a,e.length=e.length-a,f.length=f.length-a}function p(){var a;return a=c.lexer.lex()||1,typeof a!="number"&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(b),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var q,r,s,t,u,v,w={},x,y,z,A;for(;;){s=d[d.length-1],this.defaultActions[s]?t=this.defaultActions[s]:(q==null&&(q=p()),t=g[s]&&g[s][q]);if(typeof t=="undefined"||!t.length||!t[0]){if(!k){A=[];for(x in g[s])this.terminals_[x]&&x>2&&A.push("'"+this.terminals_[x]+"'");var B="";this.lexer.showPosition?B="Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+A.join(", ")+", got '"+this.terminals_[q]+"'":B="Parse error on line "+(i+1)+": Unexpected "+(q==1?"end of input":"'"+(this.terminals_[q]||q)+"'"),this.parseError(B,{text:this.lexer.match,token:this.terminals_[q]||q,line:this.lexer.yylineno,loc:n,expected:A})}if(k==3){if(q==m)throw new Error(B||"Parsing halted.");j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,q=p()}for(;;){if(l.toString()in g[s])break;if(s==0)throw new Error(B||"Parsing halted.");o(1),s=d[d.length-1]}r=q,q=l,s=d[d.length-1],t=g[s]&&g[s][l],k=3}if(t[0]instanceof Array&&t.length>1)throw new Error("Parse Error: multiple actions possible at state: "+s+", token: "+q);switch(t[0]){case 1:d.push(q),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(t[1]),q=null,r?(q=r,r=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:y=this.productions_[t[1]][1],w.$=e[e.length-y],w._$={first_line:f[f.length-(y||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(y||1)].first_column,last_column:f[f.length-1].last_column},v=this.performAction.call(w,h,j,i,this.yy,t[1],e,f);if(typeof v!="undefined")return v;y&&(d=d.slice(0,-1*y*2),e=e.slice(0,-1*y),f=f.slice(0,-1*y)),d.push(this.productions_[t[1]][0]),e.push(w.$),f.push(w._$),z=g[d[d.length-2]][d[d.length-1]],d.push(z);break;case 3:return!0}}return!0}};return a}();typeof a!="undefined"&&typeof b!="undefined"&&(b.parser=c,b.parse=function(){return c.parse.apply(c,arguments)},b.main=function(d){if(!d[1])throw new Error("Usage: "+d[0]+" FILE");if(typeof process!="undefined")var e=a("fs").readFileSync(a("path").join(process.cwd(),d[1]),"utf8");else var f=a("file").path(a("file").cwd()),e=f.join(d[1]).read({charset:"utf-8"});return b.parser.parse(e)},typeof module!="undefined"&&a.main===module&&b.main(typeof process!="undefined"?process.argv.slice(1):a("system").args))},a["./properties"]=new function(){var b=this;((function(){var b,c,d,e,f,g,h,i,j,k,l,m=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};d=a("./serenade").Serenade,b=a("./collection").Collection,c=a("./events").Events,l=a("./helpers"),i=l.pairToObject,k=l.serializeObject,g=l.extend,h=l.map,j="_prop_",f=/^_prop_/,e=Object.defineProperties,d.Properties={property:function(a,b){b==null&&(b={}),this[j+a]=b,this[j+a].name=a,e&&Object.defineProperty(this,a,{get:function(){return d.Properties.get.call(this,a)},set:function(b){return d.Properties.set.call(this,a,b)}});if(typeof b.serialize=="string")return this.property(b.serialize,{get:function(){return this.get(a)},set:function(b){return this.set(a,b)}})},collection:function(a,c){return this.property(a,{get:function(){var c=this;return this.attributes[a]||(this.attributes[a]=new b([]),this.attributes[a].bind("change",function(){return c._triggerChangesTo([a])}),this.attributes[a]._deferTo=i(a,this)),this.attributes[a]},set:function(b){return this.get(a).update(b)}})},set:function(a,b){var c,d,e;typeof a=="string"&&(a=i(a,b)),d=[];for(c in a)b=a[c],this._undefer(c),d.push(c),this.attributes||(this.attributes={}),((e=this[j+c])!=null?e.set:void 0)?this[j+c].set.call(this,b):this.attributes[c]=b,this._defer(c);return this._triggerChangesTo(d)},get:function(a){var b;return this.attributes||(this.attributes={}),((b=this[j+a])!=null?b.get:void 0)?this[j+a].get.call(this):this.attributes[a]},format:function(a){var b,c;return b=(c=this[j+a])!=null?c.format:void 0,typeof b=="string"?d._formats[b].call(this,this.get(a)):typeof b=="function"?b.call(this,this.get(a)):this.get(a)},serialize:function(){var a,b,c,d,e,g;d={};for(b in this)c=this[b],b.match(f)&&(typeof c.serialize=="string"?d[c.serialize]=k(this.get(c.name)):typeof c.serialize=="function"?(g=c.serialize.call(this),a=g[0],e=g[1],d[a]=k(e)):c.serialize&&(d[c.name]=k(this.get(c.name))));return d},_defer:function(a){var b,c;b=this.get(a);if(typeof b=="object"&&b._triggerChangesTo)return b._deferTo||(b._deferTo={}),(c=b._deferTo)!=null?c[a]=this:void 0},_undefer:function(a){var b;b=this.get(a);if(b!=null?b._deferTo:void 0)return delete b._deferTo[a]},_triggerChangesTo:function(a){var b,c,d,i,j,k,l,n,o,p,q,r,s,t,u,v,w,x,y,z=this;o=function(a){return[].concat(a)},d=function(b){var c,e,g,h;h=[];for(c in z)e=z[c],c.match(f)&&e.dependsOn&&(m.call(o(e.dependsOn),b)>=0&&(g=e.name,m.call(a,g)<0)?(a.push(e.name),h.push(d(e.name))):h.push(void 0));return h};for(r=0,u=a.length;r<u;r++)p=a[r],d(p);c={};for(s=0,v=a.length;s<v;s++)n=a[s],q=this.get(n),this.trigger("change:"+n,q),c[n]=q,e||(this[n]=this.get(n));this.trigger("change",c),b=this._deferTo||[];if(this._inCollections){x=this._inCollections;for(t=0,w=x.length;t<w;t++)i=x[t],g(b,i._deferTo)}y=[];for(j in b){k=b[j];if(!b.hasOwnProperty(j))continue;l=h(a,function(a){return""+j+"."+a}),y.push(k._triggerChangesTo(l))}return y}},g(d.Properties,c)})).call(this)},a["./model"]=new function(){var b=this;((function(){var b,c,d,e,f=Object.prototype.hasOwnProperty,g=function(a,b){function d(){this.constructor=a}for(var c in b)f.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=a("./serenade").Serenade,c=a("./cache").Cache,b=a("./associations").Associations,e=a("./helpers").extend,d.Model=function(){function a(a,b){var d,e=this;b==null&&(b=!1);if(!b)if(a!=null?a.id:void 0){d=c.get(this.constructor,a.id);if(d)return d.set(a),d;c.set(this.constructor,a.id,this)}this.constructor.localStorage==="save"?this.bind("saved",function(){return c.store(e.constructor,e.get("id"),e)}):this.constructor.localStorage&&this.bind("change",function(){return c.store(e.constructor,e.get("id"),e)}),this.set(a)}return e(a.prototype,d.Properties),e(a.prototype,b),a.property=function(){var a;return(a=this.prototype).property.apply(a,arguments)},a.collection=function(){var a;return(a=this.prototype).collection.apply(a,arguments)},a.belongsTo=function(){var a;return(a=this.prototype).belongsTo.apply(a,arguments)},a.hasMany=function(){var a;return(a=this.prototype).hasMany.apply(a,arguments)},a.find=function(a){return c.get(this,a)||new this({id:a})},a.property("id",{serialize:!0}),a.extend=function(a,b){var c;return c=function(c){function d(){d.__super__.constructor.apply(this,arguments),b&&b.apply(this,arguments)}return g(d,c),d.modelName=a,d}(this)},a.prototype.save=function(){return this.trigger("saved")},a}()})).call(this)},a["./view"]=new function(){var b=this;((function(){var c,d,e,f,g;g=a("./parser").parser,c=a("./lexer").Lexer,d=a("./nodes").Nodes,e=a("./serenade").Serenade,g.lexer={lex:function(){var a,b;return b=this.tokens[this.pos++]||[""],a=b[0],this.yytext=b[1],this.yylineno=b[2],a},setInput:function(a){return this.tokens=a,this.pos=0},upcomingInput:function(){return""}},f=function(){function a(a){this.view=a}return a.prototype.parse=function(){return typeof this.view=="string"?g.parse((new c).tokenize(this.view)):this.view},a.prototype.render=function(a,b){var c;return a==null&&(a={}),b==null&&(b={}),c=d.compile(this.parse(),e.document,a,b),b.model=a,b.view=c.element},a}(),b.View=f})).call(this)},a["./serenade"].Serenade}();typeof define=="function"&&define.amd?define(function(){return b}):a.Serenade=b})(this)
8
+ (function(a){var b=function(){function a(b){return a[b]}return a["./events"]=new function(){var a=this;((function(){var b=Array.prototype.slice;a.Events={bind:function(a,b){var c,d,e,f,g;d=a.split(" "),c=this.hasOwnProperty("_callbacks")&&this._callbacks||(this._callbacks={});for(f=0,g=d.length;f<g;f++)e=d[f],c[e]||(c[e]=[]),c[e].push(b);return this},one:function(a,b){return this.bind(a,function(){return this.unbind(a,arguments.callee),b.apply(this,arguments)})},trigger:function(){var a,c,d,e,f,g,h;a=1<=arguments.length?b.call(arguments,0):[],d=a.shift(),typeof recordEvents!="undefined"&&recordEvents!==null&&(this._triggeredEvents||(this._triggeredEvents={}),this._triggeredEvents[d]=a),e=this.hasOwnProperty("_callbacks")&&((h=this._callbacks)!=null?h[d]:void 0);if(!e)return!1;for(f=0,g=e.length;f<g;f++)c=e[f],c.apply(this,a);return!0},unbind:function(a,b){var c,d,e,f,g;if(!a)return this._callbacks={},this;e=(g=this._callbacks)!=null?g[a]:void 0;if(!e)return this;if(!b)return delete this._callbacks[a],this;for(d=0,f=e.length;d<f;d++){c=e[d];if(c!==b)continue;e=e.slice(),e.splice(d,1),this._callbacks[a]=e;break}return this}}})).call(this)},a["./helpers"]=new function(){var a=this;((function(){var b;b={extend:function(a,b){var c,d,e;e=[];for(c in b)d=b[c],Object.prototype.hasOwnProperty.call(b,c)?e.push(a[c]=d):e.push(void 0);return e},get:function(a,b,c){return c==null&&(c=!0),c&&(a!=null?a.get:void 0)?a.get(b):c?a!=null?a[b]:void 0:b},format:function(a,c,d){return d==null&&(d=!0),d&&a.format?a.format(c):b.get(a,c,d)},forEach:function(a,b){var c,d,e,f;if(typeof a.forEach=="function")return a.forEach(b);f=[];for(d=0,e=a.length;d<e;d++)c=a[d],f.push(b(c));return f},map:function(a,b){var c,d,e,f;if(typeof a.map=="function")return a.map(b);f=[];for(d=0,e=a.length;d<e;d++)c=a[d],f.push(b(c));return f},isArray:function(a){return Object.prototype.toString.call(a)==="[object Array]"},pairToObject:function(a,b){var c;return c={},c[a]=b,c},serializeObject:function(a){return a&&typeof a.serialize=="function"?a.serialize():b.isArray(a)?b.map(a,function(a){return b.serializeObject(a)}):a},indexOf:function(a,b){var c,d,e;if(a.indexOf)return a.indexOf(b);for(c=0,e=a.length;c<e;c++){d=a[c];if(d===b)return c}return-1},deleteItem:function(a,c){return a.splice(b.indexOf(c),1)},getFunctionName:function(a){var b,c,d;return b=a.modelName,b||(b=a.name),b||(b=(c=a.toString().match(/\[object (.+?)\]/))!=null?c[1]:void 0),b||(b=(d=a.toString().match(/function (.+?)\(\)/))!=null?d[1]:void 0),b},preventDefault:function(a){return a.preventDefault?a.preventDefault():a.returnValue=!1}},b.extend(a,b)})).call(this)},a["./cache"]=new function(){var b=this;((function(){var c,d,e,f;f=a("./helpers"),e=f.serializeObject,d=f.getFunctionName,c={_storage:typeof window!="undefined"&&window!==null?window.localStorage:void 0,_identityMap:{},get:function(a,b){var c,e;c=d(a);if(c&&b)return((e=this._identityMap[c])!=null?e[b]:void 0)||this.retrieve(a,b)},set:function(a,b,c){var e,f;e=d(a);if(e&&b)return(f=this._identityMap)[e]||(f[e]={}),this._identityMap[e][b]=c},store:function(a,b,c){var f;f=d(a);if(f&&b&&typeof JSON!="undefined"&&JSON!==null)return this._storage.setItem(""+f+"_"+b,JSON.stringify(e(c)))},retrieve:function(a,b){var c,e;e=d(a);if(e&&b&&a.localStorage&&typeof JSON!="undefined"&&JSON!==null){c=this._storage.getItem(""+e+"_"+b);if(c)return new a(JSON.parse(c),!0)}}},b.Cache=c})).call(this)},a["./collection"]=new function(){var b=this;((function(){var c,d,e,f,g,h,i;c=a("./events").Events,i=a("./helpers"),e=i.extend,f=i.forEach,h=i.serializeObject,d=i.deleteItem,g=i.indexOf,b.Collection=function(){function a(a){var b=this;this.list=a,this.length=this.list.length,this.bind("change",function(){return b.length=b.list.length})}return e(a.prototype,c),a.prototype.get=function(a){return this.list[a]},a.prototype.set=function(a,b){return this._notIn(this.list[a]),this.list[a]=b,this._in(b),this.trigger("change:"+a,b),this.trigger("set",a,b),this.trigger("change",this.list)},a.prototype.push=function(a){return this.list.push(a),this._in(a),this.trigger("add",a),this.trigger("change",this.list)},a.prototype.update=function(a){var b,c,d,e,f,g;g=this.list;for(c=0,e=g.length;c<e;c++)b=g[c],this._notIn(b);this.list=a;for(d=0,f=a.length;d<f;d++)b=a[d],this._in(b);return this.trigger("update",a),this.trigger("change",this.list)},a.prototype.forEach=function(a){return f(this.list,a)},a.prototype.map=function(a){var b,c,d,e,f;e=this.list,f=[];for(c=0,d=e.length;c<d;c++)b=e[c],f.push(a(b));return f},a.prototype.indexOf=function(a){return g(this.list,a)},a.prototype.deleteAt=function(a){return this._notIn(this.list[a]),this.list.splice(a,1),this.trigger("delete",a),this.trigger("change",this.list)},a.prototype["delete"]=function(a){return this.deleteAt(this.indexOf(a))},a.prototype.serialize=function(){return h(this.list)},a.prototype.select=function(a){var b,c,d,e,f;e=this.list,f=[];for(c=0,d=e.length;c<d;c++)b=e[c],a(b)&&f.push(b);return f},a.prototype._in=function(a){var b;if(a!=null?a._triggerChangesTo:void 0)return a._inCollections||(a._inCollections=[]),(b=a._inCollections)!=null?b.push(this):void 0},a.prototype._notIn=function(a){if(a!=null?a._inCollections:void 0)return d(a._inCollections,this)},a}()})).call(this)},a["./association_collection"]=new function(){var b=this;((function(){var c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=a("./collection").Collection,c=function(a){function b(a,c){var d;this.ctor=a,this.list=c,b.__super__.constructor.call(this,function(){var a,b,e;e=[];for(a=0,b=c.length;a<b;a++)d=c[a],e.push(this._convert(d));return e}.call(this))}return f(b,a),b.prototype.set=function(a,c){return b.__super__.set.call(this,a,this._convert(c))},b.prototype.push=function(a){return b.__super__.push.call(this,this._convert(a))},b.prototype.update=function(a){var c;return b.__super__.update.call(this,function(){var b,d,e;e=[];for(b=0,d=a.length;b<d;b++)c=a[b],e.push(this._convert(c));return e}.call(this))},b.prototype._convert=function(a){return a.constructor===Object&&this.ctor?new(this.ctor())(a):a},b}(d),b.AssociationCollection=c})).call(this)},a["./associations"]=new function(){var b=this;((function(){var c,d,e,f,g,h,i;c=a("./association_collection").AssociationCollection,e=a("./collection").Collection,i=a("./helpers"),f=i.extend,h=i.map,g=i.get,d=function(){function a(){}return a.belongsTo=function(a,b){return b==null&&(b={}),f(b,{set:function(c){return c.constructor===Object&&b.as&&(c=new(b.as())(c)),this.attributes[a]=c}}),this.property(a,b),this.property(a+"Id",{get:function(){return g(this.get(a),"id")},set:function(c){return this.attributes[a]=b.as().find(c)},dependsOn:a,serialize:b.serializeId})},a.hasMany=function(a,b){return b==null&&(b={}),f(b,{get:function(){var d=this;return this.attributes[a]||(this.attributes[a]=new c(b.as,[]),this.attributes[a].bind("change",function(){return d._triggerChangesTo([a])})),this.attributes[a]},set:function(b){return this.get(a).update(b)}}),this.property(a,b),this.property(a+"Ids",{get:function(){return new e(this.get(a).map(function(a){return g(a,"id")}))},set:function(d){var e;return e=h(d,function(a){return b.as().find(a)}),this.attributes[a]=new c(b.as,e)},dependsOn:a,serialize:b.serializeIds})},a}(),b.Associations=d})).call(this)},a["./serenade"]=new function(){var b=this;((function(){var c,d,e;c=a("./cache").Cache,e=a("./helpers").extend,d={VERSION:"0.1.3",_views:{},_controllers:{},_formats:{},document:typeof window!="undefined"&&window!==null?window.document:void 0,view:function(b,c){var d;return d=a("./view").View,c?this._views[b]=new d(b,c):new d(void 0,b)},render:function(a,b,c){return this._views[a].render(b,c)},controller:function(a,b){return this._controllers[a]=b},controllerFor:function(a,b){if(this._controllers[a])return new this._controllers[a](b)},registerFormat:function(a,b){return this._formats[a]=b},clearIdentityMap:function(){return c._identityMap={}},clearLocalStorage:function(){return c._storage.clear()},clearCache:function(){return d.clearIdentityMap(),d.clearLocalStorage()},unregisterAll:function(){return d._views={},d._controllers={},d._formats={}},bindEvent:function(a,b,c){return typeof a.addEventListener=="function"?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)},useJQuery:function(){return this.bindEvent=function(a,b,c){return jQuery(a).bind(b,c)}},extend:e,Events:a("./events").Events,Collection:a("./collection").Collection,Helpers:{}},b.Serenade=d,b.compile=function(){var b,c,e;return b=a("jsdom").jsdom(null,null,{}),c=a("fs"),e=b.createWindow(),d.document=b,function(a){var e,f,g,h;return g=a.model,h=a.filename.split("/").reverse()[0].replace(/\.serenade$/,""),d.view(h,c.readFileSync(a.filename).toString()),e=d.render(h,g,{}),b.body.appendChild(e),f=b.body.innerHTML,a.doctype!==!1&&(f="<!DOCTYPE html>\n"+f),f}}})).call(this)},a["./lexer"]=new function(){var a=this;((function(){var b,c,d,e,f,g;b=/^[a-zA-Z][a-zA-Z0-9\-_]*/,c=/^[\[\]=\:\-!#\.@]/,f=/^"((?:\\.|[^"])*)"/,e=/^(?:\n[^\n\S]*)+/,g=/^[^\n\S]+/,d=function(){function a(){}return a.prototype.tokenize=function(a,b){var c,d;b==null&&(b={}),this.code=a.replace(/^\s*/,""),this.line=b.line||0,this.indent=0,this.indents=[],this.ends=[],this.tokens=[],c=0;while(this.chunk=this.code.slice(c))c+=this.identifierToken()||this.whitespaceToken()||this.lineToken()||this.stringToken()||this.literalToken();while(d=this.ends.pop())d==="OUTDENT"?this.token("OUTDENT"):this.error("missing "+d);return this.tokens},a.prototype.whitespaceToken=function(){var a;return(a=g.exec(this.chunk))?(this.token("WHITESPACE",a[0].length),a[0].length):0},a.prototype.token=function(a,b){return this.tokens.push([a,b,this.line])},a.prototype.identifierToken=function(){var a;return(a=b.exec(this.chunk))?(this.token("IDENTIFIER",a[0]),a[0].length):0},a.prototype.stringToken=function(){var a;return(a=f.exec(this.chunk))?(this.token("STRING_LITERAL",a[1]),a[0].length):0},a.prototype.lineToken=function(){var a,b,c,d,f;if(!(c=e.exec(this.chunk)))return 0;b=c[0],this.line+=this.count(b,"\n"),d=this.last(this.tokens,1),f=b.length-1-b.lastIndexOf("\n"),a=f-this.indent;if(f===this.indent)this.newlineToken();else if(f>this.indent)this.token("INDENT"),this.indents.push(a),this.ends.push("OUTDENT");else{while(a<0)this.last(this.ends)!=="OUTDENT"&&this.error("Should be an OUTDENT, yo"),this.ends.pop(),a+=this.indents.pop(),this.token("OUTDENT");this.token("TERMINATOR","\n")}return this.indent=f,b.length},a.prototype.literalToken=function(){var a;return(a=c.exec(this.chunk))?(this.token(a[0]),1):this.error("WUT??? is '"+this.chunk.charAt(0)+"'")},a.prototype.newlineToken=function(){if(this.tag()!=="TERMINATOR")return this.token("TERMINATOR","\n")},a.prototype.tag=function(a,b){var c;return(c=this.last(this.tokens,a))&&(b?c[0]=b:c[0])},a.prototype.value=function(a,b){var c;return(c=this.last(this.tokens,a))&&(b?c[1]=b:c[1])},a.prototype.error=function(a){throw SyntaxError(""+a+" on line "+(this.line+1))},a.prototype.count=function(a,b){var c,d;c=d=0;if(!b.length)return 1/0;while(d=1+a.indexOf(b,d))c++;return c},a.prototype.last=function(a,b){return a[a.length-(b||0)-1]},a}(),a.Lexer=d})).call(this)},a["./nodes"]=new function(){var b=this;((function(){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u=function(a,b){return function(){return a.apply(b,arguments)}};l=a("./serenade").Serenade,t=a("./helpers"),q=t.format,r=t.get,p=t.forEach,s=t.preventDefault,j=function(){function a(a,b,c,d){var e,f,g,h,i,j,l,m,n;this.ast=a,this.document=b,this.model=c,this.controller=d,this.element=this.document.createElement(this.ast.name),this.ast.id&&this.element.setAttribute("id",this.ast.id),((l=this.ast.classes)!=null?l.length:void 0)&&this.element.setAttribute("class",this.ast.classes.join(" ")),m=this.ast.properties;for(g=0,i=m.length;g<i;g++)f=m[g],k.property(f,this,this.document,this.model,this.controller);n=this.ast.children;for(h=0,j=n.length;h<j;h++)e=n[h],k.compile(e,this.document,this.model,this.controller).append(this.element)}return a.prototype.append=function(a){return a.appendChild(this.element)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.element,a.nextSibling)},a.prototype.remove=function(){return this.element.parentNode.removeChild(this.element)},a.prototype.lastElement=function(){return this.element},a}(),m=function(){function a(a,b,c,d,e){var f,g=this;this.ast=a,this.node=b,this.document=c,this.model=d,this.controller=e,this.element=this.node.element,this.update(),this.ast.bound&&typeof (f=this.model).bind=="function"&&f.bind("change:"+this.ast.value,function(a){return g.update()})}return a.prototype.update=function(){return this.element.style[this.ast.name]=this.get()},a.prototype.get=function(){return q(this.model,this.ast.value,this.ast.bound)},a}(),f=function(){function a(a,b,c,d,e){var f,g;this.ast=a,this.node=b,this.document=c,this.model=d,this.controller=e,this.element=this.node.element,g=this,f=function(a){return g.ast.preventDefault&&s(a),g.controller[g.ast.value](a)},l.bindEvent(this.element,this.ast.name,f)}return a}(),c=function(){function a(a,b,c,d,e){var f,g=this;this.ast=a,this.node=b,this.document=c,this.model=d,this.controller=e,this.element=this.node.element,this.update(),this.ast.bound&&typeof (f=this.model).bind=="function"&&f.bind("change:"+this.ast.value,function(a){return g.update()})}return a.prototype.update=function(){var a,b;return b=this.get(),this.ast.name==="value"?this.element.value=b||"":this.node.ast.name==="input"&&this.ast.name==="checked"?this.element.checked=!!b:this.ast.name==="class"?(a=this.node.ast.classes,b!==void 0&&(a=a.concat(b)),a.length?this.element.setAttribute(this.ast.name,a.join(" ")):this.element.removeAttribute(this.ast.name)):b===void 0?this.element.removeAttribute(this.ast.name):(b===0&&(b="0"),this.element.setAttribute(this.ast.name,b))},a.prototype.get=function(){return q(this.model,this.ast.value,this.ast.bound)},a}(),n=function(){function a(a,b,c,d){var e=this;this.ast=a,this.document=b,this.model=c,this.controller=d,this.textNode=b.createTextNode(this.get()),this.ast.bound&&typeof c.bind=="function"&&c.bind("change:"+this.ast.value,function(){return e.textNode.nodeValue=e.get()})}return a.prototype.append=function(a){return a.appendChild(this.textNode)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.textNode,a.nextSibling)},a.prototype.remove=function(){return this.textNode.parentNode.removeChild(this.textNode)},a.prototype.lastElement=function(){return this.textNode},a.prototype.get=function(){var a;return a=q(this.model,this.ast.value,this.ast.bound),a===0&&(a="0"),a||""},a}(),o=function(){function a(a,b,c,d){this.ast=a,this.document=b,this.model=c,this.parentController=d,this.controller=l.controllerFor(this.ast.arguments[0],this.model),this.controller&&(this.controller.parent=this.parentController),this.view=l.render(this.ast.arguments[0],this.model,this.controller||this.parentController,this.document)}return a.prototype.append=function(a){return a.appendChild(this.view)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.view,a.nextSibling)},a.prototype.remove=function(){return this.view.parentNode.removeChild(this.view)},a.prototype.lastElement=function(){return this.view},a}(),h=function(){function a(a,b,c,d){var e;this.ast=a,this.document=b,this.model=c,this.controller=d,this.build=u(this.build,this),this.anchor=b.createTextNode(""),typeof (e=this.model).bind=="function"&&e.bind("change:"+this.ast.arguments[0],this.build)}return a.prototype.build=function(){var a,b,c,d,e,f,g;if(r(this.model,this.ast.arguments[0])){this.nodes||(this.nodes=function(){var b,c,d,e;d=this.ast.children,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(k.compile(a,this.document,this.model,this.controller));return e}.call(this)),e=this.nodes,g=[];for(b=0,d=e.length;b<d;b++)c=e[b],g.push(c.insertAfter(((f=this.nodes[b-1])!=null?f.lastElement():void 0)||this.anchor));return g}return this.removeNodes()},a.prototype.append=function(a){return a.appendChild(this.anchor),this.build()},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.anchor,a.nextSibling),this.build()},a.prototype.remove=function(){return this.removeNodes(),this.anchor.parentNode.removeChild(this.anchor)},a.prototype.removeNodes=function(){var a,b,c,d;if(this.nodes){d=this.nodes;for(b=0,c=d.length;b<c;b++)a=d[b],a.remove()}return this.nodes=void 0},a.prototype.lastElement=function(){return this.nodes[this.nodes.length-1].lastElement()},a}(),i=function(){function a(a,b,c,d){var e;this.ast=a,this.document=b,this.model=c,this.controller=d,this.build=u(this.build,this),this.anchor=b.createTextNode(""),typeof (e=this.model).bind=="function"&&e.bind("change:"+this.ast.arguments[0],this.build)}return a.prototype.build=function(){var a,b,c,d,e,f,g,h;this.removeNodes(),d=r(this.model,this.ast.arguments[0]),this.nodes=function(){var b,c,e,f;e=this.ast.children,f=[];for(b=0,c=e.length;b<c;b++)a=e[b],f.push(k.compile(a,this.document,d,this.controller));return f}.call(this),f=this.nodes,h=[];for(b=0,e=f.length;b<e;b++)c=f[b],h.push(c.insertAfter(((g=this.nodes[b-1])!=null?g.lastElement():void 0)||this.anchor));return h},a.prototype.append=function(a){return a.appendChild(this.anchor),this.build()},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.anchor,a.nextSibling),this.build()},a.prototype.remove=function(){return this.removeNodes(),this.anchor.parentNode.removeChild(this.anchor)},a.prototype.removeNodes=function(){var a,b,c,d;if(this.nodes){d=this.nodes;for(b=0,c=d.length;b<c;b++)a=d[b],a.remove()}return this.nodes=void 0},a.prototype.lastElement=function(){return this.nodes[this.nodes.length-1].lastElement()},a}(),d=function(){function a(a,b,c,d){var e=this;this.ast=a,this.document=b,this.model=c,this.controller=d,this.anchor=b.createTextNode(""),this.collection=this.get(),this.collection.bind&&(this.collection.bind("update",function(){return e.rebuild()}),this.collection.bind("set",function(){return e.rebuild()}),this.collection.bind("add",function(a){return e.appendItem(a)}),this.collection.bind("delete",function(a){return e["delete"](a)}))}return a.prototype.rebuild=function(){var a,b,c,d;d=this.items;for(b=0,c=d.length;b<c;b++)a=d[b],a.remove();return this.build()},a.prototype.build=function(){var a=this;return this.items=[],p(this.collection,function(b){return a.appendItem(b)})},a.prototype.appendItem=function(a){var b;return b=new e(this.ast.children,this.document,a,this.controller),b.insertAfter(this.lastElement()),this.items.push(b)},a.prototype["delete"]=function(a){return this.items[a].remove(),this.items.splice(a,1)},a.prototype.lastItem=function(){return this.items[this.items.length-1]},a.prototype.lastElement=function(){var a;return a=this.lastItem(),a?a.lastElement():this.anchor},a.prototype.remove=function(){var a,b,c,d,e;this.anchor.parentNode.removeChild(this.anchor),d=this.items,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.remove());return e},a.prototype.append=function(a){return a.appendChild(this.anchor),this.build()},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.anchor,a.nextSibling),this.build()},a.prototype.get=function(){return r(this.model,this.ast.arguments[0])},a}(),g=function(){function a(a,b,c,d){this.ast=a,this.document=b,this.model=c,this.controller=d,this.render=u(this.render,this),this.helperFunction=l.Helpers[this.ast.command]||function(){throw SyntaxError("no helper "+this.ast.command+" defined")}.call(this),this.context={document:this.document,render:this.render,model:this.model,controller:this.controller},this.element=this.helperFunction.apply(this.context,this.ast.arguments)}return a.prototype.render=function(a,b,c){var d,e,f,g,h,i;b==null&&(b=this.model),c==null&&(c=this.controller),h=this.ast.children,i=[];for(f=0,g=h.length;f<g;f++)d=h[f],e=k.compile(d,this.document,b,c),i.push(e.append(a));return i},a.prototype.lastElement=function(){var a;return a=this.lastItem(),a?a.lastElement():this.anchor},a.prototype.remove=function(){var a,b,c,d,e;this.element.parentNode.removeChild(this.element),d=this.items,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.remove());return e},a.prototype.append=function(a){return a.appendChild(this.element)},a.prototype.insertAfter=function(a){return a.parentNode.insertBefore(this.element,a.nextSibling)},a}(),e=function(){function a(a,b,c,d){var e;this.children=a,this.document=b,this.model=c,this.controller=d,this.nodes=function(){var a,b,c,d;c=this.children,d=[];for(a=0,b=c.length;a<b;a++)e=c[a],d.push(k.compile(e,this.document,this.model,this.controller));return d}.call(this)}return a.prototype.insertAfter=function(a){var b,c,d,e,f,g;b=a,f=this.nodes,g=[];for(d=0,e=f.length;d<e;d++)c=f[d],c.insertAfter(b),g.push(b=c.lastElement());return g},a.prototype.lastElement=function(){return this.nodes[this.nodes.length-1].lastElement()},a.prototype.remove=function(){var a,b,c,d,e;d=this.nodes,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.remove());return e},a}(),k={compile:function(a,b,c,e){switch(a.type){case"element":return new j(a,b,c,e);case"text":return new n(a,b,c,e);case"instruction":switch(a.command){case"view":return new o(a,b,c,e);case"collection":return new d(a,b,c,e);case"if":return new h(a,b,c,e);case"in":return new i(a,b,c,e);default:return new g(a,b,c,e)}break;default:throw SyntaxError("unknown type '"+a.type+"'")}},property:function(a,b,d,e,g){switch(a.scope){case"attribute":return new c(a,b,d,e,g);case"style":return new m(a,b,d,e,g);case"event":return new f(a,b,d,e,g);default:throw SyntaxError(""+a.scope+" is not a valid scope")}}},b.Nodes=k})).call(this)},a["./parser"]=new function(){var b=this,c=function(){undefined;var a={trace:function(){},yy:{},symbols_:{error:2,Root:3,Element:4,TERMINATOR:5,ElementIdentifier:6,IDENTIFIER:7,"#":8,".":9,"[":10,"]":11,PropertyList:12,WHITESPACE:13,Text:14,INDENT:15,ChildList:16,OUTDENT:17,TextList:18,Bound:19,STRING_LITERAL:20,Child:21,Instruction:22,Property:23,"=":24,"!":25,":":26,"-":27,"@":28,$accept:0,$end:1},terminals_:{2:"error",5:"TERMINATOR",7:"IDENTIFIER",8:"#",9:".",10:"[",11:"]",13:"WHITESPACE",15:"INDENT",17:"OUTDENT",20:"STRING_LITERAL",24:"=",25:"!",26:":",27:"-",28:"@"},productions_:[0,[3,0],[3,1],[3,2],[6,1],[6,3],[6,2],[6,2],[6,3],[4,1],[4,3],[4,4],[4,3],[4,4],[18,1],[18,3],[14,1],[14,1],[16,1],[16,3],[21,1],[21,1],[21,1],[12,1],[12,3],[23,3],[23,3],[23,4],[23,4],[23,3],[23,3],[22,3],[22,3],[22,4],[19,2]],performAction:function(b,c,d,e,f,g,h){var i=g.length-1;switch(f){case 1:this.$=null;break;case 2:return this.$;case 3:return this.$;case 4:this.$={name:g[i],classes:[]};break;case 5:this.$={name:g[i-2],id:g[i],classes:[]};break;case 6:this.$={name:"div",id:g[i],classes:[]};break;case 7:this.$={name:"div",classes:[g[i]]};break;case 8:this.$=function(){return g[i-2].classes.push(g[i]),g[i-2]}();break;case 9:this.$={name:g[i].name,id:g[i].id,classes:g[i].classes,properties:[],children:[],type:"element"};break;case 10:this.$=g[i-2];break;case 11:this.$=function(){return g[i-3].properties=g[i-1],g[i-3]}();break;case 12:this.$=function(){return g[i-2].children=g[i-2].children.concat(g[i]),g[i-2]}();break;case 13:this.$=function(){return g[i-3].children=g[i-3].children.concat(g[i-1]),g[i-3]}();break;case 14:this.$=[g[i]];break;case 15:this.$=g[i-2].concat(g[i]);break;case 16:this.$={type:"text",value:g[i],bound:!0};break;case 17:this.$={type:"text",value:g[i],bound:!1};break;case 18:this.$=[].concat(g[i]);break;case 19:this.$=g[i-2].concat(g[i]);break;case 20:this.$=g[i];break;case 21:this.$=g[i];break;case 22:this.$=g[i];break;case 23:this.$=[g[i]];break;case 24:this.$=g[i-2].concat(g[i]);break;case 25:this.$={name:g[i-2],value:g[i],bound:!0,scope:"attribute"};break;case 26:this.$={name:g[i-2],value:g[i],bound:!0,scope:"attribute"};break;case 27:this.$={name:g[i-3],value:g[i-1],bound:!0,scope:"attribute",preventDefault:!0};break;case 28:this.$={name:g[i-3],value:g[i-1],bound:!0,scope:"attribute",preventDefault:!0};break;case 29:this.$={name:g[i-2],value:g[i],bound:!1,scope:"attribute"};break;case 30:this.$=function(){return g[i].scope=g[i-2],g[i]}();break;case 31:this.$={command:g[i],arguments:[],children:[],type:"instruction"};break;case 32:this.$=function(){return g[i-2].arguments.push(g[i].value),g[i-2]}();break;case 33:this.$=function(){return g[i-3].children=g[i-1],g[i-3]}();break;case 34:this.$=g[i]}},table:[{1:[2,1],3:1,4:2,6:3,7:[1,4],8:[1,5],9:[1,6]},{1:[3]},{1:[2,2],5:[1,7],10:[1,8],13:[1,9],15:[1,10]},{1:[2,9],5:[2,9],9:[1,11],10:[2,9],13:[2,9],15:[2,9],17:[2,9]},{1:[2,4],5:[2,4],8:[1,12],9:[2,4],10:[2,4],13:[2,4],15:[2,4],17:[2,4]},{7:[1,13]},{7:[1,14]},{1:[2,3]},{7:[1,18],11:[1,15],12:16,23:17},{14:19,19:20,20:[1,21],28:[1,22]},{4:25,6:3,7:[1,4],8:[1,5],9:[1,6],14:29,16:23,18:27,19:20,20:[1,21],21:24,22:26,27:[1,28],28:[1,22]},{7:[1,30]},{7:[1,31]},{1:[2,6],5:[2,6],9:[2,6],10:[2,6],13:[2,6],15:[2,6],17:[2,6]},{1:[2,7],5:[2,7],9:[2,7],10:[2,7],13:[2,7],15:[2,7],17:[2,7]},{1:[2,10],5:[2,10],10:[2,10],13:[2,10],15:[2,10],17:[2,10]},{11:[1,32],13:[1,33]},{11:[2,23],13:[2,23]},{24:[1,34],26:[1,35]},{1:[2,12],5:[2,12],10:[2,12],13:[2,12],15:[2,12],17:[2,12]},{1:[2,16],5:[2,16],10:[2,16],13:[2,16],15:[2,16],17:[2,16]},{1:[2,17],5:[2,17],10:[2,17],13:[2,17],15:[2,17],17:[2,17]},{7:[1,36]},{5:[1,38],17:[1,37]},{5:[2,18],17:[2,18]},{5:[2,20],10:[1,8],13:[1,9],15:[1,10],17:[2,20]},{5:[2,21],13:[1,39],15:[1,40],17:[2,21]},{5:[2,22],13:[1,41],17:[2,22]},{13:[1,42]},{5:[2,14],13:[2,14],17:[2,14]},{1:[2,8],5:[2,8],9:[2,8],10:[2,8],13:[2,8],15:[2,8],17:[2,8]},{1:[2,5],5:[2,5],9:[2,5],10:[2,5],13:[2,5],15:[2,5],17:[2,5]},{1:[2,11],5:[2,11],10:[2,11],13:[2,11],15:[2,11],17:[2,11]},{7:[1,18],23:43},{7:[1,44],19:45,20:[1,46],28:[1,22]},{7:[1,18],23:47},{1:[2,34],5:[2,34],10:[2,34],11:[2,34],13:[2,34],15:[2,34],17:[2,34],25:[2,34]},{1:[2,13],5:[2,13],10:[2,13],13:[2,13],15:[2,13],17:[2,13]},{4:25,6:3,7:[1,4],8:[1,5],9:[1,6],14:29,18:27,19:20,20:[1,21],21:48,22:26,27:[1,28],28:[1,22]},{14:49,19:20,20:[1,21],28:[1,22]},{4:25,6:3,7:[1,4],8:[1,5],9:[1,6],14:29,16:50,18:27,19:20,20:[1,21],21:24,22:26,27:[1,28],28:[1,22]},{14:51,19:20,20:[1,21],28:[1,22]},{7:[1,52]},{11:[2,24],13:[2,24]},{11:[2,25],13:[2,25],25:[1,53]},{11:[2,26],13:[2,26],25:[1,54]},{11:[2,29],13:[2,29]},{11:[2,30],13:[2,30]},{5:[2,19],17:[2,19]},{5:[2,32],13:[2,32],15:[2,32],17:[2,32]},{5:[1,38],17:[1,55]},{5:[2,15],13:[2,15],17:[2,15]},{5:[2,31],13:[2,31],15:[2,31],17:[2,31]},{11:[2,27],13:[2,27]},{11:[2,28],13:[2,28]},{5:[2,33],13:[2,33],15:[2,33],17:[2,33]}],defaultActions:{7:[2,3]},parseError:function(b,c){throw new Error(b)},parse:function(b){function o(a){d.length=d.length-2*a,e.length=e.length-a,f.length=f.length-a}function p(){var a;return a=c.lexer.lex()||1,typeof a!="number"&&(a=c.symbols_[a]||a),a}var c=this,d=[0],e=[null],f=[],g=this.table,h="",i=0,j=0,k=0,l=2,m=1;this.lexer.setInput(b),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,typeof this.lexer.yylloc=="undefined"&&(this.lexer.yylloc={});var n=this.lexer.yylloc;f.push(n),typeof this.yy.parseError=="function"&&(this.parseError=this.yy.parseError);var q,r,s,t,u,v,w={},x,y,z,A;for(;;){s=d[d.length-1],this.defaultActions[s]?t=this.defaultActions[s]:(q==null&&(q=p()),t=g[s]&&g[s][q]);if(typeof t=="undefined"||!t.length||!t[0]){if(!k){A=[];for(x in g[s])this.terminals_[x]&&x>2&&A.push("'"+this.terminals_[x]+"'");var B="";this.lexer.showPosition?B="Parse error on line "+(i+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+A.join(", ")+", got '"+this.terminals_[q]+"'":B="Parse error on line "+(i+1)+": Unexpected "+(q==1?"end of input":"'"+(this.terminals_[q]||q)+"'"),this.parseError(B,{text:this.lexer.match,token:this.terminals_[q]||q,line:this.lexer.yylineno,loc:n,expected:A})}if(k==3){if(q==m)throw new Error(B||"Parsing halted.");j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,q=p()}for(;;){if(l.toString()in g[s])break;if(s==0)throw new Error(B||"Parsing halted.");o(1),s=d[d.length-1]}r=q,q=l,s=d[d.length-1],t=g[s]&&g[s][l],k=3}if(t[0]instanceof Array&&t.length>1)throw new Error("Parse Error: multiple actions possible at state: "+s+", token: "+q);switch(t[0]){case 1:d.push(q),e.push(this.lexer.yytext),f.push(this.lexer.yylloc),d.push(t[1]),q=null,r?(q=r,r=null):(j=this.lexer.yyleng,h=this.lexer.yytext,i=this.lexer.yylineno,n=this.lexer.yylloc,k>0&&k--);break;case 2:y=this.productions_[t[1]][1],w.$=e[e.length-y],w._$={first_line:f[f.length-(y||1)].first_line,last_line:f[f.length-1].last_line,first_column:f[f.length-(y||1)].first_column,last_column:f[f.length-1].last_column},v=this.performAction.call(w,h,j,i,this.yy,t[1],e,f);if(typeof v!="undefined")return v;y&&(d=d.slice(0,-1*y*2),e=e.slice(0,-1*y),f=f.slice(0,-1*y)),d.push(this.productions_[t[1]][0]),e.push(w.$),f.push(w._$),z=g[d[d.length-2]][d[d.length-1]],d.push(z);break;case 3:return!0}}return!0}};return a}();typeof a!="undefined"&&typeof b!="undefined"&&(b.parser=c,b.parse=function(){return c.parse.apply(c,arguments)},b.main=function(d){if(!d[1])throw new Error("Usage: "+d[0]+" FILE");if(typeof process!="undefined")var e=a("fs").readFileSync(a("path").join(process.cwd(),d[1]),"utf8");else var f=a("file").path(a("file").cwd()),e=f.join(d[1]).read({charset:"utf-8"});return b.parser.parse(e)},typeof module!="undefined"&&a.main===module&&b.main(typeof process!="undefined"?process.argv.slice(1):a("system").args))},a["./properties"]=new function(){var b=this;((function(){var b,c,d,e,f,g,h,i,j,k,l,m=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};d=a("./serenade").Serenade,b=a("./collection").Collection,c=a("./events").Events,l=a("./helpers"),i=l.pairToObject,k=l.serializeObject,g=l.extend,h=l.map,j="_prop_",f=/^_prop_/,e=Object.defineProperties,d.Properties={property:function(a,b){b==null&&(b={}),this[j+a]=b,this[j+a].name=a,e&&Object.defineProperty(this,a,{get:function(){return d.Properties.get.call(this,a)},set:function(b){return d.Properties.set.call(this,a,b)}});if(typeof b.serialize=="string")return this.property(b.serialize,{get:function(){return this.get(a)},set:function(b){return this.set(a,b)}})},collection:function(a,c){return this.property(a,{get:function(){var c=this;return this.attributes[a]||(this.attributes[a]=new b([]),this.attributes[a].bind("change",function(){return c._triggerChangesTo([a])}),this.attributes[a]._deferTo=i(a,this)),this.attributes[a]},set:function(b){return this.get(a).update(b)}})},set:function(a,b){var c,d,e;typeof a=="string"&&(a=i(a,b)),d=[];for(c in a)b=a[c],this._undefer(c),d.push(c),this.attributes||(this.attributes={}),((e=this[j+c])!=null?e.set:void 0)?this[j+c].set.call(this,b):this.attributes[c]=b,this._defer(c);return this._triggerChangesTo(d)},get:function(a){var b;return this.attributes||(this.attributes={}),((b=this[j+a])!=null?b.get:void 0)?this[j+a].get.call(this):this.attributes[a]},format:function(a){var b,c;return b=(c=this[j+a])!=null?c.format:void 0,typeof b=="string"?d._formats[b].call(this,this.get(a)):typeof b=="function"?b.call(this,this.get(a)):this.get(a)},serialize:function(){var a,b,c,d,e,g;d={};for(b in this)c=this[b],b.match(f)&&(typeof c.serialize=="string"?d[c.serialize]=k(this.get(c.name)):typeof c.serialize=="function"?(g=c.serialize.call(this),a=g[0],e=g[1],d[a]=k(e)):c.serialize&&(d[c.name]=k(this.get(c.name))));return d},_defer:function(a){var b,c;b=this.get(a);if(b!=null?b._triggerChangesTo:void 0)return b._deferTo||(b._deferTo={}),(c=b._deferTo)!=null?c[a]=this:void 0},_undefer:function(a){var b;b=this.get(a);if(b!=null?b._deferTo:void 0)return delete b._deferTo[a]},_triggerChangesTo:function(a){var b,c,d,i,j,k,l,n,o,p,q,r,s,t,u,v,w,x,y,z=this;o=function(a){return[].concat(a)},d=function(b){var c,e,g,h;h=[];for(c in z)e=z[c],c.match(f)&&e.dependsOn&&(m.call(o(e.dependsOn),b)>=0&&(g=e.name,m.call(a,g)<0)?(a.push(e.name),h.push(d(e.name))):h.push(void 0));return h};for(r=0,u=a.length;r<u;r++)p=a[r],d(p);c={};for(s=0,v=a.length;s<v;s++)n=a[s],q=this.get(n),this.trigger("change:"+n,q),c[n]=q,e||(this[n]=this.get(n));this.trigger("change",c),b=this._deferTo||[];if(this._inCollections){x=this._inCollections;for(t=0,w=x.length;t<w;t++)i=x[t],g(b,i._deferTo)}y=[];for(j in b){k=b[j];if(!b.hasOwnProperty(j))continue;l=h(a,function(a){return""+j+"."+a}),y.push(k._triggerChangesTo(l))}return y}},g(d.Properties,c)})).call(this)},a["./model"]=new function(){var b=this;((function(){var b,c,d,e,f=Object.prototype.hasOwnProperty,g=function(a,b){function d(){this.constructor=a}for(var c in b)f.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=a("./serenade").Serenade,c=a("./cache").Cache,b=a("./associations").Associations,e=a("./helpers").extend,d.Model=function(){function a(a,b){var d,e=this;b==null&&(b=!1);if(!b)if(a!=null?a.id:void 0){d=c.get(this.constructor,a.id);if(d)return d.set(a),this.set(a),d;c.set(this.constructor,a.id,this)}this.constructor.localStorage==="save"?this.bind("saved",function(){return c.store(e.constructor,e.get("id"),e)}):this.constructor.localStorage&&this.bind("change",function(){return c.store(e.constructor,e.get("id"),e)}),this.set(a)}return e(a.prototype,d.Properties),e(a.prototype,b),a.property=function(){var a;return(a=this.prototype).property.apply(a,arguments)},a.collection=function(){var a;return(a=this.prototype).collection.apply(a,arguments)},a.belongsTo=function(){var a;return(a=this.prototype).belongsTo.apply(a,arguments)},a.hasMany=function(){var a;return(a=this.prototype).hasMany.apply(a,arguments)},a.find=function(a){return c.get(this,a)||new this({id:a})},a.property("id",{serialize:!0}),a.extend=function(a,b){var c;return c=function(c){function d(){d.__super__.constructor.apply(this,arguments),b&&b.apply(this,arguments)}return g(d,c),d.modelName=a,d}(this)},a.prototype.save=function(){return this.trigger("saved")},a}()})).call(this)},a["./view"]=new function(){var b=this;((function(){var c,d,e,f,g;g=a("./parser").parser,c=a("./lexer").Lexer,d=a("./nodes").Nodes,e=a("./serenade").Serenade,g.lexer={lex:function(){var a,b;return b=this.tokens[this.pos++]||[""],a=b[0],this.yytext=b[1],this.yylineno=b[2],a},setInput:function(a){return this.tokens=a,this.pos=0},upcomingInput:function(){return""}},f=function(){function a(a,b){this.name=a,this.view=b}return a.prototype.parse=function(){return typeof this.view=="string"?g.parse((new c).tokenize(this.view)):this.view},a.prototype.render=function(a,b){var c;return this.name&&(b||(b=e.controllerFor(this.name,a))),b||(b={}),c=d.compile(this.parse(),e.document,a,b),b.model||(b.model=a),b.view||(b.view=c.element),c.element},a}(),b.View=f})).call(this)},a["./serenade"].Serenade}();typeof define=="function"&&define.amd?define(function(){return b}):a.Serenade=b})(this)
@@ -1,3 +1,3 @@
1
1
  module SerenadeRails
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serenade_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &2166682420 !ruby/object:Gem::Requirement
16
+ requirement: &2157448140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2166682420
24
+ version_requirements: *2157448140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: execjs
27
- requirement: &2166681920 !ruby/object:Gem::Requirement
27
+ requirement: &2157447420 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.3.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2166681920
35
+ version_requirements: *2157447420
36
36
  description: Use Serenade.js within the Rails asset pipeline
37
37
  email:
38
38
  - jonas.nicklas@gmail.com