luca 0.8.599 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/.gitignore +3 -0
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG +51 -2
  4. data/README.md +10 -247
  5. data/ROADMAP +6 -2
  6. data/app.rb +16 -2
  7. data/assets/javascripts/dependencies/bootstrap.min.js +7 -1
  8. data/assets/javascripts/dependencies/codemirror-coffeescript.js +347 -0
  9. data/assets/javascripts/dependencies/codemirror-css.js +124 -0
  10. data/assets/javascripts/dependencies/codemirror-html.js +410 -0
  11. data/assets/javascripts/dependencies/codemirror-javascript.js +361 -0
  12. data/assets/javascripts/dependencies/codemirror-less.js +232 -0
  13. data/assets/javascripts/dependencies/codemirror-vim.js +500 -0
  14. data/assets/javascripts/dependencies/codemirror.js +3076 -0
  15. data/assets/javascripts/dependencies.coffee +0 -1
  16. data/assets/javascripts/luca-ui-base.coffee +10 -3
  17. data/assets/javascripts/luca-ui-bootstrap.js +1 -0
  18. data/assets/javascripts/luca-ui-development-tools.coffee +9 -0
  19. data/assets/javascripts/luca-ui.coffee +6 -1
  20. data/assets/javascripts/sandbox/application.coffee +51 -0
  21. data/assets/javascripts/sandbox/router.coffee +14 -0
  22. data/assets/javascripts/sandbox/templates/main.luca +33 -0
  23. data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +1 -0
  24. data/assets/javascripts/sandbox/templates/sandbox.luca +1 -0
  25. data/assets/javascripts/sandbox/views/top_navigation.coffee +4 -0
  26. data/assets/javascripts/sandbox.coffee +2 -2
  27. data/assets/stylesheets/bootstrap.min.css +395 -297
  28. data/assets/stylesheets/codemirror-blackboard.css +25 -0
  29. data/assets/stylesheets/codemirror-monokai.css +33 -0
  30. data/assets/stylesheets/codemirror.css +126 -0
  31. data/assets/stylesheets/luca-ui-bootstrap.css +0 -1
  32. data/assets/stylesheets/luca-ui-development-tools.css +5 -0
  33. data/assets/stylesheets/sandbox/sandbox.scss +1 -3
  34. data/assets/stylesheets/themes/amelia-bootstrap.css +826 -0
  35. data/assets/stylesheets/themes/slate-bootstrap.css +797 -0
  36. data/assets/stylesheets/themes/superhero-bootstrap.css +830 -0
  37. data/lib/luca/code_browser.rb +55 -0
  38. data/lib/luca/rails/version.rb +1 -1
  39. data/lib/luca/rails.rb +1 -0
  40. data/spec/components/fields/checkbox_array_spec.coffee +46 -0
  41. data/spec/components/form_view_spec.coffee +10 -4
  42. data/spec/containers/card_view_spec.coffee +7 -0
  43. data/spec/core/collection_spec.coffee +58 -4
  44. data/spec/core/container_spec.coffee +6 -6
  45. data/spec/core/view_spec.coffee +93 -7
  46. data/spec/framework_spec.coffee +15 -12
  47. data/src/components/application.coffee +126 -18
  48. data/src/components/base_toolbar.coffee +2 -2
  49. data/src/components/collection_loader_view.coffee +1 -2
  50. data/src/components/collection_view.coffee +77 -0
  51. data/src/components/controller.coffee +1 -4
  52. data/src/components/fields/button_field.coffee +1 -1
  53. data/src/components/fields/checkbox_array.coffee +2 -2
  54. data/src/components/fields/checkbox_field.coffee +3 -1
  55. data/src/components/fields/file_upload_field.coffee +1 -1
  56. data/src/components/fields/hidden_field.coffee +1 -1
  57. data/src/components/fields/select_field.coffee +1 -1
  58. data/src/components/fields/text_area_field.coffee +1 -1
  59. data/src/components/fields/text_field.coffee +10 -6
  60. data/src/components/fields/type_ahead_field.coffee +18 -5
  61. data/src/components/form_button_toolbar.coffee +1 -2
  62. data/src/components/form_view.coffee +44 -62
  63. data/src/components/grid_view.coffee +27 -20
  64. data/src/components/load_mask.coffee +3 -0
  65. data/src/components/nav_bar.coffee +26 -0
  66. data/src/components/record_manager.coffee +1 -3
  67. data/src/components/router.coffee +1 -1
  68. data/src/components/template.coffee +3 -15
  69. data/src/components/toolbar_dialog.coffee +25 -0
  70. data/src/containers/card_view.coffee +22 -23
  71. data/src/containers/column_view.coffee +1 -6
  72. data/src/containers/modal_view.coffee +20 -71
  73. data/src/containers/panel_toolbar.coffee +156 -0
  74. data/src/containers/panel_view.coffee +1 -1
  75. data/src/containers/split_view.coffee +1 -3
  76. data/src/containers/tab_view.coffee +29 -29
  77. data/src/containers/viewport.coffee +38 -3
  78. data/src/core/collection.coffee +80 -48
  79. data/src/core/container.coffee +153 -72
  80. data/src/core/core.coffee +181 -0
  81. data/src/core/field.coffee +4 -2
  82. data/src/core/model.coffee +1 -1
  83. data/src/core/observer.coffee +3 -3
  84. data/src/core/panel.coffee +143 -0
  85. data/src/core/registry.coffee +104 -0
  86. data/src/core/util.coffee +82 -0
  87. data/src/core/view.coffee +158 -85
  88. data/src/framework.coffee +112 -178
  89. data/src/index.coffee +0 -255
  90. data/src/managers/collection_manager.coffee +1 -0
  91. data/src/samples/definition.coffee +49 -0
  92. data/src/stylesheets/base.scss +0 -78
  93. data/src/stylesheets/components/form_view.scss +8 -3
  94. data/src/stylesheets/components/grid_view.scss +3 -7
  95. data/src/stylesheets/components/load_mask.scss +14 -0
  96. data/src/stylesheets/components/toolbar.scss +0 -15
  97. data/src/stylesheets/containers/container.scss +14 -2
  98. data/src/stylesheets/containers/panels.scss +23 -0
  99. data/src/stylesheets/tools/class_browser.scss +32 -0
  100. data/src/stylesheets/tools/code_editor.scss +24 -0
  101. data/src/stylesheets/tools/component_tester.scss +8 -0
  102. data/src/stylesheets/tools/console.scss +26 -0
  103. data/src/templates/components/collection_loader_view.luca +1 -1
  104. data/src/templates/components/form_view.luca +2 -13
  105. data/src/templates/components/grid_view.luca +0 -2
  106. data/src/templates/components/load_mask.luca +3 -0
  107. data/src/templates/components/nav_bar.luca +2 -0
  108. data/src/templates/containers/tab_view.luca +1 -0
  109. data/src/templates/fields/text_field.luca +4 -1
  110. data/src/tools/class_browser.coffee +39 -0
  111. data/src/tools/code_editor.coffee +258 -0
  112. data/src/tools/code_mirror_field.coffee +57 -0
  113. data/src/tools/coffee_script_editor.coffee +60 -0
  114. data/src/tools/collection_inspector.coffee +4 -0
  115. data/src/tools/component_tester.coffee +472 -0
  116. data/src/tools/components/class_browser_detail.coffee +10 -0
  117. data/src/tools/components/class_browser_list.coffee +74 -0
  118. data/src/tools/console.coffee +147 -0
  119. data/src/tools/development_console.coffee +147 -0
  120. data/src/tools/models/components.coffee +63 -0
  121. data/src/tools/templates/component_tester/help.luca +14 -0
  122. data/vendor/assets/javascripts/luca-ui-base.js +1389 -611
  123. data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
  124. data/vendor/assets/javascripts/luca-ui-development-tools.js +18719 -0
  125. data/vendor/assets/javascripts/luca-ui-spec.js +2065 -878
  126. data/vendor/assets/javascripts/luca-ui.js +1759 -852
  127. data/vendor/assets/javascripts/luca-ui.min.js +3 -3
  128. data/vendor/assets/stylesheets/luca-ui-bootstrap.css +494 -440
  129. data/vendor/assets/stylesheets/luca-ui-development-tools.css +224 -0
  130. data/vendor/assets/stylesheets/luca-ui-spec.css +99 -140
  131. data/vendor/assets/stylesheets/luca-ui.css +99 -140
  132. data/views/index.erb +6 -3
  133. metadata +60 -18
  134. data/assets/javascripts/dependencies/jquery-console.js +0 -649
  135. data/assets/javascripts/development-console.coffee +0 -2
  136. data/assets/javascripts/sandbox/sandbox.coffee +0 -16
  137. data/assets/javascripts/sandbox/templates/features/collection_helpers.luca +0 -33
  138. data/assets/javascripts/sandbox/templates/features/form_demo_code.luca +0 -48
  139. data/assets/javascripts/sandbox/templates/features/grid_demo_code.luca +0 -24
  140. data/assets/javascripts/sandbox/templates/features/introduction.luca +0 -11
  141. data/assets/javascripts/sandbox/templates/features/view_helpers.luca +0 -43
  142. data/assets/javascripts/sandbox/templates/navigation.luca +0 -8
  143. data/assets/javascripts/sandbox/views/form_demo.coffee +0 -47
  144. data/assets/javascripts/sandbox/views/grid_demo.coffee +0 -23
  145. data/assets/javascripts/sandbox/views/pages/collection_events_sample.coffee +0 -1
  146. data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +0 -38
  147. data/src/components/collection_inspector.coffee +0 -2
  148. data/src/components/development_console.coffee +0 -59
  149. data/src/stylesheets/components/development_console.scss +0 -47
@@ -1,3 +1,3 @@
1
- (function(){var DefineProxy;window.Luca={VERSION:"0.8.599",core:{},containers:{},components:{},modules:{},util:{},fields:{},component_cache:{cid_index:{},name_index:{}},registry:{classes:{},namespaces:["Luca.containers","Luca.components"]}},Luca.enableGlobalObserver=!1,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.resolve=function(a,b){return _(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)},Luca.util.nestedValue=Luca.util.resolve,Luca.util.classify=function(a){return a==null&&(a=""),_.string.camelize(_.string.capitalize(a))},Luca.registry.lookup=function(a){var b,c,d,e;return b=Luca.registry.classes[a],b!=null?b:(c=Luca.util.classify(a),d=_(Luca.registry.namespaces).map(function(a){return Luca.util.nestedValue(a,window||global)}),(e=_(d).chain().map(function(a){return a[c]}).compact().value())!=null?e[0]:void 0)},Luca.util.lazyComponent=function(config){var componentClass,constructor,ctype;ctype=config.ctype||config.type,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;return c=Luca.registry.classes[a],c!=null&&window.TestRun==null?console.log("Attempting to register component with the signature "+a+". Already exists"):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}},Luca.template=function(a,b){var c,d,e,f,g;window.JST||(window.JST={}),d=(g=Luca.templates)!=null?g[a]:void 0,c=typeof JST!="undefined"&&JST!==null?JST[a]:void 0,d==null&&c==null&&(e=new RegExp(""+a+"$"),d=_(Luca.templates).detect(function(a,b){return e.exec(b)}),c=_(JST).detect(function(a,b){return e.exec(b)}));if(!d&&!c)throw"Could not find template with "+a;return f=d||c,b!=null?f(b):f},DefineProxy=function(){function DefineProxy(a){var b;this.namespace=window||global,this.componentId=this.componentName=a,a.match(/\./)&&(this.namespaced=!0,b=a.split("."),this.componentId=b.pop(),this.namespace=b.join("."),Luca.registry.addNamespace(b.join(".")))}return DefineProxy.prototype["in"]=function(a){return this.namespace=a,this},DefineProxy.prototype.from=function(a){return this.superClassName=a,this},DefineProxy.prototype["extends"]=function(a){return this.superClassName=a,this},DefineProxy.prototype.extend=function(a){return this.superClassName=a,this},DefineProxy.prototype["with"]=function(properties){var at;return at=this.namespaced?Luca.util.resolve(this.namespace,window||global):window||global,this.namespaced&&_.isUndefined(at)&&(eval("window."+this.namespace+" = {}"),at=Luca.util.resolve(this.namespace,window||global)),at[this.componentId]=Luca.extend(this.superClassName,this.componentName,properties),Luca.register(_.string.underscored(this.componentId),this.componentName),at[this.componentId]},DefineProxy}(),Luca.define=function(a){return new DefineProxy(a)},Luca.component=Luca.define,Luca.extend=function(a,b,c){var d;c==null&&(c={}),d=Luca.util.resolve(a,window||global);if(!_.isFunction(d!=null?d.extend:void 0))throw""+a+" is not a valid component to extend from";return c._className=b,c._superClass=function(){return d._className||(d._className=a),d},d.extend(c)},_.mixin({component:Luca.define}),$(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-g-view-wrapper'>\n <div class='g-view-header'>\n <div class='toolbar-container top'></div>\n </div>\n <div class='luca-ui-g-view-body'>\n <table cellpadding='0' cellspacing='0' class='luca-ui-g-view scrollable-table' width='100%'>\n <thead class='fixed'></thead>\n <tbody class='scrollable'></tbody>\n </table>\n </div>\n <div class='luca-ui-g-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_array"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='form-horizontal'>\n <div class='control-group'>\n <label for='",input_id,"'>\n ",label,"\n </label>\n <div class='controls'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/checkbox_array_item"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n <input id='",input_id,"' name='",input_name,"' type='checkbox' value='",value,"' />\n ",label,"\n</label>\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 class='",input_class,"' 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.layoutTemplate!=null&&this.$el.html(),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):(this.trigger("before:render",this),b.apply(this,arguments),this.trigger("after:render",this),this)},Luca.View.originalExtend.call(this,a)},_.extend(Luca.View.prototype,{applyStyles:function(a){var b,c;a==null&&(a={});for(b in a)c=a[b],this.$el.css(b,c);return this},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&&this.observeEvents===!0&&(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 _.string.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}})},registerEvent:function(a,b){return this.events||(this.events={}),this.events[a]=b,this.delegateEvents()}})}.call(this),function(){_.component("Luca.Model")["extends"]("Backbone.Model")["with"]({initialize:function(){var a,b,c,d,e=this;Backbone.Model.prototype.initialize(this,arguments);if(_.isUndefined(this.computed))return;this._computed={},c=this.computed,d=[];for(a in c)b=c[a],this.on("change:"+a,function(){return e._computed[a]=e[a].call(e)}),d.push(_(b).each(function(b){e.on("change:"+b,function(){return e.trigger("change:"+a)});if(e.has(b))return e.trigger("change:"+a)}));return d},get:function(a){var b;return((b=this.computed)!=null?b.hasOwnProperty(a):void 0)?this._computed[a]:Backbone.Model.prototype.get.call(this,a)}})}.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(){_.component("Luca.core.Field")["extends"]("Luca.View")["with"]({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(){_.component("Luca.core.Container")["extends"]("Luca.View")["with"]({className:"luca-ui-container",componentClass:"luca-ui-panel",isContainer:!0,hooks:["before:components","before:render: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.trigger("before:render:components",this,this.components),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 b.appended==null&&a.$el.append(Luca.templates["containers/basic"](b)),b.appended=!0})},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){console.log("Error Rendering Component "+(a.name||a.cid),a),console.log(c.message),console.log(c.stack);if(Luca.silenceRenderErrors!=null!=1)throw c}})},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()}})}.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.initialCollections&&(this.state.set({loaded_collections_count:0,collections_count:this.initialCollections.length}),this.state.bind("change:loaded_collections_count",this.collectionCountDidChange),this.useProgressLoader&&(this.loaderView||(this.loaderView=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=Luca.util.classify(a),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.initialCollections).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
2
- .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(){_.component("Luca.containers.SplitView")["extends"]("Luca.core.Container")["with"]({layout:"100",componentType:"split_view",containerTemplate:"containers/basic",className:"luca-ui-split-view",componentClass:"luca-ui-panel"})}.call(this),function(){_.component("Luca.containers.ColumnView")["extends"]("Luca.core.Container")["with"]({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}})}.call(this),function(){_.component("Luca.containers.CardView")["extends"]("Luca.core.Container")["with"]({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.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])}})}.call(this),function(){_.component("Luca.containers.ModalView")["extends"]("Luca.core.Container")["with"]({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)}})}.call(this),function(){_.component("Luca.containers.PanelView")["extends"]("Luca.core.Container")["with"]({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 _(this.css).each(function(a,c){return b.$el.css(c,a)})}})}.call(this),function(){_.component("Luca.containers.TabView")["extends"]("Luca.containers.CardView")["with"]({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||this.activeTab||this.activeItem)},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(){_.component("Luca.containers.Viewport").extend("Luca.containers.CardView")["with"]({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 this.$el.addClass("luca-ui-viewport")}})}.call(this),function(){}.call(this),function(){_.component("Luca.components.Template")["extends"]("Luca.View")["with"]({templateContainer:"Luca.templates",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)},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)}})}.call(this),function(){_.component("Luca.Application")["extends"]("Luca.containers.Viewport")["with"]({components:[{ctype:"controller",name:"main_controller",defaultCard:"welcome",components:[{ctype:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}]}],initialize:function(a){var b,c=this;return this.options=a!=null?a:{},Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.collectionManager||(this.collectionManager=(typeof (b=Luca.CollectionManager).get=="function"?b.get():void 0)||new Luca.CollectionManager),this.state=new Backbone.Model(this.defaultState),this.bind("ready",function(){return c.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 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(){_.component("Luca.components.Toolbar")["extends"]("Luca.core.Container")["with"]({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)}})}.call(this),function(){_.component("Luca.components.CollectionInspector")["extends"]("Luca.View")["with"]({name:"collection_inspector"})}.call(this),function(){_.component("Luca.components.CollectionLoaderView")["extends"]("Luca.components.Template")["with"]({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,f;return d=a.manager.loadedCollectionsCount(),f=a.manager.totalCollectionsCount(),e=parseInt(d/f*100),c=_.string.titleize(_.string.humanize(b)),a.modalContainer().find(".progress .bar").attr("style","width: "+e+"%;"),a.modalContainer().find(".message").html("Loaded "+c+"...")}),this.manager.bind("all_collections_loaded",function(){return a.modalContainer().find(".message").html("All done!"),_.delay(function(){return a.modalContainer().modal("hide")},400)})}})}.call(this),function(){_.component("Luca.components.Controller")["extends"]("Luca.containers.CardView")["with"]({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(){_.component("Luca.components.DevelopmentConsole")["extends"]("Luca.View")["with"]({name:"development_console",className:"luca-ui-development-console",initialize:function(a){this.options=a!=null?a:{},Luca.View.prototype.initialize.apply(this,arguments);if(this.modal)return this.$el.addClass("luca-ui-modal")},beforeRender:function(){return this.$el.append(this.make("div",{"class":"console-inner"})),this.console_el=this.$(".console-inner"),this.console=this.console_el.console({promptLabel:"Coffee> ",animateScroll:!0,promptHistory:!0,autoFocus:!0,commandValidate:function(a){var b;b=!0,a===""&&(b=!1);try{CoffeeScript.compile(a)?b=!0:b=!1}catch(c){b=!1}return b},returnValue:function(a){return a==null?"undefined":(a!=null?a.toString():void 0)||""},parseLine:function(a){return a=_.string.strip(a),a=a.replace(/^return/," "),"return "+a},commandHandle:function(line){var compiled,ret;if(line==="")return;compiled=CoffeeScript.compile(this.parseLine(line));try{return ret=eval(compiled),this.returnValue(ret)}catch(error){return error.message.match(/circular structure to JSON/)?ret.toString():error.toString()}}})}})}.call(this),function(){_.component("Luca.fields.ButtonField")["extends"]("Luca.core.Field")["with"]({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=""),this.icon_class.length&&!this.icon_class.match(/^icon-/)&&(this.icon_class="icon-"+this.icon_class);if(this.white)return this.icon_class+=" icon-white"},setValue:function(){return!0}})}.call(this),function(){_.component("Luca.fields.CheckboxArray")["extends"]("Luca.core.Field")["with"]({template:"fields/checkbox_array",events:{"click input":"clickHandler"},initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"populateCheckboxes","clickHandler","_updateModel"),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.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.selectedItems=[]},afterInitialize:function(a){this.options=a!=null?a:{};try{this.configure_collection()}catch(b){console.log("Error Configuring Collection",this,b.message)}return this.collection.bind("reset",this.populateCheckboxes)},afterRender:function(){var a,b;return((a=this.collection)!=null?(b=a.models)!=null?b.length:void 0:void 0)>0?this.populateCheckboxes():this.collection.trigger("reset")},clickHandler:function(a){var b;return b=a.target,b.checked?this.selectedItems.push(b.value):this.selectedItems.indexOf(b.value)!==-1&&(this.selectedItems=_.without(this.selectedItems,[b.value])),this._updateModel()},populateCheckboxes:function(){var a,b=this;return a=$(this.el).find(".controls"),a.empty(),_.isUndefined(this.getModel())||(this.selectedItems=this.getModel().get(this.name)),this.collection.each(function(c){var d,e,f;f=c.get(b.valueField),e=c.get(b.displayField),d=_.uniqueId("field"),a.append(Luca.templates["fields/checkbox_array_item"]({label:e,value:f,input_id:d,input_name:b.input_name}));if(_(b.selectedItems).indexOf(f)!==-1)return b.$("#"+d).attr("checked","checked")}),$(this.container).append(this.$el)},_updateModel:function(){var a;return a={},a[this.name]=this.selectedItems,this.getModel().set(a)}})}.call(this),function(){_.component("Luca.fields.CheckboxField")["extends"]("Luca.core.Field")["with"]({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}})}.call(this),function(){_.component("Luca.fields.FileUploadField")["extends"]("Luca.core.Field")["with"]({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="")}})}.call(this),function(){_.component("Luca.fields.HiddenField")["extends"]("Luca.core.Field")["with"]({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)}})}.call(this),function(){_.component("Luca.fields.SelectField")["extends"]("Luca.core.Field")["with"]({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)}})}.call(this),function(){_.component("Luca.fields.TextAreaField")["extends"]("Luca.core.Field")["with"]({events:{"keydown input":"keydown_handler","blur input":"blur_handler","focus input":"focus_handler"},template:"fields/text_area_field",height:"200px",width:"90%",initialize:function(a){return this.options=a!=null?a:{},_.bindAll(this,"keydown_handler"),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)}})}.call(this),function(){_.component("Luca.fields.TextField")["extends"]("Luca.core.Field")["with"]({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.input_class||(this.input_class=this["class"]),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)}})}.call(this),function(){_.component("Luca.fields.TypeAheadField")["extends"]("Luca.fields.TextField")["with"]({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(){_.component("Luca.components.FormButtonToolbar")["extends"]("Luca.components.Toolbar")["with"]({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"})}})}.call(this),function(){_.component("Luca.components.FormView")["extends"]("Luca.core.Container")["with"]({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})},afterComponents:function(){var a,b=this;return(a=Luca.core.Container.prototype.afterComponents)!=null&&a.apply(this,arguments),this.eachField(function(a){return a.getForm=function(){return b},a.getModel=function(){return b.currentModel()}})},render:function(){return $(this.container).append(this.$el),this},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()})},eachField:function(a){return _(this.getFields()).map(a)},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(){if(this.current_model!=null)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==null&&(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),_.string.isBlank(f)&&(a.reject_blank&&!c.send_blanks&&(e=!0),c.input_name==="id"&&(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)}})}.call(this),function(){_.component("Luca.components.GridView").extend("Luca.View")["with"]({autoBindEventHandlers:!0,events:{"dblclick table tbody tr":"double_click_handler","click table tbody tr":"click_handler"},className:"luca-ui-g-view",rowClass:"luca-ui-g-row"
3
- ,wrapperClass:"luca-ui-g-view-wrapper",additionalWrapperClasses:[],wrapperStyles:{},scrollable:!0,emptyText:"No Results To display.",tableStyle:"striped",defaultHeight:285,defaultWidth:756,maxWidth:void 0,hooks:["before:grid:render","before:render:header","before:render:row","after:grid:render","row:double:click","row:click","after:collection:load"],initialize:function(a){var b=this;return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),Luca.View.prototype.initialize.apply(this,arguments),this.configure_collection(),this.collection.bind("reset",function(a){return b.refresh(),b.trigger("after:collection:load",a)}),this.collection.bind("change",function(a){var c,d;try{return d=b.getRowEl(a.id||a.get("id")||a.cid),c=b.render_row(a,b.collection.indexOf(a),{cellsOnly:!0}),$(d).html(c)}catch(e){return console.log("Error in change handler for GridView.collection",e,b)}})},beforeRender:function(){return this.trigger("before:grid:render",this),this.$el.html(Luca.templates["components/grid_view"]()),this.table=this.$("table.luca-ui-g-view"),this.header=this.$("thead"),this.body=this.$("tbody"),this.footer=this.$("tfoot"),this.wrapper=this.$("."+this.wrapperClass),this.applyCssClasses(),this.scrollable&&this.setDimensions(),this.renderHeader(),this.emptyMessage(),this.renderToolbars(),$(this.container).append(this.$el)},applyCssClasses:function(){var a,b=this;return this.scrollable&&this.$el.addClass("scrollable-g-view"),_(this.additionalWrapperClasses).each(function(a){var c;return(c=b.wrapper)!=null?c.addClass(a):void 0}),Luca.enableBootstrap&&this.table.addClass("table"),_((a=this.tableStyle)!=null?a.split(" "):void 0).each(function(a){return b.table.addClass("table-"+a)})},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=this.defaultHeight),this.$(".luca-ui-g-view-body").height(this.height),this.$("tbody.scrollable").height(this.height-23),this.container_width=function(){return $(b.container).width()}(),this.width||(this.width=this.container_width>0?this.container_width:this.defaultWidth),this.width=_([this.width,this.maxWidth||this.width]).max(),this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width),this.setDefaultColumnWidths()},resize:function(a){var b,c,d=this;b=a-this.width,this.width=a,this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width);if(this.columns.length>0)return c=b/this.columns.length,_(this.columns).each(function(a,b){var e;return e=$(".column-"+b,d.el),e.width(a.width=a.width+c)})},padLastColumn:function(){var a,b;a=_(this.columns).inject(function(a,b){return a=b.width+a},0),b=this.width-a;if(b>0)return this.lastColumn().width+=b},setDefaultColumnWidths:function(){var a;return a=this.columns.length>0?this.width/this.columns.length:200,_(this.columns).each(function(b){return parseInt(b.width||(b.width=a))}),this.padLastColumn()},lastColumn:function(){return this.columns[this.columns.length-1]},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>")},getRowEl:function(a){return this.$("[data-record-id="+a+"]","table")},render_row:function(a,b,c){var d,e,f,g,h,i,j=this;return c==null&&(c={}),h=this.rowClass,g=(a!=null?a.get:void 0)&&(a!=null?a.attributes:void 0)?a.get("id"):"",this.trigger("before:render:row",a,b),e=_(this.columns).map(function(b,c){var d,e,f;return f=j.cell_renderer(a,b,c),e=b.width?"width:"+b.width+"px;":"",d=_.isUndefined(f)?"":f,"<td style='"+e+"' class='column-"+c+"'>"+d+"</td>"}),c.cellsOnly?e:(d="",this.alternateRowClasses&&(d=b%2===0?"even":"odd"),f="<tr data-record-id='"+g+"' data-row-index='"+b+"' class='"+h+" "+d+"' id='row-"+b+"'>"+e+"</tr>",c.contentOnly===!0?f:(i=this.body)!=null?i.append(f):void 0)},cell_renderer:function(a,b,c){var d;return _.isFunction(b.renderer)?b.renderer.apply(this,[a,b,c]):b.data.match(/\w+\.\w+/)?(d=a.attributes||a,Luca.util.nestedValue(b.data,d)):(typeof a.get=="function"?a.get(b.data):void 0)||a[b.data]},double_click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:double:click",this,d,e)},click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:click",this,d,e),$("."+this.rowClass,this.body).removeClass("selected-row"),b.addClass("selected-row")}})}.call(this),function(){_.component("Luca.components.RecordManager").extend("Luca.containers.CardView")["with"]({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(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(){var a,b=Array.prototype.slice;(window||global).Luca=function(){var a,c,d,e,f,g;f=arguments[0],a=2<=arguments.length?b.call(arguments,1):[];if(_.isString(f)&&(g=Luca.cache(f)))return g;if(_.isString(f)&&(g=Luca.find(f)))return g;if(_.isObject(f)&&f.ctype!=null)return Luca.util.lazyComponent(f);_.isObject(f)&&f.defines&&f["extends"]&&(c=f.defines,e=f["extends"]);if(_.isFunction(d=_(a).last()))return d()},_.extend(Luca,{VERSION:"0.9.0",core:{},containers:{},components:{},modules:{},util:{},fields:{},registry:{}}),_.extend(Luca,Backbone.Events),Luca.developmentMode=!1,Luca.enableGlobalObserver=!1,Luca.enableBootstrap=!0,Luca.keys={ENTER:13,ESCAPE:27,KEYLEFT:37,KEYUP:38,KEYRIGHT:39,KEYDOWN:40,SPACEBAR:32,FORWARDSLASH:191},Luca.keyMap=_(Luca.keys).inject(function(a,b,c){return a[b]=c.toLowerCase(),a},{}),Luca.find=function(){return},Luca.supportsEvents=Luca.supportsBackboneEvents=function(a){return Luca.isComponent(a)||_.isFunction(a!=null?a.trigger:void 0)||_.isFunction(a!=null?a.bind:void 0)},Luca.isComponent=function(a){return Luca.isBackboneModel(a)||Luca.isBackboneView(a)||Luca.isBackboneCollection(a)},Luca.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.template=function(a,b){var c,d,e,f,g;window.JST||(window.JST={});if(_.isFunction(a))return a(b);d=(g=Luca.templates)!=null?g[a]:void 0,c=typeof JST!="undefined"&&JST!==null?JST[a]:void 0,d==null&&c==null&&(e=new RegExp(""+a+"$"),d=_(Luca.templates).detect(function(a,b){return e.exec(b)}),c=_(JST).detect(function(a,b){return e.exec(b)}));if(!d&&!c)throw"Could not find template named "+a;return f=d||c,b!=null?f(b):f},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},a={module:function(a,b){_.extend(a,b);if(a.included&&_(a.included).isFunction())return a.included.apply(a)},"delete":function(a,b){var c;return c=a[b],delete a[b],c},idle:function(a,b){var c;return b==null&&(b=1e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleShort:function(a,b){var c;return b==null&&(b=100),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleMedium:function(a,b){var c;return b==null&&(b=2e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleLong:function(a,b){var c;return b==null&&(b=5e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}}},_.mixin(a)}).call(this),function(){var currentNamespace;Luca.util.resolve=function(a,b){return b||(b=window||global),_(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)},Luca.util.nestedValue=Luca.util.resolve,Luca.util.classify=function(a){return a==null&&(a=""),_.string.camelize(_.string.capitalize(a))},Luca.util.hook=function(a){var b,c,d;return a==null&&(a=""),c=a.split(":"),d=c.shift(),c=_(c).map(function(a){return _.string.capitalize(a)}),b=d+c.join("")},Luca.util.isIE=function(){try{return Object.defineProperty({},"",{}),!1}catch(a){return!0}},currentNamespace=window||global,Luca.util.namespace=function(namespace){return namespace==null?currentNamespace:(currentNamespace=_.isString(namespace)?Luca.util.resolve(namespace,window||global):namespace,currentNamespace!=null?currentNamespace:currentNamespace=eval("(window||global)."+namespace+" = {}"))},Luca.util.lazyComponent=function(config){var componentClass,constructor,ctype;_.isObject(config)&&(ctype=config.ctype||config.type),_.isString(config)&&(ctype=config),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.util.selectProperties=function(a,b,c){var d;return d=_(b).values(),_(d).select(a)},Luca.util.loadScript=function(a,b){var c;return c=document.createElement("script"),c.type="text/javascript",c.readyState&&(c.onreadystatechange=function(){return c.readyState==="loaded"||c.readyState==="complete"?(c.onreadystatechange=null,b()):c.onload=function(){return b()}}),c.src=a,document.body.appendChild(c)}}.call(this),function(){var DeferredBindingProxy,DefineProxy;Luca.define=function(a){return new DefineProxy(a)},Luca.component=Luca.define,DefineProxy=function(){function DefineProxy(a){var b;this.namespace=Luca.util.namespace(),this.componentId=this.componentName=a,a.match(/\./)&&(this.namespaced=!0,b=a.split("."),this.componentId=b.pop(),this.namespace=b.join("."),Luca.registry.addNamespace(b.join(".")))}return DefineProxy.prototype["in"]=function(a){return this.namespace=a,this},DefineProxy.prototype.from=function(a){return this.superClassName=a,this},DefineProxy.prototype["extends"]=function(a){return this.superClassName=a,this},DefineProxy.prototype.extend=function(a){return this.superClassName=a,this},DefineProxy.prototype.enhance=function(a){return a!=null?this["with"](a):this},DefineProxy.prototype["with"]=function(properties){var at;return at=this.namespaced?Luca.util.resolve(this.namespace,window||global):window||global,this.namespaced&&at==null&&(eval("(window||global)."+this.namespace+" = {}"),at=Luca.util.resolve(this.namespace,window||global)),at[this.componentId]=Luca.extend(this.superClassName,this.componentName,properties),Luca.register(_.string.underscored(this.componentId),this.componentName),at[this.componentId]},DefineProxy}(),Luca.extend=function(a,b,c){var d;c==null&&(c={}),d=Luca.util.resolve(a,window||global);if(!_.isFunction(d!=null?d.extend:void 0))throw""+a+" is not a valid component to extend from";return c.displayName=b,c._superClass=function(){return d.displayName||(d.displayName=a),d},c._super=function(a,b,c){var d;return(d=this._superClass().prototype[a])!=null?d.apply(b,c):void 0},d.extend(c)},_.mixin({def:Luca.define}),DeferredBindingProxy=function(){function a(a,b,c){var d,e=this;this.object=a,c==null&&(c=!0),_.isFunction(b)?d=b:_.isString(b)&&_.isFunction(this.object[b])&&(d=this.object[b]);if(!_.isFunction(d))throw"Must pass a function or a string representing one";c===!0?this.fn=function(){return _.defer(d)}:this.fn=d,this}return a.prototype.until=function(a,b){return a!=null&&b==null&&(b=a,a=this.object),a.once(b,this.fn),this.object},a}(),Luca.Events={defer:function(a,b){return b==null&&(b=!0),new DeferredBindingProxy(this,a,b)},once:function(a,b,c){var d;return c||(c=this),d=function(){return b.apply(c,arguments),this.unbind(a,d)},this.bind(a,d)}},Luca.ScriptLoader=function(){function a(a){var b;a==null&&(a={}),_.extend(this,Backbone.Events,Luca.Events),this.autoStart=a.autoStart===!0,this.scripts=a.scripts,b=function(){return this.trigger("ready")},this.ready=_.after(this.scripts.length,b),_.bindAll(this,"load","ready"),this.defer("load").until(this,"start"),this.autoStart===!0&&this.trigger("start"),this.bind("ready",this.onReady)}return a.loaded={},a.prototype.applyPrefix=function(a){return a},a.prototype.onReady=function(){return console.log("All dependencies loaded")},a.prototype.start=function(){return this.trigger("start")},a.prototype.load=function(){var a,b,c,d,e;d=this.scripts,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(Luca.util.loadScript(this.applyPrefix(a),this.ready));return e},a}()}.call(this),function(){var a,b;b={classes:{},namespaces:["Luca.containers","Luca.components"]},a={cid_index:{},name_index:{}},Luca.defaultComponentType="view",Luca.register=function(a,c){return Luca.trigger("component:registered",a,c),b.classes[a]=c},Luca.development_mode_register=function(a,c){var d,e,f;return d=b.classes[a],Luca.enableDevelopmentTools===!0&&d!=null&&(f=Luca.util.resolve(d,window),e=Luca.registry.findInstancesByClassName(c),_(e).each(function(a){var b;return a!=null?(b=a.refreshCode)!=null?b.call(a,f):void 0:void 0})),Luca.register(a,c)},Luca.registry.addNamespace=function(a){return b.namespaces.push(a),b.namespaces=_(b.namespaces).uniq()},Luca.registry.namespaces=function(a){return a==null&&(a=!0),_(b.namespaces).map(function(b){return a?Luca.util.resolve(b):b})},Luca.registry.lookup=function(a){var c,d,e,f,g;return c=b.classes[a],c!=null?c:(d=Luca.util.classify(a),f=Luca.registry.namespaces(),e=(g=_(f).chain().map(function(a){return a[d]}).compact().value())!=null?g[0]:void 0)},Luca.registry.findInstancesByClassName=function(b){var c;return c=_(a.cid_index).values(),_(c).select(function(a){var c;return a.displayName===b||(typeof a._superClass=="function"?(c=a._superClass())!=null?c.displayName:void 0:void 0)===b})},Luca.registry.classes=function(a){return a==null&&(a=!1),_(b.classes).map(function(b,c){return a?b:{className:b,ctype:c}})},Luca.cache=function(b,c){var d;return c!=null&&(a.cid_index[b]=c),c=a.cid_index[b],(c!=null?c.component_name:void 0)!=null?(Luca.trigger("component:created:"+c.component_name,c),a.name_index[c.component_name]=c.cid):(c!=null?c.name:void 0)!=null&&(Luca.trigger("component:created:"+c.component_name,c),a.name_index[c.name]=c.cid),c!=null?c:(d=a.name_index[b],a.cid_index[d])}}.call(this),function(){var a,b;_.def("Luca.View")["extends"]("Backbone.View")["with"]({additionalClassNames:[],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.developmentMode===!0||this.observeEvents===!0)&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)},hooks:["after:initialize","before:render","after:render","first:activation","activation","deactivation"],initialize:function(a){var b,c,d,e,f,g;this.options=a!=null?a:{},_.extend(this,this.options),this.name!=null&&(this.cid=_.uniqueId(this.name));if(c=this.bodyTemplate)this.$el.empty(),Luca.View.prototype.$html.call(this,Luca.template(c,this));Luca.cache(this.cid,this),d=_(Luca.View.prototype.hooks.concat(this.hooks)).uniq(),this.setupHooks(d),this.autoBindEventHandlers===!0&&this.bindAllEventHandlers();if(this.additionalClassNames){_.isString(this.additionalClassNames)&&(this.additionalClassNames=this.additionalClassNames.split(" ")),g=this.additionalClassNames;for(e=0,f=g.length;e<f;e++)b=g[e],this.$el.addClass(b)}return this.trigger("after:initialize",this),this.registerCollectionEvents(),this.delegateEvents()},$wrap:function(a){return a.match(/[<>]/)||(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$el.html(Luca.template(a,b))},$html:function(a){return this.$el.html(a)},$append:function(a){return this.$el.append(a)},$attach:function(){return this.$container().append(this.el)},$container:function(){return $(this.container)},setupHooks:function(a){var b=this;return a||(a=this.hooks),_(a).each(function(a){var c,d;d=Luca.util.hook(a),c=function(){var a;return(a=b[d])!=null?a.apply(b,arguments):void 0};if(a!=null?a.match(/once:/):void 0)c=_.once(c);return b.bind(a,c)})},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}})},registerEvent:function(a,b){return this.events||(this.events={}),this.events[a]=b,this.delegateEvents()},bindAllEventHandlers:function(){var a=this;return _(this.events).each(function(b,c){if(_.isString(b))return _.bindAll(a,b)})},definitionClass:function(){var a;return(a=Luca.util.resolve(this.displayName,window))!=null?a.prototype:void 0},refreshCode:function(){var a;return a=this,_(this.eventHandlerProperties()).each(function(b){return a[b]=a.definitionClass()[b]}),this.autoBindEventHandlers===!0&&this.bindAllEventHandlers(),this.delegateEvents()},eventHandlerProperties:function(){var a;return a=_(this.events).values(),_(a).select(function(a){return _.isString(a)})},eventHandlerFunctions:function(){var a,b=this;return a=_(this.events).values(),_(a).map(function(a){return _.isFunction(a)?a:b[a]})},collections:function(){return Luca.util.selectProperties(Luca.isBackboneCollection,this)},models:function(){return Luca.util.selectProperties(Luca.isBackboneModel,this)},views:function(){return Luca.util.selectProperties(Luca.isBackboneView,this)}}),b=Backbone.View.extend,a=function(a){var b;return b=a.render,b||(b=Luca.View.prototype.$attach),a.render=function(){var a,c,d,e,f,g=this;return f=this,this.deferrable?(d=this.deferrable_target,Luca.isBackboneCollection(this.deferrable)||(this.deferrable=this.collection),d||(d=this.deferrable),e=this.deferrable_event?this.deferrable_event:"reset",f.defer(function(){return b.call(f),f.trigger("after:render",f)}).until(d,e),f.trigger("before:render",this),a=this.deferrable_trigger||this.deferUntil,a==null?d[this.deferrable_method||"fetch"].call(d):(c=_.once(function(){var a,b;return typeof (a=g.deferrable)[b=g.deferrable_method||"fetch"]=="function"?a[b]():void 0}),(this.deferrable_target||this).bind(this.deferrable_trigger,c)),this):(this.trigger("before:render",this),b.apply(this,arguments),this.trigger("after:render",this),this)},a},Luca.View.extend=function(c){return c=a(c),b.call(this,c)}}.call(this),function(){_.def("Luca.Model")["extends"]("Backbone.Model")["with"]({initialize:function(){var a,b,c,d,e=this;Backbone.Model.prototype.initialize(this,arguments);if(_.isUndefined(this.computed))return;this._computed={},c=this.computed,d=[];for(a in c)b=c[a],this.on("change:"+a,function(){return e._computed[a]=e[a].call(e)}),d.push(_(b).each(function(b){e.on("change:"+b,function(){return e.trigger("change:"+a)});if(e.has(b))return e.trigger("change:"+a)}));return d},get:function(a){var b;return((b=this.computed)!=null?b.hasOwnProperty(a):void 0)?this._computed[a]:Backbone.Model.prototype.get.call(this,a)}})}.call(this),function(){var a;a="Backbone.Collection",Backbone.QueryCollection!=null&&(a="Backbone.QueryCollection"),_.def("Luca.Collection")["extends"](a)["with"]({cachedMethods:[],restoreMethodCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],a.original!=null?(a.args=void 0,d.push(this[b]=a.original)):d.push(void 0);return d},clearMethodCache:function(a){return this._methodCache[a].value=void 0},clearAllMethodsCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],d.push(this.clearMethodCache(b));return d},setupMethodCaching:function(){var a,b,c;return b=this,c=["reset","add","remove"],a=this._methodCache={},_(this.cachedMethods).each(function(d){var e,f,g,h,i,j,k,l,m;a[d]={name:d,original:b[d],value:void 0},b[d]=function(){var c;return(c=a[d]).value||(c.value=a[d].original.apply(b,arguments))};for(h=0,j=c.length;h<j;h++)g=c[h],b.bind(g,function(){return b.clearAllMethodsCache()});e=d.split(":")[1];if(e){l=e.split(","),m=[];for(i=0,k=l.length;i<k;i++)f=l[i],m.push(b.bind("change:"+f,function(){return b.clearMethodCache({method:d})}));return m}})},initialize:function(a,b){var c,d=this;a==null&&(a=[]),this.options=b,_.extend(this,this.options),this.setupMethodCaching(),this._reset(),this.cached&&console.log("The @cached property of Luca.Collection is being deprecated. Please change to cache_key");if(this.cache_key||(this.cache_key=this.cached))this.bootstrap_cache_key=_.isFunction(this.cache_key)?this.cache_key():this.cache_key;(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.cache_key()),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},remoteFilter:!0,applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b.remote!=null==1?(this.applyParams(a),this.fetch(_.extend(b,{refresh:!0}))):this.reset(this.query(a))},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(){var a;a=function(a){var b,c,d,e,f;return a==null&&(a={}),a.orientation||(a.orientation="top"),a.ctype||(a.ctype=this.toolbarType||"panel_toolbar"),e=""+this.cid+"-tbc-"+a.orientation,f=Luca.util.lazyComponent(a),c=this.make("div",{"class":"toolbar-container "+a.orientation,id:e},f.render().el),d=this.bodyClassName||this.bodyTagName,b=function(){switch(a.orientation){case"top":case"left":return d?"before":"prepend";case"bottom":case"right":return d?"after":"append"}}(),this.$bodyEl()[b](c)},_.def("Luca.components.Panel")["extends"]("Luca.View")["with"]({topToolbar:void 0,bottomToolbar:void 0,loadMask:!1,loadMaskTemplate:["components/load_mask"],initialize:function(a){var b=this;this.options=a!=null?a:{},Luca.View.prototype.initialize.apply(this,arguments);if(this.loadMask===!0)return this.defer(function(){b.$el.addClass("with-mask");if(b.$(".load-mask").length===0)return b.loadMaskTarget().prepend(Luca.template(b.loadMaskTemplate,b)),b.$(".load-mask").hide()}).until("after:render"),this.on("enable:loadmask",this.applyLoadMask),this.on("disable:loadmask",this.applyLoadMask)},loadMaskTarget:function(){return this.loadMaskEl!=null?this.$(this.loadMaskEl):this.$bodyEl()},applyLoadMask:function(){var a,b=this;return this.$(".load-mask").is(":visible")?(this.$(".load-mask .bar").css("width","100%"),this.$(".load-mask").hide(),clearInterval(this.loadMaskInterval)):(this.$(".load-mask").show().find(".bar").css("width","0%"),a=this.$(".load-mask .progress").width(),a<20&&(a=this.$el.width())<20&&(a=this.$el.parent().width()),this.loadMaskInterval=setInterval(function(){var a,c;return a=b.$(".load-mask .bar").width(),c=a+12,b.$(".load-mask .bar").css("width",c)},200))},applyStyles:function(a,b){var c,d,e;a==null&&(a={}),b==null&&(b=!1),d=b?this.$bodyEl():this.$el;for(c in a)e=a[c],d.css(c,e);return this},beforeRender:function(){var a;return(a=Luca.View.prototype.beforeRender)!=null&&a.apply(this,arguments),this.styles!=null&&this.applyStyles(this.styles),this.bodyStyles!=null&&this.applyStyles(this.bodyStyles,!0),typeof this.renderToolbars=="function"?this.renderToolbars():void 0},$bodyEl:function(){var a,b,c,d;return c=this.bodyTagName||"div",b=this.bodyClassName||"view-body",this.bodyEl||(this.bodyEl=""+c+"."+b),a=this.$(this.bodyEl),a.length>0?a:a.length!==0||this.bodyClassName==null&&this.bodyTagName==null?$(this.el):(d=this.make(c,{"class":b,"data-auto-appended":!0}),$(this.el).append(d),this.$(this.bodyEl))},$wrap:function(a){return a.match(/[<>]/)||(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$html(Luca.template(a,b))},$html:function(a){return this.$bodyEl().html(a)},$append:function(a){return this.$bodyEl().append(a)},renderToolbars:function(){var a=this;return _(["top","left","right","bottom"]).each(function(b){var c;if(c=a[""+b+"Toolbar"])return a.renderToolbar(b,c)})},renderToolbar:function(b,c){return b==null&&(b="top"),c==null&&(c={}),c.parent=this,c.orientation=b,a.call(this,c)}})}.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' style='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='form-view-panel'>\n <ul class='form-view-flash-container'></ul>\n <div class='form-view-body'></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-g-view-wrapper'>\n <div class='g-view-header'></div>\n <div class='luca-ui-g-view-body'>\n <table cellpadding='0' cellspacing='0' class='luca-ui-g-view scrollable-table' width='100%'>\n <thead class='fixed'></thead>\n <tbody class='scrollable'></tbody>\n </table>\n </div>\n <div class='luca-ui-g-view-footer'></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["components/load_mask"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='load-mask'>\n <div class='progress progress-striped active'>\n <div class='bar' style='width:1%'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/nav_bar"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='navbar-inner'>\n <div class='luca-ui-navbar-body container'></div>\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("<ul class='nav nav-tabs' id='",cid,"-tabs-selector'></ul>\n<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_array"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='form-horizontal'>\n <div class='control-group'>\n <label for='",input_id,"'>\n ",label,"\n </label>\n <div class='controls'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/checkbox_array_item"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n <input id='",input_id,"' name='",input_name,"' type='checkbox' value='",value,"' />\n ",label,"\n</label>\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.
2
+ 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(""),(typeof label!="undefined"&&typeof hideLabel!="undefined"&&!hideLabel||typeof hideLabel=="undefined")&&__p.push("\n<label class='control-label' for='",input_id,"'>\n ",label,"\n</label>\n"),__p.push("\n"),typeof addOn!="undefined"&&__p.push("\n<span class='add-on'>\n ",addOn,"\n</span>\n"),__p.push("\n<input class='",input_class,"' 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(a){var b=this;this.options=a!=null?a:{},_.extend(this,Backbone.Events),this.type=this.options.type,this.options.debugAll&&this.bind("all",function(a,b,c){return console.log("ALL",a,b,c)})}return b.prototype.relay=function(){var b,c;return c=arguments[0],b=2<=arguments.length?a.call(arguments,1):[],console.log("Relaying",trigger,b),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(){_.def("Luca.core.Field")["extends"]("Luca.View")["with"]({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),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_class||(this.input_class=""),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=""),Luca.View.prototype.initialize.apply(this,arguments)},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(){var a,b,c;c=function(){return this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},a=function(a,b){var c,d;return d=[],a.height!=null&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width!=null&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={"class":(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";"),"data-luca-owner":this.name||this.cid},this.customizeContainerEl!=null&&(c=this.customizeContainerEl(c,a,b)),c},b=function(){return this.trigger("before:components",this,this.components),this.prepareComponents(),this.createComponents(),this.trigger("before:render:components",this,this.components),this.renderComponents(),this.trigger("after:components",this,this.components)},_.def("Luca.core.Container")["extends"]("Luca.components.Panel")["with"]({className:"luca-ui-container",componentTag:"div",componentClass:"luca-ui-panel",isContainer:!0,hooks:["before:components","before:render: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(["before:components","before:render:components","before:layout","after:components","after:layout","first:activation"]),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){var a;return c.call(this),b.call(this),(a=Luca.components.Panel.prototype.beforeRender)!=null?a.apply(this,arguments):void 0},customizeContainerEl:function(a,b,c){return a},prepareLayout:function(){var b;return b=this,this.componentContainers=_(this.components).map(function(c,d){return a.call(b,c,d)})},prepareComponents:function(){var a,b,c,d,e=this;d=this.components;for(b=0,c=d.length;b<c;b++)a=d[b],_.isString(a)&&(a={type:a});return _(this.components).each(function(a,b){var c,d,f;c=(f=e.componentContainers)!=null?f[b]:void 0,c["class"]=c["class"]||c.className||c.classes,e.appendContainers&&(d=e.make(e.componentTag,c,""),e.$append(d));if(a.container==null)return e.appendContainers&&(a.container="#"+c.id),a.container||(a.container=e.$bodyEl())})},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=Luca.isBackboneView(b)?b:(b.type||(b.type=b.ctype),b.type==null?b.components!=null?b.type=b.ctype="container":b.type=b.ctype=Luca.defaultComponentType:void 0,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,_.isEmpty(this.componentEvents)||this.registerComponentEvents(),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){console.log("Error Rendering Component "+(a.name||a.cid),a),_.isObject(c)&&(console.log(c.message),console.log(c.stack));if(Luca.silenceRenderErrors!=null!=1)throw c}})},firstActivation:function(){var a;return a=this,this.each(function(b,c){var d;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.call(b,"first:activation",b,a),b.previously_activated=!0})},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)},componentEvents:{},registerComponentEvents:function(){var a,b,c,d,e,f,g,h;f=this.componentEvents,h=[];for(d in f)c=f[d],g=d.split(" "),b=g[0],e=g[1],a=this.findComponentByName(b),h.push(a!=null?a.bind(e,this[c]):void 0);return h},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},each:function(a){return this.eachComponent(a,!1)},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c,d){var e;a.call(c,c,d);if(b)return c!=null?(e=c.eachComponent)!=null?e.apply(c,[a,b]):void 0:void 0})},indexOf:function(a){var b;return b=_(this.components).pluck("name"),_(b).indexOf(a)},activeComponent:function(){return this.activeItem?this.components[this.activeItem]:this},componentElements:function(){return $(">."+this.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()}})}.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.initialCollections&&(this.state.set({loaded_collections_count:0,collections_count:this.initialCollections.length}),this.state.bind("change:loaded_collections_count",this.collectionCountDidChange),this.useProgressLoader&&(this.loaderView||(this.loaderView=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=Luca.util.classify(a),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.initialCollections).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(){_.def("Luca.containers.SplitView")["extends"]("Luca.core.Container")["with"]({componentType:"split_view",containerTemplate:"containers/basic",className:"luca-ui-split-view",componentClass:"luca-ui-panel"})}.call(this),function(){_.def("Luca.containers.ColumnView")["extends"]("Luca.core.Container")["with"]({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+"%"})},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}})}.call(this),function(){_.def("Luca.containers.CardView")["extends"]("Luca.core.Container")["with"]({componentType:"card_view",className:"luca-ui-card-view-wrapper",activeCard:0,components:[],hooks:["before:card:switch","after:card:switch"],componentClass:"luca-ui-card",appendContainers:!0,initialize:function(a){return this.options=a,Luca.core.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks)},prepareComponents:function(){var a,b=this;return(a=Luca.core.Container.prototype.prepareComponents)!=null&&a.apply(this,arguments),_(this.components).each(function(a,c){return c===b.activeCard?$(a.container).show():$(a.container).hide()})},activeComponentElement:function(){return this.componentElements().eq(this.activeCard)},activeComponent:function(){return this.getComponent(this.activeCard)},customizeContainerEl:function(a,b,c){return a.style+=c===this.activeCard?"display:block;":"display:none;",a},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.componentElements().hide(),d.previously_activated||(d.trigger("first:activation"),d.previously_activated=!0),this.activeCard=a,this.activeComponentElement().show(),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])}})}.call(this),function(){_.def("Luca.ModalView")["extends"]("Luca.View")["with"]({closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")},render:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0})}}),_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]()}.call(this),function(){var a,b,c;b=Backbone.View.prototype.make,a=function(a,d){var e,f,g,h,i,j,k,l,m,n,o=this;d==null&&(d=!0);if(a.ctype!=null){a.className||(a.className=""),a.className+="toolbar-component",l=Luca(a).render();if(Luca.isBackboneView(l))return console.log("Adding toolbar component",l),l.el}return a.spacer?b("div",{"class":"spacer "+a.spacer}):a.text?b("div",{"class":"toolbar-text"},a.text):(n="btn-group",a.wrapper!=null&&(n+=" "+a.wrapper),a.align!=null&&(n+=" align-"+a.align),a.group!=null&&a.buttons!=null?(h=c(a.buttons,!1),b("div",{"class":n},h)):(k=a.label||(a.label=""),a.eventId||(a.eventId=_.string.dasherize(a.label.toLowerCase())),a.icon&&(_.string.isBlank(k)&&(k=" "),a.white&&(m="icon-white"),k="<i class='"+(m||"")+" icon-"+a.icon+"' /> "+k),f={"class":_.compact(["btn",a.classes,a.className]).join(" "),"data-eventId":a.eventId,title:a.title||a.description},a.color!=null&&(f["class"]+=" btn-"+a.color),a.dropdown&&(k=""+k+" <span class='caret'></span>",f["class"]+=" dropdown-toggle",f["data-toggle"]="dropdown",j=_(a.dropdown).map(function(a){var c;return c=b("a",{},a[1]),b("li",{"data-eventId":a[0]},c)}),i=b("ul",{"class":"dropdown-menu"},j)),g=b("a",f,k),e="btn-group",a.align!=null&&(e+=" align-"+a.align),d===!0?b("div",{"class":e},[g,i]):g))},c=function(b,c){return c==null&&(c=!0),_(b).map(function(b){return a(b,c)})},_.def("Luca.containers.PanelToolbar")["extends"]("Luca.View")["with"]({className:"luca-ui-toolbar btn-toolbar",buttons:[],well:!0,orientation:"top",autoBindEventHandlers:!0,events:{"click a.btn, click .dropdown-menu li":"clickHandler"},clickHandler:function(a){var b,c,d,e,f;d=e=$(a.target),d.is("i")&&(d=e=$(a.target).parent()),b=e.data("eventid");if(b==null)return;return c=Luca.util.hook(b),f=this.parent||this,_.isFunction(f[c])?f[c].call(this,d,a):f.trigger(b,d,a)},beforeRender:function(){this._super("beforeRender",this,arguments),this.well===!0&&this.$el.addClass("well"),this.$el.addClass("toolbar-"+this.orientation);if(this.styles!=null)return this.applyStyles(this.styles)},render:function(){var a,b=this;return this.$el.empty(),a=c(this.buttons),_(a).each(function(a){return b.$el.append(a)})},afterRender:function(){return this._super("afterRender",this,arguments)}})}.call(this),function(){_.def("Luca.containers.PanelView")["extends"]("Luca.core.Container")["with"]({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 _(this.css).each(function(a,c){return b.$el.css(c,a)})}})}.call(this),function(){_.def("Luca.containers.TabView")["extends"]("Luca.containers.CardView")["with"]({hooks:["before:select","after:select"],componentType:"tab_view",className:"luca-ui-tab-view tabbable",tab_position:"top",tabVerticalOffset:"50px",bodyTemplate:"containers/tab_view",bodyEl:"div.tab-content",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||this.activeTab||this.activeItem)},beforeLayout:function(){var a;return this.$el.addClass("tabs-"+this.tab_position),this.activeTabSelector().addClass("active"),this.createTabSelectors(),(a=Luca.containers.CardView.prototype.beforeLayout)!=null?a.apply(this,arguments):void 0},afterRender:function(){var a;(a=Luca.containers.CardView.prototype.afterRender)!=null&&a.apply(this,arguments),this.registerEvent("click #"+this.cid+"-tabs-selector li a","select");if(Luca.enableBootstrap&&(this.tab_position==="left"||this.tab_position==="right"))return this.tabContainerWrapper().addClass("span2"),this.tabContentWrapper().addClass("span9")},createTabSelectors:function(){var a;return a=this,this.each(function(b,c){var d;return d=a.make("li",{"class":"tab-selector","data-target":c},"<a>"+b.title+"</a>"),a.tabContainer().append(d)})},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},select:function(a){var b,c;return b=c=$(a.target),this.trigger("before:select",this),this.activate(c.parent().data("target")),this.trigger("after:select",this)},componentElements:function(){return this.$(">.tab-content >."+this.componentClass)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return this.$("ul.nav-tabs",this.tabContainerWrapper())},tabSelectors:function(){return this.$("li.tab-selector",this.tabContainer())}})}.call(this),function(){_.def("Luca.containers.Viewport").extend("Luca.containers.CardView")["with"]({activeItem:0,className:"luca-ui-viewport",fullscreen:!0,fluid:!1,wrapperClass:"row",initialize:function(a){this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments),Luca.enableBootstrap===!0&&(this.fluid===!0&&(this.wrapperClass="row-fluid"),this.$el.wrap("<div class='"+this.wrapperClass+"' />").addClass("span12"));if(this.fullscreen)return $("html,body").addClass("luca-ui-fullscreen")},beforeRender:function(){var a;(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),Luca.enableBootstrap&&this.topNav&&this.fullscreen&&$("body").css("padding","40px"),this.topNav!=null&&this.renderTopNavigation();if(this.bottomNav!=null)return this.renderBottomNavigation()},renderTopNavigation:function(){var a;if(this.topNav==null)return;return _.isString(this.topNav)&&(this.topNav=Luca.util.lazyComponent(this.topNav)),_.isObject(this.topNav)&&((a=this.topNav).ctype||(a.ctype=this.topNav.type||"nav_bar"),Luca.isBackboneView(this.topNav)||(this.topNav=Luca.util.lazyComponent(this.topNav))),this.topNav.app=this,$("body").prepend(this.topNav.render().el)},renderBottomNavigation:function(){}})}.call(this),function(){}.call(this),function(){_.def("Luca.components.Template")["extends"]("Luca.View")["with"]({initialize:function(a){return this.options=a!=null?a:{},console.log("The Use of Luca.components.Template directly is being DEPRECATED"),Luca.View.prototype.initialize.apply(this,arguments)}})}.call(this),function(){_.def("Luca.Application")["extends"]("Luca.containers.Viewport")["with"]({autoStartHistory:!0,useCollectionManager:!0,plugin:!1,useController:!0,components:[{ctype:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}],initialize:function(a){var b,c,d=this;this.options=a!=null?a:{},Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.useController===!0&&(b=this.components||[]),this.components=[{ctype:"controller",name:"main_controller",components:b}],this.useCollectionManager===!0&&(this.collectionManager||(this.collectionManager=typeof (c=Luca.CollectionManager).get=="function"?c.get():void 0),this.collectionManager||(this.collectionManager=new Luca.CollectionManager(this.collectionManagerOptions||(this.collectionManagerOptions={})))),this.state=new Backbone.Model(this.defaultState),this.bind("ready",function(){return d.render()}),this.useKeyRouter===!0&&this.keyEvents!=null&&this.setupKeyRouter();if(this.plugin!==!0)return Luca.getApplication=function(){return d}},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")},beforeRender:function(){var a,b;(b=Luca.containers.Viewport.prototype.beforeRender)!=null&&b.apply(this,arguments);if(this.router!=null&&this.autoStartHistory===!0)return a=this.startRouterOn||"after:render",a==="before:render"?Backbone.history.start():this.bind(a,function(){return Backbone.history.start()})},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},boot:function(){return 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.useController===!0?this.components[0]:Luca.cache("main_controller")},set:function(a){return this.state.set(a)},view:function(a){return Luca.cache(a)},navigate_to:function(a,b){return this.getMainController().navigate_to(a,b)},setupKeyRouter:function(){var a,b;if(!this.keyEvents)return;return(b=this.keyEvents).control_meta||(b.control_meta={}),this.keyEvents.meta_control&&_.extend(this.keyEvents.control_meta,this.keyEvents.meta_control),a=_.bind(this.keyRouter,this),$(document).keydown(a)},keyRouter:function(a){var b,c,d,e,f,g,h;if(!a||!this.keyEvents)return;c=$(a.target).is("input")||$(a.target).is("textarea");if(c)return;e=Luca.keyMap[a.keyCode];if(!e)return;f=(a!=null?a.metaKey:void 0)===!0,b=(a!=null?a.ctrlKey:void 0)===!0,g=this.keyEvents,g=f?this.keyEvents.meta:g,g=b?this.keyEvents.control:g,g=f&&b?this.keyEvents.meta_control:g;if(d=g!=null?g[e]:void 0)return this[d]!=null?(h=this[d])!=null?h.call(this):void 0:this.trigger(d)}})}.call(this),function(){_.def("Luca.components.Toolbar")["extends"]("Luca.core.Container")["with"]({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)}})}.call(this),function(){_.def("Luca.components.CollectionLoaderView")["extends"]("Luca.components.Template")["with"]({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,f;return d=a.manager.loadedCollectionsCount(),f=a.manager.totalCollectionsCount(),e=parseInt(d/f*100),c=_.string.titleize(_.string.humanize(b)),a.modalContainer().find(".progress .bar").attr("style","width: "+e+"%;"),a.modalContainer().find(".message").html("Loaded "+c+"...")}),this.manager.bind("all_collections_loaded",function(){return a.modalContainer().find(".message").html("All done!"),_.delay(function(){return a.modalContainer().modal("hide")},400)})}})}.call(this),function(){var a;a=Luca.View.prototype.make,_.def("Luca.components.CollectionView")["extends"]("Luca.components.Panel")["with"]({tagName:"div",className:"luca-ui-collection-view",bodyClassName:"collection-ui-panel",itemTemplate:void 0,itemRenderer:void 0,itemTagName:"li",itemClassName:"collection-item",initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"refresh");if(this.collection==null)throw"Collection Views must specify a collection";if(this.itemTemplate==null&&this.itemRenderer==null)throw"Collection Views must specify an item template or item renderer function";Luca.components.Panel.prototype.initialize.apply(this,arguments);if(Luca.isBackboneCollection(this.collection))return this.collection.bind("reset",this.refresh),this.collection.bind("add",this.refresh),this.collection.bind("remove",this.refresh)},attributesForItem:function(a){return _.extend({},{"class":this.itemClassName,"data-index":a.index})},contentForItem:function(a){var b,c;return a==null&&(a={}),this.itemTemplate!=null&&(c=Luca.template(this.itemTemplate))&&(b=c.call(this,a)),this.itemRenderer!=null&&_.isFunction(this.itemRenderer)&&(b=this.itemRenderer.call(this,a)),b||""},makeItem:function(b,c){var d;return d=this.prepareItem!=null?this.prepareItem.call(this,b,c):{model:b,index:c},a(this.itemTagName,this.attributesForItem(d),this.contentForItem(d))},getModels:function(){return this.collection.models},refresh:function(){var a;return a=this,this.$bodyEl().empty(),_(this.getModels()).each(function(b,c){return a.$append(a.makeItem(b,c))})},registerEvent:function(a,b,c){var d;return c==null&&_.isFunction(b)&&(c=b,b=void 0),d=_([a,""+this.itemTagName+"."+this.itemClassName,b]).compact().join(" "),Luca.View.prototype.registerEvent(d,c)},render:function(){this.refresh();if(this.$el.parent().length>0&&this.container!=null)return this.$attach()}})}.call(this),function(){_.def("Luca.components.Controller")["extends"]("Luca.containers.CardView")["with"]({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(){_.def("Luca.fields.ButtonField")["extends"]("Luca.core.Field")["with"]({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=""),this.icon_class.length&&!this.icon_class.match(/^icon-/)&&(this.icon_class="icon-"+this.icon_class);if(this.white)return this.icon_class+=" icon-white"},setValue:function(){return!0}})}.call(this),function(){_.def("Luca.fields.CheckboxArray")["extends"]("Luca.core.Field")["with"]({template:"fields/checkbox_array",events:{"click input":"clickHandler"},initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"populateCheckboxes","clickHandler","_updateModel"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this
3
+ .name),this.label||(this.label=this.name),this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.selectedItems=[]},afterInitialize:function(a){this.options=a!=null?a:{};try{this.configure_collection()}catch(b){console.log("Error Configuring Collection",this,b.message)}return this.collection.bind("reset",this.populateCheckboxes)},afterRender:function(){var a;return((a=this.collection)!=null?a.length:void 0)>0?this.populateCheckboxes():this.collection.trigger("reset")},clickHandler:function(a){var b;return b=a.target,b.checked?this.selectedItems.push(b.value):this.selectedItems.indexOf(b.value)!==-1&&(this.selectedItems=_.without(this.selectedItems,[b.value])),this._updateModel()},populateCheckboxes:function(){var a,b=this;return a=$(this.el).find(".controls"),a.empty(),_.isUndefined(this.getModel())||(this.selectedItems=this.getModel().get(this.name)),this.collection.each(function(c){var d,e,f;f=c.get(b.valueField),e=c.get(b.displayField),d=_.uniqueId("field"),a.append(Luca.templates["fields/checkbox_array_item"]({label:e,value:f,input_id:d,input_name:b.input_name}));if(_(b.selectedItems).indexOf(f)!==-1)return b.$("#"+d).attr("checked","checked")}),$(this.container).append(this.$el)},_updateModel:function(){var a;return a={},a[this.name]=this.selectedItems,this.getModel().set(a)}})}.call(this),function(){_.def("Luca.fields.CheckboxField")["extends"]("Luca.core.Field")["with"]({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"],send_blanks:!0,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}})}.call(this),function(){_.def("Luca.fields.FileUploadField")["extends"]("Luca.core.Field")["with"]({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="")}})}.call(this),function(){_.def("Luca.fields.HiddenField")["extends"]("Luca.core.Field")["with"]({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)}})}.call(this),function(){_.def("Luca.fields.SelectField")["extends"]("Luca.core.Field")["with"]({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)}})}.call(this),function(){_.def("Luca.fields.TextAreaField")["extends"]("Luca.core.Field")["with"]({events:{"keydown input":"keydown_handler","blur input":"blur_handler","focus input":"focus_handler"},template:"fields/text_area_field",height:"200px",width:"90%",initialize:function(a){return this.options=a!=null?a:{},_.bindAll(this,"keydown_handler"),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)}})}.call(this),function(){var a;a=function(a){return this.trigger("on:change",this,a)},_.def("Luca.fields.TextField")["extends"]("Luca.core.Field")["with"]({events:{"blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",autoBindEventHandlers:!0,send_blanks:!0,initialize:function(a){this.options=a!=null?a:{},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.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend),this.append&&(this.$el.addClass("input-append"),this.addOn=this.append);if(this.enableKeyEvents)return this.registerEvent("keydown input","keydown_handler")},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:a,keydown_handler:_.throttle(function(b){return a.apply(this,arguments)},300)})}.call(this),function(){_.def("Luca.fields.TypeAheadField")["extends"]("Luca.fields.TextField")["with"]({className:"luca-ui-field",getSource:function(){return this.source||[]},matcher:function(a){return!0},beforeRender:function(){return this._super("beforeRender",this,arguments),this.$("input").attr("data-provide","typeahead")},afterRender:function(){return this._super("afterRender",this,arguments),this.$("input").typeahead({matcher:this.matcher,source:this.getSource()})}})}.call(this),function(){_.def("Luca.components.FormButtonToolbar")["extends"]("Luca.components.Toolbar")["with"]({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"})}})}.call(this),function(){_.def("Luca.components.FormView")["extends"]("Luca.core.Container")["with"]({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,legend:"",bodyClassName:"form-view-body",bodyTemplate:["components/form_view"],initialize:function(a){this.options=a!=null?a:{},this.loadMask==null&&(this.loadMask=Luca.enableBootstrap),Luca.core.Container.prototype.initialize.apply(this,arguments),_.bindAll(this,"submitHandler","resetHandler","renderToolbars","applyLoadMask"),this.state||(this.state=new Backbone.Model),this.setupHooks(this.hooks),this.applyStyleClasses();if(this.toolbar===!0&&this.bottomToolbar==null&&this.topToolbar==null)return this.bottomToolbar={buttons:[{icon:"remove-sign",label:"Reset",eventId:"click:reset",className:"reset-button",align:"right"},{icon:"ok-sign",white:!0,label:"Save Changes",eventId:"click:submit",color:"success",className:"submit-button",align:"right"}]}},applyStyleClasses:function(){Luca.enableBootstrap&&this.applyBootstrapStyleClasses(),this.labelAlign&&this.$el.addClass("label-align-"+this.labelAlign);if(this.fieldLayoutClass)return this.$el.addClass(this.fieldLayoutClass)},applyBootstrapStyleClasses: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")},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;b=c=$(a.currentTarget),this.trigger("before:submit",this),this.loadMask===!0&&this.trigger("enable:loadmask",this);if(this.hasModel())return this.submit()},afterComponents:function(){var a,b=this;return(a=Luca.core.Container.prototype.afterComponents)!=null&&a.apply(this,arguments),this.eachField(function(a){return a.getForm=function(){return b},a.getModel=function(){return b.currentModel()}})},eachField:function(a){return _(this.getFields()).map(a)},getField:function(a){return _(this.getFields("name",a)).first()},getFields:function(a,b){var c;return c=this.select("isField",!0,!0),!a||!b?c:(_(c).select(function(c){var d;return d=c[a],d!=null&&b===(_.isFunction(d)?d():d)}),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(){if(this.current_model!=null)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==null&&(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),_.string.isBlank(f)&&(a.reject_blank&&!c.send_blanks&&(e=!0),c.input_name==="id"&&(e=!0)),e!==!0&&(b[d]=f),b},{})},submit_success_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),this.loadMask===!0&&this.trigger("disable:loadmask",this),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)},hasModel:function(){return this.current_model!=null},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)}})}.call(this),function(){_.def("Luca.components.GridView").extend("Luca.components.Panel")["with"]({bodyTemplate:"components/grid_view",autoBindEventHandlers:!0,events:{"dblclick table tbody tr":"double_click_handler","click table tbody tr":"click_handler"},className:"luca-ui-g-view",rowClass:"luca-ui-g-row",wrapperClass:"luca-ui-g-view-wrapper",additionalWrapperClasses:[],wrapperStyles:{},scrollable:!0,emptyText:"No Results To display.",tableStyle:"striped",defaultHeight:285,defaultWidth:756,maxWidth:void 0,hooks:["before:grid:render","before:render:header","before:render:row","after:grid:render","row:double:click","row:click","after:collection:load"],initialize:function(a){var b=this;return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),this.loadMask==null&&(this.loadMask=Luca.enableBootstrap),this.loadMask===!0&&(this.loadMaskEl||(this.loadMaskEl=".luca-ui-g-view-body")),Luca.components.Panel.prototype.initialize.apply(this,arguments),this.configure_collection(!0),this.collection.bind("before:fetch",function(){console.log("Triggering Enable Load Mask");if(b.loadMask===!0)return b.trigger("enable:loadmask")}),this.collection.bind("reset",function(a){return b.refresh(),console.log("Triggering Disable LoadMask"),b.loadMask===!0&&b.trigger("disable:loadmask"),b.trigger("after:collection:load",a)}),this.collection.bind("change",function(a){var c,d;if(b.rendered!==!0)return;try{return d=b.getRowEl(a.id||a.get("id")||a.cid),c=b.render_row(a,b.collection.indexOf(a),{cellsOnly:!0}),$(d).html(c)}catch(e){return console.log("Error in change handler for GridView.collection",e,b,a,d,c)}})},beforeRender:function(){var a;return(a=Luca.components.Panel.prototype.beforeRender)!=null&&a.apply(this,arguments),this.trigger("before:grid:render",this),this.table=this.$("table.luca-ui-g-view"),this.header=this.$("thead"),this.body=this.$("tbody"),this.footer=this.$("tfoot"),this.wrapper=this.$("."+this.wrapperClass),this.applyCssClasses(),this.scrollable&&this.setDimensions(),this.renderHeader(),this.emptyMessage(),$(this.container).append(this.$el)},afterRender:function(){var a;return(a=Luca.components.Panel.prototype.afterRender)!=null&&a.apply(this,arguments),this.rendered=!0,this.refresh(),this.trigger("after:grid:render",this)},applyCssClasses:function(){var a,b=this;return this.scrollable&&this.$el.addClass("scrollable-g-view"),_(this.additionalWrapperClasses).each(function(a){var c;return(c=b.wrapper)!=null?c.addClass(a):void 0}),Luca.enableBootstrap&&this.table.addClass("table"),_((a=this.tableStyle)!=null?a.split(" "):void 0).each(function(a){return b.table.addClass("table-"+a)})},setDimensions:function(a){var b=this;return this.height||(this.height=this.defaultHeight),this.$(".luca-ui-g-view-body").height(this.height),this.$("tbody.scrollable").height(this.height-23),this.container_width=function(){return $(b.container).width()}(),this.width||(this.width=this.container_width>0?this.container_width:this.defaultWidth),this.width=_([this.width,this.maxWidth||this.width]).max(),this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width),this.setDefaultColumnWidths()},resize:function(a){var b,c,d=this;b=a-this.width,this.width=a,this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width);if(this.columns.length>0)return c=b/this.columns.length,_(this.columns).each(function(a,b){var e;return e=$(".column-"+b,d.el),e.width(a.width=a.width+c)})},padLastColumn:function(){var a,b;a=_(this.columns).inject(function(a,b){return a=b.width+a},0),b=this.width-a;if(b>0)return this.lastColumn().width+=b},setDefaultColumnWidths:function(){var a;return a=this.columns.length>0?this.width/this.columns.length:200,_(this.columns).each(function(b){return parseInt(b.width||(b.width=a))}),this.padLastColumn()},lastColumn:function(){return this.columns[this.columns.length-1]},emptyMessage:function(a){return a==null&&(a=""),a||(a=this.emptyText),this.body.html(""),this.body.append(Luca.templates["components/grid_view_empty_text"]({colspan:this.columns.length,text:a}))},refresh:function(){var a=this;this.body.html(""),this.collection.each(function(b,c){return a.render_row.apply(a,[b,c])});if(this.collection.models.length===0)return this.emptyMessage()},ifLoaded:function(a,b){return b||(b=this),a||(a=function(){return!0}),this.collection.ifLoaded(a,b)},applyFilter:function(a,b){return b==null&&(b={auto:!0,refresh:!0}),this.collection.applyFilter(a,b)},renderHeader:function(){var a,b=this;return this.trigger("before:render:header"),a=_(this.columns).map(function(a,b){var c;return c=a.width?"width:"+a.width+"px;":"","<th style='"+c+"' class='column-"+b+"'>"+a.header+"</th>"}),this.header.append("<tr>"+a+"</tr>")},getRowEl:function(a){return this.$("[data-record-id="+a+"]","table")},render_row:function(a,b,c){var d,e,f,g,h,i,j=this;return c==null&&(c={}),h=this.rowClass,g=(a!=null?a.get:void 0)&&(a!=null?a.attributes:void 0)?a.get("id"):"",this.trigger("before:render:row",a,b),e=_(this.columns).map(function(b,c){var d,e,f;return f=j.cell_renderer(a,b,c),e=b.width?"width:"+b.width+"px;":"",d=_.isUndefined(f)?"":f,"<td style='"+e+"' class='column-"+c+"'>"+d+"</td>"}),c.cellsOnly?e:(d="",this.alternateRowClasses&&(d=b%2===0?"even":"odd"),f="<tr data-record-id='"+g+"' data-row-index='"+b+"' class='"+h+" "+d+"' id='row-"+b+"'>"+e+"</tr>",c.contentOnly===!0?f:(i=this.body)!=null?i.append(f):void 0)},cell_renderer:function(a,b,c){var d;return _.isFunction(b.renderer)?b.renderer.apply(this,[a,b,c]):b.data.match(/\w+\.\w+/)?(d=a.attributes||a,Luca.util.nestedValue(b.data,d)):(typeof a.get=="function"?a.get(b.data):void 0)||a[b.data]},double_click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:double:click",this,d,e)},click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:click",this,d,e),$("."+this.rowClass,this.body).removeClass("selected-row"),b.addClass("selected-row")}})}.call(this),function(){_.def("Luca.components.LoadMask")["extends"]("Luca.View")["with"]({className:"luca-ui-load-mask",bodyTemplate:"components/load_mask"})}.call(this),function(){_.def("Luca.components.NavBar")["extends"]("Luca.View")["with"]({fixed:!0,position:"top",className:"navbar",initialize:function(a){return this.options=a!=null?a:{},Luca.View.prototype.initialize.apply(this,arguments)},brand:"Luca.js",bodyTemplate:"nav_bar",bodyClassName:"luca-ui-navbar-body",beforeRender:function(){this.fixed&&this.$el.addClass("navbar-fixed-"+this.position);if(this.brand!=null)return this.content().append("<a class='brand' href='#'>"+this.brand+"</a>")},render:function(){return this},content:function(){return this.$(".container").eq(0)}})}.call(this),function(){_.def("Luca.components.RecordManager")["extends"]("Luca.containers.CardView")["with"]({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(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(){_.def("Luca.Router")["extends"]("Backbone.Router")["with"]({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(){_.def("Luca.components.ToolbarDialog")["extends"]("Luca.View")["with"]({className:"luca-ui-toolbar-dialog span well",styles:{position:"absolute","z-Index":"3000","float":"left"},initialize:function(a){return this.options=a!=null?a:{},this._super("initialize",this,arguments)},createWrapper:function(){return this.make("div",{"class":"component-picker span4 well",style:"position: absolute; z-index:12000"})},show:function(){return this.$el.parent().show()},hide:function(){return this.$el.parent().hide()},toggle:function(){return this.$el.parent().toggle()}})}.call(this),function(){_.extend(Luca,Luca.Events),_.extend(Luca.View.prototype,Luca.Events),_.extend(Luca.Collection.prototype,Luca.Events),_.extend(Luca.Model.prototype,Luca.Events)}.call(this);