luca 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +49 -0
- data/Gemfile +8 -1
- data/Gemfile.lock +97 -53
- data/Guardfile +3 -25
- data/README.md +5 -16
- data/ROADMAP +15 -9
- data/Rakefile +24 -75
- data/app.rb +10 -42
- data/app/assets/javascripts/luca/basic.coffee +1 -1
- data/app/assets/javascripts/luca/components/application.coffee +187 -104
- data/app/assets/javascripts/luca/components/collection_view.coffee +115 -51
- data/app/assets/javascripts/luca/components/controller.coffee +87 -10
- data/app/assets/javascripts/luca/components/fields/base.coffee +74 -13
- data/app/assets/javascripts/luca/components/fields/button_field.coffee +60 -13
- data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
- data/app/assets/javascripts/luca/components/fields/select_field.coffee +82 -23
- data/app/assets/javascripts/luca/components/fields/text_area_field.coffee +25 -10
- data/app/assets/javascripts/luca/components/fields/text_field.coffee +9 -3
- data/app/assets/javascripts/luca/components/form_view.coffee +105 -33
- data/app/assets/javascripts/luca/components/grid_layout_view.coffee +42 -0
- data/app/assets/javascripts/luca/components/index.coffee +6 -0
- data/app/assets/javascripts/luca/components/nav_bar.coffee +60 -6
- data/app/assets/javascripts/luca/components/page.coffee +70 -0
- data/app/assets/javascripts/luca/components/simple_collection_view.coffee +10 -0
- data/app/assets/javascripts/luca/components/table_view.coffee +7 -3
- data/app/assets/javascripts/luca/components/table_view_scrollable.coffee +23 -0
- data/app/assets/javascripts/luca/concerns/collection_event_bindings.coffee +4 -1
- data/app/assets/javascripts/luca/concerns/development_tool_helpers.coffee +23 -14
- data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
- data/app/assets/javascripts/luca/concerns/filterable.coffee +8 -11
- data/app/assets/javascripts/luca/concerns/form_model_bindings.coffee +20 -0
- data/app/assets/javascripts/luca/concerns/modal_view.coffee +40 -15
- data/app/assets/javascripts/luca/concerns/query_collection_bindings.coffee +7 -1
- data/app/assets/javascripts/luca/concerns/state_model.coffee +40 -26
- data/app/assets/javascripts/luca/concerns/templating.coffee +3 -1
- data/app/assets/javascripts/luca/config.coffee +5 -0
- data/app/assets/javascripts/luca/containers/card_view.coffee +87 -52
- data/app/assets/javascripts/luca/containers/container.coffee +305 -108
- data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
- data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
- data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +5 -6
- data/app/assets/javascripts/luca/containers/tab_view.coffee +19 -10
- data/app/assets/javascripts/luca/containers/viewport.coffee +12 -16
- data/app/assets/javascripts/luca/core/collection.coffee +19 -5
- data/app/assets/javascripts/luca/core/events.coffee +5 -5
- data/app/assets/javascripts/luca/core/model.coffee +1 -1
- data/app/assets/javascripts/luca/core/panel.coffee +18 -6
- data/app/assets/javascripts/luca/core/registry/component_definition.coffee +2 -1
- data/app/assets/javascripts/luca/core/registry/meta_data.coffee +2 -0
- data/app/assets/javascripts/luca/core/registry/registry.coffee +14 -11
- data/app/assets/javascripts/luca/core/templates.coffee +5 -1
- data/app/assets/javascripts/luca/core/view.coffee +200 -47
- data/app/assets/javascripts/luca/dependencies.coffee +2 -0
- data/app/assets/javascripts/luca/development/code_sync_manager.coffee +173 -0
- data/app/assets/javascripts/luca/development/component.coffee +76 -0
- data/app/assets/javascripts/luca/development/components.coffee +57 -0
- data/app/assets/javascripts/luca/development/console.coffee +1 -1
- data/app/assets/javascripts/luca/development/index.coffee +4 -1
- data/app/assets/javascripts/luca/framework.coffee +7 -3
- data/app/assets/javascripts/luca/index.coffee +2 -1
- data/app/assets/javascripts/luca/managers/collection_manager.coffee +2 -3
- data/app/assets/javascripts/luca/managers/index.coffee +1 -1
- data/app/assets/javascripts/luca/managers/socket_manager.coffee +31 -8
- data/app/assets/javascripts/luca/templates/components/nav_bar.jst.ejs +16 -1
- data/app/assets/javascripts/luca/templates/containers/tab_view.jst.ejs +1 -1
- data/app/assets/javascripts/luca/util/index.coffee +1 -0
- data/app/assets/javascripts/luca/util/keybindings.coffee +24 -0
- data/app/assets/javascripts/luca/util/logging.coffee +15 -0
- data/app/assets/javascripts/luca/util/luca.coffee +9 -1
- data/app/assets/stylesheets/luca/components/table_view.scss +85 -0
- data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
- data/app/assets/stylesheets/luca/containers/container.scss +8 -0
- data/app/assets/stylesheets/luca/index.css +2 -2
- data/bin/luca +14 -0
- data/config.ru +1 -2
- data/docs/framework.json +1 -0
- data/docs/luca-framework-documentation.js +1 -0
- data/docs/{application.md → old/application.md} +0 -0
- data/docs/{collection.md → old/collection.md} +0 -0
- data/docs/{collection_manager.md → old/collection_manager.md} +0 -0
- data/docs/{container_philosophy.md → old/container_philosophy.md} +0 -0
- data/docs/{event_binding_helpers.md → old/event_binding_helpers.md} +0 -0
- data/docs/{method_caching_and_computed_properties.md → old/method_caching_and_computed_properties.md} +0 -0
- data/docs/{view.md → old/view.md} +0 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.coffee +2 -5
- data/lib/guard/luca.rb +84 -0
- data/lib/luca.rb +25 -1
- data/lib/luca/asset_compiler.rb +117 -0
- data/lib/luca/cli.rb +68 -0
- data/lib/luca/cli/generate.rb +37 -0
- data/lib/luca/cli/server.rb +20 -0
- data/lib/luca/cli/sync.rb +40 -0
- data/lib/luca/cli/watch.rb +16 -0
- data/lib/luca/collection.rb +64 -0
- data/lib/luca/collection/endpoint.rb +38 -0
- data/lib/luca/collection/file_backend.rb +121 -0
- data/lib/luca/collection/redis_backend.rb +153 -0
- data/lib/luca/compiled_asset.rb +61 -0
- data/lib/luca/component_definition.rb +356 -0
- data/lib/luca/luca_application.rb +258 -0
- data/lib/luca/project.rb +73 -0
- data/lib/luca/project_harness.rb +96 -0
- data/lib/luca/rails.rb +5 -3
- data/lib/luca/rails/engine.rb +8 -0
- data/lib/luca/rails/version.rb +1 -2
- data/lib/luca/server.rb +7 -0
- data/lib/luca/stylesheet.rb +35 -0
- data/lib/luca/template.rb +2 -0
- data/lib/luca/template_asset.rb +64 -0
- data/lib/luca/version.rb +3 -0
- data/lib/luca/watcher.rb +72 -0
- data/lib/railties/luca/tasks.rake +7 -0
- data/site/.bundle/config +2 -0
- data/site/.gitignore +5 -0
- data/site/.rvmrc +1 -0
- data/site/CHANGELOG.md +41 -0
- data/site/DOCS.md +41 -0
- data/site/Gemfile +8 -0
- data/site/Gemfile.lock +134 -0
- data/site/LICENSE.md +19 -0
- data/site/config.rb +84 -0
- data/site/helpers/site_helpers.rb +20 -0
- data/site/html5bp-docs/README.md +38 -0
- data/site/html5bp-docs/contribute.md +104 -0
- data/site/html5bp-docs/crossdomain.md +21 -0
- data/site/html5bp-docs/css.md +135 -0
- data/site/html5bp-docs/extend.md +507 -0
- data/site/html5bp-docs/faq.md +77 -0
- data/site/html5bp-docs/htaccess.md +323 -0
- data/site/html5bp-docs/html.md +170 -0
- data/site/html5bp-docs/js.md +31 -0
- data/site/html5bp-docs/misc.md +25 -0
- data/site/html5bp-docs/usage.md +109 -0
- data/site/readme.md +47 -0
- data/site/source/.htaccess +540 -0
- data/site/source/404.html +157 -0
- data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
- data/site/source/app/assets/javascripts/docs-docs.js +1 -0
- data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
- data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
- data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
- data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
- data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
- data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
- data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
- data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
- data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
- data/{spec/components/application_spec.coffee → site/source/app/assets/javascripts/docs/lib/util.coffee} +0 -0
- data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
- data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
- data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
- data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
- data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
- data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
- data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
- data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
- data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
- data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
- data/{spec/components/collection_loader_view_spec.coffee → site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee} +0 -0
- data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
- data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
- data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
- data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
- data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
- data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
- data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
- data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
- data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
- data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
- data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
- data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
- data/site/source/app/assets/javascripts/luca-docs.js +1 -0
- data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
- data/site/source/app/assets/javascripts/site.js.coffee +4 -0
- data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
- data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
- data/site/source/app/assets/javascripts/vendor/css.js +465 -0
- data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
- data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
- data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
- data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
- data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
- data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
- data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
- data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
- data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
- data/site/source/app/assets/stylesheets/site.css.scss +2 -0
- data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
- data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
- data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
- data/site/source/crossdomain.xml +15 -0
- data/site/source/documentation.html.haml +1 -0
- data/site/source/favicon_base.png +0 -0
- data/site/source/humans.txt +15 -0
- data/site/source/images/background.png +0 -0
- data/site/source/images/middleman.png +0 -0
- data/site/source/index.html.haml +1 -0
- data/site/source/layouts/layout.haml +55 -0
- data/site/source/readme.md +63 -0
- data/site/source/robots.txt +3 -0
- data/spec/{components/grid_view_spec.coffee → javascripts/components/application_spec.coffee} +0 -0
- data/spec/{components/pagination_control_spec.coffee → javascripts/components/collection_loader_view_spec.coffee} +0 -0
- data/spec/{components → javascripts/components}/collection_view_spec.coffee +1 -1
- data/spec/{components → javascripts/components}/controller_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/fields/checkbox_array_spec.coffee +0 -0
- data/spec/javascripts/components/form_view_spec.coffee +162 -0
- data/spec/{components/record_manager_spec.coffee → javascripts/components/grid_view_spec.coffee} +0 -0
- data/spec/{components → javascripts/components}/multi_collection_view_spec.coffee +0 -0
- data/spec/{components/template_spec.coffee → javascripts/components/pagination_control_spec.coffee} +0 -0
- data/spec/{concerns/paginatable_spec.coffee → javascripts/components/record_manager_spec.coffee} +0 -0
- data/spec/{components → javascripts/components}/table_view_spec.coffee +0 -0
- data/spec/{containers/modal_view_spec.coffee → javascripts/components/template_spec.coffee} +0 -0
- data/spec/{concerns → javascripts/concerns}/collection_event_bindings_spec.coffee +0 -0
- data/spec/{concerns → javascripts/concerns}/dom_helpers_spec.coffee +0 -0
- data/spec/{concerns → javascripts/concerns}/filterable_spec.coffee +0 -0
- data/spec/{concerns → javascripts/concerns}/model_presenter_spec.coffee +0 -0
- data/spec/{containers/panel_view_spec.coffee → javascripts/concerns/paginatable_spec.coffee} +0 -0
- data/spec/{concerns → javascripts/concerns}/state_model_spec.coffee +5 -0
- data/spec/javascripts/containers/card_view_spec.coffee +108 -0
- data/spec/{containers/tab_view_spec.coffee → javascripts/containers/modal_view_spec.coffee} +0 -0
- data/spec/{containers/viewport_spec.coffee → javascripts/containers/panel_view_spec.coffee} +0 -0
- data/spec/{core/observer_spec.coffee → javascripts/containers/tab_view_spec.coffee} +0 -0
- data/spec/{managers/socket_manager_spec.coffee → javascripts/containers/viewport_spec.coffee} +0 -0
- data/spec/{core → javascripts/core}/collection_spec.coffee +1 -1
- data/spec/{core → javascripts/core}/concerns_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/container_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/define_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/events_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/field_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/framework_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/model_spec.coffee +0 -0
- data/spec/javascripts/core/observer_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/util_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/view_spec.coffee +51 -39
- data/spec/{dependencies → javascripts/dependencies}/index.coffee +0 -0
- data/spec/{dependencies → javascripts/dependencies}/jasmine-html.js +0 -0
- data/spec/{dependencies → javascripts/dependencies}/jasmine.js +0 -0
- data/spec/{dependencies → javascripts/dependencies}/sinon.js +0 -0
- data/spec/{helper.coffee → javascripts/helper.coffee} +0 -0
- data/spec/{managers → javascripts/managers}/collection_manager_spec.coffee +0 -0
- data/spec/javascripts/managers/socket_manager_spec.coffee +0 -0
- data/spec/lib/component_definition_spec.rb +63 -0
- data/spec/lib/input_compiler_spec.rb +9 -0
- data/spec/lib/luca_application_spec.rb +30 -0
- data/spec/support/fixtures/application.coffee +45 -0
- data/spec/support/fixtures/component.coffee +34 -0
- data/tutorials/component-definitions.md +0 -0
- data/tutorials/component-definitions/01_intro.md +0 -0
- data/tutorials/component-driven-design.md +140 -0
- data/tutorials/structure-of-a-project.md +63 -0
- data/vendor/assets/javascripts/backbone-min.js +37 -33
- data/vendor/assets/javascripts/backbone-query.min.js +1 -1
- data/vendor/assets/javascripts/hogan.js +707 -0
- data/vendor/assets/javascripts/jquery.js +5 -4
- data/vendor/assets/javascripts/keymaster.min.js +4 -0
- data/vendor/assets/javascripts/luca-dependencies.min.js +8 -0
- data/vendor/assets/javascripts/luca-development.min.js +1 -0
- data/vendor/assets/javascripts/luca-spec.js +6 -6
- data/vendor/assets/javascripts/luca-ui.js +7386 -0
- data/vendor/assets/javascripts/luca-ui.min.js +5 -0
- data/vendor/assets/javascripts/luca.full.min.js +12 -0
- data/vendor/assets/javascripts/luca.min.js +5 -0
- data/vendor/assets/javascripts/underscore-min.js +1 -5
- data/vendor/assets/javascripts/underscore-string.min.js +1 -1
- data/vendor/assets/stylesheets/luca-components.css +202 -0
- data/vendor/assets/stylesheets/luca-development.css +23 -0
- data/vendor/assets/stylesheets/luca-ui.css +198 -0
- metadata +324 -94
- data/app/assets/javascripts/luca/components/base_toolbar.coffee +0 -17
- data/app/assets/javascripts/luca/components/form_button_toolbar.coffee +0 -28
- data/app/assets/javascripts/luca/components/grid_view.coffee +0 -269
- data/app/assets/javascripts/luca/components/page_controller.coffee +0 -7
- data/app/assets/javascripts/luca/components/template.coffee +0 -5
- data/app/assets/javascripts/luca/components/toolbar_dialog.coffee +0 -25
- data/lib/luca/code_browser.rb +0 -55
- data/lib/luca/command_line.rb +0 -69
- data/lib/luca/component_documentation.rb +0 -72
- data/site/assets/bootstrap.min.js +0 -7
- data/site/assets/dependencies.js +0 -94
- data/site/assets/glyphicons-halflings-white.png +0 -0
- data/site/assets/glyphicons-halflings.png +0 -0
- data/site/assets/luca-ui-bootstrap.css +0 -1331
- data/site/assets/luca-ui-bootstrap.js +0 -9
- data/site/assets/luca-ui-development-tools.css +0 -234
- data/site/assets/luca-ui-development-tools.js +0 -18561
- data/site/assets/luca-ui-development-tools.min.js +0 -15
- data/site/assets/luca-ui-full.min.js +0 -8
- data/site/assets/luca-ui.min.js +0 -4
- data/site/assets/sandbox.css +0 -62
- data/site/assets/sandbox.js +0 -469
- data/site/docs/application.html +0 -41
- data/site/docs/caching.html +0 -43
- data/site/docs/collection.html +0 -75
- data/site/docs/collection_manager.html +0 -71
- data/site/docs/containers.html +0 -118
- data/site/docs/events.html +0 -153
- data/site/docs/view.html +0 -128
- data/site/img/glyphicons-halflings-white.png +0 -0
- data/site/img/glyphicons-halflings.png +0 -0
- data/site/index.html +0 -20
- data/site/source-map.js +0 -1
- data/spec/components/form_view_spec.coffee +0 -84
- data/spec/containers/card_view_spec.coffee +0 -50
- data/spec/luca-spec.coffee +0 -9
File without changes
|
File without changes
|
File without changes
|
data/spec/{managers/socket_manager_spec.coffee → javascripts/containers/viewport_spec.coffee}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,10 +1,59 @@
|
|
1
|
+
describe "Inheriting Events", ->
|
2
|
+
beforeEach ->
|
3
|
+
eventTester = Luca.register("Luca.EventTester").extends("Luca.View")
|
4
|
+
eventTester.defines
|
5
|
+
_inheritEvents:
|
6
|
+
"click input" : "clickHandler"
|
7
|
+
|
8
|
+
bodyTemplate: ()->
|
9
|
+
"<input type='text' />"
|
10
|
+
|
11
|
+
clickHandler: ()->
|
12
|
+
@trigger("clicked:on:me")
|
13
|
+
|
14
|
+
inheritor = Luca.register("Luca.EventInheritor").extends("Luca.EventTester")
|
15
|
+
inheritor.defines
|
16
|
+
events:
|
17
|
+
"blur input": "blurHandler"
|
18
|
+
|
19
|
+
hmm: ()->
|
20
|
+
@trigger("hmm:what")
|
21
|
+
|
22
|
+
blurHandler: ()->
|
23
|
+
@trigger("blurred:me")
|
24
|
+
|
25
|
+
it "should register event handlers", ->
|
26
|
+
view = new Luca.EventInheritor()
|
27
|
+
view.render()
|
28
|
+
view.registerEvent("keydown input", "hmm")
|
29
|
+
expect( view.events["keydown input"] ).toEqual "hmm"
|
30
|
+
|
31
|
+
it "should register event handlers", ->
|
32
|
+
view = new Luca.EventInheritor()
|
33
|
+
view.render()
|
34
|
+
expect( _(view.events).keys().length ).toEqual 2
|
35
|
+
|
36
|
+
it "should inherit dom events defined under _inheritEvents", ->
|
37
|
+
view = new Luca.EventInheritor()
|
38
|
+
view.render()
|
39
|
+
view.$('input').trigger("click")
|
40
|
+
expect( view ).toHaveTriggered("clicked:on:me")
|
41
|
+
|
42
|
+
it "should rely on events as normal", ->
|
43
|
+
view = new Luca.EventInheritor()
|
44
|
+
view.render()
|
45
|
+
view.$('input').trigger("blur")
|
46
|
+
expect( view ).toHaveTriggered("blurred:me")
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
1
51
|
# In order to maintain backward compatibility with older apps,
|
2
52
|
# I feel compelled to keep around the old deferrable hack job that is in place.
|
3
53
|
#
|
4
54
|
# However, selectively, I will go through and upgrade the way
|
5
55
|
# render() gets wrapped on luca components, so that the API is easier
|
6
56
|
# to understand.
|
7
|
-
|
8
57
|
describe 'Rendering Strategies', ->
|
9
58
|
Luca.View.renderStrategies.spy = sinon.spy()
|
10
59
|
Luca.View.renderStrategies.spec = (_userSpecified)->
|
@@ -102,43 +151,6 @@ describe "Luca.View", ->
|
|
102
151
|
view = new Luca.View(additionalClassNames:"yes-yes yall")
|
103
152
|
expect( view.$el.is(".yes-yes.yall") ).toEqual true
|
104
153
|
|
105
|
-
|
106
|
-
describe "Development Tool Helpers", ->
|
107
|
-
beforeEach ->
|
108
|
-
_.def("Luca.views.IntrospectionView").extends("Luca.View").with
|
109
|
-
include:["Luca.concerns.DevelopmentToolHelpers"]
|
110
|
-
|
111
|
-
@view = new Luca.views.IntrospectionView
|
112
|
-
events:
|
113
|
-
"click .a" : "clickHandler"
|
114
|
-
"hover .a" : "hoverHandler"
|
115
|
-
|
116
|
-
clickHandler: ()-> "click"
|
117
|
-
hoverHandler: ()-> "hover"
|
118
|
-
|
119
|
-
collection_one: new Luca.Collection([],name:"collection_one")
|
120
|
-
collection_two: new Luca.Collection([],name:"collection_two")
|
121
|
-
view_one: new Luca.View(name:"view_one")
|
122
|
-
view_two: new Luca.View(name:"view_two")
|
123
|
-
model_one: new Luca.Model(name:"model_one")
|
124
|
-
model_two: new Luca.Model(name:"model_two")
|
125
|
-
|
126
|
-
it "should know the names of functions which are event handlers", ->
|
127
|
-
names = @view.eventHandlerProperties()
|
128
|
-
expect( names ).toEqual ["clickHandler","hoverHandler"]
|
129
|
-
|
130
|
-
it "should know which properties are other views", ->
|
131
|
-
viewNames = _( @view.views() ).pluck("name")
|
132
|
-
expect( viewNames ).toEqual ["view_one","view_two"]
|
133
|
-
|
134
|
-
it "should know which properties are other models", ->
|
135
|
-
modelNames = _( @view.models() ).map (m)-> m.get('name')
|
136
|
-
expect( modelNames ).toEqual ["model_one","model_two"]
|
137
|
-
|
138
|
-
it "should know which properties are other collections", ->
|
139
|
-
collectionNames = _( @view.collections() ).pluck("name")
|
140
|
-
expect( collectionNames ).toEqual ["collection_one","collection_two"]
|
141
|
-
|
142
154
|
describe "DOM Helper Methods", ->
|
143
155
|
it "should use the $html method to inject into the $el", ->
|
144
156
|
view = new Luca.View()
|
@@ -219,7 +231,7 @@ describe "The Collection Events API", ->
|
|
219
231
|
@manager ||= new SampleManager()
|
220
232
|
@collection = @manager.getOrCreate("sample")
|
221
233
|
|
222
|
-
|
234
|
+
xit "should call the resetHandler callback on the view", ->
|
223
235
|
view = new SampleView()
|
224
236
|
collection = @manager.get("sample")
|
225
237
|
collection.reset([])
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ComponentDefinition do
|
4
|
+
let(:path) { File.join(Rails.root,"spec","support","fixtures","component.coffee")}
|
5
|
+
let(:definition) { ComponentDefinition.new(path) }
|
6
|
+
|
7
|
+
it "should be valid" do
|
8
|
+
definition.should be_valid
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should recognize the class being defined" do
|
12
|
+
definition.class_name.should == "Luca.SampleComponent"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should know the type alias" do
|
16
|
+
definition.type_alias.should == "sample_component"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be view based" do
|
20
|
+
definition.should be_view_based
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have a css class identifier" do
|
24
|
+
definition.css_class_identifier.should == "luca-sample-component"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should know the class it extends" do
|
28
|
+
definition.extends.should == "Luca.View"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should detect the definition variable name" do
|
32
|
+
definition.definition_proxy_variable_name.should == "component"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should tell me which methods are defined" do
|
36
|
+
definition.defines_methods.should == ["methodOne","methodTwo"]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should tell me which properties are defined" do
|
40
|
+
definition.defines_properties.should == ["privateSetting","el","bodyClassName", "publicSetting"]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should tell me where a method is defined" do
|
44
|
+
definition.find_definition_of("methodOne").line_number.should > 0
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should tell me where a property is defined" do
|
48
|
+
definition.find_definition_of("privateSetting").line_number.should > 0
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should find the documentation for a method definition" do
|
52
|
+
definition.find_comments_above("methodOne").should_not be_empty
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should produce human readable documentation for a method definition" do
|
56
|
+
definition.documentation_for("methodOne").should == "here is some documentation for methodOne"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not pick up things which aren't documentation" do
|
60
|
+
definition.documentation_for("bodyClassName").should == ""
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LucaApplication do
|
4
|
+
let(:repo) { LucaApplication.new("tools") }
|
5
|
+
let(:application_file_path) { File.join(repo.send(:coffeescripts_location),'tools_application.coffee') }
|
6
|
+
|
7
|
+
it "should retrieve source code for a component" do
|
8
|
+
source_length = repo.source_code_for_class("Tools.Application").length
|
9
|
+
file_length = File.size( repo.find_definition_file_for_class('Tools.Application') )
|
10
|
+
file_length.should be_within(5).of( source_length )
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should map all component definitions to their respective files" do
|
14
|
+
map = repo.component_definition_filemap
|
15
|
+
map["Tools.Application"].should == application_file_path
|
16
|
+
end
|
17
|
+
|
18
|
+
xit "should find a template object by its filename" do
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should find a component definition by class name" do
|
22
|
+
repo.find_component_definition_for_class('Tools.Application').should be_present
|
23
|
+
repo.find_component_definition_for_class('Tools.Collection').should be_present
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should detect the namespace" do
|
27
|
+
repo.namespace.should == "Tools"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
application = Tools.register "Tools.Application"
|
2
|
+
application.extends "Luca.Application"
|
3
|
+
|
4
|
+
application.configuration
|
5
|
+
el: '#viewport'
|
6
|
+
bodyClassName: "viewport-body"
|
7
|
+
|
8
|
+
bindMethods:[
|
9
|
+
"toggleLayout"
|
10
|
+
]
|
11
|
+
|
12
|
+
topToolbar:
|
13
|
+
buttons:[
|
14
|
+
label: "Toggle Layout"
|
15
|
+
eventId: "toggle:layout"
|
16
|
+
]
|
17
|
+
|
18
|
+
bottomToolbar:
|
19
|
+
buttons:[]
|
20
|
+
|
21
|
+
fluid: false
|
22
|
+
applyWrapper: false
|
23
|
+
autoBoot: false
|
24
|
+
useController: false
|
25
|
+
name: 'ToolsApp'
|
26
|
+
router: "Tools.Router"
|
27
|
+
collectionManager: "ToolsCollectionManager"
|
28
|
+
|
29
|
+
application.contains
|
30
|
+
type: "component_inspector"
|
31
|
+
role: "component_inspector"
|
32
|
+
className: "work-area row-fluid"
|
33
|
+
|
34
|
+
application.publicMethods
|
35
|
+
currentApplication: ()->
|
36
|
+
"tools"
|
37
|
+
|
38
|
+
toggleLayout: ()->
|
39
|
+
Tools().getComponentInspector().cycleLayout()
|
40
|
+
|
41
|
+
application.privateMethods
|
42
|
+
boundaries: ()->
|
43
|
+
[0,60,400,460]
|
44
|
+
|
45
|
+
application.register()
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# This is a sample component definition file
|
2
|
+
# for the luca framework. The header of the file
|
3
|
+
# is used to describe the general purpose of the component.
|
4
|
+
component = Luca.register "Luca.SampleComponent"
|
5
|
+
component.extends "Luca.View"
|
6
|
+
|
7
|
+
# We can comment on a specific entry such as the mixins.
|
8
|
+
component.mixesIn "SomeMixin"
|
9
|
+
|
10
|
+
component.privateConfiguration
|
11
|
+
# this is a basic description of the private setting.
|
12
|
+
# expects: Boolean
|
13
|
+
privateSetting: false
|
14
|
+
el: '#viewport'
|
15
|
+
bodyClassName: "viewport-body"
|
16
|
+
|
17
|
+
component.publicConfiguration
|
18
|
+
# this is a comment for the public setting
|
19
|
+
publicSetting: ["1,2,3"]
|
20
|
+
|
21
|
+
component.publicMethods
|
22
|
+
# here is some documentation for methodOne
|
23
|
+
methodOne: ()->
|
24
|
+
@thisIsSomeMethodicalShitSon()
|
25
|
+
@puttingAllsortsOfCode
|
26
|
+
allUp: "InYo"
|
27
|
+
bidness: "Baby"
|
28
|
+
|
29
|
+
# here is a multi line comment for methodTwo
|
30
|
+
# it is pretty dope
|
31
|
+
# that i can do this
|
32
|
+
methodTwo: (butThistime="withSomArguments", youKnow=[], man={})->
|
33
|
+
@okCool()
|
34
|
+
|
File without changes
|
File without changes
|
@@ -0,0 +1,140 @@
|
|
1
|
+
## Component Driven Design
|
2
|
+
|
3
|
+
The Luca framework is designed to encourage Component Driven Design for your single page application. In the simplest instance, components can be single purpose elements composed of a View, an optional Template, and CSS. Or, as your application grows in complexity, your components will grow to encapsulate multiple smaller components.
|
4
|
+
|
5
|
+
Good component design dictates that each component should only care about itself and not be aware of anything outside of it. A good component provides a public API for working with everything inside of it.
|
6
|
+
|
7
|
+
Luca provides a special type of View called 'Luca.Container` which is designed to faciliate the communication between multiple components.
|
8
|
+
|
9
|
+
|
10
|
+
### Component Definition Registry
|
11
|
+
|
12
|
+
The component definition style employed by Luca makes it easy to manage a registry of components in your application. It provides more granular methods for definining the properties and methods on your component prototype. In the end, everything
|
13
|
+
gets put together and the component is defined just as you would define a standard Backbone component.
|
14
|
+
|
15
|
+
In Luca, you can call Luca.View.extend just as you would Backbone.View.extend. But doing so will bypass the component registry
|
16
|
+
and a lot of the helpers in the framework that are designed to help you manage the complexity of your application as it grows.
|
17
|
+
|
18
|
+
#### Step One: Defining a simple list component
|
19
|
+
```
|
20
|
+
list = App.register "App.views.BooksList"
|
21
|
+
list.extends "Luca.CollectionView"
|
22
|
+
|
23
|
+
list.defines
|
24
|
+
autoBindEventHandlers: true
|
25
|
+
events:
|
26
|
+
"click .book" : "selectBook"
|
27
|
+
|
28
|
+
collection: "books"
|
29
|
+
itemTemplate: "book_listing"
|
30
|
+
itemClassName: "book"
|
31
|
+
|
32
|
+
selectBook: (e)->
|
33
|
+
$element = $(e.target)
|
34
|
+
bookId = $element.data('model-id')
|
35
|
+
bookModel = @collection.get(bookId)
|
36
|
+
|
37
|
+
@trigger "book:selected", bookModel, e
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
#### Step Two: Defining a details view
|
42
|
+
|
43
|
+
Below we will define another component. The syntax below is optional, and is essentially the same as above, however we will take advantage of the more granular options available to us for the purpose of making our definition more readable. Here we are explicit about our intent for the method `@renderBookDetails` by specifying it as public, any component which makes use of this knows that it will interact with the public interface.
|
44
|
+
|
45
|
+
In addition to providing more readable code, these methods are used to automatically generate nice documentation for your components.
|
46
|
+
|
47
|
+
```
|
48
|
+
details = App.register "App.views.BookDetails"
|
49
|
+
|
50
|
+
details.extends "Luca.View"
|
51
|
+
|
52
|
+
|
53
|
+
details.publicMethods
|
54
|
+
renderBookDetails: (bookModel)->
|
55
|
+
@$el.html( Luca.template("book_details", bookModel))
|
56
|
+
|
57
|
+
|
58
|
+
details.register() # the call to register is the same as defines() but is more readable on its own.
|
59
|
+
```
|
60
|
+
|
61
|
+
#### Step Three: Putting the components together
|
62
|
+
|
63
|
+
Now that we have defined two components, they can be used on their own or as members of a larger composite view.
|
64
|
+
|
65
|
+
In the below example, we create a `Luca.Container` which contains the two components we defined above and facilitates
|
66
|
+
communication between them by listening to the events they emit and passing them to interested parties.
|
67
|
+
|
68
|
+
```
|
69
|
+
browser = App.register "App.views.BooksBrowser"
|
70
|
+
|
71
|
+
browser.extends "Luca.Container"
|
72
|
+
|
73
|
+
component.defines
|
74
|
+
# This component will be unique, there will only ever be one instance of it.
|
75
|
+
# Other parts of our application will be able to access it by `App("books_browser")`
|
76
|
+
name: "books_browser"
|
77
|
+
|
78
|
+
# Will be rendered with the `row-fluid` class on it. Enabling our subcomponents
|
79
|
+
# to add their own `span6` classes to position themselves in a bootstrap style grid.
|
80
|
+
rowFluid: true
|
81
|
+
|
82
|
+
# faciliate the communication between our subcomponents by listening to the events
|
83
|
+
# they emit and routing them to interested parties.
|
84
|
+
componentEvents:
|
85
|
+
"list book:selected" : "viewBookDetails"
|
86
|
+
|
87
|
+
components:
|
88
|
+
role: "list"
|
89
|
+
type: "books_list"
|
90
|
+
span: 3
|
91
|
+
,
|
92
|
+
role: "details"
|
93
|
+
type: "book_details"
|
94
|
+
span: 9
|
95
|
+
|
96
|
+
# This method will get called in response to the componentEvent binding that we declared.
|
97
|
+
# It will take the message and pass it to the component with the role `details`
|
98
|
+
viewBookDetails: (bookModel)->
|
99
|
+
@getDetails().renderBookDetails(bookModel)
|
100
|
+
```
|
101
|
+
|
102
|
+
#### A Note on the @type alias:
|
103
|
+
|
104
|
+
Whenever you register a component using the style above, type aliases will be created for you. `BookDetails` will be `book_details`, `BooksBrowser` will be `books_browser` and so on. This allows you to compose containers by specifying a JSON object with strings, as opposed to manually instantiating the object yourself and having to type out the full name of the component every time.
|
105
|
+
|
106
|
+
#### Using your components
|
107
|
+
|
108
|
+
The components we defined can be used in isolation, or as parts of other components.
|
109
|
+
|
110
|
+
We could simply render the BooksBrowser into the DOM directly:
|
111
|
+
|
112
|
+
```
|
113
|
+
browser = new App.views.BooksBrowser()
|
114
|
+
$('body').html( browser.render().el )
|
115
|
+
```
|
116
|
+
|
117
|
+
Or include it in a page of our application:
|
118
|
+
|
119
|
+
```
|
120
|
+
MyApp = new App.Application
|
121
|
+
routes:
|
122
|
+
"" : "books_browser"
|
123
|
+
"books/:title" : "books_browser#loadBook"
|
124
|
+
|
125
|
+
collectionManager:
|
126
|
+
initialCollections:[
|
127
|
+
"books"
|
128
|
+
]
|
129
|
+
|
130
|
+
getCollection: (collectionName)->
|
131
|
+
@collectionManager.getOrCreate(collectionName)
|
132
|
+
|
133
|
+
components:[
|
134
|
+
name: "books_browser"
|
135
|
+
type: "books_browser"
|
136
|
+
loadBook: (title)->
|
137
|
+
bookModel = App().getCollection("books").findByTitle(title)
|
138
|
+
@viewBookDetails(bookModel)
|
139
|
+
]
|
140
|
+
```
|