mozart-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ /*! Mozart v0.1.8 */
2
+ (function(){var t=function(e,n){var i=t.resolve(e,n||"/"),r=t.modules[i];if(!r)throw Error("Failed to resolve module "+e+", tried "+i);var o=t.cache[i],s=o?o.exports:r();return s};t.paths=[],t.modules={},t.cache={},t.extensions=[".js",".coffee",".json"],t._core={assert:!0,events:!0,fs:!0,path:!0,vm:!0},t.resolve=function(){return function(e,n){function i(e){if(e=a.normalize(e),t.modules[e])return e;for(var n=0;t.extensions.length>n;n++){var i=t.extensions[n];if(t.modules[e+i])return e+i}}function r(e){e=e.replace(/\/+$/,"");var n=a.normalize(e+"/package.json");if(t.modules[n]){var r=t.modules[n](),o=r.browserify;if("object"==typeof o&&o.main){var s=i(a.resolve(e,o.main));if(s)return s}else if("string"==typeof o){var s=i(a.resolve(e,o));if(s)return s}else if(r.main){var s=i(a.resolve(e,r.main));if(s)return s}}return i(e+"/index")}function o(t,e){for(var n=s(e),o=0;n.length>o;o++){var a=n[o],l=i(a+"/"+t);if(l)return l;var h=r(a+"/"+t);if(h)return h}var l=i(t);return l?l:void 0}function s(t){var e;e="/"===t?[""]:a.normalize(t).split("/");for(var n=[],i=e.length-1;i>=0;i--)if("node_modules"!==e[i]){var r=e.slice(0,i+1).join("/")+"/node_modules";n.push(r)}return n}if(n||(n="/"),t._core[e])return e;var a=t.modules.path();n=a.resolve("/",n);var l=n||"/";if(e.match(/^(?:\.\.?\/|\/)/)){var h=i(a.resolve(l,e))||r(a.resolve(l,e));if(h)return h}var u=o(e,l);if(u)return u;throw Error("Cannot find module '"+e+"'")}}(),t.alias=function(e,n){var i=t.modules.path(),r=null;try{r=t.resolve(e+"/package.json","/")}catch(o){r=t.resolve(e,"/")}for(var s=i.dirname(r),a=(Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e})(t.modules),l=0;a.length>l;l++){var h=a[l];if(h.slice(0,s.length+1)===s+"/"){var u=h.slice(s.length);t.modules[n+u]=t.modules[s+u]}else h===s&&(t.modules[n]=t.modules[s])}},function(){var e={},n="undefined"!=typeof window?window:{},i=!1;t.define=function(r,o){!i&&t.modules.__browserify_process&&(e=t.modules.__browserify_process(),i=!0);var s=t._core[r]?"":t.modules.path().dirname(r),a=function(e){var n=t(e,s),i=t.cache[t.resolve(e,s)];return i&&null===i.parent&&(i.parent=l),n};a.resolve=function(e){return t.resolve(e,s)},a.modules=t.modules,a.define=t.define,a.cache=t.cache;var l={id:r,filename:r,exports:{},loaded:!1,parent:null};t.modules[r]=function(){return t.cache[r]=l,o.call(l.exports,a,l,l.exports,s,r,e,n),l.loaded=!0,l.exports}}}(),t.define("path",function(t,e,n,i,r,o){function s(t,e){for(var n=[],i=0;t.length>i;i++)e(t[i],i,t)&&n.push(t[i]);return n}function a(t,e){for(var n=0,i=t.length;i>=0;i--){var r=t[i];"."==r?t.splice(i,1):".."===r?(t.splice(i,1),n++):n&&(t.splice(i,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var l=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){for(var t="",e=!1,n=arguments.length;n>=-1&&!e;n--){var i=n>=0?arguments[n]:o.cwd();"string"==typeof i&&i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=a(s(t.split("/"),function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."},n.normalize=function(t){var e="/"===t.charAt(0),n="/"===t.slice(-1);return t=a(s(t.split("/"),function(t){return!!t}),!e).join("/"),t||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t},n.join=function(){var t=Array.prototype.slice.call(arguments,0);return n.normalize(s(t,function(t){return t&&"string"==typeof t}).join("/"))},n.dirname=function(t){var e=l.exec(t)[1]||"",n=!1;return e?1===e.length||n&&3>=e.length&&":"===e.charAt(1)?e:e.substring(0,e.length-1):"."},n.basename=function(t,e){var n=l.exec(t)[2]||"";return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},n.extname=function(t){return l.exec(t)[3]||""}}),t.define("__browserify_process",function(t,e,n,i,r,o){var o=e.exports={};o.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){if(t.source===window&&"browserify-tick"===t.data&&(t.stopPropagation(),n.length>0)){var e=n.shift();e()}},!0),function(t){n.push(t),window.postMessage("browserify-tick","*")}}return function(t){setTimeout(t,0)}}(),o.title="browser",o.browser=!0,o.env={},o.argv=[],o.binding=function(e){if("evals"===e)return t("vm");throw Error("No such module. (Possibly not yet loaded)")},function(){var e,n="/";o.cwd=function(){return n},o.chdir=function(i){e||(e=t("path")),n=e.resolve(i,n)}}()}),t.define("/collection.coffee",function(t,e,n){(function(){var e,i,r,o,s=function(t,e){return function(){return t.apply(e,arguments)}},a={}.hasOwnProperty,l=function(t,e){function n(){this.constructor=t}for(var i in e)a.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};o=t("./view").View,r=t("./util"),n.Collection=i=function(t){function e(){return this.draw=s(this.draw,this),this.createView=s(this.createView,this),this.refresh=s(this.refresh,this),this.afterRender=s(this.afterRender,this),this.release=s(this.release,this),this.init=s(this.init,this),e.__super__.constructor.apply(this,arguments)}return l(e,t),e.prototype.tag="ul",e.prototype.skipTemplate=!0,e.prototype.init=function(){var t,n;return e.__super__.init.apply(this,arguments),r.log("collection","init"),this.itemViews={},this.localMozartModel=r._getPath("Mozart.Model"),this.localMozartInstanceCollection=r._getPath("Mozart.InstanceCollection"),null!=this.filterAttribute&&(this.bind("change:filterAttribute",this.draw),this.bind("change:filterText",this.draw)),null!=this.sortAttribute&&(this.bind("change:sortAttribute",this.draw),this.bind("change:sortDescending",this.draw)),null==this.pageSize&&this.set("pageSize",1e4),null==this.pageCurrent&&this.set("pageCurrent",0),this.bind("change:pageSize",this.draw),this.bind("change:pageCurrent",this.draw),null==(n=this.method)&&(this.method="all"),this.bind("change:collection",this.afterRender),this.bind("change:method",this.afterRender),"function"==typeof(t=this.collection).bind?t.bind("change",this.afterRender):void 0},e.prototype.release=function(){var t;return"function"==typeof(t=this.collection).unbind&&t.unbind("change",this.afterRender),e.__super__.release.apply(this,arguments)},e.prototype.afterRender=function(){return this.refresh(),this.draw()},e.prototype.refresh=function(){var t,e,n,i,o,s,a,l,h,u,c,d,p,f,g,y;if(r.log("collection","refresh"),this.dataSet={},null!=this.collection)if(r.isObject(this.collection)){if(r.isFunction(this.collection[this.method+"AsMap"]))this.dataSet=this.collection[this.method+"AsMap"]();else if(r.isFunction(this.collection[this.method]))for(c=this.collecton[this.method](),o=0,l=c.length;l>o;o++)e=c[o],this.dataSet[e.id]=e}else if(r.isFunction(this.collection))for(d=this.collection(),s=0,h=d.length;h>s;s++)e=d[s],this.dataSet[e.id]=e;else if(r.isArray(this.collection))for(p=this.collection,a=0,u=p.length;u>a;a++)e=p[a],this.dataSet[e.id]=e;else console.error("Collection: "+typeof this.collection+" can't be iterated");n=[],f=this.itemViews;for(t in f)i=f[t],null==this.dataSet[t]&&n.push(t);for(y=[];n.length>0;)t=n.pop(),r.log("collection","destroyView",t,this.itemViews[t]),this.removeView(this.itemViews[t]),null!=(g=this.itemViews[t].element)&&g.remove(),this.layout.queueReleaseView(this.itemViews[t]),y.push(delete this.itemViews[t]);return y},e.prototype.createView=function(t){var e,n;return r.log("collection","createView",t,"layout",this.layout.rootElement),e={content:t,parent:this},this.viewClass===o&&(e.tag="li"),null!=this.viewClassTemplateName&&(e.templateName=this.viewClassTemplateName),null!=this.viewClassTemplateFunction&&(e.templateFunction=this.viewClassTemplateFunction),null!=this.collectionTag&&(e.tag=this.collectionTag),null!=this.collectionClassNames&&(e.classNames=this.collectionClassNames),null!=this.tooltips&&(e.tooltips=this.tooltips),n=this.layout.createView(this.viewClass,e),this.element.append(n.createElement()),this.itemViews[t.id]=n,this.addView(n),this.layout.queueRenderView(n)},e.prototype.draw=function(){var t,e,n,i,o,s,a,l,h,u,c,d,p,f,g,y,m,v,w,b,C,M;v=this.itemViews;for(o in v)u=v[o],null!=(w=u.element)&&w.detach();if(this.displayOrder=_(this.dataSet).values(),this.hidden={},null!=this.sortAttribute&&r.sortBy(this.displayOrder,this.sortAttribute),this.sortDescending&&this.displayOrder.reverse(),null!=this.filterText&&null!=this.filterAttribute&&this.filterText.length>0)for(a=(""+this.filterText).toLowerCase(),b=this.displayOrder,d=0,g=b.length;g>d;d++)for(s=b[d],i=!0,C=this.filterAttribute.split(","),p=0,y=C.length;y>p;p++)n=C[p],c=r.getPath(s,n),null!=c&&(i=i&&-1===(""+c).toLowerCase().indexOf(a)),i&&(this.hidden[s.id]=1);for(l=this.pageCurrent*this.pageSize,t=0,h=0,e=0,M=this.displayOrder,f=0,m=M.length;m>f;f++)s=M[f],null==this.hidden[s.id]&&(l>t||e>=this.pageSize||(null==this.itemViews[s.id]&&this.createView(s),this.element.append(this.itemViews[s.id].element),e++),h++),t++;return this.set("pageTotal",Math.ceil(h/this.pageSize)),this.pageCurrent>this.pageTotal?this.set("pageCurrent",this.pageTotal-1):void 0},e}(o),n.BoundView=e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return l(e,t),e.prototype.init=function(){return e.__super__.init.apply(this,arguments),this.content.bind("change",this.redraw)},e.prototype.release=function(){return this.content.unbind("change",this.redraw),e.__super__.release.apply(this,arguments)},e}(o)}).call(this)}),t.define("/view.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};e=t("./object").MztObject,i=t("./util"),n.View=r=function(t){function e(){return this.copyHtmlAttrsToElement=o(this.copyHtmlAttrsToElement,this),this.getHtmlAttrsMap=o(this.getHtmlAttrsMap,this),this.createElement=o(this.createElement,this),this.release=o(this.release,this),this.hasAncestor=o(this.hasAncestor,this),this.removeView=o(this.removeView,this),this.namedChildViewExists=o(this.namedChildViewExists,this),this.childView=o(this.childView,this),this.addView=o(this.addView,this),this.redraw=o(this.redraw,this),this.postRender=o(this.postRender,this),this.replaceElement=o(this.replaceElement,this),this.findElementInPreparedContent=o(this.findElementInPreparedContent,this),this.reassignElements=o(this.reassignElements,this),this.prepareElement=o(this.prepareElement,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.tag="div",e.prototype.disableHtmlAttributes=!1,e.prototype.idPrefix="view",e.prototype.init=function(){var t,e,n;return null==(t=this.id)&&(this.id=""+this.idPrefix+"-"+this._mozartId),this.childViews={},null==(e=this.context)&&(this.context={}),this.namedChildViews={},this.valid=!0,this.domBindings={},null==(n=this.display)&&(this.display=!0),null!=this.parent&&this.parent.addView(this),null==this.templateFunction&&null==this.skipTemplate&&(null==this.templateName&&i.error("View: View has no templateName or templateFunction","view",this),this.templateFunction=HandlebarsTemplates[this.templateName]),i.log("views","view "+this.id+" init"),this.bind("change:display",this.redraw)},e.prototype.prepareElement=function(){return this.released?void 0:(this.newElement=this.createElement(),!this.skipTemplate&&this.display?this.newElement.innerHTML=this.templateFunction(this,{data:this}):void 0)},e.prototype.reassignElements=function(){var t,e,n;n=this.childViews;for(t in n)e=n[t],e.reassignElements();return null!=this.parent?this.el=this.parent.findElementInPreparedContent(this.id):void 0},e.prototype.findElementInPreparedContent=function(t){var e;return this.newElement?e=this._find(this.newElement,t):null},e.prototype._find=function(t,e){var n,i,r,o,s;if(t.id===e)return t;for(s=t.children,r=0,o=s.length;o>r;r++)if(n=s[r],i=this._find(n,e),null!=i)return i;return null},e.prototype.replaceElement=function(){var t,e,n;if(!this.released&&this.el){n=this.childViews;for(t in n)e=n[t],e.replaceElement();return this.el!==this.newElement&&(this.oldEl=this.el,this.el.parentNode.replaceChild(this.newElement,this.el),null!=this.layout&&this.el===this.layout.rootEl&&(this.layout.rootEl=this.newElement),this.el=this.newElement,delete this.oldEl),this.element=$(this.el)}},e.prototype.beforeRender=function(){},e.prototype.afterRender=function(){},e.prototype.postRender=function(){return this.released?void 0:(this.createDomBinds(),this.afterRender())},e.prototype.redraw=function(){return this.released?void 0:this.layout.queueRenderView(this)},e.prototype.addView=function(t){return this.childViews[t.id]=t,null!=t.name?this.namedChildViews[t.name]=t:void 0},e.prototype.childView=function(t){return this.namedChildViews[t]},e.prototype.namedChildViewExists=function(t){return null!=this.namedChildViews[t]},e.prototype.releaseChildren=function(){var t,e,n;n=this.childViews;for(t in n)e=n[t],this.layout.queueReleaseView(e);return this.childViews={},this.namedChildViews={}},e.prototype.removeView=function(t){return null!=this.childViews?delete this.childViews[t.id]:void 0},e.prototype.hasAncestor=function(t){var e;for(e=this.parent;null!=e;){if(e.id===t.id)return!0;e=e.parent}return!1},e.prototype.release=function(){return this.released?void 0:(i.log("views",this.layout,"releasing view "+this.id),this.removeDomBinds(),this.unbind(),null!=this.parent&&this.parent.removeView(this),this.releaseChildren(),null!=this.element&&this.element.remove(),this.layout.releaseView(this),e.__super__.release.apply(this,arguments))},e.prototype.createElement=function(){var t,e,n,i;if(this.display===!1)return t=document.createElement("script"),t.setAttribute("id",this.id),t;if(t=document.createElement(this.tag),t.setAttribute("id",this.id),t.setAttribute("view",""),!this.disableHtmlAttributes){i=this.getHtmlAttrsMap();for(e in i)n=i[e],t.setAttribute(e,n)}return t},e.prototype.getHtmlAttrsMap=function(){var t,e,n;e={};for(t in this)n=this[t],"string"==typeof this[t]&&i.stringEndsWith(t,"Html")&&(e[i.sliceStringBefore(t,"Html")]=n);return e},e.prototype.copyHtmlAttrsToElement=function(t){return t.attr(this.getHtmlAttrsMap()),t},e.prototype.registerDomBind=function(t,e){var n,r,o,s;return s=i.parsePath(e),o=s[0],n=s[1],r=null!=o?i.getPath(this,o):this,null==r&&i.error("View.registerDomBind (bind helper) - cannot find object "+o),this.domBindings[t]={view:this,target:r,attribute:n,element:null}},e.prototype.createDomBinds=function(){var t,e,n,r;n=this.domBindings,r=[];for(t in n)e=n[t],e.element=$("#"+t),null==e.element&&i.error("View.createDomBinds - cannot find element "+t),e.target.bind("change:"+e.attribute,this.onDomBindChange,e),r.push(e.element.text(e.target[e.attribute]));return r},e.prototype.onDomBindChange=function(t,e){return e.element.text(e.target[e.attribute])},e.prototype.removeDomBinds=function(){var t,e,n;n=this.domBindings;for(t in n)e=n[t],true===e.element&&e.target.unbind("change:"+e.attribute,this.onDomBindChange);return this.domBindings={}},e}(e)}).call(this)}),t.define("/object.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},a=[].slice,l={}.hasOwnProperty;r=t("./util"),e=t("./events").Events,n.MztObject=i=function(){function t(){this._createBinding=o(this._createBinding,this),this._mozartId=r.getId()}var n;return n=["extended","included"],t.NOTIFY=2,t.OBSERVE=1,t.SYNC=0,t.include=function(t){var e,i,r;for(e in t)i=t[e],0>s.call(n,e)&&(this[e]=i);return null!=(r=t.extended)&&r.apply(this),this},t.extend=function(t){var e,i,r;for(e in t)i=t[e],0>s.call(n,e)&&(this.prototype[e]=i);return null!=(r=t.included)&&r.apply(this),this},t.create=function(t){var e,n,i;e=new this;for(n in t)i=t[n],e[n]=i;return e._bindings={},e._bindings.notify={},e._bindings.observe={},e._bindings.stored={},e._createDeclaredBinds(),e._createLookups(),"function"==typeof e.init&&e.init(),e},t.prototype.toString=function(){return"obj-"+this._mozartId},t.prototype.get=function(t){return r.isFunction(this[t])?this[t].call(this):this[t]},t.prototype.set=function(t,e){var n,i,r,o,s,a,l;if(o=this[t],o!==e){if(o instanceof Mozart.MztObject&&(this._bindings.stored[t]={notify:o._stripNotifyBindings(!0),observe:o._stripObserveBindings(!0)},this._bindings.stored[t].notify==={}&&this._bindings.stored[t].observe==={}&&delete this._bindings.stored[t]),null!=this._bindings.stored[t]&&null!=this._bindings.stored[t].notify&&null===e){l=this._bindings.stored[t].notify;for(r in l)for(i=l[r],s=0,a=i.length;a>s;s++)n=i[s],n.target.set(n.attr,null)}return e instanceof Mozart.MztObject&&null!=this._bindings.stored[t]&&(this._bindings.stored[t].notify!=={}&&e._addNotifyBindings(this._bindings.stored[t].notify),this._bindings.stored[t].observe!=={}&&e._addObserveBindings(this._bindings.stored[t].observe),delete this._bindings.stored[t]),this[t]=e,this._doNotifyBinding(t),this.trigger("change"),this.trigger("change:"+t)}},t.prototype.bind=function(){var t;return t=arguments.length>=1?a.call(arguments,0):[],e.bind.apply(e,[this._mozartId].concat(a.call(t))),this},t.prototype.one=function(){var t;return t=arguments.length>=1?a.call(arguments,0):[],e.one.apply(e,[this._mozartId].concat(a.call(t))),this},t.prototype.trigger=function(){var t;return t=arguments.length>=1?a.call(arguments,0):[],e.trigger.apply(e,[this._mozartId].concat(a.call(t))),this},t.prototype.unbind=function(){var t;return t=arguments.length>=1?a.call(arguments,0):[],e.unbind.apply(e,[this._mozartId].concat(a.call(t))),this},t.prototype.release=function(){var t,e;if(!this.released){this._removeAllBindings(),this.unbind();for(t in this)l.call(this,t)&&(e=this[t],this[t]=void 0,delete this[t]);return this.released=!0}},t.prototype._stripNotifyBindings=function(e){var n,i,r,o,s,a,l;null==e&&(e=!1),i={},l=this._bindings.notify;for(o in l)for(r=l[o],i[o]=[],s=0,a=r.length;a>s;s++)n=r[s],(!e||n.transferable)&&(i[o].push(n),this._removeBinding(o,n.target,n.attr,t.NOTIFY));return i},t.prototype._addNotifyBindings=function(e){var n,i,r,o;o=[];for(r in e)i=e[r],o.push(function(){var e,o,s;for(s=[],e=0,o=i.length;o>e;e++)n=i[e],s.push(this._createBinding(r,n.target,n.attr,t.NOTIFY,n.transferable));return s}.call(this));return o},t.prototype._stripObserveBindings=function(e){var n,i,r,o,s,a,l;null==e&&(e=!1),i={},l=this._bindings.observe;for(o in l)for(r=l[o],i[o]=[],s=0,a=r.length;a>s;s++)n=r[s],(!e||n.transferable)&&(i[o].push(n),this._removeBinding(o,n.target,n.attr,t.OBSERVE,n.transferable));return i},t.prototype._addObserveBindings=function(e){var n,i,r,o;o=[];for(r in e)i=e[r],o.push(function(){var e,o,s;for(s=[],e=0,o=i.length;o>e;e++)n=i[e],s.push(this._createBinding(r,n.target,n.attr,t.OBSERVE,n.transferable));return s}.call(this));return o},t.prototype._createDeclaredBinds=function(){var e,n,i,o,s,a,l,h;h=[];for(n in this)a=this[n],!r.isFunction(this[n])&&r.stringEndsWith(n,"Binding")&&(n=r.sliceStringBefore(n,"Binding"),s=t.SYNC,r.stringEndsWith(n,"Observe")?(n=r.sliceStringBefore(n,"Observe"),s=t.OBSERVE):r.stringEndsWith(n,"Notify")&&(n=r.sliceStringBefore(n,"Notify"),s=t.NOTIFY),l=r.parsePath(a),o=l[0],e=l[1],i=null!=o?r._getPath(this,o):this,h.push(this._createBinding(n,i,e,s,r.isAbsolutePath(a))));return h},t.prototype._hasNotifyBinding=function(t,e,n){var i,r,o,s;if(null==this._bindings.notify[t])return!1;for(s=this._bindings.notify[t],r=0,o=s.length;o>r;r++)if(i=s[r],i.attr===n&&i.target===e)return!0;return!1},t.prototype._hasObserveBinding=function(t,e,n){var i,r,o,s;if(null==this._bindings.observe[t])return!1;for(s=this._bindings.observe[t],r=0,o=s.length;o>r;r++)if(i=s[r],i.attr===n&&i.target===e)return!0;return!1},t.prototype._createBinding=function(e,n,i,o,s){var a,l,h,u;switch(o){case t.NOTIFY:if(this._hasNotifyBinding(e,n,i,o))return;return null==(h=(a=this._bindings.notify)[e])&&(a[e]=[]),this._bindings.notify[e].push({attr:i,target:n,transferable:s}),n instanceof t&&n._createBinding(i,this,e,t.OBSERVE,s),this._doNotifyBinding(e);case t.OBSERVE:if(this._hasObserveBinding(e,n,i,o))return;return n instanceof t?(null==(u=(l=this._bindings.observe)[e])&&(l[e]=[]),this._bindings.observe[e].push({attr:i,target:n,transferable:s}),n._createBinding(i,this,e,t.NOTIFY,s)):(r.warn("Binding "+e+"ObserveBinding on",this,": target",n,"is not a MztObject"),void 0);case t.SYNC:return this._createBinding(e,n,i,t.OBSERVE,s),this._createBinding(e,n,i,t.NOTIFY,s)}},t.prototype._removeBinding=function(e,n,i,r){var o,s,a,l,h,u,c,d;switch(r){case t.NOTIFY:if(!this._hasNotifyBinding(e,n,i))return;for(s=[],c=this._bindings.notify[e],a=0,h=c.length;h>a;a++)o=c[a],o.attr!==i&&o.target!==n&&s.push(o);if(0===s.length?this._bindings.notify[e]=s:delete this._bindings.notify[e],n instanceof t)return n._removeBinding(i,this,e,t.OBSERVE);break;case t.OBSERVE:if(!this._hasObserveBinding(e,n,i))return;for(s=[],d=this._bindings.observe[e],l=0,u=d.length;u>l;l++)o=d[l],o.attr!==i&&o.target!==n&&s.push(o);if(0===s.length?this._bindings.observe[e]=s:delete this._bindings.observe[e],n instanceof t)return n._removeBinding(i,this,e,t.NOTIFY);break;case t.SYNC:return this._removeBinding(e,n,i,t.NOTIFY),this._removeBinding(e,n,i,t.OBSERVE)}},t.prototype._removeAllBindings=function(){return this._stripObserveBindings(!1),this._stripNotifyBindings(!1)},t.prototype._doNotifyBinding=function(t){var e,n,i,o,s;if(n=this._bindings.notify[t],null!=n){for(s=[],i=0,o=n.length;o>i;i++)e=n[i],null!=e?r.isFunction(e.target.set)?s.push(e.target.set(e.attr,this.get(t))):s.push(e.target[e.attr]=this.get(t)):s.push(void 0);return s}},t.prototype._createLookups=function(){var t,e,n;n=[];for(t in this)e=this[t],!r.isFunction(this[t])&&r.stringEndsWith(t,"Lookup")&&(t=r.sliceStringBefore(t,"Lookup"),n.push(this[t]=r._getPath(e)));return n},t}()}).call(this)}),t.define("/util.coffee",function(t,e){(function(){var t,n,i,r=[].slice,o={}.hasOwnProperty;i={},n=0,t=e.exports={toString:Object.prototype.toString,getType:function(t){return this.toString.call(t).match(/^\[object\s(.*)\]$/)[1]},isObject:function(t){return"Object"===this.getType(t)},isFunction:function(t){return"Function"===this.getType(t)},isArray:function(t){return"Array"===this.getType(t)},isString:function(t){return"String"===this.getType(t)},isBoolean:function(t){return"Boolean"===this.getType(t)},log:function(){var t,e;return e=arguments[0],t=arguments.length>=2?r.call(arguments,1):[],null!=i[e]&&"undefined"!=typeof console&&null!==console?console.log.apply(console,[e+":"].concat(r.call(t))):void 0},showLog:function(t){return i[t]=!0},hideLog:function(t){return i[t]=!1},error:function(){var t,e;throw e=arguments[0],t=arguments.length>=2?r.call(arguments,1):[],"undefined"!=typeof console&&null!==console&&console.error("Exception:",e,t),e},warn:function(){var t,e;return e=arguments[0],t=arguments.length>=2?r.call(arguments,1):[],"undefined"!=typeof console&&null!==console?console.log("Warning:",e,t):void 0},clone:function(t){return $.extend({},t)},getPath:function(t,e){var n;if(n=this._getPath(t,e),void 0===n)throw Error("Object "+t+" has no "+e);return n},isAbsolutePath:function(t){return t[0].toUpperCase()===t[0]},_getPath:function(e,n){var i,r,o;for(null!=e&&null==n&&(n=e,e=Mozart.root),t.isAbsolutePath(n)&&(e=Mozart.root),i=n.split(".");i.length>0;){if(r=i.shift(),"this"!==r){if(void 0===e[r])return void 0;if(o=t.isFunction(e.get)?e.get.call(e,r):e[r],null===o&&i.length>0)return void 0}else o=e;e=o}return o},getId:function(){return++n},parsePath:function(t){var e,n;return-1===t.indexOf(".")?[null,t]:(n=t.split("."),e=n.pop(),[n.join("."),e])},toMap:function(t,e){var n,i,r,o;for(null==e&&(e="id"),i={},r=0,o=t.length;o>r;r++)n=t[r],i[n[e]]=n;return i},sortBy:function(e,n){return n=t.parseSort(n),e.sort(function(t,e){var i,r,o,s,a;for(s=0,a=n.length;a>s;s++)if(o=n[s],i="function"==typeof t[o]?t[o]():t[o],r="function"==typeof e[o]?e[o]():e[o],null!=i&&null!=r){if(null==i)return-1;if(null==r)return 1;if(i=(""+i).toLowerCase(),r=(""+r).toLowerCase(),i>r)return 1;if(r>i)return-1}})},parseSort:function(t,e){var n,i,r;for(null==e&&(e={pos:0}),r=[],i="";e.pos<t.length;)switch(n=t[e.pos++]){case",":i.length>0&&(r.push(i),i="");break;case"[":if(i.length>0)throw Error("parseSort: Unexpected Character [ at "+(""+e.pos));r.push(this.parseSort(t,e));break;case"]":return i.length>0&&r.push(i),r;default:i+=n}return i.length>0&&(r.push(i),i=""),r},toCapsCase:function(t){var e;return e=t.replace(/^[a-z]{1,1}/g,function(t){return t.toUpperCase()}),e=e.replace(/_[a-z]{1,1}/g,function(t){return t.toUpperCase()}),e=e.replace(/_/g," ")},toSnakeCase:function(t){var e;return e=t.replace(/[A-Z]{1,1}/g,function(t){return"_"+t.toLowerCase()}),e.replace(/^_/,"")},sliceStringBefore:function(t,e){return t.slice(0,t.length-e.length)},sliceStringAfter:function(t,e){return t.slice(e.length)},stringEndsWith:function(t,e){var n;return n=e.length,t.length>=n&&t.slice(-n)===e},stringStartsWith:function(t,e){var n;return n=e.length,t.length>=n&&t.slice(0,n)===e},addBindingsParent:function(e){var n,i,r;r=[];for(n in e)o.call(e,n)&&(i=e[n],t.stringEndsWith(n,"Binding")&&null!=i&&null!=i.length&&i.length>0&&i[0]!==i[0].toUpperCase()?r.push(e[n]="parent."+e[n]):r.push(void 0));return r}}}).call(this)}),t.define("/events.coffee",function(t,e,n){(function(){var e,i;i=t("./util"),n.Events=e=function(){function t(){}return t.callbacks={},t.eventInit=function(e,n){var i,r,o,s;return null==(o=(i=t.callbacks)[e])&&(i[e]={count:0,events:{}}),null!=(s=(r=t.callbacks[e].events)[n])?s:r[n]={}},t.trigger=function(e,n,r){var o,s,a,l,h,u,c;if(null!=t.callbacks[e]&&null!=t.callbacks[e].events[n]){a=[],u=t.callbacks[e].events[n];for(s in u)o=u[s],null==o.fn.call&&i.log("general","callback issue ",o.fn),o.fn.call(this,r,o.binddata),o.once&&a.push({objectId:e,eventName:n,id:s});for(c=[],l=0,h=a.length;h>l;l++)o=a[l],c.push(delete t.callbacks[o.objectId].events[o.eventName][o.id]);return c}},t.one=function(e,n,i,r){return t.eventInit(e,n),t.callbacks[e].events[n][t.callbacks[e].count++]={fn:i,binddata:r,once:!0}},t.bind=function(e,n,i,r){return t.eventInit(e,n),t.callbacks[e].events[n][t.callbacks[e].count++]={fn:i,binddata:r}},t.unbind=function(e,n,i){var r,o,s,a,l,h;{if(null==i||null==t.callbacks[e]||null==t.callbacks[e].events[n])return null!=n&&null!=t.callbacks[e]&&null!=t.callbacks[e].events[n]?(delete t.callbacks[e].events[n],void 0):delete t.callbacks[e];s=[],h=t.callbacks[e].events[n];for(o in h)r=h[o],r.fn===i&&s.push(o);for(a=0,l=s.length;l>a;a++)o=s[a],delete t.callbacks[e].events[n][o]}},t.getBinds=function(e,n){return _(t.callbacks[e].events[n]).values()},t}()}).call(this)}),t.define("/control.coffee",function(t,e,n){(function(){var e,i,r=function(t,e){return function(){return t.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};i=t("./view").View,n.Control=e=function(t){function e(){return this.afterRender=r(this.afterRender,this),e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.idPrefix="control",e.prototype.error=function(t){return this.help=t,this.errorState=!0},e.prototype.afterRender=function(){return this.errorState?this.element.addClass("error"):void 0},e}(i)}).call(this)}),t.define("/controller.coffee",function(t,e,n){(function(){var e,i,r={}.hasOwnProperty,o=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};i=t("./object").MztObject,n.Controller=e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return o(e,t),e}(i)}).call(this)}),t.define("/data-index.coffee",function(t,e,n){(function(){var e,i,r,o,s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};o=t("./object").MztObject,n.DataIndex=i=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return a(e,t),e.indexTypes={},e.prototype.load=function(){throw Error("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.add=function(){throw Error("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.remove=function(){throw Error("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.update=function(){throw Error("Mozart.DataIndex: Abstract, Not Implemented")},e.prototype.rebuild=function(){throw Error("Mozart.DataIndex: Abstract, Not Implemented")},e.registerIndexClassType=function(t,e){return this.indexTypes[t]=e},e.getIndexClassType=function(t){return this.indexTypes[t]},e}(o),n.MapIndex=r=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.init=function(){return this.map={},this.rebuild()},e.prototype.load=function(t){return null!=this.map[t]?this.map[t]:{}},e.prototype.update=function(t,e,n){var i,r;return null!=this.map[e]&&(delete this.map[e][t.id],0===_(this.map[e]).keys().length&&delete this.map[e]),null==(r=(i=this.map)[n])&&(i[n]={}),this.map[n][t.id]=t},e.prototype.add=function(t){var e,n,i;return null==(i=(e=this.map)[n=t[this.attribute]])&&(e[n]={}),this.map[t[this.attribute]][t.id]=t},e.prototype.remove=function(t){var e,n,i,r;i=this.map,r=[];for(n in i)e=i[n],delete e[t.id],0===_(e).keys().length?r.push(delete this.map[n]):r.push(void 0);return r},e.prototype.rebuild=function(){var t,e,n,i,r;for(this.map={},i=this.modelClass.all(),r=[],e=0,n=i.length;n>e;e++)t=i[e],r.push(this.add(t));return r},e}(i),i.registerIndexClassType("map",r),n.BooleanIndex=e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.init=function(){return this.value=this.options.value,this.rebuild()},e.prototype.load=function(t){return t===this.value?this.valueIds:this.nonValueIds},e.prototype.update=function(t,e,n){return e===this.value?delete this.valueIds[t.id]:delete this.nonValueIds[t.id],n===this.value?this.valueIds[t.id]=t:this.nonValueIds[t.id]=t},e.prototype.add=function(t){return t[this.attribute]===this.value?this.valueIds[t.id]=t:this.nonValueIds[t.id]=t},e.prototype.remove=function(t){return delete this.valueIds[t.id],delete this.nonValueIds[t.id]},e.prototype.rebuild=function(){var t,e,n,i,r;for(this.valueIds={},this.nonValueIds={},i=this.modelClass.all(),r=[],e=0,n=i.length;n>e;e++)t=i[e],r.push(this.add(t));return r},e}(i),i.registerIndexClassType("boolean",e)}).call(this)}),t.define("/dom-manager.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},l=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};r=t("./util"),i=t("./object").MztObject,n.DOMManager=e=function(t){function e(){return this.getControlOptionsValues=o(this.getControlOptionsValues,this),this.onControlEvent=o(this.onControlEvent,this),this.onViewEvent=o(this.onViewEvent,this),this.onApplicationEvent=o(this.onApplicationEvent,this),this.release=o(this.release,this),this.checkClickOutside=o(this.checkClickOutside,this),this.checkClickInside=o(this.checkClickInside,this),this.find=o(this.find,this),e.__super__.constructor.apply(this,arguments)}var n;return a(e,t),n={click:"click",dblclick:"dblClick",focus:"focus",blur:"blur",keyup:"keyUp",keydown:"keyDown",keypress:"keyPress",focusout:"focusOut",focusin:"focusIn",change:"change",mouseover:"mouseOver",mouseout:"mouseOut"},e.prototype.init=function(){var t,e,i,r,o;this.element=$(this.rootElement);for(t in n)r=n[t],this.element.on(t,null,{eventName:r},this.onApplicationEvent);
3
+ return e=function(){var t;t=[];for(i in n)o=n[i],t.push(i);return t}().join(" "),this.element.on(e,"[view]",this.onViewEvent),this.element.on(e,"[data-mozart-action]",this.onControlEvent),this.openElements={}},e.prototype.find=function(t){var e,n,i,o,s,a;for(a=this.layouts,o=0,s=a.length;s>o;o++){if(i=a[o],null!=i.views[t])return r.log("general",""+t+": view of",i.rootElement),i.views[t];if(e=i.getControl(t),null!=e)return r.log("general",""+t+": control of",i.rootElement),e}return n=$("#"+t),n.length>0?(r.log("general",""+t+" is a an element"),n[0]):r.log("general","Cannot find ID "+t)},e.prototype.checkClickInside=function(t){var e,n,i,o,s,a,l;if("click"===t.type){for(a=this.layouts,l=[],o=0,s=a.length;s>o;o++)n=a[o],l.push(function(){var o,s;o=n.hasClickInside,s=[];for(e in o)i=o[e],$(t.target).parents("#"+e).length>0?(r.log("events","clickInside on",i,"(",t,")"),s.push(i.clickInside())):s.push(void 0);return s}());return l}},e.prototype.checkClickOutside=function(t){var e,n,i,o,s,a,l;if("click"===t.type){for(a=this.layouts,l=[],o=0,s=a.length;s>o;o++)n=a[o],l.push(function(){var o,s;o=n.hasClickOutside,s=[];for(e in o)i=o[e],0===$(t.target).parents("#"+e).length?(r.log("events","clickOutside on",i,"(",t,")"),s.push(i.clickOutside())):s.push(void 0);return s}());return l}},e.prototype.release=function(){var t,i,r,o,s;for(t in n)o=n[t],this.element.off(t,null,this._checkRootEvent);return i=function(){var t;t=[];for(r in n)s=n[r],t.push(r);return t}().join(" "),this.element.off(i,"[view]",this.onViewEvent),this.element.off(i,"[data-mozart-action]",this.onControlEvent),e.__super__.release.apply(this,arguments)},e.prototype.onApplicationEvent=function(t){return this.trigger(t.data.eventName,t)},e.prototype.onViewEvent=function(t){var e,i,o,s,a,l,h,u;if(this.checkClickInside(t),a=null,e=s=t.currentTarget,null!=e){for(u=this.layouts,l=0,h=u.length;h>l;l++)i=u[l],a=i.views[e.id],null!=a&&(o=n[t.type],this.trigger("viewEvent",t,a),"function"==typeof a[o]&&(r.log("events",o,"on",a,"(",t,")"),a[o](t,a)));return this.checkClickOutside(t),!0}},e.prototype.onControlEvent=function(t){var e,n,i,o,s,a,h,u;for(this.checkClickInside(t),n=$(t.currentTarget),i=n.attr("data-mozart-action"),r.log("controls","action",t),h=this.layouts,s=0,a=h.length;a>s;s++)o=h[s],e=o.getControl(i),null!=e&&(null===e.events||(u=t.type,l.call(e.events,u)>=0))&&("function"==typeof e.view[e.action]?(r.log("events","method",e.action,"on",e.view,"(",t,")"),r.log("controls","action on control",e,t),this.trigger("controlEvent",t,e),e.view[e.action](n,this.getControlOptionsValues(e.view,e.options),t),e.allowDefault||t.preventDefault()):r.warn("Action "+e.action+" does not exist on view "+e.view.id+", "+e.view.name,e));return this.checkClickOutside(t),t.stopImmediatePropagation()},e.prototype.getControlOptionsValues=function(t,e){var n,i,o,s;o={};for(n in e)s=e[n],r.stringEndsWith(n,"Lookup")?(i=r.sliceStringBefore(n,"Lookup"),o[i]=r._getPath(t,s)):o[n]=s;return o},e}(i)}).call(this)}),t.define("/handlebars.coffee",function(t){(function(){var e,n,i,r,o,s;i=t("./util"),r=t("./view").View,n=t("./i18n-view").I18nView,e=t("./collection").Collection,o=function(t,e){return i._getPath(t,e)},s=function(t,e){var n;return"string"==typeof e?n=i._getPath(t,e):"function"==typeof e&&(n=e.call(t)),n},Handlebars.registerHelper("site",function(){return new Handlebars.SafeString("/#")}),Handlebars.registerHelper("bind",function(t,e){var n,r,o,s,a,l,h;i.log("handlebars","handlebars helper 'bind':",this,t,e),1===arguments.length&&i.error("Bind helper must have a target."),n="bind"+i.getId(),s=null!=(l=e.hash.tag)?l:"span",r="<"+s+" id='"+n+"'",h=e.hash;for(o in h)a=h[o],i.stringEndsWith(o,"Html")&&(r+=" "+i.sliceStringBefore(o,"Html")+'="'+a+'"');return r+="></"+s+">",e.data.registerDomBind(n,t),new Handlebars.SafeString(r)}),Handlebars.registerHelper("i18n",function(t,e){var n,r,o;return i.log("handlebars","handlebars helper 'i18n':",this,t,e),1===arguments.length?(n="",i.error("i18n helper usage must reference a key.")):(r=i._getPath(window,"i18n."+t),null==r?(i.error("i18n helper: key '"+t+"' does not exist in current language file."),n=""):(o=null!=e&&null!=e.hash?Mozart.MztObject.create(e.hash):{},n=i.getPath(window,"i18n."+t)(o))),new Handlebars.SafeString(n)}),Handlebars.registerHelper("bindI18n",function(t,e){var r,o,s,a,l,h,u;if(i.log("handlebars","handlebars helper 'bindI18n':",this,t,e),1===arguments.length&&i.error("bindI18n helper must have a target."),l={context:this,i18nTemplate:t,parent:e.data},null!=e.hash){i.addBindingsParent(e.hash),u=e.hash;for(o in u)a=u[o],l[o]=a}return h=l.parent.layout.createView(n,l),l.parent.addView(h),s=h.createElement(),r=s.outerHTML,null==r&&(r=""),l.parent.layout.queueRenderView(h),new Handlebars.SafeString(r)}),Handlebars.registerHelper("view",function(t,e){var n,o,s,a,l,h,u,c,d;if(i.log("handlebars","handlebars helper 'view':",this,t,e),1===arguments.length&&(e=t,t=null),s=e.data,u=null!=t?"string"==typeof t?i._getPath(t):t:r,null==u&&i.error("view handlebars helper: viewClass does not exist","context",t,"this",this),c={context:this,parent:s},null!=e.fn&&(c.templateFunction=e.fn),null!=e.hash){i.addBindingsParent(e.hash),d=e.hash;for(o in d)l=d[o],c[o]=l}return h=s.layout.createView(u,c),s.addView(h),a=h.createElement(),n=a.outerHTML,null==n&&(n=""),s.layout.queueRenderView(h),new Handlebars.SafeString(n)}),Handlebars.registerHelper("collection",function(t,n){var o,s,a,l,h,u,c,d,p,f;i.log("handlebars","handlebars helper 'collection':",this,i.clone(t),n),1===arguments.length?(n=t,t=null,d=r):(d=i.getPath(t),null==d&&i.error("View for collection does not exist","view name",t)),l=n.data,p={context:this,viewClass:d,parent:l},null!=n.fn&&(p.viewClassTemplateFunction=n.fn),i.addBindingsParent(n.hash),f=n.hash;for(a in f)u=f[a],p[a]=u;return o=null!=n.hash.collectionClass?i.getPath(n.hash.collectionClass):e,c=l.layout.createView(o,p),c.parent=l,l.addView(c),h=c.createElement(),s=h.outerHTML,null==s&&(s=""),l.layout.queueRenderView(c),new Handlebars.SafeString(s)}),Handlebars.registerHelper("linkTo",function(t,e){var n,r,o;return i.log("handlebars","handlebars helper 'linkTo':",this,t,e),1===arguments.length&&(e=t),"string"==typeof t?t=i._getPath(this,t):"function"==typeof t&&(t=t.call(this)),null!=t?(n="<a href='/#"+t.showUrl()+"'",null!=(null!=(o=e.hash)?o.classNames:void 0)&&(n+=" class='"+e.hash.classNames+"'"),n+=">",r=e.fn(this),null!=r&&r.length>0||(r="(Empty Value)"),n+=r,n+="</a>",new Handlebars.SafeString(n)):""}),Handlebars.registerHelper("valueOf",function(t,e){var n;return i.log("handlebars","handlebars helper 'valueOf':",this,t,e),1===arguments.length&&(e=t),n=i._getPath(this,t),null==n&&(n=""),new Handlebars.SafeString(n)}),Handlebars.registerHelper("rawPath",function(t,e){var n;return 1===arguments.length&&(e=t),n=i._getPath(this,t),null==n&&(n=""),n}),Handlebars.registerHelper("uriPath",function(t,e){var n;return 1===arguments.length&&(e=t),n=i._getPath(this,t),null==n&&(n=""),encodeURI(n)}),Handlebars.registerHelper("valueEach",function(t,e){var n,r,o,s,a,l;if(i.log("handlebars","handlebars helper 'valueEach':",this,t,e),1===arguments.length&&(e=t),t=i.getPath(this,t),null==t)return"";for(r="",o=0,s=t.length;s>o;o++)n=t[o],r+=e.fn(n),null!=(null!=e?null!=(a=e.hash)?a.seperator:void 0:void 0)&&(r+=e.hash.seperator);return null!=(null!=e?null!=(l=e.hash)?l.seperator:void 0:void 0)&&r.length>0&&(r=r.slice(0,r.length-e.hash.seperator.length)),new Handlebars.SafeString(r)}),Handlebars.registerHelper("yesNo",function(t,e){return i.log("handlebars","handlebars helper 'yesNo':",this,t,e),1===arguments.length&&(e=t),"string"==typeof t&&(t=i.getPath(this,t)),null==t?"No":t?"Yes":"No"}),Handlebars.registerHelper("valueIf",function(t,e){return i.log("handlebars","handlebars helper 'valueOf':",this,t,e),"string"==typeof t&&(t=i._getPath(this,t)),t?e.fn(this):e.inverse(this)}),Handlebars.registerHelper("valueUnless",function(t,e){return"string"==typeof t&&(t=i.getPath(this,t)),t?e.inverse(this):e.fn(this)}),Handlebars.registerHelper("action",function(t,e){var n,r,o,s,a;return i.log("handlebars","handlebars helper 'action':",this,t,e),1===arguments.length&&(e=record),a=e.data,null!=e.hash.target&&(a="parent"===e.hash.target?e.data.parent:i.getPath(e.data,e.hash.target)),n=i.getId(),s='data-mozart-action="'+n+'"',o=null!=e.hash.events?e.hash.events.split(","):["click"],r=e.hash.allowDefault&&!0,e.data.layout.addControl(n,{action:t,view:a,options:e.hash,events:o,allowDefault:r}),new Handlebars.SafeString(s)}),Handlebars.registerHelper("date",function(t){var e,n;return n=s(this,t),e=i.serverToLocalDate(n)||"(none)",new Handlebars.SafeString(e)}),Handlebars.registerHelper("dateTime",function(t){var e,n;return n=s(this,t),e=i.serverToLocalDateTime(n),new Handlebars.SafeString(e)}),Handlebars.registerHelper("timeAgo",function(t){var e,n;return n=s(this,t),e=i.serverToLocalTimeAgo(n),new Handlebars.SafeString(e)}),Handlebars.registerHelper("mozartversion",function(){return new Handlebars.SafeString(Mozart.version)}),Handlebars.registerHelper("mozartversiondate",function(){return new Handlebars.SafeString(Mozart.versionDate.toLocaleDateString())})}).call(this)}),t.define("/i18n-view.coffee",function(t,e,n){(function(){var e,i,r,o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};r=t("./view").View,i=t("./util"),n.I18nView=e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.tag="span",e.prototype.idPrefix="i18nview",e.prototype.init=function(){if(e.__super__.init.apply(this,arguments),null==this.i18nTemplate)throw Error("Mozart.I18nView must have a i18nTemplate");return this.bind("change",this.redraw)},e.prototype.templateFunction=function(){try{return i.getPath(window,"i18n."+this.i18nTemplate)(this)}catch(t){return i.warn("MessageFormat failed with Error:",t),""}},e}(r)}).call(this)}),t.define("/http.coffee",function(t,e,n){(function(){var e,i,r,o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};i=t("./object").MztObject,r=t("./util"),n.HTTP=e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.handleError=function(t,e,n,i){switch(t.status){case 401:return Mozart.Ajax.trigger("httpAuthorizationRequired",n,t);case 404:return Mozart.Ajax.trigger("httpForbidden",n,t);default:return r.error("Model.Ajax.handleError",t,e,i)}},e.prototype._xhrHandler=function(t,e,n,i,o){var s,a,l,h,u;return this.support.ajax?(u="object"==typeof t?this.support.cors?t.cors||t.proxy:t.proxy:t,l=e||"GET",h=i||{},s=o||{},a=n||{},o.success=o.success||function(t,n,i){return r.log("Mozart.HTTP",e,"success",t,n,i)},o.error=o.error||function(t,n,i){return r.log("Mozart.HTTP",e,"error",t,n,i)},o.complete=o.complete||function(t,n){return r.log("Mozart.HTTP",e,"complete",t,n)},this._request(u,l,a,h,s)):r.log("Mozart.HTTP","AJAX is not supported. Exiting")},e.prototype._request=function(t,e,n,i,r){return $.ajax({url:t,type:e,success:r.success,error:r.error,complete:r.complete,data:n,context:i.context||this,dataType:i.dataType||"json",contentType:i.contentType||"application/json"})},e.prototype.support={ajax:function(){try{return!!new XMLHttpRequest}catch(t){return!1}},cors:function(){return this.ajax&&"withCredentials"in new XMLHttpRequest}},e.prototype.get=function(t,e){var n,i,r;return e=e||{},i=e.data||{},r=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"GET",i,r,n)},e.prototype.post=function(t,e){var n,i,r;return e=e||{},i=e.data||{},r=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"POST",i,r,n)},e.prototype.put=function(t,e){var n,i,r;return e=e||{},i=e.data||{},r=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"PUT",i,r,n)},e.prototype["delete"]=function(t,e){var n,i,r;return e=e||{},i=e.data||{},r=e.options||{},n=e.callbacks||{},this._xhrHandler(t,"DELETE",i,r,n)},e}(i)}).call(this)}),t.define("/layout.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};r=t("./util"),i=t("./router").Router,n.Layout=e=function(t){function e(){return this.releaseViewControls=o(this.releaseViewControls,this),this.removeControl=o(this.removeControl,this),this.getControl=o(this.getControl,this),this.addControl=o(this.addControl,this),this.releaseViews=o(this.releaseViews,this),this.releaseView=o(this.releaseView,this),this.queueReleaseView=o(this.queueReleaseView,this),this.release=o(this.release,this),this.processRenderQueue=o(this.processRenderQueue,this),this.queueRenderView=o(this.queueRenderView,this),this._transition=o(this._transition,this),this.doRoute=o(this.doRoute,this),this.resetRoute=o(this.resetRoute,this),this.bindRoot=o(this.bindRoot,this),this.createView=o(this.createView,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.init=function(){var t,n,i,r,o;for(e.__super__.init.apply(this,arguments),this.viewRenderQueue=[],this.releaseMap={},this.views={},this.currentState=null,this.controls={},this.hasClickOutside={},this.hasClickInside={},r=this.states,o=[],n=0,i=r.length;i>n;n++)t=r[n],null!=t.path&&null!=t.viewClass&&o.push(this.register(t.path,this.doRoute,t));return o},e.prototype.createView=function(t,e){var n;return null==e&&(e={}),e.layout=this,n=t.create(e),this.views[n.id]=n,null!=n.clickInside&&(this.hasClickInside[n.id]=n),null!=n.clickOutside&&(this.hasClickOutside[n.id]=n),n},e.prototype.bindRoot=function(){return this.rootEl=$(this.rootElement)[0]},e.prototype.resetRoute=function(){return this.viewRenderQueue=[],this.currentState=null,this.releaseViews()},e.prototype.doRoute=function(t,e){return null==this.currentState||this.currentState.canExit()?(this.currentState=null,t.canEnter(e)?(this._transition(t),!0):(r.log("layout","cannot enter state",t,e),!1)):(r.log("layout","cannot exit state",this.currentState),!1)},e.prototype._transition=function(t){return this.resetRoute(),this.currentState=t,this.currentState.doTitle(),null!=this.currentState.viewClass?(null!=this.currentView&&(this.releaseMap[this.currentView.id]=this.currentView),this.currentView=this.createView(this.currentState.viewClass,this.currentState.viewOptions),this.currentView.el=this.rootEl,this.queueRenderView(this.currentView)):void 0},e.prototype.queueRenderView=function(t){var e,n,i;return r.log("layout",""+this._mozartId+" queueRenderView",t),null==(i=(e=this.views)[n=t.id])&&(e[n]=t),0===this.viewRenderQueue.length&&_.delay(this.processRenderQueue,0),this.viewRenderQueue.push(t)},e.prototype.processRenderQueue=function(){var t,e,n,i,o,s,a,l,h,u,c,d,p,f,g,y,m,v,w;if(!this.released&&0!==this.viewRenderQueue.length){for(r.log("layout",""+this._mozartId+" processRenderQueue with "+this.viewRenderQueue.length+" views"),e=[],n=[];this.viewRenderQueue.length>0;)s=this.viewRenderQueue.shift(),s.beforeRender(),s.releaseChildren(),s.prepareElement(),n.push(s);for(i=[],h=0,p=n.length;p>h;h++)for(a=n[h],u=0,f=n.length;f>u;u++)l=n[u],l!==a&&a.hasAncestor(l)&&!_.contains(i,a)&&i.push(a);for(o=_.difference(n,i),c=0,g=o.length;g>c;c++)s=o[c],s.reassignElements();for(d=0,y=o.length;y>d;d++)s=o[d],s.replaceElement();for(v=0,m=n.length;m>v;v++)s=n[v],s.postRender();w=this.releaseMap;for(t in w)s=w[t],null!=s&&s.release();return this.releaseMap={},r.log("layout",""+this._mozartId+" render finished"),this.trigger("render:complete")}},e.prototype.release=function(){return this.releaseViews(),e.__super__.release.apply(this,arguments)},e.prototype.queueReleaseView=function(t){return this.releaseMap[t.id]=t},e.prototype.releaseView=function(t){return this.releaseViewControls(t),delete this.views[t.id],delete this.hasClickOutside[t.id],delete this.hasClickInside[t.id]},e.prototype.releaseViews=function(){var t,e,n,i;n=this.views,i=[];for(t in n)e=n[t],r.log("layout","processRenderQueue:releasing",e.id,e),this.releaseMap[t]=e,i.push(this.processRenderQueue());return i},e.prototype.addControl=function(t,e){return r.log("layout","adding control",t,e),this.controls[t]=e},e.prototype.getControl=function(t){return this.controls[t]},e.prototype.removeControl=function(t){return r.log("layout","removing control",t),delete this.controls[t]},e.prototype.releaseViewControls=function(t){var e,n,i,o;i=this.controls,o=[];for(n in i)e=i[n],e.view===t&&(r.log("layout","releasing control for view",t,"control",e.action,e),o.push(delete this.controls[n]));return o},e}(i)}).call(this)}),t.define("/router.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};e=t("./object").MztObject,r=t("./util"),n.Router=i=function(t){function e(){return this.release=o(this.release,this),this.navigateRoute=o(this.navigateRoute,this),this.onPopState=o(this.onPopState,this),this.onNavigationEvent=o(this.onNavigationEvent,this),this.onHashChange=o(this.onHashChange,this),this.register=o(this.register,this),this.stop=o(this.stop,this),this.start=o(this.start,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.init=function(){var t;return this.routes={},null!=(t=this.useHashRouting)?t:this.useHashRouting=!1},e.prototype.start=function(){return this.useHashRouting?($(window).bind("hashchange",this.onHashChange),this.onHashChange()):($("body").on("click","a",this.onNavigationEvent),$(window).on("popstate",this.onPopState),-1!==navigator.userAgent.indexOf("Firefox")?this.onPopState():void 0)},e.prototype.stop=function(){return this.useHashRouting?$(window).unbind("hashchange",this.onHashChange):($("body").off("click","a",this.onNavigationEvent),$(window).off("popstate",this.onPopState))},e.prototype.register=function(t,e,n){var i,o,s,a,l,h;for(r.log("routes","registering route",t,n),a=t.split("/"),i=[],o="",l=0,h=a.length;h>l;l++)s=a[l],":"===s[0]?(o+="([^\\/]+)\\/",i.push(s.substr(1))):o+=this._escForRegEx(s)+"\\/";return o.length>2&&(o=o.substr(0,o.length-2)),this.routes[t]={regex:RegExp("^"+o+"$","i"),params:i,callback:e,data:n}},e.prototype.onHashChange=function(){var t;return t=window.location.hash,t.length>0&&"#"===t[0]&&(t=t.substr(1)),this.navigateRoute(t)},e.prototype.onNavigationEvent=function(t){return t.target.host===document.location.host&&t.target.port===document.location.port&&t.target.protocol===document.location.protocol?this.navigateRoute(t.target.pathname)?(history.pushState({one:1},null,t.target.href),t.preventDefault()):void 0:void 0},e.prototype.onPopState=function(){return this.navigateRoute(window.location.pathname)},e.prototype.navigateRoute=function(t){var e,n,i,o,s,a,l,h,u,c;if(this.isNavigating=!0,null==t||0===t.length){if(a=this.routes["/"],null!=a)return a.callback(a.data,i),this.isNavigating=!1,!1;r.log("routemanager","WARNING: No Default route defined, no route for path",t)}u=this.routes;for(o in u)if(a=u[o],i={},n=a.regex.exec(t),null!==n){for(e=1,c=a.params,l=0,h=c.length;h>l;l++)s=c[l],n.length>e&&(i[s]=n[e++]);return a.callback(a.data,i),this.isNavigating=!1,!0}return this.isNavigating=!1,this.trigger("noroute",window.location.hash),!1},e.prototype.release=function(){return this.stop(),e.__super__.release.apply(this,arguments)},e.prototype._escForRegEx=function(t){var e,n,i,r;for(t.replace("\\","\\\\"),e="./+{}()*",i=0,r=e.length;r>i;i++)n=e[i],t=t.replace(n,"\\"+n);return t},e}(e)}).call(this)}),t.define("/model-instance.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},l=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};r=t("./util"),i=t("./object").MztObject,n.Instance=e=function(t){function e(){return this.copyFrom=o(this.copyFrom,this),this.copyTo=o(this.copyTo,this),this.set=o(this.set,this),this.get=o(this.get,this),this.destroy=o(this.destroy,this),this.save=o(this.save,this),this.load=o(this.load,this),e.__super__.constructor.apply(this,arguments)}var n;return a(e,t),n=["id"],e.prototype.init=function(){return this._type=this.modelClass.modelName},e.prototype.load=function(t){return null==t&&(t={}),this.modelClass.loadInstance(this,t)},e.prototype.save=function(t){return null==t&&(t={}),this.modelClass.exists(this.id)?(this.modelClass.updateInstance(this,t),this.trigger("update")):(this.modelClass.createInstance(this,t),this.trigger("create")),this.trigger("change")},e.prototype.destroy=function(t){return null==t&&(t={}),this.trigger("destroy",t),this.trigger("change"),this.modelClass.destroyInstance(this,t)},e.prototype.get=function(t){if(this.modelClass.hasAttribute(t)||r.isFunction(this[t]))return r.isFunction(this[t])?this[t].apply(this):e.__super__.get.call(this,t);throw Error(""+this.modelClass.modelName+" has no attribute or relation '"+t+"' or foreign key '"+t+"_id'")},e.prototype.set=function(t,n){if(this.modelClass.hasAttribute(t)||r.isFunction(this[t]))return r.isFunction(this[t])?this[t](n):("id"!==t&&this.modelClass.hasIndex(t)&&this.modelClass.exists(this.id)&&this.modelClass.updateIndex(t,this,this[t],n),e.__super__.set.call(this,t,n));throw Error(""+this.modelClass.modelName+" has no attribute or relation '"+t+"' or foreign key '"+t+"_id'")},e.prototype.copyTo=function(t){var e,r,o;null==t&&(t=i.create()),o=this.modelClass.attrs;for(e in o)r=o[e],0>l.call(n,e)&&(null!=t.set?t.set(e,this[e]):t[e]=this[e]);return t},e.prototype.copyFrom=function(t){var e,i,r,o,s;i=!1;for(e in t)s=t[e],0>l.call(n,e)&&(o=this.modelClass.attrs[e],null!=o&&(r=s,"decimal"===o&&(r=parseFloat(r)),this[e]!==r&&(i=!0,this.set(e,r))));return i},e}(i)}).call(this)}),t.define("/model-instancecollection.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};r=t("./util"),i=t("./object").MztObject,n.InstanceCollection=e=function(t){function e(){return this.unBindEvents=o(this.unBindEvents,this),this.bindEvents=o(this.bindEvents,this),this.allAsMap=o(this.allAsMap,this),this.count=o(this.count,this),e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.count=function(){return this.all().length},e.prototype.allAsMap=function(){return r.toMap(this.all())},e.prototype.all=function(){return[]},e.prototype.bindEvents=function(t){var e,n,i,r;for(r=[],n=0,i=t.length;i>n;n++)e=t[n],e.bind("create",this.onModelChange),e.bind("update",this.onModelChange),r.push(e.bind("destroy",this.onModelChange));return r},e.prototype.unBindEvents=function(t){var e,n,i,r;for(r=[],n=0,i=t.length;i>n;n++)e=t[n],e.unbind("create",this.onModelChange),e.unbind("update",this.onModelChange),r.push(e.unbind("destroy",this.onModelChange));return r},e}(i)}).call(this)}),t.define("/model-onetomanycollection.coffee",function(t,e,n){(function(){var e,i,r=function(t,e){return function(){return t.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.OneToManyCollection=i=function(t){function e(){return this.release=r(this.release,this),this.onModelChange=r(this.onModelChange,this),this.contains=r(this.contains,this),this.remove=r(this.remove,this),this.createFromValues=r(this.createFromValues,this),this.add=r(this.add,this),this.all=r(this.all,this),e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.init=function(){return this.bindEvents([this.otherModel])},e.prototype.all=function(){return this.otherModel.findByAttribute(this.fkname,this.record.id)},e.prototype.add=function(t){return t.set(this.fkname,this.record.id),t.save(),this.record.trigger("change:"+this.attribute)},e.prototype.createFromValues=function(t){var e;return e=this.otherModel.initInstance(t),this.add(e),e},e.prototype.remove=function(t){return t.set(this.fkname,null),this.record.trigger("change:"+this.attribute)},e.prototype.contains=function(){return this.otherModel.findByAttribute(this.fkname,this.record.id).length>0},e.prototype.onModelChange=function(t){return this.trigger("change",t)},e.prototype.release=function(){return this.unBindEvents([this.otherModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-onetomanypolycollection.coffee",function(t,e,n){(function(){var e,i,r=function(t,e){return function(){return t.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.OneToManyPolyCollection=i=function(t){function e(){return this.contains=r(this.contains,this),this.remove=r(this.remove,this),this.add=r(this.add,this),this.createFromValues=r(this.createFromValues,this),this.all=r(this.all,this),e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.all=function(){var t;return t={},t[this.thatFkAttr]=this.record.id,t[this.thatTypeAttr]=this.model.modelName,this.otherModel.findByAttributes(t)},e.prototype.createFromValues=function(t){var e;return e=this.otherModel.initInstance(t),this.add(e),e},e.prototype.add=function(t){return t.set(this.thatFkAttr,this.record.id),t.set(this.thatTypeAttr,this.model.modelName),t.save()},e.prototype.remove=function(t){return t.set(this.thatFkAttr,null),t.set(this.thatTypeAttr,null),t.save()},e.prototype.contains=function(){var t;return t={},t[this.thatFkAttr]=this.record.id,t[this.thatTypeAttr]=this.model.modelName,0!==this.otherModel.findByAttributes(t).length},e}(e)}).call(this)}),t.define("/model-manytomanycollection.coffee",function(t,e,n){(function(){var e,i,r=function(t,e){return function(){return t.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.ManyToManyCollection=i=function(t){function e(){return this.release=r(this.release,this),this.onModelChange=r(this.onModelChange,this),this.contains=r(this.contains,this),this.remove=r(this.remove,this),this.createFromValues=r(this.createFromValues,this),this.add=r(this.add,this),this.all=r(this.all,this),e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.init=function(){return this.bindEvents([this.linkModel])},e.prototype.all=function(){var t,e,n,i,r;for(e=this.linkModel.findByAttribute(this.thisFkAttr,this.record.id),r=[],n=0,i=e.length;i>n;n++)t=e[n],r.push(this.otherModel.findById(t[this.thatFkAttr]));return r},e.prototype.add=function(t){var e,n;return n={},n[this.thisFkAttr]=this.record.id,n[this.thatFkAttr]=t.id,0===this.linkModel.findByAttributes(n).length?(e=this.linkModel.initInstance(),e.set(this.thisFkAttr,this.record.id),e.set(this.thatFkAttr,t.id),e.save(),e):void 0},e.prototype.createFromValues=function(t){var e;return e=this.otherModel.initInstance(t),e.save(),this.add(e),e},e.prototype.remove=function(t){var e,n,i,r,o,s;for(i={},i[this.thisFkAttr]=this.record.id,i[this.thatFkAttr]=t.id,n=this.linkModel.findByAttributes(i),s=[],r=0,o=n.length;o>r;r++)e=n[r],s.push(e.destroy());return s},e.prototype.contains=function(t){var e;return e={},e[this.thisFkAttr]=this.record.id,e[this.thatFkAttr]=t.id,0!==this.linkModel.findByAttributes(e).length},e.prototype.onModelChange=function(t){var e;return t.get(this.thisFkAttr)===this.record.id?(e=this.otherModel.findById(t[this.thatFkAttr]),this.trigger("change",e)):void 0},e.prototype.release=function(){return this.unBindEvents([this.linkModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-manytomanypolycollection.coffee",function(t,e,n){(function(){var e,i,r=function(t,e){return function(){return t.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.ManyToManyPolyCollection=i=function(t){function e(){return this.release=r(this.release,this),this.onModelChange=r(this.onModelChange,this),this.contains=r(this.contains,this),this.remove=r(this.remove,this),this.add=r(this.add,this),this.createFromValues=r(this.createFromValues,this),this.all=r(this.all,this),e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.init=function(){return this.bindEvents([this.linkModel])},e.prototype.all=function(){var t,e,n,i,r,o;for(n={},n[this.thisFkAttr]=this.record.id,n[this.thatTypeAttr]=this.otherModel.modelName,e=this.linkModel.findByAttributes(n),o=[],i=0,r=e.length;r>i;i++)t=e[i],o.push(this.otherModel.findById(t[this.thatFkAttr]));return o},e.prototype.createFromValues=function(t){var e;return e=this.otherModel.initInstance(t),e.save(),this.add(e),e},e.prototype.add=function(t){var e,n;return n={},n[this.thisFkAttr]=this.record.id,n[this.thatFkAttr]=t.id,n[this.thatTypeAttr]=this.otherModel.modelName,0===this.linkModel.findByAttributes(n).length?(e=this.linkModel.initInstance(),e.set(this.thisFkAttr,this.record.id),e.set(this.thatFkAttr,t.id),e.set(this.thatTypeAttr,this.otherModel.modelName),e.save(),e):void 0},e.prototype.remove=function(t){var e,n,i,r,o,s;for(n={},n[this.thisFkAttr]=this.record.id,n[this.thatFkAttr]=t.id,n[this.thatTypeAttr]=this.otherModel.modelName,o=this.linkModel.findByAttributes(n),s=[],i=0,r=o.length;r>i;i++)e=o[i],s.push(e.destroy());return s},e.prototype.contains=function(t){var e;return e={},e[this.thisFkAttr]=this.record.id,e[this.thatFkAttr]=t.id,e[this.thatTypeAttr]=this.otherModel.modelName,0!==this.linkModel.findByAttributes(e).length},e.prototype.onModelChange=function(t){var e;return t[this.thisFkAttr]===this.record.id&&t[this.thatTypeAttr]===this.otherModel.modelName?(e=this.otherModel.findById(t[this.thatFkAttr]),this.trigger("change",e)):void 0},e.prototype.release=function(){return this.unBindEvents([this.linkModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-manytomanypolyreversecollection.coffee",function(t,e,n){(function(){var e,i,r=function(t,e){return function(){return t.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};e=t("./model-instancecollection").InstanceCollection,n.ManyToManyPolyReverseCollection=i=function(t){function e(){return this.release=r(this.release,this),this.onModelChange=r(this.onModelChange,this),this.contains=r(this.contains,this),this.remove=r(this.remove,this),this.add=r(this.add,this),this.createFromValues=r(this.createFromValues,this),this.all=r(this.all,this),e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.init=function(){return this.bindEvents([this.linkModel])},e.prototype.all=function(){var t,e,n,i,r,o;for(n={},n[this.thatFkAttr]=this.record.id,n[this.thatTypeAttr]=this.model.modelName,e=this.linkModel.findByAttributes(n),o=[],i=0,r=e.length;r>i;i++)t=e[i],o.push(this.otherModel.findById(t[this.thisFkAttr]));
4
+ return o},e.prototype.createFromValues=function(t){var e;return e=this.otherModel.initInstance(t),e.save(),this.add(e),e},e.prototype.add=function(t){var e,n;return n={},n[this.thisFkAttr]=t.id,n[this.thatFkAttr]=this.record.id,n[this.thatTypeAttr]=this.model.modelName,0===this.linkModel.findByAttributes(n).length?(e=this.linkModel.initInstance(),e.set(this.thisFkAttr,t.id),e.set(this.thatFkAttr,this.record.id),e.set(this.thatTypeAttr,this.model.modelName),e.save(),e):void 0},e.prototype.remove=function(t){var e,n,i,r,o,s;for(n={},n[this.thisFkAttr]=t.id,n[this.thatFkAttr]=this.record.id,n[this.thatTypeAttr]=this.model.modelName,o=this.linkModel.findByAttributes(n),s=[],i=0,r=o.length;r>i;i++)e=o[i],s.push(e.destroy());return s},e.prototype.contains=function(t){var e;return e={},e[this.thisFkAttr]=t.id,e[this.thatFkAttr]=this.record.id,e[this.thatTypeAttr]=this.model.modelName,0!==this.linkModel.findByAttributes(e).length},e.prototype.onModelChange=function(t){var e;return t[this.thatFkAttr]===this.record.id&&t[this.thatTypeAttr]===this.model.modelName?(e=this.model.findById(t[this.thisFkAttr]),this.trigger("change",e)):void 0},e.prototype.release=function(){return this.unBindEvents([this.linkModel]),e.__super__.release.apply(this,arguments)},e}(e)}).call(this)}),t.define("/model-ajax.coffee",function(t){(function(){var e,n,i,r;e=t("./model").Model,n=t("./util"),r={},i={},e.extend({ajax:function(t){var e,o,s,a,l,h,u,c,d;for(h=["url","interface","plural"],o=0,s=h.length;s>o;o++)e=h[o],null!=t[e]&&(this[e]=t[e]);return this.bind("load",this.loadServer),this.bind("create",this.createServer),this.bind("update",this.updateServer),this.bind("destroy",this.destroyServer),null==(u=r[a=this.modelName])&&(r[a]={}),null==(c=i[l=this.modelName])&&(i[l]={}),null==(d=Mozart.Ajax)&&(Mozart.Ajax=Mozart.MztObject.create({handleError:function(t,e,i,r){switch(t.status){case 401:return Mozart.Ajax.trigger("httpAuthorizationRequired",i,t);case 404:return Mozart.Ajax.trigger("httpForbidden",i,t);default:return n.error("Model.Ajax.handleError",t,e,r)}}})),this.instanceClass.extend({getServerId:function(){return this.modelClass.getServerId(this.id)},existsOnServer:function(){return null!=this.modelClass.getServerId(this.id)},loadServer:function(){return this.modelClass.load(this.modelClass.getServerId(this.id))}})},registerServerId:function(t,e){if(null==r[this.modelName])throw Error("Model.registerServerId: "+this.modelName+" is not registered for ajax.");return r[this.modelName][e]=t,i[this.modelName][t]=e},unRegisterServerId:function(t,e){return delete r[this.modelName][e],delete i[this.modelName][t]},getServerId:function(t){return i[this.modelName][t]},getClientId:function(t){return r[this.modelName][t]},toServerObject:function(t){var n,i,r,o,s,a,l,h;r={},a=this.attrs;for(n in a)o=a[n],"id"!==n&&(r[n]=t[n]);r.id=this.getServerId(t.id),l=this.fks;for(n in l)i=l[n],r[n]=i.getServerId(t[n]);h=this.polyFks;for(n in h)s=h[n],r[n]=null!=t[s]?e.models[t[s]].getServerId(t[n]):null;return r},toClientObject:function(t){var n,i,r,o,s,a,l,h;r={},a=this.attrs;for(n in a)o=a[n],"id"!==n&&t[n]!==void 0&&(r[n]=t[n]);r.id=this.getClientId(t.id),l=this.fks;for(n in l)i=l[n],t[n]!==void 0&&(r[n]=i.getClientId(t[n]),r[n]===void 0&&(r[n]=null));h=this.polyFks;for(n in h)s=h[n],r[n]=t[n]!==void 0&&null!=t[s]?e.models[t[s]].getClientId(t[n]):null;return r},loadServer:function(t){var e;return e=t.modelClass.getServerId(t.id),null!=e?t.modelClass.load(e):void 0},createServer:function(t){return t.modelClass.createAjax(t.id,t.modelClass.toServerObject(t))},updateServer:function(t){var e;return e=t.modelClass.getServerId(t.id),null!=e?t.modelClass.updateAjax(e,t.id,t.modelClass.toServerObject(t)):void 0},destroyServer:function(t){var e;return e=t.modelClass.getServerId(t.id),null!=e?t.modelClass.destroyAjax(t.modelClass.getServerId(t.id),t.id):void 0},loadAll:function(){var t,e,i,r;return r=function(t,e){var n,i,r;for(null!=this.model.plural&&(t=t[this.model.plural]),i=0,r=t.length;r>i;i++)n=t[i],this.model._processLoad(n,this.model,e);return this.model.trigger("loadAllComplete")},i=function(t,e,n){return Mozart.Ajax.handleError(t,e,this,n)},e=function(t,e){return n.log("ajax","Model.loadAll.onComplete",t,e)},t=Mozart.HTTP.create(),t.get(this.url,{options:{context:{model:this}},callbacks:{success:r,error:i,complete:e}})},load:function(t){var e,i,r,o;return o=function(t,e){return null!=this.model.plural&&(t=t[this.model.plural]),this.model._processLoad(t,this.model,e)},r=function(t,e,n){return Mozart.Ajax.handleError(t,e,this,n)},i=function(t,e){return n.log("ajax","Model.load.onComplete",t,e)},e=Mozart.HTTP.create(),e.get(this.url+"/"+t,{options:{context:{model:this,id:t}},callbacks:{success:o,error:r,complete:i}})},_processLoad:function(t,e,i){var r,o,s;return s=t.id,r=e.toClientObject(t),o=e.findById(r.id),null==o&&(o=e.initInstance(t)),e.registerServerId(o.id,s),o.copyFrom(r),o.save({disableModelCreateEvent:!0,disableModelUpdateEvent:!0}),n.log("ajax","Model._processLoad.onSuccess",i,t),e.trigger("loadComplete",o)},createAjax:function(t,e){var i,r,o,s;return s=function(e,i){return this.model.registerServerId(this.clientId,e.id),n.log("ajax","Model.createAjax.onSuccess",i,e),this.model.trigger("createComplete",this.model.findById(t))},o=function(t,e,n){return Mozart.Ajax.handleError(t,e,this,n)},r=function(t,e){return n.log("ajax","Model.createAjax.onComplete",t,e)},i=Mozart.HTTP.create(),i.post(this.url,{data:JSON.stringify(e),options:{context:{model:this,clientId:t}},callbacks:{success:s,error:o,complete:r}})},updateAjax:function(t,e,i){var r,o,s,a;return a=function(t,i){return n.log("ajax","Model.updateAjax.onSuccess",i,t),this.model.trigger("updateComplete",this.model.findById(e))},s=function(t,e,n){return Mozart.Ajax.handleError(t,e,this,n)},o=function(t,e){return n.log("ajax","Model.updateAjax.onComplete",t,e)},r=Mozart.HTTP.create(),r.put(this.url+"/"+t,{data:JSON.stringify(i),options:{context:{model:this,clientId:this.clientId,serverId:this.serverId}},callbacks:{success:a,error:s,complete:o}})},destroyAjax:function(t,e){var i,r,o,s;return s=function(i,r){return this.model.unRegisterServerId(e,t),n.log("ajax","Model.destroyAjax.onSuccess",r,i),this.model.trigger("destroyComplete",t)},o=function(t,e,n){return Mozart.Ajax.handleError(t,e,this,n)},r=function(t,e){return n.log("ajax","Model.destroyAjax.onComplete",t,e)},i=Mozart.HTTP.create(),i["delete"](this.url+"/"+t,{options:{context:{model:this,clientId:e,serverId:t}},callbacks:{success:s,error:o,complete:r}})}})}).call(this)}),t.define("/model.coffee",function(t,e,n){(function(){var e,i,r,o,s,a,l,h,u,c,d,p=function(t,e){return function(){return t.apply(e,arguments)}},f={}.hasOwnProperty,g=function(t,e){function n(){this.constructor=t}for(var i in e)f.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};d=t("./util"),h=t("./object").MztObject,e=t("./data-index").DataIndex,i=t("./model-instance").Instance,r=t("./model-instancecollection").InstanceCollection,u=t("./model-onetomanycollection").OneToManyCollection,c=t("./model-onetomanypolycollection").OneToManyPolyCollection,o=t("./model-manytomanycollection").ManyToManyCollection,s=t("./model-manytomanypolycollection").ManyToManyPolyCollection,a=t("./model-manytomanypolyreversecollection").ManyToManyPolyReverseCollection,n.Model=l=function(t){function n(){return this.index=p(this.index,this),this._generateId=p(this._generateId,this),this._getInstance=p(this._getInstance,this),this.toSnakeCase=p(this.toSnakeCase,this),this.destroyInstance=p(this.destroyInstance,this),this.updateInstance=p(this.updateInstance,this),this.createInstance=p(this.createInstance,this),this.loadInstance=p(this.loadInstance,this),this.createFromValues=p(this.createFromValues,this),this.initInstance=p(this.initInstance,this),this.exists=p(this.exists,this),this.findByAttributes=p(this.findByAttributes,this),this.findByAttribute=p(this.findByAttribute,this),this.selectAsMap=p(this.selectAsMap,this),this.selectIds=p(this.selectIds,this),this.select=p(this.select,this),this.findAll=p(this.findAll,this),this.findById=p(this.findById,this),this.count=p(this.count,this),this.allAsMap=p(this.allAsMap,this),this.all=p(this.all,this),this.hasManyThrough=p(this.hasManyThrough,this),this.hasMany=p(this.hasMany,this),this.belongsToPoly=p(this.belongsToPoly,this),this.belongsTo=p(this.belongsTo,this),this.polyForeignKeys=p(this.polyForeignKeys,this),this.foreignKeys=p(this.foreignKeys,this),this.attributes=p(this.attributes,this),this.reset=p(this.reset,this),n.__super__.constructor.apply(this,arguments)}return g(n,t),n.idCount=1,n.indexForeignKeys=!0,n.models={},n.prototype.toString=function(){return"Model: "+this.modelName},n.prototype.init=function(){var t;if(null==this.modelName)throw Error("Model must have a modelName");return this.records={},this.fks={},this.polyFks={},this.attrs={id:"integer"},this.relations={},this.indexes={},n.models[this.modelName]=this,this.instanceClass=t=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return g(e,t),e}(i)},n.prototype.reset=function(){var t,e,n;n=this.records;for(t in n)e=n[t],e.release();return this.records={},this.rebuildAllIndexes()},n.prototype.attributes=function(t){var e,n,i;i=[];for(e in t)n=t[e],i.push(this.attrs[e]=n);return i},n.prototype.hasAttribute=function(t){return null!=this.attrs[t]||null!=this.fks[t+"_id"]},n.prototype.hasRelation=function(t){return null!=this.relations[t]},n.prototype.foreignKeys=function(t){var e,i,r;r=[];for(e in t)i=t[e],this.fks[e]=i,n.DataIndexForeignKeys?r.push(this.index(e)):r.push(void 0);return r},n.prototype.polyForeignKeys=function(t){var e,i,r;r=[];for(e in t)i=t[e],this.polyFks[e]=i,n.DataIndexForeignKeys?r.push(this.index(e)):r.push(void 0);return r},n.prototype.belongsTo=function(t,e,n){var i,r,o,s,a;return null==e&&null==e&&(e=this.toSnakeCase(t.modelName)),r={},null==n&&(n=e+"_id"),r[n]="integer",this.attributes(r),o={},o[n]=t,this.foreignKeys(o),s={},s[e]=function(i){var r;if(1===arguments.length){if(null!==i&&(null==i.modelClass||i.modelClass!==t))throw Error("Cannot assign "+i+" to belongsTo "+this.modelClass.modelName+":"+e+" (Value is not an Instance or incorrect ModelClass)");return null!=i?this.set(n,i.id):this.set(n,null)}return r=this[n],null==r?null:t.findById(r)},this.instanceClass.extend(s),i=this,a=function(e){var i,r,o,s,a;for(s=t.findByAttribute(n,e.id),a=[],r=0,o=s.length;o>r;r++)i=s[r],i.set(n,null),a.push(i.save());return a},t.bind("destroy",a)},n.prototype.hasOne=function(t,e,n){var i,r,o,s;return null==e&&(e=this.toSnakeCase(this.modelName)),r={},null==n&&(n=e+"_id"),r[n]="integer",t.attributes(r),o={},o[n]=this,t.foreignKeys(o),this.instanceClass.prototype[e]=function(i){var r,o,s,a,l;if(1===arguments.length){for(l=t.findByAttribute(n,this.id),s=0,a=l.length;a>s;s++)r=l[s],r!==i&&(r.set(n,null),r.save());if(null===i)return;return i.set(n,this.id),i.save(),this.trigger("change:"+e),this.trigger("change")}return o=t.findByAttribute(n,this.id),o.length>0?o[0]:null},i=this,s=function(e){var i,r,o,s,a;for(s=t.findByAttribute(n,e.id),a=[],r=0,o=s.length;o>r;r++)i=s[r],i.set(n,null),a.push(i.save());return a},this.bind("destroy",s)},n.prototype.belongsToPoly=function(t,e,i,r){var o,s,a,l,h,u,c,p,f;for(null==e&&(e=this.toSnakeCase(l.modelName)),s={},null==i&&(i=e+"_id"),s[i]="integer",null==r&&(r=e+"_type"),s[r]="string",this[e+"_allowed_models"]=t,this.attributes(s),a={},a[i]=r,this.polyForeignKeys(a),h={},h[e]=function(e,o){var s,a;return arguments.length>0?(null!=e?(_.contains(t,e.modelClass)||d.error("Cannot assign a model of type {{value.modelClass.modelName}} to this belongsToPoly - allowed model types are "+t.join(", ")),this.set(i,e.id),this.set(r,e.modelClass.modelName)):(this[i]=null,this[r]=null),this.save(o)):(s=this[i],a=n.models[this[r]],null==s||null==a?null:a.findById(s))},this.instanceClass.extend(h),o=this,u=function(t,e){var n,s,a,l,h,u;for(null==e&&(e={}),s={},s[i]=t.id,s[r]=t.modelClass.modelName,h=o.findByAttributes(s),u=[],a=0,l=h.length;l>a;a++)n=h[a],n.set(i,null),n.set(r,null),u.push(n.save(e));return u},f=[],c=0,p=t.length;p>c;c++)l=t[c],f.push(l.bind("destroy",u));return f},n.prototype.hasMany=function(t,e,n){var i,r,o,s,a;return null==e&&(e=this.toSnakeCase(t.modelName)),r={},null==n&&(n=this.toSnakeCase(this.modelName+"_id")),r[n]="integer",t.attributes(r),o={},o[n]=this,t.foreignKeys(o),this.relations[e]={type:"hasMany",otherModel:t,foreignKeyAttribute:n},i=this,s={},s[e]=function(){if(arguments.length>0)throw Error("Cannot set a hasMany relation");return null==this[e+"_hasMany_collection"]&&(this[e+"_hasMany_collection"]=u.create({record:this,attribute:this.attribute,model:i,otherModel:t,fkname:n})),this[e+"_hasMany_collection"]},this.instanceClass.extend(s),a=function(e,i){var r,o,s,a,l;for(null==i&&(i={}),a=t.findByAttribute(n,e.id),l=[],o=0,s=a.length;s>o;o++)r=a[o],r.set(n,null),l.push(r.save(i));return l},this.bind("destroy",a)},n.prototype.hasManyPoly=function(t,e,n,i){var r,o,s,a;return null==e&&(e=this.toSnakeCase(t.modelName)),null==n&&(n=e+"_id"),null==i&&(i=e+"_type"),o={},o[n]="integer",o[i]="string",t.attributes(o),s={},s[n]=i,t.polyForeignKeys(s),this.relations[e]={type:"hasManyPoly",otherModel:t,foreignKeyAttribute:n,foreignModelTypeAttribute:i},r=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throw Error("Cannot set a hasManyPoly relation");return null==this[e+"_hasManyPoly_collection"]&&(this[e+"_hasManyPoly_collection"]=c.create({record:this,model:r,otherModel:t,thatFkAttr:n,thatTypeAttr:i})),this[e+"_hasManyPoly_collection"]},a=function(e,o){var s,a,l,h,u,c;for(null==o&&(o={}),a={},a[n]=e.id,a[i]=r.modelName,u=t.findByAttributes(a),c=[],l=0,h=u.length;h>l;l++)s=u[l],s.set(n,null),s.set(i,null),c.push(s.save(o));return c},this.bind("destroy",a)},n.prototype.hasManyThrough=function(t,e,n,i,r){var s,a,l,h,u;return null==e&&(e=this.toSnakeCase(t.modelName)),a={},null==i&&(i=this.toSnakeCase(this.modelName+"_id")),null==r&&(r=this.toSnakeCase(t.modelName)+"_id"),a[i]="integer",a[r]="integer",n.attributes(a),l={},l[i]=this,l[r]=t,n.foreignKeys(l),this.relations[e]={type:"hasManyThrough",otherModel:t,linkModel:n,foreignKeyAttribute:i,otherModelForeignKeyAttribute:r},s=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throw Error("Cannot set a hasManyThrough relation");return null==this[e+"_hasManyThrough_collection"]&&(this[e+"_hasManyThrough_collection"]=o.create({record:this,model:s,otherModel:t,linkModel:n,thisFkAttr:i,thatFkAttr:r})),this[e+"_hasManyThrough_collection"]},u=function(t,e){var r,o,s,a,l;for(null==e&&(e={}),a=n.findByAttribute(i,t.id),l=[],o=0,s=a.length;s>o;o++)r=a[o],l.push(r.destroy(e));return l},this.bind("destroy",u),h=function(t,e){var i,o,s,a,l;for(null==e&&(e={}),a=n.findByAttribute(r,t.id),l=[],o=0,s=a.length;s>o;o++)i=a[o],l.push(i.destroy(e));return l},t.bind("destroy",h)},n.prototype.hasManyThroughPoly=function(t,e,n,i,r,o){var a,l,h,u,c;return null==e&&(e=this.toSnakeCase(t.modelName)),null==i&&(i=this.toSnakeCase(this.modelName+"_id")),null==r&&(r=e+"_id"),null==o&&(o=e+"_type"),l={},l[i]="integer",l[r]="integer",l[o]="string",n.attributes(l),h={},h[i]=this,n.foreignKeys(h),h={},h[r]=o,n.polyForeignKeys(h),this.relations[e]={type:"hasManyThroughPoly",otherModel:t,linkModel:n,foreignKeyAttribute:i,otherModelForeignKeyAttribute:r,otherModelModelTypeAttribute:o},a=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throw Error("Cannot set a hasManyThroughPoly relation");return null==this[e+"_hasManyThroughPoly_collection"]&&(this[e+"_hasManyThroughPoly_collection"]=s.create({record:this,model:a,otherModel:t,linkModel:n,thisFkAttr:i,thatFkAttr:r,thatTypeAttr:o})),this[e+"_hasManyThroughPoly_collection"]},c=function(t,e){var r,o,s,a,l,h;for(null==e&&(e={}),o={},o[i]=t.id,l=n.findByAttributes(o),h=[],s=0,a=l.length;a>s;s++)r=l[s],h.push(r.destroy(e));return h},this.bind("destroy",c),u=function(t,e){var i,s,a,l,h,u;for(null==e&&(e={}),s={},s[r]=t.id,s[o]=t.modelClass.modelName,h=n.findByAttributes(s),u=[],a=0,l=h.length;l>a;a++)i=h[a],u.push(i.destroy(e));return u},t.bind("destroy",u)},n.prototype.hasManyThroughPolyReverse=function(t,e,n,i,r,o){var s;return null==e&&(e=this.toSnakeCase(t.modelName)),null==i&&(i=this.toSnakeCase(this.modelName+"_id")),null==r&&(r=e+"_id"),null==o&&(o=e+"_type"),this.relations[e]={type:"hasManyThroughPolyReverse",otherModel:t,linkModel:n,foreignKeyAttribute:i,otherModelForeignKeyAttribute:r,otherModelModelTypeAttribute:o},(null==n.fks[i]||null==n.polyFks[r]||n.polyFks[r]===(null!=o))&&console.error("WARNING: hasManyThroughPolyReverse - "+i+", "+r+" or "+o+" do not exist on link model '"+n.modelName+"' - there should be an existing hasManyThroughPoly to support this hasManyThroughPolyReverse"),s=this,this.instanceClass.prototype[e]=function(){if(arguments.length>0)throw Error("Cannot set a hasManyThroughPolyReverse relation");return null==this[e+"_hasManyThroughPolyReverse_collection"]&&(this[e+"_hasManyThroughPolyReverse_collection"]=a.create({record:this,model:s,otherModel:t,linkModel:n,thisFkAttr:i,thatFkAttr:r,thatTypeAttr:o})),this[e+"_hasManyThroughPolyReverse_collection"]}},n.prototype.all=function(){return _(this.records).values()},n.prototype.allAsMap=function(){return this.records},n.prototype.count=function(){return _(this.records).keys().length},n.prototype.findById=function(t){return null==t?void 0:this.records[t]},n.prototype.findAll=function(t){var e,n,i,r;for(n=[],i=0,r=t.length;r>i;i++)e=t[i],null!=this.exists(e)&&n.push(this.records[e]);return n},n.prototype.select=function(t){return this.findAll(this.selectIds(t))},n.prototype.selectIds=function(t){var e,n,i,r;i=[],r=this.records;for(e in r)n=r[e],t(n)&&i.push(e);return i},n.prototype.selectAsMap=function(t){var e,n,i,r;i={},r=this.records;for(e in r)n=r[e],t(n)&&(i[e]=n);return i},n.prototype.findByAttribute=function(t,e){var n;return n={},n[t]=e,this.findByAttributes(n)},n.prototype.findByAttributes=function(t){var e,n,i,r,o,s,a,l;s=[];for(e in t)l=t[e],this.hasIndex(e)?s.push(this.getIndexFor(e,l)):s.push(this.selectAsMap(function(t){return t[e]===l}));for(r=s.pop()||{};s.length>0;){a=s.pop(),o={};for(n in a)i=a[n],null!=r[n]&&(o[n]=i);r=o}return _(r).values()},n.prototype.exists=function(t){return null!=this.records[t]},n.prototype.initInstance=function(t){var e,n,i,r;e=this._getInstance(),r=this.attrs;for(n in r)i=r[n],null!=t&&null!=t[n]?e.set(n,t[n]):e.set(n,null);return e.set("id",this._generateId()),e},n.prototype.createFromValues=function(t){var e;return e=this.initInstance(t),e.save(),e},n.prototype.loadInstance=function(t,e){return null==e&&(e={}),this.trigger("load",t)},n.prototype.createInstance=function(t,e){var n;return null==e&&(e={}),n=t.id,this.exists(n)&&d.error("createInstance: ID Already Exists","collection","model",this.name,"id",n),this.records[n]=t,this.addToIndexes(t),e.disableModelCreateEvent||this.trigger("create",t,e),e.disableModelChangeEvent||this.trigger("change",t,e),t},n.prototype.updateInstance=function(t,e){var n;return null==e&&(e={}),e.disableModelUpdateEvent||this.trigger("update",t,e),e.disableModelChangeEvent||this.trigger("change",t,e),n=t.id,this.exists(n)?void 0:d.error("updateInstance: ID does not exist","collection","model",this.name,"id",n)},n.prototype.destroyInstance=function(t,e){var n;return null==e&&(e={}),n=t.id,this.exists(n)||d.error("destroyInstance: ID does not exist","collection","model",this.name,"id",n),delete this.records[t.id],t.modelClass.removeFromIndexes(t),e.disableModelDestroyEvent||this.trigger("destroy",t,e),e.disableModelChangeEvent?void 0:this.trigger("change",t,e)},n.prototype.toSnakeCase=function(t){var e;return e=t.replace(/[A-Z]{1,1}/g,function(t){return"_"+t.toLowerCase()}),e.replace(/^_/,"")},n.prototype._getInstance=function(){return this.instanceClass.create({modelClass:this})},n.prototype._generateId=function(){return"c-"+n.idCount++},n.prototype.index=function(t,n,i){var r;if(null==n&&(n="map"),null==this.indexes[t]){if(r=e.getIndexClassType(n),null!=r)return this.indexes[t]=r.create({modelClass:this,attribute:t,options:i});throw Error("Model: Index Type "+n+" is not supported")}return this.rebuildIndex(t)},n.prototype.hasIndex=function(t){return null!=this.indexes[t]},n.prototype.getIndexFor=function(t,e){if(null==this.indexes[t])throw Error("Model.rebuildIndex: Index "+t+" does not exist");return this.indexes[t].load(e)},n.prototype.updateIndex=function(t,e,n,i){if(null==this.indexes[t])throw Error("Model.rebuildIndex: Index "+t+" does not exist");return this.indexes[t].update(e,n,i)},n.prototype.addToIndexes=function(t){var e,n,i,r;i=this.indexes,r=[];for(e in i)n=i[e],r.push(n.add(t));return r},n.prototype.removeFromIndexes=function(t){var e,n,i,r;i=this.indexes,r=[];for(e in i)n=i[e],r.push(n.remove(t));return r},n.prototype.rebuildIndex=function(t){if(null==this.indexes[t])throw Error("Model.rebuildIndex: Index "+t+" does not exist");return this.indexes[t].rebuild()},n.prototype.dropIndex=function(t){return delete this.indexes[t]},n.prototype.rebuildAllIndexes=function(){var t,e,n,i,r;for(i=_(this.indexes).keys(),r=[],e=0,n=i.length;n>e;e++)t=i[e],r.push(this.rebuildIndex(t));return r},n}(h)}).call(this)}),t.define("/model-localstorage.coffee",function(t){(function(){var e,n,i,r;e=t("./model").Model,n=t("./util"),r={},i={},e.extend({localStorage:function(t){var e,n,o,s,a,l,h,u,c;return null==window.localStorage&&Mozart.error(this.modelName+".localStorage - localStorage not available in this browser"),null==t&&(t={}),null==(l=t.prefix)&&(t.prefix="MozartLS"),this.localStorageOptions=t,this.bind("load",this.loadLocalStorage),this.bind("create",this.createLocalStorage),this.bind("update",this.updateLocalStorage),this.bind("destroy",this.destroyLocalStorage),null==(h=r[s=this.modelName])&&(r[s]={}),null==(u=i[a=this.modelName])&&(i[a]={}),null==(c=Mozart.LocalStorage)&&(Mozart.LocalStorage=Mozart.MztObject.create({handleError:function(t,e,n){return Mozart.LocalStorage.trigger("notFound",t,e,n)}})),o=this.getLocalStoragePrefix(),this.instanceClass.extend({getLocalStorageId:function(){return this.modelClass.getLocalStorageId(this.id)},existsInLocalStorage:function(){var t;return t=this.modelClass.getLocalStorageId(this.id),null!=window.localStorage[this+("-"+t)]},loadLocalStorage:function(){return this.modelClass.loadLocalStorage(this)}}),n=window.localStorage[o+"-nextPK"],null==n&&(window.localStorage[o+"-nextPK"]="1"),e=window.localStorage[o+"-index"],null==e?window.localStorage[o+"-index"]="[]":void 0},getLocalStoragePrefix:function(){return this.localStorageOptions.prefix+"-"+this.modelName},registerLocalStorageId:function(t,e){if(null==r[this.modelName])throw Error("Model.registerLocalStorageId: "+this.modelName+" is not registered for localStorage.");return r[this.modelName][e]=t,i[this.modelName][t]=e},unRegisterLocalStorageId:function(t,e){return delete r[this.modelName][e],delete i[this.modelName][t]},getLocalStorageId:function(t){return i[this.modelName][t]},getLocalStorageClientId:function(t){return r[this.modelName][t]},toLocalStorageObject:function(t){var n,i,r,o,s,a,l,h;r={},a=this.attrs;for(n in a)o=a[n],"id"!==n&&(r[n]=t[n]);r.id=this.getLocalStorageId(t.id),l=this.fks;for(n in l)i=l[n],r[n]=i.getLocalStorageId(t[n]);h=this.polyFks;for(n in h)s=h[n],r[n]=null!=t[s]?e.models[t[s]].getLocalStorageId(t[n]):null;return r},toLocalStorageClientObject:function(t){var n,i,r,o,s,a,l,h;r={},a=this.attrs;for(n in a)o=a[n],"id"!==n&&(r[n]=t[n]);r.id=this.getLocalStorageClientId(t.id),l=this.fks;for(n in l)i=l[n],r[n]=i.getLocalStorageClientId(t[n]),r[n]===void 0&&(r[n]=null);h=this.polyFks;for(n in h)s=h[n],r[n]=null!=t[s]?e.models[t[s]].getLocalStorageClientId(t[n]):null;return r},loadAllLocalStorage:function(){var t,e,i,r,o,s;for(r=this.getLocalStoragePrefix(),e=JSON.parse(window.localStorage[r+"-index"]),o=0,s=e.length;s>o;o++)i=e[o],t=JSON.parse(window.localStorage[r+("-"+i)]),this._processLocalStorageLoad(i,t,this);return this.trigger("loadAllLocalStorageComplete"),n.log("localStorage","Model.loadAllLocalStorage.onComplete")},loadLocalStorage:function(t){var e;return e=t.modelClass.getLocalStorageId(t.id),this.loadLocalStorageId(e)},loadLocalStorageId:function(t){var e,n;return n=this.getLocalStoragePrefix(),e=window.localStorage[n+("-"+t)],null==e&&Mozart.LocalStorage.handleError(this,t,"record does not exist"),e=JSON.parse(e),e.id=t,this._processLocalStorageLoad(t,e,this)},_processLocalStorageLoad:function(t,e,i){var r,o,s;return r=i.getLocalStorageClientId(t),o=i.toLocalStorageClientObject(e),null!=r?(s=i.findById(r),s.copyFrom(o)):s=i.initInstance(e),s.save({disableModelCreateEvent:!0,disableModelUpdateEvent:!0}),i.registerLocalStorageId(s.id,t),n.log("localStorage","Model._processLocalStorageLoad.onSuccess",e,i),i.trigger("loadLocalStorageComplete",s)},createLocalStorage:function(t){var e,i,r,o;return e=t.modelClass.toLocalStorageObject(t),o=t.modelClass.getLocalStoragePrefix(),r=parseInt(window.localStorage[o+"-nextPK"]),window.localStorage[o+"-nextPK"]=""+(r+1),window.localStorage[o+("-"+r)]=JSON.stringify(e),t.modelClass.registerLocalStorageId(t.id,r),i=JSON.parse(window.localStorage[o+"-index"]),i.push(r),window.localStorage[o+"-index"]=JSON.stringify(i),n.log("localStorage","Model.createLocalStorageComplete",t),t.modelClass.trigger("createLocalStorageComplete",t)},updateLocalStorage:function(t){var e,i,r;return i=t.modelClass.getLocalStorageId(t.id),null!=i?(e=t.modelClass.toLocalStorageObject(t),r=t.modelClass.getLocalStoragePrefix(),null==window.localStorage[r+("-"+i)]&&Mozart.LocalStorage.handleError(t.modelClass,i,"updateLocalStorage: record does not exist"),window.localStorage[r+("-"+i)]=JSON.stringify(e),t.modelClass.trigger("updateLocalStorageComplete",t),n.log("localStorage","Model.updateLocalStorage.onComplete",t)):void 0},destroyLocalStorage:function(t){var e,i,r;return i=t.modelClass.getLocalStorageId(t.id),null!=i?(r=t.modelClass.getLocalStoragePrefix(),null==window.localStorage[r+("-"+i)]&&Mozart.LocalStorage.handleError(t.modelClass,i,"destroyLocalStorage: record does not exist"),window.localStorage.removeItem(r+("-"+i)),t.modelClass.unRegisterLocalStorageId(t.id,i),e=JSON.parse(window.localStorage[r+"-index"]),e=_.without(e,i),window.localStorage[r+"-index"]=JSON.stringify(e),n.log("localStorage","Model.destroyLocalStorage.onSuccess",t),t.modelClass.trigger("destroyLocalStorageComplete",i)):void 0},destroyAllLocalStorage:function(){var t,e,n,o,s;for(n=this.getLocalStoragePrefix(),e=JSON.parse(window.localStorage[n+"-index"]),o=0,s=e.length;s>o;o++)t=e[o],window.localStorage.removeItem(n+("-"+t));return window.localStorage[n+"-index"]="[]",window.localStorage[n+"-nextPK"]="1",r[this.modelName]={},i[this.modelName]={}}})}).call(this)}),t.define("/route.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};r=t("./util"),e=t("./object").MztObject,n.Route=i=function(t){function e(){return this.doTitle=o(this.doTitle,this),this.canEnter=o(this.canEnter,this),this.canExit=o(this.canExit,this),e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.init=function(){return null!=this.path&&this.path.length>0||r.warn("Route must have a path",this),null==this.viewClass?r.warn("Route must have a viewClass",this):void 0},e.prototype.canExit=function(){return!(null!=this.exit)||this.exit()===!0},e.prototype.canEnter=function(t){return!(null!=this.enter)||this.enter(t)===!0},e.prototype.doTitle=function(){return null!=this.title?document.title="function"==typeof this.title?this.title(this):this.title:void 0},e}(e)}).call(this)}),t.define("/switch-view.coffee",function(t,e,n){(function(){var e,i,r=function(t,e){return function(){return t.apply(e,arguments)}},o={}.hasOwnProperty,s=function(t,e){function n(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};i=t("./view").View,n.SwitchView=e=function(t){function e(){return this.beforeRender=r(this.beforeRender,this),e.__super__.constructor.apply(this,arguments)}return s(e,t),e.prototype.beforeRender=function(){var t;return t=HandlebarsTemplates[this.templateBase+"/"+this.content[this.templateField]],null!=t?this.templateFunction=t:(Util.log("views","SwitchView: No view found for "+this.templateBase+"/"+this.content[this.templateField]),this.templateFunction=function(){return""})},e}(i)}).call(this)}),t.define("/dynamic-view.coffee",function(t,e,n){(function(){var e,i,r,o=function(t,e){return function(){return t.apply(e,arguments)}},s={}.hasOwnProperty,a=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};r=t("./view").View,i=t("./util"),n.DynamicView=e=function(t){function e(){return this.createText=o(this.createText,this),this.createView=o(this.createView,this),this.afterRender=o(this.afterRender,this),this.init=o(this.init,this),e.__super__.constructor.apply(this,arguments)}return a(e,t),e.prototype.skipTemplate=!0,e.prototype.init=function(){return e.__super__.init.apply(this,arguments),i.log("dynamicview","init"),null!=this.schema?this.bind("change:schema",this.afterRender):void 0},e.prototype.afterRender=function(){var t,e,n,r,o;if(this.releaseChildren(),this.element.empty(),!i.isArray(this.schema))return i.warn("DynamicView "+id+": schema is not an array"),void 0;for(r=this.schema,o=[],e=0,n=r.length;n>e;e++)t=r[e],null!=t.viewClass?o.push(this.createView(t)):o.push(this.createText(t));return o},e.prototype.createView=function(t){var e,n;return n=i._getPath(t.viewClass),delete t.viewClass,t.parent=this,e=this.layout.createView(n,t),this.element.append(e.createElement()),this.addView(e),this.layout.queueRenderView(e)},e.prototype.createText=function(t){return this.element.append(t)},e}(r)}).call(this)}),t.define("/cookies.coffee",function(t,e,n){(function(){var e,i,r={}.hasOwnProperty,o=function(t,e){function n(){this.constructor=t}for(var i in e)r.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t};i=t("./object").MztObject,n.Cookies=e=function(t){function e(){return e.__super__.constructor.apply(this,arguments)}return o(e,t),e.setCookie=function(t,e,n){var i,r,o,s,a,l;return n=n||{},void 0!==document.cookie&&(n.path||(n.path="/"),s=""+encodeURIComponent(t)+"="+encodeURIComponent(e),a=n.path?";path="+n.path:"",i=n.domain?";domain="+n.domain:"",o=n["max-age"]?";max-age="+n["max-age"]:"",r="",n.expires instanceof Date&&(r=";expires="+n.expires.toUTCString()),l=n.secure?";secure":"",document.cookie=s+a+i+o+r+l),this},e.getCookie=function(t){var e,n,i,r,o,s;for(n=document.cookie.split(/;\s*/),o=0,s=n.length;s>o;o++)if(e=n[o],r=e.split("="),i=decodeURIComponent(r[0]),i===t)return decodeURIComponent(r[1]);return null},e.removeCookie=function(t){var e;return e=new Date,e.setTime(e.getTime()-1),this.setCookie(t,"",{expires:e}),this},e.hasCookie=function(t){return null!==this.getCookie(t)},e}(i)}).call(this)}),t.define("/mozart.coffee",function(t,e,n,i,r,o,s){(function(){var e,n,i,r,o,a,l,h,u={}.hasOwnProperty;for(e={version:"0.1.9",versionDate:new Date(2013,7,1),Plugins:{}},l=[t("./collection"),t("./control"),t("./controller"),t("./data-index"),t("./dom-manager"),t("./events"),t("./handlebars"),t("./http"),t("./layout"),t("./model-instance"),t("./model-instancecollection"),t("./model-onetomanycollection"),t("./model-onetomanypolycollection"),t("./model-manytomanycollection"),t("./model-manytomanypolycollection"),t("./model-manytomanypolyreversecollection"),t("./model-ajax"),t("./model-localstorage"),t("./model"),t("./object"),t("./route"),t("./router"),t("./switch-view"),t("./util"),t("./view"),t("./dynamic-view"),t("./cookies")],o=0,a=l.length;a>o;o++){i=l[o];
5
+ for(r in i)u.call(i,r)&&(n=i[r],e[r]=n)}null!=s.module?i.exports=e:null!=(null!=(h=s.define)?h.amd:void 0)?define("mozart",e):s.Mozart=e}).call(this)}),t("/mozart.coffee")})();
@@ -0,0 +1,5 @@
1
+ // Underscore.js 1.4.2
2
+ // http://underscorejs.org
3
+ // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
4
+ // Underscore may be freely distributed under the MIT license.
5
+ (function(){var e=this,t=e._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,o=r.push,u=r.slice,a=r.concat,f=r.unshift,l=i.toString,c=i.hasOwnProperty,h=r.forEach,p=r.map,d=r.reduce,v=r.reduceRight,m=r.filter,g=r.every,y=r.some,b=r.indexOf,w=r.lastIndexOf,E=Array.isArray,S=Object.keys,x=s.bind,T=function(e){if(e instanceof T)return e;if(!(this instanceof T))return new T(e);this._wrapped=e};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=T),exports._=T):e._=T,T.VERSION="1.4.2";var N=T.each=T.forEach=function(e,t,r){if(e==null)return;if(h&&e.forEach===h)e.forEach(t,r);else if(e.length===+e.length){for(var i=0,s=e.length;i<s;i++)if(t.call(r,e[i],i,e)===n)return}else for(var o in e)if(T.has(e,o)&&t.call(r,e[o],o,e)===n)return};T.map=T.collect=function(e,t,n){var r=[];return e==null?r:p&&e.map===p?e.map(t,n):(N(e,function(e,i,s){r[r.length]=t.call(n,e,i,s)}),r)},T.reduce=T.foldl=T.inject=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(d&&e.reduce===d)return r&&(t=T.bind(t,r)),i?e.reduce(t,n):e.reduce(t);N(e,function(e,s,o){i?n=t.call(r,n,e,s,o):(n=e,i=!0)});if(!i)throw new TypeError("Reduce of empty array with no initial value");return n},T.reduceRight=T.foldr=function(e,t,n,r){var i=arguments.length>2;e==null&&(e=[]);if(v&&e.reduceRight===v)return r&&(t=T.bind(t,r)),arguments.length>2?e.reduceRight(t,n):e.reduceRight(t);var s=e.length;if(s!==+s){var o=T.keys(e);s=o.length}N(e,function(u,a,f){a=o?o[--s]:--s,i?n=t.call(r,n,e[a],a,f):(n=e[a],i=!0)});if(!i)throw new TypeError("Reduce of empty array with no initial value");return n},T.find=T.detect=function(e,t,n){var r;return C(e,function(e,i,s){if(t.call(n,e,i,s))return r=e,!0}),r},T.filter=T.select=function(e,t,n){var r=[];return e==null?r:m&&e.filter===m?e.filter(t,n):(N(e,function(e,i,s){t.call(n,e,i,s)&&(r[r.length]=e)}),r)},T.reject=function(e,t,n){var r=[];return e==null?r:(N(e,function(e,i,s){t.call(n,e,i,s)||(r[r.length]=e)}),r)},T.every=T.all=function(e,t,r){t||(t=T.identity);var i=!0;return e==null?i:g&&e.every===g?e.every(t,r):(N(e,function(e,s,o){if(!(i=i&&t.call(r,e,s,o)))return n}),!!i)};var C=T.some=T.any=function(e,t,r){t||(t=T.identity);var i=!1;return e==null?i:y&&e.some===y?e.some(t,r):(N(e,function(e,s,o){if(i||(i=t.call(r,e,s,o)))return n}),!!i)};T.contains=T.include=function(e,t){var n=!1;return e==null?n:b&&e.indexOf===b?e.indexOf(t)!=-1:(n=C(e,function(e){return e===t}),n)},T.invoke=function(e,t){var n=u.call(arguments,2);return T.map(e,function(e){return(T.isFunction(t)?t:e[t]).apply(e,n)})},T.pluck=function(e,t){return T.map(e,function(e){return e[t]})},T.where=function(e,t){return T.isEmpty(t)?[]:T.filter(e,function(e){for(var n in t)if(t[n]!==e[n])return!1;return!0})},T.max=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);if(!t&&T.isEmpty(e))return-Infinity;var r={computed:-Infinity};return N(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o>=r.computed&&(r={value:e,computed:o})}),r.value},T.min=function(e,t,n){if(!t&&T.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);if(!t&&T.isEmpty(e))return Infinity;var r={computed:Infinity};return N(e,function(e,i,s){var o=t?t.call(n,e,i,s):e;o<r.computed&&(r={value:e,computed:o})}),r.value},T.shuffle=function(e){var t,n=0,r=[];return N(e,function(e){t=T.random(n++),r[n-1]=r[t],r[t]=e}),r};var k=function(e){return T.isFunction(e)?e:function(t){return t[e]}};T.sortBy=function(e,t,n){var r=k(t);return T.pluck(T.map(e,function(e,t,i){return{value:e,index:t,criteria:r.call(n,e,t,i)}}).sort(function(e,t){var n=e.criteria,r=t.criteria;if(n!==r){if(n>r||n===void 0)return 1;if(n<r||r===void 0)return-1}return e.index<t.index?-1:1}),"value")};var L=function(e,t,n,r){var i={},s=k(t);return N(e,function(t,o){var u=s.call(n,t,o,e);r(i,u,t)}),i};T.groupBy=function(e,t,n){return L(e,t,n,function(e,t,n){(T.has(e,t)?e[t]:e[t]=[]).push(n)})},T.countBy=function(e,t,n){return L(e,t,n,function(e,t,n){T.has(e,t)||(e[t]=0),e[t]++})},T.sortedIndex=function(e,t,n,r){n=n==null?T.identity:k(n);var i=n.call(r,t),s=0,o=e.length;while(s<o){var u=s+o>>>1;n.call(r,e[u])<i?s=u+1:o=u}return s},T.toArray=function(e){return e?e.length===+e.length?u.call(e):T.values(e):[]},T.size=function(e){return e.length===+e.length?e.length:T.keys(e).length},T.first=T.head=T.take=function(e,t,n){return t!=null&&!n?u.call(e,0,t):e[0]},T.initial=function(e,t,n){return u.call(e,0,e.length-(t==null||n?1:t))},T.last=function(e,t,n){return t!=null&&!n?u.call(e,Math.max(e.length-t,0)):e[e.length-1]},T.rest=T.tail=T.drop=function(e,t,n){return u.call(e,t==null||n?1:t)},T.compact=function(e){return T.filter(e,function(e){return!!e})};var A=function(e,t,n){return N(e,function(e){T.isArray(e)?t?o.apply(n,e):A(e,t,n):n.push(e)}),n};T.flatten=function(e,t){return A(e,t,[])},T.without=function(e){return T.difference(e,u.call(arguments,1))},T.uniq=T.unique=function(e,t,n,r){var i=n?T.map(e,n,r):e,s=[],o=[];return N(i,function(n,r){if(t?!r||o[o.length-1]!==n:!T.contains(o,n))o.push(n),s.push(e[r])}),s},T.union=function(){return T.uniq(a.apply(r,arguments))},T.intersection=function(e){var t=u.call(arguments,1);return T.filter(T.uniq(e),function(e){return T.every(t,function(t){return T.indexOf(t,e)>=0})})},T.difference=function(e){var t=a.apply(r,u.call(arguments,1));return T.filter(e,function(e){return!T.contains(t,e)})},T.zip=function(){var e=u.call(arguments),t=T.max(T.pluck(e,"length")),n=new Array(t);for(var r=0;r<t;r++)n[r]=T.pluck(e,""+r);return n},T.object=function(e,t){var n={};for(var r=0,i=e.length;r<i;r++)t?n[e[r]]=t[r]:n[e[r][0]]=e[r][1];return n},T.indexOf=function(e,t,n){if(e==null)return-1;var r=0,i=e.length;if(n){if(typeof n!="number")return r=T.sortedIndex(e,t),e[r]===t?r:-1;r=n<0?Math.max(0,i+n):n}if(b&&e.indexOf===b)return e.indexOf(t,n);for(;r<i;r++)if(e[r]===t)return r;return-1},T.lastIndexOf=function(e,t,n){if(e==null)return-1;var r=n!=null;if(w&&e.lastIndexOf===w)return r?e.lastIndexOf(t,n):e.lastIndexOf(t);var i=r?n:e.length;while(i--)if(e[i]===t)return i;return-1},T.range=function(e,t,n){arguments.length<=1&&(t=e||0,e=0),n=arguments[2]||1;var r=Math.max(Math.ceil((t-e)/n),0),i=0,s=new Array(r);while(i<r)s[i++]=e,e+=n;return s};var O=function(){};T.bind=function(t,n){var r,i;if(t.bind===x&&x)return x.apply(t,u.call(arguments,1));if(!T.isFunction(t))throw new TypeError;return i=u.call(arguments,2),r=function(){if(this instanceof r){O.prototype=t.prototype;var e=new O,s=t.apply(e,i.concat(u.call(arguments)));return Object(s)===s?s:e}return t.apply(n,i.concat(u.call(arguments)))}},T.bindAll=function(e){var t=u.call(arguments,1);return t.length==0&&(t=T.functions(e)),N(t,function(t){e[t]=T.bind(e[t],e)}),e},T.memoize=function(e,t){var n={};return t||(t=T.identity),function(){var r=t.apply(this,arguments);return T.has(n,r)?n[r]:n[r]=e.apply(this,arguments)}},T.delay=function(e,t){var n=u.call(arguments,2);return setTimeout(function(){return e.apply(null,n)},t)},T.defer=function(e){return T.delay.apply(T,[e,1].concat(u.call(arguments,1)))},T.throttle=function(e,t){var n,r,i,s,o,u,a=T.debounce(function(){o=s=!1},t);return function(){n=this,r=arguments;var f=function(){i=null,o&&(u=e.apply(n,r)),a()};return i||(i=setTimeout(f,t)),s?o=!0:(s=!0,u=e.apply(n,r)),a(),u}},T.debounce=function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},T.once=function(e){var t=!1,n;return function(){return t?n:(t=!0,n=e.apply(this,arguments),e=null,n)}},T.wrap=function(e,t){return function(){var n=[e];return o.apply(n,arguments),t.apply(this,n)}},T.compose=function(){var e=arguments;return function(){var t=arguments;for(var n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},T.after=function(e,t){return e<=0?t():function(){if(--e<1)return t.apply(this,arguments)}},T.keys=S||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var n in e)T.has(e,n)&&(t[t.length]=n);return t},T.values=function(e){var t=[];for(var n in e)T.has(e,n)&&t.push(e[n]);return t},T.pairs=function(e){var t=[];for(var n in e)T.has(e,n)&&t.push([n,e[n]]);return t},T.invert=function(e){var t={};for(var n in e)T.has(e,n)&&(t[e[n]]=n);return t},T.functions=T.methods=function(e){var t=[];for(var n in e)T.isFunction(e[n])&&t.push(n);return t.sort()},T.extend=function(e){return N(u.call(arguments,1),function(t){for(var n in t)e[n]=t[n]}),e},T.pick=function(e){var t={},n=a.apply(r,u.call(arguments,1));return N(n,function(n){n in e&&(t[n]=e[n])}),t},T.omit=function(e){var t={},n=a.apply(r,u.call(arguments,1));for(var i in e)T.contains(n,i)||(t[i]=e[i]);return t},T.defaults=function(e){return N(u.call(arguments,1),function(t){for(var n in t)e[n]==null&&(e[n]=t[n])}),e},T.clone=function(e){return T.isObject(e)?T.isArray(e)?e.slice():T.extend({},e):e},T.tap=function(e,t){return t(e),e};var M=function(e,t,n,r){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return e===t;e instanceof T&&(e=e._wrapped),t instanceof T&&(t=t._wrapped);var i=l.call(e);if(i!=l.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:e==0?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if(typeof e!="object"||typeof t!="object")return!1;var s=n.length;while(s--)if(n[s]==e)return r[s]==t;n.push(e),r.push(t);var o=0,u=!0;if(i=="[object Array]"){o=e.length,u=o==t.length;if(u)while(o--)if(!(u=M(e[o],t[o],n,r)))break}else{var a=e.constructor,f=t.constructor;if(a!==f&&!(T.isFunction(a)&&a instanceof a&&T.isFunction(f)&&f instanceof f))return!1;for(var c in e)if(T.has(e,c)){o++;if(!(u=T.has(t,c)&&M(e[c],t[c],n,r)))break}if(u){for(c in t)if(T.has(t,c)&&!(o--))break;u=!o}}return n.pop(),r.pop(),u};T.isEqual=function(e,t){return M(e,t,[],[])},T.isEmpty=function(e){if(e==null)return!0;if(T.isArray(e)||T.isString(e))return e.length===0;for(var t in e)if(T.has(e,t))return!1;return!0},T.isElement=function(e){return!!e&&e.nodeType===1},T.isArray=E||function(e){return l.call(e)=="[object Array]"},T.isObject=function(e){return e===Object(e)},N(["Arguments","Function","String","Number","Date","RegExp"],function(e){T["is"+e]=function(t){return l.call(t)=="[object "+e+"]"}}),T.isArguments(arguments)||(T.isArguments=function(e){return!!e&&!!T.has(e,"callee")}),typeof /./!="function"&&(T.isFunction=function(e){return typeof e=="function"}),T.isFinite=function(e){return T.isNumber(e)&&isFinite(e)},T.isNaN=function(e){return T.isNumber(e)&&e!=+e},T.isBoolean=function(e){return e===!0||e===!1||l.call(e)=="[object Boolean]"},T.isNull=function(e){return e===null},T.isUndefined=function(e){return e===void 0},T.has=function(e,t){return c.call(e,t)},T.noConflict=function(){return e._=t,this},T.identity=function(e){return e},T.times=function(e,t,n){for(var r=0;r<e;r++)t.call(n,r)},T.random=function(e,t){return t==null&&(t=e,e=0),e+(0|Math.random()*(t-e+1))};var _={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}};_.unescape=T.invert(_.escape);var D={escape:new RegExp("["+T.keys(_.escape).join("")+"]","g"),unescape:new RegExp("("+T.keys(_.unescape).join("|")+")","g")};T.each(["escape","unescape"],function(e){T[e]=function(t){return t==null?"":(""+t).replace(D[e],function(t){return _[e][t]})}}),T.result=function(e,t){if(e==null)return null;var n=e[t];return T.isFunction(n)?n.call(e):n},T.mixin=function(e){N(T.functions(e),function(t){var n=T[t]=e[t];T.prototype[t]=function(){var e=[this._wrapped];return o.apply(e,arguments),F.call(this,n.apply(T,e))}})};var P=0;T.uniqueId=function(e){var t=P++;return e?e+t:t},T.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var H=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},j=/\\|'|\r|\n|\t|\u2028|\u2029/g;T.template=function(e,t,n){n=T.defaults({},n,T.templateSettings);var r=new RegExp([(n.escape||H).source,(n.interpolate||H).source,(n.evaluate||H).source].join("|")+"|$","g"),i=0,s="__p+='";e.replace(r,function(t,n,r,o,u){s+=e.slice(i,u).replace(j,function(e){return"\\"+B[e]}),s+=n?"'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'":r?"'+\n((__t=("+r+"))==null?'':__t)+\n'":o?"';\n"+o+"\n__p+='":"",i=u+t.length}),s+="';\n",n.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";try{var o=new Function(n.variable||"obj","_",s)}catch(u){throw u.source=s,u}if(t)return o(t,T);var a=function(e){return o.call(this,e,T)};return a.source="function("+(n.variable||"obj")+"){\n"+s+"}",a},T.chain=function(e){return T(e).chain()};var F=function(e){return this._chain?T(e).chain():e};T.mixin(T),N(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=r[e];T.prototype[e]=function(){var n=this._wrapped;return t.apply(n,arguments),(e=="shift"||e=="splice")&&n.length===0&&delete n[0],F.call(this,n)}}),N(["concat","join","slice"],function(e){var t=r[e];T.prototype[e]=function(){return F.call(this,t.apply(this._wrapped,arguments))}}),T.extend(T.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this);
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mozart-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sasha Gerrand
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Use Mozart with Rails 3
56
+ email:
57
+ - sasha.gerrand@bigcommerce.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - LICENSE.txt
64
+ - mozart-rails.gemspec
65
+ - Rakefile
66
+ - README.md
67
+ - lib/mozart-rails.rb
68
+ - lib/generators/mozart/install/install_generator.rb
69
+ - lib/mozart/assert_select.rb
70
+ - lib/mozart/rails/engine.rb
71
+ - lib/mozart/rails/railtie.rb
72
+ - lib/mozart/rails/version.rb
73
+ - lib/mozart/rails.rb
74
+ - vendor/assets/javascripts/handlebars.js
75
+ - vendor/assets/javascripts/jquery.js
76
+ - vendor/assets/javascripts/mozart.min.js
77
+ - vendor/assets/javascripts/underscore.js
78
+ homepage: https://mozart.io
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.0.3
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: This gem provides Mozart for your Rails 3 application.
102
+ test_files: []