luca 0.9.89 → 0.9.91

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +11 -1
  2. data/Gemfile +5 -2
  3. data/Gemfile.lock +84 -56
  4. data/Rakefile +10 -2
  5. data/app/assets/javascripts/luca/components/application.coffee +82 -89
  6. data/app/assets/javascripts/luca/components/collection_view.coffee +9 -5
  7. data/app/assets/javascripts/luca/components/controller.coffee +72 -11
  8. data/app/assets/javascripts/luca/components/fields/base.coffee +61 -8
  9. data/app/assets/javascripts/luca/components/fields/button_field.coffee +53 -7
  10. data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
  11. data/app/assets/javascripts/luca/components/fields/text_field.coffee +1 -1
  12. data/app/assets/javascripts/luca/components/form_view.coffee +2 -2
  13. data/app/assets/javascripts/luca/components/grid_layout_view.coffee +0 -1
  14. data/app/assets/javascripts/luca/components/page.coffee +1 -0
  15. data/app/assets/javascripts/luca/components/table_view.coffee +2 -2
  16. data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
  17. data/app/assets/javascripts/luca/containers/card_view.coffee +84 -54
  18. data/app/assets/javascripts/luca/containers/container.coffee +126 -46
  19. data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
  20. data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
  21. data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +1 -1
  22. data/app/assets/javascripts/luca/containers/viewport.coffee +2 -5
  23. data/app/assets/javascripts/luca/core/collection.coffee +18 -4
  24. data/app/assets/javascripts/luca/core/model.coffee +1 -1
  25. data/app/assets/javascripts/luca/core/panel.coffee +1 -1
  26. data/app/assets/javascripts/luca/core/view.coffee +26 -7
  27. data/app/assets/javascripts/luca/development/code_sync_manager.coffee +51 -4
  28. data/app/assets/javascripts/luca/development/console.coffee +1 -1
  29. data/app/assets/javascripts/luca/framework.coffee +1 -1
  30. data/app/assets/javascripts/luca/index.coffee +1 -0
  31. data/app/assets/javascripts/luca/util/luca.coffee +2 -1
  32. data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
  33. data/bin/luca +14 -0
  34. data/docs/framework.json +1 -1
  35. data/docs/luca-framework-documentation.js +1 -0
  36. data/lib/luca/cli/generate.rb +37 -0
  37. data/lib/luca/cli/server.rb +20 -0
  38. data/lib/luca/cli/sync.rb +40 -0
  39. data/lib/luca/cli/watch.rb +16 -0
  40. data/lib/luca/cli.rb +68 -0
  41. data/lib/luca/collection/endpoint.rb +1 -0
  42. data/lib/luca/component_definition.rb +23 -5
  43. data/lib/luca/luca_application.rb +18 -7
  44. data/lib/luca/rails/version.rb +1 -1
  45. data/lib/luca/server.rb +7 -0
  46. data/lib/luca/stylesheet.rb +2 -3
  47. data/lib/luca/version.rb +3 -0
  48. data/lib/luca/watcher.rb +72 -0
  49. data/lib/luca.rb +8 -1
  50. data/luca.gemspec +14 -7
  51. data/site/.bundle/config +2 -0
  52. data/site/.gitignore +5 -0
  53. data/site/.rvmrc +1 -0
  54. data/site/CHANGELOG.md +41 -0
  55. data/site/DOCS.md +41 -0
  56. data/site/Gemfile +8 -0
  57. data/site/Gemfile.lock +134 -0
  58. data/site/LICENSE.md +19 -0
  59. data/site/config.rb +84 -0
  60. data/site/helpers/site_helpers.rb +20 -0
  61. data/site/html5bp-docs/README.md +38 -0
  62. data/site/html5bp-docs/contribute.md +104 -0
  63. data/site/html5bp-docs/crossdomain.md +21 -0
  64. data/site/html5bp-docs/css.md +135 -0
  65. data/site/html5bp-docs/extend.md +507 -0
  66. data/site/html5bp-docs/faq.md +77 -0
  67. data/site/html5bp-docs/htaccess.md +323 -0
  68. data/site/html5bp-docs/html.md +170 -0
  69. data/site/html5bp-docs/js.md +31 -0
  70. data/site/html5bp-docs/misc.md +25 -0
  71. data/site/html5bp-docs/usage.md +109 -0
  72. data/site/readme.md +47 -0
  73. data/site/source/.htaccess +540 -0
  74. data/site/source/404.html +157 -0
  75. data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
  76. data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
  77. data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
  78. data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
  79. data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
  80. data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
  81. data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
  82. data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
  83. data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
  84. data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
  85. data/site/source/app/assets/javascripts/docs/lib/util.coffee +0 -0
  86. data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
  87. data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
  88. data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
  89. data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
  90. data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
  91. data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
  92. data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
  93. data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
  94. data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
  95. data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
  96. data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
  97. data/site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee +0 -0
  98. data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
  99. data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
  100. data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
  101. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
  102. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
  103. data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
  104. data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
  105. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
  106. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
  107. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
  108. data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
  109. data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
  110. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
  111. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
  112. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
  113. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
  114. data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
  115. data/site/source/app/assets/javascripts/docs-docs.js +1 -0
  116. data/site/source/app/assets/javascripts/luca-docs.js +1 -0
  117. data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
  118. data/site/source/app/assets/javascripts/site.js.coffee +4 -0
  119. data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
  120. data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
  121. data/site/source/app/assets/javascripts/vendor/css.js +465 -0
  122. data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
  123. data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
  124. data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
  125. data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
  126. data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
  127. data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
  128. data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
  129. data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
  130. data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
  131. data/site/source/app/assets/stylesheets/site.css.scss +2 -0
  132. data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
  133. data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
  134. data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
  135. data/site/source/crossdomain.xml +15 -0
  136. data/site/source/documentation.html.haml +1 -0
  137. data/site/source/favicon_base.png +0 -0
  138. data/site/source/humans.txt +15 -0
  139. data/site/source/images/background.png +0 -0
  140. data/site/source/images/middleman.png +0 -0
  141. data/site/source/index.html.haml +1 -0
  142. data/site/source/layouts/layout.haml +55 -0
  143. data/site/source/readme.md +63 -0
  144. data/site/source/robots.txt +3 -0
  145. data/spec/javascripts/components/collection_view_spec.coffee +1 -1
  146. data/spec/javascripts/containers/card_view_spec.coffee +58 -5
  147. data/spec/javascripts/core/collection_spec.coffee +1 -1
  148. data/spec/javascripts/core/view_spec.coffee +2 -2
  149. data/vendor/assets/javascripts/backbone-min.js +37 -33
  150. data/vendor/assets/javascripts/backbone-query.min.js +1 -1
  151. data/vendor/assets/javascripts/jquery.js +5 -4
  152. data/vendor/assets/javascripts/luca-dependencies.min.js +8 -6
  153. data/vendor/assets/javascripts/luca-development.min.js +1 -1
  154. data/vendor/assets/javascripts/luca.full.min.js +12 -10
  155. data/vendor/assets/javascripts/luca.min.js +5 -5
  156. data/vendor/assets/javascripts/underscore-min.js +1 -5
  157. data/vendor/assets/javascripts/underscore-string.min.js +1 -1
  158. data/vendor/assets/stylesheets/luca-components.css +0 -2
  159. data/vendor/assets/stylesheets/luca-development.css +1 -1
  160. metadata +215 -39
  161. data/app/assets/javascripts/luca/components/page_controller.coffee +0 -3
  162. data/app/assets/javascripts/luca/core/collection_view.coffee +0 -150
  163. data/site/assets/bootstrap.min.js +0 -7
  164. data/site/assets/dependencies.js +0 -94
  165. data/site/assets/glyphicons-halflings-white.png +0 -0
  166. data/site/assets/glyphicons-halflings.png +0 -0
  167. data/site/assets/luca-ui-bootstrap.css +0 -1331
  168. data/site/assets/luca-ui-bootstrap.js +0 -9
  169. data/site/assets/luca-ui-development-tools.css +0 -234
  170. data/site/assets/luca-ui-development-tools.js +0 -18561
  171. data/site/assets/luca-ui-development-tools.min.js +0 -15
  172. data/site/assets/luca-ui-full.min.js +0 -8
  173. data/site/assets/luca-ui.min.js +0 -4
  174. data/site/assets/sandbox.css +0 -62
  175. data/site/assets/sandbox.js +0 -469
  176. data/site/docs/application.html +0 -41
  177. data/site/docs/caching.html +0 -43
  178. data/site/docs/collection.html +0 -75
  179. data/site/docs/collection_manager.html +0 -71
  180. data/site/docs/containers.html +0 -118
  181. data/site/docs/events.html +0 -153
  182. data/site/docs/view.html +0 -128
  183. data/site/img/glyphicons-halflings-white.png +0 -0
  184. data/site/img/glyphicons-halflings.png +0 -0
  185. data/site/index.html +0 -20
  186. data/site/source-map.js +0 -1
@@ -1,5 +1,5 @@
1
- (function(){this.JST||(this.JST={}),this.JST["luca/templates/components/bootstrap_form_controls"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="btn-group form-actions">\n <a class="btn btn-primary submit-button">\n <i class="icon icon-ok icon-white"></i>\n Save Changes\n </a>\n <a class="btn reset-button cancel-button">\n <i class="icon icon-remove"></i>\n Cancel\n </a>\n</div>\n');return __p.join("")}}).call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/collection_loader_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div id="progress-modal" class="modal" 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">Initializing...</div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/form_alert"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="',className,'">\n <a class="close" href="#" data-dismiss="alert">x</a>\n ',message,"\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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 class="luca-ui-g-view scrollable-table" width="100%" cellpadding=0 cellspacing=0>\n <thead class="fixed"></thead>\n <tbody class="scrollable"></tbody>\n <tfoot></tfoot>\n </table>\n </div>\n <div class="luca-ui-g-view-header"></div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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 empty-text-wrapper">\n <p>',text,"</p>\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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:0%"></div>\n </div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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">\n <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">\n <span class="icon-bar"></span>\n <span class="icon-bar"></span>\n <span class="icon-bar"></span>\n </button>\n\n <a class="brand" href="#">Set @brand</a>\n \n <div class="nav-collapse collapse">\n <ul class="nav">\n <li class="active">\n <a href="#">Home</a>\n </li>\n </ul>\n </div>\n </div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/pagination"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="pagination">\n <a class="btn previous">\n <i class="icon icon-chevron-left"></i>\n </a>\n <div class="pagination-group">\n </div>\n <a class="btn next">\n <i class="icon icon-chevron-right"></i>\n </a>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/table_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<thead></thead>\n<tbody class="table-body"></tbody>\n<tfoot></tfoot>\n<caption></caption>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/containers/basic"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div id="',id,'" class="',classes,'" style="',style,'"></div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/containers/tab_selector_container"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{}){__p.push('<div id="',cid,'-tab-selector" class="tab-selector-container">\n <ul id="',cid,'-tabs-nav" class="nav nav-tabs">\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(){this.JST||(this.JST={}),this.JST["luca/templates/containers/tab_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<ul id="',cid,'-tabs-selector" class="nav nav-tabs"></ul>\n<div id="',cid,'-tab-view-content" class="tab-content"></div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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(){this.JST||(this.JST={}),this.JST["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 style="',inputStyles,'" class="btn ',input_class,'" value="',input_value,'" type="',input_type,'" id="<%= input_id" />\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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 ',input_value,"\n "),__p.push("\n</a>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_array"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="control-group">\n <label for="',input_id,'"><%= label =>\n <div class="controls"><div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_array_item"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n <input id="',input_id,'" type="checkbox" name="',input_name,'" value="',value,'" />\n</label>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n <input type="checkbox" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n</label>\n\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(){this.JST||(this.JST={}),this.JST["luca/templates/fields/file_upload_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n <input type="file" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n</label>\n\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(){this.JST||(this.JST={}),this.JST["luca/templates/fields/hidden_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(' <input type="hidden" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/select_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n</label>\n<div class="controls">\n <select name="',input_name,'" value="',input_value,'" style="',inputStyles,'" ></select>\n '),helperText&&__p.push('\n <p class="helper-text help-block">\n ',helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/text_area_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n</label>\n<div class="controls">\n <textarea placeholder="',placeHolder,'" name="',input_name,'" style="',inputStyles,'" >',input_value,"</textarea>\n "),helperText&&__p.push('\n <p class="helper-text help-block">\n ',helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/text_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),(typeof label!="undefined"&&typeof hideLabel!="undefined"&&!hideLabel||typeof hideLabel=="undefined")&&__p.push('\n<label class="control-label" for="',input_id,'">',label,"</label>\n"),__p.push('\n\n<div class="controls">\n'),typeof addOn!="undefined"&&__p.push('\n <span class="add-on">',addOn,"</span>\n"),__p.push('\n<input type="text" placeholder="',placeHolder,'" name="',input_name,'" style="',inputStyles,'" value="',input_value,'" />\n'),helperText&&__p.push('\n<p class="helper-text help-block">\n ',helperText,"\n</p>\n"),__p.push("\n\n</div>\n");return __p.join("")}}.call(this),function(){var a,b,c=Array.prototype.slice;b=function(){var a,b,d,e,f;d=arguments[0],a=2<=arguments.length?c.call(arguments,1):[];if(arguments.length===0)return(f=_(Luca.Application.instances).values())!=null?f[0]:void 0;if(_.isString(d)&&(e=Luca.cache(d)))return e;if(_.isString(d)&&(e=Luca.find(d)))return e;if(_.isString(d)&&(e=Luca.registry.find(d)))return e;if(d instanceof jQuery&&(e=Luca.find(d)))return e;if(_.isObject(d)&&d.ctype!=null)return Luca.util.lazyComponent(d);if(_.isFunction(b=_(a).last()))return b()},(window||global).Luca=function(){return b.apply(this,arguments)},Luca.VERSION="0.9.9",_.extend(Luca,{core:{},collections:{},containers:{},components:{},models:{},concerns:{},util:{},fields:{},registry:{},options:{},config:{},logger:function(a){return function(){var b;return b=1<=arguments.length?c.call(arguments,0):[],b.unshift(a),console.log(this,b)}},getHelper:function(){return function(){return b.apply(this,arguments)}}}),_.extend(Luca,Backbone.Events),Luca.setupCollectionSpace=function(a){var b,c;return a==null&&(a={}),b=a.baseParams,c=a.modelBootstrap,b!=null?Luca.Collection.baseParams(b):Luca.warn("You should remember to set the base params for Luca.Collection class. You can do this by defining a property or function on Luca.config.baseParams"),c!=null?Luca.Collection.bootstrap(c):Luca.warn("You should remember to set the model bootstrap location for Luca.Collection. You can do this by defining a property or function on Luca.config.modelBootstrap")},Luca.initialize=function(a,b){var c,d;return b==null&&(b={}),Luca.namespace=a.toLowerCase(),c=Luca.util.resolve(a,window||global)||{},_.defaults(c,{views:{},collections:{},models:{},components:{},lib:{},util:{},concerns:{},register:function(){return Luca.register.apply(this,arguments)},onReady:function(){return Luca.onReady.apply(this,arguments)},getApplication:function(){var a;return(a=Luca.getApplication)!=null?a.apply(this,arguments):void 0},getCollectionManager:function(){var a;return(a=Luca.CollectionManager.get)!=null?a.apply(this,arguments):void 0},route:Luca.routeHelper}),d={},d[a]=_.defaults(Luca.getHelper(),c),_.extend(Luca.config,b),_.extend(window||global,d),Luca.lastNamespace=a,Luca.concern.namespace(""+a+".concerns"),Luca.registry.namespace(""+a+".views"),Luca.Collection.namespace(""+a+".collections"),Luca.on("ready",function(){return Luca.setupCollectionSpace(b)})},Luca.onReady=function(a){return Luca.define.close(),Luca.trigger("ready"),$(function(){return a.apply(this,arguments)})},Luca.find=function(a){return Luca($(a).data("luca-id"))},Luca.supportsEvents=Luca.supportsBackboneEvents=function(a){return Luca.isComponent(a)||_.isFunction(a!=null?a.trigger:void 0)||_.isFunction(a!=null?a.bind:void 0)},Luca.isComponent=function(a){return Luca.isBackboneModel(a)||Luca.isBackboneView(a)||Luca.isBackboneCollection(a)},Luca.isComponentPrototype=function(a){return Luca.isViewPrototype(a)||Luca.isModelPrototype(a)||Luca.isCollectionPrototype(a)},Luca.isBackboneModel=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.set:void 0)&&_.isFunction(a!=null?a.get:void 0)&&_.isObject(a!=null?a.attributes:void 0)},Luca.isBackboneView=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.render:void 0)&&!_.isUndefined(a!=null?a.el:void 0)},Luca.isBackboneCollection=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.fetch:void 0)&&_.isFunction(a!=null?a.reset:void 0)},Luca.isViewPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&a.prototype.make!=null&&a.prototype.$!=null&&a.prototype.render!=null},Luca.isModelPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&(typeof a.prototype=="function"?a.prototype(a.prototype.save!=null&&a.prototype.changedAttributes!=null):void 0)},Luca.isCollectionPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&!Luca.isModelPrototype(a)&&a.prototype.reset!=null&&a.prototype.select!=null&&a.prototype.reject!=null},Luca.inheritanceChain=function(a){return Luca.parentClasses(a)},Luca.parentClasses=function(a){var b,c,d;return b=[],_.isString(a)&&(a=Luca.util.resolve(a)),c=typeof a.componentMetaData=="function"?a.componentMetaData():void 0,c||(c=typeof (d=a.prototype).componentMetaData=="function"?d.componentMetaData():void 0),b=(c!=null?c.classHierarchy():void 0)||[a.displayName||a.prototype.displayName]},Luca.parentClass=function(a,b){var c,d,e,f,g;return b==null&&(b=!0),_.isString(a)&&(a=Luca.util.resolve(a)),c=typeof a.componentMetaData=="function"?(e=a.componentMetaData())!=null?e.meta["super class name"]:void 0:void 0,c||(c=typeof (d=a.prototype).componentMetaData=="function"?(f=d.componentMetaData())!=null?f.meta["super class name"]:void 0:void 0),c||a.displayName||((g=a.prototype)!=null?g.displayName:void 0),b?Luca.util.resolve(c):c},a={module:function(a,b){_.extend(a,b);if(a.included&&_(a.included).isFunction())return a.included.apply(a)},"delete":function(a,b){var c;return c=a[b],delete a[b],c},idle:function(a,b){var c;return b==null&&(b=1e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleShort:function(a,b){var c;return b==null&&(b=100),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleMedium:function(a,b){var c;return b==null&&(b=2e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleLong:function(a,b){var c;return b==null&&(b=5e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}}},_.mixin(a)}.call(this),function(){Luca.config.maintainStyleHierarchy=!0,Luca.config.maintainClassHierarchy=!0,Luca.config.autoApplyClassHierarchyAsCssClasses=!0,Luca.config.idAttributeType="integer",Luca.config.apiSortByParameter="sortBy",Luca.config.apiPageParameter="page",Luca.config.apiLimitParameter="limit",Luca.autoRegister=Luca.config.autoRegister=!0,Luca.developmentMode=Luca.config.developmentMode=!1,Luca.enableGlobalObserver=Luca.config.enableGlobalObserver=!1,Luca.config.enableBoostrap=Luca.config.enableBootstrap=!0,Luca.config.fluidWrapperClass="container-fluid",Luca.config.wrapperClass="container",Luca.config.enhancedViewProperties=!0,Luca.keys=Luca.config.keys={ENTER:13,ESCAPE:27,KEYLEFT:37,KEYUP:38,KEYRIGHT:39,KEYDOWN:40,SPACEBAR:32,FORWARDSLASH:191,TAB:9},Luca.config.toolbarContainerClass="toolbar-container",Luca.keyMap=Luca.config.keyMap=_(Luca.keys).inject(function(a,b,c){return a[b]=c.toLowerCase(),a},{}),Luca.config.showWarnings=!0,Luca.config.default_socket_port=9292}.call(this),function(){var currentNamespace,__slice=Array.prototype.slice;Luca.util.resolve=function(a,b){var c;if(!_.isString(a))return a;try{b||(b=window||global),c=_(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)}catch(d){throw console.log("Error resolving",a,b),d}return c},Luca.util.nestedValue=Luca.util.resolve,Luca.util.argumentsLogger=function(a){return function(){return console.log(""+a+" "+(typeof this.identifier=="function"?this.identifier():void 0),arguments)}},Luca.util.read=function(){var a,b;return b=arguments[0],a=2<=arguments.length?__slice.call(arguments,1):[],_.isFunction(b)?b.apply(this,a):b},Luca.util.readAll=function(a){var b,c,d;a==null&&(a={}),c={};for(b in a)d=a[b],c[b]=Luca.util.read(d);return c},Luca.util.classify=function(a){return a==null&&(a=""),_.string.camelize(_.string.capitalize(a))},Luca.util.hook=function(a){var b,c,d;return a==null&&(a=""),c=a.split(":"),d=c.shift(),c=_(c).map(function(a){return _.string.capitalize(a)}),b=d+c.join("")},Luca.util.toCssClass=function(){var a,b,c,d,e;return a=arguments[0],b=2<=arguments.length?__slice.call(arguments,1):[],d=a.split("."),e=function(){var a,e,f;f=[];for(a=0,e=d.length;a<e;a++){c=d[a];if(_(b).indexOf(c)!==-1)continue;c=_.str.underscored(c),c=c.replace(/_/g,"-"),f.push(c)}return f}(),e.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)},Luca.util.make=Backbone.View.prototype.make,Luca.util.list=function(a,b,c){var d,e,f,g;b==null&&(b={}),d=c?"ol":"ul",d=Luca.util.make(d,b);if(_.isArray(a))for(f=0,g=a.length;f<g;f++)e=a[f],$(d).append(Luca.util.make("li",{},e));return d.outerHTML},Luca.util.label=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="label"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)},Luca.util.badge=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="badge"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)},Luca.util.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=this[d])!=null?a.apply(this,arguments):void 0};if(a!=null?a.match(/once:/):void 0)c=_.once(c);return b.on(a,c,b)})},Luca.util.setupHooksAdvanced=function(a){var b=this;return a||(a=this.hooks),_(a).each(function(a){var c,d,e,f,g,h,i;f=b[Luca.util.hook(a)],_.isArray(f)||(f=[f]),i=[];for(g=0,h=f.length;g<h;g++){d=f[g],e=_.isString(d)?b[d]:void 0,_.isFunction(d)&&(e=d),c=function(){var a;return(a=this[e])!=null?a.apply(this,arguments):void 0};if(a!=null?a.match(/once:/):void 0)c=_.once(c);i.push(b.on(a,c,b))}return i})},Luca.util.rejectBlanks=function(a){var b,c,d;c={};for(b in a)d=a[b],_.isBlank(d)!==!0&&(c[b]=d);return c},Luca.util.enableDropdowns=function(a){var b;return a==null&&(a=".dropdown-toggle"),typeof (b=$(a)).dropdown=="function"?b.dropdown():void 0}}.call(this),function(){var a=Array.prototype.slice;Luca.stats={},Luca.stats.reset=function(){return Luca.__stats={}},Luca.stats.increment=function(a){var b;return Luca.__stats||(Luca.__stats={}),(b=Luca.__stats)[a]||(b[a]=1),Luca.__stats[a]=Luca.__stats[a]+1,Luca.__stats[a]},Luca.stats.report=function(){var a,b,c,d;console.log("Stats..."),c=Luca.__stats,d=[];for(a in c)b=c[a],d.push(console.log(a,b));return d},Luca.warn=function(){var b;b=1<=arguments.length?a.call(arguments,0):[];if(Luca.config.showWarnings!==!0)return;return Luca.isComponent(this)&&b.unshift(this.identifier()),b.unshift("Warning:"),console.log.apply(console,b)},Luca.log=function(){var b;return b=1<=arguments.length?a.call(arguments,0):[],Luca.isComponent(this)&&b.unshift(this.identifier()),console.log.apply(console,b)}}.call(this),function(){Luca.util.deprecateComponent=function(a,b){var c,d;c=_.template(""+a+" has been renamed to "+b+". Please update your definitions."),(d=Luca.registry.componentAliases)[b]||(d[b]=[]),Luca.registry.componentAliases[b].push(a);if(a!==b)return Luca.registry.deprecatedComponents[a]={message:c({previous:a,newName:b}),newName:b}},Luca.util.checkDeprecationStatusOf=function(a){var b;return(b=Luca.registry.deprecatedComponents[a])?(Luca.log(b.message),b.newName):a}}.call(this),function(){Luca.util.setupKeymaster=Luca.util.setupKeyBindings=function(a,b){b==null&&(b="all");if(!_.isFunction(Luca.key))throw"Keymaster library has not been included.";return{on:function(c){var d,e,f;c.on("before:remove",function(){var a;return(a=Luca.key)!=null?a.deleteScope(b):void 0}),f=[];for(e in a)d=a[e],_.isString(d)&&_.isFunction(c[d])&&(d=c[d]),_.isFunction(d)?(d=_.bind(d,c),f.push(Luca.key(e,b,d))):f.push(void 0);return f}}}}.call(this),function(){}.call(this),function(){Luca.concern=function(a){var b,c;return b=_(Luca.concern.namespaces).detect(function(b){var c;return((c=Luca.util.resolve(b))!=null?c[a]:void 0)!=null}),b||(b="Luca.concerns"),c=Luca.util.resolve(b)[a],c==null&&console.log("Could not find "+a+" in ",Luca.concern.namespaces),c},Luca.concern.namespaces=["Luca.concerns"],Luca.concern.namespace=function(a){return Luca.concern.namespaces.push(a),Luca.concern.namespaces=_(Luca.concern.namespaces).uniq()},Luca.concern.setup=function(){var a,b,c,d,e,f,g,h;if(((d=this.concerns)!=null?d.length:void 0)>0){e=this.concerns,h=[];for(b=0,c=e.length;b<c;b++)a=e[b],h.push((f=Luca.concern(a))!=null?(g=f.__initializer)!=null?g.call(this,this,a):void 0:void 0);return h}},Luca.decorate=function(a){var b,c,d;try{_.isString(a)&&(c=a,b=Luca.util.resolve(c)),_.isFunction(a)&&(b=a),d=b.prototype,c=c||b.displayName,c||(c=d.displayName)}catch(e){throw console.log(e.message),console.log(e.stack),console.log("Error calling Luca.decorate on ",b,d,c),e}return{"with":function(a){var e,f,g,h,i,j,k;g=Luca.concern(a),g.__displayName||(g.__displayName=a),h=_(g).chain().keys().select(function(a){return(""+a).match(/^__/)||a==="classMethods"}),i=_(g).omit(h.value()),_.extend(d,i);if(g.classMethods!=null){k=g.classMethods;for(f in k)e=k[f],b[f]=_.bind(e,b)}return g!=null&&typeof g.__included=="function"&&g.__included(c,b,g),j=d._superClass().prototype.concerns,d.concerns||(d.concerns=[]),d.concerns.push(a),d.concerns=d.concerns.concat(j),d.concerns=_(d.concerns).chain().uniq().compact().value(),d}}}}.call(this),function(){var ComponentDefinition,cd,__slice=Array.prototype.slice;ComponentDefinition=function(){function ComponentDefinition(a,b){var c;this.autoRegister=b!=null?b:!0,this.namespace=Luca.util.namespace(),this.componentId=this.componentName=a,this.superClassName="Luca.View",this.properties||(this.properties={}),this._classProperties||(this._classProperties={}),a.match(/\./)&&(this.namespaced=!0,c=a.split("."),this.componentId=c.pop(),this.namespace=c.join("."),Luca.registry.addNamespace(c.join("."))),Luca.define.__definitions.push(this)}return ComponentDefinition.create=function(a,b){return b==null&&(b=Luca.config.autoRegister),new ComponentDefinition(a,b)},ComponentDefinition.prototype.isValid=function(){return _.isObject(this.properties)?Luca.util.resolve(this.superClassName)==null?!1:this.componentName==null?!1:!0:!1},ComponentDefinition.prototype.isDefined=function(){return this.defined===!0},ComponentDefinition.prototype.isOpen=function(){return!!this.isValid()&&!this.isDefined()},ComponentDefinition.prototype.meta=function(a,b){var c,d;return d=this.namespace+"."+this.componentId,d=d.replace(/^\./,""),c=Luca.registry.addMetaData(d,a,b),this.properties.componentMetaData=function(){return Luca.registry.getMetaDataFor(d)}},ComponentDefinition.prototype["in"]=function(a){return this.namespace=a,this},ComponentDefinition.prototype.from=function(a){return this.superClassName=a,this},ComponentDefinition.prototype["extends"]=function(a){return this.superClassName=a,this},ComponentDefinition.prototype.extend=function(a){return this.superClassName=a,this},ComponentDefinition.prototype.aliases=function(){var a;return a=1<=arguments.length?__slice.call(arguments,0):[],this._aliases=a,this.meta("aliases",this._aliases),this},ComponentDefinition.prototype.replaces=function(){var a,b,c,d,e;b=1<=arguments.length?__slice.call(arguments,0):[],this._aliases||(this._aliases=[]),e=[];for(c=0,d=b.length;c<d;c++)a=b[c],this._aliases.push(a),e.push(Luca.util.deprecateComponent(a,this.componentName));return e},ComponentDefinition.prototype.triggers=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{hooks:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.hooks.push(a);return this.properties.hooks=_.uniq(this.properties.hooks),this.meta("hooks",this.properties.hooks),this},ComponentDefinition.prototype.includes=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{include:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.include.push(a);return this.properties.include=_.uniq(this.properties.include),this.meta("includes",this.properties.include),this},ComponentDefinition.prototype.mixesIn=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{concerns:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.concerns.push(a);return this.properties.concerns=_.uniq(this.properties.concerns),this.meta("concerns",this.properties.concerns),this},ComponentDefinition.prototype.contains=function(){var a;return a=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties,{components:[]}),this.properties.components=a,this},ComponentDefinition.prototype.validatesConfigurationWith=function(a){return a==null&&(a={}),this.meta("configuration validations",a),this.properties.validatable=!0,this},ComponentDefinition.prototype.beforeDefinition=function(a){return this._classProperties.beforeDefinition=a,this},ComponentDefinition.prototype.afterDefinition=function(a){return this._classProperties.afterDefinition=a,this},ComponentDefinition.prototype.classConfiguration=function(a){return a==null&&(a={}),this.meta("class configuration",_.keys(a)),_.defaults(this._classProperties||(this._classProperties={}),a),this},ComponentDefinition.prototype.configuration=function(a){return a==null&&(a={}),this.meta("public configuration",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.publicConfiguration=function(a){return a==null&&(a={}),this.meta("public configuration",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.privateConfiguration=function(a){return a==null&&(a={}),this.meta("private configuration",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.classInterface=function(a){return a==null&&(a={}),this.meta("class interface",_.keys(a)),_.defaults(this._classProperties||(this._classProperties={}),a),this},ComponentDefinition.prototype.methods=function(a){return a==null&&(a={}),this.meta("public interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.public=function(a){return a==null&&(a={}),this.meta("public interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.publicInterface=function(a){return a==null&&(a={}),this.meta("public interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.private=function(a){return a==null&&(a={}),this.meta("private interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.privateInterface=function(a){return a==null&&(a={}),this.meta("private interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.definePrototype=function(properties){var alias,at,componentType,definition,include,type_alias,_base,_i,_j,_len,_len2,_ref,_ref2,_ref3,_ref4,_ref5;properties==null&&(properties={}),_.defaults(this.properties||(this.properties={}),properties),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)),this.meta("super class name",this.superClassName),this.meta("display name",this.componentName),this.properties.displayName=this.componentName,this.properties.componentMetaData=function(){return Luca.registry.getMetaDataFor(this.displayName)},(_ref=this._classProperties)!=null&&typeof _ref.beforeDefinition=="function"&&_ref.beforeDefinition(this),definition=at[this.componentId]=Luca.extend(this.superClassName,this.componentName,this.properties);if(_.isArray((_ref2=this.properties)!=null?_ref2.include:void 0)){_ref3=this.properties.include;for(_i=0,_len=_ref3.length;_i<_len;_i++)include=_ref3[_i],_.isString(include)&&(include=Luca.util.resolve(include)),include==null&&console.log("Attempt to include module failed. "+include+" not defined."),_.extend(definition.prototype,include)}if(this._aliases!=null){_ref4=this._aliases;for(_j=0,_len2=_ref4.length;_j<_len2;_j++)alias=_ref4[_j],eval(""+alias+" = definition;")}return this.autoRegister===!0&&(Luca.isViewPrototype(definition)&&(componentType="view"),Luca.isCollectionPrototype(definition)&&((_base=Luca.Collection).namespaces||(_base.namespaces=[]),Luca.Collection.namespaces.push(this.namespace),componentType="collection"),Luca.isModelPrototype(definition)&&(componentType="model"),type_alias=_.string.underscored(this.componentId),Luca.registerComponent(type_alias,this.componentName,componentType)),this.defined=!0,_.isEmpty(this._classProperties)||_.extend(definition,this._classProperties),definition!=null&&(_ref5=definition.afterDefinition)!=null&&_ref5.call(definition,this),definition},ComponentDefinition}(),cd=ComponentDefinition.prototype,cd.concerns=cd.behavesAs=cd.uses=cd.mixesIn,cd.register=cd.defines=cd.defaults=cd.exports=cd.defaultProperties=cd.definePrototype,cd.defaultsTo=cd.enhance=cd["with"]=cd.definePrototype,cd.publicMethods=cd.publicInterface,cd.privateMethods=cd.privateInterface,cd.classProperites=cd.classMethods=cd.classInterface,_.extend(Luca.define=ComponentDefinition.create,{__definitions:[],incomplete:function(){return _(Luca.define.__definitions).select(function(a){return a.isOpen()})},close:function(){var a,b,c,d;d=Luca.define.incomplete();for(b=0,c=d.length;b<c;b++)a=d[b],a.isValid()&&a.register();return Luca.define.__definitions.length=0},findDefinition:function(a){return _(Luca.define.__definitions).detect(function(b){return b.componentName===a})}}),Luca.register=function(a){return new ComponentDefinition(a,!0)},_.mixin({def:Luca.define}),Luca.extend=function(a,b,c){var d,e,f,g,h,i,j;c==null&&(c={}),a=Luca.util.checkDeprecationStatusOf(a),f=Luca.util.resolve(a,window||global);if(!_.isFunction(f!=null?f.extend:void 0))throw"Error defining "+b+". "+a+" is not a valid component to extend from";g=Luca.registry
2
- .getMetaDataFor(a),g.descendants().push(b),c.displayName=b,c._superClass=function(){return f.displayName||(f.displayName=a),f},c._super=function(a,b,c){var d;return b==null&&(b=this),c==null&&(c=[]),(d=this._superClass().prototype[a])!=null?d.apply(b,c):void 0},d=f.extend(c);if(_.isArray(c!=null?c.include:void 0)){j=c.include;for(h=0,i=j.length;h<i;h++)e=j[h],_.isString(e)&&(e=Luca.util.resolve(e)),_.extend(d.prototype,e)}return d}}.call(this),function(){var a,b;b={classes:{},model_classes:{},collection_classes:{},namespaces:["Luca.containers","Luca.components"]},a={cid_index:{},name_index:{}},Luca.config.defaultComponentClass=Luca.defaultComponentClass="Luca.View",Luca.config.defaultComponentType=Luca.defaultComponentType="view",Luca.registry.deprecatedComponents={},Luca.registry.componentAliases={},Luca.registry.typeAliases={grid:"grid_view",form:"form_view",text:"text_field",button:"button_field",select:"select_field",card:"card_view",paged:"card_view",wizard:"card_view",collection:"collection_view",list:"collection_view",multi:"collection_multi_view",table:"table_view"},Luca.registerComponent=function(a,c,d){var e,f,g,h,i,j;d==null&&(d="view"),Luca.trigger("component:registered",a,c);switch(d){case"model":e=b.model_classes[a],b.model_classes[a]=c;break;case"collection":e=b.collection_classes[a],b.collection_classes[a]=c;break;case"view":e=b.classes[a],b.classes[a]=c;break;default:e=b.classes[a],b.classes[a]=c}if(e!=null&&Luca.config.developmentMode===!0){g=Luca.registry.findInstancesByClassName(c);if(g.length>0){j=[];for(h=0,i=g.length;h<i;h++)f=g[h],j.push(typeof f.refreshEventBindings=="function"?f.refreshEventBindings():void 0);return j}}},Luca.registry.addNamespace=Luca.registry.namespace=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,h;if(c=Luca.registry.typeAliases[a])a=c;return d=b.classes[a],d!=null?d:(e=Luca.util.classify(a),g=Luca.registry.namespaces(),f=(h=_(g).chain().map(function(a){return a[e]}).compact().value())!=null?h[0]:void 0)},Luca.registry.instances=function(){return _(a.cid_index).values()},Luca.registry.findInstancesByClass=function(a){return Luca.registry.findInstancesByClassName(a.displayName)},Luca.registry.findInstancesByClassName=function(a){var b;return _.isString(a)||(a=a.displayName),b=Luca.registry.instances(),_(b).select(function(b){var c,d;return c=b.displayName===a,b.displayName===a||(typeof b._superClass=="function"?(d=b._superClass())!=null?d.displayName:void 0:void 0)===a})},Luca.registry.classes=function(a){return a==null&&(a=!1),_(_.extend({},b.classes,b.model_classes,b.collection_classes)).map(function(b,c){return a?b:{className:b,ctype:c}})},Luca.registry.find=function(a){return Luca.util.resolve(a)||Luca.define.findDefinition(a)},Luca.remove=Luca.registry.removeInstance=function(b){if(b==null)return;return _(a.name_index)["delete"](b),_(a.cid_index)["delete"](b)},Luca.cache=Luca.registry.cacheInstance=function(b,c){var d;if(b==null)return;return(c!=null?c.doNotCache:void 0)===!0?c:(c!=null&&(a.cid_index[b]=c),c=a.cid_index[b],(c!=null?c.component_name:void 0)!=null?a.name_index[c.component_name]=c.cid:(c!=null?c.name:void 0)!=null&&(a.name_index[c.name]=c.cid),c!=null?c:(d=a.name_index[b],a.cid_index[d]))}}.call(this),function(){var a;Luca.registry.componentMetaData={},Luca.registry.getMetaDataFor=function(b){return new a(Luca.registry.componentMetaData[b])},Luca.registry.addMetaData=function(a,b,c){var d,e;return d=(e=Luca.registry.componentMetaData)[a]||(e[a]={}),d[b]=_(c).clone(),d},a=function(){function a(a){this.meta=a!=null?a:{},_.defaults(this.meta,{"super class name":"","display name":"",descendants:[],aliases:[],"public interface":[],"public configuration":[],"private interface":[],"private configuration":[],"class configuration":[],"class interface":[]})}return a.prototype.className=function(){return this.meta["display name"]},a.prototype.superClass=function(){return Luca.util.resolve(this.meta["super class name"])},a.prototype.componentDefinition=function(){return Luca.registry.find(this.meta["display name"])},a.prototype.componentPrototype=function(){var a;return(a=this.componentDefinition())!=null?a.prototype:void 0},a.prototype.prototypeFunctions=function(){return _.functions(this.componentPrototype())},a.prototype.classAttributes=function(){return _.uniq(this.classInterface().concat(this.classConfiguration()))},a.prototype.publicAttributes=function(){return _.uniq(this.publicInterface().concat(this.publicConfiguration()))},a.prototype.privateAttributes=function(){return _.uniq(this.privateInterface().concat(this.privateConfiguration()))},a.prototype.classMethods=function(){var a;return a=_.functions(this.componentDefinition()),_(a).intersection(this.classAttributes())},a.prototype.publicMethods=function(){return _(this.prototypeFunctions()).intersection(this.publicAttributes())},a.prototype.privateMethods=function(){return _(this.prototypeFunctions()).intersection(this.privateAttributes())},a.prototype.classConfiguration=function(){return this.meta["class configuration"]},a.prototype.publicConfiguration=function(){return this.meta["public configuration"]},a.prototype.privateConfiguration=function(){return this.meta["private configuration"]},a.prototype.classInterface=function(){return this.meta["class interface"]},a.prototype.publicInterface=function(){return this.meta["public interface"]},a.prototype.privateInterface=function(){return this.meta["private interface"]},a.prototype.triggers=function(){return this.meta.hooks},a.prototype.hooks=function(){return this.meta.hooks},a.prototype.descendants=function(){return this.meta.descendants},a.prototype.styleHierarchy=function(){var a;return a=_(this.classHierarchy()).map(function(a){return Luca.util.toCssClass(a,"views","components","core","fields","containers")}),_(a).without("backbone-view","luca-view")},a.prototype.classHierarchy=function(){var a,b,c,d,e,f;a=[this.meta["display name"],this.meta["super class name"]],b=(c=this.superClass())!=null?(d=c.prototype)!=null?typeof d.componentMetaData=="function"?d.componentMetaData():void 0:void 0:void 0;while(!!b)a=a.concat(b!=null?b.classHierarchy():void 0),b=(e=b.superClass())!=null?(f=e.prototype)!=null?typeof f.componentMetaData=="function"?f.componentMetaData():void 0:void 0:void 0;return _(a).uniq()},a}()}.call(this),function(){}.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(){var a=Array.prototype.slice;Luca.DeferredBindingProxy=function(){function a(a,b,c){var d;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=_.bind(function(){return _.defer(d)},this.object):this.fn=_.bind(d,this.object),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.EventRelayer=function(){function b(a){a==null&&(a={}),this.target=a.target,this.events=a.events,this.prefix=a.prefix,this.source=a.source,this.events.length>0&&this.target&&this.source&&this.setup(),this}return b.prototype.prefixedBy=function(a){return this.prefix=a!=null?a:"",this},b.prototype.from=function(a){return this.source=a,this},b.prototype.to=function(a){return this.target=a,this},b.prototype.setup=function(b){var c,d,e,f,g,h;this.target=b,d=this.prefix,b=this.target,g=this.events,h=[];for(e=0,f=g.length;e<f;e++)c=g[e],console.log("Binding to ",c,d,this.target.name,this.source.name),h.push(this.source.on(c,function(){var b,e;return b=1<=arguments.length?a.call(arguments,0):[],e=_([d,c]).compact().join(":"),b.unshift(e),this.trigger.apply(this,b)},b));return h},b}(),Luca.Events={relays:function(){var b;return b=1<=arguments.length?a.call(arguments,0):[],new Luca.EventRelayer({relayer:this,events:b})},defer:function(a,b){return b==null&&(b=!0),new Luca.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.EventsExt={waitUntil:function(a,b){return this.waitFor.call(this,a,b)},waitFor:function(b,c){var d,e;return e=this,d={on:function(a){return a.waitFor.call(a,b,c)},and:function(){var d,f,g,h,i;f=1<=arguments.length?a.call(arguments,0):[],i=[];for(g=0,h=f.length;g<h;g++)d=f[g],d=_.isFunction(d)?d:e[d],i.push(e.once(b,d,c));return i},andThen:function(){return e.and.apply(e,arguments)}}},relayEvent:function(b){var c=this;return{on:function(){var d;return d=1<=arguments.length?a.call(arguments,0):[],{to:function(){var e,f,g,h,i,j;g=1<=arguments.length?a.call(arguments,0):[],j=[];for(h=0,i=g.length;h<i;h++)f=g[h],j.push(function(){var c,g,h,i=this;h=[];for(c=0,g=d.length;c<g;c++)e=d[c],h.push(e.on(b,function(){var c;return c=1<=arguments.length?a.call(arguments,0):[],c.unshift(b),f.trigger.apply(f,c)}));return h}.call(c));return j}}}}}}}.call(this),function(){var a,b;Luca.templates||(Luca.templates={});if(window.JST!=null)for(b in JST){a=JST[b];if(!b.match(/^luca\/templates\//))continue;Luca.templates[b.replace("luca/templates/","")]=a,_(JST)["delete"](b)}Luca.template=function(a,b,c){var d,e,f,g,h;window.JST||(window.JST={});if(_.isFunction(a))return a(b);e=(h=Luca.templates)!=null?h[a]:void 0,d=typeof JST!="undefined"&&JST!==null?JST[a]:void 0,e==null&&d==null&&(f=new RegExp(""+a+"$"),e=_(Luca.templates).detect(function(a,b){return f.exec(b)}),d=_(JST).detect(function(a,b){return f.exec(b)}));if(!e&&!d)throw"Could not find template named "+a;return g=e||d,g instanceof Hogan.template&&b!=null?g.render(b,c):b!=null?g(b):g},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}}.call(this),function(){Luca.concerns.ApplicationEventBindings={__initializer:function(){var a,b,c,d,e,f,g;if(_.isEmpty(this.applicationEvents))return;a=this.app;if(_.isString(a)||_.isUndefined(a))a=(e=Luca.Application)!=null?typeof e.get=="function"?e.get(a):void 0:void 0;if(!Luca.supportsEvents(a))throw"Error binding to the application object on "+(this.name||this.cid);f=this.applicationEvents,g=[];for(c=0,d=f.length;c<d;c++){b=f[c],_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"Error registering application event "+b+" on "+(this.name||this.cid);g.push(a.on(b,c,this))}return g}}}.call(this),function(){var a,b=Array.prototype.slice;Luca.concerns.CollectionEventBindings={__initializer:function(){var b=this;this.defer(function(){return Luca.concerns.CollectionEventBindings.__setup.call(b)}).until("after:initialize");if(this.collectionEventBindingsSetup!==!0)return Luca.isBackboneCollection(this.collection)&&(this.collection.on("reset",a("collection:reset"),this),this.collection.on("add",a("collection:add"),this),this.collection.on("remove",a("collection:remove"),this),this.collection.on("change",a("collection:change"),this),this.collection.on("before:fetch",a("collection:fetch"),this)),this.collectionEventBindingsSetup=!0},__setup:function(){var a,b,c,d,e,f,g,h,i;if(_.isEmpty(this.collectionEvents))return;e=this.collectionManager||Luca.CollectionManager.get(),g=this.collectionEvents,i=[];for(f in g){c=g[f],h=f.split(" "),d=h[0],b=h[1],a=e.getOrCreate(d);if(!a)throw"Could not find collection specified by "+d;_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"invalid collectionEvents configuration";try{i.push(a.on(b,c,this))}catch(j){throw console.log("Error Binding To Collection in registerCollectionEvents",this),j}}return i}},a=function(a){return function(){var c;return c=1<=arguments.length?b.call(arguments,0):[],c.unshift(a),this.trigger.apply(this,c)}}}.call(this),function(){Luca.concerns.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)),_.isObject(this.collection)&&!Luca.isBackboneCollection(this.collection)&&(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.concerns.DevelopmentToolHelpers={refreshEventBindings:function(){var a,b,c,d,e,f,g,h,i;f=this,console.log("Refreshing Event Bindings ON ",f.name||f.cid),f.undelegateEvents(),b=(typeof f.definitionClass=="function"?(g=f.definitionClass())!=null?g.events:void 0:void 0)||f.events;for(d in b){c=b[d];if(_.isString(c)!==!0)continue;a=typeof f.definitionClass=="function"?(h=f.definitionClass())!=null?h[c]:void 0:void 0,console.log("Rebinding dom event",d,c,a),f.events[d]=a}return f.state!=null&&f.stateful!=null&&(Luca.concerns.StateModel.__setupModelBindings.call(f,"off"),Luca.concerns.StateModel.__setupModelBindings.call(f,"on")),f.isContainer===!0&&!_.isEmpty(f.componentEvents)&&(Luca.Container.prototype.registerComponentEvents.call(this,void 0,"off"),e=typeof f.definitionClass=="function"?(i=f.definitionClass())!=null?i.componentEvents:void 0:void 0,Luca.Container.prototype.registerComponentEvents.call(this,e,"on")),f.delegateEvents()}}}.call(this),function(){Luca.concerns.DomHelpers={__initializer:function(){var a,b,c,d,e,f,g,h,i,j,k,l;b=_(this.additionalClassNames||[]).clone(),this.wrapperClass!=null&&this.$wrap(this.wrapperClass),_.isString(b)&&(b=b.split(" ")),(f=this.gridSpan||this.span)&&b.push("span"+f),(e=this.gridOffset||this.offset)&&b.push("offset"+e),(this.gridRowFluid||this.rowFluid)&&b.push("row-fluid"),(this.gridRow||this.row)&&b.push("row");if(b==null)return;for(g=0,i=b.length;g<i;g++)a=b[g],this.$el.addClass(a);if(Luca.config.autoApplyClassHierarchyAsCssClasses===!0){c=(typeof this.componentMetaData=="function"?(k=this.componentMetaData())!=null?k.styleHierarchy():void 0:void 0)||[],l=[];for(h=0,j=c.length;h<j;h++)d=c[h],d!=="luca-view"&&d!=="backbone-view"&&l.push(this.$el.addClass(d));return l}},$wrap:function(a){return _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a,"data-wrapper":!0})),this.$el.wrap(a)},$wrapper:function(){return this.$el.parent('[data-wrapper="true"]')},$template:function(a,b){var c;b==null&&(b={});try{return this.$el.html(Luca.template(a,b))}catch(d){return console.log("Error in $template: "+a+" "+(((c=typeof this.identifier==="function"?this.identifier():void 0)!=null?c:this.name)||this.cid))}},$html:function(a){return this.$el.html(a)},$append:function(a){return this.$el.append(a)},$attach:function(){return this.$container().append(this.el)},$bodyEl:function(){return this.$el},$container:function(){return $(this.container)}}}.call(this),function(){Luca.concerns.EnhancedProperties={__initializer:function(){if(Luca.config.enhancedViewProperties!==!0)return;_.isString(this.collection)&&Luca.CollectionManager.get()&&(this.collection=Luca.CollectionManager.get().getOrCreate(this.collection)),this.template!=null&&this.$template(this.template,this);if(_.isString(this.collectionManager))return this.collectionManager=Luca.CollectionManager.get(this.collectionManager)}}}.call(this),function(){var a,b=Object.prototype.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};Luca.concerns.Filterable={classMethods:{prepare:function(){var a,b,c;this.trigger("data:refresh");if(!this.isRemote())return;return a=_.clone(this.getRemoteQuery()),b=_.clone(this.getQueryOptions()),c=this.prepareRemoteFilter(a,b),this.collection.applyFilter(c,{remote:!0})}},__included:function(a,b){return _.extend(Luca.Collection.prototype,{__filters:{}})},__initializer:function(a,b){var c,d,e,f=this;if(this.filterable===!1)return;this.filterable===!0&&(this.filterable={}),Luca.isBackboneCollection(this.collection)||(this.collection=typeof (d=Luca.CollectionManager).get=="function"?(e=d.get())!=null?e.getOrCreate(this.collection):void 0:void 0);if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Filterable due to no collection being present on "+(this.name||this.cid)),this.debug("Collection",this.collection);return}return this.getCollection||(this.getCollection=function(){return this.collection}),c=this.getFilterState(),this.querySources||(this.querySources=[]),this.optionsSources||(this.optionsSources=[]),this.query||(this.query={}),this.queryOptions||(this.queryOptions={}),this.querySources.push(function(a){return a==null&&(a={}),f.getFilterState().toQuery()}),this.optionsSources.push(function(a){return a==null&&(a={}),f.getFilterState().toOptions()}),c.on("change",function(){return f.trigger("filter:change")}),this.on("filter:change",Luca.concerns.Filterable.classMethods.prepare,this),b},prepareRemoteFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b.limit!=null&&(a[Luca.config.apiLimitParameter]=b.limit),b.page!=null&&(a[Luca.config.apiPageParameter]=b.page),b.sortBy!=null&&(a[Luca.config.apiSortByParameter]=b.sortBy),a},isRemote:function(){var a;if(this.getQueryOptions().remote===!0)return!0;if(this.remoteFilterFallback===!0&&((a=this.getCollection())!=null?a.length:void 0)===0)return!0},getFilterState:function(){var b,c,d,e,f,g;return g=b=this.filterable||{},c=g.options,d=g.query,!_.isEmpty(b)&&_.isEmpty(d)&&_.isEmpty(c)&&_.extend(c,_(b).pluck("sortBy","page","limit")),(e=this.collection.__filters)[f=this.cid]||(e[f]=new a({query:d||{},options:c||{}}))},setSortBy:function(a,b){return b==null&&(b={}),this.getFilterState().setOption("sortBy",a,b)},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b=_.defaults(b,this.getQueryOptions()),this.getFilterState().clear({silent:!0}),this.getFilterState().set({query:a,options:b},b)}},a=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return c(b,a),b.prototype.defaults={options:{},query:{}},b.prototype.setOption=function(a,b,c){var d;return d={},d[a]=b,this.set("options",_.extend(this.toOptions(),d),c)},b.prototype.setQueryOption=function(a,b,c){var d;return d={},d[a]=b,this.set("query",_.extend(this.toQuery(),d),c)},b.prototype.toOptions=function(){return _.clone(this.toJSON().options)},b.prototype.toQuery=function(){return _.clone(this.toJSON().query)},b.prototype.toRemote=function(){return Luca.concerns.Filterable.prepareRemoteFilter.call(this,this.toQuery(),this.toOptions())},b}(Backbone.Model)}.call(this),function(){Luca.concerns.FormModelBindings={__initializer:function(){if(this.trackModelChanges!==!0)return;return this.on("state:change:currentModel",this.onStateChangeCurrentModel,this),_.bindAll(this,"onStateChangeCurrentModel","unbindFromModel","onModelChange","bindToModel")},onStateChangeCurrentModel:function(a,b,c){Luca.isBackboneModel(c)&&this.unbindFromModel(c);if(Luca.isBackboneModel(b))return this.bindToModel(b)},unbindFromModel:function(a){var b;return(b=a||this.currentModel())!=null?b.unbind("change",this.onModelChange):void 0},onModelChange:function(a){return this.setValues(a,{modelChange:!0})},bindToModel:function(a){var b;return(b=a||this.currentModel())!=null?b.bind("change",this.onModelChange,this):void 0}}}.call(this),function(){Luca.concerns.GridLayout={_initializer:function(){this.gridSpan&&this.$el.addClass("span"+this.gridSpan),this.gridOffset&&this.$el.addClass("offset"+this.gridOffset),this.gridRowFluid&&this.$el.addClass("row-fluid");if(this.gridRow)return this.$el.addClass("row")}}}.call(this),function(){Luca.concerns.LoadMaskable={__initializer:function(){var a=this;if(this.loadMask===!1||this.loadMask==null)return;return this.loadMask===!0&&(this.loadMask={enableEvent:"enable:loadmask",disableEvent:"disable:loadmask"}),this.on("collection:fetch",function(){return a.trigger("enable:loadmask")}),this.on("collection:reset",function(){return a.trigger("disable:loadmask")}),this.on("after:render",function(){this.$el.addClass("with-mask");if(this.$(".load-mask").length===0&&this.loadMaskTemplate!=null)return this.loadMaskTarget().prepend(Luca.template(this.loadMaskTemplate,this)),this.$(".load-mask").hide()},this),this.on(this.loadMask.enableEvent,this.applyLoadMask,this),this.on(this.loadMask.disableEvent,this.applyLoadMask,this)},showLoadMask:function(){return this.trigger("enable:loadmask")},hideLoadMask:function(){return this.trigger("disable:loadmask")},loadMaskTarget:function(){return this.loadMaskEl!=null?this.$(this.loadMaskEl):this.$bodyEl()},disableLoadMask:function(){return this.$(".load-mask .bar").css("width","100%"),this.$(".load-mask").hide(),clearInterval(this.loadMaskInterval)},enableLoadMask:function(){var a,b=this;this.$(".load-mask").show().find(".bar").css("width","0%"),a=this.$(".load-mask .progress").width(),a<20&&(a=this.$el.width())<20&&(a=this.$el.parent().width()),this.loadMaskInterval=setInterval(function(){var a,c;return a=b.$(".load-mask .bar").width(),c=a+12,b.$(".load-mask .bar").css("width",c)},200);if(this.loadMaskTimeout==null)return;return _.delay(function(){return b.disableLoadMask()},this.loadMaskTimeout)},applyLoadMask:function(){return this.$(".load-mask").is(":visible")?this.disableLoadMask():this.enableLoadMask()}}}.call(this),function(){Luca.LocalStore=function(){function a(a){var b;this.name=a,b=localStorage.getItem(this.name),this.data=b&&JSON.parse(b)||{}}return a.prototype.guid=function(){var a;return a=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},a.prototype.save=function(){return localStorage.setItem(this.name,JSON.stringify(this.data))},a.prototype.create=function(a){return a.id||(a.id=a.attribtues.id=this.guid()),this.data[a.id]=a,this.save(),a},a.prototype.update=function(a){return this.data[a.id]=a,this.save(),a},a.prototype.find=function(a){return this.data[a.id]},a.prototype.findAll=function(){return _.values(this.data)},a.prototype.destroy=function(a){return delete this.data[a.id],this.save(),a},a}(),Backbone.LocalSync=function(a,b,c){var d,e;return e=b.localStorage||b.collection.localStorage,d=function(){switch(a){case"read":return b.id?e.find(b):e.findAll();case"create":return e.create(b);case"update":return e.update(b);case"delete":return e.destroy(b)}}(),d?c.success(d):c.error("Record not found")}}.call(this),function(){Luca.concerns.ModalView={version:3,closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,__initializer:function(){if(this.modal!==!0)return;return this.on("before:render",this.applyModalConfig,this),this},applyModalConfig:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this.showOnInitialize!==!0&&this.$el.css("display","none"),this},container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.rendered!==!0&&this.render(),this.trigger("before:show"),this.$el.modal("show"),this.trigger("after:show")},hide:function(){return this.trigger("before:hide"),this.$el.modal("hide"),this.trigger("after:hide")},setModalDimensions:function(a,b){var c;_.isObject(a)&&(c=a,a=c.height,b=c.width),a!=null&&this.setModalHeight(a);if(b!=null)return this.setModalWidth(b)},setModalWidth:function(a){return this.$el.css({width:a,"max-width":a,"margin-left":a*.5*-1})},setModalHeight:function(a){return this.$el.css({"max-height":a,"margin-top":a*.5*-1,height:a})}}}.call(this),function(){Luca.concerns.ModelPresenter={classMethods:{getPresenter:function(a){var b;return(b=this.presenters)!=null?b[a]:void 0},registerPresenter:function(a,b){return this.presenters||(this.presenters={}),this.presenters[a]=b}},presentAs:function(a){var b,c=this;try{return b=this.componentMetaData().componentDefinition().getPresenter(a),b==null?this.toJSON():_(b).reduce(function(a,b){return a[b]=c.read(b),a},{})}catch(d){return console.log("Error presentAs",d.stack,d.message),this.toJSON()}}}}.call(this),function(){Luca.concerns.Paginatable={paginatorViewClass:"Luca.components.PaginationControl",paginationSelector:".toolbar.bottom.pagination-container",__included:function(){return _.extend(Luca.Collection.prototype,{__paginators:{}})},__initializer:function(){var a,b,c=this;if(this.paginatable===!1)return;if(_.isNumber(this.paginatable)||_.isString(this.paginatable))this.paginatable={limit:parseInt(this.paginatable),page:1};if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Paginatable due to no collection being present on "+(this.name||this.cid)),this.debug("collection",this.collection);return}return _.bindAll(this,"paginationControl","pager"),a=(this.getCollection||(this.getCollection=function(){return this.collection}))(),b=this.getPaginationState(),this.optionsSources||(this.optionsSources=[]),this.queryOptions||(this.queryOptions={}),this.optionsSources.push(function(){var a;return a=_(b.toJSON()).pick("limit","page","sortBy"),_.extend(a,{pager:c.pager})}),b.on("change:page",function(){return c.trigger("pagination:change")}),this.on("pagination:change",Luca.concerns.Filterable.classMethods.prepare,this),this.on("before:render",this.renderPaginationControl,this)},pager:function(a,b){return this.getPaginationState().set({numberOfPages:a,itemCount:b.length}),this.paginationControl().updateWithPageCount(a,b)},isRemote:function(){return this.getQueryOptions().remote===!0},getPaginationState:function(){var a,b;return(a=this.collection.__paginators)[b=this.cid]||(a[b]=this.paginationControl().state)},paginationContainer:function(){return this.$(">"+this.paginationSelector)},setCurrentPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.getPaginationState().set("page",a,b)},setPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.getPaginationState().set("page",a,b)},setLimit:function(a,b){return a==null&&(a=0),b==null&&(b={}),this.getPaginationState().set("limit",a,b)},paginationControl:function(){return this.paginator!=null?this.paginator:(_.defaults(this.paginatable||(this.paginatable={}),{page:1,limit:20}),this.paginator=Luca.util.lazyComponent({type:"pagination_control",collection:this.getCollection(),defaultState:this.paginatable,parent:this.name||this.cid,debugMode:this.debugMode}),this.paginator)},renderPaginationControl:function(){var a;return a=this.paginationControl(),this.paginationContainer().append(a.render().$el),a}}}.call(this),function(){Luca.concerns.QueryCollectionBindings={getCollection:function(){return this.collection},loadModels:function(a,b){var c;return a==null&&(a=[]),b==null&&(b={}),(c=this.getCollection())!=null?c.reset(a,b):void 0},applyQuery:function(a,b){return a==null&&(a={}),b==null&&(b={}),this.query=a,this.queryOptions=b,this.refresh(),this},getQuery:function(a){var b,c,d,e,f;a==null&&(a={}),b=this.query||(this.query={}),f=_(this.querySources||[]).compact();for(d=0,e=f.length;d<e;d++)c=f[d],b=_.extend(b,c(a)||{});return Luca.util.readAll(b)},getRemoteQuery:function(a){return a==null&&(a={}),this.getQuery(a)},getLocalQuery:function(a){return a==null&&(a={}),this.getQuery(a)},getQueryOptions:function(a){var b,c,d,e,f;a==null&&(a={}),c=this.queryOptions||(this.queryOptions={}),f=_(this.optionsSources||[]).compact();for(d=0,e=f.length;d<e;d++)b=f[d],c=_.extend(c,b(a)||{});return c},getModels:function(a,b){var c;return((c=this.collection)!=null?c.query:void 0)?(a||(a=this.getLocalQuery()),b||(b=this.getQueryOptions()),b.prepare||(b.prepare=this.prepareQuery),this.collection.query(a,b)):this.collection.models}}}.call(this),function(){var a;Luca.concerns.Sortable={__included:function(a,b){return _.extend(Luca.Collection.prototype,{__sortables:{}})},__initializer:function(){var a,b,c=this;if(this.sortable===!1)return;_.isString(this.sortable)&&(this.sortable={sortBy:this.sortable});if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Sortable due to no collection being present on "+(this.name||this.cid)),this.debug("collection",this.collection);return}return a=(this.getCollection||(this.getCollection=function(){return this.collection}))(),b=this.getSortableState(),this.optionsSources||(this.optionsSources=[]),this.queryOptions||(this.queryOptions={}),this.optionsSources.push(function(){return _(b.toJSON()).pick("sortBy","order")}),b.on("change",function(){return c.trigger("sortable:change")}),this.defer(function(){return c.$(".sortable-toggle").on("click",function(a){var b,d;return b=d=c.$(a.target),b=d=d.closest(".sortable-toggle"),c.toggleSortOrderDirection(d.data("sortableSortBy"))})}).until("after:render"),this.on("sortable:change",Luca.concerns.Filterable.classMethods.prepare,this)},isRemote:function(){return this.getQueryOptions().remote===!0},getSortableState:function(){var b,c,d;return b=_(this.sortable||{}).pick("sortBy","order"),(c=this.collection.__sortables)[d=this.cid]||(c[d]=new a(b))},sortBy:function(a,b){return a!=null&&this.setSortBy(a),b!=null&&this.setOrder(b),this},setSortBy:function(a,b){return b==null&&(b={}),this.getSortableState().set("sortBy",a,b),this},toggleSortOrderDirection:function(a){var b,c;return c=this.getSortableState().get("order")||"ASC",b=c==="ASC"?"DESC":"ASC",a||(a=this.getSortableState().get("sortBy")),this.sortBy(a,b)},setOrder:function(a,b){return b==null&&(b={}),this.getSortableState().set("order",a,b),this}},Luca.util.makeSortableToggleElement=function(a,b,c){return $(a).attr("data-sortable-sort-by",b).attr("data-sortable-order",c),$(a)},a=Backbone.Model.extend()}.call(this),function(){var a,b=Array.prototype.slice;a=Luca.register("Luca.ViewState")["extends"]("Luca.Model"),Luca.concerns.StateModel={__onModelChange:function(){var a,c,d,e,f,g,h,i;a=1<=arguments.length?b.call(arguments,0):[],e=this,d=e.state,(g=this.trigger).call.apply(g,[e,"state:change"].concat(b.call(a))),h=d.changedAttributes(),i=[];for(c in h)f=h[c],i.push(this.trigger.call(e,"state:change:"+c,d,f,d.previous(c)));return i},__initializer:function(){var a,b,c,d,e,f,g;this.stateAttributes!=null&&(this.stateful=this.stateAttributes);if(this.stateful==null)return;d=this,_.isObject(this.stateful)&&this.defaultState==null&&(this.defaultState=this.stateful),this.state||(this.state=new Luca.ViewState(this.defaultState||{})),f=this,this.get=function(){return f.state.get.apply(f.state,arguments)},this.set=function(){return f.state.set.apply(f.state,arguments)},g=this.state.toJSON();for(c in g)e=g[c],b="on"+_.str.capitalize(c)+"Change",a="get"+_.str.capitalize(c),_.isFunction(this[a])||1,_.isFunction(this[b])&&1;return Luca.concerns.StateModel.__setupModelBindings.call(this,"on")},__setupModelBindings:function(a){var b,c,d,e,f,g;a==null&&(a="on"),f=this,g=this.stateChangeEvents;for(b in g)d=g[b],c=_.isString(d)?f[d]:d,b==="*"?f[a]("state:change",c,f):f[a]("state:change:"+b,c,f);return e=f.state,f.state[a]("change",Luca.concerns.StateModel.__onModelChange,f)}}}.call(this),function(){Luca.concerns.Templating={__initializer:function(){var a,b,c;c=Luca.util.read.call(this,this.bodyTemplateVars)||{};if(a=this.bodyTemplate){this.$el.empty();try{b=Luca.template(a,c)}catch(d){console.log("Error Rendering "+a+" in View: "+((typeof this.identifier=="function"?this.identifier():void 0)||this.name||this.cid))}return Luca.View.prototype.$html.call(this,b)}}}}.call(this),function(){var a,b;a=Luca.define("Luca.Model"),a["extends"]("Backbone.Model"),a.includes("Luca.Events"),a.defines({initialize:function(){return Backbone.Model.prototype.initialize(this,arguments),b.call(this),Luca.concern.setup.call(this)},read:function(a){return _.isFunction(this[a])?this[a].call(this):this.get(a)||this[a]},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)}}),b=function(){var a,b,c,d,e=this;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.read(a)}),_.isString(b)&&(b=b.split(",")),d.push(_(b)
3
- .each(function(b){e.on("change:"+b,function(){return e.trigger("change:"+a)});if(e.has(b))return e.trigger("change:"+a)}));return d},Luca.Model._originalExtend=Backbone.Model.extend,Luca.Model.extend=function(a){var b,c,d,e,f;a==null&&(a={}),a.concerns!=null&&(a.concerns||(a.concerns=a.concerns)),b=Luca.Model._originalExtend.call(this,a);if(a.concerns!=null&&_.isArray(a.concerns)){f=a.concerns;for(d=0,e=f.length;d<e;d++)c=f[d],Luca.decorate(b)["with"](c)}return b}}.call(this),function(){var a;a=Luca.define("Luca.Collection"),a["extends"]("Backbone.QueryCollection"),a.includes("Luca.Events"),a.triggers("after:initialize","before:fetch","after:response"),a.defines({model:Luca.Model,cachedMethods:[],remoteFilter:!1,initialize:function(a,b){var c,d=this;a==null&&(a=[]),this.options=b,_.extend(this,this.options),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=Luca.util.read(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.manager=_.isFunction(this.manager)?this.manager():this.manager,this.name&&!this.manager&&(this.manager=Luca.CollectionManager.get()),this.manager&&(this.name||(this.name=Luca.util.read(this.cache_key)),this.name=Luca.util.read(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 a cache_key property or method 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}),Luca.concern.setup.call(this),Luca.util.setupHooks.call(this,this.hooks),this.setupMethodCaching(),this.trigger("after:initialize")},__wrapUrl:function(){var a,b,c=this;return _.isFunction(this.url)?this.url=_.wrap(this.url,function(a){var b,d,e,f,g;return g=a.apply(c),e=g.split("?"),e.length>1&&(b=_.last(e)),f=c.queryString(),b&&g.match(b)&&(f=f.replace(b,"")),d=""+g+"?"+f,d.match(/\?$/)&&(d=d.replace(/\?$/,"")),d}):(b=this.url,a=this.queryString(),this.url=_([b,a]).compact().join("?"))},queryString:function(){var a,b=this;return a=_(this.base_params||(this.base_params=Luca.Collection.baseParams())).inject(function(a,b,c){var d;return d=""+c+"="+b,a.push(d),a},[]),_.uniq(a).join("&")},resetFilter:function(){return this.base_params=_(Luca.Collection.baseParams()).clone(),this},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b=_(b).clone(),b.remote!=null==1||this.remoteFilter===!0?(this.applyParams(a),this.fetch(_.extend(b,{refresh:!0,remote:!0}))):this.reset(this.query(a,b))},applyParams:function(a){return this.base_params=_(Luca.Collection.baseParams()).clone()||{},_.extend(this.base_params,a),this},register:function(a,b,c){b==null&&(b=""),a||(a=Luca.CollectionManager.get());if(!(b.length>=1))throw"Attempt to register a collection without specifying a key.";_.isString(a)&&(a=Luca.util.resolve(a));if(a==null)throw"Attempt to register with a non existent collection manager.";if(_.isFunction(a.add))return a.add(b,c);if(_.isObject(a))return a[b]=c},loadFromBootstrap:function(){if(!this.bootstrap_cache_key)return;return this.reset(this.cached_models()),this.trigger("bootstrapped",this)},bootstrap:function(){return this.loadFromBootstrap()},cached_models:function(){return Luca.Collection.cache(this.bootstrap_cache_key)},fetch:function(a){var b;a==null&&(a={}),this.trigger("before:fetch",this);if(this.memoryCollection===!0)return this.reset(this.data);if(this.cached_models().length&&a.refresh!==!0&&a.remote!==!0)return this.bootstrap();b=_.isFunction(this.url)?this.url():this.url;if(!(b&&b.length>1||this.localStorage))return!0;this.fetching=!0;try{return Backbone.Collection.prototype.fetch.apply(this,arguments)}catch(c){throw console.log("Error in Collection.fetch",c),c}},onceLoaded:function(a,b){var c,d=this;b==null&&(b={}),_.defaults(b,{autoFetch:!0});if(this.length>0&&!this.fetching){a.apply(this,[this]);return}c=function(){return a.apply(d,[d])},this.bind("reset",function(){return c(),this.unbind("reset",this)});if(!this.fetching&&!!b.autoFetch)return this.fetch()},ifLoaded:function(a,b){var c,d=this;b==null&&(b={scope:this,autoFetch:!0}),c=b.scope||this,this.length>0&&!this.fetching&&a.apply(c,[this]),this.bind("reset",function(b){return a.call(c,b)});if(!(this.fetching===!0||!b.autoFetch||this.length>0))return this.fetch()},parse:function(a){var b;return this.fetching=!1,this.trigger("after:response",a),b=this.root!=null?a[this.root]:a,this.bootstrap_cache_key&&Luca.Collection.cache(this.bootstrap_cache_key,b),b},restoreMethodCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],a.original!=null?(a.args=void 0,d.push(this[b]=a.original)):d.push(void 0);return d},clearMethodCache:function(a){return this._methodCache[a].value=void 0},clearAllMethodsCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],d.push(this.clearMethodCache(b));return d},setupMethodCaching:function(){var b,c,d;if(((d=this.cachedMethods)!=null?d.length:void 0)>0)return a=this,c=["reset","add","remove"],b=this._methodCache={},_(this.cachedMethods).each(function(d){var e,f,g,h,i;b[d]={name:d,original:a[d],value:void 0},a[d]=function(){var c;return(c=b[d]).value||(c.value=b[d].original.apply(a,arguments))};for(h=0,i=c.length;h<i;h++)f=c[h],a.bind(f,function(){return a.clearAllMethodsCache()});e=d.split(":")[1];if(e)return g=e.split(","),_(g).each(function(b){return a.bind("change:"+b,function(){return a.clearMethodCache({method:d})})})});return},query:function(a,b){var c;return a==null&&(a={}),b==null&&(b={}),Backbone.QueryCollection!=null?(_.isFunction(c=b.prepare||this.prepareQuery)&&(a=c(a)),Backbone.QueryCollection.prototype.query.call(this,a,b)):this.models}}),_.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._originalExtend=Backbone.Collection.extend,Luca.Collection.extend=function(a){var b,c,d,e,f;a==null&&(a={}),a.concerns!=null&&(a.concerns||(a.concerns=a.concerns)),b=Luca.Collection._originalExtend.call(this,a);if(a.concerns!=null&&_.isArray(a.concerns)){f=a.concerns;for(d=0,e=f.length;d<e;d++)c=f[d],Luca.decorate(b)["with"](c)}return b},Luca.Collection.namespace=function(a){var b;return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&(Luca.Collection.__defaultNamespace=a),(b=Luca.Collection).__defaultNamespace||(b.__defaultNamespace=window||global),Luca.util.read(Luca.Collection.__defaultNamespace)},Luca.Collection.baseParams=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a&&(Luca.Collection._baseParams=a),Luca.util.read(Luca.Collection._baseParams)},Luca.Collection.resetBaseParams=function(){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,b,c,d=Array.prototype.slice;c=Luca.register("Luca.View"),c["extends"]("Backbone.View"),c.includes("Luca.Events","Luca.concerns.DomHelpers","Luca.concerns.DevelopmentToolHelpers"),c.mixesIn("DomHelpers","Templating","EnhancedProperties","CollectionEventBindings","ApplicationEventBindings","StateModel"),c.triggers("before:initialize","after:initialize","before:render","after:render","first:activation","activation","deactivation"),c.publicConfiguration({name:void 0,autoBindEventHandlers:!1,_events:void 0}),c.publicMethods({identifier:function(){return(this.displayName||this.type)+":"+(this.name||this.role||this.cid)},remove:function(){return this.trigger("before:remove",this),Luca.remove(this),Backbone.View.prototype.remove.apply(this,arguments)},initialize:function(b){var c,e,f,g,h;this.options=b!=null?b:{},this.trigger("before:initialize",this,this.options),_.extend(this,this.options),(this.autoBindEventHandlers===!0||this.bindAllEvents===!0)&&a.call(this),this.name!=null&&(this.cid=_.uniqueId(this.name)),this.$el.attr("data-luca-id",this.name||this.cid),Luca.registry.cacheInstance(this.cid,this),this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq()),Luca.concern.setup.call(this),this.delegateEvents(),this.trigger("after:initialize",this),((f=this.bindMethods)!=null?f.legth:void 0)>0&&_.bindAll.apply(_,[this].concat(d.call(this.bindMethods)));if(!_.isEmpty(this._events)){g=this._events,h=[];for(c in g)e=g[c],h.push(this.registerEvent(c,e));return h}},debug:function(){var a;a=1<=arguments.length?d.call(arguments,0):[];if(this.debugMode===!0||window.LucaDebugMode===!0)return a.unshift(this.identifier()),console.log.apply(console,a)},trigger:function(){return Luca.enableGlobalObserver&&(Luca.developmentMode===!0||this.observeEvents===!0)&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)},registerEvent:function(a,b){return this.events||(this.events={}),_.isObject(a)?this.events=_.extend(this.events,a):this.events[a]=b,this.delegateEvents()}}),c.privateMethods({definitionClass:function(){var a;return(a=Luca.util.resolve(this.displayName,window))!=null?a.prototype:void 0},_collections:function(){return Luca.util.selectProperties(Luca.isBackboneCollection,this)},_models:function(){return Luca.util.selectProperties(Luca.isBackboneModel,this)},_views:function(){return Luca.util.selectProperties(Luca.isBackboneView,this)},setupHooks:Luca.util.setupHooks}),c.register(),Luca.View._originalExtend=Backbone.View.extend,Luca.View.renderStrategies={legacy:function(a){var b,d,e,f,g,h=this;return c=this,this.deferrable?(f=this.deferrable_target,Luca.isBackboneCollection(this.deferrable)||(this.deferrable=this.collection),f||(f=this.deferrable),g=this.deferrable_event?this.deferrable_event:Luca.View.deferrableEvent,d=function(){return a.call(c),this.rendered=!0,c.trigger("after:render",c)},c.defer(d).until(f,g),c.trigger("before:render",this),b=this.deferrable_trigger||this.deferUntil,b==null?f[this.deferrable_method||"fetch"].call(f):(e=_.once(function(){var a,b;return typeof (a=h.deferrable)[b=h.deferrable_method||"fetch"]=="function"?a[b]():void 0}),(this.deferrable_target||this).bind(this.deferrable_trigger,e)),this):(this.trigger("before:render",this),a.apply(this,arguments),this.rendered=!0,this.trigger("after:render",this),this)},improved:function(a){var b,d=this;this.trigger("before:render",this),b=function(){return a.apply(d,arguments),d.trigger("after:render",d)},console.log("doing the improved one",this.deferrable);if(this.deferrable!=null&&!_.isString(this.deferrable))throw"Deferrable property is expected to be a event id";return _.isString(this.deferrable)?(console.log("binding to "+this.deferrable+" on "+this.cid),c.on(this.deferrable,function(){return console.log("did the improved one"),b.call(c),c.unbind(listenForEvent,this)})):b.call(this)}},Luca.View.renderWrapper=function(a){var b;return b=a.render,b||(b=function(){return this.trigger("empty:render")}),a.render=function(){var a;a=Luca.View.renderStrategies[this.renderStrategy||(this.renderStrategy="legacy")];if(!_.isFunction(a))throw"Invalid rendering strategy. Please see Luca.View.renderStrategies";return a.call(this,b),this},a},a=function(){var a,c,d,e,f;e=[this.events,this.componentEvents,this.collectionEvents,this.applicationEvents],f=[];for(c=0,d=e.length;c<d;c++)a=e[c],_.isEmpty(a)||f.push(b.call(this,a));return f},b=function(a){var b,c,d;a==null&&(a={}),d=[];for(b in a){c=a[b];if(_.isString(c))try{d.push(_.bindAll(this,c))}catch(e){d.push(console.log("Error binding to handler - "+c+" = "+e+" "+this.identifier()))}else d.push(void 0)}return d},Luca.View.deferrableEvent="reset",Luca.View.extend=function(a){var b,c,d,e,f;a==null&&(a={}),a=Luca.View.renderWrapper(a),a.concerns!=null&&(a.concerns||(a.concerns=a.concerns)),b=Luca.View._originalExtend.call(this,a);if(a.concerns!=null&&_.isArray(a.concerns)){f=a.concerns;for(d=0,e=f.length;d<e;d++)c=f[d],Luca.decorate(b)["with"](c)}return b}}.call(this),function(){var a;a=Luca.register("Luca.Panel"),a.replaces("Luca.Panel"),a["extends"]("Luca.View"),a.configuration({topToolbar:void 0,bottomToolbar:void 0}),a.publicMethods({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},$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 _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$html(Luca.template(a,b))},$empty:function(){return this.$bodyEl().empty()},$html:function(a){return this.$bodyEl().html(a)},$append:function(a){return this.$bodyEl().append(a)}}),a.privateMethods({beforeRender:function(){var a;return(a=Luca.View.prototype.beforeRender)!=null&&a.apply(this,arguments),this.styles!=null&&this.applyStyles(this.styles),this.bodyStyles!=null&&this.applyStyles(this.bodyStyles,!0),typeof this.renderToolbars=="function"?this.renderToolbars():void 0},renderToolbars:function(){var a=this;return _(["top","left","right","bottom"]).each(function(b){var c;if(c=a[""+b+"Toolbar"])return a.renderToolbar(b,c)})},renderToolbar:function(a,b){var c;return a==null&&(a="top"),b==null&&(b={}),b.parent=this,b.orientation=a,c=Luca.util.read(b.container),c||(c=Luca.util.read(b.targetEl)),Luca.Panel.attachToolbar.call(this,b,c)}}),a.classMethods({attachToolbar:function(a,b){var c,d,e,f;return a==null&&(a={}),a.orientation||(a.orientation="top"),a.type||(a.type=a.ctype||(a.ctype=this.toolbarType||"panel_toolbar")),a.additionalClassNames=""+Luca.config.toolbarContainerClass+" "+a.orientation,e=Luca.util.lazyComponent(a),a.orientation==="bottom"&&(this.getBottomToolbar||(this.getBottomToolbar=function(){return e})),a.orientation==="top"&&(this.getTopToolbar||(this.getTopToolbar=function(){return e})),a.orientation==="right"&&(this.getRightToolbar||(this.getRightToolbar=function(){return e})),a.orientation==="left"&&(this.getLeftToolbar||(this.getLeftToolbar=function(){return e})),d=this.bodyClassName||this.bodyTagName,c=a.attachmentAction,c||(c=function(){switch(a.orientation){case"top":case"left":return d&&(b!=null?!b.length:!void 0)>0?"before":"prepend";case"bottom":case"right":return d&&(b!=null?!b.length:!void 0)>0?"after":"append"}}()),f=(b!=null?b.length:void 0)>0?this.$(b):this.$bodyEl(),f[c](e.render().el)}}),a.defines({version:3})}.call(this),function(){}.call(this),function(){var a,b,c;Luca.CollectionManager=function(){function c(a){var c,d,e,f;this.options=a!=null?a:{},_.extend(this,this.options),d=this;if(c=typeof (e=Luca.CollectionManager).get=="function"?e.get(this.name):void 0)throw"Attempt to create a collection manager with a name which already exists";this.collectionNamespace||(this.collectionNamespace=Luca.util.read(Luca.Collection.namespace)),(f=Luca.CollectionManager).instances||(f.instances={}),_.extend(this,Backbone.Events),_.extend(this,Luca.Events),Luca.CollectionManager.instances[this.name]=d,Luca.CollectionManager.get=function(a){return a==null?d:Luca.CollectionManager.instances[a]},this.state=new Luca.Model,this.initialCollections&&this.on("ready",b,this),this.autoStart===!0&&this.trigger("ready")}return c.prototype.name="primary",c.prototype.__collections={},c.prototype.autoStart=!0,c.prototype.relayEvents=!0,c.prototype.add=function(a,b){var c;return(c=this.currentScope())[a]||(c[a]=b)},c.prototype.allCollections=function(){return _(this.currentScope()).values()},c.prototype.create=function(b,c,d){var e,f,g;c==null&&(c={}),d==null&&(d=[]),e=c.base,e||(e=a.call(this,b)),c.private&&(c.name="");try{f=new e(d,c)}catch(h){throw console.log("Error creating collection",e,c,b),h}return this.add(b,f),g=this,this.relayEvents===!0&&this.bind("*",function(){return console.log("Relay Events on Collection Manager *",f,arguments)}),f},c.prototype.currentScope=function(){var a,b;return(a=this.getScope())?(b=this.__collections)[a]||(b[a]={}):this.__collections},c.prototype.each=function(a){return _(this.all()).each(a)},c.prototype.get=function(a){return this.currentScope()[a]},c.prototype.getScope=function(){return},c.prototype.destroy=function(a){var b;return b=this.get(a),delete this.currentScope()[a],b},c.prototype.getOrCreate=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.get(a)||this.create(a,b,c,!1)},c.prototype.collectionCountDidChange=function(){if(this.allCollectionsLoaded())return this.trigger("all_collections_loaded"),this.trigger("initial:load")},c.prototype.allCollectionsLoaded=function(){return this.totalCollectionsCount()===this.loadedCollectionsCount()},c.prototype.totalCollectionsCount=function(){return this.state.get("collections_count")},c.prototype.loadedCollectionsCount=function(){return this.state.get("loaded_collections_count")},c.prototype.private=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.create(a,b,c,!0)},c}(),Luca.CollectionManager.isRunning=function(){return _.isEmpty(Luca.CollectionManager.instances)!==!0},Luca.CollectionManager.destroyAll=function(){return Luca.CollectionManager.instances={}},Luca.CollectionManager.loadCollectionsByName=function(a,b){var c,d,e,f,g;g=[];for(e=0,f=a.length;e<f;e++)d=a[e],(c=this.getOrCreate(d))?(c.on("reset",function(){return b(c),c.unbind("reset",this)}),g.push(c.fetch())):g.push(void 0);return g},a=function(a){var b,c,d,e;return b=Luca.util.classify(a),_.isString(this.collectionNamespace)&&(this.collectionNamespace=Luca.util.resolve(this.collectionNamespace)),c=(this.collectionNamespace||window||global)[b],c||(c=(this.collectionNamespace||window||global)[""+b+"Collection"]),c==null&&((e=Luca.Collection.namespaces)!=null?e.length:void 0)>0&&(d=_(Luca.Collection.namespaces.reverse()).map(function(a){return Luca.util.resolve(""+a+"."+b)||Luca.util.resolve(""+a+"."+b+"Collection")}),d=_(d).compact(),d.length>0&&(c=d[0])),c},c=function(){var a,b,c=this;return a=function(a){var b;return b=c.state.get("loaded_collections_count"),c.state.set("loaded_collections_count",b+1),c.trigger("collection_loaded",a.name),a.unbind("reset")},b=this.initialCollections,Luca.CollectionManager.loadCollectionsByName.call(this,b,a)},b=function(){var a=this;return this.state.set({loaded_collections_count:0,collections_count:this.initialCollections.length}),this.state.bind("change:loaded_collections_count",function(){return a.collectionCountDidChange()}),this.useProgressLoader&&(this.loaderView||(this.loaderView=new Luca.components.CollectionLoaderView({manager:this,name:"collection_loader_view"}))),c.call(this),this}}.call(this),function(){var a;a=Luca.register("Luca.SocketManager"),a["extends"]("Luca.Model"),a.defines({defaults:{autoStart:!0,providerAvailable:!1,ready:!1,provider:"faye.js"},initialize:function(a){var b,c,d,e=this;return this.attributes=a!=null?a:{},this.providerLibraryIsAvailable()||this.loadProviderSource(),(d=Luca.Model.prototype.initialize)!=null&&d.apply(this,arguments),c=this,b=function(){if(e.isReady())return e.connect()},c.on("change:ready",function(){return b(),c.unbind("change:ready",this)}),c.on("change:providerAvailable",function(){return b(),c.unbind("change:ready",this)}),this.on("ready",_.once(function(){return e.set("ready",!0)})),this.trigger("change")},isReady:function(){return this.get("ready")===!0&&this.get("providerAvailable")===!0},providerLibraryIsAvailable:function(){var a;return a=function(){switch(this.get("provider")){case"socket.io":return"io";case"faye.js":return"Faye.Client"}}.call(this),Luca.util.resolve(a)!=null},connect:function(){switch(this.get("provider")){case"socket.io":return this.client=io.connect(this.get("host"));case"faye.js":return this.client=new Faye.Client(this.get("host")),this.set("client",this.client)}},providerSourceLoaded:function(){return this.set("providerAvailable",!0)},providerSourceUrl:function(){switch(this.get("provider")){case"socket.io":return""+this.get("host")+"/socket.io/socket.io.js";case"faye.js":return""+this.get("host")+"/faye.js"}},loadProviderSource:function(){var a,b=this;return a=document.createElement("script"),a.setAttribute("type","text/javascript"),a.setAttribute("src",this.providerSourceUrl()),a.onload=_.bind(this.providerSourceLoaded,this),Luca.util.isIE()&&(a.onreadystatechange=function(){if(a.readyState==="loaded")return b.providerSourceLoaded()}),document.getElementsByTagName("head")[0].appendChild(a)}})}.call(this),function(){}.call(this),function(){var a,b,c,d,e,f,g,h;b=Luca.register("Luca.Container"),b["extends"]("Luca.Panel"),b.triggers("before:components","before:render:components","before:layout","after:components","after:layout","first:activation"),b.replaces("Luca.Container"),b.publicConfiguration({components:[]}),b.privateConfiguration({emptyContainerElements:!1,className:"luca-ui-container",componentTag:"div",componentClass:"luca-ui-panel",isContainer:!0,rendered:!1,componentEvents:{},initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},_.extend(this,this.options),this.components||(this.components=this.fields||(this.fields=this.pages||(this.pages=this.cards||(this.cards=this.views)))),e=this.components;for(c=0,d=e.length;c<d;c++)b=e[c],_.isString(b)&&(b={type:b,role:b,name:b});return _.bindAll(this,"beforeRender"),this.setupHooks(Luca.Container.prototype.hooks),h(this),Luca.View.prototype.initialize.apply(this,arguments)},remove:function(){return Luca.View.prototype.remove.apply(this,arguments),this.eachComponent(function(a){return typeof a.remove=="function"?a.remove():void 0})},beforeRender:function(){var a;return f.call(this),e.call(this),(a=Luca.Panel.prototype.beforeRender)!=null?a.apply(this,arguments):void 0},customizeContainerEl:function(a,b,c){return a},prepareLayout:function(){var c,d,e,f,g,h,i;b=this,this.componentContainers=_(this.components).map(function(c,d){return a.call(b,c,d)}),c=this._().select(function(a){var c;return _.isString(a.container)&&((c=a.container)!=null?c.match(/^\./):void 0)&&b.$(a.container).length>0});if(c.length>0){i=[];for(g=0,h=c.length;g<h;g++)e=c[g],d=_.uniqueId("container"),f=b.$(e.container),f.length>0?($(f).attr("data-container-assignment",d),i.push(e.container+="[data-container-assignment='"+d+"']")):i.push(void 0);return i}},prepareComponents:function(){var a=this;return b=this,_(this.components).each(function(c,d){var e,f,g,h,i,j;e=f=(i=a.componentContainers)!=null?i[d]:void 0,e["class"]=e["class"]||e.className||e.classes,a.generateComponentElements&&(h=a.make(a.componentTag,f,""),a.$append(h)),b.defaults!=null&&(c=_.defaults(c,b.defaults||{})),_.isArray(b.extensions)&&_.isObject((j=b.extensions)!=null?j[d]:void 0)&&(g=b.extensions[d],c=_.extend(c,g)),c.role!=null&&_.isObject(b.extensions)&&_.isObject(b.extensions[c.role])&&(g=b.extensions[c.role],c=_.extend(c,g));if(c.container==null)return a.generateComponentElements&&(c.container="#"+f.id),c.container||(c.container=a.$bodyEl())})},createComponents:function(){var a,c=this;if(this.componentsCreated===!0)return;return a=this.componentIndex={name_index:{},cid_index:{},role_index:{}},b=this,this.components=_(this.components).map(function(a,d){var e,f,h;return e=Luca.isComponent(a)?a:(a.component!=null&&!a.type&&!a.ctype?(a.type=a.component,a.name||(a.name=a.component),a.role||(a.role=a.component)):void 0,a.type||(a.type=a.ctype),a.type==null?a.components!=null?a.type=a.ctype="container":a.type=a.ctype=Luca.defaultComponentType:void 0,a._parentCid||(a._parentCid=b.cid),f=Luca.util.lazyComponent(a)),!e.container&&((h=e.options)!=null?h.container:void 0)&&(e.container=e.options.container),e.getParent||(e.getParent=function(){return Luca(e._parentCid)}),e.container==null&&(console.log(e,d,c),console.error("could not assign container property to component on container "+(c.name||c.cid))),g(e).at(d)["in"](c.componentIndex),e}),this.componentsCreated=!0,a},renderComponents:function(a){return this.debugMode=a!=null?a:"",this.debug("container render components"),b=this,_(this.components).each(function(a){var c;try{return a.trigger("before:attach"),c=b.$(a.container),c.length===0&&(_.isString(a.container)&&1,c.length===0&&(c=this.$(a.container).eq(0))),this.emptyContainerElements===!0&&c.empty(),c.append(a.el),a.trigger("after:attach"),a.render(),a.rendered=!0}catch(d){console.log("Error Rendering Component "+(a.name||a.cid),a),_.isObject(d)&&(console.log(d.message),console.log(d.stack));if(Luca.silenceRenderErrors!=null!=1)throw d}})},firstActivation:function(){var a;return a=this,this.each(function(b,c){var d;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.call(b,"first:activation",b,a),b.previously_activated=!0})},_:function(){return _(this.components)},pluck:function(a){return this._().pluck(a)},invoke:function(a){return this._().invoke(a)},select:function(a){return this._().select(a)},detect:function(a){return this._().detect(attribute)},reject:function(a){return this._().reject(a)},map:function(a){return this._().map(a)},registerComponentEvents:function(a,c){var d,e,f,g,h,i,j,k,l=this;c==null&&(c="on"),b=this,i=a||this.componentEvents||{},k=[];for(h in i){g=i[h],j=h.split(" "),e=j[0],f=j[1];if(!_.isFunction(this[g]))throw console.log("Error registering component event",h,e,f),"Invalid component event definition "+h+". Specified handler is not a method on the container";if(e==="*")k.push(this.eachComponent(function(a){return a.on(f,l[g],b)}));else{d=this.findComponentForEventBinding(e);if(d==null||!Luca.isComponent(d))throw console.log("Error registering component event",h,e,f),"Invalid component event definition: "+e;k.push(d[c](f,this[g],b))}}return k},subContainers:function(){return this.select(function(a){return a.isContainer===!0})},roles:function(){return _(this.allChildren()).pluck("role")},allChildren:function(){var a,b;return a=this.components,b=_(this.subContainers()).map(function(a){return a!=null?typeof a.allChildren=="function"?a.allChildren():void 0:void 0}),_([a,b]).chain().compact().flatten().value()},findComponentForEventBinding:function(a,b){return b==null&&(b=!0),this.findComponentByName(a,b)||this.findComponentByGetter(a,b)||this.findComponentByRole(a,b)},findComponentByGetter:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return(b!=null?b.getter:void 0)===a})},findComponentByRole:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return(b!=null?b.role:void 0)===a||(b!=null?b.type:void 0)===a||(b!=null?b.ctype:void 0)===a})},findComponentByType:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return a===(b.type||b.ctype)})},findComponentByName:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.name===a})},findComponentById:function(a,b){return b==null&&(b=!1),this.findComponent(a,"cid_index",b)},findComponent:function(a,b,c){var d,e,f,g;b==null&&(b="name"),c==null&&(c=!1),this.componentsCreated!==!0&&this.createComponents(),e=(g=this.componentIndex)!=null?g[b][a]:void 0,d=this.components[e];if(d)return d;if(c===!0)return f=_(this.components).detect(function(c){return c!=null?typeof c.findComponent=="function"?c.findComponent(a,b,!0):void 0:void 0}),f!=null?typeof f.findComponent=="function"?f.findComponent(a,b,!0):void 0:void 0},each:function(a){return this.eachComponent(a,!1)},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c,d){var e;a.call(c,c,d);if(b)return c!=null?(e=c.eachComponent)!=null?e.apply(c,[a,b]):void 0:void 0})},indexOf:function(a){var b;return b=_(this.components).pluck("name"),_(b).indexOf(a)},activeComponent:function(){return this.activeItem?this.components[this.activeItem]:this},componentElements:function(){return this.$("[data-luca-parent='"+(this.name||this.cid)+"']")},getComponent:function(a){return this.components[a]},isRootComponent:function(){return this.rootComponent===!0||this.getParent==null},getRootComponent:function(){return this.isRootComponent()?this:this.getParent().getRootComponent()},selectByAttribute:function(a,b,c){var d;return b==null&&(b=void 0),c==null&&(c=!1),d=_(this.components).map(function(d){var e,f;return e=[],f=d[a],(f===b||b==null&&f!=null)&&e.push(d),c===!0&&e.push(typeof d.selectByAttribute=="function"?d.selectByAttribute(a,b,!0):void 0),_.compact(e)}),_.flatten(d)}}),b.register(),Luca.Container.componentRenderer=function(a,b){var c;return c=$(b.container)[b.attachWith||"append"],c(b.render().el)},f=function(){return this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},a=function(a,b){var c,d;return d=[],a.height!=null&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width!=null&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={"class":(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";"),"data-luca-parent":this.name||this.cid},this.customizeContainerEl!=null&&(c=this.customizeContainerEl(c,a,b)),c},c=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return(a!=null?a.getter:void 0)!=null}),_(a).each(function(a){var c;return b[c=a.getter]||(b[c]=function(){return a})})},d=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return(a!=null?a.role:void 0)!=null}),_(a).each(function(a){var c,d;return c=_.str.camelize("get_"+a.role),d=function(){return a},b[c]||(b[c]=_.bind(d,b))})},e=function(){return this.trigger("before:components",this,this.components),this.prepareComponents(),this.trigger("before:create:components",this,this.components),this.createComponents(),this.trigger("before:render:components",this,this.components),this.renderComponents(),this.trigger("after:components",this,this.components),this.skipGetterMethods!==!0&&(c.call(this),d.call(this)),this.registerComponentEvents()},h=function(){return!0},g=function(a){return{at:function(b){return{"in":function(c){a.cid!=null&&(c.cid_index[a.cid]=b),a.role!=null&&(c.role_index[a.role]=b);if(a.name!=null)return c.name_index[a.name]=b}}}}}}.call(this),function(){var a;a=Luca.define("Luca.containers.CardView"),a["extends"]("Luca.Container"),a.aliases("Luca.PageView"),a.defaults({activeCard:0,components:[],hooks:["before:card:switch","after:card:switch"],componentClass:"luca-ui-card",generateComponentElements:!0,initialize:function(a){return this.options=a,this.components||(this.components=this.pages||(this.pages=this.cards)),Luca.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks),this.defer(this.simulateActivationEvent,this).until("after:render")},simulateActivationEvent:function(){var a;a=this.activeComponent();if(a!=null&&this.$el.is(":visible"))return a!=null?a.trigger("activation",this,a,a):void 0},prepareComponents:function(){var a;return(a=Luca.Container.prototype.prepareComponents)!=null&&a.apply(this,arguments),this.componentElements().hide(),this.activeComponentElement().show()},activeComponentElement:function(){return this.componentElements().eq(this.activeCard)},activeComponent:function(){return this.getComponent(this.activeCard)},customizeContainerEl:function(a,b,c){return a.style+=c===this.activeCard?"display:block;":"display:none;",a},atFirst:function(){return this.activeCard===0},atLast:function(){return this.activeCard===this.components.length-1},next:function(){if(this.atLast())return;return this.activate(this.activeCard+1)},previous:function(){if(this.atFirst())return;return this.activate(this.activeCard-1)},cycle:function(){var a;return a=this.atLast()?0:this.activeCard+1,this.activate(a)},find:function(a){return Luca(a)},firstActivation:function(){var a;return(a=this.activeComponent())!=null?a.trigger("first:activation",this,this.activeComponent()):void 0},activate:function(a,b,c){var d,e,f,g=this;b==null&&(b=!1),_.isFunction
4
- (b)&&(b=!1,c=b);if(a===this.activeCard)return;f=this.activeComponent(),e=this.getComponent(a),e||(a=this.indexOf(a),e=this.getComponent(a));if(!e)return;b!==!0&&(this.trigger("before:card:switch",f,e),f!=null&&f.trigger("before:deactivation",this,f,e),e!=null&&e.trigger("before:activation",this,f,e),_.defer(function(){return g.$el.data(g.activeAttribute||"active-card",e.name)})),this.componentElements().hide(),e.previously_activated!==!0&&(e.rendered===!0?e.trigger("first:activation"):e.defer(function(){return e.trigger("first:activation")}).until(e,"after:render"),e.previously_activated=!0),this.activeCard=a,this.activeComponentElement().show(),b!==!0&&(this.trigger("after:card:switch",f,e),f!=null&&f.trigger("deactivation",this,f,e),e!=null&&e.trigger("on:deactivation",this,f,e),e!=null&&e.trigger("activation",this,f,e),e!=null&&e.trigger("on:activation",this,f,e)),d=this,Luca.containers.CardView.activationContext==="current"&&(d=e);if(_.isFunction(c))return c.apply(d,[this,f,e])}}),Luca.containers.CardView.activationContext="current"}.call(this),function(){_.def("Luca.ModalView")["extends"]("Luca.Container")["with"]({closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,className:"luca-ui-container modal",container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")},render:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this}}),_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]()}.call(this),function(){var a,b,c,d;c=Luca.register("Luca.PanelToolbar"),c["extends"]("Luca.View"),c.defines({buttons:[],orientation:"top",autoBindEventHandlers:!0,events:{"click a.btn, click .dropdown-menu li":"clickHandler"},initialize:function(a){var b;this.options=a!=null?a:{},this._super("initialize",this,arguments);if(this.group===!0&&((b=this.buttons)!=null?b.length:void 0)>=0)return this.buttons=[{group:!0,buttons:this.buttons}]},clickHandler:function(a){var b,c,d,e,f;d=e=$(a.target),d.is("i")&&(d=e=$(a.target).parent()),this.selectable===!0&&(e.siblings().removeClass("is-selected"),d.addClass("is-selected"));if(!(b=e.data("eventid")))return;return c=Luca.util.hook(b),f=this.parent||this,_.isFunction(f[c])?f[c].call(this,d,a):f.trigger(b,d,a)},beforeRender:function(){this._super("beforeRender",this,arguments),this.well===!0&&this.$el.addClass("well"),this.selectable===!0&&this.$el.addClass("btn-selectable"),this.$el.addClass("toolbar-"+this.orientation),this.align==="right"&&this.$el.addClass("pull-right");if(this.align==="left")return this.$el.addClass("pull-left")},render:function(){var a,b,c,e;this.$el.empty(),e=d(this.buttons);for(b=0,c=e.length;b<c;b++)a=e[b],this.$el.append(a);return this}}),b=Backbone.View.prototype.make,a=function(a,c){var e,f,g,h,i,j,k,l,m,n,o,p;c==null&&(c=!0);if(a.ctype!=null||a.type!=null){a.className||(a.className=""),a.className+="toolbar-component",n=Luca(a).render();if(Luca.isBackboneView(n))return n.$el}return a.spacer?b("div",{"class":"spacer "+a.spacer}):a.text?b("div",{"class":"toolbar-text"},a.text):(p="btn-group",a.wrapper!=null&&(p+=""+a.wrapper),a.align!=null&&(p+="pull-"+a.align+" align-"+a.align),a.selectable===!0&&(p+="btn-selectable"),a.group!=null&&a.buttons!=null?(h=d(a.buttons,!1),b("div",{"class":p},h)):(l=a.label||(a.label=""),a.eventId||(a.eventId=_.string.dasherize(a.label.toLowerCase())),a.icon&&(_.string.isBlank(l)&&(l=" "),a.white&&(o="icon-white"),l="<i class='"+(o||"")+" icon-"+a.icon+"' /> "+l),f={"class":_.compact(["btn",a.classes,a.className]).join(" "),"data-eventId":a.eventId,title:a.title||a.description},a.color!=null&&(f["class"]+=" btn-"+a.color),a.selected!=null&&(f["class"]+=" is-selected"),a.dropdown&&(l=""+l+" <span class='caret'></span>",f["class"]+=" dropdown-toggle",f["data-toggle"]="dropdown",k=function(){var c,d,e,f;e=a.dropdown,f=[];for(c=0,d=e.length;c<d;c++)j=e[c],_.isObject(j)&&(j=_.values(j).reverse()),m=b("a",{},j[1]),f.push(b("li",{"data-eventId":j[0]},m));return f}(),i=b("ul",{"class":"dropdown-menu"},k)),g=b("a",f,l),e="btn-group",a.align!=null&&(e+=" align-"+a.align),c===!0?b("div",{"class":e},[g,i]):g))},d=function(b,c){var d,e,f,g;b==null&&(b=[]),c==null&&(c=!0),g=[];for(e=0,f=b.length;e<f;e++)d=b[e],g.push(a(d,c));return g}}.call(this),function(){var a;a=Luca.register("Luca.containers.TabView"),a["extends"]("Luca.containers.CardView"),a.triggers("before:select","after:select"),a.publicConfiguration({tab_position:"top",tabVerticalOffset:"50px"}),a.privateConfiguration({additionalClassNames:"tabbable",navClass:"nav-tabs",bodyTemplate:"containers/tab_view",bodyClassName:"tab-content",skipGetterMethods:!0}),a.defines({initialize:function(a){return this.options=a!=null?a:{},this.navStyle==="list"&&(this.navClass="nav-list"),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,b;(b=Luca.containers.CardView.prototype.afterRender)!=null&&b.apply(this,arguments),a=this.tabContainer().attr("id"),this.registerEvent("click #"+a+" li a","tabSelectClickHandler");if(Luca.config.enableBootstrap&&(this.tab_position==="left"||this.tab_position==="right"))return this.tabContainerWrapper().addClass("span2"),this.tabContentWrapper().addClass("span9")},createTabSelectors:function(){return a=this,this.each(function(b,c){var d,e,f,g;b.tabIcon&&(d="<i class='icon-"+b.tabIcon+"'></i>"),e="<a href='#'>"+(d||"")+" "+b.title+"</a>",f=a.make("li",{"class":"tab-selector","data-target":c},e),a.tabContainer().append(f);if(b.navHeading!=null&&((g=a.navHeadings)!=null?!g[b.navHeading]:!void 0))return $(f).before(a.make("li",{"class":"nav-header"},b.navHeading)),a.navHeadings||(a.navHeadings={}),a.navHeadings[b.navHeading]=!0})},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},tabSelectClickHandler:function(a){var b,c,d;return a!=null&&a.preventDefault(),b=c=$(a.target),b=c||(c=this.tabSelectors()[0]),d=c.parent().data("target"),this.select(d)},select:function(a){return a==null&&(a=0),this.trigger("before:select",this),this.activate(a),this.trigger("after:select",this)},componentElements:function(){return this.$(">.tab-content >."+this.componentClass)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return this.$("ul."+this.navClass,this.tabContainerWrapper())},tabSelectors:function(){return this.$("li.tab-selector",this.tabContainer())},bodyTemplateVars:function(){return{cid:this.cid,navClass:this.navClass}}})}.call(this),function(){var a;a=Luca.register("Luca.containers.Viewport"),a["extends"]("Luca.Container"),a.defines({fullscreen:!0,fluid:!1,applyWrapper:!0,initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),Luca.config.enableBoostrap===!0&&this.applyWrapper===!0&&(this.wrapperClass=this.fluid===!0?Luca.config.fluidWrapperClass:Luca.config.wrapperClass),Luca.Container.prototype.initialize.apply(this,arguments);if(this.fullscreen===!0)return this.enableFullscreen()},enableFluid:function(){return this.enableWrapper()},disableFluid:function(){return this.disableWrapper()},enableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().addClass(this.wrapperClass)},disableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().removeClass(this.wrapperClass)},enableFullscreen:function(){return $("html,body").addClass("luca-ui-fullscreen"),this.$el.addClass("fullscreen-enabled")},disableFullscreen:function(){return $("html,body").removeClass("luca-ui-fullscreen"),this.$el.removeClass("fullscreen-enabled")},beforeRender:function(){var a;(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.topNav!=null&&this.renderTopNavigation();if(this.bottomNav!=null)return this.renderBottomNavigation()},height:function(){return this.$el.height()},width:function(){return this.$el.width()},afterRender:function(){var a;(a=Luca.containers.CardView.prototype.after)!=null&&a.apply(this,arguments);if(Luca.config.enableBoostrap===!0&&this.containerClassName)return this.$el.children().wrap('<div class="#{ containerClassName }" />')},renderTopNavigation:function(){var a;if(this.topNav==null)return;return _.isString(this.topNav)&&(this.topNav=Luca.util.lazyComponent(this.topNav)),_.isObject(this.topNav)&&((a=this.topNav).ctype||(a.ctype=this.topNav.type||"nav_bar"),Luca.isBackboneView(this.topNav)||(this.topNav=Luca.util.lazyComponent(this.topNav))),this.topNav.app=this,$("body").prepend(this.topNav.render().el)},renderBottomNavigation:function(){}}),Luca.containers.Viewport.defaultWrapperClass=Luca.config.wrapperClass||"container",Luca.containers.Viewport.fluidWrapperClass=Luca.config.fluidWrapperClass||"container-fluid"}.call(this),function(){}.call(this),function(){var a;a=Luca.register("Luca.CollectionView"),a["extends"]("Luca.Panel"),a.replaces("Luca.components.CollectionView"),a.mixesIn("QueryCollectionBindings","LoadMaskable","Filterable","Paginatable","Sortable"),a.triggers("before:refresh","after:refresh","refresh","empty:results"),a.publicConfiguration({collection:void 0,tagName:"ol",bodyClassName:"collection-ui-panel",itemTagName:"li",itemClassName:"collection-item",itemTemplate:void 0,itemRenderer:void 0,itemProperty:void 0,observeChanges:!1}),a.publicMethods({initialize:function(a){var b,c;this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"refresh");if(this.collection==null&&!this.options.collection)throw console.log("Error on initialize of collection view",this),"Collection Views must specify a collection";if(this.itemTemplate==null&&this.itemRenderer==null&&this.itemProperty==null)throw"Collection Views must specify an item template or item renderer function";_.isString(this.collection)&&(Luca.CollectionManager.get()?this.collection=Luca.CollectionManager.get().getOrCreate(this.collection):console.log("String Collection but no collection manager"));if(!Luca.isBackboneCollection(this.collection))throw console.log("Missing Collection on "+(this.name||this.cid),this,this.collection),"Collection Views must have a valid backbone collection";this.on("data:refresh",this.refresh,this),this.on("collection:reset",this.refresh,this),this.on("collection:remove",this.refresh,this),this.on("collection:add",this.refresh,this),this.observeChanges===!0&&this.on("collection:change",this.refreshModel,this),Luca.Panel.prototype.initialize.apply(this,arguments),b=this;if(((c=this.getCollection())!=null?c.length:void 0)>0)return this.on("after:render",function(){return b.refresh(),b.unbind("after:render",this)})},locateItemElement:function(a){return this.$("."+this.itemClassName+"[data-model-id='"+a+"']")},refresh:function(){var a,b,c,d,e,f,g;e=this.getLocalQuery(),d=this.getQueryOptions(),c=this.getModels(e,d),this.$bodyEl().empty(),this.trigger("before:refresh",c,e,d),c.length===0&&this.trigger("empty:results",e,d),a=0;for(f=0,g=c.length;f<g;f++)b=c[f],this.$append(this.makeItem(b,a++));return this.trigger("after:refresh",c,e,d),this}}),a.privateMethods({attributesForItem:function(a,b){return _.extend({},{"class":this.itemClassName,"data-index":a.index,"data-model-id":a.model.get("id")})},contentForItem:function(a){var b,c;return a==null&&(a={}),this.itemTemplate!=null&&(c=Luca.template(this.itemTemplate))?b=c.call(this,a):this.itemRenderer!=null&&_.isFunction(this.itemRenderer)?b=this.itemRenderer.call(this,a,a.model,a.index):this.itemProperty&&a.model!=null?b=a.model.read(this.itemProperty):""},makeItem:function(a,b){var c,d,e;e=this.prepareItem!=null?this.prepareItem.call(this,a,b):{model:a,index:b},c=this.attributesForItem(e,a),d=this.contentForItem(e);try{return Backbone.View.prototype.make(this.itemTagName,c,d)}catch(f){return console.log("Error generating DOM element for CollectionView",this,a,b)}},refreshModel:function(a){var b;return b=this.collection.indexOf(a),this.locateItemElement(a.get("id")).empty().append(this.contentForItem({model:a,index:b},a)),this.trigger("model:refreshed",b,a)},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)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.SimpleCollectionView"),a["extends"]("Luca.CollectionView"),a.defines({filterable:!1,paginatable:!1,sortable:!1,loadMask:!1})}.call(this),function(){var a;a=Luca.register("Luca.components.GridLayoutView"),a["extends"]("Luca.CollectionView"),a.publicConfiguration({itemsPerRow:3}),a.privateConfiguration({className:"grid-layout-view",tagName:"div",itemTagName:"div"}),a.privateMethods({attributesForItem:function(){var a,b;return a=Luca.CollectionView.prototype.attributesForItem.apply(this,arguments),_.isNumber(this.itemsPerRow)&&this.itemsPerRow>1||(this.itemsPerRow=3),b=parseInt(12/this.itemsPerRow),a["class"]+=" span"+b,a},renderModels:function(a){var b,c,d,e,f,g,h,i;b=0,e=0,f=function(){var f,g,h;h=[];for(f=0,g=a.length;f<g;f++)c=a[f],e++===0&&(d=this.make("div",{"class":"row-fluid"})),$(d).append(this.makeItem(c,b++)),b>0&&b%this.itemsPerRow===0&&(e=0),h.push(d);return h}.call(this),console.log("Appending rows",f),i=[];for(g=0,h=f.length;g<h;g++)d=f[g],i.push(this.$append(d));return i}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.TableView"),a["extends"]("Luca.CollectionView"),a.publicConfiguration({widths:[],columns:[],emptyText:"There are no results to display"}),a.privateConfiguration({additionalClassNames:"table",tagName:"table",bodyTemplate:"table_view",bodyTagName:"tbody",bodyClassName:"table-body",stateful:!0,itemTagName:"tr",observeChanges:!0}),a.privateMethods({lastColumn:function(){return this.columns[this.columns.length-1]},eachColumn:function(a,b){var c,d,e,f,g,h;b==null&&(b=this),d=0,g=this.columns,h=[];for(e=0,f=g.length;e<f;e++)c=g[e],h.push(a.call(b,c,d++,this));return h},itemRenderer:function(a,b){return Luca.components.TableView.rowRenderer.call(this,a,b)},initialize:function(a){var b,c,d,e=this;return this.options=a!=null?a:{},Luca.components.CollectionView.prototype.initialize.apply(this,arguments),c=0,this.columns=function(){var a,e,f,g;f=this.columns,g=[];for(a=0,e=f.length;a<e;a++){b=f[a];if(d=this.widths[c])b.width=d;_.isString(b)&&(b={reader:b}),b.header==null&&(b.header=_.str.titleize(_.str.humanize(b.reader))),c++,g.push(b)}return g}.call(this),this.defer(function(){return Luca.components.TableView.renderHeader.call(e,e.columns,e.$("thead"))}).until("after:render")}}),a.classMethods({renderHeader:function(a,b){var c,d,e,f,g,h,i,j,k,l;f=0,this.$(b).append("<tr></tr>");for(h=0,j=a.length;h<j;h++)d=a[h],c={"data-col-index":f++},d.sortable&&(c["class"]="sortable-toggle",c["data-sortable-sort-by"]=d.sortBy||d.sortable,c["data-sortable-order"]=d.order),e=d.header,d.sortable&&(e="<a class='link'>"+d.header+"</a>"),this.$(b).find("tr").append(Backbone.View.prototype.make("th",c,e));f=0,l=[];for(i=0,k=a.length;i<k;i++){d=a[i];if(d.width==null)continue;g=this.$("th[data-col-index='"+f++ +"']",b),l.push(g.css("width",d.width))}return l},rowRenderer:function(a,b,c){var d,e,f,g,h,i;d=0,h=this.columns,i=[];for(f=0,g=h.length;f<g;f++)e=h[f],i.push(Luca.components.TableView.renderColumn.call(this,e,a,b,d++));return i},renderColumn:function(a,b,c,d){var e;return e=c.read(a.reader),_.isFunction(a.renderer)&&(e=a.renderer.call(this,e,c,a)),Backbone.View.prototype.make("td",{"data-col-index":d},e)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.MultiCollectionView"),a["extends"]("Luca.containers.CardView"),a.mixesIn("QueryCollectionBindings","LoadMaskable","Filterable","Paginatable","Sortable"),a.triggers("before:refresh","after:refresh","refresh","empty:results"),a.private({stateful:{activeView:0},initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},this.components||(this.components=this.views),e=this.components;for(c=0,d=e.length;c<d;c++)b=e[c],Luca.components.MultiCollectionView.validateComponent(b);return Luca.containers.CardView.prototype.initialize.apply(this,arguments),this.on("data:refresh",this.refresh,this),this.on("after:card:switch",this.refresh,this),this.on("after:components",Luca.components.MultiCollectionView.propagateCollectionComponents,this)},relayAfterRefresh:function(a,b,c){return this.trigger("after:refresh",a,b,c)},refresh:function(){var a;return(a=this.activeComponent())!=null?a.refresh():void 0}}),a.classMethods({propagateCollectionComponents:function(){var a,b,c,d,e,f,g=this;b=this,e=this.components,f=[];for(c=0,d=e.length;c<d;c++)a=e[c],a.on("after:refresh",function(a,b,c){return g.debug("collection member after refresh"),g.trigger("after:refresh",a,b,c)}),_.extend(a,{collection:b.getCollection(),getQuery:_.bind(b.getQuery,b),getQueryOptions:_.bind(b.getQueryOptions,b)}),b.prepareQuery!=null?f.push(_.extend(a,{prepareQuery:_.bind(b.prepareQuery,b)})):f.push(void 0);return f},validateComponent:function(a){var b;b=a.type||a.ctype;if(b==="collection"||b==="collection_view"||b==="table"||b==="table_view")return;throw"The MultiCollectionView expects to contain multiple collection views"}}),a.defines({version:3})}.call(this),function(){var a;a=Luca.register("Luca.components.ScrollableTable"),a["extends"]("Luca.components.TableView"),a.replaces("Luca.components.GridView"),a.publicConfiguration({maxHeight:void 0}),a.privateMethods({$scrollableWrapperEl:function(){return this.$el.parent(".scrollable-wrapper")},setMaxHeight:function(){var a;return a=this.$scrollableWrapperEl(),a.css({overflow:"auto","max-height":this.maxHeight})},afterRender:function(){return this.$wrap("scrollable-wrapper"),this.setMaxHeight()}}),a.defines({version:1})}.call(this),function(){var a,b=Array.prototype.slice;a=Luca.register("Luca.Application"),a["extends"]("Luca.containers.Viewport"),a.triggers("controller:change","action:change"),a.publicConfiguration({name:"MyApp",stateful:{},autoBoot:!1,autoStartHistory:"before:render",useCollectionManager:!0,collectionManager:{},collectionManagerClass:"Luca.CollectionManager",plugin:!1,useController:!0,mainControllerContainer:void 0,useKeyHandler:!1,keyEvents:{},components:[{type:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}],createRoleBasedGetters:!1,useSocketManager:!1,socketManagerOptions:{},initialize:function(a){var b,c,d,e=this;this.options=a!=null?a:{},c=this,d=this.name,b=typeof Luca.getApplication=="function"?Luca.getApplication():void 0,Luca.Application.registerInstance(this),Luca.concerns.StateModel.__initializer.call(this),this.setupCollectionManager(),this.setupSocketManager(),Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.useController===!0&&this.setupMainController(),this.defer(function(){return c.render()}).until(this,"ready"),this.setupRouter(),(this.useKeyHandler===!0||this.useKeyRouter===!0)&&this.keyEvents!=null&&this.setupKeyHandler(),this.plugin!==!0&&!b&&(Luca.getApplication=function(a){return a==null?c:Luca.Application.instances[a]});if(this.autoBoot){if(Luca.util.resolve(this.name))throw"Attempting to override window."+this.name+" when it already exists";$(function(){return window[d]=c,c.boot()})}return Luca.trigger("application:available",this)},activeView:function(){var a;return(a=this.activeSubSection())?this.view(a):this.view(this.activeSection())},activeSection:function(){return this.get("active_section")},activeSubSection:function(){return this.get("active_sub_section")},activePages:function(){var a=this;return this.$(".luca-ui-controller").map(function(a,b){return $(b).data("active-section")})},boot:function(){var a,b,c,d,e;this.trigger("ready"),d=[this.collectionManager,this.socket,this.router],e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a!=null?a.trigger("ready"):void 0);return e},collection:function(){return this.collectionManager.getOrCreate.apply(this.collectionManager,arguments)},get:function(a){return this.state.get(a)},set:function(a,b,c){return this.state.set.apply(this.state,arguments)},view:function(a){return Luca.cache(a)},navigate_to:function(a,b){return this.getMainController().navigate_to(a,b)}}),a.privateInterface({keyHandler: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&&_.isFunction(this[d])?(h=this[d])!=null?h.call(this,a,e,d):void 0:this.trigger(d,a,e)},setupControllerBindings:function(){var a,b,c,d=this;return a=this,(b=this.getMainController())!=null&&b.bind("after:card:switch",function(b,c){return d.state.set({active_section:c.name}),a.trigger("controller:change",b.name,c.name)}),(c=this.getMainController())!=null?c.each(function(b){var c;c=b.type||b.ctype;if(c.match(/controller$/))return b.bind("after:card:switch",function(b,c){return d.state.set({active_sub_section:c.name}),a.trigger("action:change",b.name,c.name)})}):void 0},setupMainController:function(){var a,b,c=this;return this.useController===!0&&(b=this.components||[],a={type:"controller",name:"main_controller",role:"main_controller",components:b},this.mainControllerContainer!=null&&_.extend(a,{container:this.mainControllerContainer}),this.components=[a]),this.getMainController=function(){return c.findComponentByRole("main_controller")},this.defer(this.setupControllerBindings,!1).until("after:components")},setupCollectionManager:function(){var a,b,c,d,e;if(this.useCollectionManager!==!0)return;if(this.collectionManager!=null&&((c=this.collectionManager)!=null?c.get:void 0)!=null)return;_.isString(this.collectionManagerClass)&&(this.collectionManagerClass=Luca.util.resolve(this.collectionManagerClass)),a=this.collectionManagerOptions||{},_.isObject(this.collectionManager)&&!_.isFunction((d=this.collectionManager)!=null?d.get:void 0)&&(a=this.collectionManager,this.collectionManager=void 0),_.isString(this.collectionManager)&&(a={name:this.collectionManager}),this.collectionManager=typeof (b=Luca.CollectionManager).get=="function"?b.get(a.name):void 0;if(!_.isFunction((e=this.collectionManager)!=null?e.get:void 0))return a.autoStart=!1,this.collectionManager=new this.collectionManagerClass(a)},setupSocketManager:function(){if(_.isEmpty(this.socketManagerOptions))return;return _.extend(this.socketManagerOptions,{autoStart:!1}),this.socket=new Luca.SocketManager(this.socketManagerOptions)},setupRouter:function(){var a,b,c,d,e,f,g,h,i,j;if(this.router==null&&this.routes==null)return;f=Luca.Router,_.isString(this.router)&&(f=Luca.util.resolve(this.router)),g=f.prototype,g.routes||(g.routes={}),g.app=this;if(_.isObject(this.routes)){h=this.routes;for(e in h)b=h[e],b.match(/\ /)?(i=b.split(" "),d=i[0],a=i[1]):b.match(/\#/)&&(j=b.split("#"),d=j[0],a=j[1]),c=_.uniqueId(d),g[c]=Luca.Application.routeTo(d).action(a),g.routes[e]=c}this.router=new f(g);if(this.router&&this.autoStartHistory)return this.autoStartHistory===!0&&(this.autoStartHistory="before:render"),this.defer(Luca.Application.startHistory,!1).until(this,this.autoStartHistory)},setupKeyHandler:function(){var a,b,c,d,e,f,g;if(!this.keyEvents)return;(c=this.keyEvents).control_meta||(c.control_meta={}),this.keyEvents.meta_control&&_.extend(this.keyEvents.control_meta,this.keyEvents.meta_control),a=_.bind(this.keyHandler,this),f=this.keypressEvents||["keydown"],g=[];for(d=0,e=f.length;d<e;d++)b=f[d],g.push($(document).on(b,a));return g}}),a.classInterface({instances:{},pageHierarchy:function(){var a,b,c;return a=Luca(),c=a.getMainController(),b=function(a){return a.components==null&&a.pages==null?{}:_(a.components||a.pages).reduce(function(a,c){return a[c.name]=c.name,c.navigate_to!=null&&(a[c.name]=b(c)),a},{})},b(c)},registerInstance:function(a){return Luca.Application.instances[a.name]=a},checkForKeymaster:function(){var a;if(typeof window!="undefined"&&window!==null?(a=window.key)!=null?a.noConflict:void 0:void 0)return Luca.key=window.key.noConflict(),Luca.Application.prototype.setupKeyHandler=function(){if(!this.keyEvents)return;return Luca.util.setupKeymaster(this.keyEvents,"all").on(this)}},routeTo:function(){var a,c,d,e,f,g;return e=1<=arguments.length?b.call(arguments,0):[],d=_(e).last(),c=_(e).first(),a=void 0,g=void 0,f=function(){var f,h,i,j,k,l,m,n,o,p;h=1<=arguments.length?b.call(arguments,0):[],l=this.app||Luca(),i=0,e.length===1&&(m=Luca(c))&&(e=m.controllerPath()),p=[];for(n=0,o=e.length;n<o;n++){k=e[n];if(!_.isString(k))continue;j=e[++i],m=Luca(k),k===d&&(a=g!=null&&m[g]!=null?_.bind(m[g],m):m.routeHandler!=null?m.routeHandler:void 0),a||(a=_.isFunction(j)?_.bind(j,m):_.isObject(j)?(f=j.action&&m[f]!=null)?_.bind(m[f],m):void 0:void 0),p.push(l=l.navigate_to(k,function(){return a!=null?a.apply(m,h):void 0}))}return p},f.action=function(a){return g=a,f},f},startHistory:function(){return Backbone.history.start()}}),a.afterDefinition(function(){return Luca.routeHelper=Luca.Application.routeTo,Luca.Application.checkForKeymaster()}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.CollectionLoaderView"),a["extends"]("Luca.View"),a.defines({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.register("Luca.components.Controller"),a["extends"]("Luca.containers.CardView"),a.publicInterface({tracker:"page","default":function(a){return this.navigate_to(this.defaultPage||this.defaultCard,a)},activePage:function(){return this.activeSection()},navigate_to:function(a,b){var c=this;return a||(a=this.defaultCard),this.activate(a,!1,function(a,d,e){var f,g;e.activatedByController===!0?e.trigger("on:controller:reactivation"):(e.trigger("on:controller:reactivation"),e.trigger("on:controller:activation"),e.activatedByController=!0),c.state.set({active_section:e.name}),(f=typeof Luca.getApplication=="function"?Luca.getApplication():void 0)&&f.state.set(c.tracker,e.name),(g=Luca.key)!=null&&g.setScope(e.name);if(_.isFunction(b))return b.call(e)}),this.find(a)}}),a.classMethods({setupComponentKeyEvents:function(){return this._().each(function(a){if(_.isObject(a.keyEvents)&&a.name!=null)return Luca.util.setupKeymaster(a.keyEvents,a.name).on(a)})},controllerPath:function(){var a,b,c;b=this,c=[b.name],a=!1;while(b&&!a)b=typeof b.getParent=="function"?b.getParent():void 0,(b!=null?b.role:void 0)==="main_controller"&&(a=!0),b!=null&&!a&&c.push(b.name);return c.reverse()}}),a.afterDefinition(function(){return Luca.View.prototype.hooks.push("on:controller:activation")}),a.defines({additionalClassNames:"luca-ui-controller",activeAttribute:"active-section",stateful:!0,initialize:function(a){var b;this.options=a,this.defaultCard||(this.defaultCard=this.defaultPage||(this.defaultPage=((b=this.components[0])!=null?b.name:void 0)||0)),this.defaultPage||(this.defaultPage=this.defaultCard),this.defaultState||(this.defaultState={active_section:this.defaultPage}),Luca.containers.CardView.prototype.initialize.apply(this,arguments);if(this.defaultCard==null)throw"Controllers must specify a defaultCard property and/or the first component must have a name";return this._().each(function(a){return a.controllerPath=Luca.components.Controller.controllerPath}),this.on("after:render",this["default"],this),this.on("before:render",Luca.components.Controller.setupComponentKeyEvents,this)},each:function(a){var b=this;return _(this.components).each(function(c){return a.call(b,c)})},activeSection:function(){return this.get("active_section")},pageControllers:function(a){return a==null&&(a=!1),this.controllers.apply(this,arguments)},controllers:function(a){return a==null&&(a=!1),this.select(function(a){var b;return b=a.type||a.ctype,b==="controller"||b==="page_controller"})},availablePages:function(){return this.availableSections.apply(this,arguments)},availableSections:function(){var a,b=this;return a={},a[this.name]=this.sectionNames(),_(this.controllers()).reduce(function(a,b){return a[b.name]=b.sectionNames(),a},a)},pageNames:function(){return this.sectionNames()},sectionNames:function(a){return a==null&&(a=!1),this.pluck("name")}})}.call(this),function(){var a;a=Luca.register("Luca.core.Field"),a["extends"]("Luca.View"),a.triggers("before:validation","after:validation","on:change"),a.publicConfiguration({labelAlign:"top",className:"luca-ui-text-field luca-ui-field",statuses:["warning","error","success"]}),a.publicInterface({disable:function(){return this.getInputElement().attr("disabled",!0)},enable:function(){return this.getInputElement().attr("disabled",!1)},getValue:function(){var a;return this.getParsedValue((a=this.getInputElement())!=null?a.attr("value"):void 0)},setValue:function(a){var b;return(b=this.getInputElement())!=null?b.attr("value",a):void 0},updateState:function(a){var b=this;return _(this.statuses).each(function(a){return b.$el.removeClass(a)}),this.$el.addClass(a)},clearErrors:function(){return this.$el.removeClass("error")},displayErrors:function(a){return this.updateState("error")}}),a.methods({getParsedValue:function(a){if(_.str.isBlank(a))return a;switch(this.valueType){case"integer":return parseInt(a);case"string":return""+a;case"float":return parseFloat(a);default:return a}}}),a.privateConfiguration({isField:!0,template:"fields/text_field"}),a.defines({initialize:function(a){var b;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.input_type||(this.input_type=""),this.helperText||(this.helperText="");if(this.label==null||this.label.length===0)this.label=this.name;return this.required&&((b=this.label)!=null?!b.match(/^\*/):!void 0)&&(this.label||(this.label="*"+this.label)),this.inputStyles||(this.inputStyles=""),this.input_value||(this.input_value=this.value||""),this.disabled&&this.disable(),this.updateState(this.state),this.placeHolder||(this.placeHolder=""),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){Luca.config.enableBoostrap&&this.$el.addClass("control-group");if(this.required)return this.$el.addClass("required")},change_handler:function(a){return this.trigger("on:change",this,a)},getInputElement:function(){return this.input||(this.input=this.$("input").eq(0))}})}.call(this),function(){var a;a=Luca.register("Luca.fields.ButtonField"),a["extends"]("Luca.core.Field"),a.triggers("button:click"),a.publicConfiguration({readOnly:!0,input_value:void 0,input_type:"button",icon_class:void 0,input_name:void 0,white:void 0,buttonClasses:""}),a.privateConfiguration({isButton:!0,template:"fields/button_field",events:{"click input":"click_handler"}}),a.privateInterface({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?
5
- 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_class||(this.input_class=this["class"]||(this["class"]=this.buttonClasses)),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(){var a,b;b=Luca.View.prototype.make,a=Luca.register("Luca.fields.CheckboxArray"),a["extends"]("Luca.core.Field"),a.defines({version:2,template:"fields/checkbox_array",className:"luca-ui-checkbox-array",events:{"click input":"clickHandler"},selectedItems:[],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.concerns.Deferrable),_.bindAll(this,"renderCheckboxes","clickHandler","checkSelected"),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")},afterInitialize:function(a){var b;this.options=a!=null?a:{};try{this.configure_collection()}catch(c){console.log("Error Configuring Collection",this,c.message)}b=this;if(!Luca.isBackboneCollection(this.collection))throw"Checkbox Array Fields must specify a @collection property";return this.collection.length>0?this.renderCheckboxes():this.defer("renderCheckboxes").until(this.collection,"reset")},clickHandler:function(a){var b;b=$(a.target);if(b.prop("checked"))return this.selectedItems.push(b.val());if(_(this.selectedItems).include(b.val()))return this.selectedItems=_(this.selectedItems).without(b.val())},controls:function(){return this.$(".controls")},renderCheckboxes:function(){var a=this;return this.controls().empty(),this.selectedItems=[],this.collection.each(function(c){var d,e,f,g,h;return h=c.get(a.valueField),g=c.get(a.displayField),f=_.uniqueId(""+a.cid+"_checkbox"),e=b("input",{type:"checkbox","class":"array-checkbox",name:a.input_name,value:h,id:f}),d=b("label",{"for":f},e),$(d).append(" "+g),a.controls().append(d)}),this.trigger("checkboxes:rendered",this.checkboxesRendered=!0),this},uncheckAll:function(){return this.allFields().prop("checked",!1)},allFields:function(){return this.controls().find("input[type='checkbox']")},checkSelected:function(a){var b,c,d,e,f;a!=null&&(this.selectedItems=a),this.uncheckAll(),f=this.selectedItems;for(d=0,e=f.length;d<e;d++)c=f[d],b=this.controls().find("input[value='"+c+"']"),b.prop("checked",!0);return this.selectedItems},getValue:function(){var a,b,c,d,e;d=this.allFields(),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],this.$(a).prop("checked")&&e.push(this.$(a).val());return e},setValue:function(a){var b;return this.selectedItems=a,this.checkboxesRendered===!0?this.checkSelected(a):(b=this,this.defer(function(){return b.checkSelected(a)}).until("checkboxes:rendered"))},getValues:function(){return this.getValue()},setValues:function(a){return this.setValue(a)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.CheckboxField"),a["extends"]("Luca.core.Field"),a.triggers("checked","unchecked"),a.publicConfiguration({send_blanks:!0,input_value:1}),a.privateConfiguration({template:"fields/checkbox_field",events:{"change input":"change_handler"}}),a.privateInterface({change_handler:function(a){var b,c;return b=c=$(a.target),b.is(":checked")?this.trigger("checked"):this.trigger("unchecked"),this.trigger("on:change",this,a,b.is(":checked"))},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),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name)}}),a.publicInterface({setValue:function(a){return this.getInputElement().attr("checked",a)},getValue:function(){return this.getInputElement().is(":checked")}}),a.defines({version:1})}.call(this),function(){var a;a=Luca.register("Luca.fields.FileUploadField"),a["extends"]("Luca.core.Field"),a.defines({version:1,template:"fields/file_upload_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),this.helperText||(this.helperText="")}})}.call(this),function(){var a;a=Luca.register("Luca.fields.HiddenField"),a["extends"]("Luca.core.Field"),a.defines({template:"fields/hidden_field",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(){var a;a=Luca.register("Luca.components.LabelField"),a["extends"]("Luca.core.Field"),a.defines({formatter:function(a){return a||(a=this.getValue()),_.str.titleize(a)},setValue:function(a){return this.trigger("change",a,this.getValue()),this.getInputElement().attr("value",a),this.$(".value").html(this.formatter(a))}})}.call(this),function(){var a;a=Luca.register("Luca.fields.SelectField"),a["extends"]("Luca.core.Field"),a.triggers("after:select","on:change"),a.publicConfiguration({allowMultiple:!1,includeBlank:!0,blankValue:"",blankText:"Select One",maxDisplayLength:0,retainValue:void 0,label:void 0}),a.privateConfiguration({template:"fields/select_field",events:{"change select":"change_handler"}}),a.publicMethods({setValue:function(a){return this.currentValue=a,Luca.core.Field.prototype.setValue.apply(this,arguments)},getValue:function(){var a,b,c=this;return a=(b=this.getInputElement())!=null?b.val():void 0,this.allowMultiple?_.map(a,function(a){return c.getParsedValue(a)}):this.getParsedValue(a)}}),a.privateMethods({initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.concerns.Deferrable),_.bindAll(this,"change_handler"),_.isArray(this.collection)&&(this.collection={data:this.collection}),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.valueField==="id"&&(this.valueType||(this.valueType=Luca.config.idAttributeType)),this.label||(this.label=this.name);if(this.retainValue==null)return this.retainValue=!0},afterInitialize:function(){var a,b,c;if((a=this.collection)!=null?a.data:void 0)this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.sortOptionsBy||(this.sortOptionsBy=this.displayField),this.parseData();try{this.configure_collection(this.setAsDeferrable)}catch(d){console.log("Error Configuring Collection",this,d.message)}return(b=this.collection)!=null&&b.bind("before:fetch",this.beforeFetch,this),(c=this.collection)!=null?c.bind("reset",this.populateOptions,this):void 0},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]||b[0],c):b})},getInputElement:function(){return this.input||(this.input=this.$("select").eq(0))},afterRender:function(){var a,b,c;return((a=this.collection)!=null?(b=a.models)!=null?b.length:void 0:void 0)>0?this.populateOptions():(c=this.collection)!=null?c.trigger("reset"):void 0},beforeFetch:function(){return this.resetOptions()},change_handler:function(a){return this.trigger("on:change",this,a)},resetOptions:function(){this.getInputElement().html("");if(this.allowMultiple)return this.getInputElement().attr({multiple:!0});if(this.includeBlank)return this.getInputElement().append("<option value='"+this.blankValue+"'>"+this.blankText+"</option>")},populateOptions:function(){var a,b,c,d,e,f,g,h,i,j=this;this.resetOptions();if(((i=this.collection)!=null?i.length:void 0)>0){this.sortOptionsBy!=null?c=this.collection.sortBy(function(a){return a.read!=null?a.read(j.sortOptionsBy):a.get(j.sortOptionsBy)}):c=this.collection.models;for(g=0,h=c.length;g<h;g++)b=c[g],f=(typeof b.read=="function"?b.read(this.valueField):void 0)||b.get(this.valueField),a=(typeof b.read=="function"?b.read(this.displayField):void 0)||b.get(this.displayField),this.maxDisplayLength&&this.maxDisplayLength>0&&(a=_.str.truncate(a,this.maxDisplayLength)),this.selected&&f===this.selected&&(e="selected"),d="<option "+e+" value='"+f+"'>"+a+"</option>",this.getInputElement().append(d)}return this.trigger("after:populate:options",this),this.setValue(this.currentValue)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.fields.TextAreaField"),a["extends"]("Luca.core.Field"),a.defines({autoBindEventHandlers:!0,events:{"blur textarea":"blur_handler","focus textarea":"focus_handler"},template:"fields/text_area_field",height:"200px",width:"90%",keyEventThrottle:300,initialize:function(a){this.options=a!=null?a:{},this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=""),this.inputStyles||(this.inputStyles="height:"+this.height+";width:"+this.width),this.placeHolder||(this.placeHolder=""),Luca.core.Field.prototype.initialize.apply(this,arguments);if(this.enableKeyEvents===!0)return this.keyup_handler=_.debounce(this.keyup_handler,this.keyEventThrottle||10),console.log("Registering Key Events"),this.registerEvent("keyup textarea","keyup_handler"),this.registerEvent("keydown textarea","keyup_handler")},setValue:function(a){return $(this.field()).val(a)},getValue:function(){return $(this.field()).val()},field:function(){return this.input=this.$("textarea")},keyup_handler:function(a){return this.trigger("on:change",this,a),this.trigger("on:keyup",this,a)},blur_handler:function(a){return this.trigger("on:blur",this,a)},focus_handler:function(a){return this.trigger("on:focus",this,a)},change_handler:function(a){return this.trigger("on:change",this,a)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.TextField"),a["extends"]("Luca.core.Field"),a.defines({_events:{"blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",autoBindEventHandlers:!0,send_blanks:!0,keyEventThrottle:300,initialize:function(a){return this.options=a!=null?a:{},this.enableKeyEvents&&(this.keyEventThrottle&&(this.keyup_handler=_.debounce(this.keyup_handler,this.keyEventThrottle)),this.registerEvent("keyup input","keyup_handler")),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=this.value||""),this.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend),this.append&&(this.$el.addClass("input-append"),this.addOn=this.append),this.placeHolder||(this.placeHolder=""),Luca.core.Field.prototype.initialize.apply(this,arguments)},keyup_handler:function(a){return this.trigger("on:change",this,a),this.trigger("on:keyup",this,a)},blur_handler:function(a){return this.trigger("on:blur",this,a)},focus_handler:function(a){return this.trigger("on:focus",this,a)},change_handler:function(a){return this.trigger("on:change",this,a)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.TypeAheadField"),a["extends"]("Luca.fields.TextField"),a.defines({getSource:function(){return Luca.util.read(this.source)||[]},matcher:function(a){return!0},beforeRender:function(){return Luca.fields.TextField.prototype.beforeRender.apply(this,arguments),this.getInputElement().attr("data-provide","typeahead")},afterRender:function(){return Luca.fields.TextField.prototype.afterRender.apply(this,arguments),this.getInputElement().typeahead({matcher:this.matcher,source:this.getSource()})}})}.call(this),function(){var a;a=Luca.register("Luca.components.FormView"),a["extends"]("Luca.Container"),a.mixesIn("LoadMaskable","FormModelBindings"),a.triggers("before:submit","before:reset","before:load","before:load:new","before:load:existing","after:submit","after:reset","after:load","after:load:new","after:load:existing","after:submit:success","after:submit:fatal_error","after:submit:error","state:change:dirty"),a.publicConfiguration({trackDirtyState:!1,trackModelChanges:!1,labelAlign:void 0,fieldLayoutClass:void 0,legend:"",toolbar:!0,toolbarConfig:void 0,defaultToolbar:"Luca.components.FormView.defaultToolbar",loadMask:!0,well:!1,searchForm:!1,horizontalForm:!1,inlineForm:!1,includeBlankValues:void 0}),a.privateConfiguration({tagName:"form",_events:{"click .submit-button":"submitHandler","click .reset-button":"resetHandler"},bodyClassName:"form-view-body",stateful:{dirty:!1,currentModel:void 0}}),a.privateMethods({initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},c=this,this.loadMask==null&&(this.loadMask=Luca.config.enableBoostrap),Luca.Container.prototype.initialize.apply(this,arguments),this.components||(this.components=this.fields),_.bindAll(this,"submitHandler","resetHandler","renderToolbars"),e=this._events;for(b in e)d=e[b],this.registerEvent(b,d);return this.trackDirtyState===!0&&this.on("after:components",function(){var a,b,d,e,f;e=this.getFields(),f=[];for(b=0,d=e.length;b<d;b++)a=e[b],f.push(a.on("on:change",this.onFieldChange,c));return f},c),this.setupHooks(this.hooks),this.applyStyleClasses(),Luca.components.FormView.setupToolbar.call(this)},onFieldChange:function(a,b){return this.trigger("field:change",a,b),this.state.set("dirty",!0)},getDefaultToolbar:function(){var a;return a=this.toolbarConfig||this.defaultToolbar,Luca.util.resolve(Luca.util.read(a))},applyStyleClasses:function(){Luca.config.enableBoostrap&&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,d;b=c=$(a!=null?a.target:void 0);if(this.beforeReset!=null){d=this.beforeReset();if(d===!1)return}return this.reset(),this.trigger("after:reset",this)},submitHandler:function(a){var b;if(this.beforeSubmit!=null){b=this.beforeSubmit();if(b===!1)return}else this.trigger("before:submit",this);this.loadMask===!0&&this.trigger("enable:loadmask",this);if(this.hasModel())return this.submit()},afterComponents:function(){var a,b;return(b=Luca.Container.prototype.afterComponents)!=null&&b.apply(this,arguments),a=this,this.eachField(function(b){var c=this;return b.getForm=function(){return a},b.getModel=function(){return a.currentModel()}})},eachField:function(a){return _(this.getFields()).map(a)},getField:function(a){var b;return b=_(this.getFields("name",a)).first(),b!=null?b:_(this.getFields("input_name",a)).first()},getFields:function(a,b){var c;return c=this.selectByAttribute("isField",!0,!0),a!=null&&b!=null&&(c=_(c).select(function(c){var d;return d=c[a],_.isFunction(d)&&(d=d.call(c)),d===b})),c},loadModel:function(a){var b,c,d,e;d=this,c=this.getFields(),this.state.set("dirty",!1),this.trigger("before:load",this,a),a&&((e=a.beforeFormLoad)!=null&&e.apply(a,this),b="before:load:"+(a.isNew()?"new":"existing"),this.trigger(b,this,a)),this.state.set("currentModel",a),this.setValues(a||{},{silent:!0}),this.trigger("after:load",this,a);if(a)return this.trigger("after:load:"+(a.isNew()?"new":"existing"),this,a)},reset:function(){return this.loadModel(this.state.get("currentModel"))},clear:function(){var a=this;return this.state.set("currentModel",typeof this.defaultModel=="function"?this.defaultModel():void 0),_(this.getFields()).each(function(b){try{return b.setValue("")}catch(c){return console.log("Error Clearing",a,b)}})},isDirty:function(){return!!this.state.get("dirty")},setValues:function(a,b){var c,d=this;b==null&&(b={}),a||(a=this.currentModel()),c=this.getFields(),_(c).each(function(b){var c,d;c=b.input_name||b.name;if(a!=null?a[c]:void 0)d=Luca.util.read(a[c]);!d&&Luca.isBackboneModel(a)&&(d=a.get(c));if(b.readOnly!==!0)return b!=null?b.setValue(d):void 0});if(b.silent!=null!=1)return this.applyFormValuesToModel()},getValues:function(a){var b,c=this;return a==null&&(a={}),a.reject_blank==null&&(a.reject_blank=!0),a.skip_buttons==null&&(a.skip_buttons=!0),a.blanks===!1&&(a.reject_blank=!0),b=_(this.getFields()).inject(function(b,d){var e,f,g,h,i;h=d.getValue(),f=d.input_name||d.name,i=!!_.str.isBlank(h)||!!_.isUndefined(h),e=!a.reject_blank&&!d.send_blanks;if(d.includeBlank===!0||c.includeBlankValues===!0)e=!0;return a.debug&&console.log(""+f+" Options",a,"Value",h,"Value Is Blank?",i,"Allow Blanks?",e),a.skip_buttons&&d.isButton?g=!0:(i&&e===!1&&(g=!0),d.input_name==="id"&&i===!0&&(g=!0)),a.debug&&console.log("Skip is true on "+f),g!==!0&&(b[f]=h),b},a.defaults||{}),b},removeErrors:function(){var a,b,c,d,e;this.$(".alert.alert-error").remove(),this.$el.removeClass("error"),d=this.getFields(),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.clearErrors());return e},displayErrors:function(a){var b,c,d,e,f,g,h;e=!1,h=this.getFields();for(f=0,g=h.length;f<g;f++){b=h[f];for(d in a){c=a[d];if(d!==b.input_name)continue;b.displayErrors(c),e=!0}}if(e)return this.$el.addClass("error")},displayValidationErrorsMessage:function(){return this.errorMessage("Please fix the fields with errors")},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){var d;this.trigger("after:submit",this,a,b),this.trigger("after:submit:fatal_error",this,a,b);try{d=$.parseJSON(b.responseText);if(!d.success&&d.errors!=null)return this.displayValidationErrorsMessage(),this.displayErrors(d.errors)}catch(e){}},submit:function(a,b){var c;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.removeErrors(),this.applyFormValuesToModel();if(!a)return;return(c=this.currentModel())!=null?c.save(this.currentModel().toJSON(),b):void 0},hasModel:function(){return this.currentModel()!=null},currentModel:function(a){return a==null&&(a={}),(a===!0||(a!=null?a.refresh:void 0)===!0)&&this.applyFormValuesToModel(),this.state.get("currentModel")},applyFormValuesToModel:function(a){var b;return(b=this.currentModel())!=null?b.set(this.getValues(),a):void 0},setLegend:function(a){return this.legend=a,$("fieldset legend",this.el).first().html(this.legend)},flash:function(a){return this.$(".toolbar-container.top").length>0?this.$(".toolbar-container.top").after(a):this.$bodyEl().prepend(a)},successFlashDelay:1500,successMessage:function(a){var b=this;return this.$(".alert.alert-success").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-success",message:a})),_.delay(function(){return b.$(".alert.alert-success").fadeOut()},this.successFlashDelay||0)},errorMessage:function(a){return this.$(".alert.alert-error").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-error",message:a}))}}),a.classInterface({setupToolbar:function(){if(this.toolbar!==!1&&!this.topToolbar&&!this.bottomToolbar){if(this.toolbar==="both"||this.toolbar==="top")this.topToolbar=_.clone(this.getDefaultToolbar());if(this.toolbar!=="top")return this.bottomToolbar=_.clone(this.getDefaultToolbar())}},defaultToolbar:{buttons:[{icon:"remove-sign",label:"Reset",eventId:"click:reset",className:"reset-button",align:"right"},{icon:"ok-sign",white:!0,label:"Save Changes",eventId:"click:submit",color:"success",className:"submit-button",align:"right"}]}}),a.defines({version:2})}.call(this),function(){var a;a=Luca.register("Luca.components.LoadMask"),a["extends"]("Luca.View"),a.defines({className:"luca-ui-load-mask",bodyTemplate:"components/load_mask"})}.call(this),function(){var a;a=Luca.register("Luca.components.NavBar"),a["extends"]("Luca.View"),a.publicConfiguration({fixed:!0,position:"top",fluid:void 0,brand:"Luca.js",template:void 0}),a.privateConfiguration({className:"navbar",bodyTemplate:"nav_bar",bodyClassName:"luca-ui-navbar-body",beforeRender:function(){var a;return this.fixed&&this.$el.addClass("navbar-fixed-"+this.position),this.inverse===!0&&this.$el.addClass("navbar-inverse"),this.brand!=null&&(this.$(".brand").attr("href",this.homeLink||"#"),this.$(".brand").html(this.brand)),this.template&&this.navContainer().html(Luca.template(this.template,this)),this.fluid||((a=Luca.getApplication())!=null?a.fluid:void 0)?this.content().addClass(Luca.config.fluidWrapperClass):this.content().addClass(Luca.config.wrapperClass)},render:function(){return this},navContainer:function(){return this.$(".luca-ui-navbar-body .nav-collapse")},content:function(){return this.$(".luca-ui-navbar-body").eq(0)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.Page"),a["extends"]("Luca.Container"),a.privateMethods({initialize:function(a){return this.options=a!=null?a:{},this.assignComponentsToRegions(),this.bodyTemplate=this.options.layout||this.layout,Luca.Container.prototype.initialize.apply(this,arguments)},assignComponentsToRegions:function(){var a,b,c,d;return this.components||(this.components=[]),a=function(){var a,e;a=this.regions,e=[];for(d in a)c=a[d],_.isString(c)&&(b=Luca.registry.lookup(c))?c={component:c}:_.isString(c)&&Luca.template(c)&&(c={bodyTemplate:c}),e.push(_.extend(c,{container:"[data-region='"+d+"']"}));return e}.call(this),this.components=a}}),a.publicConfiguration({layout:void 0,regions:{}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.PageController"),a["extends"]("Luca.components.Controller"),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.PaginationControl"),a["extends"]("Luca.View"),a.defines({template:"components/pagination",stateful:!0,stateChangeEvents:{numberOfPages:"onPageCountChange"},autoBindEventHandlers:!0,events:{"click a[data-page-number]":"selectPage","click a.next":"nextPage","click a.prev":"previousPage"},onPageCountChange:function(){return this.updateWithPageCount(this.get("numberOfPages"))},limit:function(){var a;return parseInt(this.get("limit")||((a=this.collection)!=null?a.length:void 0))},page:function(){return parseInt(this.get("page")||1)},nextPage:function(){if(!this.nextEnabled())return;return this.set("page",this.page()+1)},previousPage:function(){if(!this.previousEnabled())return;return this.set("page",this.page()-1)},selectPage:function(a){var b,c;return b=c=this.$(a.target),b.is("a.page")||(b=c=c.closest("a.page")),c.siblings().removeClass("is-selected"),b.addClass("is-selected"),this.setPage(c.data("page-number"))},setPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.set("page",a,b)},setLimit:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.set("limit",a,b)},pageButtonContainer:function(){return this.$(".group")},previousEnabled:function(){return this.page()>1},nextEnabled:function(){return this.page()<this.totalPages()},previousButton:function(){return this.$("a.page.prev")},nextButton:function(){return this.$("a.page.next")},pageButtons:function(){return this.$("a[data-page-number]",this.pageButtonContainer())},updateWithPageCount:function(a,b){var c,d=this;return this.pageCount=a,b==null&&(b=[]),c=b.length,this.pageButtonContainer().empty(),_(this.pageCount).times(function(a){var b,c;return c=a+1,b=d.make("a",{"data-page-number":c,"class":"page"},c),d.pageButtonContainer().append(b)}),this.toggleNavigationButtons(),this.selectActivePageButton(),this},toggleNavigationButtons:function(){this.$("a.next, a.prev").addClass("disabled"),this.nextEnabled()&&this.nextButton().removeClass("disabled");if(this.previousEnabled())return this.previousButton().removeClass("disabled")},selectActivePageButton:function(){return this.activePageButton().addClass("is-selected")},activePageButton:function(){return this.pageButtons().filter("[data-page-number='"+this.page()+"']")},totalPages:function(){return this.pageCount},totalItems:function(){var a;return parseInt(((a=this.collection)!=null?a.length:void 0)||0)},itemsPerPage:function(a,b){return b==null&&(b={}),a!=null&&this.set("limit",a,b),parseInt(this.get("limit"))}})}.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(){var a;a=Luca.register("Luca.Router"),a["extends"]("Backbone.Router"),a.defines({routes:{"":"default"},initialize:function(a){var b,c=this;return this.options=a,_.extend(this,this.options),this.routeHandlers=_(this.routes).values(),_(this.routeHandlers).each(function(a){return c.bind("route:"+a,function(){return c.trigger.apply(c,["change:navigation",a].concat(_(arguments).flatten()))})}),(b=Backbone.Router.initialize)!=null?b.apply(this,arguments):void 0},navigate:function(a,b){return b==null&&(b=!1),Backbone.Router.prototype.navigate.apply(this,arguments),this.buildPathFrom(Backbone.history.getFragment())},buildPathFrom:function(a){var b=this;return _(this.routes).each(function(c,d){var e,f;f=b._routeToRegExp(d);if(f.test(a))return e=b._extractParameters(f,a),b.trigger.apply(b,["change:navigation",c].concat(e))})}})}.call(this),function(){}.call(this),function(){}.call(this);
1
+ (function(){}).call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/bootstrap_form_controls"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="btn-group form-actions">\n <a class="btn btn-primary submit-button">\n <i class="icon icon-ok icon-white"></i>\n Save Changes\n </a>\n <a class="btn reset-button cancel-button">\n <i class="icon icon-remove"></i>\n Cancel\n </a>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/collection_loader_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div id="progress-modal" class="modal" 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">Initializing...</div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/form_alert"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="',className,'">\n <a class="close" href="#" data-dismiss="alert">x</a>\n ',message,"\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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 class="luca-ui-g-view scrollable-table" width="100%" cellpadding=0 cellspacing=0>\n <thead class="fixed"></thead>\n <tbody class="scrollable"></tbody>\n <tfoot></tfoot>\n </table>\n </div>\n <div class="luca-ui-g-view-header"></div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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 empty-text-wrapper">\n <p>',text,"</p>\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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:0%"></div>\n </div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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">\n <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">\n <span class="icon-bar"></span>\n <span class="icon-bar"></span>\n <span class="icon-bar"></span>\n </button>\n\n <a class="brand" href="#">Set @brand</a>\n \n <div class="nav-collapse collapse">\n <ul class="nav">\n <li class="active">\n <a href="#">Home</a>\n </li>\n </ul>\n </div>\n </div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/pagination"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="pagination">\n <a class="btn previous">\n <i class="icon icon-chevron-left"></i>\n </a>\n <div class="pagination-group">\n </div>\n <a class="btn next">\n <i class="icon icon-chevron-right"></i>\n </a>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/components/table_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<thead></thead>\n<tbody class="table-body"></tbody>\n<tfoot></tfoot>\n<caption></caption>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/containers/basic"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div id="',id,'" class="',classes,'" style="',style,'"></div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/containers/tab_selector_container"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{}){__p.push('<div id="',cid,'-tab-selector" class="tab-selector-container">\n <ul id="',cid,'-tabs-nav" class="nav nav-tabs">\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(){this.JST||(this.JST={}),this.JST["luca/templates/containers/tab_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<ul id="',cid,'-tabs-selector" class="nav nav-tabs"></ul>\n<div id="',cid,'-tab-view-content" class="tab-content"></div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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(){this.JST||(this.JST={}),this.JST["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 style="',inputStyles,'" class="btn ',input_class,'" value="',input_value,'" type="',input_type,'" id="<%= input_id" />\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["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 ',input_value,"\n "),__p.push("\n</a>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_array"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="control-group">\n <label for="',input_id,'"><%= label =>\n <div class="controls"><div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_array_item"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n <input id="',input_id,'" type="checkbox" name="',input_name,'" value="',value,'" />\n</label>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/checkbox_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n <input type="checkbox" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n</label>\n\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(){this.JST||(this.JST={}),this.JST["luca/templates/fields/file_upload_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n <input type="file" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n</label>\n\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(){this.JST||(this.JST={}),this.JST["luca/templates/fields/hidden_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(' <input type="hidden" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/select_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n</label>\n<div class="controls">\n <select name="',input_name,'" value="',input_value,'" style="',inputStyles,'" ></select>\n '),helperText&&__p.push('\n <p class="helper-text help-block">\n ',helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/text_area_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n</label>\n<div class="controls">\n <textarea placeholder="',placeHolder,'" name="',input_name,'" style="',inputStyles,'" >',input_value,"</textarea>\n "),helperText&&__p.push('\n <p class="helper-text help-block">\n ',helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca/templates/fields/text_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),(typeof label!="undefined"&&typeof hideLabel!="undefined"&&!hideLabel||typeof hideLabel=="undefined")&&__p.push('\n<label class="control-label" for="',input_id,'">',label,"</label>\n"),__p.push('\n\n<div class="controls">\n'),typeof addOn!="undefined"&&__p.push('\n <span class="add-on">',addOn,"</span>\n"),__p.push('\n<input type="text" placeholder="',placeHolder,'" name="',input_name,'" style="',inputStyles,'" value="',input_value,'" />\n'),helperText&&__p.push('\n<p class="helper-text help-block">\n ',helperText,"\n</p>\n"),__p.push("\n\n</div>\n");return __p.join("")}}.call(this),function(){var a,b,c=[].slice;b=function(){var a,b,d,e,f;d=arguments[0],a=2<=arguments.length?c.call(arguments,1):[];if(arguments.length===0)return(f=_(Luca.Application.instances).values())!=null?f[0]:void 0;if(_.isString(d)&&(e=Luca.cache(d)))return e;if(_.isString(d)&&(e=Luca.find(d)))return e;if(_.isString(d)&&(e=Luca.registry.find(d)))return e;if(d instanceof jQuery&&(e=Luca.find(d)))return e;if(_.isObject(d)&&d.ctype!=null)return Luca.util.lazyComponent(d);if(_.isFunction(b=_(a).last()))return b()},(window||global).Luca=function(){return b.apply(this,arguments)},Luca.VERSION="0.9.91",_.extend(Luca,{core:{},collections:{},containers:{},components:{},models:{},concerns:{},util:{},fields:{},registry:{},options:{},config:{},logger:function(a){return function(){var b;return b=1<=arguments.length?c.call(arguments,0):[],b.unshift(a),console.log(this,b)}},getHelper:function(){return function(){return b.apply(this,arguments)}}}),_.extend(Luca,Backbone.Events),Luca.setupCollectionSpace=function(a){var b,c;return a==null&&(a={}),b=a.baseParams,c=a.modelBootstrap,b!=null?Luca.Collection.baseParams(b):Luca.warn("You should remember to set the base params for Luca.Collection class. You can do this by defining a property or function on Luca.config.baseParams"),c!=null?Luca.Collection.bootstrap(c):Luca.warn("You should remember to set the model bootstrap location for Luca.Collection. You can do this by defining a property or function on Luca.config.modelBootstrap")},Luca.initialize=function(a,b){var c,d;return b==null&&(b={}),Luca.namespace=a.toLowerCase(),c=Luca.util.resolve(a,window||global)||{},_.defaults(c,{views:{},collections:{},models:{},components:{},lib:{},util:{},concerns:{},register:function(){return Luca.register.apply(this,arguments)},onReady:function(){return Luca.onReady.apply(this,arguments)},getApplication:function(){var a;return(a=Luca.getApplication)!=null?a.apply(this,arguments):void 0},getCollectionManager:function(){var a;return(a=Luca.CollectionManager.get)!=null?a.apply(this,arguments):void 0},route:Luca.routeHelper}),d={},d[a]=_.defaults(Luca.getHelper(),c),_.extend(Luca.config,b),_.extend(window||global,d),Luca.lastNamespace=a,Luca.concern.namespace(""+a+".concerns"),Luca.registry.namespace(""+a+".views"),Luca.Collection.namespace(""+a+".collections"),Luca.on("ready",function(){return Luca.setupCollectionSpace(b)})},Luca.onReady=function(a){return Luca.define.close(),Luca.trigger("ready"),$(function(){return a.apply(this,arguments)})},Luca.find=function(a){return Luca($(a).data("luca-id"))},Luca.supportsEvents=Luca.supportsBackboneEvents=function(a){return Luca.isComponent(a)||_.isFunction(a!=null?a.trigger:void 0)||_.isFunction(a!=null?a.bind:void 0)},Luca.isComponent=function(a){return Luca.isBackboneModel(a)||Luca.isBackboneView(a)||Luca.isBackboneCollection(a)},Luca.isComponentPrototype=function(a){return Luca.isViewPrototype(a)||Luca.isModelPrototype(a)||Luca.isCollectionPrototype(a)},Luca.isBackboneModel=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.set:void 0)&&_.isFunction(a!=null?a.get:void 0)&&_.isObject(a!=null?a.attributes:void 0)},Luca.isBackboneView=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.render:void 0)&&!_.isUndefined(a!=null?a.el:void 0)},Luca.isBackboneCollection=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.fetch:void 0)&&_.isFunction(a!=null?a.reset:void 0)},Luca.isViewPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&a.prototype.make!=null&&a.prototype.$!=null&&a.prototype.render!=null},Luca.isModelPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&(typeof a.prototype=="function"?a.prototype(a.prototype.save!=null&&a.prototype.changedAttributes!=null):void 0)},Luca.isCollectionPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&!Luca.isModelPrototype(a)&&a.prototype.reset!=null&&a.prototype.select!=null&&a.prototype.reject!=null},Luca.inheritanceChain=function(a){return Luca.parentClasses(a)},Luca.parentClasses=function(a){var b,c,d;return b=[],_.isString(a)&&(a=Luca.util.resolve(a)),c=typeof a.componentMetaData=="function"?a.componentMetaData():void 0,c||(c=typeof (d=a.prototype).componentMetaData=="function"?d.componentMetaData():void 0),b=(c!=null?c.classHierarchy():void 0)||[a.displayName||a.prototype.displayName]},Luca.parentClass=function(a,b){var c,d,e,f,g;return b==null&&(b=!0),_.isString(a)&&(a=Luca.util.resolve(a)),c=typeof a.componentMetaData=="function"?(e=a.componentMetaData())!=null?e.meta["super class name"]:void 0:void 0,c||(c=typeof (d=a.prototype).componentMetaData=="function"?(f=d.componentMetaData())!=null?f.meta["super class name"]:void 0:void 0),c||a.displayName||((g=a.prototype)!=null?g.displayName:void 0),b?Luca.util.resolve(c):c},a={module:function(a,b){_.extend(a,b);if(a.included&&_(a.included).isFunction())return a.included.apply(a)},"delete":function(a,b){var c;return c=a[b],delete a[b],c},idle:function(a,b){var c;return b==null&&(b=1e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleShort:function(a,b){var c;return b==null&&(b=100),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleMedium:function(a,b){var c;return b==null&&(b=2e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleLong:function(a,b){var c;return b==null&&(b=5e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}}},_.mixin(a)}.call(this),function(){Luca.config.maintainStyleHierarchy=!0,Luca.config.maintainClassHierarchy=!0,Luca.config.autoApplyClassHierarchyAsCssClasses=!0,Luca.config.idAttributeType="integer",Luca.config.apiSortByParameter="sortBy",Luca.config.apiPageParameter="page",Luca.config.apiLimitParameter="limit",Luca.autoRegister=Luca.config.autoRegister=!0,Luca.developmentMode=Luca.config.developmentMode=!1,Luca.enableGlobalObserver=Luca.config.enableGlobalObserver=!1,Luca.config.enableBoostrap=Luca.config.enableBootstrap=!0,Luca.config.fluidWrapperClass="container-fluid",Luca.config.wrapperClass="container",Luca.config.enhancedViewProperties=!0,Luca.keys=Luca.config.keys={ENTER:13,ESCAPE:27,KEYLEFT:37,KEYUP:38,KEYRIGHT:39,KEYDOWN:40,SPACEBAR:32,FORWARDSLASH:191,TAB:9},Luca.config.toolbarContainerClass="toolbar-container",Luca.keyMap=Luca.config.keyMap=_(Luca.keys).inject(function(a,b,c){return a[b]=c.toLowerCase(),a},{}),Luca.config.showWarnings=!0,Luca.config.default_socket_port=9292}.call(this),function(){var currentNamespace,__slice=[].slice;Luca.util.resolve=function(a,b){var c;if(!_.isString(a))return a;try{b||(b=window||global),c=_(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)}catch(d){throw console.log("Error resolving",a,b),d}return c},Luca.util.nestedValue=Luca.util.resolve,Luca.util.argumentsLogger=function(a){return function(){return console.log(""+a+" "+(typeof this.identifier=="function"?this.identifier():void 0),arguments)}},Luca.util.read=function(){var a,b;return b=arguments[0],a=2<=arguments.length?__slice.call(arguments,1):[],_.isFunction(b)?b.apply(this,a):b},Luca.util.readAll=function(a){var b,c,d;a==null&&(a={}),c={};for(b in a)d=a[b],c[b]=Luca.util.read(d);return c},Luca.util.classify=function(a){return a==null&&(a=""),_.string.camelize(_.string.capitalize(a))},Luca.util.hook=function(a){var b,c,d;return a==null&&(a=""),c=a.split(":"),d=c.shift(),c=_(c).map(function(a){return _.string.capitalize(a)}),b=d+c.join("")},Luca.util.toCssClass=function(){var a,b,c,d,e;return a=arguments[0],b=2<=arguments.length?__slice.call(arguments,1):[],d=a.split("."),e=function(){var a,e,f;f=[];for(a=0,e=d.length;a<e;a++){c=d[a];if(_(b).indexOf(c)!==-1)continue;c=_.str.underscored(c),c=c.replace(/_/g,"-"),f.push(c)}return f}(),e.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)},Luca.util.make=function(a,b,c){return a==null&&(a="div"),b==null&&(b={}),c==null&&(c=""),Luca.View.prototype.make.apply(this,arguments)},Luca.util.list=function(a,b,c){var d,e,f,g;b==null&&(b={}),d=c?"ol":"ul",d=Luca.util.make(d,b);if(_.isArray(a))for(f=0,g=a.length;f<g;f++)e=a[f],$(d).append(Luca.util.make("li",{},e));return d.outerHTML},Luca.util.label=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="label"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)},Luca.util.badge=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="badge"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)},Luca.util.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=this[d])!=null?a.apply(this,arguments):void 0};if(a!=null?a.match(/once:/):void 0)c=_.once(c);return b.on(a,c,b)})},Luca.util.setupHooksAdvanced=function(a){var b=this;return a||(a=this.hooks),_(a).each(function(a){var c,d,e,f,g,h,i;f=b[Luca.util.hook(a)],_.isArray(f)||(f=[f]),i=[];for(g=0,h=f.length;g<h;g++){d=f[g],e=_.isString(d)?b[d]:void 0,_.isFunction(d)&&(e=d),c=function(){var a;return(a=this[e])!=null?a.apply(this,arguments):void 0};if(a!=null?a.match(/once:/):void 0)c=_.once(c);i.push(b.on(a,c,b))}return i})},Luca.util.rejectBlanks=function(a){var b,c,d;c={};for(b in a)d=a[b],_.isBlank(d)!==!0&&(c[b]=d);return c},Luca.util.enableDropdowns=function(a){var b;return a==null&&(a=".dropdown-toggle"),typeof (b=$(a)).dropdown=="function"?b.dropdown():void 0}}.call(this),function(){var a=[].slice;Luca.stats={},Luca.stats.reset=function(){return Luca.__stats={}},Luca.stats.increment=function(a){var b;return Luca.__stats||(Luca.__stats={}),(b=Luca.__stats)[a]||(b[a]=1),Luca.__stats[a]=Luca.__stats[a]+1,Luca.__stats[a]},Luca.stats.report=function(){var a,b,c,d;console.log("Stats..."),c=Luca.__stats,d=[];for(a in c)b=c[a],d.push(console.log(a,b));return d},Luca.warn=function(){var b;b=1<=arguments.length?a.call(arguments,0):[];if(Luca.config.showWarnings!==!0)return;return Luca.isComponent(this)&&b.unshift(this.identifier()),b.unshift("Warning:"),console.log.apply(console,b)},Luca.log=function(){var b;return b=1<=arguments.length?a.call(arguments,0):[],Luca.isComponent(this)&&b.unshift(this.identifier()),console.log.apply(console,b)}}.call(this),function(){Luca.util.deprecateComponent=function(a,b){var c,d;c=_.template(""+a+" has been renamed to "+b+". Please update your definitions."),(d=Luca.registry.componentAliases)[b]||(d[b]=[]),Luca.registry.componentAliases[b].push(a);if(a!==b)return Luca.registry.deprecatedComponents[a]={message:c({previous:a,newName:b}),newName:b}},Luca.util.checkDeprecationStatusOf=function(a){var b;return(b=Luca.registry.deprecatedComponents[a])?(Luca.log(b.message),b.newName):a}}.call(this),function(){Luca.util.setupKeymaster=Luca.util.setupKeyBindings=function(a,b){b==null&&(b="all");if(!_.isFunction(Luca.key))throw"Keymaster library has not been included.";return{on:function(c){var d,e,f;c.on("before:remove",function(){var a;return(a=Luca.key)!=null?a.deleteScope(b):void 0}),f=[];for(e in a)d=a[e],_.isString(d)&&_.isFunction(c[d])&&(d=c[d]),_.isFunction(d)?(d=_.bind(d,c),f.push(Luca.key(e,b,d))):f.push(void 0);return f}}}}.call(this),function(){}.call(this),function(){Luca.concern=function(a){var b,c;return b=_(Luca.concern.namespaces).detect(function(b){var c;return((c=Luca.util.resolve(b))!=null?c[a]:void 0)!=null}),b||(b="Luca.concerns"),c=Luca.util.resolve(b)[a],c==null&&console.log("Could not find "+a+" in ",Luca.concern.namespaces),c},Luca.concern.namespaces=["Luca.concerns"],Luca.concern.namespace=function(a){return Luca.concern.namespaces.push(a),Luca.concern.namespaces=_(Luca.concern.namespaces).uniq()},Luca.concern.setup=function(){var a,b,c,d,e,f,g,h;if(((d=this.concerns)!=null?d.length:void 0)>0){e=this.concerns,h=[];for(b=0,c=e.length;b<c;b++)a=e[b],h.push((f=Luca.concern(a))!=null?(g=f.__initializer)!=null?g.call(this,this,a):void 0:void 0);return h}},Luca.decorate=function(a){var b,c,d;try{_.isString(a)&&(c=a,b=Luca.util.resolve(c)),_.isFunction(a)&&(b=a),d=b.prototype,c=c||b.displayName,c||(c=d.displayName)}catch(e){throw console.log(e.message),console.log(e.stack),console.log("Error calling Luca.decorate on ",b,d,c),e}return{"with":function(a){var e,f,g,h,i,j,k;g=Luca.concern(a),g.__displayName||(g.__displayName=a),h=_(g).chain().keys().select(function(a){return(""+a).match(/^__/)||a==="classMethods"}),i=_(g).omit(h.value()),_.extend(d,i);if(g.classMethods!=null){k=g.classMethods;for(f in k)e=k[f],b[f]=_.bind(e,b)}return g!=null&&typeof g.__included=="function"&&g.__included(c,b,g),j=d._superClass().prototype.concerns,d.concerns||(d.concerns=[]),d.concerns.push(a),d.concerns=d.concerns.concat(j),d.concerns=_(d.concerns).chain().uniq().compact().value(),d}}}}.call(this),function(){var ComponentDefinition,cd,__slice=[].slice;ComponentDefinition=function(){function ComponentDefinition(a,b){var c;this.autoRegister=b!=null?b:!0,this.namespace=Luca.util.namespace(),this.componentId=this.componentName=a,this.superClassName="Luca.View",this.properties||(this.properties={}),this._classProperties||(this._classProperties={}),a.match(/\./)&&(this.namespaced=!0,c=a.split("."),this.componentId=c.pop(),this.namespace=c.join("."),Luca.registry.addNamespace(c.join("."))),Luca.define.__definitions.push(this)}return ComponentDefinition.create=function(a,b){return b==null&&(b=Luca.config.autoRegister),new ComponentDefinition(a,b)},ComponentDefinition.prototype.isValid=function(){return _.isObject(this.properties)?Luca.util.resolve(this.superClassName)==null?!1:this.componentName==null?!1:!0:!1},ComponentDefinition.prototype.isDefined=function(){return this.defined===!0},ComponentDefinition.prototype.isOpen=function(){return!!this.isValid()&&!this.isDefined()},ComponentDefinition.prototype.meta=function(a,b){var c,d;return d=this.namespace+"."+this.componentId,d=d.replace(/^\./,""),c=Luca.registry.addMetaData(d,a,b),this.properties.componentMetaData=function(){return Luca.registry.getMetaDataFor(d)}},ComponentDefinition.prototype["in"]=function(a){return this.namespace=a,this},ComponentDefinition.prototype.from=function(a){return this.superClassName=a,this},ComponentDefinition.prototype["extends"]=function(a){return this.superClassName=a,this},ComponentDefinition.prototype.extend=function(a){return this.superClassName=a,this},ComponentDefinition.prototype.aliases=function(){var a;return a=1<=arguments.length?__slice.call(arguments,0):[],this._aliases=a,this.meta("aliases",this._aliases),this},ComponentDefinition.prototype.replaces=function(){var a,b,c,d,e;b=1<=arguments.length?__slice.call(arguments,0):[],this._aliases||(this._aliases=[]),e=[];for(c=0,d=b.length;c<d;c++)a=b[c],this._aliases.push(a),e.push(Luca.util.deprecateComponent(a,this.componentName));return e},ComponentDefinition.prototype.triggers=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{hooks:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.hooks.push(a);return this.properties.hooks=_.uniq(this.properties.hooks),this.meta("hooks",this.properties.hooks),this},ComponentDefinition.prototype.includes=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{include:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.include.push(a);return this.properties.include=_.uniq(this.properties.include),this.meta("includes",this.properties.include),this},ComponentDefinition.prototype.mixesIn=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{concerns:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.concerns.push(a);return this.properties.concerns=_.uniq(this.properties.concerns),this.meta("concerns",this.properties.concerns),this},ComponentDefinition.prototype.contains=function(){var a;return a=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties,{components:[]}),this.properties.components=a,this},ComponentDefinition.prototype.validatesConfigurationWith=function(a){return a==null&&(a={}),this.meta("configuration validations",a),this.properties.validatable=!0,this},ComponentDefinition.prototype.beforeDefinition=function(a){return this._classProperties.beforeDefinition=a,this},ComponentDefinition.prototype.afterDefinition=function(a){return this._classProperties.afterDefinition=a,this},ComponentDefinition.prototype.classConfiguration=function(a){return a==null&&(a={}),this.meta("class configuration",_.keys(a)),_.defaults(this._classProperties||(this._classProperties={}),a),this},ComponentDefinition.prototype.configuration=function(a){return a==null&&(a={}),this.meta("public configuration",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.publicConfiguration=function(a){return a==null&&(a={}),this.meta("public configuration",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.privateConfiguration=function(a){return a==null&&(a={}),this.meta("private configuration",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.classInterface=function(a){return a==null&&(a={}),this.meta("class interface",_.keys(a)),_.defaults(this._classProperties||(this._classProperties={}),a),this},ComponentDefinition.prototype.methods=function(a){return a==null&&(a={}),this.meta("public interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype["public"]=function(a){return a==null&&(a={}),this.meta("public interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.publicInterface=function(a){return a==null&&(a={}),this.meta("public interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype["private"]=function(a){return a==null&&(a={}),this.meta("private interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.privateInterface=function(a){return a==null&&(a={}),this.meta("private interface",_.keys(a)),_.defaults(this.properties||(this.properties={}),a),this},ComponentDefinition.prototype.definePrototype=function(properties){var alias,at,componentType,definition,include,type_alias,_base,_i,_j,_len,_len1,_ref,_ref1,_ref2,_ref3,_ref4;properties==null&&(properties={}),_.defaults(this.properties||(this.properties={}),properties),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)),this.meta("super class name",this.superClassName),this.meta("display name",this.componentName),this.properties.displayName=this.componentName,this.properties.componentMetaData=function(){return Luca.registry.getMetaDataFor(this.displayName)},(_ref=this._classProperties)!=null&&typeof _ref.beforeDefinition=="function"&&_ref.beforeDefinition(this),definition=at[this.componentId]=Luca.extend(this.superClassName,this.componentName,this.properties);if(_.isArray((_ref1=this.properties)!=null?_ref1.include:void 0)){_ref2=this.properties.include;for(_i=0,_len=_ref2.length;_i<_len;_i++)include=_ref2[_i],_.isString(include)&&(include=Luca.util.resolve(include)),include==null&&console.log("Attempt to include module failed. "+include+" not defined."),_.extend(definition.prototype,include)}if(this._aliases!=null){_ref3=this._aliases;for(_j=0,_len1=_ref3.length;_j<_len1;_j++)alias=_ref3[_j],eval(""+alias+" = definition;")}return this.autoRegister===!0&&(Luca.isViewPrototype(definition)&&(componentType="view"),Luca.isCollectionPrototype(definition)&&((_base=Luca.Collection).namespaces||(_base.namespaces=[]),Luca.Collection.namespaces.push(this.namespace),componentType="collection"),Luca.isModelPrototype(definition)&&(componentType="model"),type_alias=_.string.underscored(this.componentId),Luca.registerComponent(type_alias,this.componentName,componentType)),this.defined=!0,_.isEmpty(this._classProperties)||_.extend(definition,this._classProperties),definition!=null&&(_ref4=definition.afterDefinition)!=null&&_ref4.call(definition,this),definition},ComponentDefinition}(),cd=ComponentDefinition.prototype,cd.concerns=cd.behavesAs=cd.uses=cd.mixesIn,cd.register=cd.defines=cd.defaults=cd.exports=cd.defaultProperties=cd.definePrototype,cd.defaultsTo=cd.enhance=cd["with"]=cd.definePrototype,cd.publicMethods=cd.publicInterface,cd.privateMethods=cd.privateInterface,cd.classProperites=cd.classMethods=cd.classInterface,_.extend(Luca.define=ComponentDefinition.create,{__definitions:[],incomplete:function(){return _(Luca.define.__definitions).select(function(a){return a.isOpen()})},close:function(){var a,b,c,d;d=Luca.define.incomplete();for(b=0,c=d.length;b<c;b++)a=d[b],a.isValid()&&a.register();return Luca.define.__definitions.length=0},findDefinition:function(a){return _(Luca.define.__definitions).detect(function(b){return b.componentName===a})}}),Luca.register=function(a){return new ComponentDefinition(a,!0)},_.mixin({def:Luca.define}),Luca.extend=function(a,b,c){var d,e,f,g,h,i,j;c==null&&(c={}),a=Luca.util.checkDeprecationStatusOf(a),f=Luca.util.resolve(a,window||global);if(!_.isFunction(f!=null?f.extend:void 0))throw"Error defining "+
2
+ b+". "+a+" is not a valid component to extend from";g=Luca.registry.getMetaDataFor(a),g.descendants().push(b),c.displayName=b,c._superClass=function(){return f.displayName||(f.displayName=a),f},c._super=function(a,b,c){var d;return b==null&&(b=this),c==null&&(c=[]),(d=this._superClass().prototype[a])!=null?d.apply(b,c):void 0},d=f.extend(c);if(_.isArray(c!=null?c.include:void 0)){j=c.include;for(h=0,i=j.length;h<i;h++)e=j[h],_.isString(e)&&(e=Luca.util.resolve(e)),_.extend(d.prototype,e)}return d}}.call(this),function(){var a,b;b={classes:{},model_classes:{},collection_classes:{},namespaces:["Luca.containers","Luca.components"]},a={cid_index:{},name_index:{}},Luca.config.defaultComponentClass=Luca.defaultComponentClass="Luca.View",Luca.config.defaultComponentType=Luca.defaultComponentType="view",Luca.registry.deprecatedComponents={},Luca.registry.componentAliases={},Luca.registry.typeAliases={grid:"grid_view",form:"form_view",text:"text_field",button:"button_field",select:"select_field",card:"card_view",paged:"card_view",wizard:"card_view",collection:"collection_view",list:"collection_view",multi:"collection_multi_view",table:"table_view"},Luca.registerComponent=function(a,c,d){var e,f,g,h,i,j;d==null&&(d="view"),Luca.trigger("component:registered",a,c);switch(d){case"model":e=b.model_classes[a],b.model_classes[a]=c;break;case"collection":e=b.collection_classes[a],b.collection_classes[a]=c;break;case"view":e=b.classes[a],b.classes[a]=c;break;default:e=b.classes[a],b.classes[a]=c}if(e!=null&&Luca.config.developmentMode===!0){g=Luca.registry.findInstancesByClassName(c);if(g.length>0){j=[];for(h=0,i=g.length;h<i;h++)f=g[h],j.push(typeof f.refreshEventBindings=="function"?f.refreshEventBindings():void 0);return j}}},Luca.registry.addNamespace=Luca.registry.namespace=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,h;if(c=Luca.registry.typeAliases[a])a=c;return d=b.classes[a],d!=null?d:(e=Luca.util.classify(a),g=Luca.registry.namespaces(),f=(h=_(g).chain().map(function(a){return a[e]}).compact().value())!=null?h[0]:void 0)},Luca.registry.instances=function(){return _(a.cid_index).values()},Luca.registry.findInstancesByClass=function(a){return Luca.registry.findInstancesByClassName(a.displayName)},Luca.registry.findInstancesByClassName=function(a){var b;return _.isString(a)||(a=a.displayName),b=Luca.registry.instances(),_(b).select(function(b){var c,d;return c=b.displayName===a,b.displayName===a||(typeof b._superClass=="function"?(d=b._superClass())!=null?d.displayName:void 0:void 0)===a})},Luca.registry.classes=function(a){return a==null&&(a=!1),_(_.extend({},b.classes,b.model_classes,b.collection_classes)).map(function(b,c){return a?b:{className:b,ctype:c}})},Luca.registry.find=function(a){return Luca.util.resolve(a)||Luca.define.findDefinition(a)},Luca.remove=Luca.registry.removeInstance=function(b){if(b==null)return;return _(a.name_index)["delete"](b),_(a.cid_index)["delete"](b)},Luca.cache=Luca.registry.cacheInstance=function(b,c){var d;if(b==null)return;return(c!=null?c.doNotCache:void 0)===!0?c:(c!=null&&(a.cid_index[b]=c),c=a.cid_index[b],(c!=null?c.component_name:void 0)!=null?a.name_index[c.component_name]=c.cid:(c!=null?c.name:void 0)!=null&&(a.name_index[c.name]=c.cid),c!=null?c:(d=a.name_index[b],a.cid_index[d]))}}.call(this),function(){var a;Luca.registry.componentMetaData={},Luca.registry.getMetaDataFor=function(b){return new a(Luca.registry.componentMetaData[b])},Luca.registry.addMetaData=function(a,b,c){var d,e;return d=(e=Luca.registry.componentMetaData)[a]||(e[a]={}),d[b]=_(c).clone(),d},a=function(){function a(a){this.meta=a!=null?a:{},_.defaults(this.meta,{"super class name":"","display name":"",descendants:[],aliases:[],"public interface":[],"public configuration":[],"private interface":[],"private configuration":[],"class configuration":[],"class interface":[]})}return a.prototype.className=function(){return this.meta["display name"]},a.prototype.superClass=function(){return Luca.util.resolve(this.meta["super class name"])},a.prototype.componentDefinition=function(){return Luca.registry.find(this.meta["display name"])},a.prototype.componentPrototype=function(){var a;return(a=this.componentDefinition())!=null?a.prototype:void 0},a.prototype.prototypeFunctions=function(){return _.functions(this.componentPrototype())},a.prototype.classAttributes=function(){return _.uniq(this.classInterface().concat(this.classConfiguration()))},a.prototype.publicAttributes=function(){return _.uniq(this.publicInterface().concat(this.publicConfiguration()))},a.prototype.privateAttributes=function(){return _.uniq(this.privateInterface().concat(this.privateConfiguration()))},a.prototype.classMethods=function(){var a;return a=_.functions(this.componentDefinition()),_(a).intersection(this.classAttributes())},a.prototype.publicMethods=function(){return _(this.prototypeFunctions()).intersection(this.publicAttributes())},a.prototype.privateMethods=function(){return _(this.prototypeFunctions()).intersection(this.privateAttributes())},a.prototype.classConfiguration=function(){return this.meta["class configuration"]},a.prototype.publicConfiguration=function(){return this.meta["public configuration"]},a.prototype.privateConfiguration=function(){return this.meta["private configuration"]},a.prototype.classInterface=function(){return this.meta["class interface"]},a.prototype.publicInterface=function(){return this.meta["public interface"]},a.prototype.privateInterface=function(){return this.meta["private interface"]},a.prototype.triggers=function(){return this.meta.hooks},a.prototype.hooks=function(){return this.meta.hooks},a.prototype.descendants=function(){return this.meta.descendants},a.prototype.styleHierarchy=function(){var a;return a=_(this.classHierarchy()).map(function(a){return Luca.util.toCssClass(a,"views","components","core","fields","containers")}),_(a).without("backbone-view","luca-view")},a.prototype.classHierarchy=function(){var a,b,c,d,e,f;a=[this.meta["display name"],this.meta["super class name"]],b=(c=this.superClass())!=null?(d=c.prototype)!=null?typeof d.componentMetaData=="function"?d.componentMetaData():void 0:void 0:void 0;while(!!b)a=a.concat(b!=null?b.classHierarchy():void 0),b=(e=b.superClass())!=null?(f=e.prototype)!=null?typeof f.componentMetaData=="function"?f.componentMetaData():void 0:void 0:void 0;return _(a).uniq()},a}()}.call(this),function(){}.call(this),function(){var a=[].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(){var a=[].slice;Luca.DeferredBindingProxy=function(){function a(a,b,c){var d;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=_.bind(function(){return _.defer(d)},this.object):this.fn=_.bind(d,this.object),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.EventRelayer=function(){function b(a){a==null&&(a={}),this.target=a.target,this.events=a.events,this.prefix=a.prefix,this.source=a.source,this.events.length>0&&this.target&&this.source&&this.setup(),this}return b.prototype.prefixedBy=function(a){return this.prefix=a!=null?a:"",this},b.prototype.from=function(a){return this.source=a,this},b.prototype.to=function(a){return this.target=a,this},b.prototype.setup=function(b){var c,d,e,f,g,h;this.target=b,d=this.prefix,b=this.target,g=this.events,h=[];for(e=0,f=g.length;e<f;e++)c=g[e],console.log("Binding to ",c,d,this.target.name,this.source.name),h.push(this.source.on(c,function(){var b,e;return b=1<=arguments.length?a.call(arguments,0):[],e=_([d,c]).compact().join(":"),b.unshift(e),this.trigger.apply(this,b)},b));return h},b}(),Luca.Events={relays:function(){var b;return b=1<=arguments.length?a.call(arguments,0):[],new Luca.EventRelayer({relayer:this,events:b})},defer:function(a,b){return b==null&&(b=!0),new Luca.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.EventsExt={waitUntil:function(a,b){return this.waitFor.call(this,a,b)},waitFor:function(b,c){var d,e;return e=this,d={on:function(a){return a.waitFor.call(a,b,c)},and:function(){var d,f,g,h,i;f=1<=arguments.length?a.call(arguments,0):[],i=[];for(g=0,h=f.length;g<h;g++)d=f[g],d=_.isFunction(d)?d:e[d],i.push(e.once(b,d,c));return i},andThen:function(){return e.and.apply(e,arguments)}}},relayEvent:function(b){var c=this;return{on:function(){var d;return d=1<=arguments.length?a.call(arguments,0):[],{to:function(){var e,f,g,h,i,j;g=1<=arguments.length?a.call(arguments,0):[],j=[];for(h=0,i=g.length;h<i;h++)f=g[h],j.push(function(){var c,g,h,i=this;h=[];for(c=0,g=d.length;c<g;c++)e=d[c],h.push(e.on(b,function(){var c;return c=1<=arguments.length?a.call(arguments,0):[],c.unshift(b),f.trigger.apply(f,c)}));return h}.call(c));return j}}}}}}}.call(this),function(){var a,b;Luca.templates||(Luca.templates={});if(window.JST!=null)for(b in JST){a=JST[b];if(!b.match(/^luca\/templates\//))continue;Luca.templates[b.replace("luca/templates/","")]=a,_(JST)["delete"](b)}Luca.template=function(a,b,c){var d,e,f,g,h;window.JST||(window.JST={});if(_.isFunction(a))return a(b);e=(h=Luca.templates)!=null?h[a]:void 0,d=typeof JST!="undefined"&&JST!==null?JST[a]:void 0,e==null&&d==null&&(f=new RegExp(""+a+"$"),e=_(Luca.templates).detect(function(a,b){return f.exec(b)}),d=_(JST).detect(function(a,b){return f.exec(b)}));if(!e&&!d)throw"Could not find template named "+a;return g=e||d,g instanceof Hogan.template&&b!=null?g.render(b,c):b!=null?g(b):g},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}}.call(this),function(){Luca.concerns.ApplicationEventBindings={__initializer:function(){var a,b,c,d,e,f,g,h;if(_.isEmpty(this.applicationEvents))return;a=this.app;if(_.isString(a)||_.isUndefined(a))a=(f=Luca.Application)!=null?typeof f.get=="function"?f.get(a):void 0:void 0;if(!Luca.supportsEvents(a))throw"Error binding to the application object on "+(this.name||this.cid);g=this.applicationEvents,h=[];for(c=d=0,e=g.length;d<e;c=++d){b=g[c],_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"Error registering application event "+b+" on "+(this.name||this.cid);h.push(a.on(b,c,this))}return h}}}.call(this),function(){var a,b=[].slice;Luca.concerns.CollectionEventBindings={__initializer:function(){var b=this;this.defer(function(){return Luca.concerns.CollectionEventBindings.__setup.call(b)}).until("after:initialize");if(this.collectionEventBindingsSetup!==!0)return Luca.isBackboneCollection(this.collection)&&(this.collection.on("reset",a("collection:reset"),this),this.collection.on("add",a("collection:add"),this),this.collection.on("remove",a("collection:remove"),this),this.collection.on("change",a("collection:change"),this),this.collection.on("before:fetch",a("collection:fetch"),this)),this.collectionEventBindingsSetup=!0},__setup:function(){var a,b,c,d,e,f,g,h,i;if(_.isEmpty(this.collectionEvents))return;e=this.collectionManager||Luca.CollectionManager.get(),g=this.collectionEvents,i=[];for(f in g){c=g[f],h=f.split(" "),d=h[0],b=h[1],a=e.getOrCreate(d);if(!a)throw"Could not find collection specified by "+d;_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"invalid collectionEvents configuration";try{i.push(a.on(b,c,this))}catch(j){throw console.log("Error Binding To Collection in registerCollectionEvents",this),j}}return i}},a=function(a){return function(){var c;return c=1<=arguments.length?b.call(arguments,0):[],c.unshift(a),this.trigger.apply(this,c)}}}.call(this),function(){Luca.concerns.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)),_.isObject(this.collection)&&!Luca.isBackboneCollection(this.collection)&&(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.concerns.DevelopmentToolHelpers={refreshEventBindings:function(){var a,b,c,d,e,f,g,h,i;f=this,console.log("Refreshing Event Bindings ON ",f.name||f.cid),f.undelegateEvents(),b=(typeof f.definitionClass=="function"?(g=f.definitionClass())!=null?g.events:void 0:void 0)||f.events;for(d in b){c=b[d];if(_.isString(c)!==!0)continue;a=typeof f.definitionClass=="function"?(h=f.definitionClass())!=null?h[c]:void 0:void 0,console.log("Rebinding dom event",d,c,a),f.events[d]=a}return f.state!=null&&f.stateful!=null&&(Luca.concerns.StateModel.__setupModelBindings.call(f,"off"),Luca.concerns.StateModel.__setupModelBindings.call(f,"on")),f.isContainer===!0&&!_.isEmpty(f.componentEvents)&&(Luca.Container.prototype.registerComponentEvents.call(this,void 0,"off"),e=typeof f.definitionClass=="function"?(i=f.definitionClass())!=null?i.componentEvents:void 0:void 0,Luca.Container.prototype.registerComponentEvents.call(this,e,"on")),f.delegateEvents()}}}.call(this),function(){Luca.concerns.DomHelpers={__initializer:function(){var a,b,c,d,e,f,g,h,i,j,k,l;b=_(this.additionalClassNames||[]).clone(),this.wrapperClass!=null&&this.$wrap(this.wrapperClass),_.isString(b)&&(b=b.split(" ")),(f=this.gridSpan||this.span)&&b.push("span"+f),(e=this.gridOffset||this.offset)&&b.push("offset"+e),(this.gridRowFluid||this.rowFluid)&&b.push("row-fluid"),(this.gridRow||this.row)&&b.push("row");if(b==null)return;for(g=0,i=b.length;g<i;g++)a=b[g],this.$el.addClass(a);if(Luca.config.autoApplyClassHierarchyAsCssClasses===!0){c=(typeof this.componentMetaData=="function"?(k=this.componentMetaData())!=null?k.styleHierarchy():void 0:void 0)||[],l=[];for(h=0,j=c.length;h<j;h++)d=c[h],d!=="luca-view"&&d!=="backbone-view"&&l.push(this.$el.addClass(d));return l}},$wrap:function(a){return _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a,"data-wrapper":!0})),this.$el.wrap(a)},$wrapper:function(){return this.$el.parent('[data-wrapper="true"]')},$template:function(a,b){var c;b==null&&(b={});try{return this.$el.html(Luca.template(a,b))}catch(d){return console.log("Error in $template: "+a+" "+(((c=typeof this.identifier==="function"?this.identifier():void 0)!=null?c:this.name)||this.cid))}},$html:function(a){return a!=null?this.$el.html(a):this.$el.html()},$append:function(a){return this.$el.append(a)},$attach:function(){return this.$container().append(this.el)},$bodyEl:function(){return this.$el},$container:function(){return $(this.container)}}}.call(this),function(){Luca.concerns.EnhancedProperties={__initializer:function(){if(Luca.config.enhancedViewProperties!==!0)return;_.isString(this.collection)&&Luca.CollectionManager.get()&&(this.collection=Luca.CollectionManager.get().getOrCreate(this.collection)),this.template!=null&&this.$template(this.template,this);if(_.isString(this.collectionManager))return this.collectionManager=Luca.CollectionManager.get(this.collectionManager)}}}.call(this),function(){var a,b={}.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};Luca.concerns.Filterable={classMethods:{prepare:function(){var a,b,c;this.trigger("data:refresh");if(!this.isRemote())return;return a=_.clone(this.getRemoteQuery()),b=_.clone(this.getQueryOptions()),c=this.prepareRemoteFilter(a,b),this.collection.applyFilter(c,{remote:!0})}},__included:function(a,b){return _.extend(Luca.Collection.prototype,{__filters:{}})},__initializer:function(a,b){var c,d,e,f=this;if(this.filterable===!1)return;this.filterable===!0&&(this.filterable={}),Luca.isBackboneCollection(this.collection)||(this.collection=typeof (d=Luca.CollectionManager).get=="function"?(e=d.get())!=null?e.getOrCreate(this.collection):void 0:void 0);if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Filterable due to no collection being present on "+(this.name||this.cid)),this.debug("Collection",this.collection);return}return this.getCollection||(this.getCollection=function(){return this.collection}),c=this.getFilterState(),this.querySources||(this.querySources=[]),this.optionsSources||(this.optionsSources=[]),this.query||(this.query={}),this.queryOptions||(this.queryOptions={}),this.querySources.push(function(a){return a==null&&(a={}),f.getFilterState().toQuery()}),this.optionsSources.push(function(a){return a==null&&(a={}),f.getFilterState().toOptions()}),c.on("change",function(){return f.trigger("filter:change")}),this.on("filter:change",Luca.concerns.Filterable.classMethods.prepare,this),b},prepareRemoteFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b.limit!=null&&(a[Luca.config.apiLimitParameter]=b.limit),b.page!=null&&(a[Luca.config.apiPageParameter]=b.page),b.sortBy!=null&&(a[Luca.config.apiSortByParameter]=b.sortBy),a},isRemote:function(){var a;if(this.getQueryOptions().remote===!0)return!0;if(this.remoteFilterFallback===!0&&((a=this.getCollection())!=null?a.length:void 0)===0)return!0},getFilterState:function(){var b,c,d,e,f,g;return g=b=this.filterable||{},c=g.options,d=g.query,!_.isEmpty(b)&&_.isEmpty(d)&&_.isEmpty(c)&&_.extend(c,_(b).pluck("sortBy","page","limit")),(e=this.collection.__filters)[f=this.cid]||(e[f]=new a({query:d||{},options:c||{}}))},setSortBy:function(a,b){return b==null&&(b={}),this.getFilterState().setOption("sortBy",a,b)},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b=_.defaults(b,this.getQueryOptions()),this.getFilterState().clear({silent:!0}),this.getFilterState().set({query:a,options:b},b)}},a=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return c(b,a),b.prototype.defaults={options:{},query:{}},b.prototype.setOption=function(a,b,c){var d;return d={},d[a]=b,this.set("options",_.extend(this.toOptions(),d),c)},b.prototype.setQueryOption=function(a,b,c){var d;return d={},d[a]=b,this.set("query",_.extend(this.toQuery(),d),c)},b.prototype.toOptions=function(){return _.clone(this.toJSON().options)},b.prototype.toQuery=function(){return _.clone(this.toJSON().query)},b.prototype.toRemote=function(){return Luca.concerns.Filterable.prepareRemoteFilter.call(this,this.toQuery(),this.toOptions())},b}(Backbone.Model)}.call(this),function(){Luca.concerns.FormModelBindings={__initializer:function(){if(this.trackModelChanges!==!0)return;return this.on("state:change:currentModel",this.onStateChangeCurrentModel,this),_.bindAll(this,"onStateChangeCurrentModel","unbindFromModel","onModelChange","bindToModel")},onStateChangeCurrentModel:function(a,b,c){Luca.isBackboneModel(c)&&this.unbindFromModel(c);if(Luca.isBackboneModel(b))return this.bindToModel(b)},unbindFromModel:function(a){var b;return(b=a||this.currentModel())!=null?b.unbind("change",this.onModelChange):void 0},onModelChange:function(a){return this.setValues(a,{modelChange:!0})},bindToModel:function(a){var b;return(b=a||this.currentModel())!=null?b.bind("change",this.onModelChange,this):void 0}}}.call(this),function(){Luca.concerns.GridLayout={_initializer:function(){this.gridSpan&&this.$el.addClass("span"+this.gridSpan),this.gridOffset&&this.$el.addClass("offset"+this.gridOffset),this.gridRowFluid&&this.$el.addClass("row-fluid");if(this.gridRow)return this.$el.addClass("row")}}}.call(this),function(){Luca.concerns.LoadMaskable={__initializer:function(){var a=this;if(this.loadMask===!1||this.loadMask==null)return;return this.loadMask===!0&&(this.loadMask={enableEvent:"enable:loadmask",disableEvent:"disable:loadmask"}),this.on("collection:fetch",function(){return a.trigger("enable:loadmask")}),this.on("collection:reset",function(){return a.trigger("disable:loadmask")}),this.on("after:render",function(){this.$el.addClass("with-mask");if(this.$(".load-mask").length===0&&this.loadMaskTemplate!=null)return this.loadMaskTarget().prepend(Luca.template(this.loadMaskTemplate,this)),this.$(".load-mask").hide()},this),this.on(this.loadMask.enableEvent,this.applyLoadMask,this),this.on(this.loadMask.disableEvent,this.applyLoadMask,this)},showLoadMask:function(){return this.trigger("enable:loadmask")},hideLoadMask:function(){return this.trigger("disable:loadmask")},loadMaskTarget:function(){return this.loadMaskEl!=null?this.$(this.loadMaskEl):this.$bodyEl()},disableLoadMask:function(){return this.$(".load-mask .bar").css("width","100%"),this.$(".load-mask").hide(),clearInterval(this.loadMaskInterval)},enableLoadMask:function(){var a,b=this;this.$(".load-mask").show().find(".bar").css("width","0%"),a=this.$(".load-mask .progress").width(),a<20&&(a=this.$el.width())<20&&(a=this.$el.parent().width()),this.loadMaskInterval=setInterval(function(){var a,c;return a=b.$(".load-mask .bar").width(),c=a+12,b.$(".load-mask .bar").css("width",c)},200);if(this.loadMaskTimeout==null)return;return _.delay(function(){return b.disableLoadMask()},this.loadMaskTimeout)},applyLoadMask:function(){return this.$(".load-mask").is(":visible")?this.disableLoadMask():this.enableLoadMask()}}}.call(this),function(){Luca.LocalStore=function(){function a(a){var b;this.name=a,b=localStorage.getItem(this.name),this.data=b&&JSON.parse(b)||{}}return a.prototype.guid=function(){var a;return a=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},a.prototype.save=function(){return localStorage.setItem(this.name,JSON.stringify(this.data))},a.prototype.create=function(a){return a.id||(a.id=a.attribtues.id=this.guid()),this.data[a.id]=a,this.save(),a},a.prototype.update=function(a){return this.data[a.id]=a,this.save(),a},a.prototype.find=function(a){return this.data[a.id]},a.prototype.findAll=function(){return _.values(this.data)},a.prototype.destroy=function(a){return delete this.data[a.id],this.save(),a},a}(),Backbone.LocalSync=function(a,b,c){var d,e;return e=b.localStorage||b.collection.localStorage,d=function(){switch(a){case"read":return b.id?e.find(b):e.findAll();case"create":return e.create(b);case"update":return e.update(b);case"delete":return e.destroy(b)}}(),d?c.success(d):c.error("Record not found")}}.call(this),function(){Luca.concerns.ModalView={version:3,closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,__initializer:function(){if(this.modal!==!0)return;return this.on("before:render",this.applyModalConfig,this),this},applyModalConfig:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this.showOnInitialize!==!0&&this.$el.css("display","none"),this},container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.rendered!==!0&&this.render(),this.trigger("before:show"),this.$el.modal("show"),this.trigger("after:show")},hide:function(){return this.trigger("before:hide"),this.$el.modal("hide"),this.trigger("after:hide")},setModalDimensions:function(a,b){var c;_.isObject(a)&&(c=a,a=c.height,b=c.width),a!=null&&this.setModalHeight(a);if(b!=null)return this.setModalWidth(b)},setModalWidth:function(a){return this.$el.css({width:a,"max-width":a,"margin-left":a*.5*-1})},setModalHeight:function(a){return this.$el.css({"max-height":a,"margin-top":a*.5*-1,height:a})}}}.call(this),function(){Luca.concerns.ModelPresenter={classMethods:{getPresenter:function(a){var b;return(b=this.presenters)!=null?b[a]:void 0},registerPresenter:function(a,b){return this.presenters||(this.presenters={}),this.presenters[a]=b}},presentAs:function(a){var b,c=this;try{return b=this.componentMetaData().componentDefinition().getPresenter(a),b==null?this.toJSON():_(b).reduce(function(a,b){return a[b]=c.read(b),a},{})}catch(d){return console.log("Error presentAs",d.stack,d.message),this.toJSON()}}}}.call(this),function(){Luca.concerns.Paginatable={paginatorViewClass:"Luca.components.PaginationControl",paginationSelector:".toolbar.bottom.pagination-container",__included:function(){return _.extend(Luca.Collection.prototype,{__paginators:{}})},__initializer:function(){var a,b,c=this;if(this.paginatable===!1)return;if(_.isNumber(this.paginatable)||_.isString(this.paginatable))this.paginatable={limit:parseInt(this.paginatable),page:1};if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Paginatable due to no collection being present on "+(this.name||this.cid)),this.debug("collection",this.collection);return}return _.bindAll(this,"paginationControl","pager"),a=(this.getCollection||(this.getCollection=function(){return this.collection}))(),b=this.getPaginationState(),this.optionsSources||(this.optionsSources=[]),this.queryOptions||(this.queryOptions={}),this.optionsSources.push(function(){var a;return a=_(b.toJSON()).pick("limit","page","sortBy"),_.extend(a,{pager:c.pager})}),b.on("change:page",function(){return c.trigger("pagination:change")}),this.on("pagination:change",Luca.concerns.Filterable.classMethods.prepare,this),this.on("before:render",this.renderPaginationControl,this)},pager:function(a,b){return this.getPaginationState().set({numberOfPages:a,itemCount:b.length}),this.paginationControl().updateWithPageCount(a,b)},isRemote:function(){return this.getQueryOptions().remote===!0},getPaginationState:function(){var a,b;return(a=this.collection.__paginators)[b=this.cid]||(a[b]=this.paginationControl().state)},paginationContainer:function(){return this.$(">"+this.paginationSelector)},setCurrentPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.getPaginationState().set("page",a,b)},setPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.getPaginationState().set("page",a,b)},setLimit:function(a,b){return a==null&&(a=0),b==null&&(b={}),this.getPaginationState().set("limit",a,b)},paginationControl:function(){return this.paginator!=null?this.paginator:(_.defaults(this.paginatable||(this.paginatable={}),{page:1,limit:20}),this.paginator=Luca.util.lazyComponent({type:"pagination_control",collection:this.getCollection(),defaultState:this.paginatable,parent:this.name||this.cid,debugMode:this.debugMode}),this.paginator)},renderPaginationControl:function(){var a;return a=this.paginationControl(),this.paginationContainer().append(a.render().$el),a}}}.call(this),function(){Luca.concerns.QueryCollectionBindings={getCollection:function(){return this.collection},loadModels:function(a,b){var c;return a==null&&(a=[]),b==null&&(b={}),(c=this.getCollection())!=null?c.reset(a,b):void 0},applyQuery:function(a,b){return a==null&&(a={}),b==null&&(b={}),this.query=a,this.queryOptions=b,this.refresh(),this},getQuery:function(a){var b,c,d,e,f;a==null&&(a={}),b=this.query||(this.query={}),f=_(this.querySources||[]).compact();for(d=0,e=f.length;d<e;d++)c=f[d],b=_.extend(b,c(a)||{});return Luca.util.readAll(b)},getRemoteQuery:function(a){return a==null&&(a={}),this.getQuery(a)},getLocalQuery:function(a){return a==null&&(a={}),this.getQuery(a)},getQueryOptions:function(a){var b,c,d,e,f;a==null&&(a={}),c=this.queryOptions||(this.queryOptions={}),f=_(this.optionsSources||[]).compact();for(d=0,e=f.length;d<e;d++)b=f[d],c=_.extend(c,b(a)||{});return c},getModels:function(a,b){var c;return((c=this.collection)!=null?c.query:void 0)?(a||(a=this.getLocalQuery()),b||(b=this.getQueryOptions()),b.prepare||(b.prepare=this.prepareQuery),this.collection.query(a,b)):this.collection.models}}}.call(this),function(){var a;Luca.concerns.Sortable={__included:function(a,b){return _.extend(Luca.Collection.prototype,{__sortables:{}})},__initializer:function(){var a,b,c=this;if(this.sortable===!1)return;_.isString(this.sortable)&&(this.sortable={sortBy:this.sortable});if(!Luca.isBackboneCollection(this.collection)){this.debug("Skipping Sortable due to no collection being present on "+(this.name||this.cid)),this.debug("collection",this.collection);return}return a=(this.getCollection||(this.getCollection=function(){return this.collection}))(),b=this.getSortableState(),this.optionsSources||(this.optionsSources=[]),this.queryOptions||(this.queryOptions={}),this.optionsSources.push(function(){return _(b.toJSON()).pick("sortBy","order")}),b.on("change",function(){return c.trigger("sortable:change")}),this.defer(function(){return c.$(".sortable-toggle").on("click",function(a){var b,d;return b=d=c.$(a.target),b=d=d.closest(".sortable-toggle"),c.toggleSortOrderDirection(d.data("sortableSortBy"))})}).until("after:render"),this.on("sortable:change",Luca.concerns.Filterable.classMethods.prepare,this)},isRemote:function(){return this.getQueryOptions().remote===!0},getSortableState:function(){var b,c,d;return b=_(this.sortable||{}).pick("sortBy","order"),(c=this.collection.__sortables)[d=this.cid]||(c[d]=new a(b))},sortBy:function(a,b){return a!=null&&this.setSortBy(a),b!=null&&this.setOrder(b),this},setSortBy:function(a,b){return b==null&&(b={}),this.getSortableState().set("sortBy",a,b),this},toggleSortOrderDirection:function(a){var b,c;return c=this.getSortableState().get("order")||"ASC",b=c==="ASC"?"DESC":"ASC",a||(a=this.getSortableState().get("sortBy")),this.sortBy(a,b)},setOrder:function(a,b){return b==null&&(b={}),this.getSortableState().set("order",a,b),this}},Luca.util.makeSortableToggleElement=function(a,b,c){return $(a).attr("data-sortable-sort-by",b).attr("data-sortable-order",c),$(a)},a=Backbone.Model.extend()}.call(this),function(){var a,b=[].slice;a=Luca.register("Luca.ViewState")["extends"]("Luca.Model"),Luca.concerns.StateModel={__onModelChange:function(){var a,c,d,e,f,g,h,i;a=1<=arguments.length?b.call(arguments,0):[],e=this,d=e.state,(g=this.trigger).call.apply(g,[e,"state:change"].concat(b.call(a))),h=d.changedAttributes(),i=[];for(c in h)f=h[c],i.push(this.trigger.call(e,"state:change:"+c,d,f,d.previous(c)));return i},__initializer:function(){var a,b,c,d,e,f,g;this.stateAttributes!=null&&(this.stateful=this.stateAttributes);if(this.stateful==null)return;d=this,_.isObject(this.stateful)&&this.defaultState==null&&(this.defaultState=this.stateful),this.state||(this.state=new Luca.ViewState(this.defaultState||{})),f=this,this.get=function(){return f.state.get.apply(f.state,arguments)},this.set=function(){return f.state.set.apply(f.state,arguments)},g=this.state.toJSON();for(c in g)e=g[c],b="on"+_.str.capitalize(c)+"Change",a="get"+_.str.capitalize(c),_.isFunction(this[a])||1,_.isFunction(this[b])&&1;return Luca.concerns.StateModel.__setupModelBindings.call(this,"on")},__setupModelBindings:function(a){var b,c,d,e,f,g;a==null&&(a="on"),f=this,g=this.stateChangeEvents;for(b in g)d=g[b],c=_.isString(d)?f[d]:d,b==="*"?f[a]("state:change",c,f):f[a]("state:change:"+b,c,f);return e=f.state,f.state[a]("change",Luca.concerns.StateModel.__onModelChange,f)}}}.call(this),function(){Luca.concerns.Templating={__initializer:function(){var a,b,c;c=Luca.util.read.call(this,this.bodyTemplateVars)||{};if(a=this.bodyTemplate){this.$el.empty();try{b=Luca.template(a,c)}catch(d){console.log("Error Rendering "+a+" in View: "+((typeof this.identifier=="function"?this.identifier():void 0)||this.name||this.cid))}return Luca.View.prototype.$html.call(this,b)}}}}.call(this),function(){var a,b;a=Luca.register("Luca.Model"),a["extends"]("Backbone.Model"),a.includes("Luca.Events"),a.defines({initialize:function(){return Backbone.Model.prototype.initialize(this,arguments),b.call(this),Luca.concern.setup.call(this)},read:function(a){return _.isFunction(this[a])?this[a].call(this):this.get(a)||this[a]},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)}}),b=function(){var a,b,c,d,e=this;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.read(a)}),_.isString
3
+ (b)&&(b=b.split(",")),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},Luca.Model._originalExtend=Backbone.Model.extend,Luca.Model.extend=function(a){var b,c,d,e,f;a==null&&(a={}),a.concerns!=null&&(a.concerns||(a.concerns=a.concerns)),b=Luca.Model._originalExtend.call(this,a);if(a.concerns!=null&&_.isArray(a.concerns)){f=a.concerns;for(d=0,e=f.length;d<e;d++)c=f[d],Luca.decorate(b)["with"](c)}return b}}.call(this),function(){var a;a=Luca.register("Luca.Collection"),a["extends"]("Backbone.QueryCollection"),a.includes("Luca.Events"),a.triggers("after:initialize","before:fetch","after:response"),a.publicConfiguration({model:Luca.Model,cachedMethods:[],remoteFilter:!1,cache_key:void 0,manager:void 0,initialize:function(a,b){var c,d=this;a==null&&(a=[]),this.options=b,_.extend(this,this.options),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=Luca.util.read(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.manager!=null&&(this.manager=Luca.util.read(this.manager)),this.name&&!this.manager&&(this.manager=Luca.CollectionManager.get()),this.manager&&(this.name||(this.name=Luca.util.read(this.cache_key)),this.name=Luca.util.read(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 a cache_key property or method 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}),Luca.concern.setup.call(this),Luca.util.setupHooks.call(this,this.hooks),this.setupMethodCaching(),this.trigger("after:initialize")},__wrapUrl:function(){var a,b,c=this;return _.isFunction(this.url)?this.url=_.wrap(this.url,function(a){var b,d,e,f,g;return g=a.apply(c),e=g.split("?"),e.length>1&&(b=_.last(e)),f=c.queryString(),b&&g.match(b)&&(f=f.replace(b,"")),d=""+g+"?"+f,d.match(/\?$/)&&(d=d.replace(/\?$/,"")),d}):(b=this.url,a=this.queryString(),this.url=_([b,a]).compact().join("?"))},queryString:function(){var a,b=this;return a=_(this.base_params||(this.base_params=Luca.Collection.baseParams())).inject(function(a,b,c){var d;return d=""+c+"="+b,a.push(d),a},[]),_.uniq(a).join("&")},resetFilter:function(){return this.base_params=_(Luca.Collection.baseParams()).clone(),this},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b=_(b).clone(),b.remote!=null==1||this.remoteFilter===!0?(this.applyParams(a),this.fetch(_.extend(b,{refresh:!0,remote:!0}))):this.reset(this.query(a,b))},applyParams:function(a){return this.base_params=_(Luca.Collection.baseParams()).clone()||{},_.extend(this.base_params,a),this},register:function(a,b,c){b==null&&(b=""),a||(a=Luca.CollectionManager.get());if(!(b.length>=1))throw"Attempt to register a collection without specifying a key.";_.isString(a)&&(a=Luca.util.resolve(a));if(a==null)throw"Attempt to register with a non existent collection manager.";if(_.isFunction(a.add))return a.add(b,c);if(_.isObject(a))return a[b]=c},loadFromBootstrap:function(){if(!this.bootstrap_cache_key)return;return this.reset(this.cached_models()),this.trigger("bootstrapped",this)},bootstrap:function(){return this.loadFromBootstrap()},cached_models:function(){return Luca.Collection.cache(this.bootstrap_cache_key)},fetch:function(a){var b;a==null&&(a={}),this.trigger("before:fetch",this);if(this.memoryCollection===!0)return this.reset(this.data);if(this.cached_models().length&&a.refresh!==!0&&a.remote!==!0)return this.bootstrap();b=_.isFunction(this.url)?this.url():this.url;if(!(b&&b.length>1||this.localStorage))return!0;this.fetching=!0;try{return Backbone.Collection.prototype.fetch.apply(this,arguments)}catch(c){throw console.log("Error in Collection.fetch",c),c}},onceLoaded:function(a,b){var c,d=this;b==null&&(b={}),_.defaults(b,{autoFetch:!0});if(this.length>0&&!this.fetching){a.apply(this,[this]);return}c=function(){return a.apply(d,[d])},this.bind("reset",function(){return c(),this.unbind("reset",this)});if(!this.fetching&&!!b.autoFetch)return this.fetch()},ifLoaded:function(a,b){var c,d=this;b==null&&(b={scope:this,autoFetch:!0}),c=b.scope||this,this.length>0&&!this.fetching&&a.apply(c,[this]),this.bind("reset",function(b){return a.call(c,b)});if(!(this.fetching===!0||!b.autoFetch||this.length>0))return this.fetch()},parse:function(a){var b;return this.fetching=!1,this.trigger("after:response",a),b=this.root!=null?a[this.root]:a,this.bootstrap_cache_key&&Luca.Collection.cache(this.bootstrap_cache_key,b),b},restoreMethodCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],a.original!=null?(a.args=void 0,d.push(this[b]=a.original)):d.push(void 0);return d},clearMethodCache:function(a){return this._methodCache[a].value=void 0},clearAllMethodsCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],d.push(this.clearMethodCache(b));return d},setupMethodCaching:function(){var b,c,d;if(((d=this.cachedMethods)!=null?d.length:void 0)>0)return a=this,c=["reset","add","remove"],b=this._methodCache={},_(this.cachedMethods).each(function(d){var e,f,g,h,i;b[d]={name:d,original:a[d],value:void 0},a[d]=function(){var c;return(c=b[d]).value||(c.value=b[d].original.apply(a,arguments))};for(h=0,i=c.length;h<i;h++)f=c[h],a.bind(f,function(){return a.clearAllMethodsCache()});e=d.split(":")[1];if(e)return g=e.split(","),_(g).each(function(b){return a.bind("change:"+b,function(){return a.clearMethodCache({method:d})})})});return},query:function(a,b){var c;return a==null&&(a={}),b==null&&(b={}),Backbone.QueryCollection!=null?(_.isFunction(c=b.prepare||this.prepareQuery)&&(a=c(a)),Backbone.QueryCollection.prototype.query.call(this,a,b)):this.models}}),a.register(),_.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._originalExtend=Backbone.Collection.extend,Luca.Collection.extend=function(a){var b,c,d,e,f;a==null&&(a={}),a.concerns!=null&&(a.concerns||(a.concerns=a.concerns)),b=Luca.Collection._originalExtend.call(this,a);if(a.concerns!=null&&_.isArray(a.concerns)){f=a.concerns;for(d=0,e=f.length;d<e;d++)c=f[d],Luca.decorate(b)["with"](c)}return b},Luca.Collection.namespace=function(a){var b;return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&(Luca.Collection.__defaultNamespace=a),(b=Luca.Collection).__defaultNamespace||(b.__defaultNamespace=window||global),Luca.util.read(Luca.Collection.__defaultNamespace)},Luca.Collection.baseParams=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a&&(Luca.Collection._baseParams=a),Luca.util.read(Luca.Collection._baseParams)},Luca.Collection.resetBaseParams=function(){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,b,c,d=[].slice;c=Luca.register("Luca.View"),c["extends"]("Backbone.View"),c.includes("Luca.Events","Luca.concerns.DomHelpers","Luca.concerns.DevelopmentToolHelpers"),c.mixesIn("DomHelpers","Templating","EnhancedProperties","CollectionEventBindings","ApplicationEventBindings","StateModel"),c.triggers("before:initialize","after:initialize","before:render","after:render","first:activation","activation","deactivation"),c.publicConfiguration({name:void 0,autoBindEventHandlers:!1,_inheritEvents:void 0}),c.publicMethods({identifier:function(){return(this.displayName||this.type)+":"+(this.name||this.role||this.cid)},remove:function(){return this.trigger("before:remove",this),Luca.remove(this),Backbone.View.prototype.remove.apply(this,arguments)},initialize:function(b){var c,e,f,g,h;this.options=b!=null?b:{},this.trigger("before:initialize",this,this.options),_.extend(this,this.options),(this.autoBindEventHandlers===!0||this.bindAllEvents===!0)&&a.call(this),this.name!=null&&(this.cid=_.uniqueId(this.name)),this.$el.attr("data-luca-id",this.name||this.cid),Luca.registry.cacheInstance(this.cid,this),this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq()),Luca.concern.setup.call(this),_.isEmpty(this.events)||this.delegateEvents(),this.trigger("after:initialize",this),((f=this.bindMethods)!=null?f.legth:void 0)>0&&_.bindAll.apply(_,[this].concat(d.call(this.bindMethods)));if(!_.isEmpty(this._inheritEvents)){g=this._inheritEvents,h=[];for(c in g)e=g[c],h.push(this.registerEvent(c,e));return h}},debug:function(){var a;a=1<=arguments.length?d.call(arguments,0):[];if(this.debugMode===!0||window.LucaDebugMode===!0)return a.unshift(this.identifier()),console.log.apply(console,a)},trigger:function(){return Luca.enableGlobalObserver&&(Luca.developmentMode===!0||this.observeEvents===!0)&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)},make:function(a,b,c){var d;return d=document.createElement(a),b&&Backbone.$(d).attr(b),c!==null&&Backbone.$(d).html(c),d},registerEvent:function(a,b){this.events||(this.events={});if(_.isObject(a))this.events=_.extend(this.events,a);else if(_.isFunction(b)||_.isString(b)&&this[b]!=null)this.events[a]=b;return this.delegateEvents()}}),c.privateMethods({definitionClass:function(){var a;return(a=Luca.util.resolve(this.displayName,window))!=null?a.prototype:void 0},_collections:function(){return Luca.util.selectProperties(Luca.isBackboneCollection,this)},_models:function(){return Luca.util.selectProperties(Luca.isBackboneModel,this)},_views:function(){return Luca.util.selectProperties(Luca.isBackboneView,this)},setupHooks:Luca.util.setupHooks}),c.afterDefinition(function(){if(Backbone.View.prototype.make==null)return Backbone.View.prototype.make=function(){return console.log("Backbone.View::make has been removed from backbone. You should use Luca.View::make instead."),Luca.View.prototype.make}}),c.register(),Luca.View._originalExtend=Backbone.View.extend,Luca.View.renderStrategies={legacy:function(a){var b,d,e,f,g,h=this;return c=this,this.deferrable?(f=this.deferrable_target,Luca.isBackboneCollection(this.deferrable)||(this.deferrable=this.collection),f||(f=this.deferrable),g=this.deferrable_event?this.deferrable_event:Luca.View.deferrableEvent,d=function(){return a.call(c),this.rendered=!0,c.trigger("after:render",c)},c.defer(d).until(f,g),c.trigger("before:render",this),b=this.deferrable_trigger||this.deferUntil,b==null?f[this.deferrable_method||"fetch"].call(f):(e=_.once(function(){var a,b;return typeof (a=h.deferrable)[b=h.deferrable_method||"fetch"]=="function"?a[b]():void 0}),(this.deferrable_target||this).bind(this.deferrable_trigger,e)),this):(this.trigger("before:render",this),a.apply(this,arguments),this.rendered=!0,this.trigger("after:render",this),this)},improved:function(a){var b,d=this;this.trigger("before:render",this),b=function(){return a.apply(d,arguments),d.trigger("after:render",d)},console.log("doing the improved one",this.deferrable);if(this.deferrable!=null&&!_.isString(this.deferrable))throw"Deferrable property is expected to be a event id";return _.isString(this.deferrable)?(console.log("binding to "+this.deferrable+" on "+this.cid),c.on(this.deferrable,function(){return console.log("did the improved one"),b.call(c),c.unbind(listenForEvent,this)})):b.call(this)}},Luca.View.renderWrapper=function(a){var b;return b=a.render,b||(b=function(){return this.trigger("empty:render")}),a.render=function(){var a;a=Luca.View.renderStrategies[this.renderStrategy||(this.renderStrategy="legacy")];if(!_.isFunction(a))throw"Invalid rendering strategy. Please see Luca.View.renderStrategies";return a.call(this,b),this},a},a=function(){var a,c,d,e,f;e=[this.events,this.componentEvents,this.collectionEvents,this.applicationEvents],f=[];for(c=0,d=e.length;c<d;c++)a=e[c],_.isEmpty(a)||f.push(b.call(this,a));return f},b=function(a){var b,c,d;a==null&&(a={}),d=[];for(b in a){c=a[b];if(_.isString(c))try{d.push(_.bindAll(this,c))}catch(e){d.push(console.log("Error binding to handler - "+c+" = "+e+" "+this.identifier()))}else d.push(void 0)}return d},Luca.View.deferrableEvent="reset",Luca.View.extend=function(a){var b,c,d,e,f;a==null&&(a={}),a=Luca.View.renderWrapper(a),a.concerns!=null&&(a.concerns||(a.concerns=a.concerns)),b=Luca.View._originalExtend.call(this,a);if(a.concerns!=null&&_.isArray(a.concerns)){f=a.concerns;for(d=0,e=f.length;d<e;d++)c=f[d],Luca.decorate(b)["with"](c)}return b}}.call(this),function(){var a;a=Luca.register("Luca.Panel"),a.replaces("Luca.Panel"),a["extends"]("Luca.View"),a.configuration({topToolbar:void 0,bottomToolbar:void 0}),a.publicMethods({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},$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 _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$html(Luca.template(a,b))},$empty:function(){return this.$bodyEl().empty()},$html:function(a){return a!=null?this.$bodyEl().html(a):this.$bodyEl().html()},$append:function(a){return this.$bodyEl().append(a)}}),a.privateMethods({beforeRender:function(){var a;return(a=Luca.View.prototype.beforeRender)!=null&&a.apply(this,arguments),this.styles!=null&&this.applyStyles(this.styles),this.bodyStyles!=null&&this.applyStyles(this.bodyStyles,!0),typeof this.renderToolbars=="function"?this.renderToolbars():void 0},renderToolbars:function(){var a=this;return _(["top","left","right","bottom"]).each(function(b){var c;if(c=a[""+b+"Toolbar"])return a.renderToolbar(b,c)})},renderToolbar:function(a,b){var c;return a==null&&(a="top"),b==null&&(b={}),b.parent=this,b.orientation=a,c=Luca.util.read(b.container),c||(c=Luca.util.read(b.targetEl)),Luca.Panel.attachToolbar.call(this,b,c)}}),a.classMethods({attachToolbar:function(a,b){var c,d,e,f;return a==null&&(a={}),a.orientation||(a.orientation="top"),a.type||(a.type=a.ctype||(a.ctype=this.toolbarType||"panel_toolbar")),a.additionalClassNames=""+Luca.config.toolbarContainerClass+" "+a.orientation,e=Luca.util.lazyComponent(a),a.orientation==="bottom"&&(this.getBottomToolbar||(this.getBottomToolbar=function(){return e})),a.orientation==="top"&&(this.getTopToolbar||(this.getTopToolbar=function(){return e})),a.orientation==="right"&&(this.getRightToolbar||(this.getRightToolbar=function(){return e})),a.orientation==="left"&&(this.getLeftToolbar||(this.getLeftToolbar=function(){return e})),d=this.bodyClassName||this.bodyTagName,c=a.attachmentAction,c||(c=function(){switch(a.orientation){case"top":case"left":return d&&(b!=null?!b.length:!void 0)>0?"before":"prepend";case"bottom":case"right":return d&&(b!=null?!b.length:!void 0)>0?"after":"append"}}()),f=(b!=null?b.length:void 0)>0?this.$(b):this.$bodyEl(),f[c](e.render().el)}}),a.defines({version:3})}.call(this),function(){}.call(this),function(){var a,b,c;Luca.CollectionManager=function(){function c(a){var c,d,e,f;this.options=a!=null?a:{},_.extend(this,this.options),d=this;if(c=typeof (e=Luca.CollectionManager).get=="function"?e.get(this.name):void 0)throw"Attempt to create a collection manager with a name which already exists";this.collectionNamespace||(this.collectionNamespace=Luca.util.read(Luca.Collection.namespace)),(f=Luca.CollectionManager).instances||(f.instances={}),_.extend(this,Backbone.Events),_.extend(this,Luca.Events),Luca.CollectionManager.instances[this.name]=d,Luca.CollectionManager.get=function(a){return a==null?d:Luca.CollectionManager.instances[a]},this.state=new Luca.Model,this.initialCollections&&this.on("ready",b,this),this.autoStart===!0&&this.trigger("ready")}return c.prototype.name="primary",c.prototype.__collections={},c.prototype.autoStart=!0,c.prototype.relayEvents=!0,c.prototype.add=function(a,b){var c;return(c=this.currentScope())[a]||(c[a]=b)},c.prototype.allCollections=function(){return _(this.currentScope()).values()},c.prototype.create=function(b,c,d){var e,f,g;c==null&&(c={}),d==null&&(d=[]),e=c.base,e||(e=a.call(this,b)),c["private"]&&(c.name="");try{f=new e(d,c)}catch(h){throw console.log("Error creating collection",e,c,b),h}return this.add(b,f),g=this,this.relayEvents===!0&&this.bind("*",function(){return console.log("Relay Events on Collection Manager *",f,arguments)}),f},c.prototype.currentScope=function(){var a,b;return(a=this.getScope())?(b=this.__collections)[a]||(b[a]={}):this.__collections},c.prototype.each=function(a){return _(this.all()).each(a)},c.prototype.get=function(a){return this.currentScope()[a]},c.prototype.getScope=function(){return void 0},c.prototype.destroy=function(a){var b;return b=this.get(a),delete this.currentScope()[a],b},c.prototype.getOrCreate=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.get(a)||this.create(a,b,c,!1)},c.prototype.collectionCountDidChange=function(){if(this.allCollectionsLoaded())return this.trigger("all_collections_loaded"),this.trigger("initial:load")},c.prototype.allCollectionsLoaded=function(){return this.totalCollectionsCount()===this.loadedCollectionsCount()},c.prototype.totalCollectionsCount=function(){return this.state.get("collections_count")},c.prototype.loadedCollectionsCount=function(){return this.state.get("loaded_collections_count")},c.prototype["private"]=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.create(a,b,c,!0)},c}(),Luca.CollectionManager.isRunning=function(){return _.isEmpty(Luca.CollectionManager.instances)!==!0},Luca.CollectionManager.destroyAll=function(){return Luca.CollectionManager.instances={}},Luca.CollectionManager.loadCollectionsByName=function(a,b){var c,d,e,f,g;g=[];for(e=0,f=a.length;e<f;e++)d=a[e],(c=this.getOrCreate(d))?(c.on("reset",function(){return b(c),c.unbind("reset",this)}),g.push(c.fetch())):g.push(void 0);return g},a=function(a){var b,c,d,e;return b=Luca.util.classify(a),_.isString(this.collectionNamespace)&&(this.collectionNamespace=Luca.util.resolve(this.collectionNamespace)),c=(this.collectionNamespace||window||global)[b],c||(c=(this.collectionNamespace||window||global)[""+b+"Collection"]),c==null&&((e=Luca.Collection.namespaces)!=null?e.length:void 0)>0&&(d=_(Luca.Collection.namespaces.reverse()).map(function(a){return Luca.util.resolve(""+a+"."+b)||Luca.util.resolve(""+a+"."+b+"Collection")}),d=_(d).compact(),d.length>0&&(c=d[0])),c},c=function(){var a,b,c=this;return a=function(a){var b;return b=c.state.get("loaded_collections_count"),c.state.set("loaded_collections_count",b+1),c.trigger("collection_loaded",a.name),a.unbind("reset")},b=this.initialCollections,Luca.CollectionManager.loadCollectionsByName.call(this,b,a)},b=function(){var a=this;return this.state.set({loaded_collections_count:0,collections_count:this.initialCollections.length}),this.state.bind("change:loaded_collections_count",function(){return a.collectionCountDidChange()}),this.useProgressLoader&&(this.loaderView||(this.loaderView=new Luca.components.CollectionLoaderView({manager:this,name:"collection_loader_view"}))),c.call(this),this}}.call(this),function(){var a;a=Luca.register("Luca.SocketManager"),a["extends"]("Luca.Model"),a.defines({defaults:{autoStart:!0,providerAvailable:!1,ready:!1,provider:"faye.js"},initialize:function(a){var b,c,d,e=this;return this.attributes=a!=null?a:{},this.providerLibraryIsAvailable()||this.loadProviderSource(),(d=Luca.Model.prototype.initialize)!=null&&d.apply(this,arguments),c=this,b=function(){if(e.isReady())return e.connect()},c.on("change:ready",function(){return b(),c.unbind("change:ready",this)}),c.on("change:providerAvailable",function(){return b(),c.unbind("change:ready",this)}),this.on("ready",_.once(function(){return e.set("ready",!0)})),this.trigger("change")},isReady:function(){return this.get("ready")===!0&&this.get("providerAvailable")===!0},providerLibraryIsAvailable:function(){var a;return a=function(){switch(this.get("provider")){case"socket.io":return"io";case"faye.js":return"Faye.Client"}}.call(this),Luca.util.resolve(a)!=null},connect:function(){switch(this.get("provider")){case"socket.io":return this.client=io.connect(this.get("host"));case"faye.js":return this.client=new Faye.Client(this.get("host")),this.set("client",this.client)}},providerSourceLoaded:function(){return this.set("providerAvailable",!0)},providerSourceUrl:function(){switch(this.get("provider")){case"socket.io":return""+this.get("host")+"/socket.io/socket.io.js";case"faye.js":return""+this.get("host")+"/faye.js"}},loadProviderSource:function(){var a,b=this;return a=document.createElement("script"),a.setAttribute("type","text/javascript"),a.setAttribute("src",this.providerSourceUrl()),a.onload=_.bind(this.providerSourceLoaded,this),Luca.util.isIE()&&(a.onreadystatechange=function(){if(a.readyState==="loaded")return b.providerSourceLoaded()}),document.getElementsByTagName("head")[0].appendChild(a)}})}.call(this),function(){}.call(this),function(){var a,b,c,d,e,f,g,h;b=Luca.register("Luca.Container"),b["extends"]("Luca.Panel"),b.triggers("before:components","before:render:components","before:layout","after:components","after:layout","first:activation"),b.replaces("Luca.Container"),b.publicConfiguration({components:[],defaults:{},extensions:{},componentEvents:{}}),b.privateConfiguration({className:"luca-ui-container",isContainer:!0,generateComponentElements:!1,emptyContainerElements:!1,componentTag:"div",componentClass:"luca-ui-panel",rendered:!1}),b.privateMethods({initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},_.extend(this,this.options),this.components||(this.components=this.fields||(this.fields=this.pages||(this.pages=this.cards||(this.cards=this.views)))),e=this.components;for(c=0,d=e.length;c<d;c++)b=e[c],_.isString(b)&&(b={type:b,role:b,name:b});return _.bindAll(this,"beforeRender"),this.setupHooks(Luca.Container.prototype.hooks),h(this),Luca.View.prototype.initialize.apply(this,arguments)},remove:function(){return Luca.View.prototype.remove.apply(this,arguments),this.eachComponent(function(a){return typeof a.remove=="function"?a.remove():void 0})},beforeRender:function(){var a;return f.call(this),e.call(this),(a=Luca.Panel.prototype.beforeRender)!=null?a.apply(this,arguments):void 0},customizeContainerEl:function(a,b,c){return a},prepareLayout:function(){var c,d,e,f,g,h,i;b=this,this.componentContainers=_(this.components).map(function(c,d){return a.call(b,c,d)}),c=this._().select(function(a){var c;return _.isString(a.container)&&((c=a.container)!=null?c.match(/^\./):void 0)&&b.$(a.container).length>0});if(c.length>0){i=[];for(g=0,h=c.length;g<h;g++)e=c[g],d=_.uniqueId("container"),f=b.$(e.container),f.length>0?($(f).attr("data-container-assignment",d),i.push(e.container+="[data-container-assignment='"+d+"']")):i.push(void 0);return i}},prepareComponents:function(){var a=this;return b=this,_(this.components).each(function(c,d){var e,f,g,h,i,j;e=f=(i=a.componentContainers)!=null?i[d]:void 0,e["class"]=e["class"]||e.className||e.classes,a.generateComponentElements&&(h=a.make(a.componentTag,f,""),a.$append(h)),b.defaults!=null&&(c=_.defaults(c,b.defaults||{})),_.isArray(b.extensions)&&_.isObject((j=b.extensions)!=null?j[d]:void 0)&&(g=b.extensions[d],c=_.extend(c,g)),c.role!=null&&_.isObject(b.extensions)&&_.isObject(b.extensions[c.role])&&(g=b.extensions[c.role],c=_.extend(c,g));if(c.container==null)return a.generateComponentElements&&(c.container="#"+f.id),c.container||(c.container=a.$bodyEl())})},createComponents:function(){var a,c=this;if(this.componentsCreated===!0)return;return a=this.componentIndex={name_index:{},cid_index:{},role_index:{}},b=this,this.components=_(this.components).map(function(a,d){var e,f,h;return e=Luca.isComponent(a)?a:(a.component!=null&&!a.type&&!a.ctype?(a.type=a.component,a.name||(a.name=a.component),a.role||(a.role=a.component)):void 0,a.type||(a.type=a.ctype),a.type==null?a.components!=null?a.type=a.ctype="container":a.type=a.ctype=Luca.defaultComponentType:void 0,a._parentCid||(a._parentCid=b.cid),f=Luca.util.lazyComponent(a)),!e.container&&((h=e.options)!=null?h.container:void 0)&&(e.container=e.options.container),e.getParent||(e.getParent=function(){return Luca(e._parentCid)}),e.container==null&&(console.log(e,d,c),console.error("could not assign container property to component on container "+(c.name||c.cid))),g(e).at(d)["in"](c.componentIndex),e}),this.componentsCreated=!0,a},renderComponents:function(a){return this.debugMode=a!=null?a:"",this.debug("container render components"),b=this,_(this.components).each(function(a){var c;try{return a.trigger("before:attach"),c=b.$(a.container),c.length===0&&(_.isString(a.container)&&1,c.length===0&&(c=this.$(a.container).eq(0))),this.emptyContainerElements===!0&&c.empty(),c.append(a.el),a.trigger("after:attach"),a.render(),a.rendered=!0}catch(d){console.log("Error Rendering Component "+(a.name||a.cid),a),_.isObject(d)&&(console.log(d.message),console.log(d.stack));if(Luca.silenceRenderErrors!=null!=1)throw d}})},firstActivation:function(){var a;return a=this,this.each(function(b,c){var d;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.call(b,"first:activation",b,a),b.previously_activated=!0})},registerComponentEvents:function(a,c){var d,e,f,g,h,i,j,k,l=this;c==null&&(c="on"),b=this,i=a||this.componentEvents||{},k=[];for(h in i){g=i[h],j=h.split(" "),e=j[0],f=j[1];if(!_.isFunction(this[g]))throw console.log("Error registering component event",h,e,f),"Invalid component event definition "+h+". Specified handler is not a method on the container";if(e==="*")k.push(this.eachComponent(function(a){return a.on(f,l[g],b)}));else{d=this.findComponentForEventBinding(e);if(d==null||!Luca.isComponent(d))throw console.log("Error registering component event",h,e,f),"Invalid component event definition: "+e;k.push(d[c](f,this[g],b))}}return k}}),b.publicMethods({_:function(){return _(this.components)},pluck:function(a){return this._().pluck(a)},invoke:function(a){return this._().invoke(a)},select:function(a){return this._().select(a)},detect:function(a){return this._().detect(a)},reject:function(a){return this._().reject(a)},map:function(a){return this._().map(a)},subContainers:function(){return this.select(function(a){return a.isContainer===!0})},roles:function(){return _(this.allChildren()).chain().pluck("role").compact().value()},allChildren:function(){var a,b;return a=this.components,b=_(this.subContainers()).map(function(a){return a!=null?typeof a.allChildren=="function"?a.allChildren():void 0:void 0}),_([a,b]).chain().compact().flatten().value()},find:function(a){return _(this.components).detect(function(b){return b.name===a})},findComponentForEventBinding:function(a,b){return b==null&&(b=!0),this.findComponentByName(a,b)||this.findComponentByGetter(a,b)||this.findComponentByRole(a,b)},findComponentByGetter:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return(b!=null?b.getter:void 0)===a})},findComponentByRole:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return(b!=null?b.role:void 0)===a||(b!=null?b.type:void 0)===a||(b!=null?b.ctype:void 0)===a})},findComponentByType:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return a===(b.type||b.ctype)})},findComponentByName:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.name===a})},findComponentById:function(a,b){return b==null&&(b=!1),this.findComponent(a,"cid_index",b)},findComponent:function(a,b,c){var d,e,f,g;b==null&&(b="name"),c==null&&(c=!1),this.componentsCreated!==!0&&this.createComponents(),e=(g=this.componentIndex)!=null?g[b][a]:void 0,d=this.components[e];if(d)return d;if(c===!0)return f=_(this.components).detect(function(c){return c!=null?typeof c.findComponent=="function"?c.findComponent(a,b,!0):void 0:void 0}),f!=null?typeof f.findComponent=="function"?f.findComponent(a,b,!0):void 0:void 0},each:function(a){return this.eachComponent(a,!1)},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c,d){var e;a.call(c,c,d);if(b)return c!=null?(e=c.eachComponent)!=null?e.apply(c,[a,b]):void 0:void 0})},indexOfComponentName:function(a){var b;return b=_(this.components).pluck("name"),_(b).indexOf(a)},indexOf:function(a){if(_.isString(a))return this.indexOfComponentName(a);if(_.isObject(a))return _(this.components).indexOf(a)},activeComponent:function(){return this.activeItem?this.components[this.activeItem]:this},componentElements:function(){return this.$("[data-luca-parent='"+(this.name||this.cid)+"']")},getComponent:function(a){return this.components[a]},isRootComponent:function(){return this.rootComponent===!0||this.getParent==null},getRootComponent:function(){return this.isRootComponent()?this:this.getParent().getRootComponent()},selectByAttribute:function(a,b,c){var d;return b==null&&(b=void 0),c==null&&(c=!1),d=_(this.components).map(function(d){var e,f;return e=[],f=d[a],(f===b||b==null&&f!=null)&&e.push(d),c===!0&&e.push(typeof d.selectByAttribute=="function"?d.selectByAttribute(a,b,!0):void 0),_.compact(e)}),_.flatten(d)}}),b.register(),Luca.Container.componentRenderer=function(a,b){var c;return c=$(b.container)[b.attachWith||"append"],c(b.render().el)},f=function(){return this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},a=function(a,b){var c,d;return d=[],a.height!=null&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width!=null&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={"class":(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";"),"data-luca-parent":this.name||this.cid},this.customizeContainerEl!=null&&(c=this.customizeContainerEl(c,a,b)),c},c=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return(a!=null?a.getter:void 0)!=null}),_(a).each(function(a){var c;return b[c=a.getter]||(b[c]=function(){return a})})},d=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return(a!=null?a.role:void 0)!=null}),_(a).each(function(a){var c,d;return c=_.str.camelize("get_"+a.role),d=function(){return a},b[c]||(b[c]=_.bind(d,b))})},e=function(){return this.trigger("before:components",this,this.components),this.prepareComponents(),this.trigger("before:create:components",this,this.components),this.createComponents(),this.trigger("before:render:components",this,this.components),this.renderComponents(),this.trigger("after:components",this,this.components),this.skipGetterMethods!==!0&&(c.call(this),d.call(this)),this.registerComponentEvents()},h=function(){return!0},g=function(a){return{at:function(b){return{"in":function(c){a.cid!=null&&(c.cid_index[a.cid]=b),a.role!=null&&(c.role_index[a.role]=b);if(a.name!=null)return c.name_index[a.name]=b}}}}}}.call(this),function(){var a;a=Luca.register("Luca.containers.CardView"),a["extends"]("Luca.Container"),a.publicConfiguration({activeCard:0,components:[]}),a.classInterface({activationContext:"current"}),a.privateConfiguration({hooks:["before:card:switch","after:card:switch"],componentClass:"luca-ui-card",generateComponentElements:!0}),a.publicMethods({atFirst:function(){return this.activeCard===0},atLast:function(){return this.activeCard===this.components.length-1},next:function(){if(this.atLast())return;return this.activate(this.activeCard+1)},previous:function(){if(this.atFirst())return;return this.activate(this.activeCard-1)},cycle:function(){var a;return a=this.atLast()?0:this.activeCard+1,this.activate(a)},find:function(a){return _(this.components).detect(function(b){return b.name===a})},activate:function(
4
+ a,b,c){var d,e,f,g=this;b==null&&(b=!1),_.isFunction(b)&&(b=!1,c=b);if(a===this.activeCard)return;f=this.activeComponent(),e=this.getComponent(a);if(e==null){a=this.indexOf(a);if(!(e=this.getComponent(a)))return}b!==!0&&(this.trigger("before:card:switch",f,e),f!=null&&f.trigger("before:deactivation",this,f,e),e!=null&&e.trigger("before:activation",this,f,e),_.defer(function(){return g.$el.data(g.activeAttribute||"active-card",e.name)})),this.componentElements().hide(),e.previously_activated!==!0&&(e.rendered===!0?e.trigger("first:activation"):e.once("after:render",function(){return e.rendered=!0,e.trigger("first:activation")}),e.previously_activated=!0),this.activeCard=a,this.activeComponentElement().show(),b!==!0&&(this.trigger("after:card:switch",f,e),f!=null&&f.trigger("deactivation",this,f,e),e!=null&&e.trigger("activation",this,f,e)),d=this,Luca.containers.CardView.activationContext==="current"&&(d=e);if(_.isFunction(c))return c.apply(d,[this,f,e])}}),a.privateMethods({initialize:function(a){return this.options=a,this.components||(this.components=this.pages||(this.pages=this.cards)),Luca.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks),this.defer(this.simulateActivationEvent,this).until("after:render")},simulateActivationEvent:function(){var a;a=this.activeComponent();if(a!=null&&(this.visible||this.$el.is(":visible"))){a!=null&&a.trigger("activation",this,a,a);if(!a.previously_activated)return a.trigger("first:activation"),a.previously_activated=!0}},prepareComponents:function(){var a;return(a=Luca.Container.prototype.prepareComponents)!=null&&a.apply(this,arguments),this.componentElements().hide(),this.activeComponentElement().show()},activeComponentElement:function(){return this.componentElements().eq(this.activeCard)},activeComponent:function(){return this.getComponent(this.activeCard)},customizeContainerEl:function(a,b,c){return a.style+=c===this.activeCard?"display:block;":"display:none;",a},firstActivation:function(){var a;if(a=this.activeComponent())return a.trigger("first:activation",this,this.activeComponent())}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.containers.ModalView"),a["extends"]("Luca.Container"),a.publicConfiguration({closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,className:"modal"}),a.publicMethods({container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")},render:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.containers.PageController"),a["extends"]("Luca.Container"),a.privateMethods({initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},this.components||(this.components=this.pages||this.options.pages),e=this.components;for(c=0,d=e.length;c<d;c++)b=e[c],b.components||(b.components=b.pages);return Luca.Container.prototype.initialize.apply(this,arguments)}}),a.register()}.call(this),function(){var a,b,c,d;c=Luca.register("Luca.PanelToolbar"),c["extends"]("Luca.View"),c.defines({buttons:[],orientation:"top",autoBindEventHandlers:!0,events:{"click a.btn, click .dropdown-menu li":"clickHandler"},initialize:function(a){var b;this.options=a!=null?a:{},this._super("initialize",this,arguments);if(this.group===!0&&((b=this.buttons)!=null?b.length:void 0)>=0)return this.buttons=[{group:!0,buttons:this.buttons}]},clickHandler:function(a){var b,c,d,e,f;d=e=$(a.target),d.is("i")&&(d=e=$(a.target).parent()),this.selectable===!0&&(e.siblings().removeClass("is-selected"),d.addClass("is-selected"));if(!(b=e.data("eventid")))return;return c=Luca.util.hook(b),f=this.parent||this,_.isFunction(f[c])?f[c].call(this,d,a):f.trigger(b,d,a)},beforeRender:function(){this._super("beforeRender",this,arguments),this.well===!0&&this.$el.addClass("well"),this.selectable===!0&&this.$el.addClass("btn-selectable"),this.$el.addClass("toolbar-"+this.orientation),this.align==="right"&&this.$el.addClass("pull-right");if(this.align==="left")return this.$el.addClass("pull-left")},render:function(){var a,b,c,e;this.$el.empty(),e=d(this.buttons);for(b=0,c=e.length;b<c;b++)a=e[b],this.$el.append(a);return this}}),b=Luca.View.prototype.make,a=function(a,c){var e,f,g,h,i,j,k,l,m,n,o,p;c==null&&(c=!0);if(a.ctype!=null||a.type!=null){a.className||(a.className=""),a.className+="toolbar-component",n=Luca(a).render();if(Luca.isBackboneView(n))return n.$el}return a.spacer?b("div",{"class":"spacer "+a.spacer}):a.text?b("div",{"class":"toolbar-text"},a.text):(p="btn-group",a.wrapper!=null&&(p+=""+a.wrapper),a.align!=null&&(p+="pull-"+a.align+" align-"+a.align),a.selectable===!0&&(p+="btn-selectable"),a.group!=null&&a.buttons!=null?(h=d(a.buttons,!1),b("div",{"class":p},h)):(l=a.label||(a.label=""),a.eventId||(a.eventId=_.string.dasherize(a.label.toLowerCase())),a.icon&&(_.string.isBlank(l)&&(l=" "),a.white&&(o="icon-white"),l="<i class='"+(o||"")+" icon-"+a.icon+"' /> "+l),f={"class":_.compact(["btn",a.classes,a.className]).join(" "),"data-eventId":a.eventId,title:a.title||a.description},a.color!=null&&(f["class"]+=" btn-"+a.color),a.selected!=null&&(f["class"]+=" is-selected"),a.dropdown&&(l=""+l+" <span class='caret'></span>",f["class"]+=" dropdown-toggle",f["data-toggle"]="dropdown",k=function(){var c,d,e,f;e=a.dropdown,f=[];for(c=0,d=e.length;c<d;c++)j=e[c],_.isObject(j)&&(j=_.values(j).reverse()),m=b("a",{},j[1]),f.push(b("li",{"data-eventId":j[0]},m));return f}(),i=b("ul",{"class":"dropdown-menu"},k)),g=b("a",f,l),e="btn-group",a.align!=null&&(e+=" align-"+a.align),c===!0?b("div",{"class":e},[g,i]):g))},d=function(b,c){var d,e,f,g;b==null&&(b=[]),c==null&&(c=!0),g=[];for(e=0,f=b.length;e<f;e++)d=b[e],g.push(a(d,c));return g}}.call(this),function(){var a;a=Luca.register("Luca.containers.TabView"),a["extends"]("Luca.containers.CardView"),a.triggers("before:select","after:select"),a.publicConfiguration({tab_position:"top",tabVerticalOffset:"50px"}),a.privateConfiguration({additionalClassNames:"tabbable",navClass:"nav-tabs",bodyTemplate:"containers/tab_view",bodyClassName:"tab-content",skipGetterMethods:!0}),a.defines({initialize:function(a){return this.options=a!=null?a:{},this.navStyle==="list"&&(this.navClass="nav-list"),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,b;(b=Luca.containers.CardView.prototype.afterRender)!=null&&b.apply(this,arguments),a=this.tabContainer().attr("id"),this.registerEvent("click #"+a+" li a","tabSelectClickHandler");if(Luca.config.enableBootstrap&&(this.tab_position==="left"||this.tab_position==="right"))return this.tabContainerWrapper().addClass("span2"),this.tabContentWrapper().addClass("span9")},createTabSelectors:function(){return a=this,this.each(function(b,c){var d,e,f,g;b.tabIcon&&(d="<i class='icon-"+b.tabIcon+"'></i>"),e="<a href='#'>"+(d||"")+" "+b.title+"</a>",f=a.make("li",{"class":"tab-selector","data-target":c},e),a.tabContainer().append(f);if(b.navHeading!=null&&((g=a.navHeadings)!=null?!g[b.navHeading]:!void 0))return $(f).before(a.make("li",{"class":"nav-header"},b.navHeading)),a.navHeadings||(a.navHeadings={}),a.navHeadings[b.navHeading]=!0})},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},tabSelectClickHandler:function(a){var b,c,d;return a!=null&&a.preventDefault(),b=c=$(a.target),b=c||(c=this.tabSelectors()[0]),d=c.parent().data("target"),this.select(d)},select:function(a){return a==null&&(a=0),this.trigger("before:select",this),this.activate(a),this.trigger("after:select",this)},componentElements:function(){return this.$(">.tab-content >."+this.componentClass)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return this.$("ul."+this.navClass,this.tabContainerWrapper())},tabSelectors:function(){return this.$("li.tab-selector",this.tabContainer())},bodyTemplateVars:function(){return{cid:this.cid,navClass:this.navClass}}})}.call(this),function(){var a;a=Luca.register("Luca.containers.Viewport"),a["extends"]("Luca.Container"),a.defines({fullscreen:!0,fluid:!1,applyWrapper:!0,initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),Luca.config.enableBoostrap===!0&&this.applyWrapper===!0&&(this.wrapperClass=this.fluid===!0?Luca.config.fluidWrapperClass:Luca.config.wrapperClass),Luca.Container.prototype.initialize.apply(this,arguments);if(this.fullscreen===!0)return this.enableFullscreen()},enableFluid:function(){return this.enableWrapper()},disableFluid:function(){return this.disableWrapper()},enableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().addClass(this.wrapperClass)},disableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().removeClass(this.wrapperClass)},enableFullscreen:function(){return $("html,body").addClass("luca-ui-fullscreen"),this.$el.addClass("fullscreen-enabled")},disableFullscreen:function(){return $("html,body").removeClass("luca-ui-fullscreen"),this.$el.removeClass("fullscreen-enabled")},beforeRender:function(){var a;(a=Luca.Container.prototype.beforeRender)!=null&&a.apply(this,arguments),this.topNav!=null&&this.renderTopNavigation();if(this.bottomNav!=null)return this.renderBottomNavigation()},height:function(){return this.$el.height()},width:function(){return this.$el.width()},afterRender:function(){var a;(a=Luca.Container.prototype.afterRender)!=null&&a.apply(this,arguments);if(Luca.config.enableBoostrap===!0&&this.containerClassName)return this.$el.children().wrap('<div class="#{ containerClassName }" />')},renderTopNavigation:function(){var a;if(this.topNav==null)return;return _.isString(this.topNav)&&(this.topNav=Luca.util.lazyComponent(this.topNav)),_.isObject(this.topNav)&&((a=this.topNav).ctype||(a.ctype=this.topNav.type||"nav_bar"),Luca.isBackboneView(this.topNav)||(this.topNav=Luca.util.lazyComponent(this.topNav))),this.topNav.app=this,$("body").prepend(this.topNav.render().el)},renderBottomNavigation:function(){}}),Luca.containers.Viewport.defaultWrapperClass=Luca.config.wrapperClass||"container",Luca.containers.Viewport.fluidWrapperClass=Luca.config.fluidWrapperClass||"container-fluid"}.call(this),function(){}.call(this),function(){var a;a=Luca.register("Luca.CollectionView"),a["extends"]("Luca.Panel"),a.replaces("Luca.components.CollectionView"),a.mixesIn("QueryCollectionBindings","LoadMaskable","Filterable","Paginatable","Sortable"),a.triggers("before:refresh","after:refresh","refresh","empty:results"),a.publicConfiguration({collection:void 0,tagName:"ol",bodyClassName:"collection-ui-panel",itemTagName:"li",itemClassName:"collection-item",itemTemplate:void 0,itemRenderer:void 0,itemProperty:void 0,observeChanges:!1}),a.publicMethods({initialize:function(a){var b,c;this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"refresh");if(this.collection==null&&!this.options.collection)throw console.log("Error on initialize of collection view",this),"Collection Views must specify a collection";if(this.itemTemplate==null&&this.itemRenderer==null&&this.itemProperty==null)throw"Collection Views must specify an item template or item renderer function";_.isString(this.collection)&&(Luca.CollectionManager.get()?this.collection=Luca.CollectionManager.get().getOrCreate(this.collection):console.log("String Collection but no collection manager"));if(!Luca.isBackboneCollection(this.collection))throw console.log("Missing Collection on "+(this.name||this.cid),this,this.collection),"Collection Views must have a valid backbone collection";this.on("data:refresh",this.refresh,this),this.on("collection:reset",this.refresh,this),this.on("collection:remove",this.refresh,this),this.on("collection:add",this.refresh,this),this.observeChanges===!0&&this.on("collection:change",this.refreshModel,this),Luca.Panel.prototype.initialize.apply(this,arguments),b=this;if(((c=this.getCollection())!=null?c.length:void 0)>0)return this.on("after:render",function(){return b.refresh(),b.unbind("after:render",this)})},locateItemElement:function(a){return this.$("."+this.itemClassName+"[data-model-id='"+a+"']")},refresh:function(){var a,b,c;return c=this.getLocalQuery(),b=this.getQueryOptions(),a=this.getModels(c,b),this.$bodyEl().empty(),this.trigger("before:refresh",a,c,b),a.length===0&&this.trigger("empty:results",c,b),this.renderModels(a,c,b),this.trigger("after:refresh",a,c,b),this}}),a.privateMethods({renderModels:function(a,b,c){var d,e,f,g,h;d=0,h=[];for(f=0,g=a.length;f<g;f++)e=a[f],h.push(this.$append(this.makeItem(e,d++)));return h},attributesForItem:function(a,b){return _.extend({},{"class":this.itemClassName,"data-index":a.index,"data-model-id":a.model.get("id")})},contentForItem:function(a){var b,c;return a==null&&(a={}),this.itemTemplate!=null&&(c=Luca.template(this.itemTemplate))?b=c.call(this,a):this.itemRenderer!=null&&_.isFunction(this.itemRenderer)?b=this.itemRenderer.call(this,a,a.model,a.index):this.itemProperty&&a.model!=null?b=a.model.read(this.itemProperty):""},makeItem:function(a,b){var c,d,e;e=this.prepareItem!=null?this.prepareItem.call(this,a,b):{model:a,index:b},c=this.attributesForItem(e,a),d=this.contentForItem(e);try{return Luca.View.prototype.make(this.itemTagName,c,d)}catch(f){return console.log("Error generating DOM element for CollectionView",this,a,b)}},refreshModel:function(a){var b;return b=this.collection.indexOf(a),this.locateItemElement(a.get("id")).empty().append(this.contentForItem({model:a,index:b},a)),this.trigger("model:refreshed",b,a)},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)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.SimpleCollectionView"),a["extends"]("Luca.CollectionView"),a.defines({filterable:!1,paginatable:!1,sortable:!1,loadMask:!1})}.call(this),function(){var a;a=Luca.register("Luca.components.GridLayoutView"),a["extends"]("Luca.CollectionView"),a.publicConfiguration({itemsPerRow:3}),a.privateConfiguration({className:"grid-layout-view",tagName:"div",itemTagName:"div"}),a.privateMethods({attributesForItem:function(){var a,b;return a=Luca.CollectionView.prototype.attributesForItem.apply(this,arguments),_.isNumber(this.itemsPerRow)&&this.itemsPerRow>1||(this.itemsPerRow=3),b=parseInt(12/this.itemsPerRow),a["class"]+=" span"+b,a},renderModels:function(a){var b,c,d,e,f,g,h,i;b=0,e=0,f=function(){var f,g,h;h=[];for(f=0,g=a.length;f<g;f++)c=a[f],e++===0&&(d=this.make("div",{"class":"row-fluid"})),$(d).append(this.makeItem(c,b++)),b>0&&b%this.itemsPerRow===0&&(e=0),h.push(d);return h}.call(this),i=[];for(g=0,h=f.length;g<h;g++)d=f[g],i.push(this.$append(d));return i}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.TableView"),a["extends"]("Luca.CollectionView"),a.publicConfiguration({widths:[],columns:[],emptyText:"There are no results to display"}),a.privateConfiguration({additionalClassNames:"table",tagName:"table",bodyTemplate:"table_view",bodyTagName:"tbody",bodyClassName:"table-body",stateful:!0,itemTagName:"tr",observeChanges:!0}),a.privateMethods({lastColumn:function(){return this.columns[this.columns.length-1]},eachColumn:function(a,b){var c,d,e,f,g,h;b==null&&(b=this),d=0,g=this.columns,h=[];for(e=0,f=g.length;e<f;e++)c=g[e],h.push(a.call(b,c,d++,this));return h},itemRenderer:function(a,b){return Luca.components.TableView.rowRenderer.call(this,a,b)},initialize:function(a){var b,c,d,e=this;return this.options=a!=null?a:{},Luca.components.CollectionView.prototype.initialize.apply(this,arguments),c=0,this.columns=function(){var a,e,f,g;f=this.columns,g=[];for(a=0,e=f.length;a<e;a++){b=f[a];if(d=this.widths[c])b.width=d;_.isString(b)&&(b={reader:b}),b.header==null&&(b.header=_.str.titleize(_.str.humanize(b.reader))),c++,g.push(b)}return g}.call(this),this.defer(function(){return Luca.components.TableView.renderHeader.call(e,e.columns,e.$("thead"))}).until("after:render")}}),a.classMethods({renderHeader:function(a,b){var c,d,e,f,g,h,i,j,k,l;f=0,this.$(b).append("<tr></tr>");for(h=0,j=a.length;h<j;h++)d=a[h],c={"data-col-index":f++},d.sortable&&(c["class"]="sortable-toggle",c["data-sortable-sort-by"]=d.sortBy||d.sortable,c["data-sortable-order"]=d.order),e=d.header,d.sortable&&(e="<a class='link'>"+d.header+"</a>"),this.$(b).find("tr").append(Luca.View.prototype.make("th",c,e));f=0,l=[];for(i=0,k=a.length;i<k;i++){d=a[i];if(d.width==null)continue;g=this.$("th[data-col-index='"+f++ +"']",b),l.push(g.css("width",d.width))}return l},rowRenderer:function(a,b,c){var d,e,f,g,h,i;d=0,h=this.columns,i=[];for(f=0,g=h.length;f<g;f++)e=h[f],i.push(Luca.components.TableView.renderColumn.call(this,e,a,b,d++));return i},renderColumn:function(a,b,c,d){var e;return e=c.read(a.reader),_.isFunction(a.renderer)&&(e=a.renderer.call(this,e,c,a)),Luca.View.prototype.make("td",{"data-col-index":d},e)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.MultiCollectionView"),a["extends"]("Luca.containers.CardView"),a.mixesIn("QueryCollectionBindings","LoadMaskable","Filterable","Paginatable","Sortable"),a.triggers("before:refresh","after:refresh","refresh","empty:results"),a["private"]({stateful:{activeView:0},initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},this.components||(this.components=this.views),e=this.components;for(c=0,d=e.length;c<d;c++)b=e[c],Luca.components.MultiCollectionView.validateComponent(b);return Luca.containers.CardView.prototype.initialize.apply(this,arguments),this.on("data:refresh",this.refresh,this),this.on("after:card:switch",this.refresh,this),this.on("after:components",Luca.components.MultiCollectionView.propagateCollectionComponents,this)},relayAfterRefresh:function(a,b,c){return this.trigger("after:refresh",a,b,c)},refresh:function(){var a;return(a=this.activeComponent())!=null?a.refresh():void 0}}),a.classMethods({propagateCollectionComponents:function(){var a,b,c,d,e,f,g=this;b=this,e=this.components,f=[];for(c=0,d=e.length;c<d;c++)a=e[c],a.on("after:refresh",function(a,b,c){return g.debug("collection member after refresh"),g.trigger("after:refresh",a,b,c)}),_.extend(a,{collection:b.getCollection(),getQuery:_.bind(b.getQuery,b),getQueryOptions:_.bind(b.getQueryOptions,b)}),b.prepareQuery!=null?f.push(_.extend(a,{prepareQuery:_.bind(b.prepareQuery,b)})):f.push(void 0);return f},validateComponent:function(a){var b;b=a.type||a.ctype;if(b==="collection"||b==="collection_view"||b==="table"||b==="table_view")return;throw"The MultiCollectionView expects to contain multiple collection views"}}),a.defines({version:3})}.call(this),function(){var a;a=Luca.register("Luca.components.ScrollableTable"),a["extends"]("Luca.components.TableView"),a.replaces("Luca.components.GridView"),a.publicConfiguration({maxHeight:void 0}),a.privateMethods({$scrollableWrapperEl:function(){return this.$el.parent(".scrollable-wrapper")},setMaxHeight:function(){var a;return a=this.$scrollableWrapperEl(),a.css({overflow:"auto","max-height":this.maxHeight})},afterRender:function(){return this.$wrap("scrollable-wrapper"),this.setMaxHeight()}}),a.defines({version:1})}.call(this),function(){var a,b=[].slice;a=Luca.register("Luca.Application"),a["extends"]("Luca.containers.Viewport"),a.triggers("controller:change","action:change"),a.publicConfiguration({name:"MyApp",stateful:{},autoBoot:!1,autoStartHistory:"before:render",pushState:!1,startHistorySilently:!1,rootUrl:void 0,useCollectionManager:!0,collectionManager:{},collectionManagerClass:"Luca.CollectionManager",plugin:!1,useController:!0,mainControllerContainer:void 0,keyEvents:{},createRoleBasedGetters:!1,useSocketManager:!1,socketManagerOptions:{}}),a.publicMethods({initialize:function(a){var b,c,d,e=this;this.options=a!=null?a:{},c=this,d=this.name,b=typeof Luca.getApplication=="function"?Luca.getApplication():void 0,Luca.Application.registerInstance(this),Luca.concerns.StateModel.__initializer.call(this),this.setupCollectionManager(),this.setupSocketManager(),Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.useController===!0&&this.setupMainController(),this.defer(function(){return c.render()}).until(this,"ready"),this.setupRouter(),(this.useKeyHandler===!0||this.useKeyRouter===!0)&&this.keyEvents!=null&&this.setupKeyHandler(),this.plugin!==!0&&!b&&(Luca.getApplication=function(a){return a==null?c:Luca.Application.instances[a]});if(this.autoBoot){if(Luca.util.resolve(this.name))throw"Attempting to override window."+this.name+" when it already exists";$(function(){return window[d]=c,c.boot()})}return Luca.trigger("application:available",this)},activeView:function(){var a;return(a=this.activeSubSection())?this.view(a):this.view(this.activeSection())},activeSection:function(){return this.get("active_section")},activeSubSection:function(){return this.get("active_sub_section")},activePages:function(){var a=this;return console.log("This method will be getting removed in Luca 1.0"),this.$(".luca-controller").map(function(a,b){return $(b).data("active-section")})},boot:function(){var a,b,c,d,e;this.trigger("ready"),d=[this.collectionManager,this.socket,this.router],e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a!=null?a.trigger("ready"):void 0);return e},collection:function(){return this.collectionManager.getOrCreate.apply(this.collectionManager,arguments)},get:function(a){return this.state.get(a)},set:function(a,b,c){return this.state.set.apply(this.state,arguments)},view:function(a){return Luca.cache(a)},navigate_to:function(a,b){return this.getMainController().navigate_to(a,b)}}),a.privateMethods({setupControllerBindings:function(){var a,b,c,d=this;return a=this,(b=this.getMainController())!=null&&b.bind("after:card:switch",function(b,c){return d.state.set({active_section:c.name}),a.trigger("controller:change",b.name,c.name)}),(c=this.getMainController())!=null?c.each(function(b){var c;c=b.type||b.ctype;if(c.match(/controller$/))return b.bind("after:card:switch",function(b,c){return d.state.set({active_sub_section:c.name}),a.trigger("action:change",b.name,c.name)})}):void 0},setupMainController:function(){var a,b,c=this;return this.useController===!0&&(b=this.components||[],a={type:"controller",name:"main_controller",role:"main_controller",components:b},this.mainControllerContainer!=null&&_.extend(a,{container:this.mainControllerContainer}),this.components=[a]),this.getMainController=function(){return c.findComponentByRole("main_controller")},this.defer(this.setupControllerBindings,!1).until("after:components")},setupCollectionManager:function(){var a,b,c,d,e;if(this.useCollectionManager!==!0)return;if(this.collectionManager!=null&&((c=this.collectionManager)!=null?c.get:void 0)!=null)return;_.isString(this.collectionManagerClass)&&(this.collectionManagerClass=Luca.util.resolve(this.collectionManagerClass)),a=this.collectionManagerOptions||{},_.isObject(this.collectionManager)&&!_.isFunction((d=this.collectionManager)!=null?d.get:void 0)&&(a=this.collectionManager,this.collectionManager=void 0),_.isString(this.collectionManager)&&(a={name:this.collectionManager}),this.collectionManager=typeof (b=Luca.CollectionManager).get=="function"?b.get(a.name):void 0;if(!_.isFunction((e=this.collectionManager)!=null?e.get:void 0))return a.autoStart=!1,this.collectionManager=new this.collectionManagerClass(a)},setupSocketManager:function(){if(_.isEmpty(this.socketManagerOptions))return;return _.extend(this.socketManagerOptions,{autoStart:!1}),this.socket=new Luca.SocketManager(this.socketManagerOptions)},setupRouter:function(){var a,b,c,d,e,f,g,h,i,j;if(this.router==null&&this.routes==null)return;f=Luca.Router,_.isString(this.router)&&(f=Luca.util.resolve(this.router)),g=f.prototype,g.routes||(g.routes={}),g.app=this;if(_.isObject(this.routes)){h=this.routes;for(e in h)b=h[e],b.match(/\ /)?(i=b.split(" "),d=i[0],a=i[1]):b.match(/\#/)&&(j=b.split("#"),d=j[0],a=j[1]),c=_.uniqueId(d),g[c]=Luca.Application.routeTo(d).action(a),g.routes[e]=c}this.router=new f(g);if(this.router&&this.autoStartHistory)return this.autoStartHistory===!0&&(this.autoStartHistory="before:render"),this.defer(Luca.Application.startHistory,!1).until(this,this.autoStartHistory)},setupKeyHandler:function(){var a,b,c,d,e,f,g;if(!this.keyEvents)return;(c=this.keyEvents).control_meta||(c.control_meta={}),this.keyEvents.meta_control&&_.extend(this.keyEvents.control_meta,this.keyEvents.meta_control),a=_.bind(this.keyHandler,this),f=this.keypressEvents||["keydown"],g=[];for(d=0,e=f.length;d<e;d++)b=f[d],g.push($(document).on(b,a));return g}}),a.classMethods({instances:{},pageHierarchy:function(){var a,b,c;return a=Luca(),c=a.getMainController(),b=function(a){return a.components==null&&a.pages==null?{}:_(a.components||a.pages).reduce(function(a,c){return a[c.name]=c.name,c.navigate_to!=null&&(a[c.name]=b(c)),a},{})},b(c)},registerInstance:function(a){return Luca.Application.instances[a.name]=a},checkForKeymaster:function(){var a;if(typeof window!="undefined"&&window!==null?(a=window.key)!=null?a.noConflict:void 0:void 0)return Luca.key=window.key.noConflict(),Luca.Application.prototype.setupKeyHandler=function(){if(!this.keyEvents)return;return Luca.util.setupKeymaster(this.keyEvents,"all").on(this)}},routeTo:function(){var a,c,d,e,f,g;return e=1<=arguments.length?b.call(arguments,0):[],d=_(e).last(),c=_(e).first(),a=void 0,g=void 0,f=function(){var f,h,i,j,k,l,m,n,o,p;h=1<=arguments.length?b.call(arguments,0):[],l=this.app||Luca(),i=0,e.length===1&&(m=Luca(c))&&(e=m.controllerPath()),p=[];for(n=0,o=e.length;n<o;n++){k=e[n];if(!_.isString(k))continue;j=e[++i],m=Luca(k),k===d&&(g!=null&&m[g]==null&&m.routeHandler==null&&console.log("You specified a component action to call when a route matches, but it does not exist on the component"),a=g!=null&&m[g]!=null?_.bind(m[g],m):m.routeHandler!=null?m.routeHandler:void 0),a||(a=_.isFunction(j)?_.bind(j,m):_.isObject(j)?(f=j.action&&m[f]!=null)?_.bind(m[f],m):void 0:void 0),p.push(l=l.navigate_to(k,function(){return a!=null?a.apply(m,h):void 0}))}return p},f.action=function(a){return g=a,f},f},startHistory:function(){return Backbone.history.start({pushState:this.pushState,rootUrl:this.rootUrl,silent:this.startHistorySilently})}}),a.afterDefinition(function(){return Luca.routeHelper=Luca.Application.routeTo,Luca.Application.checkForKeymaster()}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.CollectionLoaderView"),a["extends"]("Luca.View"),a.defines({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.register("Luca.components.Controller"),a["extends"]("Luca.containers.CardView"),a.publicConfiguration({tracker:"page",activeAttribute:"active-section",stateful:!0,defaultPage:void 0,defaultCard:0}),a.publicMethods({"default":function(a){return this.navigate_to(this.defaultPage||this.defaultCard,a)},activePage:function(){return this.activeSection()},navigate_to:function(a,b){var c=this;return a||(a=this.defaultCard),this.activate(a,!1,function(a,d,e){var f,g;e.activatedByController===!0?e.trigger("on:controller:reactivation"):(e.trigger("on:controller:activation"),e.activatedByController=!0),c.state.set({active_section:e.name}),c.tracker!=null&&(f=c.app||(typeof Luca.getApplication=="function"?Luca.getApplication():void 0))&&f.state.set(c.tracker,e.name),(g=Luca.key)!=null&&g.setScope(e.name);if(_.isFunction(b))return b.call(e)}),this.find(a)}}),a.classMethods({setupComponentKeyEvents:function(){return this._().each(function(a){if(_.isObject(a.keyEvents)&&a.name!=null)return Luca.util.setupKeymaster(a.keyEvents,a.name).on(a)})},controllerPath:function(){var a,b,c;b=this,c=[b.name],a=!1;while(b&&!a)b=typeof b.getParent=="function"?b.getParent():void 0,(b!=null?b.role:void 0)==="main_controller"&&(a=!0),b!=null&&!a&&c.push(b.name);return c.reverse()}}),a.afterDefinition(function(){return Luca.View.prototype.hooks.push("on:controller:activation")}),a.defines({initialize:function(a){var b;this.options=a,this.defaultCard||(this.defaultCard=this.defaultPage||(this.defaultPage=((b=this.components[0])!=null?b.name:void 0)||0)),this.defaultPage||(this.defaultPage=this.defaultCard),this.defaultState||(this.defaultState={active_section:this.defaultPage}),Luca.containers.CardView.prototype.initialize.apply(this,arguments);if(this.defaultCard==null)throw"Controllers must specify a defaultCard property and/or the first component must have a name";return this._().each(function(a){return a.controllerPath=Luca.components.Controller.controllerPath}),this.on("after:render",this["default"],this),this.on("before:render",Luca.components.Controller.setupComponentKeyEvents,this)},each:function(a){var b=this;return _(this.components).each(function(c){return a.call(b,c)})},activeSection:function(){return this.get("active_section")},pageControllers:function(a){return a==null&&(a=!1),this.controllers.apply(this,arguments)},controllers:function(a){return a==null&&(a=!1),this.select(function(a){var b;return b=a.type||a.ctype,b==="controller"||b==="page_controller"})},availablePages:function(){return this.availableSections.apply(this,arguments)},availableSections:function(){var a,b=this;return console.log("The availableSections()/availablePages() method will be removed in 1.0"),a={},a[this.name]=this.sectionNames(),_(this.controllers()).reduce(function(a,b){return a[b.name]=b.sectionNames(),a},a)},pageNames:function(){return this.sectionNames()},sectionNames:function(a){return a==null&&(a=!1),this.pluck("name")}})}.call(this),function(){var a;a=Luca.register("Luca.core.Field"),a["extends"]("Luca.View"),a.triggers("before:validation","after:validation","on:change"),a.publicConfiguration({className:"luca-ui-field",disabled:void 0,helperText:void 0,label:void 0,labelAlign:"top",placeHolder:void 0,required:void 0,statuses:["warning","error","success"],valueType:"string"}),a.publicMethods({disable:function(){return this.getInputElement().attr("disabled",!0)},enable:function(){return this.getInputElement().attr("disabled",!1)},getValue:function(){var a,b;return a=(b=this.getInputElement())!=null?b.val():void 0,this.getParsedValue(a)},setValue:function(a){var b;return(b=this.getInputElement())!=null?b.val(a):void 0},updateState:function(a){var b,c,d,e;e=this.statuses;for(c=0,d=e.length;c<d;c++)b=e[c],this.$el.removeClass(b);return this.$el.addClass(a)},clearErrors:function(){return this.$el.removeClass("error")},displayErrors:function(a){return this.updateState("error")}}),a.privateMethods({getParsedValue:function(a){if(_.str.isBlank(a))return a;switch(this.valueType){case"integer":return parseInt(a);case"string":return""+a;case"float":return parseFloat(a);default:return a}}}),a.privateConfiguration({isField:!0,template:"fields/text_field"}),a.privateMethods({initialize:function(a){var b;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.input_type||(this.input_type=""),this.helperText||(this.helperText=""
5
+ );if(this.label==null||this.label.length===0)this.label=this.name;return this.required&&((b=this.label)!=null?!b.match(/^\*/):!void 0)&&(this.label||(this.label="*"+this.label)),this.inputStyles||(this.inputStyles=""),this.input_value||(this.input_value=this.value||""),this.disabled&&this.disable(),this.updateState(this.state),this.placeHolder||(this.placeHolder=""),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){Luca.config.enableBoostrap&&this.$el.addClass("control-group");if(this.required)return this.$el.addClass("required")},change_handler:function(a){return this.trigger("on:change",this,a)},getInputElement:function(){return this.input||(this.input=this.$("input").eq(0))}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.fields.ButtonField"),a["extends"]("Luca.core.Field"),a.triggers("button:click"),a.publicConfiguration({buttonSize:void 0,"class":void 0,icon_class:void 0,label:void 0,text:void 0,white:!1}),a.privateConfiguration({readOnly:!0,input_value:void 0,input_type:"button",icon_class:void 0,input_name:void 0,buttonClasses:""}),a.privateConfiguration({isButton:!0,autoBindEventHandlers:!0,template:"fields/button_field",events:{"click input":"clickHandler"}}),a.privateMethods({clickHandler: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,this.options),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(){var a;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_class||(this.input_class=this["class"]||(this["class"]=this.buttonClasses)),((a=this.buttonSize)!=null?a.length:void 0)>0&&(this.input_class+=" "+buttonSize.replace(/btn-/,"")),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}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.fields.CheckboxArray"),a["extends"]("Luca.core.Field"),a.privateConfiguration({template:"fields/checkbox_array",className:"luca-ui-checkbox-array",events:{"click input":"clickHandler"},selectedItems:[]}),a.privateMethods({initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.concerns.Deferrable),_.bindAll(this,"renderCheckboxes","clickHandler","checkSelected"),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")},afterInitialize:function(a){var b;this.options=a!=null?a:{};try{this.configure_collection()}catch(c){console.log("Error Configuring Collection",this,c.message)}b=this;if(!Luca.isBackboneCollection(this.collection))throw"Checkbox Array Fields must specify a @collection property";return this.collection.length>0?this.renderCheckboxes():this.defer("renderCheckboxes").until(this.collection,"reset")},clickHandler:function(a){var b;b=$(a.target);if(b.prop("checked"))return this.selectedItems.push(b.val());if(_(this.selectedItems).include(b.val()))return this.selectedItems=_(this.selectedItems).without(b.val())},controls:function(){return this.$(".controls")},renderCheckboxes:function(){var a=this;return this.controls().empty(),this.selectedItems=[],this.collection.each(function(b){var c,d,e,f,g;return g=b.get(a.valueField),f=b.get(a.displayField),e=_.uniqueId(""+a.cid+"_checkbox"),d=a.make("input",{type:"checkbox","class":"array-checkbox",name:a.input_name,value:g,id:e}),c=a.make("label",{"for":e},d),$(c).append(" "+f),a.controls().append(c)}),this.trigger("checkboxes:rendered",this.checkboxesRendered=!0),this},uncheckAll:function(){return this.allFields().prop("checked",!1)},allFields:function(){return this.controls().find("input[type='checkbox']")}}),a.publicMethods({checkSelected:function(a){var b,c,d,e,f;a!=null&&(this.selectedItems=a),this.uncheckAll(),f=this.selectedItems;for(d=0,e=f.length;d<e;d++)c=f[d],b=this.controls().find("input[value='"+c+"']"),b.prop("checked",!0);return this.selectedItems},getValue:function(){var a,b,c,d,e;d=this.allFields(),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],this.$(a).prop("checked")&&e.push(this.$(a).val());return e},setValue:function(a){var b;return this.selectedItems=a,this.checkboxesRendered===!0?this.checkSelected(a):(b=this,this.defer(function(){return b.checkSelected(a)}).until("checkboxes:rendered"))},getValues:function(){return this.getValue()},setValues:function(a){return this.setValue(a)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.CheckboxField"),a["extends"]("Luca.core.Field"),a.triggers("checked","unchecked"),a.publicConfiguration({send_blanks:!0,input_value:1}),a.privateConfiguration({template:"fields/checkbox_field",events:{"change input":"change_handler"}}),a.privateInterface({change_handler:function(a){var b,c;return b=c=$(a.target),b.is(":checked")?this.trigger("checked"):this.trigger("unchecked"),this.trigger("on:change",this,a,b.is(":checked"))},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),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name)}}),a.publicInterface({setValue:function(a){return this.getInputElement().attr("checked",a)},getValue:function(){return this.getInputElement().is(":checked")}}),a.defines({version:1})}.call(this),function(){var a;a=Luca.register("Luca.fields.FileUploadField"),a["extends"]("Luca.core.Field"),a.defines({version:1,template:"fields/file_upload_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),this.helperText||(this.helperText="")}})}.call(this),function(){var a;a=Luca.register("Luca.fields.HiddenField"),a["extends"]("Luca.core.Field"),a.defines({template:"fields/hidden_field",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(){var a;a=Luca.register("Luca.components.LabelField"),a["extends"]("Luca.core.Field"),a.defines({formatter:function(a){return a||(a=this.getValue()),_.str.titleize(a)},setValue:function(a){return this.trigger("change",a,this.getValue()),this.getInputElement().attr("value",a),this.$(".value").html(this.formatter(a))}})}.call(this),function(){var a;a=Luca.register("Luca.fields.SelectField"),a["extends"]("Luca.core.Field"),a.triggers("after:select","on:change"),a.publicConfiguration({allowMultiple:!1,includeBlank:!0,blankValue:"",blankText:"Select One",maxDisplayLength:0,retainValue:void 0,label:void 0}),a.privateConfiguration({template:"fields/select_field",events:{"change select":"change_handler"}}),a.publicMethods({setValue:function(a){return this.currentValue=a,Luca.core.Field.prototype.setValue.apply(this,arguments)},getValue:function(){var a,b,c=this;return a=(b=this.getInputElement())!=null?b.val():void 0,this.allowMultiple?_.map(a,function(a){return c.getParsedValue(a)}):this.getParsedValue(a)}}),a.privateMethods({initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.concerns.Deferrable),_.bindAll(this,"change_handler"),_.isArray(this.collection)&&(this.collection={data:this.collection}),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.valueField==="id"&&(this.valueType||(this.valueType=Luca.config.idAttributeType)),this.label||(this.label=this.name);if(this.retainValue==null)return this.retainValue=!0},afterInitialize:function(){var a,b,c;if((a=this.collection)!=null?a.data:void 0)this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.sortOptionsBy||(this.sortOptionsBy=this.displayField),this.parseData();try{this.configure_collection(this.setAsDeferrable)}catch(d){console.log("Error Configuring Collection",this,d.message)}return(b=this.collection)!=null&&b.bind("before:fetch",this.beforeFetch,this),(c=this.collection)!=null?c.bind("reset",this.populateOptions,this):void 0},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]||b[0],c):b})},getInputElement:function(){return this.input||(this.input=this.$("select").eq(0))},afterRender:function(){var a,b,c;return((a=this.collection)!=null?(b=a.models)!=null?b.length:void 0:void 0)>0?this.populateOptions():(c=this.collection)!=null?c.trigger("reset"):void 0},beforeFetch:function(){return this.resetOptions()},change_handler:function(a){return this.trigger("on:change",this,a)},resetOptions:function(){this.getInputElement().html("");if(this.allowMultiple)return this.getInputElement().attr({multiple:!0});if(this.includeBlank)return this.getInputElement().append("<option value='"+this.blankValue+"'>"+this.blankText+"</option>")},populateOptions:function(){var a,b,c,d,e,f,g,h,i,j=this;this.resetOptions();if(((i=this.collection)!=null?i.length:void 0)>0){this.sortOptionsBy!=null?c=this.collection.sortBy(function(a){return a.read!=null?a.read(j.sortOptionsBy):a.get(j.sortOptionsBy)}):c=this.collection.models;for(g=0,h=c.length;g<h;g++)b=c[g],f=(typeof b.read=="function"?b.read(this.valueField):void 0)||b.get(this.valueField),a=(typeof b.read=="function"?b.read(this.displayField):void 0)||b.get(this.displayField),this.maxDisplayLength&&this.maxDisplayLength>0&&(a=_.str.truncate(a,this.maxDisplayLength)),this.selected&&f===this.selected&&(e="selected"),d="<option "+e+" value='"+f+"'>"+a+"</option>",this.getInputElement().append(d)}return this.trigger("after:populate:options",this),this.setValue(this.currentValue)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.fields.TextAreaField"),a["extends"]("Luca.core.Field"),a.defines({autoBindEventHandlers:!0,events:{"blur textarea":"blur_handler","focus textarea":"focus_handler"},template:"fields/text_area_field",height:"200px",width:"90%",keyEventThrottle:300,initialize:function(a){this.options=a!=null?a:{},this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=""),this.inputStyles||(this.inputStyles="height:"+this.height+";width:"+this.width),this.placeHolder||(this.placeHolder=""),Luca.core.Field.prototype.initialize.apply(this,arguments);if(this.enableKeyEvents===!0)return this.keyup_handler=_.debounce(this.keyup_handler,this.keyEventThrottle||10),console.log("Registering Key Events"),this.registerEvent("keyup textarea","keyup_handler"),this.registerEvent("keydown textarea","keyup_handler")},setValue:function(a){return $(this.field()).val(a)},getValue:function(){return $(this.field()).val()},field:function(){return this.input=this.$("textarea")},keyup_handler:function(a){return this.trigger("on:change",this,a),this.trigger("on:keyup",this,a)},blur_handler:function(a){return this.trigger("on:blur",this,a)},focus_handler:function(a){return this.trigger("on:focus",this,a)},change_handler:function(a){return this.trigger("on:change",this,a)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.TextField"),a["extends"]("Luca.core.Field"),a.defines({_inheritEvents:{"blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",autoBindEventHandlers:!0,send_blanks:!0,keyEventThrottle:300,initialize:function(a){return this.options=a!=null?a:{},this.enableKeyEvents&&(this.keyEventThrottle&&(this.keyup_handler=_.debounce(this.keyup_handler,this.keyEventThrottle)),this.registerEvent("keyup input","keyup_handler")),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=this.value||""),this.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend),this.append&&(this.$el.addClass("input-append"),this.addOn=this.append),this.placeHolder||(this.placeHolder=""),Luca.core.Field.prototype.initialize.apply(this,arguments)},keyup_handler:function(a){return this.trigger("on:change",this,a),this.trigger("on:keyup",this,a)},blur_handler:function(a){return this.trigger("on:blur",this,a)},focus_handler:function(a){return this.trigger("on:focus",this,a)},change_handler:function(a){return this.trigger("on:change",this,a)}})}.call(this),function(){var a;a=Luca.register("Luca.fields.TypeAheadField"),a["extends"]("Luca.fields.TextField"),a.defines({getSource:function(){return Luca.util.read(this.source)||[]},matcher:function(a){return!0},beforeRender:function(){return Luca.fields.TextField.prototype.beforeRender.apply(this,arguments),this.getInputElement().attr("data-provide","typeahead")},afterRender:function(){return Luca.fields.TextField.prototype.afterRender.apply(this,arguments),this.getInputElement().typeahead({matcher:this.matcher,source:this.getSource()})}})}.call(this),function(){var a;a=Luca.register("Luca.components.FormView"),a["extends"]("Luca.Container"),a.mixesIn("LoadMaskable","FormModelBindings"),a.triggers("before:submit","before:reset","before:load","before:load:new","before:load:existing","after:submit","after:reset","after:load","after:load:new","after:load:existing","after:submit:success","after:submit:fatal_error","after:submit:error","state:change:dirty"),a.publicConfiguration({trackDirtyState:!1,trackModelChanges:!1,labelAlign:void 0,fieldLayoutClass:void 0,legend:"",toolbar:!0,toolbarConfig:void 0,defaultToolbar:"Luca.components.FormView.defaultToolbar",loadMask:!0,well:!1,searchForm:!1,horizontalForm:!1,inlineForm:!1,includeBlankValues:void 0}),a.privateConfiguration({tagName:"form",_inheritEvents:{"click .submit-button":"submitHandler","click .reset-button":"resetHandler"},bodyClassName:"form-view-body",stateful:{dirty:!1,currentModel:void 0}}),a.privateMethods({initialize:function(a){var b,c,d,e;this.options=a!=null?a:{},c=this,this.loadMask==null&&(this.loadMask=Luca.config.enableBoostrap),Luca.Container.prototype.initialize.apply(this,arguments),this.components||(this.components=this.fields),_.bindAll(this,"submitHandler","resetHandler","renderToolbars"),e=this._inheritEvents;for(b in e)d=e[b],this.registerEvent(b,d);return this.trackDirtyState===!0&&this.on("after:components",function(){var a,b,d,e,f;e=this.getFields(),f=[];for(b=0,d=e.length;b<d;b++)a=e[b],f.push(a.on("on:change",this.onFieldChange,c));return f},c),this.setupHooks(this.hooks),this.applyStyleClasses(),Luca.components.FormView.setupToolbar.call(this)},onFieldChange:function(a,b){return this.trigger("field:change",a,b),this.state.set("dirty",!0)},getDefaultToolbar:function(){var a;return a=this.toolbarConfig||this.defaultToolbar,Luca.util.resolve(Luca.util.read(a))},applyStyleClasses:function(){Luca.config.enableBoostrap&&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,d;b=c=$(a!=null?a.target:void 0);if(this.beforeReset!=null){d=this.beforeReset();if(d===!1)return}return this.reset(),this.trigger("after:reset",this)},submitHandler:function(a){var b;if(this.beforeSubmit!=null){b=this.beforeSubmit();if(b===!1)return}else this.trigger("before:submit",this);this.loadMask===!0&&this.trigger("enable:loadmask",this);if(this.hasModel())return this.submit()},afterComponents:function(){var a,b;return(b=Luca.Container.prototype.afterComponents)!=null&&b.apply(this,arguments),a=this,this.eachField(function(b){var c=this;return b.getForm=function(){return a},b.getModel=function(){return a.currentModel()}})},eachField:function(a){return _(this.getFields()).map(a)},getField:function(a){var b;return b=_(this.getFields("name",a)).first(),b!=null?b:_(this.getFields("input_name",a)).first()},getFields:function(a,b){var c;return c=this.selectByAttribute("isField",!0,!0),a!=null&&b!=null&&(c=_(c).select(function(c){var d;return d=c[a],_.isFunction(d)&&(d=d.call(c)),d===b})),c},loadModel:function(a){var b,c,d,e;d=this,c=this.getFields(),this.state.set("dirty",!1),this.trigger("before:load",this,a),a&&((e=a.beforeFormLoad)!=null&&e.apply(a,this),b="before:load:"+(a.isNew()?"new":"existing"),this.trigger(b,this,a)),this.state.set("currentModel",a),this.setValues(a||{},{silent:!0}),this.trigger("after:load",this,a);if(a)return this.trigger("after:load:"+(a.isNew()?"new":"existing"),this,a)},reset:function(){return this.loadModel(this.state.get("currentModel"))},clear:function(){var a=this;return this.state.set("currentModel",typeof this.defaultModel=="function"?this.defaultModel():void 0),_(this.getFields()).each(function(b){try{return b.setValue("")}catch(c){return console.log("Error Clearing",a,b)}})},isDirty:function(){return!!this.state.get("dirty")},setValues:function(a,b){var c,d=this;b==null&&(b={}),a||(a=this.currentModel()),c=this.getFields(),_(c).each(function(b){var c,d;c=b.input_name||b.name;if(a!=null?a[c]:void 0)d=Luca.util.read(a[c]);!d&&Luca.isBackboneModel(a)&&(d=a.get(c));if(b.readOnly!==!0)return b!=null?b.setValue(d):void 0});if(b.silent!=null!=1)return this.applyFormValuesToModel()},getValues:function(a){var b,c=this;return a==null&&(a={}),a.reject_blank==null&&(a.reject_blank=!0),a.skip_buttons==null&&(a.skip_buttons=!0),a.blanks===!1&&(a.reject_blank=!0),b=_(this.getFields()).inject(function(b,d){var e,f,g,h,i;h=d.getValue(),f=d.input_name||d.name,i=!!_.str.isBlank(h)||!!_.isUndefined(h),e=!a.reject_blank&&!d.send_blanks;if(d.includeBlank===!0||c.includeBlankValues===!0)e=!0;return a.debug&&console.log(""+f+" Options",a,"Value",h,"Value Is Blank?",i,"Allow Blanks?",e),a.skip_buttons&&d.isButton?g=!0:(i&&e===!1&&(g=!0),d.input_name==="id"&&i===!0&&(g=!0)),a.debug&&console.log("Skip is true on "+f),g!==!0&&(b[f]=h),b},a.defaults||{}),b},removeErrors:function(){var a,b,c,d,e;this.$(".alert.alert-error").remove(),this.$el.removeClass("error"),d=this.getFields(),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.clearErrors());return e},displayErrors:function(a){var b,c,d,e,f,g,h;e=!1,h=this.getFields();for(f=0,g=h.length;f<g;f++){b=h[f];for(d in a){c=a[d];if(d!==b.input_name)continue;b.displayErrors(c),e=!0}}if(e)return this.$el.addClass("error")},displayValidationErrorsMessage:function(){return this.errorMessage("Please fix the fields with errors")},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){var d;this.trigger("after:submit",this,a,b),this.trigger("after:submit:fatal_error",this,a,b);try{d=$.parseJSON(b.responseText);if(!d.success&&d.errors!=null)return this.displayValidationErrorsMessage(),this.displayErrors(d.errors)}catch(e){}},submit:function(a,b){var c;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.removeErrors(),this.applyFormValuesToModel();if(!a)return;return(c=this.currentModel())!=null?c.save(this.currentModel().toJSON(),b):void 0},hasModel:function(){return this.currentModel()!=null},currentModel:function(a){return a==null&&(a={}),(a===!0||(a!=null?a.refresh:void 0)===!0)&&this.applyFormValuesToModel(),this.state.get("currentModel")},applyFormValuesToModel:function(a){var b;return(b=this.currentModel())!=null?b.set(this.getValues(),a):void 0},setLegend:function(a){return this.legend=a,$("fieldset legend",this.el).first().html(this.legend)},flash:function(a){return this.$(".toolbar-container.top").length>0?this.$(".toolbar-container.top").after(a):this.$bodyEl().prepend(a)},successFlashDelay:1500,successMessage:function(a){var b=this;return this.$(".alert.alert-success").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-success",message:a})),_.delay(function(){return b.$(".alert.alert-success").fadeOut()},this.successFlashDelay||0)},errorMessage:function(a){return this.$(".alert.alert-error").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-error",message:a}))}}),a.classInterface({setupToolbar:function(){if(this.toolbar!==!1&&!this.topToolbar&&!this.bottomToolbar){if(this.toolbar==="both"||this.toolbar==="top")this.topToolbar=_.clone(this.getDefaultToolbar());if(this.toolbar!=="top")return this.bottomToolbar=_.clone(this.getDefaultToolbar())}},defaultToolbar:{buttons:[{icon:"remove-sign",label:"Reset",eventId:"click:reset",className:"reset-button",align:"right"},{icon:"ok-sign",white:!0,label:"Save Changes",eventId:"click:submit",color:"success",className:"submit-button",align:"right"}]}}),a.defines({version:2})}.call(this),function(){var a;a=Luca.register("Luca.components.LoadMask"),a["extends"]("Luca.View"),a.defines({className:"luca-ui-load-mask",bodyTemplate:"components/load_mask"})}.call(this),function(){var a;a=Luca.register("Luca.components.NavBar"),a["extends"]("Luca.View"),a.publicConfiguration({fixed:!0,position:"top",fluid:void 0,brand:"Luca.js",template:void 0}),a.privateConfiguration({className:"navbar",bodyTemplate:"nav_bar",bodyClassName:"luca-ui-navbar-body",beforeRender:function(){var a;return this.fixed&&this.$el.addClass("navbar-fixed-"+this.position),this.inverse===!0&&this.$el.addClass("navbar-inverse"),this.brand!=null&&(this.$(".brand").attr("href",this.homeLink||"#"),this.$(".brand").html(this.brand)),this.template&&this.navContainer().html(Luca.template(this.template,this)),this.fluid||((a=Luca.getApplication())!=null?a.fluid:void 0)?this.content().addClass(Luca.config.fluidWrapperClass):this.content().addClass(Luca.config.wrapperClass)},render:function(){return this},navContainer:function(){return this.$(".luca-ui-navbar-body .nav-collapse")},content:function(){return this.$(".luca-ui-navbar-body").eq(0)}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.Page"),a["extends"]("Luca.Container"),a.privateMethods({initialize:function(a){return this.options=a!=null?a:{},this.assignComponentsToRegions(),this.bodyTemplate=this.options.layout||this.layout,this.bodyTemplate||(this.bodyTemplate=this.options.template||this.template),Luca.Container.prototype.initialize.apply(this,arguments)},assignComponentsToRegions:function(){var a,b,c,d;return this.components||(this.components=[]),a=function(){var a,e;a=this.regions,e=[];for(d in a)c=a[d],_.isString(c)&&(b=Luca.registry.lookup(c))?c={component:c}:_.isString(c)&&Luca.template(c)&&(c={bodyTemplate:c}),e.push(_.extend(c,{container:"[data-region='"+d+"']"}));return e}.call(this),this.components=a}}),a.publicConfiguration({layout:void 0,regions:{}}),a.register()}.call(this),function(){var a;a=Luca.register("Luca.components.PaginationControl"),a["extends"]("Luca.View"),a.defines({template:"components/pagination",stateful:!0,stateChangeEvents:{numberOfPages:"onPageCountChange"},autoBindEventHandlers:!0,events:{"click a[data-page-number]":"selectPage","click a.next":"nextPage","click a.prev":"previousPage"},onPageCountChange:function(){return this.updateWithPageCount(this.get("numberOfPages"))},limit:function(){var a;return parseInt(this.get("limit")||((a=this.collection)!=null?a.length:void 0))},page:function(){return parseInt(this.get("page")||1)},nextPage:function(){if(!this.nextEnabled())return;return this.set("page",this.page()+1)},previousPage:function(){if(!this.previousEnabled())return;return this.set("page",this.page()-1)},selectPage:function(a){var b,c;return b=c=this.$(a.target),b.is("a.page")||(b=c=c.closest("a.page")),c.siblings().removeClass("is-selected"),b.addClass("is-selected"),this.setPage(c.data("page-number"))},setPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.set("page",a,b)},setLimit:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.set("limit",a,b)},pageButtonContainer:function(){return this.$(".group")},previousEnabled:function(){return this.page()>1},nextEnabled:function(){return this.page()<this.totalPages()},previousButton:function(){return this.$("a.page.prev")},nextButton:function(){return this.$("a.page.next")},pageButtons:function(){return this.$("a[data-page-number]",this.pageButtonContainer())},updateWithPageCount:function(a,b){var c,d=this;return this.pageCount=a,b==null&&(b=[]),c=b.length,this.pageButtonContainer().empty(),_(this.pageCount).times(function(a){var b,c;return c=a+1,b=d.make("a",{"data-page-number":c,"class":"page"},c),d.pageButtonContainer().append(b)}),this.toggleNavigationButtons(),this.selectActivePageButton(),this},toggleNavigationButtons:function(){this.$("a.next, a.prev").addClass("disabled"),this.nextEnabled()&&this.nextButton().removeClass("disabled");if(this.previousEnabled())return this.previousButton().removeClass("disabled")},selectActivePageButton:function(){return this.activePageButton().addClass("is-selected")},activePageButton:function(){return this.pageButtons().filter("[data-page-number='"+this.page()+"']")},totalPages:function(){return this.pageCount},totalItems:function(){var a;return parseInt(((a=this.collection)!=null?a.length:void 0)||0)},itemsPerPage:function(a,b){return b==null&&(b={}),a!=null&&this.set("limit",a,b),parseInt(this.get("limit"))}})}.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 void 0}})},firstActivation:function(){return this.getGrid().trigger("first:activation",this,this.getGrid()),this.getFilter().trigger("first:activation",this,this.getGrid())},reload:function(){var a,b,c,d;return d=this,c=this.getGrid(),b=this.getFilter(),a=this.getEditor(),b.clear(),c.applyFilter()},manageRecord:function(a){var b,c=this;return b=this.getCollection().get(a),b?this.loadModel(b):(console.log("Could Not Find Model, building and fetching"),b=this.buildModel(),b.set({id:a},{silent:!0}),b.fetch({success:function(a,b){return c.loadModel(a)}}))},loadModel:function(a){return this.current_model=a,this.getEditor(!0).loadModel(this.current_model),this.trigger("model:loaded",this.current_model)},currentModel:function(){return this.getEditor(!1).currentModel()},buildModel:function(){var a,b,c;return b=this.getEditor(!1),a=this.getCollection(),a.add([{}],{silent:!0,at:0}),c=a.at(0)},createModel:function(){return this.loadModel(this.buildModel())},reset_filter_handler:function(a){return this.getFilter().clear(),this.getGrid().applyFilter(this.getFilter().getValues())},filter_handler:function(a){return this.getGrid().applyFilter(this.getFilter().getValues())},edit_handler:function(a){var b,c,d,e;return b=d=$(a.currentTarget),e=d.parents("tr").data("record-id"),e&&(c=this.getGrid().collection.get(e)),c||(c=this.getGrid().collection.at(row_index))},add_handler:function(a){var b,c,d;return b=c=$(a.currentTarget),d=c.parents(".record-manager").eq(0).data("resource")},destroy_handler:function(a){},back_to_search_handler:function(){}})}.call(this),function(){var a;a=Luca.register("Luca.Router"),a["extends"]("Backbone.Router"),a.defines({routes:{"":"default"},initialize:function(a){var b,c=this;return this.options=a,_.extend(this,this.options),this.routeHandlers=_(this.routes).values(),_(this.routeHandlers).each(function(a){return c.bind("route:"+a,function(){return c.trigger.apply(c,["change:navigation",a].concat(_(arguments).flatten()))})}),(b=Backbone.Router.initialize)!=null?b.apply(this,arguments):void 0},navigate:function(a,b){return b==null&&(b=!1),Backbone.Router.prototype.navigate.apply(this,arguments),this.buildPathFrom(Backbone.history.getFragment())},buildPathFrom:function(a){var b=this;return _(this.routes).each(function(c,d){var e,f;f=b._routeToRegExp(d);if(f.test(a))return e=b._extractParameters(f,a),b.trigger.apply(b,["change:navigation",c].concat(e))})}})}.call(this),function(){}.call(this);