luca 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. data/CHANGELOG +49 -0
  2. data/Gemfile +8 -1
  3. data/Gemfile.lock +97 -53
  4. data/Guardfile +3 -25
  5. data/README.md +5 -16
  6. data/ROADMAP +15 -9
  7. data/Rakefile +24 -75
  8. data/app.rb +10 -42
  9. data/app/assets/javascripts/luca/basic.coffee +1 -1
  10. data/app/assets/javascripts/luca/components/application.coffee +187 -104
  11. data/app/assets/javascripts/luca/components/collection_view.coffee +115 -51
  12. data/app/assets/javascripts/luca/components/controller.coffee +87 -10
  13. data/app/assets/javascripts/luca/components/fields/base.coffee +74 -13
  14. data/app/assets/javascripts/luca/components/fields/button_field.coffee +60 -13
  15. data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
  16. data/app/assets/javascripts/luca/components/fields/select_field.coffee +82 -23
  17. data/app/assets/javascripts/luca/components/fields/text_area_field.coffee +25 -10
  18. data/app/assets/javascripts/luca/components/fields/text_field.coffee +9 -3
  19. data/app/assets/javascripts/luca/components/form_view.coffee +105 -33
  20. data/app/assets/javascripts/luca/components/grid_layout_view.coffee +42 -0
  21. data/app/assets/javascripts/luca/components/index.coffee +6 -0
  22. data/app/assets/javascripts/luca/components/nav_bar.coffee +60 -6
  23. data/app/assets/javascripts/luca/components/page.coffee +70 -0
  24. data/app/assets/javascripts/luca/components/simple_collection_view.coffee +10 -0
  25. data/app/assets/javascripts/luca/components/table_view.coffee +7 -3
  26. data/app/assets/javascripts/luca/components/table_view_scrollable.coffee +23 -0
  27. data/app/assets/javascripts/luca/concerns/collection_event_bindings.coffee +4 -1
  28. data/app/assets/javascripts/luca/concerns/development_tool_helpers.coffee +23 -14
  29. data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
  30. data/app/assets/javascripts/luca/concerns/filterable.coffee +8 -11
  31. data/app/assets/javascripts/luca/concerns/form_model_bindings.coffee +20 -0
  32. data/app/assets/javascripts/luca/concerns/modal_view.coffee +40 -15
  33. data/app/assets/javascripts/luca/concerns/query_collection_bindings.coffee +7 -1
  34. data/app/assets/javascripts/luca/concerns/state_model.coffee +40 -26
  35. data/app/assets/javascripts/luca/concerns/templating.coffee +3 -1
  36. data/app/assets/javascripts/luca/config.coffee +5 -0
  37. data/app/assets/javascripts/luca/containers/card_view.coffee +87 -52
  38. data/app/assets/javascripts/luca/containers/container.coffee +305 -108
  39. data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
  40. data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
  41. data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +5 -6
  42. data/app/assets/javascripts/luca/containers/tab_view.coffee +19 -10
  43. data/app/assets/javascripts/luca/containers/viewport.coffee +12 -16
  44. data/app/assets/javascripts/luca/core/collection.coffee +19 -5
  45. data/app/assets/javascripts/luca/core/events.coffee +5 -5
  46. data/app/assets/javascripts/luca/core/model.coffee +1 -1
  47. data/app/assets/javascripts/luca/core/panel.coffee +18 -6
  48. data/app/assets/javascripts/luca/core/registry/component_definition.coffee +2 -1
  49. data/app/assets/javascripts/luca/core/registry/meta_data.coffee +2 -0
  50. data/app/assets/javascripts/luca/core/registry/registry.coffee +14 -11
  51. data/app/assets/javascripts/luca/core/templates.coffee +5 -1
  52. data/app/assets/javascripts/luca/core/view.coffee +200 -47
  53. data/app/assets/javascripts/luca/dependencies.coffee +2 -0
  54. data/app/assets/javascripts/luca/development/code_sync_manager.coffee +173 -0
  55. data/app/assets/javascripts/luca/development/component.coffee +76 -0
  56. data/app/assets/javascripts/luca/development/components.coffee +57 -0
  57. data/app/assets/javascripts/luca/development/console.coffee +1 -1
  58. data/app/assets/javascripts/luca/development/index.coffee +4 -1
  59. data/app/assets/javascripts/luca/framework.coffee +7 -3
  60. data/app/assets/javascripts/luca/index.coffee +2 -1
  61. data/app/assets/javascripts/luca/managers/collection_manager.coffee +2 -3
  62. data/app/assets/javascripts/luca/managers/index.coffee +1 -1
  63. data/app/assets/javascripts/luca/managers/socket_manager.coffee +31 -8
  64. data/app/assets/javascripts/luca/templates/components/nav_bar.jst.ejs +16 -1
  65. data/app/assets/javascripts/luca/templates/containers/tab_view.jst.ejs +1 -1
  66. data/app/assets/javascripts/luca/util/index.coffee +1 -0
  67. data/app/assets/javascripts/luca/util/keybindings.coffee +24 -0
  68. data/app/assets/javascripts/luca/util/logging.coffee +15 -0
  69. data/app/assets/javascripts/luca/util/luca.coffee +9 -1
  70. data/app/assets/stylesheets/luca/components/table_view.scss +85 -0
  71. data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
  72. data/app/assets/stylesheets/luca/containers/container.scss +8 -0
  73. data/app/assets/stylesheets/luca/index.css +2 -2
  74. data/bin/luca +14 -0
  75. data/config.ru +1 -2
  76. data/docs/framework.json +1 -0
  77. data/docs/luca-framework-documentation.js +1 -0
  78. data/docs/{application.md → old/application.md} +0 -0
  79. data/docs/{collection.md → old/collection.md} +0 -0
  80. data/docs/{collection_manager.md → old/collection_manager.md} +0 -0
  81. data/docs/{container_philosophy.md → old/container_philosophy.md} +0 -0
  82. data/docs/{event_binding_helpers.md → old/event_binding_helpers.md} +0 -0
  83. data/docs/{method_caching_and_computed_properties.md → old/method_caching_and_computed_properties.md} +0 -0
  84. data/docs/{view.md → old/view.md} +0 -0
  85. data/lib/generators/luca/application/templates/javascripts/dependencies.coffee +2 -5
  86. data/lib/guard/luca.rb +84 -0
  87. data/lib/luca.rb +25 -1
  88. data/lib/luca/asset_compiler.rb +117 -0
  89. data/lib/luca/cli.rb +68 -0
  90. data/lib/luca/cli/generate.rb +37 -0
  91. data/lib/luca/cli/server.rb +20 -0
  92. data/lib/luca/cli/sync.rb +40 -0
  93. data/lib/luca/cli/watch.rb +16 -0
  94. data/lib/luca/collection.rb +64 -0
  95. data/lib/luca/collection/endpoint.rb +38 -0
  96. data/lib/luca/collection/file_backend.rb +121 -0
  97. data/lib/luca/collection/redis_backend.rb +153 -0
  98. data/lib/luca/compiled_asset.rb +61 -0
  99. data/lib/luca/component_definition.rb +356 -0
  100. data/lib/luca/luca_application.rb +258 -0
  101. data/lib/luca/project.rb +73 -0
  102. data/lib/luca/project_harness.rb +96 -0
  103. data/lib/luca/rails.rb +5 -3
  104. data/lib/luca/rails/engine.rb +8 -0
  105. data/lib/luca/rails/version.rb +1 -2
  106. data/lib/luca/server.rb +7 -0
  107. data/lib/luca/stylesheet.rb +35 -0
  108. data/lib/luca/template.rb +2 -0
  109. data/lib/luca/template_asset.rb +64 -0
  110. data/lib/luca/version.rb +3 -0
  111. data/lib/luca/watcher.rb +72 -0
  112. data/lib/railties/luca/tasks.rake +7 -0
  113. data/site/.bundle/config +2 -0
  114. data/site/.gitignore +5 -0
  115. data/site/.rvmrc +1 -0
  116. data/site/CHANGELOG.md +41 -0
  117. data/site/DOCS.md +41 -0
  118. data/site/Gemfile +8 -0
  119. data/site/Gemfile.lock +134 -0
  120. data/site/LICENSE.md +19 -0
  121. data/site/config.rb +84 -0
  122. data/site/helpers/site_helpers.rb +20 -0
  123. data/site/html5bp-docs/README.md +38 -0
  124. data/site/html5bp-docs/contribute.md +104 -0
  125. data/site/html5bp-docs/crossdomain.md +21 -0
  126. data/site/html5bp-docs/css.md +135 -0
  127. data/site/html5bp-docs/extend.md +507 -0
  128. data/site/html5bp-docs/faq.md +77 -0
  129. data/site/html5bp-docs/htaccess.md +323 -0
  130. data/site/html5bp-docs/html.md +170 -0
  131. data/site/html5bp-docs/js.md +31 -0
  132. data/site/html5bp-docs/misc.md +25 -0
  133. data/site/html5bp-docs/usage.md +109 -0
  134. data/site/readme.md +47 -0
  135. data/site/source/.htaccess +540 -0
  136. data/site/source/404.html +157 -0
  137. data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
  138. data/site/source/app/assets/javascripts/docs-docs.js +1 -0
  139. data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
  140. data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
  141. data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
  142. data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
  143. data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
  144. data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
  145. data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
  146. data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
  147. data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
  148. data/{spec/components/application_spec.coffee → site/source/app/assets/javascripts/docs/lib/util.coffee} +0 -0
  149. data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
  150. data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
  151. data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
  152. data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
  153. data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
  154. data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
  155. data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
  156. data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
  157. data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
  158. data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
  159. data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
  160. data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
  161. data/{spec/components/collection_loader_view_spec.coffee → site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee} +0 -0
  162. data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
  163. data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
  164. data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
  165. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
  166. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
  167. data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
  168. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
  169. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
  170. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
  171. data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
  172. data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
  173. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
  174. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
  175. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
  176. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
  177. data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
  178. data/site/source/app/assets/javascripts/luca-docs.js +1 -0
  179. data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
  180. data/site/source/app/assets/javascripts/site.js.coffee +4 -0
  181. data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
  182. data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
  183. data/site/source/app/assets/javascripts/vendor/css.js +465 -0
  184. data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
  185. data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
  186. data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
  187. data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
  188. data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
  189. data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
  190. data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
  191. data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
  192. data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
  193. data/site/source/app/assets/stylesheets/site.css.scss +2 -0
  194. data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
  195. data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
  196. data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
  197. data/site/source/crossdomain.xml +15 -0
  198. data/site/source/documentation.html.haml +1 -0
  199. data/site/source/favicon_base.png +0 -0
  200. data/site/source/humans.txt +15 -0
  201. data/site/source/images/background.png +0 -0
  202. data/site/source/images/middleman.png +0 -0
  203. data/site/source/index.html.haml +1 -0
  204. data/site/source/layouts/layout.haml +55 -0
  205. data/site/source/readme.md +63 -0
  206. data/site/source/robots.txt +3 -0
  207. data/spec/{components/grid_view_spec.coffee → javascripts/components/application_spec.coffee} +0 -0
  208. data/spec/{components/pagination_control_spec.coffee → javascripts/components/collection_loader_view_spec.coffee} +0 -0
  209. data/spec/{components → javascripts/components}/collection_view_spec.coffee +1 -1
  210. data/spec/{components → javascripts/components}/controller_spec.coffee +0 -0
  211. data/spec/{components → javascripts/components}/fields/checkbox_array_spec.coffee +0 -0
  212. data/spec/javascripts/components/form_view_spec.coffee +162 -0
  213. data/spec/{components/record_manager_spec.coffee → javascripts/components/grid_view_spec.coffee} +0 -0
  214. data/spec/{components → javascripts/components}/multi_collection_view_spec.coffee +0 -0
  215. data/spec/{components/template_spec.coffee → javascripts/components/pagination_control_spec.coffee} +0 -0
  216. data/spec/{concerns/paginatable_spec.coffee → javascripts/components/record_manager_spec.coffee} +0 -0
  217. data/spec/{components → javascripts/components}/table_view_spec.coffee +0 -0
  218. data/spec/{containers/modal_view_spec.coffee → javascripts/components/template_spec.coffee} +0 -0
  219. data/spec/{concerns → javascripts/concerns}/collection_event_bindings_spec.coffee +0 -0
  220. data/spec/{concerns → javascripts/concerns}/dom_helpers_spec.coffee +0 -0
  221. data/spec/{concerns → javascripts/concerns}/filterable_spec.coffee +0 -0
  222. data/spec/{concerns → javascripts/concerns}/model_presenter_spec.coffee +0 -0
  223. data/spec/{containers/panel_view_spec.coffee → javascripts/concerns/paginatable_spec.coffee} +0 -0
  224. data/spec/{concerns → javascripts/concerns}/state_model_spec.coffee +5 -0
  225. data/spec/javascripts/containers/card_view_spec.coffee +108 -0
  226. data/spec/{containers/tab_view_spec.coffee → javascripts/containers/modal_view_spec.coffee} +0 -0
  227. data/spec/{containers/viewport_spec.coffee → javascripts/containers/panel_view_spec.coffee} +0 -0
  228. data/spec/{core/observer_spec.coffee → javascripts/containers/tab_view_spec.coffee} +0 -0
  229. data/spec/{managers/socket_manager_spec.coffee → javascripts/containers/viewport_spec.coffee} +0 -0
  230. data/spec/{core → javascripts/core}/collection_spec.coffee +1 -1
  231. data/spec/{core → javascripts/core}/concerns_spec.coffee +0 -0
  232. data/spec/{core → javascripts/core}/container_spec.coffee +0 -0
  233. data/spec/{core → javascripts/core}/define_spec.coffee +0 -0
  234. data/spec/{core → javascripts/core}/events_spec.coffee +0 -0
  235. data/spec/{core → javascripts/core}/field_spec.coffee +0 -0
  236. data/spec/{core → javascripts/core}/framework_spec.coffee +0 -0
  237. data/spec/{core → javascripts/core}/model_spec.coffee +0 -0
  238. data/spec/javascripts/core/observer_spec.coffee +0 -0
  239. data/spec/{core → javascripts/core}/util_spec.coffee +0 -0
  240. data/spec/{core → javascripts/core}/view_spec.coffee +51 -39
  241. data/spec/{dependencies → javascripts/dependencies}/index.coffee +0 -0
  242. data/spec/{dependencies → javascripts/dependencies}/jasmine-html.js +0 -0
  243. data/spec/{dependencies → javascripts/dependencies}/jasmine.js +0 -0
  244. data/spec/{dependencies → javascripts/dependencies}/sinon.js +0 -0
  245. data/spec/{helper.coffee → javascripts/helper.coffee} +0 -0
  246. data/spec/{managers → javascripts/managers}/collection_manager_spec.coffee +0 -0
  247. data/spec/javascripts/managers/socket_manager_spec.coffee +0 -0
  248. data/spec/lib/component_definition_spec.rb +63 -0
  249. data/spec/lib/input_compiler_spec.rb +9 -0
  250. data/spec/lib/luca_application_spec.rb +30 -0
  251. data/spec/support/fixtures/application.coffee +45 -0
  252. data/spec/support/fixtures/component.coffee +34 -0
  253. data/tutorials/component-definitions.md +0 -0
  254. data/tutorials/component-definitions/01_intro.md +0 -0
  255. data/tutorials/component-driven-design.md +140 -0
  256. data/tutorials/structure-of-a-project.md +63 -0
  257. data/vendor/assets/javascripts/backbone-min.js +37 -33
  258. data/vendor/assets/javascripts/backbone-query.min.js +1 -1
  259. data/vendor/assets/javascripts/hogan.js +707 -0
  260. data/vendor/assets/javascripts/jquery.js +5 -4
  261. data/vendor/assets/javascripts/keymaster.min.js +4 -0
  262. data/vendor/assets/javascripts/luca-dependencies.min.js +8 -0
  263. data/vendor/assets/javascripts/luca-development.min.js +1 -0
  264. data/vendor/assets/javascripts/luca-spec.js +6 -6
  265. data/vendor/assets/javascripts/luca-ui.js +7386 -0
  266. data/vendor/assets/javascripts/luca-ui.min.js +5 -0
  267. data/vendor/assets/javascripts/luca.full.min.js +12 -0
  268. data/vendor/assets/javascripts/luca.min.js +5 -0
  269. data/vendor/assets/javascripts/underscore-min.js +1 -5
  270. data/vendor/assets/javascripts/underscore-string.min.js +1 -1
  271. data/vendor/assets/stylesheets/luca-components.css +202 -0
  272. data/vendor/assets/stylesheets/luca-development.css +23 -0
  273. data/vendor/assets/stylesheets/luca-ui.css +198 -0
  274. metadata +324 -94
  275. data/app/assets/javascripts/luca/components/base_toolbar.coffee +0 -17
  276. data/app/assets/javascripts/luca/components/form_button_toolbar.coffee +0 -28
  277. data/app/assets/javascripts/luca/components/grid_view.coffee +0 -269
  278. data/app/assets/javascripts/luca/components/page_controller.coffee +0 -7
  279. data/app/assets/javascripts/luca/components/template.coffee +0 -5
  280. data/app/assets/javascripts/luca/components/toolbar_dialog.coffee +0 -25
  281. data/lib/luca/code_browser.rb +0 -55
  282. data/lib/luca/command_line.rb +0 -69
  283. data/lib/luca/component_documentation.rb +0 -72
  284. data/site/assets/bootstrap.min.js +0 -7
  285. data/site/assets/dependencies.js +0 -94
  286. data/site/assets/glyphicons-halflings-white.png +0 -0
  287. data/site/assets/glyphicons-halflings.png +0 -0
  288. data/site/assets/luca-ui-bootstrap.css +0 -1331
  289. data/site/assets/luca-ui-bootstrap.js +0 -9
  290. data/site/assets/luca-ui-development-tools.css +0 -234
  291. data/site/assets/luca-ui-development-tools.js +0 -18561
  292. data/site/assets/luca-ui-development-tools.min.js +0 -15
  293. data/site/assets/luca-ui-full.min.js +0 -8
  294. data/site/assets/luca-ui.min.js +0 -4
  295. data/site/assets/sandbox.css +0 -62
  296. data/site/assets/sandbox.js +0 -469
  297. data/site/docs/application.html +0 -41
  298. data/site/docs/caching.html +0 -43
  299. data/site/docs/collection.html +0 -75
  300. data/site/docs/collection_manager.html +0 -71
  301. data/site/docs/containers.html +0 -118
  302. data/site/docs/events.html +0 -153
  303. data/site/docs/view.html +0 -128
  304. data/site/img/glyphicons-halflings-white.png +0 -0
  305. data/site/img/glyphicons-halflings.png +0 -0
  306. data/site/index.html +0 -20
  307. data/site/source-map.js +0 -1
  308. data/spec/components/form_view_spec.coffee +0 -84
  309. data/spec/containers/card_view_spec.coffee +0 -50
  310. data/spec/luca-spec.coffee +0 -9
@@ -0,0 +1,42 @@
1
+ gridView = Luca.register "Luca.components.GridLayoutView"
2
+ gridView.extends "Luca.CollectionView"
3
+
4
+ gridView.publicConfiguration
5
+ # how many items do you wish to render per row?
6
+ # assuming a 12 column grid, each item will receive
7
+ # an equal amount of grid span/columns.
8
+ itemsPerRow: 3
9
+
10
+ gridView.privateConfiguration
11
+ className: "grid-layout-view"
12
+ tagName: "div"
13
+ itemTagName: "div"
14
+
15
+ gridView.privateMethods
16
+ # adds the bootstrap span class to each collection-item,
17
+ # where span class is equal to the 12 column grid / @itemsPerRow.
18
+ # for example, each item would receive a span4 class when @itemsPerRow = 3
19
+ attributesForItem: ()->
20
+ base = Luca.CollectionView::attributesForItem.apply(@, arguments)
21
+ @itemsPerRow = 3 unless _.isNumber(@itemsPerRow) and @itemsPerRow > 1
22
+ columns = parseInt(12 / @itemsPerRow)
23
+ base.class += " span#{ columns }"
24
+
25
+ base
26
+
27
+ # wraps every N number of rows, where N = @itemsPerRow
28
+ # in a row-fluid wrapper, and appends it to the view
29
+ renderModels: (models)->
30
+ index = 0
31
+ rowIndex = 0
32
+
33
+ rows = for model in models
34
+ row = @make("div", class:"row-fluid") if rowIndex++ is 0
35
+ $(row).append @makeItem(model,index++)
36
+ rowIndex = 0 if index > 0 and index % @itemsPerRow is 0
37
+ row
38
+
39
+ for row in rows
40
+ @$append(row)
41
+
42
+ gridView.register()
@@ -1 +1,7 @@
1
+ #= require ./collection_view
2
+ #= require ./simple_collection_view
3
+ #= require ./grid_layout_view
4
+ #= require ./table_view
5
+ #= require ./multi_collection_view
6
+ #= require ./table_view_scrollable
1
7
  #= require_tree .
@@ -1,26 +1,80 @@
1
+ # A Twitter Bootstrap compatible navigation bar. The Luca.Application
2
+ # and Luca.containers.Viewport class both have configuration options for
3
+ # creating navbar components in the header and footer of the viewport.
4
+ #
5
+ # #### Example of an Application with a Navbar
6
+ # ##### Component Definition
7
+ # # Navigation Component
8
+ # navBar = Luca.register "App.views.TopNavigation"
9
+ # navBar.extends "Luca.components.NavBar"
10
+ # navBar.defines
11
+ # brand: "My App"
12
+ # # for white on black
13
+ # inverse: true
14
+ #
15
+ # We are able to reference the component we just defined in the
16
+ # configuration of the Application, simply by using it's
17
+ # type alias `top_navigation`
18
+ #
19
+ # # Application Component
20
+ # app = Luca.register "App.Application"
21
+ # app.extends "Luca.Application"
22
+ # app.defines
23
+ # topNav: "top_navigation"
24
+ #
1
25
  navBar = Luca.register "Luca.components.NavBar"
2
-
3
26
  navBar.extends "Luca.View"
4
27
 
5
- navBar.defines
28
+ navBar.publicConfiguration
29
+ # Specify whether the navbar is supposed to be fixed
30
+ # the way Twitter bootstrap navbar can be.
6
31
  fixed: true
32
+
33
+ # Valid options are 'top', 'bottom'. Only valid when `@fixed is true`
7
34
  position: 'top'
8
- className: 'navbar'
35
+
36
+ # Specify whether the navbar should use the fluid grid.
37
+ # Usually the same as your Viewport setting.
38
+ fluid: undefined
39
+
40
+ # What content do you want to show in the logo area of the
41
+ # standard bootstrap nav
9
42
  brand: "Luca.js"
43
+
44
+ # Specifies an optional template to use for the navigation menu
45
+ # content. Whatever you specify will be rendered inside of the
46
+ # collapsible container inside of the standard bootstrap nav.
47
+ template: undefined
48
+
49
+ navBar.privateConfiguration
50
+ className: 'navbar'
10
51
  bodyTemplate: 'nav_bar'
11
52
  bodyClassName: 'luca-ui-navbar-body'
12
53
 
13
54
  beforeRender: ()->
14
55
  @$el.addClass "navbar-fixed-#{ @position }" if @fixed
56
+ @$el.addClass "navbar-inverse" if @inverse is true
15
57
 
16
58
  if @brand?
17
- @content().append("<a class='brand' href='#'>#{ @brand }</a>")
59
+ @$('.brand').attr('href', @homeLink || '#')
60
+ @$('.brand').html(@brand)
18
61
 
19
62
  if @template
20
- @content().append Luca.template(@template, @)
63
+ @navContainer().html Luca.template(@template, @)
64
+
65
+ if !!(@fluid || Luca.getApplication()?.fluid)
66
+ @content().addClass( Luca.config.fluidWrapperClass )
67
+ else
68
+ @content().addClass( Luca.config.wrapperClass )
21
69
 
22
70
  render: ()->
23
71
  @
24
72
 
73
+ navContainer: ()->
74
+ @$('.luca-ui-navbar-body .nav-collapse')
75
+
25
76
  content: ()->
26
- @$('.container').eq(0)
77
+ @$('.luca-ui-navbar-body').eq(0)
78
+
79
+
80
+ navBar.register()
@@ -0,0 +1,70 @@
1
+ # The `Page` is a type of `Container` that has
2
+ # all of its subcomponents visible at one time,
3
+ # and assigned to various `@regions` that exist
4
+ # in the `@layout` template which provide its
5
+ # internal dom structure.
6
+ #
7
+ # #### Example Template (haml):
8
+ # .page.layout.row-fluid{"data-layout"=>"layouts/left_nav_grid"}
9
+ # .span3.region{"data-region"=>"left"}
10
+ # .span9.region{"data-region"=>"right"}
11
+ #
12
+ # ### Example Page Configuration
13
+ # page = new Luca.components.Page
14
+ # layout: "layouts/left_nav_grid"
15
+ # regions:
16
+ # left:
17
+ # type: "navigation"
18
+ # right:
19
+ # type: "details"
20
+ #
21
+ page = Luca.register "Luca.components.Page"
22
+ page.extends "Luca.Container"
23
+
24
+ page.privateMethods
25
+ # `Page`s are typically instantiated by a `Luca.components.Controller`
26
+ initialize: (@options={})->
27
+ @assignComponentsToRegions()
28
+ @bodyTemplate = @options.layout || @layout
29
+ @bodyTemplate ||= @options.template || @template
30
+ Luca.Container::initialize.apply(@, arguments)
31
+
32
+ # Takes the configuration specified in @regions
33
+ # and creates a components hash out of them.
34
+ assignComponentsToRegions: ()->
35
+ @components ||= []
36
+
37
+ assigned = for regionId, regionAssignment of @regions
38
+ if _.isString(regionAssignment) and componentClass = Luca.registry.lookup( regionAssignment )
39
+ regionAssignment =
40
+ component: regionAssignment
41
+ else if _.isString(regionAssignment) and Luca.template(regionAssignment)
42
+ regionAssignment =
43
+ bodyTemplate: regionAssignment
44
+
45
+ _.extend(regionAssignment, container: "[data-region='#{ regionId }']")
46
+
47
+ @components = assigned
48
+
49
+ page.publicConfiguration
50
+ # The `@layout` property is the equivalent to specifying @bodyTemplate
51
+ # but more semantic. A `@layout` template is expected to contain DOM
52
+ # elements with a data attribute named `region` on it.
53
+
54
+ layout: undefined
55
+ # The @regions property assigns containers ( by their type alias )
56
+ # to DOM elements identified as regions within a layout template.
57
+ #
58
+ # #### Example:
59
+ # new Luca.components.Page
60
+ # regions:
61
+ # left: "my_component"
62
+ # right:
63
+ # type: "my_other_component"
64
+ # role: "component_role"
65
+ #
66
+ # This will render an instance of MyComponent to this
67
+ # page's @$('[data-region-id="right"]') DOM element.
68
+ regions: {}
69
+
70
+ page.register()
@@ -0,0 +1,10 @@
1
+ # The SimpleCollectionView class is a CollectionView without any of the
2
+ # bells and whistles ( filtering, pagination, sorting, etc )
3
+ simple = Luca.register "Luca.components.SimpleCollectionView"
4
+ simple.extends "Luca.CollectionView"
5
+
6
+ simple.defines
7
+ filterable: false
8
+ paginatable: false
9
+ sortable: false
10
+ loadMask: false
@@ -1,5 +1,5 @@
1
1
  tableView = Luca.register "Luca.components.TableView"
2
- tableView.extends "Luca.components.CollectionView"
2
+ tableView.extends "Luca.CollectionView"
3
3
 
4
4
  tableView.publicConfiguration
5
5
  widths: []
@@ -17,6 +17,10 @@ tableView.privateConfiguration
17
17
  observeChanges: true
18
18
 
19
19
  tableView.privateMethods
20
+
21
+ lastColumn: ()->
22
+ @columns[ @columns.length - 1 ]
23
+
20
24
  eachColumn: (fn, scope=@)->
21
25
  index = 0
22
26
  for col in @columns
@@ -63,7 +67,7 @@ tableView.classMethods
63
67
  content = column.header
64
68
  content = "<a class='link'>#{ column.header }</a>" if column.sortable
65
69
 
66
- @$(targetElement).append( Backbone.View::make "th", attrs, content )
70
+ @$(targetElement).find('tr').append( Luca.View::make "th", attrs, content )
67
71
 
68
72
 
69
73
  index = 0
@@ -84,6 +88,6 @@ tableView.classMethods
84
88
  if _.isFunction( column.renderer )
85
89
  cellValue = column.renderer.call @, cellValue, model, column
86
90
 
87
- Backbone.View::make("td", {"data-col-index":index}, cellValue)
91
+ Luca.View::make("td", {"data-col-index":index}, cellValue)
88
92
 
89
93
  tableView.register()
@@ -0,0 +1,23 @@
1
+ scrollable = Luca.register 'Luca.components.ScrollableTable'
2
+
3
+ scrollable.extends 'Luca.components.TableView'
4
+
5
+ scrollable.replaces 'Luca.components.GridView'
6
+
7
+ scrollable.publicConfiguration
8
+ maxHeight: undefined
9
+
10
+ scrollable.privateMethods
11
+ $scrollableWrapperEl: ()->
12
+ @$el.parent('.scrollable-wrapper')
13
+
14
+ setMaxHeight: ()->
15
+ parent = @$scrollableWrapperEl()
16
+ parent.css('overflow':'auto', 'max-height': @maxHeight)
17
+
18
+ afterRender: ()->
19
+ @$wrap 'scrollable-wrapper'
20
+ @setMaxHeight()
21
+
22
+ scrollable.defines
23
+ version: 1
@@ -1,6 +1,9 @@
1
1
  Luca.concerns.CollectionEventBindings =
2
2
  __initializer: ()->
3
- Luca.concerns.CollectionEventBindings.__setup.call(@)
3
+
4
+ @defer ()=>
5
+ Luca.concerns.CollectionEventBindings.__setup.call(@)
6
+ .until("after:initialize")
4
7
 
5
8
  unless @collectionEventBindingsSetup is true
6
9
  if Luca.isBackboneCollection(@collection)
@@ -1,21 +1,30 @@
1
1
  Luca.concerns.DevelopmentToolHelpers =
2
- refreshCode: ()->
2
+ refreshEventBindings: ()->
3
3
  view = @
4
4
 
5
- _( @eventHandlerProperties() ).each (prop)->
6
- view[ prop ] = view.definitionClass()[prop]
5
+ console.log "Refreshing Event Bindings ON ", view.name || view.cid
7
6
 
8
- if @autoBindEventHandlers is true
9
- @bindAllEventHandlers()
7
+ view.undelegateEvents()
10
8
 
11
- @delegateEvents()
9
+ domEvents = view.definitionClass?()?.events || view.events
12
10
 
13
- eventHandlerProperties: ()->
14
- handlerIds = _( @events ).values()
15
- _( handlerIds ).select (v)->
16
- _.isString(v)
11
+ for eventSignature, eventName of domEvents when _.isString(eventName) is true
12
+ defaultEventHandler = view.definitionClass?()?[ eventName ]
13
+ console.log "Rebinding dom event", eventSignature, eventName, defaultEventHandler
14
+ view.events[ eventSignature ] = defaultEventHandler
17
15
 
18
- eventHandlerFunctions: ()->
19
- handlerIds = _( @events ).values()
20
- _( handlerIds ).map (handlerId)=>
21
- if _.isFunction(handlerId) then handlerId else @[handlerId]
16
+ if view.state? and view.stateful?
17
+ Luca.concerns.StateModel.__setupModelBindings.call(view, "off")
18
+ Luca.concerns.StateModel.__setupModelBindings.call(view, "on")
19
+
20
+ if view.isContainer is true and not _.isEmpty(view.componentEvents)
21
+ Luca.Container::registerComponentEvents.call(@,undefined,"off")
22
+ newBindings = view.definitionClass?()?.componentEvents
23
+
24
+ Luca.Container::registerComponentEvents.call(@,newBindings,"on")
25
+
26
+
27
+ #if @autoBindEventHandlers is true
28
+ # @bindAllEventHandlers()
29
+
30
+ view.delegateEvents()
@@ -46,10 +46,10 @@ Luca.concerns.DomHelpers =
46
46
  console.log "Error in $template: #{ template } #{ @identifier?() ? @name || @cid }"
47
47
 
48
48
  $html: (content)->
49
- @$el.html( content )
49
+ if content? then @$el.html(content) else @$el.html()
50
50
 
51
51
  $append: (content)->
52
- @$el.append( content )
52
+ @$el.append(content)
53
53
 
54
54
  $attach: ()->
55
55
  @$container().append( @el )
@@ -1,18 +1,16 @@
1
- Luca.concerns.Filterable =
1
+ Luca.concerns.Filterable =
2
2
  classMethods:
3
3
  prepare: ()->
4
- filter = _.clone( @getQuery() )
5
- options = _.clone( @getQueryOptions() )
4
+ @trigger "data:refresh"
5
+ return unless @isRemote()
6
+
7
+ filter = _.clone(@getRemoteQuery())
8
+ options = _.clone(@getQueryOptions())
6
9
 
7
10
  prepared = @prepareRemoteFilter(filter, options)
8
11
 
9
- @debug "Preparing filterable call", prepared, @isRemote()
12
+ @collection.applyFilter(prepared, remote: true)
10
13
 
11
- if @isRemote()
12
- @collection.applyFilter(prepared, remote: true)
13
- else
14
- @trigger "data:refresh"
15
-
16
14
  __included: (component, module)->
17
15
  _.extend(Luca.Collection::, __filters:{})
18
16
 
@@ -75,8 +73,7 @@ Luca.concerns.Filterable =
75
73
 
76
74
  applyFilter: (query={}, options={})->
77
75
  options = _.defaults(options, @getQueryOptions())
78
- query = _.defaults(query, @getQuery())
79
- @getFilterState().clear(silent:false)
76
+ @getFilterState().clear(silent: true)
80
77
  @getFilterState().set({query,options}, options)
81
78
 
82
79
  class FilterModel extends Backbone.Model
@@ -0,0 +1,20 @@
1
+ Luca.concerns.FormModelBindings =
2
+ __initializer: ()->
3
+ return unless @trackModelChanges is true
4
+
5
+ @on "state:change:currentModel", @onStateChangeCurrentModel, @
6
+
7
+ _.bindAll(@, "onStateChangeCurrentModel", "unbindFromModel", "onModelChange", "bindToModel")
8
+
9
+ onStateChangeCurrentModel: (state, current, previous)->
10
+ @unbindFromModel(previous) if Luca.isBackboneModel(previous)
11
+ @bindToModel(current) if Luca.isBackboneModel(current)
12
+
13
+ unbindFromModel: (model)->
14
+ (model || @currentModel())?.unbind("change", @onModelChange)
15
+
16
+ onModelChange: (model)->
17
+ @setValues(model, modelChange: true)
18
+
19
+ bindToModel: (model)->
20
+ (model || @currentModel())?.bind("change", @onModelChange, @)
@@ -1,4 +1,6 @@
1
1
  Luca.concerns.ModalView =
2
+ version: 3
3
+
2
4
  closeOnEscape: true
3
5
 
4
6
  showOnInitialize: false
@@ -6,12 +8,24 @@ Luca.concerns.ModalView =
6
8
  backdrop: false
7
9
 
8
10
  __initializer: ()->
9
- @$el.addClass("modal")
11
+ return unless @modal is true
10
12
 
11
- @on "before:render", applyModalConfig, @
13
+ @on "before:render", @applyModalConfig, @
12
14
 
13
15
  @
14
16
 
17
+ applyModalConfig: ()->
18
+ @$el.addClass 'modal'
19
+ @$el.addClass 'fade' if @fade is true
20
+
21
+ @$el.modal
22
+ backdrop: @backdrop is true
23
+ keyboard: @closeOnEscape is true
24
+ show: @showOnInitialize is true
25
+
26
+ @$el.css('display','none') unless @showOnInitialize is true
27
+ @
28
+
15
29
  container: ()->
16
30
  $('body')
17
31
 
@@ -19,20 +33,31 @@ Luca.concerns.ModalView =
19
33
  @$el.modal('toggle')
20
34
 
21
35
  show: ()->
36
+ @render() unless @rendered is true
37
+ @trigger "before:show"
22
38
  @$el.modal('show')
39
+ @trigger "after:show"
23
40
 
24
41
  hide: ()->
42
+ @trigger "before:hide"
25
43
  @$el.modal('hide')
26
-
27
- applyModalConfig = ()->
28
- @$el.addClass 'modal'
29
- @$el.addClass 'fade' if @fade is true
30
-
31
- $('body').append( @$el )
32
-
33
- @$el.modal
34
- backdrop: @backdrop is true
35
- keyboard: @closeOnEscape is true
36
- show: @showOnInitialize is true
37
-
38
- @
44
+ @trigger "after:hide"
45
+
46
+ setModalDimensions: (height, width)->
47
+ if _.isObject(height)
48
+ {height,width} = height
49
+
50
+ @setModalHeight( height ) if height?
51
+ @setModalWidth( width ) if width?
52
+
53
+ setModalWidth: (width)->
54
+ @$el.css
55
+ "width": width
56
+ "max-width": width
57
+ "margin-left": width * 0.5 * -1
58
+
59
+ setModalHeight: (height)->
60
+ @$el.css
61
+ "max-height": height
62
+ "margin-top": height * 0.5 * -1
63
+ "height": height