luca 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module Luca
2
2
  module Rails
3
- VERSION = "0.7.3"
3
+ VERSION = "0.7.4"
4
4
  end
5
5
  end
6
6
 
@@ -27,6 +27,8 @@ Luca.Collection = (Backbone.QueryCollection || Backbone.Collection).extend
27
27
  initialize: (models=[], @options)->
28
28
  _.extend @, @options
29
29
 
30
+ @_reset()
31
+
30
32
  # By specifying a @cached property or method, you can instruct
31
33
  # Luca.Collection instances where to pull an array of model attributes
32
34
  # usually done with the bootstrap functionality provided.
@@ -81,6 +83,9 @@ Luca.Collection = (Backbone.QueryCollection || Backbone.Collection).extend
81
83
 
82
84
  Backbone.Collection.prototype.initialize.apply @, [models, @options]
83
85
 
86
+ if models
87
+ @reset models, silent: true, parse: options?.parse
88
+
84
89
  @trigger "after:initialize"
85
90
 
86
91
  #### Automatic Query String Generation
data/src/core/view.coffee CHANGED
@@ -134,14 +134,14 @@ _.extend Luca.View.prototype,
134
134
  setupHooks: (set)->
135
135
  set ||= @hooks
136
136
 
137
- _(set).each (event)=>
138
- parts = event.split(':')
137
+ _(set).each (eventId)=>
138
+ parts = eventId.split(':')
139
139
  prefix = parts.shift()
140
140
 
141
141
  parts = _( parts ).map (p)-> _.capitalize(p)
142
142
  fn = prefix + parts.join('')
143
143
 
144
- @bind event, ()=> @[fn].apply @, arguments if @[fn]
144
+ @bind eventId, ()=> @[fn].apply @, arguments if @[fn]
145
145
 
146
146
 
147
147
  #### Luca.Collection and Luca.CollectionManager integration
data/src/framework.coffee CHANGED
@@ -1,7 +1,7 @@
1
1
  _.mixin( _.string )
2
2
 
3
3
  window.Luca =
4
- VERSION: "0.7.3"
4
+ VERSION: "0.7.4"
5
5
  core: {}
6
6
  containers: {}
7
7
  components: {}
@@ -3,7 +3,7 @@
3
3
  _.mixin(_.string);
4
4
 
5
5
  window.Luca = {
6
- VERSION: "0.7.3",
6
+ VERSION: "0.7.4",
7
7
  core: {},
8
8
  containers: {},
9
9
  components: {},
@@ -429,15 +429,15 @@
429
429
  setupHooks: function(set) {
430
430
  var _this = this;
431
431
  set || (set = this.hooks);
432
- return _(set).each(function(event) {
432
+ return _(set).each(function(eventId) {
433
433
  var fn, parts, prefix;
434
- parts = event.split(':');
434
+ parts = eventId.split(':');
435
435
  prefix = parts.shift();
436
436
  parts = _(parts).map(function(p) {
437
437
  return _.capitalize(p);
438
438
  });
439
439
  fn = prefix + parts.join('');
440
- return _this.bind(event, function() {
440
+ return _this.bind(eventId, function() {
441
441
  if (_this[fn]) return _this[fn].apply(_this, arguments);
442
442
  });
443
443
  });
@@ -477,6 +477,7 @@
477
477
  if (models == null) models = [];
478
478
  this.options = options;
479
479
  _.extend(this, this.options);
480
+ this._reset();
480
481
  if (this.cached) {
481
482
  this.bootstrap_cache_key = _.isFunction(this.cached) ? this.cached() : this.cached;
482
483
  }
@@ -505,6 +506,12 @@
505
506
  }
506
507
  if (this.useNormalUrl !== true) this.__wrapUrl();
507
508
  Backbone.Collection.prototype.initialize.apply(this, [models, this.options]);
509
+ if (models) {
510
+ this.reset(models, {
511
+ silent: true,
512
+ parse: options != null ? options.parse : void 0
513
+ });
514
+ }
508
515
  return this.trigger("after:initialize");
509
516
  },
510
517
  __wrapUrl: function() {
@@ -3,7 +3,7 @@
3
3
  _.mixin(_.string);
4
4
 
5
5
  window.Luca = {
6
- VERSION: "0.7.3",
6
+ VERSION: "0.7.4",
7
7
  core: {},
8
8
  containers: {},
9
9
  components: {},
@@ -429,15 +429,15 @@
429
429
  setupHooks: function(set) {
430
430
  var _this = this;
431
431
  set || (set = this.hooks);
432
- return _(set).each(function(event) {
432
+ return _(set).each(function(eventId) {
433
433
  var fn, parts, prefix;
434
- parts = event.split(':');
434
+ parts = eventId.split(':');
435
435
  prefix = parts.shift();
436
436
  parts = _(parts).map(function(p) {
437
437
  return _.capitalize(p);
438
438
  });
439
439
  fn = prefix + parts.join('');
440
- return _this.bind(event, function() {
440
+ return _this.bind(eventId, function() {
441
441
  if (_this[fn]) return _this[fn].apply(_this, arguments);
442
442
  });
443
443
  });
@@ -477,6 +477,7 @@
477
477
  if (models == null) models = [];
478
478
  this.options = options;
479
479
  _.extend(this, this.options);
480
+ this._reset();
480
481
  if (this.cached) {
481
482
  this.bootstrap_cache_key = _.isFunction(this.cached) ? this.cached() : this.cached;
482
483
  }
@@ -505,6 +506,12 @@
505
506
  }
506
507
  if (this.useNormalUrl !== true) this.__wrapUrl();
507
508
  Backbone.Collection.prototype.initialize.apply(this, [models, this.options]);
509
+ if (models) {
510
+ this.reset(models, {
511
+ silent: true,
512
+ parse: options != null ? options.parse : void 0
513
+ });
514
+ }
508
515
  return this.trigger("after:initialize");
509
516
  },
510
517
  __wrapUrl: function() {
@@ -3,7 +3,7 @@
3
3
  _.mixin(_.string);
4
4
 
5
5
  window.Luca = {
6
- VERSION: "0.7.3",
6
+ VERSION: "0.7.4",
7
7
  core: {},
8
8
  containers: {},
9
9
  components: {},
@@ -429,15 +429,15 @@
429
429
  setupHooks: function(set) {
430
430
  var _this = this;
431
431
  set || (set = this.hooks);
432
- return _(set).each(function(event) {
432
+ return _(set).each(function(eventId) {
433
433
  var fn, parts, prefix;
434
- parts = event.split(':');
434
+ parts = eventId.split(':');
435
435
  prefix = parts.shift();
436
436
  parts = _(parts).map(function(p) {
437
437
  return _.capitalize(p);
438
438
  });
439
439
  fn = prefix + parts.join('');
440
- return _this.bind(event, function() {
440
+ return _this.bind(eventId, function() {
441
441
  if (_this[fn]) return _this[fn].apply(_this, arguments);
442
442
  });
443
443
  });
@@ -477,6 +477,7 @@
477
477
  if (models == null) models = [];
478
478
  this.options = options;
479
479
  _.extend(this, this.options);
480
+ this._reset();
480
481
  if (this.cached) {
481
482
  this.bootstrap_cache_key = _.isFunction(this.cached) ? this.cached() : this.cached;
482
483
  }
@@ -505,6 +506,12 @@
505
506
  }
506
507
  if (this.useNormalUrl !== true) this.__wrapUrl();
507
508
  Backbone.Collection.prototype.initialize.apply(this, [models, this.options]);
509
+ if (models) {
510
+ this.reset(models, {
511
+ silent: true,
512
+ parse: options != null ? options.parse : void 0
513
+ });
514
+ }
508
515
  return this.trigger("after:initialize");
509
516
  },
510
517
  __wrapUrl: function() {
@@ -1,3 +1,3 @@
1
- (function(){_.mixin(_.string),window.Luca={VERSION:"0.7.3",core:{},containers:{},components:{},modules:{},fields:{},util:{},registry:{classes:{},namespaces:["Luca.containers","Luca.components"]},component_cache:{cid_index:{},name_index:{}}},Luca.enableBootstrap=!0,Luca.isBackboneModel=function(a){return _.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 _.isFunction(a!=null?a.render:void 0)&&!_.isUndefined(a!=null?a.el:void 0)},Luca.isBackboneCollection=function(a){return _.isFunction(a!=null?a.fetch:void 0)&&_.isFunction(a!=null?a.reset:void 0)},Luca.registry.addNamespace=function(a){return Luca.registry.namespaces.push(a),Luca.registry.namespaces=_(Luca.registry.namespaces).uniq()},Luca.cache=function(a,b){var c;return b!=null&&(Luca.component_cache.cid_index[a]=b),b=Luca.component_cache.cid_index[a],(b!=null?b.component_name:void 0)!=null?Luca.component_cache.name_index[b.component_name]=b.cid:(b!=null?b.name:void 0)!=null&&(Luca.component_cache.name_index[b.name]=b.cid),b!=null?b:(c=Luca.component_cache.name_index[a],Luca.component_cache.cid_index[c])},Luca.util.nestedValue=function(a,b){return _(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)},Luca.registry.lookup=function(a){var b,c,d;return b=Luca.registry.classes[a],b!=null?b:(c=_.camelize(_.capitalize(a)),d=_(Luca.registry.namespaces).map(function(a){return Luca.util.nestedValue(a,window||global)}),_.first(_.compact(_(d).map(function(a){return a[c]}))))},Luca.util.lazyComponent=function(config){var componentClass,constructor,ctype;ctype=config.ctype,componentClass=Luca.registry.lookup(ctype);if(!componentClass)throw"Invalid Component Type: "+ctype+". Did you forget to register it?";return constructor=eval(componentClass),new constructor(config)},Luca.register=function(a,b){var c;c=Luca.registry.classes[a];if(c!=null)throw"Can not register component with the signature "+a+". Already exists";return Luca.registry.classes[a]=b},Luca.available_templates=function(a){var b;return a==null&&(a=""),b=_(Luca.templates).keys(),a.length>0?_(b).select(function(b){return b.match(a)}):b},Luca.util.isIE=function(){try{return Object.defineProperty({},"",{}),!1}catch(a){return!0}},$(function(){return $("body").addClass("luca-ui-enabled")}())}).call(this),function(){Luca.modules.Deferrable={configure_collection:function(a){var b,c,d;a==null&&(a=!0);if(!this.collection)return;_.isString(this.collection)&&(b=(c=Luca.CollectionManager)!=null?c.get():void 0)&&(this.collection=b.getOrCreate(this.collection)),this.collection&&_.isFunction(this.collection.fetch)&&_.isFunction(this.collection.reset)||(this.collection=new Luca.Collection(this.collection.initial_set,this.collection));if((d=this.collection)!=null?d.deferrable_trigger:void 0)this.deferrable_trigger=this.collection.deferrable_trigger;if(a)return this.deferrable=this.collection}}}.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(){Luca.templates||(Luca.templates={}),Luca.templates["components/bootstrap_form_controls"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='form-actions'>\n <a class='btn btn-primary submit-button'>\n <i class='icon-ok icon-white'></i>\n Save Changes\n </a>\n <a class='btn reset-button cancel-button'>\n <i class='icon-remove'></i>\n Cancel\n </a>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/collection_loader_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='modal' id='progress-model' stype='display: none;'>\n <div class='progress progress-info progress-striped active'>\n <div class='bar' style='width: 0%;'></div>\n </div>\n <div class='message'>\n Initializing...\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/form_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-form-view-wrapper' id='",cid,"-wrapper'>\n <div class='form-view-header'>\n <div class='toolbar-container top' id='",cid,"-top-toolbar-container'></div>\n </div>\n "),legend?__p.push("\n <fieldset>\n <legend>\n ",legend,"\n </legend>\n <div class='form-view-flash-container'></div>\n <div class='form-view-body'></div>\n </fieldset>\n "):__p.push("\n <ul class='form-view-flash-container'></ul>\n <div class='form-view-body'></div>\n "),__p.push("\n <div class='form-view-footer'>\n <div class='toolbar-container bottom' id='",cid,"-bottom-toolbar-container'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/grid_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-grid-view-wrapper'>\n <div class='grid-view-header'>\n <div class='toolbar-container top'></div>\n </div>\n <div class='grid-view-body'>\n <table cellpadding='0' cellspacing='0' class='luca-ui-grid-view scrollable-table' width='100%'>\n <thead class='fixed'></thead>\n <tbody class='scrollable'></tbody>\n </table>\n </div>\n <div class='grid-view-footer'>\n <div class='toolbar-container bottom'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/grid_view_empty_text"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='empty-text-wrapper'>\n <p>\n ",text,"\n </p>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/basic"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='",classes,"' id='",id,"' style='",style,"'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/tab_selector_container"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{}){__p.push("<div class='tab-selector-container' id='",cid,"-tab-selector'>\n <ul class='nav nav-tabs' id='",cid,"-tabs-nav'>\n ");for(var i=0;i<components.length;i++){__p.push("\n ");var component=components[i];__p.push("\n <li class='tab-selector' data-target='",i,"'>\n <a data-target='",i,"'>\n ",component.title,"\n </a>\n </li>\n ")}__p.push("\n </ul>\n</div>\n")}return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/tab_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='tab-content' id='",cid,"-tab-view-content'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/toolbar_wrapper"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-toolbar-wrapper' id='",id,"'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/button_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label>&nbsp</label>\n<input class='btn ",input_class,"' id='",input_id,"' style='",inputStyles,"' type='",input_type,"' value='",input_value,"' />\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/button_field_link"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<a class='btn ",input_class,"'>\n "),icon_class.length&&__p.push("\n <i class='",icon_class,"'></i>\n "),__p.push("\n ",input_value,"\n</a>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/checkbox_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n <input name='",input_name,"' style='",inputStyles,"' type='checkbox' value='",input_value,"' />\n</label>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/file_upload_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<input id='",input_id,"' name='",input_name,"' style='",inputStyles,"' type='file' />\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/hidden_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<input id='",input_id,"' name='",input_name,"' type='hidden' value='",input_value,"' />\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/select_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<select id='",input_id,"' name='",input_name,"' style='",inputStyles,"'></select>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/text_area_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<textarea class='",input_class,"' id='",input_id,"' name='",input_name,"' style='",inputStyles,"'></textarea>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/text_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label class='control-label' for='",input_id,"'>\n ",label,"\n</label>\n"),typeof addOn!="undefined"&&__p.push("\n<span class='add-on'>\n ",addOn,"\n</span>\n"),__p.push("\n<input id='",input_id,"' name='",input_name,"' placeholder='",placeHolder,"' style='",inputStyles,"' type='text' />\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["sample/contents"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<p>Sample Contents</p>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["sample/welcome"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("welcome.luca\n");return __p.join("")}}.call(this),function(){var a=Array.prototype.slice;Luca.Observer=function(){function b(b){var c=this;this.options=b!=null?b:{},_.extend(this,Backbone.Events),this.type=this.options.type,this.options.debugAll&&this.bind("event",function(){var b,d;return d=arguments[0],b=2<=arguments.length?a.call(arguments,1):[],console.log("Observed "+c.type+" "+(d.name||d.id||d.cid),d,_(b).flatten())})}return b.prototype.relay=function(){var b,c;return c=arguments[0],b=2<=arguments.length?a.call(arguments,1):[],this.trigger("event",c,b),this.trigger("event:"+b[0],c,b.slice(1))},b}(),Luca.Observer.enableObservers=function(a){return a==null&&(a={}),Luca.enableGlobalObserver=!0,Luca.ViewObserver=new Luca.Observer(_.extend(a,{type:"view"})),Luca.CollectionObserver=new Luca.Observer(_.extend(a,{type:"collection"}))}}.call(this),function(){Luca.View=Backbone.View.extend({base:"Luca.View"}),Luca.View.originalExtend=Backbone.View.extend,Luca.View.extend=function(a){var b;return b=a.render,b||(b=function(){var a;return a=_.isFunction(this.container)?this.container():this.container,!$(a)||!this.$el?this:($(a).append(this.$el),this)}),a.render=function(){var a=this;return this.deferrable?(this.trigger("before:render",this),this.deferrable.bind(this.deferrable_event,_.once(function(){return b.apply(a,arguments),a.trigger("after:render",a)})),this.deferrable_trigger||(this.immediate_trigger=!0),this.immediate_trigger===!0?this.deferrable.fetch():this.bind(this.deferrable_trigger,_.once(function(){return a.deferrable.fetch()}))):(this.trigger("before:render",this),b.apply(this,arguments),this.trigger("after:render",this))},Luca.View.originalExtend.apply(this,[a])},_.extend(Luca.View.prototype,{debug:function(){var a,b,c,d;if(!this.debugMode&&window.LucaDebugMode==null)return;d=[];for(b=0,c=arguments.length;b<c;b++)a=arguments[b],d.push(console.log([this.name||this.cid,a]));return d},trigger:function(){return Luca.enableGlobalObserver&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)},hooks:["after:initialize","before:render","after:render","first:activation","activation","deactivation"],deferrable_event:"reset",initialize:function(a){var b,c=this;return this.options=a!=null?a:{},_.extend(this,this.options),this.name!=null&&(this.cid=_.uniqueId(this.name)),Luca.cache(this.cid,this),b=_(Luca.View.prototype.hooks.concat(this.hooks)).uniq(),this.setupHooks(b),this.autoBindEventHandlers===!0&&_(this.events).each(function(a,b){if(_.isString(a))return _.bindAll(c,a)}),this.trigger("after:initialize",this),this.registerCollectionEvents(),this.delegateEvents()},$container:function(){return $(this.container)},setupHooks:function(a){var b=this;return a||(a=this.hooks),_(a).each(function(a){var c,d,e;return d=a.split(":"),e=d.shift(),d=_(d).map(function(a){return _.capitalize(a)}),c=e+d.join(""),b.bind(a,function(){if(b[c])return b[c].apply(b,arguments)})})},getCollectionManager:function(){var a;return this.collectionManager||((a=Luca.CollectionManager.get)!=null?a.call():void 0)},registerCollectionEvents:function(){var a,b=this;return a=this.getCollectionManager(),_(this.collectionEvents).each(function(c,d){var e,f,g,h;h=d.split(" "),g=h[0],f=h[1],e=b[""+g+"Collection"]=a.getOrCreate(g);if(!e)throw"Could not find collection specified by "+g;_.isString(c)&&(c=b[c]);if(!_.isFunction(c))throw"invalid collectionEvents configuration";try{return e.bind(f,c)}catch(i){throw console.log("Error Binding To Collection in registerCollectionEvents",b),i}})}})}.call(this),function(){Luca.Collection=(Backbone.QueryCollection||Backbone.Collection).extend({initialize:function(a,b){var c,d=this;a==null&&(a=[]),this.options=b,_.extend(this,this.options),this.cached&&(this.bootstrap_cache_key=_.isFunction(this.cached)?this.cached():this.cached),(this.registerAs||this.registerWith)&&console.log("This configuration API is deprecated. use @name and @manager properties instead"),this.name||(this.name=this.registerAs),this.manager||(this.manager=this.registerWith),this.name&&!this.manager&&(this.manager=Luca.CollectionManager.get()),this.manager&&(this.name||(this.name=this.cached()),this.name=_.isFunction(this.name)?this.name():this.name,!this.private&&!this.anonymous&&this.bind("after:initialize",function(){return d.register(d.manager,d.name,d)}));if(this.useLocalStorage===!0&&window.localStorage!=null)throw c=this.bootstrap_cache_key||this.name,"Must specify either a cached or registerAs property to use localStorage";return _.isArray(this.data)&&this.data.length>0&&(this.memoryCollection=!0),this.useNormalUrl!==!0&&this.__wrapUrl(),Backbone.Collection.prototype.initialize.apply(this,[a,this.options]),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(),this},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),this.applyParams(a),this.fetch(_.extend(b,{refresh:!0}))},applyParams:function(a){return this.base_params||(this.base_params=_(Luca.Collection.baseParams()).clone()),_.extend(this.base_params,a)},register:function(a,b,c){a==null&&(a=Luca.CollectionManager.get()),b==null&&(b="");if(!(b.length>=1))throw"Can not register with a collection manager without a key";if(a==null)throw"Can not register with a collection manager without a valid collection manager";_.isString(a)&&(a=Luca.util.nestedValue(a,window||global));if(!a)throw"Could not register with 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)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={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.apply(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}}),_.extend(Luca.Collection.prototype,{trigger:function(){return Luca.enableGlobalObserver&&(Luca.CollectionObserver||(Luca.CollectionObserver=new Luca.Observer({type:"collection"})),Luca.CollectionObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)}}),Luca.Collection.baseParams=function(a){if(a)return Luca.Collection._baseParams=a;if(_.isFunction(Luca.Collection._baseParams))return Luca.Collection._baseParams.call();if(_.isObject(Luca.Collection._baseParams))return Luca.Collection._baseParams},Luca.Collection._bootstrapped_models={},Luca.Collection.bootstrap=function(a){return _.extend(Luca.Collection._bootstrapped_models,a)},Luca.Collection.cache=function(a,b){return b?Luca.Collection._bootstrapped_models[a]=b:Luca.Collection._bootstrapped_models[a]||[]}}.call(this),function(){Luca.core.Field=Luca.View.extend({className:"luca-ui-text-field luca-ui-field",isField:!0,template:"fields/text_field",labelAlign:"top",hooks:["before:validation","after:validation","on:change"],statuses:["warning","error","success"],initialize:function(a){var b;return this.options=a!=null?a:{},_.extend(this,this.options),Luca.View.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.helperText||(this.helperText=""),this.required&&((b=this.label)!=null?!b.match(/^\*/):!void 0)&&(this.label||(this.label="*"+this.label)),this.inputStyles||(this.inputStyles=""),this.disabled&&this.disable(),this.updateState(this.state),this.placeHolder||(this.placeHolder="")},beforeRender:function(){return Luca.enableBootstrap&&this.$el.addClass("control-group"),this.required&&this.$el.addClass("required"),this.$el.html(Luca.templates[this.template](this)),this.input=$("input",this.el)},change_handler:function(a){return this.trigger("on:change",this,a)},disable:function(){return $("input",this.el).attr("disabled",!0)},enable:function(){return $("input",this.el).attr("disabled",!1)},getValue:function(){return this.input.attr("value")},render:function(){return $(this.container).append(this.$el)},setValue:function(a){return this.input.attr("value",a)},updateState:function(a){var b=this;return _(this.statuses).each(function(c){return b.$el.removeClass(c),b.$el.addClass(a)})}})}.call(this),function(){Luca.core.Container=Luca.View.extend({className:"luca-ui-container",componentClass:"luca-ui-panel",isContainer:!0,hooks:["before:components","before:layout","after:components","after:layout","first:activation"],rendered:!1,components:[],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),this.setupHooks(Luca.core.Container.prototype.hooks),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){return this.debug("container before render"),this.doLayout(),this.doComponents()},doLayout:function(){return this.debug("container do layout"),this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},doComponents:function(){return this.debug("container do components"),this.trigger("before:components",this,this.components),this.prepareComponents(),this.createComponents(),this.renderComponents(),this.trigger("after:components",this,this.components)},applyPanelConfig:function(a,b){var c,d;return d=[],a.height&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={classes:(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";")}},prepareLayout:function(){var a=this;this.debug("container prepare layout"),this.componentContainers=_(this.components).map(function(b,c){return a.applyPanelConfig.apply(a,[b,c])});if(this.appendContainers)return _(this.componentContainers).each(function(b){return a.$el.append(Luca.templates["containers/basic"](b))})},prepareComponents:function(){var a=this;return this.debug("container prepare components"),this.components=_(this.components).map(function(b,c){var d;return d=a.componentContainers[c],b.container=a.appendContainers?"#"+d.id:a.el,b})},createComponents:function(){var a,b=this;if(this.componentsCreated===!0)return;return a=this.componentIndex={name_index:{},cid_index:{}},this.components=_(this.components).map(function(b,c){var d;return d=_.isObject(b)&&b.render&&b.trigger?b:(b.ctype||(b.ctype=Luca.defaultComponentType||"template"),Luca.util.lazyComponent(b)),!d.container&&d.options.container&&(d.container=d.options.container),a&&d.cid!=null&&(a.cid_index[d.cid]=c),a&&d.name!=null&&(a.name_index[d.name]=c),d}),this.componentsCreated=!0,a},renderComponents:function(a){var b=this;return this.debugMode=a!=null?a:"",this.debug("container render components"),_(this.components).each(function(a){a.getParent=function(){return b},$(a.container).append($(a.el));try{return a.render()}catch(c){return console.log("Error Rendering Component "+(a.name||a.cid),a),console.log(c.message),console.log(c.stack)}})},firstActivation:function(){var a=this;return _(this.components).each(function(b){var c,d;c=a;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.apply(b,["first:activation",[b,c]]),b.previously_activated=!0})},select:function(a,b,c){var d;return c==null&&(c=!1),d=_(this.components).map(function(d){var e,f;return e=[],f=d[a],f===b&&e.push(d),c===!0&&d.isContainer===!0&&e.push(d.select(a,b,!0)),_.compact(e)}),_.flatten(d)},findComponentByName:function(a,b){return b==null&&(b=!1),this.findComponent(a,"name_index",b)},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,h;b==null&&(b="name"),c==null&&(c=!1),this.componentsCreated!==!0&&this.createComponents(),e=(g=this.componentIndex)!=null?g[b][a]:void 0,d=(h=this.components)!=null?h[e]:void 0;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},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c){var d;a.apply(c,[c]);if(b)return c!=null?(d=c.eachComponent)!=null?d.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.componentClass,this.el)},getComponent:function(a){return this.components[a]},rootComponent:function(){return this.getParent==null},getRootComponent:function(){return this.rootComponent()?this:this.getParent().getRootComponent()}}),Luca.register("container","Luca.core.Container")}.call(this),function(){var a;a=[],Luca.CollectionManager=function(){function b(b){this.options=b!=null?b:{},_.extend(this,this.options),_.extend(this,Backbone.Events),a.push(this),this.state=new Backbone.Model,this.collectionNames&&(this.state.set({loaded_collections_count:0,collections_count:this.collectionNames.length}),this.state.bind("change:loaded_collections_count",this.collectionCountDidChange),this.useProgressLoader&&(this.loader=new Luca.components.CollectionLoaderView({manager:this,name:"collection_loader_view"})),this.loadInitialCollections()),this}return b.prototype.__collections={},b.prototype.add=function(a,b){var c;return(c=this.currentScope())[a]||(c[a]=b)},b.prototype.allCollections=function(){return _(this.currentScope()).values()},b.prototype.create=function(a,b,c){var d,e;return b==null&&(b={}),c==null&&(c=[]),d=b.base,d||(d=this.guessCollectionClass(a)),b.private&&(b.name=""),e=new d(c,b),this.add(a,e),e},b.prototype.collectionNamespace=Luca.Collection.namespace,b.prototype.currentScope=function(){var a,b;return(a=this.getScope())?(b=this.__collections)[a]||(b[a]={}):this.__collections},b.prototype.each=function(a){return _(this.all()).each(a)},b.prototype.get=function(a){return this.currentScope()[a]},b.prototype.getScope=function(){return},b.prototype.getOrCreate=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.get(a)||this.create(a,b,c,!1)},b.prototype.guessCollectionClass=function(a){var b,c;return b=_(a).chain().capitalize().camelize().value(),c=(this.collectionNamespace||window||global)[b],c||(c=(this.collectionNamespace||window||global)[""+b+"Collection"]),c},b.prototype.loadInitialCollections=function(){var a,b=this;return a=function(a){return a.unbind("reset"),b.trigger("collection_loaded",a.name)},_(this.collectionNames).each(function(c){var d;return d=b.getOrCreate(c),d.bind("reset",function(){return a(d)}),d.fetch()})},b.prototype.collectionCountDidChange=function(){if(this.totalCollectionsCount()===this.loadedCollectionsCount())return this.trigger("all_collections_loaded")},b.prototype.totalCollectionsCount=function(){return this.state.get("collections_count")},b.prototype.loadedCollectionsCount=function(){return this.state.get("loaded_collections_count")},b.prototype.private=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.create(a,b,c,!0)},b}(),Luca.CollectionManager.destroyAll=function(){return a=[]},Luca.CollectionManager.instances=function(){return a},Luca.CollectionManager.get=function(){return _(a).last()}}.call(this),function(){Luca.SocketManager=function(){function a(a){this.options=a!=null?a:{},_.extend(Backbone.Events),this.loadTransport()}return a.prototype.connect=function(){switch(this.options.provider){case"socket.io":return this.socket=io.connect(this.options.socket_host);case"faye.js":return this.socket=new Faye.Client(this.options.socket_host)}},a.prototype.transportLoaded=function(){return this.connect()},a.prototype.transport_script=function(){switch(this.options.provider){case"socket.io":return""+this.options.transport_host+"/socket.io/socket.io.js";case"faye.js":return""+this.options.transport_host+"/faye.js"}},a.prototype.loadTransport=function(){var a,b=this;return a=document.createElement("script"),a.setAttribute("type","text/javascript"),a.setAttribute("src",this.transport_script()),a.onload=this.transportLoaded,Luca.util.isIE()&&(a.onreadystatechange=function(){if(a.readyState==="loaded")return b.transportLoaded()}),document.getElementsByTagName("head")[0].appendChild(a)},a}()}.call(this),function(){Luca.containers.SplitView=Luca.core.Container.extend({layout:"100",componentType:"split_view",containerTemplate:"containers/basic",className:"luca-ui-split-view",componentClass:"luca-ui-panel"}),Luca.register("split_view","Luca.containers.SplitView")}.call(this),function(){Luca.containers.ColumnView=Luca.core.Container.extend({componentType:"column_view",className:"luca-ui-column-view",components:[],initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments),this.setColumnWidths()},componentClass:"luca-ui-column",containerTemplate:"containers/basic",appendContainers:!0,autoColumnWidths:function(){var a,b=this;return a=[],_(this.components.length).times(function(){return a.push(parseInt(100/b.components.length))}),a},setColumnWidths:function(){return this.columnWidths=this.layout!=null?_(this.layout.split("/")).map(function(a){return parseInt(a)}):this.autoColumnWidths(),this.columnWidths=_(this.columnWidths).map(function(a){return""+a+"%"})},beforeComponents:function(){return this.debug("column_view before components"),_(this.components).each(function(a){return a.ctype||(a.ctype="panel_view")})},beforeLayout:function(){var a,b=this;return this.debug("column_view before layout"),_(this.columnWidths).each(function(a,c){return b.components[c].float="left",b.components[c].width=a}),(a=Luca.core.Container.prototype.beforeLayout)!=null?a.apply(this,arguments):void 0}}),Luca.register("column_view","Luca.containers.ColumnView")}.call(this),function(){Luca.containers.CardView=Luca.core.Container.extend({componentType:"card_view",className:"luca-ui-card-view-wrapper",activeCard:0,components:[],hooks:["before:card:switch","after:card:switch"],initialize:function(a){return this.options=a,Luca.core.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks)},componentClass:"luca-ui-card",beforeLayout:function(){var a=this;return this.cards=_(this.components).map(function(b,c){return{classes:a.componentClass,style:"display:"+(c===a.activeCard?"block":"none"),id:""+a.cid+"-"+c}})},prepareLayout:function(){var a=this;return this.card_containers=_(this.cards).map(function(b,c){return a.$el.append(Luca.templates["containers/basic"](b)),$("#"+b.id)})},prepareComponents:function(){var a=this;return this.components=_(this.components).map(function(b,c){var d;return d=a.cards[c],b.container="#"+d.id,b})},activeComponent:function(){return this.getComponent(this.activeCard)},cycle:function(){var a;return a=this.activeCard<this
2
- .components.length-1?this.activeCard+1:0,this.activate(a)},find:function(a){return this.findComponentByName(a,!0)},firstActivation:function(){return this.activeComponent().trigger("first:activation",this,this.activeComponent())},activate:function(a,b,c){var d,e,f,g,h,i;b==null&&(b=!1),_.isFunction(b)&&(b=!1,c=b);if(a===this.activeCard)return;e=this.activeComponent(),d=this.getComponent(a),d||(a=this.indexOf(a),d=this.getComponent(a));if(!d)return;b||(this.trigger("before:card:switch",e,d),e!=null&&(f=e.trigger)!=null&&f.apply(e,["before:deactivation",this,e,d]),d!=null&&(g=d.trigger)!=null&&g.apply(e,["before:activation",this,e,d])),_(this.card_containers).each(function(a){return a.hide()}),d.previously_activated||(d.trigger("first:activation"),d.previously_activated=!0),$(d.container).show(),this.activeCard=a,b||(this.trigger("after:card:switch",e,d),(h=e.trigger)!=null&&h.apply(e,["deactivation",this,e,d]),(i=d.trigger)!=null&&i.apply(d,["activation",this,e,d]));if(_.isFunction(c))return c.apply(this,[this,e,d])}}),Luca.register("card_view","Luca.containers.CardView")}.call(this),function(){Luca.containers.ModalView=Luca.core.Container.extend({componentType:"modal_view",className:"luca-ui-modal-view",components:[],renderOnInitialize:!0,showOnRender:!1,hooks:["before:show","before:hide"],defaultModalOptions:{minWidth:375,maxWidth:375,minHeight:550,maxHeight:550,opacity:80,onOpen:function(a){return this.onOpen.apply(this),this.onModalOpen.apply(a,[a,this])},onClose:function(a){return this.onClose.apply(this),this.onModalClose.apply(a,[a,this])}},modalOptions:{},initialize:function(a){var b=this;return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks),_(this.defaultModalOptions).each(function(a,c){var d;return(d=b.modalOptions)[c]||(d[c]=a)}),this.modalOptions.onOpen=_.bind(this.modalOptions.onOpen,this),this.modalOptions.onClose=_.bind(this.modalOptions.onClose,this)},onOpen:function(){return!0},onClose:function(){return!0},getModal:function(){return this.modal},onModalOpen:function(a,b){return b.modal=a,a.overlay.show(),a.container.show(),a.data.show()},onModalClose:function(a,b){return $.modal.close()},prepareLayout:function(){return $("body").append(this.$el)},prepareComponents:function(){var a=this;return this.components=_(this.components).map(function(b,c){return b.container=a.el,b})},afterInitialize:function(){this.$el.hide();if(this.renderOnInitialize)return this.render()},afterRender:function(){if(this.showOnRender)return this.show()},wrapper:function(){return $(this.$el.parent())},show:function(){return this.trigger("before:show",this),this.$el.modal(this.modalOptions)},hide:function(){return this.trigger("before:hide",this)}}),Luca.register("modal_view","Luca.containers.ModalView")}.call(this),function(){Luca.containers.PanelView=Luca.core.Container.extend({className:"luca-ui-panel",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},afterLayout:function(){var a;if(this.template)return a=(Luca.templates||JST)[this.template](this),this.$el.html(a)},render:function(){return $(this.container).append(this.$el)},afterRender:function(){var a,b=this;(a=Luca.core.Container.prototype.afterRender)!=null&&a.apply(this,arguments);if(this.css)return console.log("Yes Yes Yall",this.css,this.$el),_(this.css).each(function(a,c){return b.$el.css(c,a)})}})}.call(this),function(){Luca.containers.TabView=Luca.containers.CardView.extend({events:{"click ul.nav-tabs li":"select"},hooks:["before:select","after:select"],componentType:"tab_view",className:"luca-ui-tab-view tabbable",tab_position:"top",tabVerticalOffset:"50px",initialize:function(a){return this.options=a!=null?a:{},Luca.containers.CardView.prototype.initialize.apply(this,arguments),_.bindAll(this,"select","highlightSelectedTab"),this.setupHooks(this.hooks),this.bind("after:card:switch",this.highlightSelectedTab)},activeTabSelector:function(){return this.tabSelectors().eq(this.activeCard)},prepareLayout:function(){var a=this;return this.card_containers=_(this.cards).map(function(b,c){return a.$(".tab-content").append(Luca.templates["containers/basic"](b)),$("#"+b.id)})},beforeLayout:function(){return this.$el.addClass("tabs-"+this.tab_position),this.tab_position==="below"?(this.$el.append(Luca.templates["containers/tab_view"](this)),this.$el.append(Luca.templates["containers/tab_selector_container"](this))):(this.$el.append(Luca.templates["containers/tab_selector_container"](this)),this.$el.append(Luca.templates["containers/tab_view"](this))),Luca.containers.CardView.prototype.beforeLayout.apply(this,arguments)},beforeRender:function(){var a;(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.activeTabSelector().addClass("active");if(Luca.enableBootstrap&&this.tab_position==="left"||this.tab_position==="right"){this.$el.addClass("grid-12"),this.tabContainerWrapper().addClass("grid-3"),this.tabContentWrapper().addClass("grid-9");if(this.tabVerticalOffset)return this.tabContainerWrapper().css("padding-top",this.tabVerticalOffset)}},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},select:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("before:select",this),this.activate(c.data("target")),this.trigger("after:select",this)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return $("ul#"+this.cid+"-tabs-nav")},tabSelectors:function(){return $("li.tab-selector",this.tabContainer())}})}.call(this),function(){Luca.containers.Viewport=Luca.containers.CardView.extend({activeItem:0,className:"luca-ui-viewport",fullscreen:!0,initialize:function(a){this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments);if(this.fullscreen)return $("html,body").addClass("luca-ui-fullscreen")},render:function(){return console.log("Rendering Viewport"),this.$el.addClass("luca-ui-viewport")}})}.call(this),function(){}.call(this),function(){Luca.components.Template=Luca.View.extend({initialize:function(options){this.options=options!=null?options:{},Luca.View.prototype.initialize.apply(this,arguments);if(!this.template&&!this.markup)throw"Templates must specify which template / markup to use";if(_.isString(this.templateContainer))return this.templateContainer=eval("(window || global)."+this.templateContainer)},templateContainer:"Luca.templates",beforeRender:function(){return _.isUndefined(this.templateContainer)&&(this.templateContainer=JST),this.$el.html(this.markup||this.templateContainer[this.template](this.options))},render:function(){return $(this.container).append(this.$el)}}),Luca.register("template","Luca.components.Template")}.call(this),function(){Luca.Application=Luca.containers.Viewport.extend({components:[{ctype:"controller",name:"main_controller",defaultCard:"welcome",components:[{ctype:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}]}],initialize:function(a){var b=this;return this.options=a!=null?a:{},Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.collectionManager=new Luca.CollectionManager,this.state=new Backbone.Model(this.defaultState),this.bind("ready",function(){return b.render()})},activeView:function(){var a;return(a=this.activeSubSection())?this.view(a):this.view(this.activeSection())},activeSubSection:function(){return this.get("active_sub_section")},activeSection:function(){return this.get("active_section")},afterComponents:function(){var a,b,c,d=this;return(a=Luca.containers.Viewport.prototype.afterComponents)!=null&&a.apply(this,arguments),(b=this.getMainController())!=null&&b.bind("after:card:switch",function(a,b){return d.state.set({active_section:b.name})}),(c=this.getMainController())!=null?c.each(function(a){if(a.ctype.match(/controller$/))return a.bind("after:card:switch",function(a,b){return d.state.set({active_sub_section:b.name})})}):void 0},beforeRender:function(){var a;return(a=Luca.containers.Viewport.prototype.beforeRender)!=null?a.apply(this,arguments):void 0},boot:function(){return console.log("Sup?"),this.trigger("ready")},collection:function(){return this.collectionManager.getOrCreate.apply(this.collectionManager,arguments)},get:function(a){return this.state.get(a)},getMainController:function(){return this.view("main_controler")},set:function(a){return this.state.set(a)},view:function(a){return Luca.cache(a)}})}.call(this),function(){Luca.components.Toolbar=Luca.core.Container.extend({className:"luca-ui-toolbar",position:"bottom",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},prepareComponents:function(){var a=this;return _(this.components).each(function(b){return b.container=a.el})},render:function(){return $(this.container).append(this.el)}}),Luca.register("toolbar","Luca.components.Toolbar")}.call(this),function(){Luca.components.CollectionLoaderView=Luca.components.Template.extend({className:"luca-ui-collection-loader-view",template:"components/collection_loader_view",initialize:function(a){return this.options=a!=null?a:{},Luca.components.Template.prototype.initialize.apply(this,arguments),this.container||(this.container=$("body")),this.manager||(this.manager=Luca.CollectionManager.get()),this.setupBindings()},modalContainer:function(){return $("#progress-modal",this.el)},setupBindings:function(){var a=this;return this.manager.bind("collection_loaded",function(b){var c,d,e;return c=a.manager.loadedCollectionsCount(),e=a.manager.totalCollectionsCount(),d=parseInt(c/e*100),a.modalContainer().find(".progress .bar").attr("style","width: "+d+"%;"),a.modalContainer().find(".message").html("Loaded "+_(b).chain().humanize().titleize().value()+"...")}),this.manager.bind("all_collections_loaded",function(){return a.modalContainer().find(".message").html("All done!"),_.delay(function(){return a.modalContainer().modal("hide")},400)})}}),Luca.register("collection_loader_view","Luca.components.CollectionLoaderView")}.call(this),function(){Luca.components.Controller=Luca.containers.CardView.extend({initialize:function(a){var b;this.options=a,Luca.containers.CardView.prototype.initialize.apply(this,arguments),this.defaultCard||(this.defaultCard=(b=this.components[0])!=null?b.name:void 0);if(!this.defaultCard)throw"Controllers must specify a defaultCard property and/or the first component must have a name";return this.state=new Backbone.Model({active_section:this.defaultCard})},each:function(a){var b=this;return _(this.components).each(function(c){return a.apply(b,[c])})},"default":function(a){return this.navigate_to(this.defaultCard,a)},navigate_to:function(a,b){var c=this;return a||(a=this.defaultCard),this.activate(a,!1,function(a,d,e){c.state.set({active_section:e.name});if(_.isFunction(b))return b.apply(e)}),this.find(a)}})}.call(this),function(){Luca.fields.ButtonField=Luca.core.Field.extend({form_field:!0,readOnly:!0,events:{"click input":"click_handler"},hooks:["button:click"],className:"luca-ui-field luca-ui-button-field",template:"fields/button_field",click_handler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("button:click")},initialize:function(a){var b;this.options=a!=null?a:{},_.extend(this.options),_.bindAll(this,"click_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments);if((b=this.icon_class)!=null?b.length:void 0)return this.template="fields/button_field_link"},afterInitialize:function(){this.input_id||(this.input_id=_.uniqueId("button")),this.input_name||(this.input_name=this.name||(this.name=this.input_id)),this.input_value||(this.input_value=this.label||(this.label=this.text)),this.input_type||(this.input_type="button"),this.input_class||(this.input_class=this["class"]),this.icon_class||(this.icon_class="");if(this.icon_class.length&&!this.icon_class.match(/^icon-/))return this.icon_class="icon-"+this.icon_class},setValue:function(){return!0}}),Luca.register("button_field","Luca.fields.ButtonField")}.call(this),function(){Luca.fields.CheckboxField=Luca.core.Field.extend({form_field:!0,events:{"change input":"change_handler"},change_handler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("on:change",this,a),b.checked===!0?this.trigger("checked"):this.trigger("unchecked")},className:"luca-ui-checkbox-field luca-ui-field",template:"fields/checkbox_field",hooks:["checked","unchecked"],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"change_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=1),this.label||(this.label=this.name)},setValue:function(a){return this.input.attr("checked",a)},getValue:function(){return this.input.attr("checked")===!0}}),Luca.register("checkbox_field","Luca.fields.CheckboxField")}.call(this),function(){Luca.fields.FileUploadField=Luca.core.Field.extend({form_field:!0,template:"fields/file_upload_field",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.helperText||(this.helperText="")}}),Luca.register("file_upload_field","Luca.fields.FileUploadField")}.call(this),function(){Luca.fields.HiddenField=Luca.core.Field.extend({form_field:!0,template:"fields/hidden_field",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=this.value),this.label||(this.label=this.name)}}),Luca.register("hidden_field","Luca.fields.HiddenField")}.call(this),function(){Luca.fields.SelectField=Luca.core.Field.extend({form_field:!0,events:{"change select":"change_handler"},hooks:["after:select"],className:"luca-ui-select-field luca-ui-field",template:"fields/select_field",includeBlank:!0,blankValue:"",blankText:"Select One",initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"change_handler","populateOptions","beforeFetch"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name);if(_.isUndefined(this.retainValue))return this.retainValue=!0},afterInitialize:function(){var a;if((a=this.collection)!=null?a.data:void 0)this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.parseData();try{this.configure_collection()}catch(b){console.log("Error Configuring Collection",this,b.message)}return this.collection.bind("before:fetch",this.beforeFetch),this.collection.bind("reset",this.populateOptions)},parseData:function(){var a=this;return this.collection.data=_(this.collection.data).map(function(b){var c;return _.isArray(b)?(c={},c[a.valueField]=b[0],c[a.displayField]=b[1],c):b})},afterRender:function(){var a,b;return this.input=$("select",this.el),((a=this.collection)!=null?(b=a.models)!=null?b.length:void 0:void 0)>0?this.populateOptions():this.collection.trigger("reset")},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.input.html("");if(this.includeBlank)return this.input.append("<option value='"+this.blankValue+"'>"+this.blankText+"</option>")},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="<option "+e+" value='"+f+"'>"+c+"</option>",b.input.append(d)}),this.trigger("after:populate:options",this),this.setValue(this.currentValue)}}),Luca.register("select_field","Luca.fields.SelectField")}.call(this),function(){Luca.fields.TextAreaField=Luca.core.Field.extend({form_field:!0,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"),Luca.core.Field.prototype.initialize.apply(this,arguments),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.inputStyles||(this.inputStyles="height:"+this.height+";width:"+this.width)},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)}}),Luca.register("text_area_field","Luca.fields.TextAreaField")}.call(this),function(){Luca.fields.TextField=Luca.core.Field.extend({form_field:!0,events:{"keydown input":"keydown_handler","blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",initialize:function(a){this.options=a!=null?a:{},_.bindAll(this,"keydown_handler","blur_handler","focus_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend);if(this.append)return this.$el.addClass("input-append"),this.addOn=this.append},keydown_handler:_.throttle(function(a){return this.change_handler.apply(this,arguments)},300),blur_handler:function(a){var b,c;return b=c=$(a.currentTarget)},focus_handler:function(a){var b,c;return b=c=$(a.currentTarget)},change_handler:function(a){return this.trigger("on:change",this,a)}}),Luca.register("text_field","Luca.fields.TextField")}.call(this),function(){Luca.fields.TypeAheadField=Luca.fields.TextField.extend({form_field:!0,className:"luca-ui-field",afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name)}})}.call(this),function(){Luca.components.FormButtonToolbar=Luca.components.Toolbar.extend({className:"luca-ui-form-toolbar form-actions",position:"bottom",includeReset:!1,render:function(){return $(this.container).append(this.el)},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"})}}),Luca.register("form_button_toolbar","Luca.components.FormButtonToolbar")}.call(this),function(){Luca.components.FormView=Luca.core.Container.extend({tagName:"form",className:"luca-ui-form-view",hooks:["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"],events:{"click .submit-button":"submitHandler","click .reset-button":"resetHandler"},toolbar:!0,initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments),_.bindAll(this,"submitHandler","resetHandler","renderToolbars"),this.state||(this.state=new Backbone.Model),this.setupHooks(this.hooks),this.legend||(this.legend=""),this.configureToolbars(),this.applyStyles()},addBootstrapFormControls:function(){var a=this;return this.bind("after:render",function(){var b;return b=a.$(".toolbar-container.bottom"),b.addClass("form-controls"),b.html(a.formControlsTemplate||Luca.templates["components/bootstrap_form_controls"](a))})},applyStyles:function(){Luca.enableBootstrap&&this.applyBootstrapStyles(),this.labelAlign&&this.$el.addClass("label-align-"+this.labelAlign);if(this.fieldLayoutClass)return this.$el.addClass(this.fieldLayoutClass)},applyBootstrapStyles:function(){this.labelAlign==="left"&&(this.inlineForm=!0),this.well&&this.$el.addClass("well"),this.searchForm&&this.$el.addClass("form-search"),this.horizontalForm&&this.$el.addClass("form-horizontal");if(this.inlineForm)return this.$el.addClass("form-inline")},configureToolbars:function(){if(Luca.enableBootstrap&&this.toolbar===!0)return this.addBootstrapFormControls();this.toolbar===!0&&(this.toolbars=[{ctype:"form_button_toolbar",includeReset:!0,position:"bottom"}]);if(this.toolbars&&this.toolbars.length)return this.bind("after:render",_.once(this.renderToolbars))},resetHandler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("before:reset",this),this.reset(),this.trigger("after:reset",this)},submitHandler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("before:submit",this),this.submit()},beforeLayout:function(){var a;return(a=Luca.core.Container.prototype.beforeLayout)!=null&&a.apply(this,arguments),this.$el.html(Luca.templates["components/form_view"](this))},prepareComponents:function(){var a;return a=$(".form-view-body",this.el),_(this.components).each(function(b){return b.container=a})},render:function(){return $(this.container).append(this.$el)},wrapper:function(){return this.$el.parents(".luca-ui-form-view-wrapper")},toolbarContainers:function(a){return a==null&&(a="bottom"),$(".toolbar-container."+a,this.wrapper()).first()},renderToolbars:function(){var a=this;return _(this.toolbars).each(function(b){return b.container=$("#"+a.cid+"-"+b.position+"-toolbar-container"),b=Luca.util.lazyComponent(b),b.render()})},getField:function(a){return _(this.getFields("name",a)).first()},getFields:function(a,b){var c;return c=this.select("isField",!0,!0),c.length>0&&a&&b&&(c=_(c).select(function(c){var d,e;return d=c[a],d==null?!1:(e=_.isFunction(d)?d():d,b===e)})),c},loadModel:function(a){var b,c,d,e;this.current_model=a,d=this,c=this.getFields(),this.trigger("before:load",this,this.current_model),this.current_model&&((e=this.current_model.beforeFormLoad)!=null&&e.apply(this.current_model,this),b="before:load:"+(this.current_model.isNew()?"new":"existing"),this.trigger(b,this,this.current_model)),this.setValues(this.current_model),this.trigger("after:load",this,this.current_model);if(this.current_model)return this.trigger("after:load:"+(this.current_model.isNew()?"new":"existing"),this,this.current_model)},reset:function(){return this.loadModel(this.current_model)},clear:function(){var a=this;return this.current_model=this.defaultModel!=null?this.defaultModel():void 0,_(this.getFields()).each(function(b){try{return b.setValue("")}catch(c){return console.log("Error Clearing",a,b)}})},setValues:function(a,b){var c,d=this;b==null&&(b={}),a||(a=this.currentModel()),c=this.getFields(),_(c).each(function(b){var c,e;c=b.input_name||b.name,(e=a[c])&&_.isFunction(e)&&(e=e.apply(d)),!e&&Luca.isBackboneModel(a)&&(e=a.get(c));if(b.readOnly!==!0)return b!=null?b.setValue(e):void 0});if(b.silent!=null!=1)return this.syncFormWithModel()},getValues:function(a){return a||(a={}),a.reject_blank==null&&(a.reject_blank=!0),a.skip_buttons==null&&(a.skip_buttons=!0),_(this.getFields()).inject(function(b,c){var d,e,f;return f=c.getValue(),d=c.input_name||c.name,e=!1,a.skip_buttons&&c.ctype==="button_field"&&(e=!0),a.reject_blank===!0&&_.isBlank(f)&&(e=!0),c.input_name==="id"&&_.isBlank(f)&&(e=!0),e!==!0&&(b[d]=f),b},{})},submit_success_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),b&&(b!=null?b.success:void 0)===!0?this.trigger("after:submit:success",this,a,b):this.trigger("after:submit:error",this,a,b)},submit_fatal_error_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),this.trigger("after:submit:fatal_error",this,a,b)},submit:function(a,b){a==null&&(a=!0),b==null&&(b={}),_.bindAll(this,"submit_success_handler","submit_fatal_error_handler"),b.success||(b.success=this.submit_success_handler),b.error||(b.error=this.submit_fatal_error_handler),this.syncFormWithModel();if(!a)return;return this.current_model.save(this.current_model.toJSON(),b)},currentModel:function(a){return a==null&&(a={}),(a===!0||(a!=null?a.refresh:void 0)===!0)&&this.syncFormWithModel(),this.current_model},syncFormWithModel:function(){var a;return(a=this.current_model)!=null?a.set(this.getValues()):void 0},setLegend:function(a){return this.legend=a,$("fieldset legend",this.el).first().html(this.legend)}}),Luca.register("form_view","Luca.components.FormView")}.call(this),function(){Luca.components.GridView=Luca.View.extend({events:{"dblclick .grid-view-row":"double_click_handler","click .grid-view-row":"click_handler"},className:"luca-ui-grid-view",scrollable:!0,emptyText:"No Results To display",tableStyle:"striped",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.modules.Deferrable),Luca.View.prototype.initialize.apply(this,arguments),_.bindAll(this,"double_click_handler","click_handler"),this.configure_collection(),this.collection.bind("reset",function(a){return b.refresh(),b.trigger("after:collection:load",a)})},beforeRender:function(){var a,b=this;return this.trigger("before:grid:render",this),this.scrollable&&this.$el.addClass("scrollable-grid-view"),this.$el.html(Luca.templates["components/grid_view"]()),this.table=$("table.luca-ui-grid-view",this.el),this.header=$("thead",this.table),this.body=$("tbody",this.table),this.footer=$("tfoot",this.table),Luca.enableBootstrap&&this.table.addClass("table"),_((a=this.tableStyle)!=null?a.split(" "):void 0).each(function(a){return b.table.addClass("table-"+a)}),this.scrollable&&this.setDimensions(),this.renderHeader(),this.emptyMessage(),this.renderToolbars(),$(this.container).append(this.$el)},toolbarContainers:function(a){return a==null&&(a="bottom"),$(".toolbar-container."+a,this.el)},renderToolbars:function(){var a=this;return _(this.toolbars).each(function(b){return b=Luca.util.lazyComponent(b),b.container=a.toolbarContainers(b.position),b.render()})},setDimensions:function(a){var b=this;return this.height||(this.height=285),$(".grid-view-body",this.el).height(this.height),$("tbody.scrollable",this.el).height(this.height-23),this.container_width=function(){return $(b.container).width()}(),this.width=this.container_width>0?this.container_width:756,$(".grid-view-body",this.el).width(this.width),$(".grid-view-body table",this.el).width(this.width),this.setDefaultColumnWidths()},resize:function(a){var b,c,d=this;b=a-this.width,this.width=a,$(".grid-view-body",this.el).width(this.width),$(".grid-view-body table",this.el).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]},afterRender:function(){return this.refresh(),this.trigger("after:grid:render",this)},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;":"","<th style='"+c+"' class='column-"+b+"'>"+a.header+"</th>"}),this.header.append("<tr>"+a+"</tr>")},render_row:function(a,b){var c,d,e,f,g=this;return e=(a!=null?a.get:void 0)&&(a!=null?a.attributes:void 0)?a.get("id"):"",this.trigger("before:render:row",a,b),d=_(this.columns).map(function(b,c){var d,e,f;return f=g.cell_renderer(a,b,c),e=b.width?"width:"+b.width+"px;":"",d=_.isUndefined(f)?"":f,"<td style='"+e+"' class='column-"+c+"'>"+d+"</td>"}),this.alternateRowClasses&&(c=b%2===0?"even":"odd"),(f=this.body)!=null?f.append("<tr data-record-id='"+e+"' data-row-index='"+b+"' class='grid-view-row "+c+"' id='row-"+b+"'>"+d+"</tr>"):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),$(".grid-view-row",this.body).removeClass("selected-row"),b.addClass("selected-row")}}),Luca.register("grid_view","Luca.components.GridView")}.call(this),function(){Luca.components.RecordManager=Luca.containers.CardView.extend({events:{"click .record-manager-grid .edit-link":"edit_handler","click .record-manager-filter .filter-button":"filter_handler","click .record-manager-filter .reset-button":"reset_filter_handler","click .add-button":"add_handler","click .refresh-button":"filter_handler","click .back-to-search-button":"back_to_search_handler"},record_manager:!0,initialize:function(a){var b=this;this.options=a!=null?a:{},Luca.containers.CardView.prototype.initialize.apply(this,arguments);if(!this.name)throw"Record Managers must specify a name";return _.bindAll(this,"add_handler","edit_handler","filter_handler","reset_filter_handler"),this.filterConfig&&_.extend(this.components[0][0],this.filterConfig),this.gridConfig&&_.extend(this.components[0][1],this.gridConfig),this.editorConfig&&_.extend(this.components[1][0],this.editorConfig),this.bind("after:card:switch",function(){b.activeCard===0&&b.trigger("activation:search",b);if(b.activeCard===1)return b.trigger("activation:editor",b)})},components:[{ctype:"split_view",relayFirstActivation:!0,components:[{ctype:"form_view"},{ctype:"grid_view"}]},{ctype:"form_view"}],getSearch:function(a,b){return a==null&&(a=!1),b==null&&(b=!0),a===!0&&this.activate(0),b===!0&&this.getEditor().clear(),_.first(this.components)},getFilter:function(){return _.first(this.getSearch().components)},getGrid:function(){return _.last(this.getSearch().components)},getCollection:function(){return this.getGrid().collection},getEditor:function(a,b){var c=this;return a==null&&(a=!1),b==null&&(b=!1),a===!0&&this.activate(1,function(a,b,c){return c.reset()}),_.last(this.components)},beforeRender:function(){var a;return this.$el.addClass(""+this.resource+"-manager"),(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.$el.addClass(""+this.resource+" record-manager"),this.$el.data("resource",this.resource),$(this.getGrid().el).addClass(""+this.resource+" record-manager-grid"),$(this.getFilter().el).addClass(""+this.resource+" record-manager-filter"),$(this.getEditor().el).addClass(""+this.resource+" record-manager-editor")},afterRender:function(){var a,b,c,d,e,f,g=this;return(f=Luca.containers.CardView.prototype.afterRender)!=null&&f.apply(this,arguments),e=this,d=this.getGrid(),c=this.getFilter(),b=this.getEditor(),a=this.getCollection(),d.bind("row:double:click",function(a,c,d){return e.getEditor(!0),b.loadModel
3
- (c)}),b.bind("before:submit",function(){return $(".form-view-flash-container",g.el).html(""),$(".form-view-body",g.el).spin("large")}),b.bind("after:submit",function(){return $(".form-view-body",g.el).spin(!1)}),b.bind("after:submit:fatal_error",function(){return $(".form-view-flash-container",g.el).append("<li class='error'>There was an internal server error saving this record. Please contact developers@benchprep.com to report this error.</li>"),$(".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("<li class='error'>"+a+"</li>")})}),b.bind("after:submit:success",function(a,b,c){return $(".form-view-flash-container",g.el).append("<li class='success'>Successfully Saved Record</li>"),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(){Luca.Router=Backbone.Router.extend({routes:{"":"default"},initialize:function(a){var b=this;return this.options=a,_.extend(this,this.options),this.routeHandlers=_(this.routes).values(),_(this.routeHandlers).each(function(a){return b.bind("route:"+a,function(){return b.trigger.apply(b,["change:navigation",a].concat(_(arguments).flatten()))})})},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(){}.call(this);
1
+ (function(){_.mixin(_.string),window.Luca={VERSION:"0.7.4",core:{},containers:{},components:{},modules:{},fields:{},util:{},registry:{classes:{},namespaces:["Luca.containers","Luca.components"]},component_cache:{cid_index:{},name_index:{}}},Luca.enableBootstrap=!0,Luca.isBackboneModel=function(a){return _.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 _.isFunction(a!=null?a.render:void 0)&&!_.isUndefined(a!=null?a.el:void 0)},Luca.isBackboneCollection=function(a){return _.isFunction(a!=null?a.fetch:void 0)&&_.isFunction(a!=null?a.reset:void 0)},Luca.registry.addNamespace=function(a){return Luca.registry.namespaces.push(a),Luca.registry.namespaces=_(Luca.registry.namespaces).uniq()},Luca.cache=function(a,b){var c;return b!=null&&(Luca.component_cache.cid_index[a]=b),b=Luca.component_cache.cid_index[a],(b!=null?b.component_name:void 0)!=null?Luca.component_cache.name_index[b.component_name]=b.cid:(b!=null?b.name:void 0)!=null&&(Luca.component_cache.name_index[b.name]=b.cid),b!=null?b:(c=Luca.component_cache.name_index[a],Luca.component_cache.cid_index[c])},Luca.util.nestedValue=function(a,b){return _(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)},Luca.registry.lookup=function(a){var b,c,d;return b=Luca.registry.classes[a],b!=null?b:(c=_.camelize(_.capitalize(a)),d=_(Luca.registry.namespaces).map(function(a){return Luca.util.nestedValue(a,window||global)}),_.first(_.compact(_(d).map(function(a){return a[c]}))))},Luca.util.lazyComponent=function(config){var componentClass,constructor,ctype;ctype=config.ctype,componentClass=Luca.registry.lookup(ctype);if(!componentClass)throw"Invalid Component Type: "+ctype+". Did you forget to register it?";return constructor=eval(componentClass),new constructor(config)},Luca.register=function(a,b){var c;c=Luca.registry.classes[a];if(c!=null)throw"Can not register component with the signature "+a+". Already exists";return Luca.registry.classes[a]=b},Luca.available_templates=function(a){var b;return a==null&&(a=""),b=_(Luca.templates).keys(),a.length>0?_(b).select(function(b){return b.match(a)}):b},Luca.util.isIE=function(){try{return Object.defineProperty({},"",{}),!1}catch(a){return!0}},$(function(){return $("body").addClass("luca-ui-enabled")}())}).call(this),function(){Luca.modules.Deferrable={configure_collection:function(a){var b,c,d;a==null&&(a=!0);if(!this.collection)return;_.isString(this.collection)&&(b=(c=Luca.CollectionManager)!=null?c.get():void 0)&&(this.collection=b.getOrCreate(this.collection)),this.collection&&_.isFunction(this.collection.fetch)&&_.isFunction(this.collection.reset)||(this.collection=new Luca.Collection(this.collection.initial_set,this.collection));if((d=this.collection)!=null?d.deferrable_trigger:void 0)this.deferrable_trigger=this.collection.deferrable_trigger;if(a)return this.deferrable=this.collection}}}.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(){Luca.templates||(Luca.templates={}),Luca.templates["components/bootstrap_form_controls"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='form-actions'>\n <a class='btn btn-primary submit-button'>\n <i class='icon-ok icon-white'></i>\n Save Changes\n </a>\n <a class='btn reset-button cancel-button'>\n <i class='icon-remove'></i>\n Cancel\n </a>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/collection_loader_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='modal' id='progress-model' stype='display: none;'>\n <div class='progress progress-info progress-striped active'>\n <div class='bar' style='width: 0%;'></div>\n </div>\n <div class='message'>\n Initializing...\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/form_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-form-view-wrapper' id='",cid,"-wrapper'>\n <div class='form-view-header'>\n <div class='toolbar-container top' id='",cid,"-top-toolbar-container'></div>\n </div>\n "),legend?__p.push("\n <fieldset>\n <legend>\n ",legend,"\n </legend>\n <div class='form-view-flash-container'></div>\n <div class='form-view-body'></div>\n </fieldset>\n "):__p.push("\n <ul class='form-view-flash-container'></ul>\n <div class='form-view-body'></div>\n "),__p.push("\n <div class='form-view-footer'>\n <div class='toolbar-container bottom' id='",cid,"-bottom-toolbar-container'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/grid_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-grid-view-wrapper'>\n <div class='grid-view-header'>\n <div class='toolbar-container top'></div>\n </div>\n <div class='grid-view-body'>\n <table cellpadding='0' cellspacing='0' class='luca-ui-grid-view scrollable-table' width='100%'>\n <thead class='fixed'></thead>\n <tbody class='scrollable'></tbody>\n </table>\n </div>\n <div class='grid-view-footer'>\n <div class='toolbar-container bottom'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/grid_view_empty_text"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='empty-text-wrapper'>\n <p>\n ",text,"\n </p>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/basic"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='",classes,"' id='",id,"' style='",style,"'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/tab_selector_container"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{}){__p.push("<div class='tab-selector-container' id='",cid,"-tab-selector'>\n <ul class='nav nav-tabs' id='",cid,"-tabs-nav'>\n ");for(var i=0;i<components.length;i++){__p.push("\n ");var component=components[i];__p.push("\n <li class='tab-selector' data-target='",i,"'>\n <a data-target='",i,"'>\n ",component.title,"\n </a>\n </li>\n ")}__p.push("\n </ul>\n</div>\n")}return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/tab_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='tab-content' id='",cid,"-tab-view-content'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/toolbar_wrapper"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-toolbar-wrapper' id='",id,"'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/button_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label>&nbsp</label>\n<input class='btn ",input_class,"' id='",input_id,"' style='",inputStyles,"' type='",input_type,"' value='",input_value,"' />\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/button_field_link"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<a class='btn ",input_class,"'>\n "),icon_class.length&&__p.push("\n <i class='",icon_class,"'></i>\n "),__p.push("\n ",input_value,"\n</a>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/checkbox_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n <input name='",input_name,"' style='",inputStyles,"' type='checkbox' value='",input_value,"' />\n</label>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/file_upload_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<input id='",input_id,"' name='",input_name,"' style='",inputStyles,"' type='file' />\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/hidden_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<input id='",input_id,"' name='",input_name,"' type='hidden' value='",input_value,"' />\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/select_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<select id='",input_id,"' name='",input_name,"' style='",inputStyles,"'></select>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/text_area_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<textarea class='",input_class,"' id='",input_id,"' name='",input_name,"' style='",inputStyles,"'></textarea>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/text_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label class='control-label' for='",input_id,"'>\n ",label,"\n</label>\n"),typeof addOn!="undefined"&&__p.push("\n<span class='add-on'>\n ",addOn,"\n</span>\n"),__p.push("\n<input id='",input_id,"' name='",input_name,"' placeholder='",placeHolder,"' style='",inputStyles,"' type='text' />\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["sample/contents"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<p>Sample Contents</p>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["sample/welcome"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("welcome.luca\n");return __p.join("")}}.call(this),function(){var a=Array.prototype.slice;Luca.Observer=function(){function b(b){var c=this;this.options=b!=null?b:{},_.extend(this,Backbone.Events),this.type=this.options.type,this.options.debugAll&&this.bind("event",function(){var b,d;return d=arguments[0],b=2<=arguments.length?a.call(arguments,1):[],console.log("Observed "+c.type+" "+(d.name||d.id||d.cid),d,_(b).flatten())})}return b.prototype.relay=function(){var b,c;return c=arguments[0],b=2<=arguments.length?a.call(arguments,1):[],this.trigger("event",c,b),this.trigger("event:"+b[0],c,b.slice(1))},b}(),Luca.Observer.enableObservers=function(a){return a==null&&(a={}),Luca.enableGlobalObserver=!0,Luca.ViewObserver=new Luca.Observer(_.extend(a,{type:"view"})),Luca.CollectionObserver=new Luca.Observer(_.extend(a,{type:"collection"}))}}.call(this),function(){Luca.View=Backbone.View.extend({base:"Luca.View"}),Luca.View.originalExtend=Backbone.View.extend,Luca.View.extend=function(a){var b;return b=a.render,b||(b=function(){var a;return a=_.isFunction(this.container)?this.container():this.container,!$(a)||!this.$el?this:($(a).append(this.$el),this)}),a.render=function(){var a=this;return this.deferrable?(this.trigger("before:render",this),this.deferrable.bind(this.deferrable_event,_.once(function(){return b.apply(a,arguments),a.trigger("after:render",a)})),this.deferrable_trigger||(this.immediate_trigger=!0),this.immediate_trigger===!0?this.deferrable.fetch():this.bind(this.deferrable_trigger,_.once(function(){return a.deferrable.fetch()}))):(this.trigger("before:render",this),b.apply(this,arguments),this.trigger("after:render",this))},Luca.View.originalExtend.apply(this,[a])},_.extend(Luca.View.prototype,{debug:function(){var a,b,c,d;if(!this.debugMode&&window.LucaDebugMode==null)return;d=[];for(b=0,c=arguments.length;b<c;b++)a=arguments[b],d.push(console.log([this.name||this.cid,a]));return d},trigger:function(){return Luca.enableGlobalObserver&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)},hooks:["after:initialize","before:render","after:render","first:activation","activation","deactivation"],deferrable_event:"reset",initialize:function(a){var b,c=this;return this.options=a!=null?a:{},_.extend(this,this.options),this.name!=null&&(this.cid=_.uniqueId(this.name)),Luca.cache(this.cid,this),b=_(Luca.View.prototype.hooks.concat(this.hooks)).uniq(),this.setupHooks(b),this.autoBindEventHandlers===!0&&_(this.events).each(function(a,b){if(_.isString(a))return _.bindAll(c,a)}),this.trigger("after:initialize",this),this.registerCollectionEvents(),this.delegateEvents()},$container:function(){return $(this.container)},setupHooks:function(a){var b=this;return a||(a=this.hooks),_(a).each(function(a){var c,d,e;return d=a.split(":"),e=d.shift(),d=_(d).map(function(a){return _.capitalize(a)}),c=e+d.join(""),b.bind(a,function(){if(b[c])return b[c].apply(b,arguments)})})},getCollectionManager:function(){var a;return this.collectionManager||((a=Luca.CollectionManager.get)!=null?a.call():void 0)},registerCollectionEvents:function(){var a,b=this;return a=this.getCollectionManager(),_(this.collectionEvents).each(function(c,d){var e,f,g,h;h=d.split(" "),g=h[0],f=h[1],e=b[""+g+"Collection"]=a.getOrCreate(g);if(!e)throw"Could not find collection specified by "+g;_.isString(c)&&(c=b[c]);if(!_.isFunction(c))throw"invalid collectionEvents configuration";try{return e.bind(f,c)}catch(i){throw console.log("Error Binding To Collection in registerCollectionEvents",b),i}})}})}.call(this),function(){Luca.Collection=(Backbone.QueryCollection||Backbone.Collection).extend({initialize:function(a,b){var c,d=this;a==null&&(a=[]),this.options=b,_.extend(this,this.options),this._reset(),this.cached&&(this.bootstrap_cache_key=_.isFunction(this.cached)?this.cached():this.cached),(this.registerAs||this.registerWith)&&console.log("This configuration API is deprecated. use @name and @manager properties instead"),this.name||(this.name=this.registerAs),this.manager||(this.manager=this.registerWith),this.name&&!this.manager&&(this.manager=Luca.CollectionManager.get()),this.manager&&(this.name||(this.name=this.cached()),this.name=_.isFunction(this.name)?this.name():this.name,!this.private&&!this.anonymous&&this.bind("after:initialize",function(){return d.register(d.manager,d.name,d)}));if(this.useLocalStorage===!0&&window.localStorage!=null)throw c=this.bootstrap_cache_key||this.name,"Must specify either a cached or registerAs property to use localStorage";return _.isArray(this.data)&&this.data.length>0&&(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}),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(),this},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),this.applyParams(a),this.fetch(_.extend(b,{refresh:!0}))},applyParams:function(a){return this.base_params||(this.base_params=_(Luca.Collection.baseParams()).clone()),_.extend(this.base_params,a)},register:function(a,b,c){a==null&&(a=Luca.CollectionManager.get()),b==null&&(b="");if(!(b.length>=1))throw"Can not register with a collection manager without a key";if(a==null)throw"Can not register with a collection manager without a valid collection manager";_.isString(a)&&(a=Luca.util.nestedValue(a,window||global));if(!a)throw"Could not register with 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)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={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.apply(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}}),_.extend(Luca.Collection.prototype,{trigger:function(){return Luca.enableGlobalObserver&&(Luca.CollectionObserver||(Luca.CollectionObserver=new Luca.Observer({type:"collection"})),Luca.CollectionObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)}}),Luca.Collection.baseParams=function(a){if(a)return Luca.Collection._baseParams=a;if(_.isFunction(Luca.Collection._baseParams))return Luca.Collection._baseParams.call();if(_.isObject(Luca.Collection._baseParams))return Luca.Collection._baseParams},Luca.Collection._bootstrapped_models={},Luca.Collection.bootstrap=function(a){return _.extend(Luca.Collection._bootstrapped_models,a)},Luca.Collection.cache=function(a,b){return b?Luca.Collection._bootstrapped_models[a]=b:Luca.Collection._bootstrapped_models[a]||[]}}.call(this),function(){Luca.core.Field=Luca.View.extend({className:"luca-ui-text-field luca-ui-field",isField:!0,template:"fields/text_field",labelAlign:"top",hooks:["before:validation","after:validation","on:change"],statuses:["warning","error","success"],initialize:function(a){var b;return this.options=a!=null?a:{},_.extend(this,this.options),Luca.View.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.helperText||(this.helperText=""),this.required&&((b=this.label)!=null?!b.match(/^\*/):!void 0)&&(this.label||(this.label="*"+this.label)),this.inputStyles||(this.inputStyles=""),this.disabled&&this.disable(),this.updateState(this.state),this.placeHolder||(this.placeHolder="")},beforeRender:function(){return Luca.enableBootstrap&&this.$el.addClass("control-group"),this.required&&this.$el.addClass("required"),this.$el.html(Luca.templates[this.template](this)),this.input=$("input",this.el)},change_handler:function(a){return this.trigger("on:change",this,a)},disable:function(){return $("input",this.el).attr("disabled",!0)},enable:function(){return $("input",this.el).attr("disabled",!1)},getValue:function(){return this.input.attr("value")},render:function(){return $(this.container).append(this.$el)},setValue:function(a){return this.input.attr("value",a)},updateState:function(a){var b=this;return _(this.statuses).each(function(c){return b.$el.removeClass(c),b.$el.addClass(a)})}})}.call(this),function(){Luca.core.Container=Luca.View.extend({className:"luca-ui-container",componentClass:"luca-ui-panel",isContainer:!0,hooks:["before:components","before:layout","after:components","after:layout","first:activation"],rendered:!1,components:[],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),this.setupHooks(Luca.core.Container.prototype.hooks),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){return this.debug("container before render"),this.doLayout(),this.doComponents()},doLayout:function(){return this.debug("container do layout"),this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},doComponents:function(){return this.debug("container do components"),this.trigger("before:components",this,this.components),this.prepareComponents(),this.createComponents(),this.renderComponents(),this.trigger("after:components",this,this.components)},applyPanelConfig:function(a,b){var c,d;return d=[],a.height&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={classes:(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";")}},prepareLayout:function(){var a=this;this.debug("container prepare layout"),this.componentContainers=_(this.components).map(function(b,c){return a.applyPanelConfig.apply(a,[b,c])});if(this.appendContainers)return _(this.componentContainers).each(function(b){return a.$el.append(Luca.templates["containers/basic"](b))})},prepareComponents:function(){var a=this;return this.debug("container prepare components"),this.components=_(this.components).map(function(b,c){var d;return d=a.componentContainers[c],b.container=a.appendContainers?"#"+d.id:a.el,b})},createComponents:function(){var a,b=this;if(this.componentsCreated===!0)return;return a=this.componentIndex={name_index:{},cid_index:{}},this.components=_(this.components).map(function(b,c){var d;return d=_.isObject(b)&&b.render&&b.trigger?b:(b.ctype||(b.ctype=Luca.defaultComponentType||"template"),Luca.util.lazyComponent(b)),!d.container&&d.options.container&&(d.container=d.options.container),a&&d.cid!=null&&(a.cid_index[d.cid]=c),a&&d.name!=null&&(a.name_index[d.name]=c),d}),this.componentsCreated=!0,a},renderComponents:function(a){var b=this;return this.debugMode=a!=null?a:"",this.debug("container render components"),_(this.components).each(function(a){a.getParent=function(){return b},$(a.container).append($(a.el));try{return a.render()}catch(c){return console.log("Error Rendering Component "+(a.name||a.cid),a),console.log(c.message),console.log(c.stack)}})},firstActivation:function(){var a=this;return _(this.components).each(function(b){var c,d;c=a;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.apply(b,["first:activation",[b,c]]),b.previously_activated=!0})},select:function(a,b,c){var d;return c==null&&(c=!1),d=_(this.components).map(function(d){var e,f;return e=[],f=d[a],f===b&&e.push(d),c===!0&&d.isContainer===!0&&e.push(d.select(a,b,!0)),_.compact(e)}),_.flatten(d)},findComponentByName:function(a,b){return b==null&&(b=!1),this.findComponent(a,"name_index",b)},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,h;b==null&&(b="name"),c==null&&(c=!1),this.componentsCreated!==!0&&this.createComponents(),e=(g=this.componentIndex)!=null?g[b][a]:void 0,d=(h=this.components)!=null?h[e]:void 0;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},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c){var d;a.apply(c,[c]);if(b)return c!=null?(d=c.eachComponent)!=null?d.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.componentClass,this.el)},getComponent:function(a){return this.components[a]},rootComponent:function(){return this.getParent==null},getRootComponent:function(){return this.rootComponent()?this:this.getParent().getRootComponent()}}),Luca.register("container","Luca.core.Container")}.call(this),function(){var a;a=[],Luca.CollectionManager=function(){function b(b){this.options=b!=null?b:{},_.extend(this,this.options),_.extend(this,Backbone.Events),a.push(this),this.state=new Backbone.Model,this.collectionNames&&(this.state.set({loaded_collections_count:0,collections_count:this.collectionNames.length}),this.state.bind("change:loaded_collections_count",this.collectionCountDidChange),this.useProgressLoader&&(this.loader=new Luca.components.CollectionLoaderView({manager:this,name:"collection_loader_view"})),this.loadInitialCollections()),this}return b.prototype.__collections={},b.prototype.add=function(a,b){var c;return(c=this.currentScope())[a]||(c[a]=b)},b.prototype.allCollections=function(){return _(this.currentScope()).values()},b.prototype.create=function(a,b,c){var d,e;return b==null&&(b={}),c==null&&(c=[]),d=b.base,d||(d=this.guessCollectionClass(a)),b.private&&(b.name=""),e=new d(c,b),this.add(a,e),e},b.prototype.collectionNamespace=Luca.Collection.namespace,b.prototype.currentScope=function(){var a,b;return(a=this.getScope())?(b=this.__collections)[a]||(b[a]={}):this.__collections},b.prototype.each=function(a){return _(this.all()).each(a)},b.prototype.get=function(a){return this.currentScope()[a]},b.prototype.getScope=function(){return},b.prototype.getOrCreate=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.get(a)||this.create(a,b,c,!1)},b.prototype.guessCollectionClass=function(a){var b,c;return b=_(a).chain().capitalize().camelize().value(),c=(this.collectionNamespace||window||global)[b],c||(c=(this.collectionNamespace||window||global)[""+b+"Collection"]),c},b.prototype.loadInitialCollections=function(){var a,b=this;return a=function(a){return a.unbind("reset"),b.trigger("collection_loaded",a.name)},_(this.collectionNames).each(function(c){var d;return d=b.getOrCreate(c),d.bind("reset",function(){return a(d)}),d.fetch()})},b.prototype.collectionCountDidChange=function(){if(this.totalCollectionsCount()===this.loadedCollectionsCount())return this.trigger("all_collections_loaded")},b.prototype.totalCollectionsCount=function(){return this.state.get("collections_count")},b.prototype.loadedCollectionsCount=function(){return this.state.get("loaded_collections_count")},b.prototype.private=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.create(a,b,c,!0)},b}(),Luca.CollectionManager.destroyAll=function(){return a=[]},Luca.CollectionManager.instances=function(){return a},Luca.CollectionManager.get=function(){return _(a).last()}}.call(this),function(){Luca.SocketManager=function(){function a(a){this.options=a!=null?a:{},_.extend(Backbone.Events),this.loadTransport()}return a.prototype.connect=function(){switch(this.options.provider){case"socket.io":return this.socket=io.connect(this.options.socket_host);case"faye.js":return this.socket=new Faye.Client(this.options.socket_host)}},a.prototype.transportLoaded=function(){return this.connect()},a.prototype.transport_script=function(){switch(this.options.provider){case"socket.io":return""+this.options.transport_host+"/socket.io/socket.io.js";case"faye.js":return""+this.options.transport_host+"/faye.js"}},a.prototype.loadTransport=function(){var a,b=this;return a=document.createElement("script"),a.setAttribute("type","text/javascript"),a.setAttribute("src",this.transport_script()),a.onload=this.transportLoaded,Luca.util.isIE()&&(a.onreadystatechange=function(){if(a.readyState==="loaded")return b.transportLoaded()}),document.getElementsByTagName("head")[0].appendChild(a)},a}()}.call(this),function(){Luca.containers.SplitView=Luca.core.Container.extend({layout:"100",componentType:"split_view",containerTemplate:"containers/basic",className:"luca-ui-split-view",componentClass:"luca-ui-panel"}),Luca.register("split_view","Luca.containers.SplitView")}.call(this),function(){Luca.containers.ColumnView=Luca.core.Container.extend({componentType:"column_view",className:"luca-ui-column-view",components:[],initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments),this.setColumnWidths()},componentClass:"luca-ui-column",containerTemplate:"containers/basic",appendContainers:!0,autoColumnWidths:function(){var a,b=this;return a=[],_(this.components.length).times(function(){return a.push(parseInt(100/b.components.length))}),a},setColumnWidths:function(){return this.columnWidths=this.layout!=null?_(this.layout.split("/")).map(function(a){return parseInt(a)}):this.autoColumnWidths(),this.columnWidths=_(this.columnWidths).map(function(a){return""+a+"%"})},beforeComponents:function(){return this.debug("column_view before components"),_(this.components).each(function(a){return a.ctype||(a.ctype="panel_view")})},beforeLayout:function(){var a,b=this;return this.debug("column_view before layout"),_(this.columnWidths).each(function(a,c){return b.components[c].float="left",b.components[c].width=a}),(a=Luca.core.Container.prototype.beforeLayout)!=null?a.apply(this,arguments):void 0}}),Luca.register("column_view","Luca.containers.ColumnView")}.call(this),function(){Luca.containers.CardView=Luca.core.Container.extend({componentType:"card_view",className:"luca-ui-card-view-wrapper",activeCard:0,components:[],hooks:["before:card:switch","after:card:switch"],initialize:function(a){return this.options=a,Luca.core.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks)},componentClass:"luca-ui-card",beforeLayout:function(){var a=this;return this.cards=_(this.components).map(function(b,c){return{classes:a.componentClass,style:"display:"+(c===a.activeCard?"block":"none"),id:""+a.cid+"-"+c}})},prepareLayout:function(){var a=this;return this.card_containers=_(this.cards).map(function(b,c){return a.$el.append(Luca.templates["containers/basic"](b)),$("#"+b.id)})},prepareComponents:function(){var a=this;return this.components=_(this.components).map(function(b,c){var d;return d=a.cards[c],b.container="#"+d.id,b})},activeComponent:function(){return this.getComponent
2
+ (this.activeCard)},cycle:function(){var a;return a=this.activeCard<this.components.length-1?this.activeCard+1:0,this.activate(a)},find:function(a){return this.findComponentByName(a,!0)},firstActivation:function(){return this.activeComponent().trigger("first:activation",this,this.activeComponent())},activate:function(a,b,c){var d,e,f,g,h,i;b==null&&(b=!1),_.isFunction(b)&&(b=!1,c=b);if(a===this.activeCard)return;e=this.activeComponent(),d=this.getComponent(a),d||(a=this.indexOf(a),d=this.getComponent(a));if(!d)return;b||(this.trigger("before:card:switch",e,d),e!=null&&(f=e.trigger)!=null&&f.apply(e,["before:deactivation",this,e,d]),d!=null&&(g=d.trigger)!=null&&g.apply(e,["before:activation",this,e,d])),_(this.card_containers).each(function(a){return a.hide()}),d.previously_activated||(d.trigger("first:activation"),d.previously_activated=!0),$(d.container).show(),this.activeCard=a,b||(this.trigger("after:card:switch",e,d),(h=e.trigger)!=null&&h.apply(e,["deactivation",this,e,d]),(i=d.trigger)!=null&&i.apply(d,["activation",this,e,d]));if(_.isFunction(c))return c.apply(this,[this,e,d])}}),Luca.register("card_view","Luca.containers.CardView")}.call(this),function(){Luca.containers.ModalView=Luca.core.Container.extend({componentType:"modal_view",className:"luca-ui-modal-view",components:[],renderOnInitialize:!0,showOnRender:!1,hooks:["before:show","before:hide"],defaultModalOptions:{minWidth:375,maxWidth:375,minHeight:550,maxHeight:550,opacity:80,onOpen:function(a){return this.onOpen.apply(this),this.onModalOpen.apply(a,[a,this])},onClose:function(a){return this.onClose.apply(this),this.onModalClose.apply(a,[a,this])}},modalOptions:{},initialize:function(a){var b=this;return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks),_(this.defaultModalOptions).each(function(a,c){var d;return(d=b.modalOptions)[c]||(d[c]=a)}),this.modalOptions.onOpen=_.bind(this.modalOptions.onOpen,this),this.modalOptions.onClose=_.bind(this.modalOptions.onClose,this)},onOpen:function(){return!0},onClose:function(){return!0},getModal:function(){return this.modal},onModalOpen:function(a,b){return b.modal=a,a.overlay.show(),a.container.show(),a.data.show()},onModalClose:function(a,b){return $.modal.close()},prepareLayout:function(){return $("body").append(this.$el)},prepareComponents:function(){var a=this;return this.components=_(this.components).map(function(b,c){return b.container=a.el,b})},afterInitialize:function(){this.$el.hide();if(this.renderOnInitialize)return this.render()},afterRender:function(){if(this.showOnRender)return this.show()},wrapper:function(){return $(this.$el.parent())},show:function(){return this.trigger("before:show",this),this.$el.modal(this.modalOptions)},hide:function(){return this.trigger("before:hide",this)}}),Luca.register("modal_view","Luca.containers.ModalView")}.call(this),function(){Luca.containers.PanelView=Luca.core.Container.extend({className:"luca-ui-panel",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},afterLayout:function(){var a;if(this.template)return a=(Luca.templates||JST)[this.template](this),this.$el.html(a)},render:function(){return $(this.container).append(this.$el)},afterRender:function(){var a,b=this;(a=Luca.core.Container.prototype.afterRender)!=null&&a.apply(this,arguments);if(this.css)return console.log("Yes Yes Yall",this.css,this.$el),_(this.css).each(function(a,c){return b.$el.css(c,a)})}})}.call(this),function(){Luca.containers.TabView=Luca.containers.CardView.extend({events:{"click ul.nav-tabs li":"select"},hooks:["before:select","after:select"],componentType:"tab_view",className:"luca-ui-tab-view tabbable",tab_position:"top",tabVerticalOffset:"50px",initialize:function(a){return this.options=a!=null?a:{},Luca.containers.CardView.prototype.initialize.apply(this,arguments),_.bindAll(this,"select","highlightSelectedTab"),this.setupHooks(this.hooks),this.bind("after:card:switch",this.highlightSelectedTab)},activeTabSelector:function(){return this.tabSelectors().eq(this.activeCard)},prepareLayout:function(){var a=this;return this.card_containers=_(this.cards).map(function(b,c){return a.$(".tab-content").append(Luca.templates["containers/basic"](b)),$("#"+b.id)})},beforeLayout:function(){return this.$el.addClass("tabs-"+this.tab_position),this.tab_position==="below"?(this.$el.append(Luca.templates["containers/tab_view"](this)),this.$el.append(Luca.templates["containers/tab_selector_container"](this))):(this.$el.append(Luca.templates["containers/tab_selector_container"](this)),this.$el.append(Luca.templates["containers/tab_view"](this))),Luca.containers.CardView.prototype.beforeLayout.apply(this,arguments)},beforeRender:function(){var a;(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.activeTabSelector().addClass("active");if(Luca.enableBootstrap&&this.tab_position==="left"||this.tab_position==="right"){this.$el.addClass("grid-12"),this.tabContainerWrapper().addClass("grid-3"),this.tabContentWrapper().addClass("grid-9");if(this.tabVerticalOffset)return this.tabContainerWrapper().css("padding-top",this.tabVerticalOffset)}},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},select:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("before:select",this),this.activate(c.data("target")),this.trigger("after:select",this)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return $("ul#"+this.cid+"-tabs-nav")},tabSelectors:function(){return $("li.tab-selector",this.tabContainer())}})}.call(this),function(){Luca.containers.Viewport=Luca.containers.CardView.extend({activeItem:0,className:"luca-ui-viewport",fullscreen:!0,initialize:function(a){this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments);if(this.fullscreen)return $("html,body").addClass("luca-ui-fullscreen")},render:function(){return console.log("Rendering Viewport"),this.$el.addClass("luca-ui-viewport")}})}.call(this),function(){}.call(this),function(){Luca.components.Template=Luca.View.extend({initialize:function(options){this.options=options!=null?options:{},Luca.View.prototype.initialize.apply(this,arguments);if(!this.template&&!this.markup)throw"Templates must specify which template / markup to use";if(_.isString(this.templateContainer))return this.templateContainer=eval("(window || global)."+this.templateContainer)},templateContainer:"Luca.templates",beforeRender:function(){return _.isUndefined(this.templateContainer)&&(this.templateContainer=JST),this.$el.html(this.markup||this.templateContainer[this.template](this.options))},render:function(){return $(this.container).append(this.$el)}}),Luca.register("template","Luca.components.Template")}.call(this),function(){Luca.Application=Luca.containers.Viewport.extend({components:[{ctype:"controller",name:"main_controller",defaultCard:"welcome",components:[{ctype:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}]}],initialize:function(a){var b=this;return this.options=a!=null?a:{},Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.collectionManager=new Luca.CollectionManager,this.state=new Backbone.Model(this.defaultState),this.bind("ready",function(){return b.render()})},activeView:function(){var a;return(a=this.activeSubSection())?this.view(a):this.view(this.activeSection())},activeSubSection:function(){return this.get("active_sub_section")},activeSection:function(){return this.get("active_section")},afterComponents:function(){var a,b,c,d=this;return(a=Luca.containers.Viewport.prototype.afterComponents)!=null&&a.apply(this,arguments),(b=this.getMainController())!=null&&b.bind("after:card:switch",function(a,b){return d.state.set({active_section:b.name})}),(c=this.getMainController())!=null?c.each(function(a){if(a.ctype.match(/controller$/))return a.bind("after:card:switch",function(a,b){return d.state.set({active_sub_section:b.name})})}):void 0},beforeRender:function(){var a;return(a=Luca.containers.Viewport.prototype.beforeRender)!=null?a.apply(this,arguments):void 0},boot:function(){return console.log("Sup?"),this.trigger("ready")},collection:function(){return this.collectionManager.getOrCreate.apply(this.collectionManager,arguments)},get:function(a){return this.state.get(a)},getMainController:function(){return this.view("main_controler")},set:function(a){return this.state.set(a)},view:function(a){return Luca.cache(a)}})}.call(this),function(){Luca.components.Toolbar=Luca.core.Container.extend({className:"luca-ui-toolbar",position:"bottom",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},prepareComponents:function(){var a=this;return _(this.components).each(function(b){return b.container=a.el})},render:function(){return $(this.container).append(this.el)}}),Luca.register("toolbar","Luca.components.Toolbar")}.call(this),function(){Luca.components.CollectionLoaderView=Luca.components.Template.extend({className:"luca-ui-collection-loader-view",template:"components/collection_loader_view",initialize:function(a){return this.options=a!=null?a:{},Luca.components.Template.prototype.initialize.apply(this,arguments),this.container||(this.container=$("body")),this.manager||(this.manager=Luca.CollectionManager.get()),this.setupBindings()},modalContainer:function(){return $("#progress-modal",this.el)},setupBindings:function(){var a=this;return this.manager.bind("collection_loaded",function(b){var c,d,e;return c=a.manager.loadedCollectionsCount(),e=a.manager.totalCollectionsCount(),d=parseInt(c/e*100),a.modalContainer().find(".progress .bar").attr("style","width: "+d+"%;"),a.modalContainer().find(".message").html("Loaded "+_(b).chain().humanize().titleize().value()+"...")}),this.manager.bind("all_collections_loaded",function(){return a.modalContainer().find(".message").html("All done!"),_.delay(function(){return a.modalContainer().modal("hide")},400)})}}),Luca.register("collection_loader_view","Luca.components.CollectionLoaderView")}.call(this),function(){Luca.components.Controller=Luca.containers.CardView.extend({initialize:function(a){var b;this.options=a,Luca.containers.CardView.prototype.initialize.apply(this,arguments),this.defaultCard||(this.defaultCard=(b=this.components[0])!=null?b.name:void 0);if(!this.defaultCard)throw"Controllers must specify a defaultCard property and/or the first component must have a name";return this.state=new Backbone.Model({active_section:this.defaultCard})},each:function(a){var b=this;return _(this.components).each(function(c){return a.apply(b,[c])})},"default":function(a){return this.navigate_to(this.defaultCard,a)},navigate_to:function(a,b){var c=this;return a||(a=this.defaultCard),this.activate(a,!1,function(a,d,e){c.state.set({active_section:e.name});if(_.isFunction(b))return b.apply(e)}),this.find(a)}})}.call(this),function(){Luca.fields.ButtonField=Luca.core.Field.extend({form_field:!0,readOnly:!0,events:{"click input":"click_handler"},hooks:["button:click"],className:"luca-ui-field luca-ui-button-field",template:"fields/button_field",click_handler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("button:click")},initialize:function(a){var b;this.options=a!=null?a:{},_.extend(this.options),_.bindAll(this,"click_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments);if((b=this.icon_class)!=null?b.length:void 0)return this.template="fields/button_field_link"},afterInitialize:function(){this.input_id||(this.input_id=_.uniqueId("button")),this.input_name||(this.input_name=this.name||(this.name=this.input_id)),this.input_value||(this.input_value=this.label||(this.label=this.text)),this.input_type||(this.input_type="button"),this.input_class||(this.input_class=this["class"]),this.icon_class||(this.icon_class="");if(this.icon_class.length&&!this.icon_class.match(/^icon-/))return this.icon_class="icon-"+this.icon_class},setValue:function(){return!0}}),Luca.register("button_field","Luca.fields.ButtonField")}.call(this),function(){Luca.fields.CheckboxField=Luca.core.Field.extend({form_field:!0,events:{"change input":"change_handler"},change_handler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("on:change",this,a),b.checked===!0?this.trigger("checked"):this.trigger("unchecked")},className:"luca-ui-checkbox-field luca-ui-field",template:"fields/checkbox_field",hooks:["checked","unchecked"],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"change_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=1),this.label||(this.label=this.name)},setValue:function(a){return this.input.attr("checked",a)},getValue:function(){return this.input.attr("checked")===!0}}),Luca.register("checkbox_field","Luca.fields.CheckboxField")}.call(this),function(){Luca.fields.FileUploadField=Luca.core.Field.extend({form_field:!0,template:"fields/file_upload_field",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.helperText||(this.helperText="")}}),Luca.register("file_upload_field","Luca.fields.FileUploadField")}.call(this),function(){Luca.fields.HiddenField=Luca.core.Field.extend({form_field:!0,template:"fields/hidden_field",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=this.value),this.label||(this.label=this.name)}}),Luca.register("hidden_field","Luca.fields.HiddenField")}.call(this),function(){Luca.fields.SelectField=Luca.core.Field.extend({form_field:!0,events:{"change select":"change_handler"},hooks:["after:select"],className:"luca-ui-select-field luca-ui-field",template:"fields/select_field",includeBlank:!0,blankValue:"",blankText:"Select One",initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"change_handler","populateOptions","beforeFetch"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name);if(_.isUndefined(this.retainValue))return this.retainValue=!0},afterInitialize:function(){var a;if((a=this.collection)!=null?a.data:void 0)this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.parseData();try{this.configure_collection()}catch(b){console.log("Error Configuring Collection",this,b.message)}return this.collection.bind("before:fetch",this.beforeFetch),this.collection.bind("reset",this.populateOptions)},parseData:function(){var a=this;return this.collection.data=_(this.collection.data).map(function(b){var c;return _.isArray(b)?(c={},c[a.valueField]=b[0],c[a.displayField]=b[1],c):b})},afterRender:function(){var a,b;return this.input=$("select",this.el),((a=this.collection)!=null?(b=a.models)!=null?b.length:void 0:void 0)>0?this.populateOptions():this.collection.trigger("reset")},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.input.html("");if(this.includeBlank)return this.input.append("<option value='"+this.blankValue+"'>"+this.blankText+"</option>")},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="<option "+e+" value='"+f+"'>"+c+"</option>",b.input.append(d)}),this.trigger("after:populate:options",this),this.setValue(this.currentValue)}}),Luca.register("select_field","Luca.fields.SelectField")}.call(this),function(){Luca.fields.TextAreaField=Luca.core.Field.extend({form_field:!0,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"),Luca.core.Field.prototype.initialize.apply(this,arguments),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.inputStyles||(this.inputStyles="height:"+this.height+";width:"+this.width)},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)}}),Luca.register("text_area_field","Luca.fields.TextAreaField")}.call(this),function(){Luca.fields.TextField=Luca.core.Field.extend({form_field:!0,events:{"keydown input":"keydown_handler","blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",initialize:function(a){this.options=a!=null?a:{},_.bindAll(this,"keydown_handler","blur_handler","focus_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend);if(this.append)return this.$el.addClass("input-append"),this.addOn=this.append},keydown_handler:_.throttle(function(a){return this.change_handler.apply(this,arguments)},300),blur_handler:function(a){var b,c;return b=c=$(a.currentTarget)},focus_handler:function(a){var b,c;return b=c=$(a.currentTarget)},change_handler:function(a){return this.trigger("on:change",this,a)}}),Luca.register("text_field","Luca.fields.TextField")}.call(this),function(){Luca.fields.TypeAheadField=Luca.fields.TextField.extend({form_field:!0,className:"luca-ui-field",afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name)}})}.call(this),function(){Luca.components.FormButtonToolbar=Luca.components.Toolbar.extend({className:"luca-ui-form-toolbar form-actions",position:"bottom",includeReset:!1,render:function(){return $(this.container).append(this.el)},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"})}}),Luca.register("form_button_toolbar","Luca.components.FormButtonToolbar")}.call(this),function(){Luca.components.FormView=Luca.core.Container.extend({tagName:"form",className:"luca-ui-form-view",hooks:["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"],events:{"click .submit-button":"submitHandler","click .reset-button":"resetHandler"},toolbar:!0,initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments),_.bindAll(this,"submitHandler","resetHandler","renderToolbars"),this.state||(this.state=new Backbone.Model),this.setupHooks(this.hooks),this.legend||(this.legend=""),this.configureToolbars(),this.applyStyles()},addBootstrapFormControls:function(){var a=this;return this.bind("after:render",function(){var b;return b=a.$(".toolbar-container.bottom"),b.addClass("form-controls"),b.html(a.formControlsTemplate||Luca.templates["components/bootstrap_form_controls"](a))})},applyStyles:function(){Luca.enableBootstrap&&this.applyBootstrapStyles(),this.labelAlign&&this.$el.addClass("label-align-"+this.labelAlign);if(this.fieldLayoutClass)return this.$el.addClass(this.fieldLayoutClass)},applyBootstrapStyles:function(){this.labelAlign==="left"&&(this.inlineForm=!0),this.well&&this.$el.addClass("well"),this.searchForm&&this.$el.addClass("form-search"),this.horizontalForm&&this.$el.addClass("form-horizontal");if(this.inlineForm)return this.$el.addClass("form-inline")},configureToolbars:function(){if(Luca.enableBootstrap&&this.toolbar===!0)return this.addBootstrapFormControls();this.toolbar===!0&&(this.toolbars=[{ctype:"form_button_toolbar",includeReset:!0,position:"bottom"}]);if(this.toolbars&&this.toolbars.length)return this.bind("after:render",_.once(this.renderToolbars))},resetHandler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("before:reset",this),this.reset(),this.trigger("after:reset",this)},submitHandler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("before:submit",this),this.submit()},beforeLayout:function(){var a;return(a=Luca.core.Container.prototype.beforeLayout)!=null&&a.apply(this,arguments),this.$el.html(Luca.templates["components/form_view"](this))},prepareComponents:function(){var a;return a=$(".form-view-body",this.el),_(this.components).each(function(b){return b.container=a})},render:function(){return $(this.container).append(this.$el)},wrapper:function(){return this.$el.parents(".luca-ui-form-view-wrapper")},toolbarContainers:function(a){return a==null&&(a="bottom"),$(".toolbar-container."+a,this.wrapper()).first()},renderToolbars:function(){var a=this;return _(this.toolbars).each(function(b){return b.container=$("#"+a.cid+"-"+b.position+"-toolbar-container"),b=Luca.util.lazyComponent(b),b.render()})},getField:function(a){return _(this.getFields("name",a)).first()},getFields:function(a,b){var c;return c=this.select("isField",!0,!0),c.length>0&&a&&b&&(c=_(c).select(function(c){var d,e;return d=c[a],d==null?!1:(e=_.isFunction(d)?d():d,b===e)})),c},loadModel:function(a){var b,c,d,e;this.current_model=a,d=this,c=this.getFields(),this.trigger("before:load",this,this.current_model),this.current_model&&((e=this.current_model.beforeFormLoad)!=null&&e.apply(this.current_model,this),b="before:load:"+(this.current_model.isNew()?"new":"existing"),this.trigger(b,this,this.current_model)),this.setValues(this.current_model),this.trigger("after:load",this,this.current_model);if(this.current_model)return this.trigger("after:load:"+(this.current_model.isNew()?"new":"existing"),this,this.current_model)},reset:function(){return this.loadModel(this.current_model)},clear:function(){var a=this;return this.current_model=this.defaultModel!=null?this.defaultModel():void 0,_(this.getFields()).each(function(b){try{return b.setValue("")}catch(c){return console.log("Error Clearing",a,b)}})},setValues:function(a,b){var c,d=this;b==null&&(b={}),a||(a=this.currentModel()),c=this.getFields(),_(c).each(function(b){var c,e;c=b.input_name||b.name,(e=a[c])&&_.isFunction(e)&&(e=e.apply(d)),!e&&Luca.isBackboneModel(a)&&(e=a.get(c));if(b.readOnly!==!0)return b!=null?b.setValue(e):void 0});if(b.silent!=null!=1)return this.syncFormWithModel()},getValues:function(a){return a||(a={}),a.reject_blank==null&&(a.reject_blank=!0),a.skip_buttons==null&&(a.skip_buttons=!0),_(this.getFields()).inject(function(b,c){var d,e,f;return f=c.getValue(),d=c.input_name||c.name,e=!1,a.skip_buttons&&c.ctype==="button_field"&&(e=!0),a.reject_blank===!0&&_.isBlank(f)&&(e=!0),c.input_name==="id"&&_.isBlank(f)&&(e=!0),e!==!0&&(b[d]=f),b},{})},submit_success_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),b&&(b!=null?b.success:void 0)===!0?this.trigger("after:submit:success",this,a,b):this.trigger("after:submit:error",this,a,b)},submit_fatal_error_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),this.trigger("after:submit:fatal_error",this,a,b)},submit:function(a,b){a==null&&(a=!0),b==null&&(b={}),_.bindAll(this,"submit_success_handler","submit_fatal_error_handler"),b.success||(b.success=this.submit_success_handler),b.error||(b.error=this.submit_fatal_error_handler),this.syncFormWithModel();if(!a)return;return this.current_model.save(this.current_model.toJSON(),b)},currentModel:function(a){return a==null&&(a={}),(a===!0||(a!=null?a.refresh:void 0)===!0)&&this.syncFormWithModel(),this.current_model},syncFormWithModel:function(){var a;return(a=this.current_model)!=null?a.set(this.getValues()):void 0},setLegend:function(a){return this.legend=a,$("fieldset legend",this.el).first().html(this.legend)}}),Luca.register("form_view","Luca.components.FormView")}.call(this),function(){Luca.components.GridView=Luca.View.extend({events:{"dblclick .grid-view-row":"double_click_handler","click .grid-view-row":"click_handler"},className:"luca-ui-grid-view",scrollable:!0,emptyText:"No Results To display",tableStyle:"striped",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.modules.Deferrable),Luca.View.prototype.initialize.apply(this,arguments),_.bindAll(this,"double_click_handler","click_handler"),this.configure_collection(),this.collection.bind("reset",function(a){return b.refresh(),b.trigger("after:collection:load",a)})},beforeRender:function(){var a,b=this;return this.trigger("before:grid:render",this),this.scrollable&&this.$el.addClass("scrollable-grid-view"),this.$el.html(Luca.templates["components/grid_view"]()),this.table=$("table.luca-ui-grid-view",this.el),this.header=$("thead",this.table),this.body=$("tbody",this.table),this.footer=$("tfoot",this.table),Luca.enableBootstrap&&this.table.addClass("table"),_((a=this.tableStyle)!=null?a.split(" "):void 0).each(function(a){return b.table.addClass("table-"+a)}),this.scrollable&&this.setDimensions(),this.renderHeader(),this.emptyMessage(),this.renderToolbars(),$(this.container).append(this.$el)},toolbarContainers:function(a){return a==null&&(a="bottom"),$(".toolbar-container."+a,this.el)},renderToolbars:function(){var a=this;return _(this.toolbars).each(function(b){return b=Luca.util.lazyComponent(b),b.container=a.toolbarContainers(b.position),b.render()})},setDimensions:function(a){var b=this;return this.height||(this.height=285),$(".grid-view-body",this.el).height(this.height),$("tbody.scrollable",this.el).height(this.height-23),this.container_width=function(){return $(b.container).width()}(),this.width=this.container_width>0?this.container_width:756,$(".grid-view-body",this.el).width(this.width),$(".grid-view-body table",this.el).width(this.width),this.setDefaultColumnWidths()},resize:function(a){var b,c,d=this;b=a-this.width,this.width=a,$(".grid-view-body",this.el).width(this.width),$(".grid-view-body table",this.el).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]},afterRender:function(){return this.refresh(),this.trigger("after:grid:render",this)},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;":"","<th style='"+c+"' class='column-"+b+"'>"+a.header+"</th>"}),this.header.append("<tr>"+a+"</tr>")},render_row:function(a,b){var c,d,e,f,g=this;return e=(a!=null?a.get:void 0)&&(a!=null?a.attributes:void 0)?a.get("id"):"",this.trigger("before:render:row",a,b),d=_(this.columns).map(function(b,c){var d,e,f;return f=g.cell_renderer(a,b,c),e=b.width?"width:"+b.width+"px;":"",d=_.isUndefined(f)?"":f,"<td style='"+e+"' class='column-"+c+"'>"+d+"</td>"}),this.alternateRowClasses&&(c=b%2===0?"even":"odd"),(f=this.body)!=null?f.append("<tr data-record-id='"+e+"' data-row-index='"+b+"' class='grid-view-row "+c+"' id='row-"+b+"'>"+d+"</tr>"):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),$(".grid-view-row",this.body).removeClass("selected-row"),b.addClass("selected-row")}}),Luca.register("grid_view","Luca.components.GridView")}.call(this),function(){Luca.components.RecordManager=Luca.containers.CardView.extend({events:{"click .record-manager-grid .edit-link":"edit_handler","click .record-manager-filter .filter-button":"filter_handler","click .record-manager-filter .reset-button":"reset_filter_handler","click .add-button":"add_handler","click .refresh-button":"filter_handler","click .back-to-search-button":"back_to_search_handler"},record_manager:!0,initialize:function(a){var b=this;this.options=a!=null?a:{},Luca.containers.CardView.prototype.initialize.apply(this,arguments);if(!this.name)throw"Record Managers must specify a name";return _.bindAll(this,"add_handler","edit_handler","filter_handler","reset_filter_handler"),this.filterConfig&&_.extend(this.components[0][0],this.filterConfig),this.gridConfig&&_.extend(this.components[0][1],this.gridConfig),this.editorConfig&&_.extend(this.components[1][0],this.editorConfig),this.bind("after:card:switch",function(){b.activeCard===0&&b.trigger("activation:search",b);if(b.activeCard===1)return b.trigger("activation:editor",b)})},components:[{ctype:"split_view",relayFirstActivation:!0,components:[{ctype:"form_view"},{ctype:"grid_view"}]},{ctype:"form_view"}],getSearch:function(a,b){return a==null&&(a=!1),b==null&&(b=!0),a===!0&&this.activate(0),b===!0&&this.getEditor().clear(),_.first(this.components)},getFilter:function(){return _.first(this.getSearch().components)},getGrid:function(){return _.last(this.getSearch().components)},getCollection:function(){return this.getGrid().collection},getEditor:function(a,b){var c=this;return a==null&&(a=!1),b==null&&(b=!1),a===!0&&this.activate(1,function(a,b,c){return c.reset()}),_.last(this.components)},beforeRender:function(){var a;return this.$el.addClass(""+this.resource+"-manager"),(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.$el.addClass(""+this.resource+" record-manager"),this.$el.data("resource",this.resource),$(this.getGrid().el).addClass(""+this.resource+" record-manager-grid"),$(this.getFilter().el).addClass(""+this.resource+" record-manager-filter"),$(this.getEditor().el).addClass(""+this.resource+" record-manager-editor")},afterRender:function(){var a,b,c,d,e,f,g=this;return(f=Luca.containers.CardView.prototype.afterRender)!=null&&f.apply(this,arguments),e=this,d=this.getGrid(),c=this.getFilter(),b=this.getEditor(),a=this.getCollection(),d.
3
+ bind("row:double:click",function(a,c,d){return e.getEditor(!0),b.loadModel(c)}),b.bind("before:submit",function(){return $(".form-view-flash-container",g.el).html(""),$(".form-view-body",g.el).spin("large")}),b.bind("after:submit",function(){return $(".form-view-body",g.el).spin(!1)}),b.bind("after:submit:fatal_error",function(){return $(".form-view-flash-container",g.el).append("<li class='error'>There was an internal server error saving this record. Please contact developers@benchprep.com to report this error.</li>"),$(".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("<li class='error'>"+a+"</li>")})}),b.bind("after:submit:success",function(a,b,c){return $(".form-view-flash-container",g.el).append("<li class='success'>Successfully Saved Record</li>"),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(){Luca.Router=Backbone.Router.extend({routes:{"":"default"},initialize:function(a){var b=this;return this.options=a,_.extend(this,this.options),this.routeHandlers=_(this.routes).values(),_(this.routeHandlers).each(function(a){return b.bind("route:"+a,function(){return b.trigger.apply(b,["change:navigation",a].concat(_(arguments).flatten()))})})},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(){}.call(this);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-11 00:00:00.000000000 Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties