\n
\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_array_item"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('
\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('
\n\n'),helperText&&__p.push('\n
\n ',helperText,"\n
\n"),__p.push("\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/file_upload_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('
\n\n'),helperText&&__p.push('\n
\n ',helperText,"\n
\n"),__p.push("\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/hidden_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('
\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/select_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('
\n
\n
\n '),helperText&&__p.push('\n
\n ',helperText,"\n
\n "),__p.push("\n
\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/text_area_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('
\n
\n
\n "),helperText&&__p.push('\n
\n ',helperText,"\n
\n "),__p.push("\n
\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/text_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),(typeof label!="undefined"&&typeof hideLabel!="undefined"&&!hideLabel||typeof hideLabel=="undefined")&&__p.push('\n
\n"),__p.push('\n\n
\n'),typeof addOn!="undefined"&&__p.push('\n
',addOn,"\n"),__p.push('\n
\n'),helperText&&__p.push('\n
\n ',helperText,"\n
\n"),__p.push("\n\n
\n");return __p.join("")}}.call(this),function(){var a,b,c=Array.prototype.slice;b=function(){var a,b,d,e,f;d=arguments[0],a=2<=arguments.length?c.call(arguments,1):[];if(arguments.length===0)return(f=_(Luca.Application.instances).values())!=null?f[0]:void 0;if(_.isString(d)&&(e=Luca.cache(d)))return e;if(_.isString(d)&&(e=Luca.find(d)))return e;if(_.isString(d)&&(e=Luca.registry.find(d)))return e;if(d instanceof jQuery&&(e=Luca.find(d)))return e;if(_.isObject(d)&&d.ctype!=null)return Luca.util.lazyComponent(d);if(_.isFunction(b=_(a).last()))return b()},(window||global).Luca=function(){return b.apply(this,arguments)},Luca.VERSION="0.9.82",_.extend(Luca,{core:{},collections:{},containers:{},components:{},models:{},concerns:{},util:{},fields:{},registry:{},options:{},config:{},logger:function(a){return function(){var b;return b=1<=arguments.length?c.call(arguments,0):[],b.unshift(a),console.log(this,b)}},getHelper:function(){return function(){return b.apply(this,arguments)}}}),_.extend(Luca,Backbone.Events),Luca.setupCollectionSpace=function(a){var b,c;return a==null&&(a={}),b=a.baseParams,c=a.modelBootstrap,b!=null?Luca.Collection.baseParams(b):Luca.warn("You should remember to set the base params for Luca.Collection class. You can do this by defining a property or function on Luca.config.baseParams"),c!=null?Luca.Collection.bootstrap(c):Luca.warn("You should remember to set the model bootstrap location for Luca.Collection. You can do this by defining a property or function on Luca.config.modelBootstrap")},Luca.initialize=function(a,b){var c,d;return b==null&&(b={}),c={views:{},collections:{},models:{},components:{},lib:{},util:{},concerns:{},register:function(){return Luca.register.apply(this,arguments)},onReady:function(){return Luca.onReady.apply(this,arguments)},getApplication:function(){var a;return(a=Luca.getApplication)!=null?a.apply(this,arguments):void 0},getCollectionManager:function(){var a;return(a=Luca.CollectionManager.get)!=null?a.apply(this,arguments):void 0},route:Luca.routeHelper},d={},d[a]=_.extend(Luca.getHelper(),c),_.extend(Luca.config,b),_.extend(window||global,d),Luca.concern.namespace(""+a+".concerns"),Luca.registry.namespace(""+a+".views"),Luca.Collection.namespace(""+a+".collections"),Luca.on("ready",function(){return Luca.setupCollectionSpace(b)})},Luca.onReady=function(a){return Luca.define.close(),Luca.trigger("ready"),$(function(){return a.apply(this,arguments)})},Luca.find=function(a){return Luca($(a).data("luca-id"))},Luca.supportsEvents=Luca.supportsBackboneEvents=function(a){return Luca.isComponent(a)||_.isFunction(a!=null?a.trigger:void 0)||_.isFunction(a!=null?a.bind:void 0)},Luca.isComponent=function(a){return Luca.isBackboneModel(a)||Luca.isBackboneView(a)||Luca.isBackboneCollection(a)},Luca.isComponentPrototype=function(a){return Luca.isViewPrototype(a)||Luca.isModelPrototype(a)||Luca.isCollectionPrototype(a)},Luca.isBackboneModel=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.set:void 0)&&_.isFunction(a!=null?a.get:void 0)&&_.isObject(a!=null?a.attributes:void 0)},Luca.isBackboneView=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.render:void 0)&&!_.isUndefined(a!=null?a.el:void 0)},Luca.isBackboneCollection=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.fetch:void 0)&&_.isFunction(a!=null?a.reset:void 0)},Luca.isViewPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&a.prototype.make!=null&&a.prototype.$!=null&&a.prototype.render!=null},Luca.isModelPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&(typeof a.prototype=="function"?a.prototype(a.prototype.save!=null&&a.prototype.changedAttributes!=null):void 0)},Luca.isCollectionPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&!Luca.isModelPrototype(a)&&a.prototype.reset!=null&&a.prototype.select!=null&&a.prototype.reject!=null},Luca.inheritanceChain=function(a){return Luca.parentClasses(a)},Luca.parentClasses=function(a){var b,c,d;return b=[],_.isString(a)&&(a=Luca.util.resolve(a)),c=typeof a.componentMetaData=="function"?a.componentMetaData():void 0,c||(c=typeof (d=a.prototype).componentMetaData=="function"?d.componentMetaData():void 0),b=(c!=null?c.classHierarchy():void 0)||[a.displayName||a.prototype.displayName]},Luca.parentClass=function(a,b){var c,d,e,f,g;return b==null&&(b=!0),_.isString(a)&&(a=Luca.util.resolve(a)),c=typeof a.componentMetaData=="function"?(e=a.componentMetaData())!=null?e.meta["super class name"]:void 0:void 0,c||(c=typeof (d=a.prototype).componentMetaData=="function"?(f=d.componentMetaData())!=null?f.meta["super class name"]:void 0:void 0),c||a.displayName||((g=a.prototype)!=null?g.displayName:void 0),b?Luca.util.resolve(c):c},a={module:function(a,b){_.extend(a,b);if(a.included&&_(a.included).isFunction())return a.included.apply(a)},"delete":function(a,b){var c;return c=a[b],delete a[b],c},idle:function(a,b){var c;return b==null&&(b=1e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleShort:function(a,b){var c;return b==null&&(b=100),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleMedium:function(a,b){var c;return b==null&&(b=2e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleLong:function(a,b){var c;return b==null&&(b=5e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}}},_.mixin(a)}.call(this),function(){Luca.config.maintainStyleHierarchy=!0,Luca.config.maintainClassHierarchy=!0,Luca.config.autoApplyClassHierarchyAsCssClasses=!0,Luca.config.idAttributeType="integer",Luca.config.apiSortByParameter="sortBy",Luca.config.apiPageParameter="page",Luca.config.apiLimitParameter="limit",Luca.autoRegister=Luca.config.autoRegister=!0,Luca.developmentMode=Luca.config.developmentMode=!1,Luca.enableGlobalObserver=Luca.config.enableGlobalObserver=!1,Luca.config.enableBoostrap=Luca.config.enableBootstrap=!0,Luca.config.enhancedViewProperties=!0,Luca.keys=Luca.config.keys={ENTER:13,ESCAPE:27,KEYLEFT:37,KEYUP:38,KEYRIGHT:39,KEYDOWN:40,SPACEBAR:32,FORWARDSLASH:191,TAB:9},Luca.config.toolbarContainerClass="toolbar-container",Luca.keyMap=Luca.config.keyMap=_(Luca.keys).inject(function(a,b,c){return a[b]=c.toLowerCase(),a},{}),Luca.config.showWarnings=!0}.call(this),function(){var currentNamespace,__slice=Array.prototype.slice;Luca.util.resolve=function(a,b){var c;if(!_.isString(a))return a;try{b||(b=window||global),c=_(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)}catch(d){throw console.log("Error resolving",a,b),d}return c},Luca.util.nestedValue=Luca.util.resolve,Luca.util.argumentsLogger=function(a){return function(){return console.log(""+a+" "+(typeof this.identifier=="function"?this.identifier():void 0),arguments)}},Luca.util.read=function(){var a,b;return b=arguments[0],a=2<=arguments.length?__slice.call(arguments,1):[],_.isFunction(b)?b.apply(this,a):b},Luca.util.readAll=function(a){var b,c,d;a==null&&(a={}),c={};for(b in a)d=a[b],c[b]=Luca.util.read(d);return c},Luca.util.classify=function(a){return a==null&&(a=""),_.string.camelize(_.string.capitalize(a))},Luca.util.hook=function(a){var b,c,d;return a==null&&(a=""),c=a.split(":"),d=c.shift(),c=_(c).map(function(a){return _.string.capitalize(a)}),b=d+c.join("")},Luca.util.toCssClass=function(){var a,b,c,d,e;return a=arguments[0],b=2<=arguments.length?__slice.call(arguments,1):[],d=a.split("."),e=function(){var a,e,f;f=[];for(a=0,e=d.length;a
0&&(d=_(Luca.Collection.namespaces.reverse()).map(function(a){return Luca.util.resolve(""+a+"."+b)||Luca.util.resolve(""+a+"."+b+"Collection")}),d=_(d).compact(),d.length>0&&(c=d[0])),c},c=function(){var a,b,c=this;return a=function(a){var b;return b=c.state.get("loaded_collections_count"),c.state.set("loaded_collections_count",b+1),c.trigger("collection_loaded",a.name),a.unbind("reset")},b=this.initialCollections,Luca.CollectionManager.loadCollectionsByName.call(this,b,a)},b=function(){var a=this;return this.state.set({loaded_collections_count:0,collections_count:this.initialCollections.length}),this.state.bind("change:loaded_collections_count",function(){return a.collectionCountDidChange()}),this.useProgressLoader&&(this.loaderView||(this.loaderView=new Luca.components.CollectionLoaderView({manager:this,name:"collection_loader_view"}))),c.call(this),this.initialCollectionsLoadedu,this}}.call(this),function(){var a=Object.prototype.hasOwnProperty,b=function(b,c){function e(){this.constructor=b}for(var d in c)a.call(c,d)&&(b[d]=c[d]);return e.prototype=c.prototype,b.prototype=new e,b.__super__=c.prototype,b};Luca.SocketManager=function(a){function c(){c.__super__.constructor.apply(this,arguments)}return b(c,a),c.prototype.defaults={autoStart:!0,providerAvailable:!1,ready:!1,provider:"faye.js"},c.prototype.initialize=function(a){var b,c,d,e=this;return this.attributes=a!=null?a:{},this.providerAvailable()!==!0&&this.loadProviderSource(),(d=Luca.Model.prototype.initialize)!=null&&d.apply(this,arguments),c=this,b=function(){if(e.isReady())return e.connect()},c.on("change",function(){return b(),c.unbind("change",this)}),this.on("ready",_.once(function(){return e.set("ready",!0)})),this.trigger("change")},c.prototype.isReady=function(){return this.get("ready")===!0&&this.get("providerAvailable")===!0},c.prototype.providerAvailable=function(){var a;return a=function(){switch(this.get("provider")){case"socket.io":return"io";case"faye.js":return"Faye.Client"}}.call(this),Luca.util.resolve(a)!=null},c.prototype.connect=function(){switch(this.get("provider")){case"socket.io":return this.client=io.connect(this.get("host"));case"faye.js":return this.client=new Faye.Client(this.get("host")+(this.get("namespace")||""))}},c.prototype.providerSourceLoaded=function(){return this.set("providerAvailable",!0)},c.prototype.providerSourceUrl=function(){switch(this.get("provider")){case"socket.io":return""+this.get("host")+"/socket.io/socket.io.js";case"faye.js":return""+this.get("host")+"/faye.js"}},c.prototype.loadProviderSource=function(){var a,b=this;return a=document.createElement("script"),a.setAttribute("type","text/javascript"),a.setAttribute("src",this.providerSourceUrl()),a.onload=_.bind(this.providerSourceLoaded,this),Luca.util.isIE()&&(a.onreadystatechange=function(){if(a.readyState==="loaded")return b.providerSourceLoaded()}),document.getElementsByTagName("head")[0].appendChild(a)},c}(Backbone.Model)}.call(this),function(){}.call(this),function(){Luca.concern=function(a){var b,c;return b=_(Luca.concern.namespaces).detect(function(b){var c;return((c=Luca.util.resolve(b))!=null?c[a]:void 0)!=null}),b||(b="Luca.concerns"),c=Luca.util.resolve(b)[a],c==null&&console.log("Could not find "+a+" in ",Luca.concern.namespaces),c},Luca.concern.namespaces=["Luca.concerns"],Luca.concern.namespace=function(a){return Luca.concern.namespaces.push(a),Luca.concern.namespaces=_(Luca.concern.namespaces).uniq()},Luca.concern.setup=function(){var a,b,c,d,e,f,g,h;if(((d=this.concerns)!=null?d.length:void 0)>0){e=this.concerns,h=[];for(b=0,c=e.length;b0&&this.target&&this.source&&this.setup(),this}return b.prototype.prefixedBy=function(a){return this.prefix=a!=null?a:"",this},b.prototype.from=function(a){return this.source=a,this},b.prototype.to=function(a){return this.target=a,this},b.prototype.setup=function(b){var c,d,e,f,g,h;this.target=b,d=this.prefix,b=this.target,g=this.events,h=[];for(e=0,f=g.length;e0?_(b).select(function(b){return b.match(a)}):b}}.call(this),function(){Luca.concerns.ApplicationEventBindings={__initializer:function(){var a,b,c,d,e,f,g;if(_.isEmpty(this.applicationEvents))return;a=this.app;if(_.isString(a)||_.isUndefined(a))a=(e=Luca.Application)!=null?typeof e.get=="function"?e.get(a):void 0:void 0;if(!Luca.supportsEvents(a))throw"Error binding to the application object on "+(this.name||this.cid);f=this.applicationEvents,g=[];for(c=0,d=f.length;c]/)&&(a=this.make("div",{"class":a,"data-wrapper":!0})),this.$el.wrap(a)},$wrapper:function(){return this.$el.parent('[data-wrapper="true"]')},$template:function(a,b){var c;b==null&&(b={});try{return this.$el.html(Luca.template(a,b))}catch(d){return console.log("Error in $template: "+a+" "+(((c=typeof this.identifier==="function"?this.identifier():void 0)!=null?c:this.name)||this.cid))}},$html:function(a){return this.$el.html(a)},$append:function(a){return this.$el.append(a)},$attach:function(){return this.$container().append(this.el)},$bodyEl:function(){return this.$el},$container:function(){return $(this.container)}}}.call(this),function(){Luca.concerns.EnhancedProperties={__initializer:function(){if(Luca.config.enhancedViewProperties!==!0)return;_.isString(this.collection)&&Luca.CollectionManager.get()&&(this.collection=Luca.CollectionManager.get().getOrCreate(this.collection)),this.template!=null&&this.$template(this.template,this);if(_.isString(this.collectionManager))return this.collectionManager=Luca.CollectionManager.get(this.collectionManager)}}}.call(this),function(){var a,b=Object.prototype.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};Luca.concerns.Filterable={classMethods:{prepare:function(){var a,b,c;return a=_.clone(this.getQuery()),b=_.clone(this.getQueryOptions()),c=this.prepareRemoteFilter(a,b),this.isRemote()?this.collection.applyFilter(c,{remote:!0}):this.trigger("data:refresh")}},__included:function(a,b){return _.extend(Luca.Collection.prototype,{__filters:{}})},__initializer:function(a,b){var c,d,e,f=this;if(this.filterable===!1)return;this.filterable===!0&&(this.filterable={}),Luca.isBackboneCollection(this.collection)||(this.collection=typeof (d=Luca.CollectionManager).get=="function"?(e=d.get())!=null?e.getOrCreate(this.collection):void 0:void 0);if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Filterable due to no collection being present on "+(this.name||this.cid)),this.debug("Collection",this.collection);return}return this.getCollection||(this.getCollection=function(){return this.collection}),c=this.getFilterState(),this.querySources||(this.querySources=[]),this.optionsSources||(this.optionsSources=[]),this.query||(this.query={}),this.queryOptions||(this.queryOptions={}),this.querySources.push(function(a){return a==null&&(a={}),f.getFilterState().toQuery()}),this.optionsSources.push(function(a){return a==null&&(a={}),f.getFilterState().toOptions()}),c.on("change",function(){return f.trigger("filter:change")}),this.on("filter:change",Luca.concerns.Filterable.classMethods.prepare,this),b},prepareRemoteFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b.limit!=null&&(a[Luca.config.apiLimitParameter]=b.limit),b.page!=null&&(a[Luca.config.apiPageParameter]=b.page),b.sortBy!=null&&(a[Luca.config.apiSortByParameter]=b.sortBy),a},isRemote:function(){var a;if(this.getQueryOptions().remote===!0)return!0;if(this.remoteFilterFallback===!0&&((a=this.getCollection())!=null?a.length:void 0)===0)return!0},getFilterState:function(){var b,c,d,e,f,g;return g=b=this.filterable||{},c=g.options,d=g.query,!_.isEmpty(b)&&_.isEmpty(d)&&_.isEmpty(c)&&_.extend(c,_(b).pluck("sortBy","page","limit")),(e=this.collection.__filters)[f=this.cid]||(e[f]=new a({query:d||{},options:c||{}}))},setSortBy:function(a,b){return b==null&&(b={}),this.getFilterState().setOption("sortBy",a,b)},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b=_.defaults(b,this.getQueryOptions()),a=_.defaults(a,this.getQuery()),this.getFilterState().clear({silent:!1}),this.getFilterState().set({query:a,options:b},b)}},a=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return c(b,a),b.prototype.defaults={options:{},query:{}},b.prototype.setOption=function(a,b,c){var d;return d={},d[a]=b,this.set("options",_.extend(this.toOptions(),d),c)},b.prototype.setQueryOption=function(a,b,c){var d;return d={},d[a]=b,this.set("query",_.extend(this.toQuery(),d),c)},b.prototype.toOptions=function(){return _.clone(this.toJSON().options)},b.prototype.toQuery=function(){return _.clone(this.toJSON().query)},b.prototype.toRemote=function(){return Luca.concerns.Filterable.prepareRemoteFilter.call(this,this.toQuery(),this.toOptions())},b}(Backbone.Model)}.call(this),function(){Luca.concerns.FormModelBindings={__initializer:function(){if(this.trackModelChanges!==!0)return;return this.on("state:change:currentModel",this.onStateChangeCurrentModel,this),_.bindAll(this,"onStateChangeCurrentModel","unbindFromModel","onModelChange","bindToModel")},onStateChangeCurrentModel:function(a,b,c){Luca.isBackboneModel(c)&&this.unbindFromModel(c);if(Luca.isBackboneModel(b))return this.bindToModel(b)},unbindFromModel:function(a){var b;return(b=a||this.currentModel())!=null?b.unbind("change",this.onModelChange):void 0},onModelChange:function(a){return this.setValues(a,{modelChange:!0})},bindToModel:function(a){var b;return(b=a||this.currentModel())!=null?b.bind("change",this.onModelChange,this):void 0}}}.call(this),function(){Luca.concerns.GridLayout={_initializer:function(){this.gridSpan&&this.$el.addClass("span"+this.gridSpan),this.gridOffset&&this.$el.addClass("offset"+this.gridOffset),this.gridRowFluid&&this.$el.addClass("row-fluid");if(this.gridRow)return this.$el.addClass("row")}}}.call(this),function(){Luca.concerns.LoadMaskable={__initializer:function(){var a=this;if(this.loadMask===!1||this.loadMask==null)return;return this.loadMask===!0&&(this.loadMask={enableEvent:"enable:loadmask",disableEvent:"disable:loadmask"}),this.on("collection:fetch",function(){return a.trigger("enable:loadmask")}),this.on("collection:reset",function(){return a.trigger("disable:loadmask")}),this.on("after:render",function(){this.$el.addClass("with-mask");if(this.$(".load-mask").length===0&&this.loadMaskTemplate!=null)return this.loadMaskTarget().prepend(Luca.template(this.loadMaskTemplate,this)),this.$(".load-mask").hide()},this),this.on(this.loadMask.enableEvent,this.applyLoadMask,this),this.on(this.loadMask.disableEvent,this.applyLoadMask,this)},showLoadMask:function(){return this.trigger("enable:loadmask")},hideLoadMask:function(){return this.trigger("disable:loadmask")},loadMaskTarget:function(){return this.loadMaskEl!=null?this.$(this.loadMaskEl):this.$bodyEl()},disableLoadMask:function(){return this.$(".load-mask .bar").css("width","100%"),this.$(".load-mask").hide(),clearInterval(this.loadMaskInterval)},enableLoadMask:function(){var a,b=this;this.$(".load-mask").show().find(".bar").css("width","0%"),a=this.$(".load-mask .progress").width(),a<20&&(a=this.$el.width())<20&&(a=this.$el.parent().width()),this.loadMaskInterval=setInterval(function(){var a,c;return a=b.$(".load-mask .bar").width(),c=a+12,b.$(".load-mask .bar").css("width",c)},200);if(this.loadMaskTimeout==null)return;return _.delay(function(){return b.disableLoadMask()},this.loadMaskTimeout)},applyLoadMask:function(){return this.$(".load-mask").is(":visible")?this.disableLoadMask():this.enableLoadMask()}}}.call(this),function(){Luca.LocalStore=function(){function a(a){var b;this.name=a,b=localStorage.getItem(this.name),this.data=b&&JSON.parse(b)||{}}return a.prototype.guid=function(){var a;return a=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},a.prototype.save=function(){return localStorage.setItem(this.name,JSON.stringify(this.data))},a.prototype.create=function(a){return a.id||(a.id=a.attribtues.id=this.guid()),this.data[a.id]=a,this.save(),a},a.prototype.update=function(a){return this.data[a.id]=a,this.save(),a},a.prototype.find=function(a){return this.data[a.id]},a.prototype.findAll=function(){return _.values(this.data)},a.prototype.destroy=function(a){return delete this.data[a.id],this.save(),a},a}(),Backbone.LocalSync=function(a,b,c){var d,e;return e=b.localStorage||b.collection.localStorage,d=function(){switch(a){case"read":return b.id?e.find(b):e.findAll();case"create":return e.create(b);case"update":return e.update(b);case"delete":return e.destroy(b)}}(),d?c.success(d):c.error("Record not found")}}.call(this),function(){var a;Luca.concerns.ModalView={closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,__initializer:function(){return this.$el.addClass("modal"),this.on("before:render",a,this),this},container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")}},a=function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this}}.call(this),function(){Luca.concerns.ModelPresenter={classMethods:{getPresenter:function(a){var b;return(b=this.presenters)!=null?b[a]:void 0},registerPresenter:function(a,b){return this.presenters||(this.presenters={}),this.presenters[a]=b}},presentAs:function(a){var b,c=this;try{return b=this.componentMetaData().componentDefinition().getPresenter(a),b==null?this.toJSON():_(b).reduce(function(a,b){return a[b]=c.read(b),a},{})}catch(d){return console.log("Error presentAs",d.stack,d.message),this.toJSON()}}}}.call(this),function(){Luca.concerns.Paginatable={paginatorViewClass:"Luca.components.PaginationControl",paginationSelector:".toolbar.bottom.pagination-container",__included:function(){return _.extend(Luca.Collection.prototype,{__paginators:{}})},__initializer:function(){var a,b,c=this;if(this.paginatable===!1)return;if(_.isNumber(this.paginatable)||_.isString(this.paginatable))this.paginatable={limit:parseInt(this.paginatable),page:1};if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Paginatable due to no collection being present on "+(this.name||this.cid)),this.debug("collection",this.collection);return}return _.bindAll(this,"paginationControl","pager"),a=(this.getCollection||(this.getCollection=function(){return this.collection}))(),b=this.getPaginationState(),this.optionsSources||(this.optionsSources=[]),this.queryOptions||(this.queryOptions={}),this.optionsSources.push(function(){var a;return a=_(b.toJSON()).pick("limit","page","sortBy"),_.extend(a,{pager:c.pager})}),b.on("change:page",function(){return c.trigger("pagination:change")}),this.on("pagination:change",Luca.concerns.Filterable.classMethods.prepare,this),this.on("before:render",this.renderPaginationControl,this)},pager:function(a,b){return this.getPaginationState().set({numberOfPages:a,itemCount:b.length}),this.paginationControl().updateWithPageCount(a,b)},isRemote:function(){return this.getQueryOptions().remote===!0},getPaginationState:function(){var a,b;return(a=this.collection.__paginators)[b=this.cid]||(a[b]=this.paginationControl().state)},paginationContainer:function(){return this.$(">"+this.paginationSelector)},setCurrentPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.getPaginationState().set("page",a,b)},setPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.getPaginationState().set("page",a,b)},setLimit:function(a,b){return a==null&&(a=0),b==null&&(b={}),this.getPaginationState().set("limit",a,b)},paginationControl:function(){return this.paginator!=null?this.paginator:(_.defaults(this.paginatable||(this.paginatable={}),{page:1,limit:20}),this.paginator=Luca.util.lazyComponent({type:"pagination_control",collection:this.getCollection(),defaultState:this.paginatable,parent:this.name||this.cid,debugMode:this.debugMode}),this.paginator)},renderPaginationControl:function(){var a;return a=this.paginationControl(),this.paginationContainer().append(a.render().$el),a}}}.call(this),function(){Luca.concerns.QueryCollectionBindings={getCollection:function(){return this.collection},loadModels:function(a,b){var c;return a==null&&(a=[]),b==null&&(b={}),(c=this.getCollection())!=null?c.reset(a,b):void 0},applyQuery:function(a,b){return a==null&&(a={}),b==null&&(b={}),this.query=a,this.queryOptions=b,this.refresh(),this},getQuery:function(a){var b,c,d,e,f;a==null&&(a={}),b=this.query||(this.query={}),f=_(this.querySources||[]).compact();for(d=0,e=f.length;d0&&(this.memoryCollection=!0),this.useNormalUrl!==!0&&this.__wrapUrl(),Backbone.Collection.prototype.initialize.apply(this,[a,this.options]),a&&this.reset(a,{silent:!0,parse:b!=null?b.parse:void 0}),Luca.concern.setup.call(this),Luca.util.setupHooks.call(this,this.hooks),this.setupMethodCaching(),this.trigger("after:initialize")},__wrapUrl:function(){var a,b,c=this;return _.isFunction(this.url)?this.url=_.wrap(this.url,function(a){var b,d,e,f,g;return g=a.apply(c),e=g.split("?"),e.length>1&&(b=_.last(e)),f=c.queryString(),b&&g.match(b)&&(f=f.replace(b,"")),d=""+g+"?"+f,d.match(/\?$/)&&(d=d.replace(/\?$/,"")),d}):(b=this.url,a=this.queryString(),this.url=_([b,a]).compact().join("?"))},queryString:function(){var a,b=this;return a=_(this.base_params||(this.base_params=Luca.Collection.baseParams())).inject(function(a,b,c){var d;return d=""+c+"="+b,a.push(d),a},[]),_.uniq(a).join("&")},resetFilter:function(){return this.base_params=_(Luca.Collection.baseParams()).clone(),this},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b=_(b).clone(),b.remote!=null==1||this.remoteFilter===!0?(this.applyParams(a),this.fetch(_.extend(b,{refresh:!0,remote:!0}))):this.reset(this.query(a,b))},applyParams:function(a){return this.base_params=_(Luca.Collection.baseParams()).clone()||{},_.extend(this.base_params,a),this},register:function(a,b,c){b==null&&(b=""),a||(a=Luca.CollectionManager.get());if(!(b.length>=1))throw"Attempt to register a collection without specifying a key.";_.isString(a)&&(a=Luca.util.resolve(a));if(a==null)throw"Attempt to register with a non existent collection manager.";if(_.isFunction(a.add))return a.add(b,c);if(_.isObject(a))return a[b]=c},loadFromBootstrap:function(){if(!this.bootstrap_cache_key)return;return this.reset(this.cached_models()),this.trigger("bootstrapped",this)},bootstrap:function(){return this.loadFromBootstrap()},cached_models:function(){return Luca.Collection.cache(this.bootstrap_cache_key)},fetch:function(a){var b;a==null&&(a={}),this.trigger("before:fetch",this);if(this.memoryCollection===!0)return this.reset(this.data);if(this.cached_models().length&&a.refresh!==!0&&a.remote!==!0)return this.bootstrap();b=_.isFunction(this.url)?this.url():this.url;if(!(b&&b.length>1||this.localStorage))return!0;this.fetching=!0;try{return Backbone.Collection.prototype.fetch.apply(this,arguments)}catch(c){throw console.log("Error in Collection.fetch",c),c}},onceLoaded:function(a,b){var c,d=this;b==null&&(b={}),_.defaults(b,{autoFetch:!0});if(this.length>0&&!this.fetching){a.apply(this,[this]);return}c=function(){return a.apply(d,[d])},this.bind("reset",function(){return c(),this.unbind("reset",this)});if(!this.fetching&&!!b.autoFetch)return this.fetch()},ifLoaded:function(a,b){var c,d=this;b==null&&(b={scope:this,autoFetch:!0}),c=b.scope||this,this.length>0&&!this.fetching&&a.apply(c,[this]),this.bind("reset",function(b){return a.call(c,b)});if(!(this.fetching===!0||!b.autoFetch||this.length>0))return this.fetch()},parse:function(a){var b;return this.fetching=!1,this.trigger("after:response",a),b=this.root!=null?a[this.root]:a,this.bootstrap_cache_key&&Luca.Collection.cache(this.bootstrap_cache_key,b),b},restoreMethodCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],a.original!=null?(a.args=void 0,d.push(this[b]=a.original)):d.push(void 0);return d},clearMethodCache:function(a){return this._methodCache[a].value=void 0},clearAllMethodsCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],d.push(this.clearMethodCache(b));return d},setupMethodCaching:function(){var b,c,d;if(((d=this.cachedMethods)!=null?d.length:void 0)>0)return a=this,c=["reset","add","remove"],b=this._methodCache={},_(this.cachedMethods).each(function(d){var e,f,g,h,i;b[d]={name:d,original:a[d],value:void 0},a[d]=function(){var c;return(c=b[d]).value||(c.value=b[d].original.apply(a,arguments))};for(h=0,i=c.length;h0)return _.bindAll.apply(_,[this].concat(d.call(this.bindMethods)))},setupHooks:Luca.util.setupHooks,registerEvent:function(a,b){return this.events||(this.events={}),this.events[a]=b,_.isObject(a)&&_.extend(this.events,a),this.delegateEvents()},definitionClass:function(){var a;return(a=Luca.util.resolve(this.displayName,window))!=null?a.prototype:void 0},collections:function(){return Luca.util.selectProperties(Luca.isBackboneCollection,this)},models:function(){return Luca.util.selectProperties(Luca.isBackboneModel,this)},views:function(){return Luca.util.selectProperties(Luca.isBackboneView,this)},debug:function(){var a;a=1<=arguments.length?d.call(arguments,0):[];if(this.debugMode===!0||window.LucaDebugMode===!0)return a.unshift(this.identifier()),console.log.apply(console,a)},trigger:function(){return Luca.enableGlobalObserver&&(Luca.developmentMode===!0||this.observeEvents===!0)&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)}}),Luca.View._originalExtend=Backbone.View.extend,Luca.View.renderStrategies={legacy:function(a){var b,d,e,f,g,h=this;return c=this,this.deferrable?(f=this.deferrable_target,Luca.isBackboneCollection(this.deferrable)||(this.deferrable=this.collection),f||(f=this.deferrable),g=this.deferrable_event?this.deferrable_event:Luca.View.deferrableEvent,d=function(){return a.call(c),c.trigger("after:render",c)},c.defer(d).until(f,g),c.trigger("before:render",this),b=this.deferrable_trigger||this.deferUntil,b==null?f[this.deferrable_method||"fetch"].call(f):(e=_.once(function(){var a,b;return typeof (a=h.deferrable)[b=h.deferrable_method||"fetch"]=="function"?a[b]():void 0}),(this.deferrable_target||this).bind(this.deferrable_trigger,e)),this):(this.trigger("before:render",this),a.apply(this,arguments),this.trigger("after:render",this),this)},improved:function(a){var b,d=this;this.trigger("before:render",this),b=function(){return a.apply(d,arguments),d.trigger("after:render",d)},console.log("doing the improved one",this.deferrable);if(this.deferrable!=null&&!_.isString(this.deferrable))throw"Deferrable property is expected to be a event id";return _.isString(this.deferrable)?(console.log("binding to "+this.deferrable+" on "+this.cid),c.on(this.deferrable,function(){return console.log("did the improved one"),b.call(c),c.unbind(listenForEvent,this)})):b.call(this)}},Luca.View.renderWrapper=function(a){var b;return b=a.render,b||(b=function(){return this.trigger("empty:render")}),a.render=function(){var a;a=Luca.View.renderStrategies[this.renderStrategy||(this.renderStrategy="legacy")];if(!_.isFunction(a))throw"Invalid rendering strategy. Please see Luca.View.renderStrategies";return a.call(this,b),this},a},a=function(){var a,c,d,e,f;e=[this.events,this.componentEvents,this.collectionEvents,this.applicationEvents],f=[];for(c=0,d=e.length;c0?a:a.length!==0||this.bodyClassName==null&&this.bodyTagName==null?this.$el:(d=this.make(c,{"class":b,"data-auto-appended":!0}),this.$el.append(d),this.$(this.bodyEl))},$wrap:function(a){return _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$html(Luca.template(a,b))},$empty:function(){return this.$bodyEl().empty()},$html:function(a){return this.$bodyEl().html(a)},$append:function(a){return this.$bodyEl().append(a)}}),a.privateMethods({beforeRender:function(){var a;return(a=Luca.View.prototype.beforeRender)!=null&&a.apply(this,arguments),this.styles!=null&&this.applyStyles(this.styles),this.bodyStyles!=null&&this.applyStyles(this.bodyStyles,!0),typeof this.renderToolbars=="function"?this.renderToolbars():void 0},renderToolbars:function(){var a=this;return _(["top","left","right","bottom"]).each(function(b){var c;if(c=a[""+b+"Toolbar"])return a.renderToolbar(b,c)})},renderToolbar:function(a,b){var c;return a==null&&(a="top"),b==null&&(b={}),b.parent=this,b.orientation=a,c=Luca.util.read(b.container),c||(c=Luca.util.read(b.targetEl)),Luca.Panel.attachToolbar.call(this,b,c)}}),a.classMethods({attachToolbar:function(a,b){var c,d,e,f;return a==null&&(a={}),a.orientation||(a.orientation="top"),a.type||(a.type=a.ctype||(a.ctype=this.toolbarType||"panel_toolbar")),a.additionalClassNames=""+Luca.config.toolbarContainerClass+" "+a.orientation,e=Luca.util.lazyComponent(a),a.orientation==="bottom"&&(this.getBottomToolbar||(this.getBottomToolbar=function(){return e})),a.orientation==="top"&&(this.getTopToolbar||(this.getTopToolbar=function(){return e})),a.orientation==="right"&&(this.getRightToolbar||(this.getRightToolbar=function(){return e})),a.orientation==="left"&&(this.getLeftToolbar||(this.getLeftToolbar=function(){return e})),d=this.bodyClassName||this.bodyTagName,c=function(){switch(a.orientation){case"top":case"left":return d&&(b!=null?!b.length:!void 0)>0?"before":"prepend";case"bottom":case"right":return d&&(b!=null?!b.length:!void 0)>0?"after":"append"}}(),f=(b!=null?b.length:void 0)>0?this.$(b):this.$bodyEl(),f[c](e.render().el)}}),a.defines({version:3})}.call(this),function(){}.call(this),function(){var a,b,c,d,e,f,g,h;b=Luca.register("Luca.Container"),b["extends"]("Luca.Panel"),b.triggers("before:components","before:render:components","before:layout","after:components","after:layout","first:activation"),b.replaces("Luca.Container"),b.defines({className:"luca-ui-container",componentTag:"div",componentClass:"luca-ui-panel",isContainer:!0,rendered:!1,components:[],componentEvents:{},initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},_.extend(this,this.options),this.components||(this.components=this.fields||(this.fields=this.pages||(this.pages=this.cards||(this.cards=this.views)))),e=this.components;for(c=0,d=e.length;c0});if(c.length>0){i=[];for(g=0,h=c.length;g0?($(f).attr("data-container-assignment",d),i.push(e.container+="[data-container-assignment='"+d+"']")):i.push(void 0);return i}},prepareComponents:function(){var a=this;return b=this,_(this.components).each(function(c,d){var e,f,g,h,i,j;e=f=(i=a.componentContainers)!=null?i[d]:void 0,e["class"]=e["class"]||e.className||e.classes,a.generateComponentElements&&(h=a.make(a.componentTag,f,""),a.$append(h)),b.defaults!=null&&(c=_.defaults(c,b.defaults||{})),_.isArray(b.extensions)&&_.isObject((j=b.extensions)!=null?j[d]:void 0)&&(g=b.extensions[d],c=_.extend(c,g)),c.role!=null&&_.isObject(b.extensions)&&_.isObject(b.extensions[c.role])&&(g=b.extensions[c.role],c=_.extend(c,g));if(c.container==null)return a.generateComponentElements&&(c.container="#"+f.id),c.container||(c.container=a.$bodyEl())})},createComponents:function(){var a,c=this;if(this.componentsCreated===!0)return;return a=this.componentIndex={name_index:{},cid_index:{},role_index:{}},b=this,this.components=_(this.components).map(function(a,d){var e,f,h;return e=Luca.isComponent(a)?a:(a.type||(a.type=a.ctype),a.type==null?a.components!=null?a.type=a.ctype="container":a.type=a.ctype=Luca.defaultComponentType:void 0,a._parentCid||(a._parentCid=b.cid),f=Luca.util.lazyComponent(a)),!e.container&&((h=e.options)!=null?h.container:void 0)&&(e.container=e.options.container),e.getParent||(e.getParent=function(){return Luca(e._parentCid)}),e.container==null&&(console.log(e,d,c),console.error("could not assign container property to component on container "+(c.name||c.cid))),g(e).at(d)["in"](c.componentIndex),e}),this.componentsCreated=!0,a},renderComponents:function(a){return this.debugMode=a!=null?a:"",this.debug("container render components"),b=this,_(this.components).each(function(a){var c;try{return a.trigger("before:attach"),c=b.$(a.container),c.length===0&&(_.isString(a.container)&&1,c.length===0&&(c=this.$(a.container).eq(0))),c.append(a.el),a.trigger("after:attach"),a.render()}catch(d){console.log("Error Rendering Component "+(a.name||a.cid),a),_.isObject(d)&&(console.log(d.message),console.log(d.stack));if(Luca.silenceRenderErrors!=null!=1)throw d}})},firstActivation:function(){var a;return a=this,this.each(function(b,c){var d;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.call(b,"first:activation",b,a),b.previously_activated=!0})},_:function(){return _(this.components)},pluck:function(a){return this._().pluck(a)},invoke:function(a){return this._().invoke(a)},select:function(a){return this._().select(a)},detect:function(a){return this._().detect(attribute)},reject:function(a){return this._().reject(a)},map:function(a){return this._().map(a)},registerComponentEvents:function(a){var c,d,e,f,g,h,i,j,k=this;b=this,h=a||this.componentEvents||{},j=[];for(g in h){f=h[g],i=g.split(" "),d=i[0],e=i[1];if(!_.isFunction(this[f]))throw console.log("Error registering component event",g,d,e),"Invalid component event definition "+g+". Specified handler is not a method on the container";if(d==="*")j.push(this.eachComponent(function(a){return a.on(e,k[f],b)}));else{c=this.findComponentForEventBinding(d);if(c==null||!Luca.isComponent(c))throw console.log("Error registering component event",g,d,e),"Invalid component event definition: "+d;j.push(c!=null?c.bind(e,this[f],b):void 0)}}return j},subContainers:function(){return this.select(function(a){return a.isContainer===!0})},roles:function(){return _(this.allChildren()).pluck("role")},allChildren:function(){var a,b;return a=this.components,b=_(this.subContainers()).invoke("allChildren"),_([a,b]).chain().compact().flatten().value()},findComponentForEventBinding:function(a,b){return b==null&&(b=!0),this.findComponentByName(a,b)||this.findComponentByGetter(a,b)||this.findComponentByRole(a,b)},findComponentByGetter:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.getter===a})},findComponentByRole:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.role===a||b.type===a||b.ctype===a})},findComponentByType:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return a===(b.type||b.ctype)})},findComponentByName:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.name===a})},findComponentById:function(a,b){return b==null&&(b=!1),this.findComponent(a,"cid_index",b)},findComponent:function(a,b,c){var d,e,f,g;b==null&&(b="name"),c==null&&(c=!1),this.componentsCreated!==!0&&this.createComponents(),e=(g=this.componentIndex)!=null?g[b][a]:void 0,d=this.components[e];if(d)return d;if(c===!0)return f=_(this.components).detect(function(c){return c!=null?typeof c.findComponent=="function"?c.findComponent(a,b,!0):void 0:void 0}),f!=null?typeof f.findComponent=="function"?f.findComponent(a,b,!0):void 0:void 0},each:function(a){return this.eachComponent(a,!1)},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c,d){var e;a.call(c,c,d);if(b)return c!=null?(e=c.eachComponent)!=null?e.apply(c,[a,b]):void 0:void 0})},indexOf:function(a){var b;return b=_(this.components).pluck("name"),_(b).indexOf(a)},activeComponent:function(){return this.activeItem?this.components[this.activeItem]:this},componentElements:function(){return this.$("[data-luca-parent='"+(this.name||this.cid)+"']")},getComponent:function(a){return this.components[a]},isRootComponent:function(){return this.rootComponent===!0||this.getParent==null},getRootComponent:function(){return this.isRootComponent()?this:this.getParent().getRootComponent()},selectByAttribute:function(a,b,c){var d;return b==null&&(b=void 0),c==null&&(c=!1),d=_(this.components).map(function(d){var e,f;return e=[],f=d[a],(f===b||b==null&&f!=null)&&e.push(d),c===!0&&e.push(typeof d.selectByAttribute=="function"?d.selectByAttribute(a,b,!0):void 0),_.compact(e)}),_.flatten(d)}}),Luca.Container.componentRenderer=function(a,b){var c;return c=$(b.container)[b.attachWith||"append"],c(b.render().el)},f=function(){return this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},a=function(a,b){var c,d;return d=[],a.height!=null&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width!=null&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={"class":(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";"),"data-luca-parent":this.name||this.cid},this.customizeContainerEl!=null&&(c=this.customizeContainerEl(c,a,b)),c},c=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return a.getter!=null}),_(a).each(function(a){var c;return b[c=a.getter]||(b[c]=function(){return a})})},d=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return a.role!=null}),_(a).each(function(a){var c,d;return c=_.str.camelize("get_"+a.role),d=function(){return a},b[c]||(b[c]=_.bind(d,b))})},e=function(){return this.trigger("before:components",this,this.components),this.prepareComponents(),this.trigger("before:create:components",this,this.components),this.createComponents(),this.trigger("before:render:components",this,this.components),this.renderComponents(),this.trigger("after:components",this,this.components),this.skipGetterMethods!==!0&&(c.call(this),d.call(this)),this.registerComponentEvents()},h=function(){return!0},g=function(a){return{at:function(b){return{"in":function(c){a.cid!=null&&(c.cid_index[a.cid]=b),a.role!=null&&(c.role_index[a.role]=b);if(a.name!=null)return c.name_index[a.name]=b}}}}}}.call(this),function(){var a;a=Luca.define("Luca.containers.CardView"),a["extends"]("Luca.Container"),a.aliases("Luca.PageView"),a.defaults({className:"luca-ui-card-view-wrapper",activeCard:0,components:[],hooks:["before:card:switch","after:card:switch"],componentClass:"luca-ui-card",generateComponentElements:!0,initialize:function(a){return this.options=a,this.components||(this.components=this.pages||(this.pages=this.cards)),Luca.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks),this.defer(this.simulateActivationEvent,this).until("after:render")},simulateActivationEvent:function(){var a;a=this.activeComponent();if(a!=null&&this.$el.is(":visible"))return a!=null?a.trigger("activation",this,a,a):void 0},prepareComponents:function(){var a;return(a=Luca.Container.prototype.prepareComponents)!=null&&a.apply(this,arguments),this.componentElements().hide(),this.activeComponentElement().show()},activeComponentElement:function(){return this.componentElements().eq(this.activeCard)},activeComponent:function(){return this.getComponent(this.activeCard)},customizeContainerEl:function(a,b,c){return a.style+=c===this.activeCard?"display:block;":"display:none;",a},atFirst:function(){return this.activeCard===0},atLast:function(){return this.activeCard===this.components.length-1},next:function(){if(this.atLast())return;return this.activate(this.activeCard+1)},previous:function(){if(this.atFirst())return;return this.activate(this.activeCard-1)},cycle:function(){var a;return a=this.atLast()?0:this.activeCard+1,this.activate(a)},find:function(a){return Luca(a)},firstActivation:function(){var a;return(a=this.activeComponent())!=null?a.trigger("first:activation",this,this.activeComponent()):void 0},activate:function(a,b,c){var d,e,f,g=this;b==null&&(b=!1),_.isFunction(b)&&(b=!1,c=b);if(a===this.activeCard)return;f=this.activeComponent(),e=this.getComponent(a),e||(a=this.indexOf(a),e=this.getComponent(a));if(!e)return;b!==!0&&(this.trigger("before:card:switch",f,e),f!=null&&f.trigger("before:deactivation",this,f,e),e!=null&&e.trigger("before:activation",this,f,e),_.defer(function(){return g.$el.data(g.activeAttribute||"active-card",e.name)})),this.componentElements().hide(),e.previously_activated!==!0&&(e.trigger("first:activation"),e.previously_activated=!0),this.activeCard=a,this.activeComponentElement().show(),b!==!0&&(this.trigger("after:card:switch",f,e),f!=null&&f.trigger("deactivation",this,f,e),e!=null&&e.trigger("activation",this,f,e)),d=this,Luca.containers.CardView.activationContext==="current"&&(d=e);if(_.isFunction(c))return c.apply(d,[this,f,e])}}),Luca.containers.CardView.activationContext="current"}.call(this),function(){_.def("Luca.ModalView")["extends"]("Luca.Container")["with"]({closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,className:"luca-ui-container modal",container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")},render:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this}}),_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]()}.call(this),function(){var a,b,c,d;c=Luca.register("Luca.PanelToolbar"),c["extends"]("Luca.View"),c.defines({buttons:[],className:"luca-ui-toolbar btn-toolbar",well:!0,orientation:"top",autoBindEventHandlers:!0,events:{"click a.btn, click .dropdown-menu li":"clickHandler"},initialize:function(a){var b;this.options=a!=null?a:{},this._super("initialize",this,arguments);if(this.group===!0&&((b=this.buttons)!=null?b.length:void 0)>=0)return this.buttons=[{group:!0,buttons:this.buttons}]},clickHandler:function(a){var b,c,d,e,f;d=e=$(a.target),d.is("i")&&(d=e=$(a.target).parent()),this.selectable===!0&&(e.siblings().removeClass("is-selected"),d.addClass("is-selected"));if(!(b=e.data("eventid")))return;return c=Luca.util.hook(b),f=this.parent||this,_.isFunction(f[c])?f[c].call(this,d,a):f.trigger(b,d,a)},beforeRender:function(){this._super("beforeRender",this,arguments),this.well===!0&&this.$el.addClass("well"),this.selectable===!0&&this.$el.addClass("btn-selectable"),this.$el.addClass("toolbar-"+this.orientation),this.align==="right"&&this.$el.addClass("pull-right");if(this.align==="left")return this.$el.addClass("pull-left")},render:function(){var a,b,c,e;this.$el.empty(),e=d(this.buttons);for(b=0,c=e.length;b "+k),f={"class":_.compact(["btn",a.classes,a.className]).join(" "),"data-eventId":a.eventId,title:a.title||a.description},a.color!=null&&(f["class"]+=" btn-"+a.color),a.selected!=null&&(f["class"]+=" is-selected"),a.dropdown&&(k=""+k+" ",f["class"]+=" dropdown-toggle",f["data-toggle"]="dropdown",j=_(a.dropdown).map(function(a){var c;return c=b("a",{},a[1]),b("li",{"data-eventId":a[0]},c)}),i=b("ul",{"class":"dropdown-menu"},j)),g=b("a",f,k),e="btn-group"
,a.align!=null&&(e+=" align-"+a.align),c===!0?b("div",{"class":e},[g,i]):g))},d=function(b,c){var d,e,f,g;b==null&&(b=[]),c==null&&(c=!0),g=[];for(e=0,f=b.length;e"),e=""+(d||"")+" "+b.title+"",f=a.make("li",{"class":"tab-selector","data-target":c},e),a.tabContainer().append(f);if(b.navHeading!=null&&((g=a.navHeadings)!=null?!g[b.navHeading]:!void 0))return $(f).before(a.make("li",{"class":"nav-header"},b.navHeading)),a.navHeadings||(a.navHeadings={}),a.navHeadings[b.navHeading]=!0})},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},select:function(a){var b,c;return a.preventDefault(),b=c=$(a.target),this.trigger("before:select",this),this.activate(c.parent().data("target")),this.trigger("after:select",this)},componentElements:function(){return this.$(">.tab-content >."+this.componentClass)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return this.$("ul."+this.navClass,this.tabContainerWrapper())},tabSelectors:function(){return this.$("li.tab-selector",this.tabContainer())}})}.call(this),function(){_.def("Luca.containers.Viewport").extend("Luca.containers.CardView")["with"]({activeItem:0,additionalClassNames:"luca-ui-viewport",fullscreen:!0,fluid:!1,initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),Luca.config.enableBoostrap===!0&&(this.wrapperClass=this.fluid===!0?Luca.containers.Viewport.fluidWrapperClass:Luca.containers.Viewport.defaultWrapperClass),Luca.Container.prototype.initialize.apply(this,arguments);if(this.fullscreen===!0)return this.enableFullscreen()},enableFluid:function(){return this.enableWrapper()},disableFluid:function(){return this.disableWrapper()},enableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().addClass(this.wrapperClass)},disableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().removeClass(this.wrapperClass)},enableFullscreen:function(){return $("html,body").addClass("luca-ui-fullscreen"),this.$el.addClass("fullscreen-enabled")},disableFullscreen:function(){return $("html,body").removeClass("luca-ui-fullscreen"),this.$el.removeClass("fullscreen-enabled")},beforeRender:function(){var a;(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.topNav!=null&&this.renderTopNavigation();if(this.bottomNav!=null)return this.renderBottomNavigation()},height:function(){return this.$el.height()},width:function(){return this.$el.width()},afterRender:function(){var a;(a=Luca.containers.CardView.prototype.after)!=null&&a.apply(this,arguments);if(Luca.config.enableBoostrap===!0&&this.containerClassName)return this.$el.children().wrap('')},renderTopNavigation:function(){var a;if(this.topNav==null)return;return _.isString(this.topNav)&&(this.topNav=Luca.util.lazyComponent(this.topNav)),_.isObject(this.topNav)&&((a=this.topNav).ctype||(a.ctype=this.topNav.type||"nav_bar"),Luca.isBackboneView(this.topNav)||(this.topNav=Luca.util.lazyComponent(this.topNav))),this.topNav.app=this,$("body").prepend(this.topNav.render().el)},renderBottomNavigation:function(){}}),Luca.containers.Viewport.defaultWrapperClass="row",Luca.containers.Viewport.fluidWrapperClass="row-fluid"}.call(this),function(){}.call(this),function(){var a,b=Array.prototype.slice;a=Luca.register("Luca.Application"),a["extends"]("Luca.containers.Viewport"),a.triggers("controller:change","action:change"),a.publicInterface({name:"MyApp",defaultState:{},autoBoot:!1,autoStartHistory:"before:render",useCollectionManager:!0,collectionManager:{},collectionManagerClass:"Luca.CollectionManager",plugin:!1,useController:!0,useKeyHandler:!1,keyEvents:{},components:[{type:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}],createRoleBasedGetters:!1,useSocketManager:!1,socketManagerOptions:{},initialize:function(a){var b,c,d,e=this;this.options=a!=null?a:{},c=this,d=this.name,b=typeof Luca.getApplication=="function"?Luca.getApplication():void 0,Luca.Application.registerInstance(this),Luca.concerns.StateModel.__initializer.call(this),this.setupCollectionManager(),this.setupSocketManager(),Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.useController===!0&&this.setupMainController(),this.defer(function(){return c.render()}).until(this,"ready"),this.setupRouter(),(this.useKeyHandler===!0||this.useKeyRouter===!0)&&this.keyEvents!=null&&this.setupKeyHandler(),this.plugin!==!0&&!b&&(Luca.getApplication=function(a){return a==null?c:Luca.Application.instances[a]});if(this.autoBoot){if(Luca.util.resolve(this.name))throw"Attempting to override window."+this.name+" when it already exists";$(function(){return window[d]=c,c.boot()})}return Luca.trigger("application:available",this)},activeView:function(){var a;return(a=this.activeSubSection())?this.view(a):this.view(this.activeSection())},activeSection:function(){return this.get("active_section")},activeSubSection:function(){return this.get("active_sub_section")},activePages:function(){var a=this;return this.$(".luca-ui-controller").map(function(a,b){return $(b).data("active-section")})},boot:function(){var a,b,c,d,e;this.trigger("ready"),d=[this.collectionManager,this.socket,this.router],e=[];for(b=0,c=d.length;b0)return this.on("after:render",function(){return b.refresh(),b.unbind("after:render",this)})},attributesForItem:function(a,b){return _.extend({},{"class":this.itemClassName,"data-index":a.index,"data-model-id":a.model.get("id")})},contentForItem:function(a){var b,c;return a==null&&(a={}),this.itemTemplate!=null&&(c=Luca.template(this.itemTemplate))?b=c.call(this,a):this.itemRenderer!=null&&_.isFunction(this.itemRenderer)?b=this.itemRenderer.call(this,a,a.model,a.index):this.itemProperty&&a.model!=null?b=a.model.read(this.itemProperty):""},makeItem:function(a,c){var d,e,f;f=this.prepareItem!=null?this.prepareItem.call(this,a,c):{model:a,index:c},d=this.attributesForItem(f,a),e=this.contentForItem(f);try{return b(this.itemTagName,d,e)}catch(g){return console.log("Error generating DOM element for CollectionView",this,a,c)}},locateItemElement:function(a){return this.$("."+this.itemClassName+"[data-model-id='"+a+"']")},refreshModel:function(a){var b;return b=this.collection.indexOf(a),this.locateItemElement(a.get("id")).empty().append(this.contentForItem({model:a,index:b},a)),this.trigger("model:refreshed",b,a)},refresh:function(a,b,c){var d,e,f,g;a||(a=this.getQuery()),b||(b=this.getQueryOptions()),c||(c=this.getModels(a,b)),this.$bodyEl().empty(),this.trigger("before:refresh",c,a,b),c.length===0&&this.trigger("empty:results"),d=0;for(f=0,g=c.length;f0?this.renderCheckboxes():this.defer("renderCheckboxes").until(this.collection,"reset")},clickHandler:function(a){var b;b=$(a.target);if(b.prop("checked"))return this.selectedItems.push(b.val());if(_(this.selectedItems).include(b.val()))return this.selectedItems=_(this.selectedItems).without(b.val())},controls:function(){return this.$(".controls")},renderCheckboxes:function(){var a=this;return this.controls().empty(),this.selectedItems=[],this.collection.each(function(c){var d,e,f,g,h;return h=c.get(a.valueField),g=c.get(a.displayField),f=_.uniqueId(""+a.cid+"_checkbox"),e=b("input",{type:"checkbox","class":"array-checkbox",name:a.input_name,value:h,id:f}),d=b("label",{"for":f},e),$(d).append(" "+g),a.controls().append(d)}),this.trigger("checkboxes:rendered",this.checkboxesRendered=!0),this},uncheckAll:function(){return this.allFields().prop("checked",!1)},allFields:function(){return this.controls().find("input[type='checkbox']")},checkSelected:function(a){var b,c,d,e,f;a!=null&&(this.selectedItems=a),this.uncheckAll(),f=this.selectedItems;for(d=0,e=f.length;d0?this.populateOptions():(c=this.collection)!=null?c.trigger("reset"):void 0},setValue:function(a){return this.currentValue=a,Luca.core.Field.prototype.setValue.apply(this,arguments)},beforeFetch:function(){return this.resetOptions()},change_handler:function(a){return this.trigger("on:change",this,a)},resetOptions:function(){this.getInputElement().html("");if(this.includeBlank)return this.getInputElement().append("")},populateOptions:function(){var a,b=this;return this.resetOptions(),((a=this.collection)!=null?a.each:void 0)!=null&&this.collection.each(function(a){var c,d,e,f;return f=a.get(b.valueField),c=a.get(b.displayField),b.selected&&f===b.selected&&(e="selected"),d="",b.getInputElement().append(d)}),this.trigger("after:populate:options",this),this.setValue(this.currentValue)}})}.call(this),function(){_.def("Luca.fields.TextAreaField")["extends"]("Luca.core.Field")["with"]({events:{"keydown input":"keydown_handler","blur input":"blur_handler","focus input":"focus_handler"},template:"fields/text_area_field",height:"200px",width:"90%",initialize:function(a){return this.options=a!=null?a:{},_.bindAll(this,"keydown_handler"),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=""),this.inputStyles||(this.inputStyles="height:"+this.height+";width:"+this.width),this.placeHolder||(this.placeHolder=""),Luca.core.Field.prototype.initialize.apply(this,arguments)},setValue:function(a){return $(this.field()).val(a)},getValue:function(){return $(this.field()).val()},field:function(){return this.input=$("textarea#"+this.input_id,this.el)},keydown_handler:function(a){var b,c;return b=c=$(a.currentTarget)},blur_handler:function(a){var b,c;return b=c=$(a.currentTarget)},focus_handler:function(a){var b,c;return b=c=$(a.currentTarget)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.TextField"),a["extends"]("Luca.core.Field"),a.defines({events:{"blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",autoBindEventHandlers:!0,send_blanks:!0,keyEventThrottle:300,initialize:function(a){return this.options=a!=null?a:{},this.enableKeyEvents&&(this.keyEventThrottle&&(this.keyup_handler=_.debounce(this.keyup_handler,this.keyEventThrottle)),this.registerEvent("keyup input","keyup_handler")),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=this.value||""),this.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend),this.append&&(this.$el.addClass("input-append"),this.addOn=this.append),this.placeHolder||(this.placeHolder=""),Luca.core.Field.prototype.initialize.apply(this,arguments)},keyup_handler:function(a){return this.trigger("on:change",this,a),this.trigger("on:keyup",this,a)},blur_handler:function(a){return this.trigger("on:blur",this,a)},focus_handler:function(a){return this.trigger("on:focus",this,a)},change_handler:function(a){return this.trigger("on:change",this,a)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.TypeAheadField"),a["extends"]("Luca.fields.TextField"),a.defines({getSource:function(){return Luca.util.read(this.source)||[]},matcher:function(a){return!0},beforeRender:function(){return Luca.fields.TextField.prototype.beforeRender.apply(this,arguments),this.getInputElement().attr("data-provide","typeahead")},afterRender:function(){return Luca.fields.TextField.prototype.afterRender.apply(this,arguments),this.getInputElement().typeahead({matcher:this.matcher
,source:this.getSource()})}})}.call(this),function(){var a;a=Luca.register("Luca.components.FormButtonToolbar"),a["extends"]("Luca.components.Toolbar"),a.defines({className:"luca-ui-form-toolbar form-actions",position:"bottom",includeReset:!1,render:function(){return $(this.container).append(this.el),this},initialize:function(a){this.options=a!=null?a:{},Luca.components.Toolbar.prototype.initialize.apply(this,arguments),this.components=[{ctype:"button_field",label:"Submit","class":"btn submit-button"}];if(this.includeReset)return this.components.push({ctype:"button_field",label:"Reset","class":"btn reset-button"})}})}.call(this),function(){var a;a=Luca.register("Luca.components.FormView"),a["extends"]("Luca.Container"),a.mixesIn("LoadMaskable","FormModelBindings"),a.triggers("before:submit","before:reset","before:load","before:load:new","before:load:existing","after:submit","after:reset","after:load","after:load:new","after:load:existing","after:submit:success","after:submit:fatal_error","after:submit:error","state:change:dirty"),a.publicConfiguration({trackDirtyState:!1,trackModelChanges:!1,labelAlign:void 0,fieldLayoutClass:void 0,legend:"",toolbar:!0,toolbarConfig:void 0,defaultToolbar:"Luca.components.FormView.defaultToolbar",loadMask:!0,well:!1,searchForm:!1,horizontalForm:!1,inlineForm:!1,includeBlankValues:void 0}),a.privateConfiguration({tagName:"form",events:{"click .submit-button":"submitHandler","click .reset-button":"resetHandler"},bodyClassName:"form-view-body",stateful:{dirty:!1,currentModel:void 0}}),a.privateMethods({initialize:function(a){var b;return this.options=a!=null?a:{},b=this,this.loadMask==null&&(this.loadMask=Luca.config.enableBoostrap),Luca.Container.prototype.initialize.apply(this,arguments),this.components||(this.components=this.fields),_.bindAll(this,"submitHandler","resetHandler","renderToolbars"),this.trackDirtyState===!0&&this.on("after:components",function(){var a,c,d,e,f;e=this.getFields(),f=[];for(c=0,d=e.length;c0?this.$(".toolbar-container.top").after(a):this.$bodyEl().prepend(a)},successFlashDelay:1500,successMessage:function(a){var b=this;return this.$(".alert.alert-success").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-success",message:a})),_.delay(function(){return b.$(".alert.alert-success").fadeOut()},this.successFlashDelay||0)},errorMessage:function(a){return this.$(".alert.alert-error").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-error",message:a}))}}),a.classInterface({setupToolbar:function(){if(this.toolbar!==!1&&!this.topToolbar&&!this.bottomToolbar){if(this.toolbar==="both"||this.toolbar==="top")this.topToolbar=_.clone(this.getDefaultToolbar());if(this.toolbar!=="top")return this.bottomToolbar=_.clone(this.getDefaultToolbar())}},defaultToolbar:{buttons:[{icon:"remove-sign",label:"Reset",eventId:"click:reset",className:"reset-button",align:"right"},{icon:"ok-sign",white:!0,label:"Save Changes",eventId:"click:submit",color:"success",className:"submit-button",align:"right"}]}}),a.defines({version:2})}.call(this),function(){_.def("Luca.components.GridView").extend("Luca.Panel")["with"]({bodyTemplate:"components/grid_view",autoBindEventHandlers:!0,events:{"dblclick table tbody tr":"double_click_handler","click table tbody tr":"click_handler"},className:"luca-ui-g-view",rowClass:"luca-ui-g-row",wrapperClass:"luca-ui-g-view-wrapper",additionalWrapperClasses:[],wrapperStyles:{},scrollable:!0,emptyText:"No Results To display.",tableStyle:"striped",defaultHeight:285,defaultWidth:756,maxWidth:void 0,hooks:["before:grid:render","before:render:header","before:render:row","after:grid:render","row:double:click","row:click","after:collection:load"],initialize:function(a){var b=this;return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.concerns.Deferrable),this.loadMask==null&&(this.loadMask=Luca.config.enableBoostrap),this.loadMask===!0&&(this.loadMaskEl||(this.loadMaskEl=".luca-ui-g-view-body")),Luca.Panel.prototype.initialize.apply(this,arguments),this.configure_collection(!0),this.collection.bind("before:fetch",function(){if(b.loadMask===!0)return b.trigger("enable:loadmask")}),this.collection.bind("reset",function(a){return b.refresh(),b.loadMask===!0&&b.trigger("disable:loadmask"),b.trigger("after:collection:load",a)}),this.collection.bind("change",function(a){var c,d;if(b.rendered!==!0)return;try{return d=b.getRowEl(a.id||a.get("id")||a.cid),c=b.render_row(a,b.collection.indexOf(a),{cellsOnly:!0}),$(d).html(c.join(" "))}catch(e){return console.log("Error in change handler for GridView.collection",e,b,a)}})},beforeRender:function(){var a;return(a=Luca.Panel.prototype.beforeRender)!=null&&a.apply(this,arguments),this.trigger("before:grid:render",this),this.table=this.$("table.luca-ui-g-view"),this.header=this.$("thead"),this.body=this.$("tbody"),this.footer=this.$("tfoot"),this.wrapper=this.$("."+this.wrapperClass),this.applyCssClasses(),this.scrollable&&this.setDimensions(),this.renderHeader(),this.emptyMessage(),$(this.container).append(this.$el)},afterRender:function(){var a;return(a=Luca.Panel.prototype.afterRender)!=null&&a.apply(this,arguments),this.rendered=!0,this.refresh(),this.trigger("after:grid:render",this)},applyCssClasses:function(){var a,b=this;return this.scrollable&&this.$el.addClass("scrollable-g-view"),_(this.additionalWrapperClasses).each(function(a){var c;return(c=b.wrapper)!=null?c.addClass(a):void 0}),Luca.config.enableBoostrap&&this.table.addClass("table"),_((a=this.tableStyle)!=null?a.split(" "):void 0).each(function(a){return b.table.addClass("table-"+a)})},setDimensions:function(a){var b=this;return this.height||(this.height=this.defaultHeight),this.$(".luca-ui-g-view-body").height(this.height),this.$("tbody.scrollable").height(this.height-23),this.container_width=function(){return $(b.container).width()}(),this.width||(this.width=this.container_width>0?this.container_width:this.defaultWidth),this.width=_([this.width,this.maxWidth||this.width]).max(),this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width),this.setDefaultColumnWidths()},resize:function(a){var b,c,d=this;b=a-this.width,this.width=a,this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width);if(this.columns.length>0)return c=b/this.columns.length,_(this.columns).each(function(a,b){var e;return e=$(".column-"+b,d.el),e.width(a.width=a.width+c)})},padLastColumn:function(){var a,b;a=_(this.columns).inject(function(a,b){return a=b.width+a},0),b=this.width-a;if(b>0)return this.lastColumn().width+=b},setDefaultColumnWidths:function(){var a;return a=this.columns.length>0?this.width/this.columns.length:200,_(this.columns).each(function(b){return parseInt(b.width||(b.width=a))}),this.padLastColumn()},lastColumn:function(){return this.columns[this.columns.length-1]},emptyMessage:function(a){return a==null&&(a=""),a||(a=this.emptyText),this.body.html(""),this.body.append(Luca.templates["components/grid_view_empty_text"]({colspan:this.columns.length,text:a}))},refresh:function(){var a=this;this.body.html(""),this.collection.each(function(b,c){return a.render_row.apply(a,[b,c])});if(this.collection.models.length===0)return this.emptyMessage()},ifLoaded:function(a,b){return b||(b=this),a||(a=function(){return!0}),this.collection.ifLoaded(a,b)},applyFilter:function(a,b){return b==null&&(b={auto:!0,refresh:!0}),this.collection.applyFilter(a,b)},renderHeader:function(){var a,b=this;return this.trigger("before:render:header"),a=_(this.columns).map(function(a,b){var c;return c=a.width?"width:"+a.width+"px;":"",""+a.header+" | "}),this.header.append(""+a+"
")},getRowEl:function(a){return this.$("[data-record-id="+a+"]","table")},render_row:function(a,b,c){var d,e,f,g,h,i,j=this;return c==null&&(c={}),h=this.rowClass,g=(a!=null?a.get:void 0)&&(a!=null?a.attributes:void 0)?a.get("id"):"",this.trigger("before:render:row",a,b),e=_(this.columns).map(function(b,c){var d,e,f;return f=j.cell_renderer(a,b,c),e=b.width?"width:"+b.width+"px;":"",d=_.isUndefined(f)?"":f,""+d+" | "}),c.cellsOnly?e:(d="",this.alternateRowClasses&&(d=b%2===0?"even":"odd"),f=""+e+"
",c.contentOnly===!0?f:(i=this.body)!=null?i.append(f):void 0)},cell_renderer:function(a,b,c){var d;return _.isFunction(b.renderer)?b.renderer.apply(this,[a,b,c]):b.data.match(/\w+\.\w+/)?(d=a.attributes||a,Luca.util.nestedValue(b.data,d)):(typeof a.get=="function"?a.get(b.data):void 0)||a[b.data]},double_click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:double:click",this,d,e)},click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:click",this,d,e),$("."+this.rowClass,this.body).removeClass("selected-row"),b.addClass("selected-row")}})}.call(this),function(){var a;a=Luca.register("Luca.components.LoadMask"),a["extends"]("Luca.View"),a.defines({className:"luca-ui-load-mask",bodyTemplate:"components/load_mask"})}.call(this),function(){var a;a=Luca.register("Luca.components.MultiCollectionView"),a["extends"]("Luca.containers.CardView"),a.mixesIn("QueryCollectionBindings","LoadMaskable","Filterable","Paginatable","Sortable"),a.triggers("before:refresh","after:refresh","refresh","empty:results"),a.private({stateful:{activeView:0},initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},this.components||(this.components=this.views),e=this.components;for(c=0,d=e.length;c"+this.brand+"");if(this.template)return this.content().append(Luca.template(this.template,this))},render:function(){return this},content:function(){return this.$(".container").eq(0)}})}.call(this),function(){var a;a=Luca.register("Luca.PageController"),a["extends"]("Luca.components.Controller"),a.defines({version:2})}.call(this),function(){var a;a=Luca.register("Luca.components.PaginationControl"),a["extends"]("Luca.View"),a.defines({template:"components/pagination",stateful:!0,stateChangeEvents:{numberOfPages:"onPageCountChange"},autoBindEventHandlers:!0,events:{"click a[data-page-number]":"selectPage","click a.next":"nextPage","click a.prev":"previousPage"},onPageCountChange:function(){return this.updateWithPageCount(this.get("numberOfPages"))},limit:function(){var a;return parseInt(this.get("limit")||((a=this.collection)!=null?a.length:void 0))},page:function(){return parseInt(this.get("page")||1)},nextPage:function(){if(!this.nextEnabled())return;return this.set("page",this.page()+1)},previousPage:function(){if(!this.previousEnabled())return;return this.set("page",this.page()-1)},selectPage:function(a){var b,c;return b=c=this.$(a.target),b.is("a.page")||(b=c=c.closest("a.page")),c.siblings().removeClass("is-selected"),b.addClass("is-selected"),this.setPage(c.data("page-number"))},setPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.set("page",a,b)},setLimit:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.set("limit",a,b)},pageButtonContainer:function(){return this.$(".group")},previousEnabled:function(){return this.page()>1},nextEnabled:function(){return this.page()There was an internal server error saving this record. Please contact developers@benchprep.com to report this error."),$(".form-view-body",g.el).spin(!1)}),b.bind("after:submit:error",function(a,b,c){return _(c.errors).each(function(a){return $(".form-view-flash-container",g.el).append(""+a+"")})}),b.bind("after:submit:success",function(a,b,c){return $(".form-view-flash-container",g.el).append("Successfully Saved Record"),b.set(c.result),a.loadModel(b),d.refresh(),_.delay(function(){return $(".form-view-flash-container li.success",g.el).fadeOut(1e3),$(".form-view-flash-container",g.el).html("")},4e3)}),c.eachComponent(function(a){try{return a.bind("on:change",g.filter_handler)}catch(b){return}})},firstActivation:function(){return this.getGrid().trigger("first:activation",this,this.getGrid()),this.getFilter().trigger("first:activation",this,this.getGrid())},reload:function(){var a,b,c,d;return d=this,c=this.getGrid(),b=this.getFilter(),a=this.getEditor(),b.clear(),c.applyFilter()},manageRecord:function(a){var b,c=this;return b=this.getCollection().get(a),b?this.loadModel(b):(console.log("Could Not Find Model, building and fetching"),b=this.buildModel(),b.set({id:a},{silent:!0}),b.fetch({success:function(a,b){return c.loadModel(a)}}))},loadModel:function(a){return this.current_model=a,this.getEditor(!0).loadModel(this.current_model),this.trigger("model:loaded",this.current_model)},currentModel:function(){return this.getEditor(!1).currentModel()},buildModel:function(){var a,b,c;return b=this.getEditor(!1),a=this.getCollection(),a.add([{}],{silent:!0,at:0}),c=a.at(0)},createModel:function(){return this.loadModel(this.buildModel())},reset_filter_handler:function(a){return this.getFilter().clear(),this.getGrid().applyFilter(this.getFilter().getValues())},filter_handler:function(a){return this.getGrid().applyFilter(this.getFilter().getValues())},edit_handler:function(a){var b,c,d,e;return b=d=$(a.currentTarget),e=d.parents("tr").data("record-id"),e&&(c=this.getGrid().collection.get(e)),c||(c=this.getGrid().collection.at(row_index))},add_handler:function(a){var b,c,d;return b=c=$(a.currentTarget),d=c.parents(".record-manager").eq(0).data("resource")},destroy_handler:function(a){},back_to_search_handler:function(){}})}.call(this),function(){var a;a=Luca.register("Luca.Router"),a["extends"]("Backbone.Router"),a.defines({routes:{"":"default"},initialize:function(a){var b,c=this;return this.options=a,_.extend(this,this.options),this.routeHandlers=_(this.routes).values(),_(this.routeHandlers).each(function(a){return c.bind("route:"+a,function(){return c.trigger.apply(c,["change:navigation",a].concat(_(arguments).flatten()))})}),(b=Backbone.Router.initialize)!=null?b.apply(this,arguments):void 0},navigate:function(a,b){return b==null&&(b=!1),Backbone.Router.prototype.navigate.apply(this,arguments),this.buildPathFrom(Backbone.history.getFragment())},buildPathFrom:function(a){var b=this;return _(this.routes).each(function(c,d){var e,f;f=b._routeToRegExp(d);if(f.test(a))return e=b._extractParameters(f,a),b.trigger.apply(b,["change:navigation",c].concat(e))})}})}.call(this),function(){var a;a=Luca.register("Luca.components.TableView"),a["extends"]("Luca.CollectionView"),a.publicConfiguration({widths:[],columns:[],emptyText:"There are no results to display"}),a.privateConfiguration({additionalClassNames:"table",tagName:"table",bodyTemplate:"table_view",bodyTagName:"tbody",bodyClassName:"table-body",stateful:!0,itemTagName:"tr",observeChanges:!0}),a.privateMethods({lastColumn:function(){return this.columns[this.columns.length-1]},eachColumn:function(a,b){var c,d,e,f,g,h;b==null&&(b=this),d=0,g=this.columns,h=[];for(e=0,f=g.length;e");for(h=0,j=a.length;h"+d.header+""),this.$(b).find("tr").append(Backbone.View.prototype.make("th",c,e));f=0,l=[];for(i=0,k=a.length;i