luca 0.9.76 → 0.9.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +65 -2
- data/Gemfile +4 -0
- data/Gemfile.lock +18 -2
- data/Guardfile +3 -25
- data/README.md +50 -58
- data/ROADMAP +15 -32
- data/Rakefile +18 -77
- data/app.rb +12 -46
- data/{assets → app/assets}/images/glyphicons-halflings-white.png +0 -0
- data/{assets → app/assets}/images/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/luca-ui.js +1 -0
- data/app/assets/javascripts/luca/basic.coffee +8 -0
- data/{src → app/assets/javascripts/luca}/components/application.coffee +233 -65
- data/{src → app/assets/javascripts/luca}/components/collection_loader_view.coffee +0 -0
- data/app/assets/javascripts/luca/components/collection_view.coffee +207 -0
- data/{src → app/assets/javascripts/luca}/components/controller.coffee +27 -13
- data/{src/core/field.coffee → app/assets/javascripts/luca/components/fields/base.coffee} +18 -10
- data/{src → app/assets/javascripts/luca}/components/fields/button_field.coffee +8 -9
- data/{src → app/assets/javascripts/luca}/components/fields/checkbox_array.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/components/fields/checkbox_field.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/components/fields/file_upload_field.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/components/fields/hidden_field.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/components/fields/label_field.coffee +0 -0
- data/app/assets/javascripts/luca/components/fields/select_field.coffee +159 -0
- data/app/assets/javascripts/luca/components/fields/text_area_field.coffee +57 -0
- data/{src → app/assets/javascripts/luca}/components/fields/text_field.coffee +9 -3
- data/{src → app/assets/javascripts/luca}/components/fields/type_ahead_field.coffee +0 -0
- data/app/assets/javascripts/luca/components/form_view.coffee +421 -0
- data/app/assets/javascripts/luca/components/grid_layout_view.coffee +43 -0
- data/app/assets/javascripts/luca/components/index.coffee +7 -0
- data/app/assets/javascripts/luca/components/load_mask.coffee +8 -0
- data/{src → app/assets/javascripts/luca}/components/multi_collection_view.coffee +34 -34
- data/app/assets/javascripts/luca/components/nav_bar.coffee +80 -0
- data/app/assets/javascripts/luca/components/page.coffee +69 -0
- data/app/assets/javascripts/luca/components/page_controller.coffee +3 -0
- data/{src → app/assets/javascripts/luca}/components/pagination_control.coffee +13 -13
- data/{src → app/assets/javascripts/luca}/components/record_manager.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/components/router.coffee +4 -1
- data/app/assets/javascripts/luca/components/simple_collection_view.coffee +10 -0
- data/app/assets/javascripts/luca/components/table_view.coffee +93 -0
- data/app/assets/javascripts/luca/components/table_view_scrollable.coffee +23 -0
- data/{src → app/assets/javascripts/luca}/concerns/application_event_bindings.coffee +1 -1
- data/app/assets/javascripts/luca/concerns/collection_event_bindings.coffee +47 -0
- data/{src → app/assets/javascripts/luca}/concerns/deferrable.coffee +1 -2
- data/app/assets/javascripts/luca/concerns/development_tool_helpers.coffee +30 -0
- data/{src → app/assets/javascripts/luca}/concerns/dom_helpers.coffee +10 -7
- data/{src → app/assets/javascripts/luca}/concerns/enhanced_properties.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/concerns/filterable.coffee +39 -20
- data/app/assets/javascripts/luca/concerns/form_model_bindings.coffee +20 -0
- data/{src → app/assets/javascripts/luca}/concerns/grid_layout.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/concerns/loadmaskable.coffee +17 -11
- data/{src → app/assets/javascripts/luca}/concerns/local_storage.coffee +0 -0
- data/app/assets/javascripts/luca/concerns/modal_view.coffee +63 -0
- data/{src → app/assets/javascripts/luca}/concerns/model_presenter.coffee +0 -0
- data/{src → app/assets/javascripts/luca}/concerns/paginatable.coffee +6 -20
- data/{src → app/assets/javascripts/luca}/concerns/query_collection_bindings.coffee +16 -8
- data/app/assets/javascripts/luca/concerns/sortable.coffee +69 -0
- data/app/assets/javascripts/luca/concerns/state_model.coffee +58 -0
- data/{src → app/assets/javascripts/luca}/concerns/templating.coffee +6 -1
- data/app/assets/javascripts/luca/config.coffee +54 -0
- data/{src → app/assets/javascripts/luca}/containers/card_view.coffee +23 -8
- data/{src/core → app/assets/javascripts/luca/containers}/container.coffee +228 -77
- data/app/assets/javascripts/luca/containers/index.coffee +2 -0
- data/{src → app/assets/javascripts/luca}/containers/modal_view.coffee +1 -1
- data/{src → app/assets/javascripts/luca}/containers/panel_toolbar.coffee +5 -6
- data/{src → app/assets/javascripts/luca}/containers/tab_view.coffee +19 -10
- data/{src → app/assets/javascripts/luca}/containers/viewport.coffee +11 -12
- data/{src → app/assets/javascripts/luca}/core/collection.coffee +37 -23
- data/{src/components → app/assets/javascripts/luca/core}/collection_view.coffee +21 -38
- data/{src/plugins → app/assets/javascripts/luca/core}/events.coffee +38 -6
- data/app/assets/javascripts/luca/core/index.coffee +12 -0
- data/{src → app/assets/javascripts/luca}/core/model.coffee +1 -1
- data/{src → app/assets/javascripts/luca}/core/observer.coffee +0 -0
- data/app/assets/javascripts/luca/core/panel.coffee +124 -0
- data/{src/define.coffee → app/assets/javascripts/luca/core/registry/component_definition.coffee} +59 -8
- data/{src → app/assets/javascripts/luca/core/registry}/concerns.coffee +0 -0
- data/app/assets/javascripts/luca/core/registry/index.coffee +4 -0
- data/{src/core → app/assets/javascripts/luca/core/registry}/meta_data.coffee +6 -0
- data/{src/core → app/assets/javascripts/luca/core/registry}/registry.coffee +20 -14
- data/app/assets/javascripts/luca/core/templates.coffee +51 -0
- data/app/assets/javascripts/luca/core/view.coffee +364 -0
- data/app/assets/javascripts/luca/dependencies.coffee +9 -0
- data/{src/tools → app/assets/javascripts/luca/development}/code_mirror_field.coffee +2 -1
- data/app/assets/javascripts/luca/development/code_sync_manager.coffee +126 -0
- data/app/assets/javascripts/luca/development/component.coffee +76 -0
- data/app/assets/javascripts/luca/development/components.coffee +57 -0
- data/{src/tools → app/assets/javascripts/luca/development}/console.coffee +6 -5
- data/app/assets/javascripts/luca/development/index.coffee +5 -0
- data/{src → app/assets/javascripts/luca}/framework.coffee +16 -99
- data/app/assets/javascripts/luca/index.coffee +8 -0
- data/{src → app/assets/javascripts/luca}/managers/collection_manager.coffee +12 -8
- data/app/assets/javascripts/luca/managers/index.coffee +2 -0
- data/app/assets/javascripts/luca/managers/socket_manager.coffee +89 -0
- data/{src → app/assets/javascripts/luca}/templates/components/bootstrap_form_controls.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/components/collection_loader_view.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/components/form_alert.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/components/grid_view.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/components/grid_view_empty_text.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/components/load_mask.jst.ejs +0 -0
- data/app/assets/javascripts/luca/templates/components/nav_bar.jst.ejs +19 -0
- data/{src → app/assets/javascripts/luca}/templates/components/pagination.jst.ejs +0 -0
- data/{src/templates → app/assets/javascripts/luca/templates/components}/table_view.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/containers/basic.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/containers/tab_selector_container.jst.ejs +0 -0
- data/app/assets/javascripts/luca/templates/containers/tab_view.jst.ejs +2 -0
- data/{src → app/assets/javascripts/luca}/templates/containers/toolbar_wrapper.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/button_field.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/button_field_link.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/checkbox_array.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/checkbox_array_item.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/checkbox_field.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/file_upload_field.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/hidden_field.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/select_field.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/text_area_field.jst.ejs +0 -0
- data/{src → app/assets/javascripts/luca}/templates/fields/text_field.jst.ejs +0 -0
- data/app/assets/javascripts/luca/util/deprecations.coffee +18 -0
- data/app/assets/javascripts/luca/util/index.coffee +4 -0
- data/app/assets/javascripts/luca/util/keybindings.coffee +24 -0
- data/app/assets/javascripts/luca/util/logging.coffee +30 -0
- data/{src/util.coffee → app/assets/javascripts/luca/util/luca.coffee} +27 -4
- data/{src/core → app/assets/javascripts/luca/util}/script_loader.coffee +0 -0
- data/{src/stylesheets → app/assets/stylesheets/luca}/components/checkbox_array.scss +0 -0
- data/app/assets/stylesheets/luca/components/form_view.scss +7 -0
- data/{src/stylesheets → app/assets/stylesheets/luca}/components/grid_view.scss +0 -0
- data/{src/stylesheets → app/assets/stylesheets/luca}/components/load_mask.scss +0 -0
- data/{vendor/assets/luca-ui/components/grid_view.css → app/assets/stylesheets/luca/components/table_view.scss} +60 -51
- data/{src/stylesheets → app/assets/stylesheets/luca}/components/viewport.scss +0 -0
- data/app/assets/stylesheets/luca/containers/container.scss +19 -0
- data/{src/stylesheets → app/assets/stylesheets/luca}/containers/modal_view.scss +0 -0
- data/{src/stylesheets → app/assets/stylesheets/luca}/containers/panels.scss +0 -0
- data/{src/stylesheets → app/assets/stylesheets/luca}/containers/tab_view.scss +0 -0
- data/{src/stylesheets/tools → app/assets/stylesheets/luca/development}/console.scss +0 -0
- data/app/assets/stylesheets/luca/development/index.css +3 -0
- data/app/assets/stylesheets/luca/index.css +4 -0
- data/{src/stylesheets → app/assets/stylesheets/luca}/normalize.scss +0 -0
- data/config.ru +1 -2
- data/docs/framework.json +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/application_generator.rb +12 -8
- data/lib/generators/luca/application/templates/controller.rb +0 -2
- data/lib/generators/luca/application/templates/index.html.erb +12 -0
- data/lib/generators/luca/application/templates/index.html.haml +1 -0
- data/lib/generators/luca/application/templates/javascripts/application.coffee +18 -0
- data/lib/generators/luca/application/templates/javascripts/collection_manager.coffee +2 -0
- data/lib/generators/luca/application/templates/javascripts/config.coffee +3 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.coffee +3 -0
- data/lib/generators/luca/application/templates/javascripts/home.jst.ejs +2 -0
- data/lib/generators/luca/application/templates/javascripts/index.coffee +15 -0
- data/lib/generators/luca/application/templates/javascripts/router.coffee +4 -0
- data/lib/guard/luca.rb +84 -0
- data/lib/luca.rb +18 -1
- data/lib/luca/asset_compiler.rb +117 -0
- data/lib/luca/collection.rb +64 -0
- data/lib/luca/collection/endpoint.rb +37 -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 +338 -0
- data/lib/luca/luca_application.rb +247 -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 +12 -0
- data/lib/luca/rails/version.rb +1 -2
- data/lib/luca/stylesheet.rb +36 -0
- data/lib/luca/template.rb +2 -0
- data/lib/luca/template_asset.rb +64 -0
- data/lib/railties/luca/tasks.rake +38 -0
- data/spec/{components → javascripts/components}/application_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/collection_loader_view_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/collection_view_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/controller_spec.coffee +4 -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 → javascripts/components}/grid_view_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/multi_collection_view_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/pagination_control_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/record_manager_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/table_view_spec.coffee +0 -0
- data/spec/{components → javascripts/components}/template_spec.coffee +0 -0
- data/spec/javascripts/concerns/collection_event_bindings_spec.coffee +15 -0
- data/spec/{concerns → javascripts/concerns}/dom_helpers_spec.coffee +2 -2
- data/spec/{concerns → javascripts/concerns}/filterable_spec.coffee +4 -4
- data/spec/{concerns → javascripts/concerns}/model_presenter_spec.coffee +0 -0
- data/spec/{concerns → javascripts/concerns}/paginatable_spec.coffee +0 -0
- data/spec/javascripts/concerns/state_model_spec.coffee +55 -0
- data/spec/{containers → javascripts/containers}/card_view_spec.coffee +5 -0
- data/spec/{containers → javascripts/containers}/modal_view_spec.coffee +0 -0
- data/spec/{containers → javascripts/containers}/panel_view_spec.coffee +0 -0
- data/spec/{containers → javascripts/containers}/tab_view_spec.coffee +0 -0
- data/spec/{containers → javascripts/containers}/viewport_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/collection_spec.coffee +25 -0
- data/spec/{concerns_spec.coffee → javascripts/core/concerns_spec.coffee} +0 -0
- data/spec/{core → javascripts/core}/container_spec.coffee +8 -6
- data/spec/{define_spec.coffee → javascripts/core/define_spec.coffee} +0 -0
- data/spec/javascripts/core/events_spec.coffee +26 -0
- data/spec/{core → javascripts/core}/field_spec.coffee +0 -0
- data/spec/{framework_spec.coffee → javascripts/core/framework_spec.coffee} +1 -1
- data/spec/{core → javascripts/core}/model_spec.coffee +0 -0
- data/spec/{core → javascripts/core}/observer_spec.coffee +0 -0
- data/spec/{util_spec.coffee → javascripts/core/util_spec.coffee} +2 -2
- data/spec/{core → javascripts/core}/view_spec.coffee +114 -38
- data/spec/javascripts/dependencies/index.coffee +3 -0
- data/{assets → spec}/javascripts/dependencies/jasmine-html.js +0 -0
- data/{assets → spec}/javascripts/dependencies/jasmine.js +0 -0
- data/{assets → spec}/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/{managers → 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/{assets/javascripts/sandbox/views/inspector/instance_list.coffee → tutorials/component-definitions.md} +0 -0
- data/{spec/concerns/state_model_spec.coffee → 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-ext.js +21 -0
- data/vendor/assets/javascripts/backbone-min.js +38 -0
- data/vendor/assets/javascripts/backbone-query.min.js +1 -0
- data/vendor/assets/javascripts/bootstrap.min.js +7 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror-coffeescript.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror-css.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror-html.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror-javascript.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror-less.js +0 -0
- data/vendor/assets/javascripts/codemirror-ui.js +503 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror-vim.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror.js +0 -0
- data/vendor/assets/javascripts/hogan.js +707 -0
- data/vendor/assets/javascripts/inflections.js +656 -0
- data/vendor/assets/javascripts/jasmine-html.js +190 -0
- data/vendor/assets/javascripts/jasmine.js +2476 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/jquery.js +0 -0
- data/vendor/assets/javascripts/keymaster.min.js +4 -0
- data/vendor/assets/javascripts/luca-dependencies.min.js +6 -0
- data/vendor/assets/javascripts/luca-development.min.js +1 -0
- data/vendor/assets/javascripts/luca-spec.js +11 -0
- data/vendor/assets/javascripts/luca-ui.js +3336 -2561
- data/vendor/assets/javascripts/luca-ui.min.js +5 -5
- data/vendor/assets/javascripts/luca.full.min.js +10 -0
- data/vendor/assets/javascripts/luca.min.js +5 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/modal.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/modernizr.min.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/prettify.js +0 -0
- data/vendor/assets/javascripts/sinon.js +3469 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/spin-min.js +0 -0
- data/{assets/javascripts/dependencies → vendor/assets/javascripts}/underscore-min.js +0 -0
- data/vendor/assets/javascripts/underscore-string.min.js +1 -0
- data/vendor/assets/stylesheets/bootstrap-responsive.min.css +9 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +9 -0
- data/{assets → vendor/assets}/stylesheets/codemirror-blackboard.css +0 -0
- data/{assets → vendor/assets}/stylesheets/codemirror-monokai.css +0 -0
- data/{assets → vendor/assets}/stylesheets/codemirror.css +0 -0
- data/{assets → vendor/assets}/stylesheets/jasmine.css +0 -0
- data/vendor/assets/stylesheets/luca-components.css +204 -0
- data/vendor/assets/stylesheets/luca-development.css +23 -0
- data/vendor/assets/stylesheets/luca-ui.css +58 -461
- data/views/jasmine.erb +2 -2
- metadata +280 -336
- data/assets/javascripts/dependencies.coffee +0 -5
- data/assets/javascripts/dependencies/backbone-min.js +0 -37
- data/assets/javascripts/dependencies/backbone-query.min.js +0 -1
- data/assets/javascripts/dependencies/bootstrap.min.js +0 -7
- data/assets/javascripts/dependencies/coffee-script.js +0 -12189
- data/assets/javascripts/dependencies/underscore-string.min.js +0 -14
- data/assets/javascripts/luca-templates.js +0 -1
- data/assets/javascripts/luca-ui-base.coffee +0 -1
- data/assets/javascripts/luca-ui-bootstrap.js +0 -1
- data/assets/javascripts/luca-ui-development-tools.coffee +0 -9
- data/assets/javascripts/luca-ui-full.js +0 -3
- data/assets/javascripts/luca-ui-spec.coffee +0 -2
- data/assets/javascripts/luca-ui.js +0 -3
- data/assets/javascripts/luca/index.coffee +0 -1
- data/assets/javascripts/sandbox.coffee +0 -7
- data/assets/javascripts/sandbox/application.coffee +0 -57
- data/assets/javascripts/sandbox/config.coffee +0 -7
- data/assets/javascripts/sandbox/router.coffee +0 -24
- data/assets/javascripts/sandbox/templates/builder.luca +0 -2
- data/assets/javascripts/sandbox/templates/builder/component_list.luca +0 -1
- data/assets/javascripts/sandbox/templates/main.luca +0 -53
- data/assets/javascripts/sandbox/templates/sandbox.luca +0 -1
- data/assets/javascripts/sandbox/templates/sandbox/docs_index.luca +0 -1
- data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +0 -8
- data/assets/javascripts/sandbox/templates/sandbox/readme.luca +0 -30
- data/assets/javascripts/sandbox/views/builder.coffee +0 -133
- data/assets/javascripts/sandbox/views/builder/builder_canvas.coffee +0 -3
- data/assets/javascripts/sandbox/views/builder/builder_editor.coffee +0 -6
- data/assets/javascripts/sandbox/views/builder/component_list.coffee +0 -38
- data/assets/javascripts/sandbox/views/builder/project_browser.coffee +0 -14
- data/assets/javascripts/sandbox/views/docs_controller.coffee +0 -7
- data/assets/javascripts/sandbox/views/inspector.coffee +0 -11
- data/assets/javascripts/sandbox/views/inspector/instance_filter.coffee +0 -18
- data/assets/javascripts/sandbox/views/top_navigation.coffee +0 -4
- data/assets/javascripts/spec-dependencies.coffee +0 -4
- data/assets/stylesheets/bootstrap-responsive.min.css +0 -2
- data/assets/stylesheets/bootstrap.min.css +0 -727
- data/assets/stylesheets/luca-ui-bootstrap.css +0 -4
- data/assets/stylesheets/luca-ui-development-tools.css +0 -5
- data/assets/stylesheets/luca-ui-full.css +0 -3
- data/assets/stylesheets/luca-ui-spec.css +0 -3
- data/assets/stylesheets/luca-ui.css +0 -3
- data/assets/stylesheets/prettify.css +0 -40
- data/assets/stylesheets/sandbox.css +0 -3
- data/assets/stylesheets/sandbox/builder.scss +0 -79
- data/assets/stylesheets/sandbox/sandbox.scss +0 -18
- data/assets/stylesheets/themes/amelia-bootstrap.css +0 -826
- data/assets/stylesheets/themes/slate-bootstrap.css +0 -797
- data/assets/stylesheets/themes/superhero-bootstrap.css +0 -830
- data/lib/generators/luca/application/templates/javascripts/application.js +0 -28
- data/lib/generators/luca/application/templates/javascripts/application.js.coffee +0 -20
- data/lib/generators/luca/application/templates/javascripts/config.js +0 -15
- data/lib/generators/luca/application/templates/javascripts/config.js.coffee +0 -9
- data/lib/generators/luca/application/templates/javascripts/dependencies.js +0 -5
- data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +0 -5
- data/lib/generators/luca/application/templates/javascripts/index.js +0 -9
- data/lib/generators/luca/application/templates/javascripts/index.js.coffee +0 -9
- data/lib/generators/luca/application/templates/javascripts/main.js +0 -8
- data/lib/generators/luca/application/templates/javascripts/main.js.coffee +0 -3
- data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +0 -1
- data/lib/generators/luca/application/templates/javascripts/router.js +0 -12
- data/lib/generators/luca/application/templates/javascripts/router.js.coffee +0 -7
- data/lib/luca/code_browser.rb +0 -55
- data/lib/luca/command_line.rb +0 -69
- data/spec/components/form_view_spec.coffee +0 -84
- data/spec/containers/column_view_spec.coffee +0 -0
- data/spec/containers/split_view_spec.coffee +0 -0
- data/src/components/base_toolbar.coffee +0 -17
- data/src/components/fields/select_field.coffee +0 -96
- data/src/components/fields/text_area_field.coffee +0 -42
- data/src/components/form_button_toolbar.coffee +0 -28
- data/src/components/form_view.coffee +0 -282
- data/src/components/grid_view.coffee +0 -269
- data/src/components/index.coffee +0 -1
- data/src/components/load_mask.coffee +0 -3
- data/src/components/nav_bar.coffee +0 -22
- data/src/components/page_controller.coffee +0 -2
- data/src/components/table_view.coffee +0 -69
- data/src/components/template.coffee +0 -5
- data/src/components/toolbar_dialog.coffee +0 -25
- data/src/concerns/collection_event_bindings.coffee +0 -26
- data/src/concerns/modal_view.coffee +0 -38
- data/src/concerns/state_model.coffee +0 -16
- data/src/containers/column_view.coffee +0 -42
- data/src/containers/page_view.coffee +0 -2
- data/src/containers/panel_view.coffee +0 -23
- data/src/containers/split_view.coffee +0 -8
- data/src/core/core.coffee +0 -0
- data/src/core/panel.coffee +0 -118
- data/src/core/view.coffee +0 -172
- data/src/index.coffee +0 -25
- data/src/managers/socket_manager.coffee +0 -54
- data/src/plugins/development_tool_helpers.coffee +0 -21
- data/src/samples/definition.coffee +0 -49
- data/src/stylesheets/base.scss +0 -0
- data/src/stylesheets/components/form_view.scss +0 -59
- data/src/stylesheets/components/toolbar.scss +0 -0
- data/src/stylesheets/containers/container.scss +0 -11
- data/src/stylesheets/tools/class_browser.scss +0 -32
- data/src/stylesheets/tools/code_editor.scss +0 -24
- data/src/stylesheets/tools/component_tester.scss +0 -26
- data/src/templates/components/nav_bar.jst.ejs +0 -4
- data/src/templates/containers/tab_view.jst.ejs +0 -2
- data/src/tools/application_inspector.coffee +0 -2
- data/src/tools/code_editor.coffee +0 -258
- data/src/tools/coffee_script_editor.coffee +0 -82
- data/src/tools/collection_inspector.coffee +0 -4
- data/src/tools/collections/components.coffee +0 -59
- data/src/tools/collections/instances.coffee +0 -15
- data/src/tools/component_tester.coffee +0 -462
- data/src/tools/models/components.coffee +0 -25
- data/src/tools/models/instance.coffee +0 -2
- data/src/tools/templates/component_tester/help.luca +0 -14
- data/vendor/assets/javascripts/luca-ui-base.js +0 -5304
- data/vendor/assets/javascripts/luca-ui-bootstrap.js +0 -9
- data/vendor/assets/javascripts/luca-ui-development-tools.js +0 -18561
- data/vendor/assets/javascripts/luca-ui-development-tools.min.js +0 -15
- data/vendor/assets/javascripts/luca-ui-full.js +0 -6696
- data/vendor/assets/javascripts/luca-ui-full.min.js +0 -9
- data/vendor/assets/javascripts/luca-ui-spec.js +0 -6815
- data/vendor/assets/javascripts/luca-ui-templates.js +0 -92
- data/vendor/assets/luca-ui/base.css +0 -85
- data/vendor/assets/luca-ui/components/application.js +0 -91
- data/vendor/assets/luca-ui/components/base_toolbar.js +0 -23
- data/vendor/assets/luca-ui/components/controller.js +0 -38
- data/vendor/assets/luca-ui/components/fields/button_field.js +0 -45
- data/vendor/assets/luca-ui/components/fields/checkbox_field.js +0 -43
- data/vendor/assets/luca-ui/components/fields/file_upload_field.js +0 -20
- data/vendor/assets/luca-ui/components/fields/hidden_field.js +0 -20
- data/vendor/assets/luca-ui/components/fields/select_field.js +0 -97
- data/vendor/assets/luca-ui/components/fields/text_area_field.js +0 -48
- data/vendor/assets/luca-ui/components/fields/text_field.js +0 -46
- data/vendor/assets/luca-ui/components/fields/type_ahead_field.js +0 -13
- data/vendor/assets/luca-ui/components/form_button_toolbar.js +0 -32
- data/vendor/assets/luca-ui/components/form_view.css +0 -32
- data/vendor/assets/luca-ui/components/form_view.js +0 -207
- data/vendor/assets/luca-ui/components/grid_view.js +0 -202
- data/vendor/assets/luca-ui/components/record_manager.js +0 -207
- data/vendor/assets/luca-ui/components/router.js +0 -36
- data/vendor/assets/luca-ui/components/template.js +0 -26
- data/vendor/assets/luca-ui/components/toolbar.css +0 -11
- data/vendor/assets/luca-ui/containers/card_view.js +0 -98
- data/vendor/assets/luca-ui/containers/column_view.js +0 -52
- data/vendor/assets/luca-ui/containers/container.css +0 -3
- data/vendor/assets/luca-ui/containers/modal_view.css +0 -0
- data/vendor/assets/luca-ui/containers/modal_view.js +0 -87
- data/vendor/assets/luca-ui/containers/panel_view.js +0 -34
- data/vendor/assets/luca-ui/containers/split_view.js +0 -13
- data/vendor/assets/luca-ui/containers/tab_view.css +0 -16
- data/vendor/assets/luca-ui/containers/tab_view.js +0 -80
- data/vendor/assets/luca-ui/containers/viewport.js +0 -18
- data/vendor/assets/luca-ui/core/collection.js +0 -221
- data/vendor/assets/luca-ui/core/container.js +0 -205
- data/vendor/assets/luca-ui/core/field.js +0 -59
- data/vendor/assets/luca-ui/core/observer.js +0 -42
- data/vendor/assets/luca-ui/core/view.js +0 -127
- data/vendor/assets/luca-ui/framework.js +0 -110
- data/vendor/assets/luca-ui/index.js +0 -5
- data/vendor/assets/luca-ui/managers/collection_manager.js +0 -98
- data/vendor/assets/luca-ui/managers/socket_manager.js +0 -52
- data/vendor/assets/luca-ui/modules/deferrable.js +0 -21
- data/vendor/assets/luca-ui/modules/local_storage.js +0 -81
- data/vendor/assets/luca-ui/normalize.css +0 -359
- data/vendor/assets/luca-ui/stylesheets/base.css +0 -85
- data/vendor/assets/luca-ui/stylesheets/components/form_view.css +0 -32
- data/vendor/assets/luca-ui/stylesheets/components/grid_view.css +0 -76
- data/vendor/assets/luca-ui/stylesheets/components/toolbar.css +0 -11
- data/vendor/assets/luca-ui/stylesheets/containers/container.css +0 -3
- data/vendor/assets/luca-ui/stylesheets/containers/modal_view.css +0 -0
- data/vendor/assets/luca-ui/stylesheets/containers/tab_view.css +0 -16
- data/vendor/assets/luca-ui/stylesheets/normalize.css +0 -359
- data/vendor/assets/luca-ui/templates/components/bootstrap_form_controls.js +0 -4
- data/vendor/assets/luca-ui/templates/components/form_view.js +0 -4
- data/vendor/assets/luca-ui/templates/components/grid_view.js +0 -4
- data/vendor/assets/luca-ui/templates/components/grid_view_empty_text.js +0 -4
- data/vendor/assets/luca-ui/templates/containers/basic.js +0 -4
- data/vendor/assets/luca-ui/templates/containers/tab_selector_container.js +0 -4
- data/vendor/assets/luca-ui/templates/containers/tab_view.js +0 -4
- data/vendor/assets/luca-ui/templates/containers/toolbar_wrapper.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/button_field.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/button_field_link.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/checkbox_field.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/file_upload_field.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/hidden_field.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/select_field.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/text_area_field.js +0 -4
- data/vendor/assets/luca-ui/templates/fields/text_field.js +0 -4
- data/vendor/assets/luca-ui/templates/sample/contents.js +0 -4
- data/vendor/assets/luca-ui/templates/sample/welcome.js +0 -4
|
@@ -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
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
## The Structure Of A Project
|
|
2
|
+
|
|
3
|
+
Luca Applications can be generated with a rails generator `rails generate luca:application app`
|
|
4
|
+
|
|
5
|
+
This will create an application file structure for you, as well as some basic classes:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
- app/assets/javascripts/app
|
|
9
|
+
- views/
|
|
10
|
+
- models/
|
|
11
|
+
- components/
|
|
12
|
+
- collections/
|
|
13
|
+
- templates/
|
|
14
|
+
- lib/
|
|
15
|
+
- config.coffee
|
|
16
|
+
- index.coffee
|
|
17
|
+
- application.coffee
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### config.coffee
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
Luca.initialize "App",
|
|
24
|
+
modelBootstrap: "window.AppBootstrap"
|
|
25
|
+
customConfigValue: "overrides Luca.config.customConfigValue"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This will create the necessary namespaces to hold your components:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
window.App =
|
|
32
|
+
views: {}
|
|
33
|
+
collections: {}
|
|
34
|
+
models: {}
|
|
35
|
+
components: {}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
It will also create a helper function for you called `App()`
|
|
39
|
+
|
|
40
|
+
`App()` without any arguments can be used to access the singleton instance of the global `App.Application` class.
|
|
41
|
+
|
|
42
|
+
`App("my_view_name")` can be used to access an individual view instance by its `@name` or `@cid` property.
|
|
43
|
+
|
|
44
|
+
`App(".custom-dom-selector")` can be used to access an instance of a view by a member of its DOM structure.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### index.coffee
|
|
48
|
+
|
|
49
|
+
This will make the application available to the Rails asset Pipeline. You simply need to:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
javascript_include_tag 'app'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This will load all of the assets defined in your folder, in the proper order they need to be included.
|
|
56
|
+
|
|
57
|
+
It will also handle booting your application for you:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
App.onReady ()->
|
|
61
|
+
window.MyApp = new App.Application()
|
|
62
|
+
window.MyApp.boot()
|
|
63
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
_.extend(Backbone.Router.prototype, Backbone.Events, {
|
|
2
|
+
route : function(route, name, callback) {
|
|
3
|
+
Backbone.history || (Backbone.history = new Backbone.History);
|
|
4
|
+
if (!_.isRegExp(route)) route = this._routeToRegExp(route);
|
|
5
|
+
Backbone.history.route(route, _.bind(function(fragment) {
|
|
6
|
+
var args = this._extractParameters(route, fragment);
|
|
7
|
+
|
|
8
|
+
if( _.isFunction( this.before ) ){
|
|
9
|
+
this.before.apply(this, args)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
callback.apply(this, args);
|
|
13
|
+
|
|
14
|
+
if( _.isFunction( this.after ) ){
|
|
15
|
+
this.after.apply(this, args)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
this.trigger.apply(this, ['route:' + name].concat(args));
|
|
19
|
+
}, this));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Backbone.js 0.9.2
|
|
2
|
+
|
|
3
|
+
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
|
4
|
+
// Backbone may be freely distributed under the MIT license.
|
|
5
|
+
// For all details and documentation:
|
|
6
|
+
// http://backbonejs.org
|
|
7
|
+
(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
|
|
8
|
+
{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
|
|
9
|
+
z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
|
|
10
|
+
{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
|
|
11
|
+
b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
|
|
12
|
+
b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
|
|
13
|
+
a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
|
|
14
|
+
h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
|
|
15
|
+
return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
|
|
16
|
+
{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
|
|
17
|
+
!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
|
|
18
|
+
this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
|
|
19
|
+
l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
|
|
20
|
+
a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
|
|
21
|
+
shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
|
|
22
|
+
this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
|
|
23
|
+
e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
|
|
24
|
+
{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
|
|
25
|
+
arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
|
|
26
|
+
C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
|
|
27
|
+
this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
|
|
28
|
+
""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
|
|
29
|
+
!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
|
|
30
|
+
this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
|
|
31
|
+
stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
|
|
32
|
+
function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
|
|
33
|
+
this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
|
|
34
|
+
f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
|
|
35
|
+
for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
|
|
36
|
+
!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
|
|
37
|
+
e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
|
|
38
|
+
b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
((function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};h=function(a){var b,c,d,e,f,g,i;i=[];for(b in a){e=a[b],c={key:b};if(_.isRegExp(e))c.type="$regex",c.value=e;else if(_(e).isObject()&&!_(e).isArray())for(f in e){g=e[f];if(n(f,g)){c.type=f;switch(f){case"$elemMatch":case"$relationMatch":c.value=h(g);break;case"$computed":d={},d[b]=g,c.value=h(d);break;default:c.value=g}}}else c.type="$equal",c.value=e;c.type==="$equal"&&_(c.value).isObject()&&(c.type="$oEqual"),i.push(c)}return i},n=function(a,b){switch(a){case"$in":case"$nin":case"$all":case"$any":return _(b).isArray();case"$size":return _(b).isNumber();case"$regex":return _(b).isRegExp();case"$like":case"$likeI":return _(b).isString();case"$between":return _(b).isArray()&&b.length===2;case"$cb":return _(b).isFunction();default:return!0}},m=function(a,b){switch(a){case"$like":case"$likeI":case"$regex":return _(b).isString();case"$contains":case"$all":case"$any":case"$elemMatch":return _(b).isArray();case"$size":return _(b).isArray()||_(b).isString();case"$in":case"$nin":return b!=null;case"$relationMatch":return b!=null&&b.models;default:return!0}},i=function(b,c,d,e,g){switch(b){case"$equal":return _(d).isArray()?o.call(d,c)>=0:d===c;case"$oEqual":return _(d).isEqual(c);case"$contains":return o.call(d,c)>=0;case"$ne":return d!==c;case"$lt":return d<c;case"$gt":return d>c;case"$lte":return d<=c;case"$gte":return d>=c;case"$between":return c[0]<d&&d<c[1];case"$in":return o.call(c,d)>=0;case"$nin":return o.call(c,d)<0;case"$all":return _(c).all(function(a){return o.call(d,a)>=0});case"$any":return _(d).any(function(a){return o.call(c,a)>=0});case"$size":return d.length===c;case"$exists":case"$has":return d!=null===c;case"$like":return d.indexOf(c)!==-1;case"$likeI":return d.toLowerCase().indexOf(c.toLowerCase())!==-1;case"$regex":return c.test(d);case"$cb":return c.call(e,d);case"$elemMatch":return f(d,c,!1,a,"elemMatch");case"$relationMatch":return f(d.models,c,!1,a,"relationMatch");case"$computed":return f([e],c,!1,a,"computed");default:return!1}},f=function(a,b,c,d,e){var f;return e==null&&(e=!1),f=e?b:h(b),d(a,function(a){var b,d,g,h,j;for(h=0,j=f.length;h<j;h++){d=f[h],b=function(){switch(e){case"elemMatch":return a[d.key];case"computed":return a[d.key]();default:return a.get(d.key)}}(),g=m(d.type,b),g&&(g=i(d.type,d.value,b,a,d.key));if(c===g)return c}return!c})},b=function(a,b){var c,d,e,f;f=[];for(d=0,e=a.length;d<e;d++)c=a[d],b(c)&&f.push(c);return f},k=function(a,b){var c,d,e,f;f=[];for(d=0,e=a.length;d<e;d++)c=a[d],b(c)||f.push(c);return f},a=function(a,b){var c,d,e;for(d=0,e=a.length;d<e;d++){c=a[d];if(b(c))return!0}return!1},j={$and:function(a,c){return f(a,c,!1,b)},$or:function(a,c){return f(a,c,!0,b)},$nor:function(a,b){return f(a,b,!0,k)},$not:function(a,b){return f(a,b,!1,k)}},c=function(a,b,c){var d,f,g,h;return g=JSON.stringify(b),d=(h=a._query_cache)!=null?h:a._query_cache={},f=d[g],f||(f=e(a,b,c),d[g]=f),f},d=function(a,b){var c,d,e;return c=_.intersection(["$and","$not","$or","$nor"],_(b).keys()),d=a.models,c.length===0?j.$and(d,b):(e=function(a,c){return j[c](a,b[c])},_.reduce(c,e,d))},e=function(a,b,c){var e;return e=d(a,b),c.sortBy&&(e=l(e,c)),e},l=function(a,b){return _(b.sortBy).isString()?a=_(a).sortBy(function(a){return a.get(b.sortBy)}):_(b.sortBy).isFunction()&&(a=_(a).sortBy(b.sortBy)),b.order==="desc"&&(a=a.reverse()),a},g=function(a,b){var c,d,e,f;return b.offset?e=b.offset:b.page?e=(b.page-1)*b.limit:e=0,c=e+b.limit,d=a.slice(e,c),b.pager&&_.isFunction(b.pager)&&(f=Math.ceil(a.length/b.limit),b.pager(f,d)),d};if(typeof require!="undefined"){if(typeof _=="undefined"||_===null)_=require("underscore");if(typeof Backbone=="undefined"||Backbone===null)Backbone=require("backbone")}Backbone.QueryCollection=Backbone.Collection.extend({query:function(a,b){var d;return b==null&&(b={}),b.cache?d=c(this,a,b):d=e(this,a,b),b.limit&&(d=g(d,b)),d},where:function(a,b){return b==null&&(b={}),new this.constructor(this.query(a,b))},reset_query_cache:function(){return this._query_cache={}}}),typeof exports!="undefined"&&(exports.QueryCollection=Backbone.QueryCollection)})).call(this)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bootstrap.js by @fat & @mdo
|
|
3
|
+
* plugins: bootstrap-transition.js, bootstrap-modal.js, bootstrap-dropdown.js, bootstrap-scrollspy.js, bootstrap-tab.js, bootstrap-tooltip.js, bootstrap-popover.js, bootstrap-affix.js, bootstrap-alert.js, bootstrap-button.js, bootstrap-collapse.js, bootstrap-carousel.js, bootstrap-typeahead.js
|
|
4
|
+
* Copyright 2012 Twitter, Inc.
|
|
5
|
+
* http://www.apache.org/licenses/LICENSE-2.0.txt
|
|
6
|
+
*/
|
|
7
|
+
!function(a){a(function(){a.support.transition=function(){var a=function(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},c;for(c in b)if(a.style[c]!==undefined)return b[c]}();return a&&{end:a}}()})}(window.jQuery),!function(a){var b=function(b,c){this.options=c,this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this)),this.options.remote&&this.$element.find(".modal-body").load(this.options.remote)};b.prototype={constructor:b,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this,c=a.Event("show");this.$element.trigger(c);if(this.isShown||c.isDefaultPrevented())return;a("body").addClass("modal-open"),this.isShown=!0,this.escape(),this.backdrop(function(){var c=a.support.transition&&b.$element.hasClass("fade");b.$element.parent().length||b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in").attr("aria-hidden",!1).focus(),b.enforceFocus(),c?b.$element.one(a.support.transition.end,function(){b.$element.trigger("shown")}):b.$element.trigger("shown")})},hide:function(b){b&&b.preventDefault();var c=this;b=a.Event("hide"),this.$element.trigger(b);if(!this.isShown||b.isDefaultPrevented())return;this.isShown=!1,a("body").removeClass("modal-open"),this.escape(),a(document).off("focusin.modal"),this.$element.removeClass("in").attr("aria-hidden",!0),a.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideModal()},enforceFocus:function(){var b=this;a(document).on("focusin.modal",function(a){b.$element[0]!==a.target&&!b.$element.has(a.target).length&&b.$element.focus()})},escape:function(){var a=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.modal",function(b){b.which==27&&a.hide()}):this.isShown||this.$element.off("keyup.dismiss.modal")},hideWithTransition:function(){var b=this,c=setTimeout(function(){b.$element.off(a.support.transition.end),b.hideModal()},500);this.$element.one(a.support.transition.end,function(){clearTimeout(c),b.hideModal()})},hideModal:function(a){this.$element.hide().trigger("hidden"),this.backdrop()},removeBackdrop:function(){this.$backdrop.remove(),this.$backdrop=null},backdrop:function(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.options.backdrop!="static"&&this.$backdrop.click(a.proxy(this.hide,this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),e?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,a.proxy(this.removeBackdrop,this)):this.removeBackdrop()):b&&b()}},a.fn.modal=function(c){return this.each(function(){var d=a(this),e=d.data("modal"),f=a.extend({},a.fn.modal.defaults,d.data(),typeof c=="object"&&c);e||d.data("modal",e=new b(this,f)),typeof c=="string"?e[c]():f.show&&e.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},a.fn.modal.Constructor=b,a(function(){a("body").on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d=c.attr("href"),e=a(c.attr("data-target")||d&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({remote:!/#/.test(d)&&d},e.data(),c.data());b.preventDefault(),e.modal(f).one("hide",function(){c.focus()})})})}(window.jQuery),!function(a){function d(){a(b).each(function(){e(a(this)).removeClass("open")})}function e(b){var c=b.attr("data-target"),d;return c||(c=b.attr("href"),c=c&&/#/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,"")),d=a(c),d.length||(d=b.parent()),d}var b="[data-toggle=dropdown]",c=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};c.prototype={constructor:c,toggle:function(b){var c=a(this),f,g;if(c.is(".disabled, :disabled"))return;return f=e(c),g=f.hasClass("open"),d(),g||(f.toggleClass("open"),c.focus()),!1},keydown:function(b){var c,d,f,g,h,i;if(!/(38|40|27)/.test(b.keyCode))return;c=a(this),b.preventDefault(),b.stopPropagation();if(c.is(".disabled, :disabled"))return;g=e(c),h=g.hasClass("open");if(!h||h&&b.keyCode==27)return c.click();d=a("[role=menu] li:not(.divider) a",g);if(!d.length)return;i=d.index(d.filter(":focus")),b.keyCode==38&&i>0&&i--,b.keyCode==40&&i<d.length-1&&i++,~i||(i=0),d.eq(i).focus()}},a.fn.dropdown=function(b){return this.each(function(){var d=a(this),e=d.data("dropdown");e||d.data("dropdown",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.dropdown.Constructor=c,a(function(){a("html").on("click.dropdown.data-api touchstart.dropdown.data-api",d),a("body").on("click.dropdown touchstart.dropdown.data-api",".dropdown form",function(a){a.stopPropagation()}).on("click.dropdown.data-api touchstart.dropdown.data-api",b,c.prototype.toggle).on("keydown.dropdown.data-api touchstart.dropdown.data-api",b+", [role=menu]",c.prototype.keydown)})}(window.jQuery),!function(a){function b(b,c){var d=a.proxy(this.process,this),e=a(b).is("body")?a(window):a(b),f;this.options=a.extend({},a.fn.scrollspy.defaults,c),this.$scrollElement=e.on("scroll.scroll-spy.data-api",d),this.selector=(this.options.target||(f=a(b).attr("href"))&&f.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=a("body"),this.refresh(),this.process()}b.prototype={constructor:b,refresh:function(){var b=this,c;this.offsets=a([]),this.targets=a([]),c=this.$body.find(this.selector).map(function(){var b=a(this),c=b.data("target")||b.attr("href"),d=/^#\w/.test(c)&&a(c);return d&&d.length&&[[d.position().top,c]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},process:function(){var a=this.$scrollElement.scrollTop()+this.options.offset,b=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,c=b-this.$scrollElement.height(),d=this.offsets,e=this.targets,f=this.activeTarget,g;if(a>=c)return f!=(g=e.last()[0])&&this.activate(g);for(g=d.length;g--;)f!=e[g]&&a>=d[g]&&(!d[g+1]||a<=d[g+1])&&this.activate(e[g])},activate:function(b){var c,d;this.activeTarget=b,a(this.selector).parent(".active").removeClass("active"),d=this.selector+'[data-target="'+b+'"],'+this.selector+'[href="'+b+'"]',c=a(d).parent("li").addClass("active"),c.parent(".dropdown-menu").length&&(c=c.closest("li.dropdown").addClass("active")),c.trigger("activate")}},a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("scrollspy"),f=typeof c=="object"&&c;e||d.data("scrollspy",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.defaults={offset:10},a(window).on("load",function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(window.jQuery),!function(a){var b=function(b){this.element=a(b)};b.prototype={constructor:b,show:function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.attr("data-target"),e,f,g;d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,""));if(b.parent("li").hasClass("active"))return;e=c.find(".active a").last()[0],g=a.Event("show",{relatedTarget:e}),b.trigger(g);if(g.isDefaultPrevented())return;f=a(d),this.activate(b.parent("li"),c),this.activate(f,f.parent(),function(){b.trigger({type:"shown",relatedTarget:e})})},activate:function(b,c,d){function g(){e.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),f?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var e=c.find("> .active"),f=d&&a.support.transition&&e.hasClass("fade");f?e.one(a.support.transition.end,g):g(),e.removeClass("in")}},a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("tab");e||d.data("tab",e=new b(this)),typeof c=="string"&&e[c]()})},a.fn.tab.Constructor=b,a(function(){a("body").on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})})}(window.jQuery),!function(a){var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,this.options.trigger=="click"?this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this)):this.options.trigger!="manual"&&(e=this.options.trigger=="hover"?"mouseenter":"focus",f=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(e+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f+"."+this.type,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);if(!c.options.delay||!c.options.delay.show)return c.show();clearTimeout(this.timeout),c.hoverState="in",this.timeout=setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show)},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);this.timeout&&clearTimeout(this.timeout);if(!c.options.delay||!c.options.delay.hide)return c.hide();c.hoverState="out",this.timeout=setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide)},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight;switch(b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},setContent:function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.options.html?"html":"text"](b),a.removeClass("fade in top bottom left right")},hide:function(){function d(){var b=setTimeout(function(){c.off(a.support.transition.end).remove()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.remove()})}var b=this,c=this.tip();return c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?d():c.remove(),this},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(b){return a.extend({},b?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass("in")?"hide":"show"]()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}},a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover",title:"",delay:0,html:!0}}(window.jQuery),!function(a){var b=function(a,b){this.init("popover",a,b)};b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype,{constructor:b,setContent:function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content > *")[this.options.html?"html":"text"](c),a.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-content")||(typeof c.content=="function"?c.content.call(b[0]):c.content),a},tip:function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}}),a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("popover"),f=typeof c=="object"&&c;e||d.data("popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.defaults=a.extend({},a.fn.tooltip.defaults,{placement:"right",trigger:"click",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'})}(window.jQuery),!function(a){var b=function(b,c){this.options=a.extend({},a.fn.affix.defaults,c),this.$window=a(window).on("scroll.affix.data-api",a.proxy(this.checkPosition,this)),this.$element=a(b),this.checkPosition()};b.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var b=a(document).height(),c=this.$window.scrollTop(),d=this.$element.offset(),e=this.options.offset,f=e.bottom,g=e.top,h="affix affix-top affix-bottom",i;typeof e!="object"&&(f=g=e),typeof g=="function"&&(g=e.top()),typeof f=="function"&&(f=e.bottom()),i=this.unpin!=null&&c+this.unpin<=d.top?!1:f!=null&&d.top+this.$element.height()>=b-f?"bottom":g!=null&&c<=g?"top":!1;if(this.affixed===i)return;this.affixed=i,this.unpin=i=="bottom"?d.top-c:null,this.$element.removeClass(h).addClass("affix"+(i?"-"+i:""))},a.fn.affix=function(c){return this.each(function(){var d=a(this),e=d.data("affix"),f=typeof c=="object"&&c;e||d.data("affix",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.affix.Constructor=b,a.fn.affix.defaults={offset:0},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var b=a(this),c=b.data();c.offset=c.offset||{},c.offsetBottom&&(c.offset.bottom=c.offsetBottom),c.offsetTop&&(c.offset.top=c.offsetTop),b.affix(c)})})}(window.jQuery),!function(a){var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function f(){e.trigger("closed").remove()}var c=a(this),d=c.attr("data-target"),e;d||(d=c.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),e=a(d),b&&b.preventDefault(),e.length||(e=c.hasClass("alert")?c:c.parent()),e.trigger(b=a.Event("close"));if(b.isDefaultPrevented())return;e.removeClass("in"),a.support.transition&&e.hasClass("fade")?e.on(a.support.transition.end,f):f()},a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("alert");e||d.data("alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a(function(){a("body").on("click.alert.data-api",b,c.prototype.close)})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.button.defaults,c)};b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.data(),e=c.is("input")?"val":"html";a+="Text",d.resetText||c.data("resetText",c[e]()),c[e](d[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.closest('[data-toggle="buttons-radio"]');a&&a.find(".active").removeClass("active"),this.$element.toggleClass("active")},a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("button"),f=typeof c=="object"&&c;e||d.data("button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=b,a(function(){a("body").on("click.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle")})})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.collapse.defaults,c),this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.prototype={constructor:b,dimension:function(){var a=this.$element.hasClass("width");return a?"width":"height"},show:function(){var b,c,d,e;if(this.transitioning)return;b=this.dimension(),c=a.camelCase(["scroll",b].join("-")),d=this.$parent&&this.$parent.find("> .accordion-group > .in");if(d&&d.length){e=d.data("collapse");if(e&&e.transitioning)return;d.collapse("hide"),e||d.data("collapse",null)}this.$element[b](0),this.transition("addClass",a.Event("show"),"shown"),a.support.transition&&this.$element[b](this.$element[0][c])},hide:function(){var b;if(this.transitioning)return;b=this.dimension(),this.reset(this.$element[b]()),this.transition("removeClass",a.Event("hide"),"hidden"),this.$element[b](0)},reset:function(a){var b=this.dimension();return this.$element.removeClass("collapse")[b](a||"auto")[0].offsetWidth,this.$element[a!==null?"addClass":"removeClass"]("collapse"),this},transition:function(b,c,d){var e=this,f=function(){c.type=="show"&&e.reset(),e.transitioning=0,e.$element.trigger(d)};this.$element.trigger(c);if(c.isDefaultPrevented())return;this.transitioning=1,this.$element[b]("in"),a.support.transition&&this.$element.hasClass("collapse")?this.$element.one(a.support.transition.end,f):f()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("collapse"),f=typeof c=="object"&&c;e||d.data("collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.defaults={toggle:!0},a.fn.collapse.Constructor=b,a(function(){a("body").on("click.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e).data("collapse")?"toggle":c.data();c[a(e).hasClass("in")?"addClass":"removeClass"]("collapsed"),a(e).collapse(f)})})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=c,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.prototype={cycle:function(b){return b||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},to:function(b){var c=this.$element.find(".item.active"),d=c.parent().children(),e=d.index(c),f=this;if(b>d.length-1||b<0)return;return this.sliding?this.$element.one("slid",function(){f.to(b)}):e==b?this.pause().cycle():this.slide(b>e?"next":"prev",a(d[b]))},pause:function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition.end&&(this.$element.trigger(a.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(b,c){var d=this.$element.find(".item.active"),e=c||d[b](),f=this.interval,g=b=="next"?"left":"right",h=b=="next"?"first":"last",i=this,j=a.Event("slide",{relatedTarget:e[0]});this.sliding=!0,f&&this.pause(),e=e.length?e:this.$element.find(".item")[h]();if(e.hasClass("active"))return;if(a.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(j);if(j.isDefaultPrevented())return;e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),this.$element.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid")},0)})}else{this.$element.trigger(j);if(j.isDefaultPrevented())return;d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return f&&this.cycle(),this}},a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("carousel"),f=a.extend({},a.fn.carousel.defaults,typeof c=="object"&&c),g=typeof c=="string"?c:f.slide;e||d.data("carousel",e=new b(this,f)),typeof c=="number"?e.to(c):g?e[g]():f.interval&&e.cycle()})},a.fn.carousel.defaults={interval:5e3,pause:"hover"},a.fn.carousel.Constructor=b,a(function(){a("body").on("click.carousel.data-api","[data-slide]",function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=!e.data("modal")&&a.extend({},e.data(),c.data());e.carousel(f),b.preventDefault()})})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.typeahead.defaults,c),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.$menu=a(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(a)).change(),this.hide()},updater:function(a){return a},show:function(){var b=a.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:b.top+b.height,left:b.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){var c;return this.query=this.$element.val(),!this.query||this.query.length<this.options.minLength?this.shown?this.hide():this:(c=a.isFunction(this.source)?this.source(this.query,a.proxy(this.process,this)):this.source,c?this.process(c):this)},process:function(b){var c=this;return b=a.grep(b,function(a){return c.matcher(a)}),b=this.sorter(b),b.length?this.render(b.slice(0,this.options.items)).show():this.shown?this.hide():this},matcher:function(a){return~a.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){var b=[],c=[],d=[],e;while(e=a.shift())e.toLowerCase().indexOf(this.query.toLowerCase())?~e.indexOf(this.query)?c.push(e):d.push(e):b.push(e);return b.concat(c,d)},highlighter:function(a){var b=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return a.replace(new RegExp("("+b+")","ig"),function(a,b){return"<strong>"+b+"</strong>"})},render:function(b){var c=this;return b=a(b).map(function(b,d){return b=a(c.options.item).attr("data-value",d),b.find("a").html(c.highlighter(d)),b[0]}),b.first().addClass("active"),this.$menu.html(b),this},next:function(b){var c=this.$menu.find(".active").removeClass("active"),d=c.next();d.length||(d=a(this.$menu.find("li")[0])),d.addClass("active")},prev:function(a){var b=this.$menu.find(".active").removeClass("active"),c=b.prev();c.length||(c=this.$menu.find("li").last()),c.addClass("active")},listen:function(){this.$element.on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),(a.browser.chrome||a.browser.webkit||a.browser.msie)&&this.$element.on("keydown",a.proxy(this.keydown,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this))},move:function(a){if(!this.shown)return;switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:a.preventDefault(),this.prev();break;case 40:a.preventDefault(),this.next()}a.stopPropagation()},keydown:function(b){this.suppressKeyPressRepeat=!~a.inArray(b.keyCode,[40,38,9,13,27]),this.move(b)},keypress:function(a){if(this.suppressKeyPressRepeat)return;this.move(a)},keyup:function(a){switch(a.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}a.stopPropagation(),a.preventDefault()},blur:function(a){var b=this;setTimeout(function(){b.hide()},150)},click:function(a){a.stopPropagation(),a.preventDefault(),this.select()},mouseenter:function(b){this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")}},a.fn.typeahead=function(c){return this.each(function(){var d=a(this),e=d.data("typeahead"),f=typeof c=="object"&&c;e||d.data("typeahead",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>',minLength:1},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery)
|
data/{assets/javascripts/dependencies → vendor/assets/javascripts}/codemirror-coffeescript.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
/* Demonstration of embedding CodeMirror in a bigger application. The
|
|
2
|
+
* interface defined here is a mess of prompts and confirms, and
|
|
3
|
+
* should probably not be used in a real project.
|
|
4
|
+
*/
|
|
5
|
+
//var CodeMirrorUI = Class.create();
|
|
6
|
+
|
|
7
|
+
function CodeMirrorUI(place, options, mirrorOptions) {
|
|
8
|
+
this.initialize(place, options, mirrorOptions);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
CodeMirrorUI.prototype = {
|
|
12
|
+
|
|
13
|
+
initialize: function(textarea, options, mirrorOptions) {
|
|
14
|
+
var defaultOptions = {
|
|
15
|
+
searchMode: 'popup', // other options are 'inline' and 'dialog'. The 'dialog' option needs work.
|
|
16
|
+
imagePath: 'images/silk',
|
|
17
|
+
path: 'js',
|
|
18
|
+
buttons: ['search', 'undo', 'redo', 'jump', 'reindentSelection', 'reindent','about'],
|
|
19
|
+
saveCallback: function() {},
|
|
20
|
+
}
|
|
21
|
+
this.textarea = textarea
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.setDefaults(this.options, defaultOptions);
|
|
24
|
+
|
|
25
|
+
this.buttonDefs = {
|
|
26
|
+
'save': ["Save", "save", this.options.imagePath + "/page_save.png", this.save],
|
|
27
|
+
'search': ["Search/Replace", "find_replace_popup", this.options.imagePath + "/find.png", this.find_replace_popup],
|
|
28
|
+
'searchClose': ["Close", "find_replace_popup_close", this.options.imagePath + "/cancel.png", this.find_replace_popup_close],
|
|
29
|
+
'searchDialog': ["Search/Replace", "find_replace_window", this.options.imagePath + "/find.png", this.find_replace_window],
|
|
30
|
+
'undo': ["Undo", "undo", this.options.imagePath + "/arrow_undo.png", this.undo],
|
|
31
|
+
'redo': ["Redo", "redo", this.options.imagePath + "/arrow_redo.png", this.redo],
|
|
32
|
+
'jump': ["Jump to line #", "jump", this.options.imagePath + "/page_go.png", this.jump],
|
|
33
|
+
'reindentSelection': ["Reformat selection", "reindentSelect", this.options.imagePath + "/text_indent.png", this.reindentSelection],
|
|
34
|
+
'reindent': ["Reformat whole document", "reindent", this.options.imagePath + "/page_refresh.png", this.reindent],
|
|
35
|
+
'about': ["About CodeMirror-UI", "about", this.options.imagePath + "/help.png", this.about]
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//place = CodeMirror.replace(place)
|
|
39
|
+
|
|
40
|
+
this.home = document.createElement("div");
|
|
41
|
+
this.textarea.parentNode.insertBefore(this.home, this.textarea);
|
|
42
|
+
/*if (place.appendChild)
|
|
43
|
+
place.appendChild(this.home);
|
|
44
|
+
else
|
|
45
|
+
place(this.home);
|
|
46
|
+
*/
|
|
47
|
+
this.self = this;
|
|
48
|
+
|
|
49
|
+
var onChange = this.editorChanged.cmuiBind(this);
|
|
50
|
+
// preserve custom onChance handler
|
|
51
|
+
if (mirrorOptions.onChange) {
|
|
52
|
+
mirrorOptions.onChange = function() {
|
|
53
|
+
mirrorOptions.onChange();
|
|
54
|
+
onChange();
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
mirrorOptions.onChange = onChange;
|
|
58
|
+
}
|
|
59
|
+
mir = CodeMirror.fromTextArea(this.textarea, mirrorOptions);
|
|
60
|
+
//console.log(mir);
|
|
61
|
+
this.mirror = mir;
|
|
62
|
+
|
|
63
|
+
this.initButtons();
|
|
64
|
+
|
|
65
|
+
//this.initWordWrapControl(); // CodeMirror v2 does not support word wrapping
|
|
66
|
+
|
|
67
|
+
if (this.options.searchMode == 'inline') {
|
|
68
|
+
this.initFindControl();
|
|
69
|
+
} else if (this.options.searchMode == 'popup') {
|
|
70
|
+
this.initPopupFindControl();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (this.saveButton) this.addClass(this.saveButton,'inactive');
|
|
74
|
+
if (this.undoButton) this.addClass(this.undoButton,'inactive');
|
|
75
|
+
if (this.redoButton) this.addClass(this.redoButton,'inactive');
|
|
76
|
+
},
|
|
77
|
+
setDefaults: function(object, defaults) {
|
|
78
|
+
for (var option in defaults) {
|
|
79
|
+
if (!object.hasOwnProperty(option))
|
|
80
|
+
object[option] = defaults[option];
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
toTextArea: function() {
|
|
84
|
+
this.home.parentNode.removeChild(this.home);
|
|
85
|
+
this.mirror.toTextArea();
|
|
86
|
+
},
|
|
87
|
+
initButtons: function() {
|
|
88
|
+
this.buttonFrame = document.createElement("div");
|
|
89
|
+
this.buttonFrame.className = "codemirror-ui-clearfix codemirror-ui-button-frame";
|
|
90
|
+
this.home.appendChild(this.buttonFrame);
|
|
91
|
+
for (var i = 0; i < this.options.buttons.length; i++) {
|
|
92
|
+
var buttonId = this.options.buttons[i];
|
|
93
|
+
var buttonDef = this.buttonDefs[buttonId];
|
|
94
|
+
this.addButton(buttonDef[0], buttonDef[1], buttonDef[2], buttonDef[3], this.buttonFrame);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//this.makeButton("Search", "search");
|
|
98
|
+
//this.makeButton("Replace", "replace");
|
|
99
|
+
//this.makeButton("Current line", "line");
|
|
100
|
+
//this.makeButton("Jump to line", "jump");
|
|
101
|
+
//this.makeButton("Insert constructor", "macro");
|
|
102
|
+
//this.makeButton("Indent all", "reindent");
|
|
103
|
+
},
|
|
104
|
+
/*
|
|
105
|
+
* This is left over from the MirrorFrame demo.
|
|
106
|
+
* Get rid of it quick.
|
|
107
|
+
*/
|
|
108
|
+
/*
|
|
109
|
+
makeButton : function(name, action){
|
|
110
|
+
var button = document.createElement("input");
|
|
111
|
+
button.type = "button";
|
|
112
|
+
button.value = name;
|
|
113
|
+
this.home.appendChild(button);
|
|
114
|
+
button.onclick = function(){
|
|
115
|
+
self[action].call(self);
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
*/
|
|
119
|
+
createFindBar: function() {
|
|
120
|
+
var findBar = document.createElement("div");
|
|
121
|
+
findBar.className = "codemirror-ui-find-bar";
|
|
122
|
+
|
|
123
|
+
this.findString = document.createElement("input");
|
|
124
|
+
this.findString.type = "text";
|
|
125
|
+
this.findString.size = 8;
|
|
126
|
+
|
|
127
|
+
this.findButton = document.createElement("input");
|
|
128
|
+
this.findButton.type = "button";
|
|
129
|
+
this.findButton.value = "Find";
|
|
130
|
+
this.findButton.onclick = function(){this.find()}.cmuiBind(this);
|
|
131
|
+
|
|
132
|
+
this.connect(this.findString, "keyup", function(e){
|
|
133
|
+
var code = e.keyCode;
|
|
134
|
+
if (code == 13){
|
|
135
|
+
this.find(this.mirror.getCursor(false))
|
|
136
|
+
}else{
|
|
137
|
+
if(!this.findString.value == ""){
|
|
138
|
+
this.find(this.mirror.getCursor(true))
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
this.findString.focus();
|
|
142
|
+
|
|
143
|
+
}.cmuiBind(this) );
|
|
144
|
+
|
|
145
|
+
var regLabel = document.createElement("label");
|
|
146
|
+
regLabel.title = "Regular Expressions"
|
|
147
|
+
this.regex = document.createElement("input");
|
|
148
|
+
this.regex.type = "checkbox"
|
|
149
|
+
this.regex.className = "codemirror-ui-checkbox"
|
|
150
|
+
regLabel.appendChild(this.regex);
|
|
151
|
+
regLabel.appendChild(document.createTextNode("RegEx"));
|
|
152
|
+
|
|
153
|
+
var caseLabel = document.createElement("label");
|
|
154
|
+
caseLabel.title = "Case Sensitive"
|
|
155
|
+
this.caseSensitive = document.createElement("input");
|
|
156
|
+
this.caseSensitive.type = "checkbox"
|
|
157
|
+
this.caseSensitive.className = "codemirror-ui-checkbox"
|
|
158
|
+
caseLabel.appendChild(this.caseSensitive);
|
|
159
|
+
caseLabel.appendChild(document.createTextNode("A/a"));
|
|
160
|
+
|
|
161
|
+
this.replaceString = document.createElement("input");
|
|
162
|
+
this.replaceString.type = "text";
|
|
163
|
+
this.replaceString.size = 8;
|
|
164
|
+
|
|
165
|
+
this.connect(this.replaceString, "keyup", function(e){
|
|
166
|
+
var code = e.keyCode;
|
|
167
|
+
if (code == 13){
|
|
168
|
+
this.replace()
|
|
169
|
+
}
|
|
170
|
+
}.cmuiBind(this) );
|
|
171
|
+
|
|
172
|
+
this.replaceButton = document.createElement("input");
|
|
173
|
+
this.replaceButton.type = "button";
|
|
174
|
+
this.replaceButton.value = "Replace";
|
|
175
|
+
this.replaceButton.onclick = this.replace.cmuiBind(this);
|
|
176
|
+
|
|
177
|
+
var replaceAllLabel = document.createElement("label");
|
|
178
|
+
replaceAllLabel.title = "Replace All"
|
|
179
|
+
this.replaceAll = document.createElement("input");
|
|
180
|
+
this.replaceAll.type = "checkbox"
|
|
181
|
+
this.replaceAll.className = "codemirror-ui-checkbox"
|
|
182
|
+
replaceAllLabel.appendChild(this.replaceAll);
|
|
183
|
+
replaceAllLabel.appendChild(document.createTextNode("All"));
|
|
184
|
+
|
|
185
|
+
findBar.appendChild(this.findString);
|
|
186
|
+
findBar.appendChild(this.findButton);
|
|
187
|
+
findBar.appendChild(caseLabel);
|
|
188
|
+
findBar.appendChild(regLabel);
|
|
189
|
+
|
|
190
|
+
findBar.appendChild(this.replaceString);
|
|
191
|
+
findBar.appendChild(this.replaceButton);
|
|
192
|
+
findBar.appendChild(replaceAllLabel);
|
|
193
|
+
return findBar;
|
|
194
|
+
},
|
|
195
|
+
initPopupFindControl: function() {
|
|
196
|
+
var findBar = this.createFindBar();
|
|
197
|
+
|
|
198
|
+
this.popupFindWrap = document.createElement("div");
|
|
199
|
+
this.popupFindWrap.className = "codemirror-ui-popup-find-wrap";
|
|
200
|
+
|
|
201
|
+
this.popupFindWrap.appendChild(findBar);
|
|
202
|
+
|
|
203
|
+
var buttonDef = this.buttonDefs['searchClose'];
|
|
204
|
+
this.addButton(buttonDef[0], buttonDef[1], buttonDef[2], buttonDef[3], this.popupFindWrap);
|
|
205
|
+
|
|
206
|
+
this.buttonFrame.appendChild(this.popupFindWrap);
|
|
207
|
+
|
|
208
|
+
},
|
|
209
|
+
initFindControl: function() {
|
|
210
|
+
var findBar = this.createFindBar();
|
|
211
|
+
this.buttonFrame.appendChild(findBar);
|
|
212
|
+
},
|
|
213
|
+
find: function( start ) {
|
|
214
|
+
var isCaseSensitive = this.caseSensitive.checked;
|
|
215
|
+
if(start == null){
|
|
216
|
+
start = this.mirror.getCursor();
|
|
217
|
+
}
|
|
218
|
+
var findString = this.findString.value;
|
|
219
|
+
if (findString == null || findString == '') {
|
|
220
|
+
alert('You must enter something to search for.');
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (this.regex.checked) {
|
|
224
|
+
findString = new RegExp(findString, !isCaseSensitive ? "i" : "");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
this.cursor = this.mirror.getSearchCursor(findString, start, !isCaseSensitive );
|
|
228
|
+
var found = this.cursor.findNext();
|
|
229
|
+
if (found) {
|
|
230
|
+
this.mirror.setSelection(this.cursor.from(),this.cursor.to())
|
|
231
|
+
//this.cursor.select();
|
|
232
|
+
} else {
|
|
233
|
+
if (confirm("No more matches. Should we start from the top?")) {
|
|
234
|
+
this.cursor = this.mirror.getSearchCursor(findString, 0, !isCaseSensitive);
|
|
235
|
+
found = this.cursor.findNext();
|
|
236
|
+
if (found) {
|
|
237
|
+
this.mirror.setSelection(this.cursor.from(),this.cursor.to())
|
|
238
|
+
//this.cursor.select();
|
|
239
|
+
} else {
|
|
240
|
+
alert("No matches found.");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
replace: function() {
|
|
246
|
+
var findString = this.findString.value,
|
|
247
|
+
replaceString = this.replaceString.value,
|
|
248
|
+
isCaseSensitive = this.caseSensitive.checked,
|
|
249
|
+
isRegex = this.regex.checked,
|
|
250
|
+
regFindString = isRegex ? new RegExp(findString, !isCaseSensitive ? "i" : "") : "";
|
|
251
|
+
|
|
252
|
+
if (this.replaceAll.checked) {
|
|
253
|
+
var cursor = this.mirror.getSearchCursor(isRegex ? regFindString : findString, 0, !isCaseSensitive);
|
|
254
|
+
while (cursor.findNext())
|
|
255
|
+
this.mirror.replaceRange(
|
|
256
|
+
isRegex ? cursor.pos.match[0].replace(regFindString, replaceString) : replaceString
|
|
257
|
+
,cursor.from(),cursor.to());
|
|
258
|
+
//cursor.replace(this.replaceString.value);
|
|
259
|
+
} else {
|
|
260
|
+
this.mirror.replaceRange(
|
|
261
|
+
isRegex ? this.cursor.pos.match[0].replace(regFindString, replaceString) : replaceString
|
|
262
|
+
,this.cursor.from(),this.cursor.to())
|
|
263
|
+
//this.cursor.replace(this.replaceString.value);
|
|
264
|
+
this.find();
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
initWordWrapControl: function() {
|
|
268
|
+
var wrapDiv = document.createElement("div");
|
|
269
|
+
wrapDiv.className = "codemirror-ui-wrap"
|
|
270
|
+
|
|
271
|
+
var label = document.createElement("label");
|
|
272
|
+
|
|
273
|
+
this.wordWrap = document.createElement("input");
|
|
274
|
+
this.wordWrap.type = "checkbox"
|
|
275
|
+
this.wordWrap.checked = true;
|
|
276
|
+
label.appendChild(this.wordWrap);
|
|
277
|
+
label.appendChild(document.createTextNode("Word Wrap"));
|
|
278
|
+
this.wordWrap.onchange = this.toggleWordWrap.cmuiBind(this);
|
|
279
|
+
wrapDiv.appendChild(label);
|
|
280
|
+
this.buttonFrame.appendChild(wrapDiv);
|
|
281
|
+
},
|
|
282
|
+
toggleWordWrap: function() {
|
|
283
|
+
if (this.wordWrap.checked) {
|
|
284
|
+
this.mirror.setTextWrapping("nowrap");
|
|
285
|
+
} else {
|
|
286
|
+
this.mirror.setTextWrapping("");
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
addButton: function(name, action, image, func, frame) {
|
|
290
|
+
var button = document.createElement("a");
|
|
291
|
+
//button.href = "#";
|
|
292
|
+
button.className = "codemirror-ui-button " + action;
|
|
293
|
+
button.title = name;
|
|
294
|
+
button.func = func.cmuiBind(this);
|
|
295
|
+
button.onclick = function(event) {
|
|
296
|
+
//alert(event.target);
|
|
297
|
+
event.target.func();
|
|
298
|
+
return false;
|
|
299
|
+
//this.self[action].call(this);
|
|
300
|
+
//eval("this."+action)();
|
|
301
|
+
}
|
|
302
|
+
.cmuiBind(this, func);
|
|
303
|
+
var img = document.createElement("img");
|
|
304
|
+
img.src = image;
|
|
305
|
+
img.border = 0;
|
|
306
|
+
img.func = func.cmuiBind(this);
|
|
307
|
+
button.appendChild(img);
|
|
308
|
+
frame.appendChild(button);
|
|
309
|
+
if (action == 'save') {
|
|
310
|
+
this.saveButton = button;
|
|
311
|
+
}
|
|
312
|
+
if (action == 'undo') {
|
|
313
|
+
this.undoButton = button;
|
|
314
|
+
}
|
|
315
|
+
if (action == 'redo') {
|
|
316
|
+
this.redoButton = button;
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
classNameRegex: function(className) {
|
|
320
|
+
var regex = new RegExp("(.*) *" + className + " *(.*)");
|
|
321
|
+
return regex;
|
|
322
|
+
},
|
|
323
|
+
addClass: function(element, className) {
|
|
324
|
+
if (!element.className.match(this.classNameRegex(className))) {
|
|
325
|
+
element.className += " " + className;
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
removeClass: function(element, className) {
|
|
329
|
+
var m = element.className.match(this.classNameRegex(className))
|
|
330
|
+
if (m) {
|
|
331
|
+
element.className = m[1] + " " + m[2];
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
editorChanged: function() {
|
|
335
|
+
if(!this.mirror) {
|
|
336
|
+
return
|
|
337
|
+
}
|
|
338
|
+
var his = this.mirror.historySize();
|
|
339
|
+
if (his['undo'] > 0) {
|
|
340
|
+
this.removeClass(this.saveButton, 'inactive');
|
|
341
|
+
this.removeClass(this.undoButton, 'inactive');
|
|
342
|
+
} else {
|
|
343
|
+
this.addClass(this.saveButton, 'inactive');
|
|
344
|
+
this.addClass(this.undoButton, 'inactive');
|
|
345
|
+
}
|
|
346
|
+
if (his['redo'] > 0) {
|
|
347
|
+
this.removeClass(this.redoButton, 'inactive');
|
|
348
|
+
} else {
|
|
349
|
+
this.addClass(this.redoButton, 'inactive');
|
|
350
|
+
}
|
|
351
|
+
//alert("undo size = " + his['undo'] + " and redo size = " + his['redo']);
|
|
352
|
+
},
|
|
353
|
+
save: function() {
|
|
354
|
+
this.options.saveCallback();
|
|
355
|
+
this.addClass(this.saveButton, 'inactive');
|
|
356
|
+
},
|
|
357
|
+
undo: function() {
|
|
358
|
+
this.mirror.undo();
|
|
359
|
+
},
|
|
360
|
+
redo: function() {
|
|
361
|
+
this.mirror.redo();
|
|
362
|
+
},
|
|
363
|
+
replaceSelection: function(newVal) {
|
|
364
|
+
this.mirror.replaceSelection(newVal);
|
|
365
|
+
this.searchWindow.focus();
|
|
366
|
+
},
|
|
367
|
+
raise_search_window: function() {
|
|
368
|
+
//alert('raising window!');
|
|
369
|
+
this.searchWindow.focus();
|
|
370
|
+
},
|
|
371
|
+
find_replace_window: function() {
|
|
372
|
+
if (this.searchWindow == null) {
|
|
373
|
+
this.searchWindow = window.open(this.options.path + "find_replace.html", "mywindow", "scrollbars=1,width=400,height=350,modal=yes");
|
|
374
|
+
this.searchWindow.codeMirrorUI = this;
|
|
375
|
+
}
|
|
376
|
+
this.searchWindow.focus();
|
|
377
|
+
},
|
|
378
|
+
find_replace_popup: function() {
|
|
379
|
+
//alert('Hello!');
|
|
380
|
+
this.popupFindWrap.className = "codemirror-ui-popup-find-wrap active";
|
|
381
|
+
this.findString.focus();
|
|
382
|
+
},
|
|
383
|
+
find_replace_popup_close: function() {
|
|
384
|
+
//alert('Hello!');
|
|
385
|
+
this.popupFindWrap.className = "codemirror-ui-popup-find-wrap";
|
|
386
|
+
},
|
|
387
|
+
/*
|
|
388
|
+
find_replace: function(){
|
|
389
|
+
this.find_replace = document.createElement("div");
|
|
390
|
+
this.find_replace.className = "codemirror-search-replace";
|
|
391
|
+
this.find_replace.innerHTML = "Just a test!";
|
|
392
|
+
this.home.appendChild(this.find_replace);
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
search: function(){
|
|
396
|
+
var text = prompt("Enter search term:", "");
|
|
397
|
+
if (!text)
|
|
398
|
+
return;
|
|
399
|
+
|
|
400
|
+
var first = true;
|
|
401
|
+
do {
|
|
402
|
+
var cursor = this.mirror.getSearchCursor(text, first);
|
|
403
|
+
first = false;
|
|
404
|
+
while (cursor.findNext()) {
|
|
405
|
+
cursor.select();
|
|
406
|
+
if (!confirm("Search again?"))
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
while (confirm("End of document reached. Start over?"));
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
replace: function(){
|
|
414
|
+
// This is a replace-all, but it is possible to implement a
|
|
415
|
+
// prompting replace.
|
|
416
|
+
var from = prompt("Enter search string:", ""), to;
|
|
417
|
+
if (from)
|
|
418
|
+
to = prompt("What should it be replaced with?", "");
|
|
419
|
+
if (to == null)
|
|
420
|
+
return;
|
|
421
|
+
|
|
422
|
+
var cursor = this.mirror.getSearchCursor(from, false);
|
|
423
|
+
while (cursor.findNext())
|
|
424
|
+
cursor.replace(to);
|
|
425
|
+
},
|
|
426
|
+
*/
|
|
427
|
+
jump: function() {
|
|
428
|
+
var line = prompt("Jump to line:", "");
|
|
429
|
+
if (line && !isNaN(Number(line))) {
|
|
430
|
+
this.mirror.setCursor(Number(line),0);
|
|
431
|
+
this.mirror.setSelection({line:Number(line),ch:0},{line:Number(line)+1,ch:0});
|
|
432
|
+
this.mirror.focus();
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
/*
|
|
436
|
+
line: function(){
|
|
437
|
+
alert("The cursor is currently at line " + this.mirror.currentLine());
|
|
438
|
+
this.mirror.focus();
|
|
439
|
+
},
|
|
440
|
+
|
|
441
|
+
macro: function(){
|
|
442
|
+
var name = prompt("Name your constructor:", "");
|
|
443
|
+
if (name)
|
|
444
|
+
this.mirror.replaceSelection("function " + name + "() {\n \n}\n\n" + name + ".prototype = {\n \n};\n");
|
|
445
|
+
},
|
|
446
|
+
*/
|
|
447
|
+
reindent: function() {
|
|
448
|
+
var lineCount = this.mirror.lineCount();
|
|
449
|
+
for(var line = 0; line < lineCount; line++) {
|
|
450
|
+
this.mirror.indentLine(line);
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
about : function() {
|
|
454
|
+
string = "CodeMirror-UI was written by Jeremy Green (http://www.octolabs.com/) as a light interface around CodeMirror by Marijn Haverbeke (http://codemirror.net)."
|
|
455
|
+
string += "\n\n"
|
|
456
|
+
string += "Documentation and the code can be found at https://github.com/jagthedrummer/codemirror-ui/."
|
|
457
|
+
alert(string);
|
|
458
|
+
},
|
|
459
|
+
reindentSelection: function() {
|
|
460
|
+
var cur = this.mirror.getCursor()
|
|
461
|
+
//console.log(cur)
|
|
462
|
+
var start = this.mirror.getCursor(true)["line"]
|
|
463
|
+
var end = this.mirror.getCursor(false)["line"]
|
|
464
|
+
for(var line = start; line <= end; line++) {
|
|
465
|
+
this.mirror.indentLine(line);
|
|
466
|
+
}
|
|
467
|
+
//this.mirror.reindentSelection();
|
|
468
|
+
|
|
469
|
+
},
|
|
470
|
+
// Event handler registration. If disconnect is true, it'll return a
|
|
471
|
+
// function that unregisters the handler.
|
|
472
|
+
// Borrowed from CodeMirror + modified
|
|
473
|
+
connect: function (node, type, handler, disconnect) {
|
|
474
|
+
/*function wrapHandler(event) {
|
|
475
|
+
handler(new Event(event || window.event));
|
|
476
|
+
}*/
|
|
477
|
+
|
|
478
|
+
if (typeof node.addEventListener == "function") {
|
|
479
|
+
node.addEventListener(type, handler, false);
|
|
480
|
+
if (disconnect)
|
|
481
|
+
return function() {
|
|
482
|
+
node.removeEventListener(type, handler, false);
|
|
483
|
+
};
|
|
484
|
+
} else {
|
|
485
|
+
node.attachEvent("on" + type, handler);
|
|
486
|
+
if (disconnect)
|
|
487
|
+
return function() {
|
|
488
|
+
node.detachEvent("on" + type, handler);
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
/*
|
|
495
|
+
* This makes coding callbacks much more sane
|
|
496
|
+
*/
|
|
497
|
+
Function.prototype.cmuiBind = function(scope) {
|
|
498
|
+
var _function = this;
|
|
499
|
+
|
|
500
|
+
return function() {
|
|
501
|
+
return _function.apply(scope, arguments);
|
|
502
|
+
}
|
|
503
|
+
}
|