javascriptmvc 3.0.0.pre15
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/README.markdown +15 -0
- data/Rakefile +17 -0
- data/VERSION +1 -0
- data/bin/jmvc-build +4 -0
- data/bin/jmvc-gen +4 -0
- data/bin/jmvc-get +4 -0
- data/bin/jmvc-init +4 -0
- data/bin/jmvc-update +4 -0
- data/lib/javascriptmvc.rb +97 -0
- data/lib/javascriptmvc/documentjs/README +0 -0
- data/lib/javascriptmvc/documentjs/add.js +76 -0
- data/lib/javascriptmvc/documentjs/application.js +285 -0
- data/lib/javascriptmvc/documentjs/attribute.js +61 -0
- data/lib/javascriptmvc/documentjs/baseclass.js +537 -0
- data/lib/javascriptmvc/documentjs/class.js +141 -0
- data/lib/javascriptmvc/documentjs/constructor.js +145 -0
- data/lib/javascriptmvc/documentjs/directives.js +394 -0
- data/lib/javascriptmvc/documentjs/distance.js +49 -0
- data/lib/javascriptmvc/documentjs/document +21 -0
- data/lib/javascriptmvc/documentjs/documentjs.js +76 -0
- data/lib/javascriptmvc/documentjs/file.js +55 -0
- data/lib/javascriptmvc/documentjs/function.js +112 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/close.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/download.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/fav-off.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/fav-on.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/favicon.ico +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/logo.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/pre.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-icons_222222_256x240.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-icons_454545_256x240.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-icons_888888_256x240.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/images/video.png +0 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/production.js +552 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/style.css +354 -0
- data/lib/javascriptmvc/documentjs/jmvcdoc/summary.ejs +134 -0
- data/lib/javascriptmvc/documentjs/json.js +172 -0
- data/lib/javascriptmvc/documentjs/page.js +107 -0
- data/lib/javascriptmvc/documentjs/pair.js +302 -0
- data/lib/javascriptmvc/documentjs/prototype.js +13 -0
- data/lib/javascriptmvc/documentjs/scripts/build.js +6 -0
- data/lib/javascriptmvc/documentjs/static.js +25 -0
- data/lib/javascriptmvc/documentjs/test/docs/Something.json +1 -0
- data/lib/javascriptmvc/documentjs/test/docs/searchData.json +1 -0
- data/lib/javascriptmvc/documentjs/test/something.js +8 -0
- data/lib/javascriptmvc/documentjs/test/test.html +6 -0
- data/lib/javascriptmvc/documentjs/test_doc.html +1 -0
- data/lib/javascriptmvc/documentjs/update +5 -0
- data/lib/javascriptmvc/funcunit/README +17 -0
- data/lib/javascriptmvc/funcunit/autosuggest/auto_suggest.js +495 -0
- data/lib/javascriptmvc/funcunit/autosuggest/autosuggest.css +24 -0
- data/lib/javascriptmvc/funcunit/autosuggest/autosuggest.html +26 -0
- data/lib/javascriptmvc/funcunit/autosuggest/autosuggest.js +17 -0
- data/lib/javascriptmvc/funcunit/autosuggest/autosuggest_test.js +14 -0
- data/lib/javascriptmvc/funcunit/autosuggest/funcunit.html +15 -0
- data/lib/javascriptmvc/funcunit/build.js +54 -0
- data/lib/javascriptmvc/funcunit/drivers/selenium.js +129 -0
- data/lib/javascriptmvc/funcunit/drivers/standard.js +169 -0
- data/lib/javascriptmvc/funcunit/envjs +13 -0
- data/lib/javascriptmvc/funcunit/envjs.bat +28 -0
- data/lib/javascriptmvc/funcunit/funcunit.html +20 -0
- data/lib/javascriptmvc/funcunit/funcunit.js +1509 -0
- data/lib/javascriptmvc/funcunit/java/selenium-java-client-driver.jar +0 -0
- data/lib/javascriptmvc/funcunit/java/selenium-server.jar +0 -0
- data/lib/javascriptmvc/funcunit/qunit.html +22 -0
- data/lib/javascriptmvc/funcunit/qunit/qunit.css +119 -0
- data/lib/javascriptmvc/funcunit/qunit/qunit.js +1124 -0
- data/lib/javascriptmvc/funcunit/qunit/rhino/rhino.js +24 -0
- data/lib/javascriptmvc/funcunit/qunit/test/qunit.html +18 -0
- data/lib/javascriptmvc/funcunit/qunit/test/test.js +7 -0
- data/lib/javascriptmvc/funcunit/resources/funcunit.js +31 -0
- data/lib/javascriptmvc/funcunit/resources/jquery.js +6378 -0
- data/lib/javascriptmvc/funcunit/resources/json.js +201 -0
- data/lib/javascriptmvc/funcunit/resources/selenium_start.js +43 -0
- data/lib/javascriptmvc/funcunit/scripts/run.js +36 -0
- data/lib/javascriptmvc/funcunit/scripts/test.js +55 -0
- data/lib/javascriptmvc/funcunit/settings.js +10 -0
- data/lib/javascriptmvc/funcunit/synthetic/browsers.js +151 -0
- data/lib/javascriptmvc/funcunit/synthetic/demo.html +150 -0
- data/lib/javascriptmvc/funcunit/synthetic/demo/record.js +254 -0
- data/lib/javascriptmvc/funcunit/synthetic/drag/drag.html +41 -0
- data/lib/javascriptmvc/funcunit/synthetic/drag/drag.js +268 -0
- data/lib/javascriptmvc/funcunit/synthetic/drag/qunit.html +20 -0
- data/lib/javascriptmvc/funcunit/synthetic/drag/test/qunit/drag_test.js +195 -0
- data/lib/javascriptmvc/funcunit/synthetic/drag/test/qunit/qunit.js +7 -0
- data/lib/javascriptmvc/funcunit/synthetic/key.js +832 -0
- data/lib/javascriptmvc/funcunit/synthetic/mouse.js +291 -0
- data/lib/javascriptmvc/funcunit/synthetic/qunit.html +22 -0
- data/lib/javascriptmvc/funcunit/synthetic/recorder.html +303 -0
- data/lib/javascriptmvc/funcunit/synthetic/synthetic.html +85 -0
- data/lib/javascriptmvc/funcunit/synthetic/synthetic.js +796 -0
- data/lib/javascriptmvc/funcunit/synthetic/test/qunit/key_test.js +391 -0
- data/lib/javascriptmvc/funcunit/synthetic/test/qunit/mouse_test.js +233 -0
- data/lib/javascriptmvc/funcunit/synthetic/test/qunit/qunit.js +6 -0
- data/lib/javascriptmvc/funcunit/synthetic/test/qunit/synthetic_test.js +91 -0
- data/lib/javascriptmvc/funcunit/synthetic/test/submit.html +29 -0
- data/lib/javascriptmvc/funcunit/synthetic/test/submitted.html +3 -0
- data/lib/javascriptmvc/funcunit/template.html +18 -0
- data/lib/javascriptmvc/funcunit/test/drag.html +63 -0
- data/lib/javascriptmvc/funcunit/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/funcunit/test/funcunit/funcunit_test.js +87 -0
- data/lib/javascriptmvc/funcunit/test/funcunit/open_test.js +28 -0
- data/lib/javascriptmvc/funcunit/test/funcunit/protodrag_test.js +13 -0
- data/lib/javascriptmvc/funcunit/test/funcunit/syn_test.js +41 -0
- data/lib/javascriptmvc/funcunit/test/jquery.event.drag.js +801 -0
- data/lib/javascriptmvc/funcunit/test/jquery.event.drop.js +439 -0
- data/lib/javascriptmvc/funcunit/test/jquery.js +6360 -0
- data/lib/javascriptmvc/funcunit/test/myapp.html +103 -0
- data/lib/javascriptmvc/funcunit/test/myotherapp.html +15 -0
- data/lib/javascriptmvc/funcunit/test/protodrag/dragdrop.js +974 -0
- data/lib/javascriptmvc/funcunit/test/protodrag/effects.js +1123 -0
- data/lib/javascriptmvc/funcunit/test/protodrag/funcunit_test.js +20 -0
- data/lib/javascriptmvc/funcunit/test/protodrag/myapp.html +63 -0
- data/lib/javascriptmvc/funcunit/test/protodrag/prototype.js +4874 -0
- data/lib/javascriptmvc/funcunit/test/protodrag/scriptaculous.js +68 -0
- data/lib/javascriptmvc/funcunit/update +5 -0
- data/lib/javascriptmvc/jquery/README +24 -0
- data/lib/javascriptmvc/jquery/build.js +73 -0
- data/lib/javascriptmvc/jquery/class/class.html +109 -0
- data/lib/javascriptmvc/jquery/class/class.js +627 -0
- data/lib/javascriptmvc/jquery/class/qunit.html +15 -0
- data/lib/javascriptmvc/jquery/class/test/qunit/class_test.js +146 -0
- data/lib/javascriptmvc/jquery/class/test/qunit/qunit.js +5 -0
- data/lib/javascriptmvc/jquery/class/test/qunit/test.html +20 -0
- data/lib/javascriptmvc/jquery/controller/controller.html +89 -0
- data/lib/javascriptmvc/jquery/controller/controller.js +735 -0
- data/lib/javascriptmvc/jquery/controller/history/history.html +44 -0
- data/lib/javascriptmvc/jquery/controller/history/history.js +177 -0
- data/lib/javascriptmvc/jquery/controller/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/scripts/compress.js +6 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/scripts/docs.js +6 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/subscribe.html +56 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/subscribe.js +27 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/test/funcunit/subscribe_test.js +11 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/controller/subscribe/test/qunit/subscribe_test.js +4 -0
- data/lib/javascriptmvc/jquery/controller/test/qunit/controller_test.js +170 -0
- data/lib/javascriptmvc/jquery/controller/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/controller/view/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/controller/view/test/qunit/controller_view_test.js +15 -0
- data/lib/javascriptmvc/jquery/controller/view/test/qunit/qunit.js +6 -0
- data/lib/javascriptmvc/jquery/controller/view/test/qunit/views/init.micro +1 -0
- data/lib/javascriptmvc/jquery/controller/view/view.js +102 -0
- data/lib/javascriptmvc/jquery/dom/closest/closest.html +23 -0
- data/lib/javascriptmvc/jquery/dom/closest/closest.js +47 -0
- data/lib/javascriptmvc/jquery/dom/closest/funcunit.html +20 -0
- data/lib/javascriptmvc/jquery/dom/closest/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/dom/closest/scripts/compress.js +3 -0
- data/lib/javascriptmvc/jquery/dom/closest/scripts/doc.js +4 -0
- data/lib/javascriptmvc/jquery/dom/closest/scripts/test.js +55 -0
- data/lib/javascriptmvc/jquery/dom/closest/settings.js +40 -0
- data/lib/javascriptmvc/jquery/dom/closest/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/dom/closest/test/funcunit/tests/basic.js +11 -0
- data/lib/javascriptmvc/jquery/dom/closest/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/dom/closest/test/qunit/tests/basic.js +4 -0
- data/lib/javascriptmvc/jquery/dom/compare/compare.html +88 -0
- data/lib/javascriptmvc/jquery/dom/compare/compare.js +67 -0
- data/lib/javascriptmvc/jquery/dom/compare/qunit.html +20 -0
- data/lib/javascriptmvc/jquery/dom/compare/test/qunit/compare_test.js +19 -0
- data/lib/javascriptmvc/jquery/dom/compare/test/qunit/qunit.js +5 -0
- data/lib/javascriptmvc/jquery/dom/cookie/cookie.html +25 -0
- data/lib/javascriptmvc/jquery/dom/cookie/cookie.js +119 -0
- data/lib/javascriptmvc/jquery/dom/cookie/scripts/compress.js +6 -0
- data/lib/javascriptmvc/jquery/dom/cookie/scripts/doc.js +6 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/funcunit/cookie_test.js +11 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/funcunit/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/qunit/cookie_test.js +4 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/dom/cookie/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/dom/cur_styles/cur_styles.html +71 -0
- data/lib/javascriptmvc/jquery/dom/cur_styles/cur_styles.js +120 -0
- data/lib/javascriptmvc/jquery/dom/cur_styles/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/dom/cur_styles/test/qunit/curStyles.micro +3 -0
- data/lib/javascriptmvc/jquery/dom/cur_styles/test/qunit/cur_styles_test.js +22 -0
- data/lib/javascriptmvc/jquery/dom/cur_styles/test/qunit/outer.micro +0 -0
- data/lib/javascriptmvc/jquery/dom/cur_styles/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/curstyles.html +22 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/dimensions.html +132 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/dimensions.js +140 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/test/qunit/curStyles.micro +3 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/test/qunit/dimensions_test.js +8 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/test/qunit/outer.micro +0 -0
- data/lib/javascriptmvc/jquery/dom/dimensions/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/dom/dom.js +7 -0
- data/lib/javascriptmvc/jquery/dom/fixture/fixture.html +143 -0
- data/lib/javascriptmvc/jquery/dom/fixture/fixture.js +521 -0
- data/lib/javascriptmvc/jquery/dom/fixture/fixtures/messages.html +31 -0
- data/lib/javascriptmvc/jquery/dom/fixture/fixtures/test.json +3 -0
- data/lib/javascriptmvc/jquery/dom/fixture/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/dom/fixture/test/qunit/fixture_test.js +50 -0
- data/lib/javascriptmvc/jquery/dom/fixture/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/dom/form_params/form_params.html +57 -0
- data/lib/javascriptmvc/jquery/dom/form_params/form_params.js +106 -0
- data/lib/javascriptmvc/jquery/dom/form_params/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/dom/form_params/test/qunit/basics.micro +27 -0
- data/lib/javascriptmvc/jquery/dom/form_params/test/qunit/checkbox.micro +20 -0
- data/lib/javascriptmvc/jquery/dom/form_params/test/qunit/form_params_test.js +43 -0
- data/lib/javascriptmvc/jquery/dom/form_params/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/dom/form_params/test/qunit/truthy.micro +8 -0
- data/lib/javascriptmvc/jquery/dom/within/within.js +67 -0
- data/lib/javascriptmvc/jquery/error/background.png +0 -0
- data/lib/javascriptmvc/jquery/error/error.html +31 -0
- data/lib/javascriptmvc/jquery/error/error.js +227 -0
- data/lib/javascriptmvc/jquery/error/setup.js +4 -0
- data/lib/javascriptmvc/jquery/error/test/test.html +23 -0
- data/lib/javascriptmvc/jquery/error/test/test.js +4 -0
- data/lib/javascriptmvc/jquery/event/default/compress.js +7 -0
- data/lib/javascriptmvc/jquery/event/default/default.html +85 -0
- data/lib/javascriptmvc/jquery/event/default/default.js +193 -0
- data/lib/javascriptmvc/jquery/event/default/defaultjquery.html +117 -0
- data/lib/javascriptmvc/jquery/event/default/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/event/default/test/qunit/default_test.js +104 -0
- data/lib/javascriptmvc/jquery/event/default/test/qunit/html.micro +8 -0
- data/lib/javascriptmvc/jquery/event/default/test/qunit/qunit.js +6 -0
- data/lib/javascriptmvc/jquery/event/default/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/event/destroyed/destroyed.html +24 -0
- data/lib/javascriptmvc/jquery/event/destroyed/destroyed.js +40 -0
- data/lib/javascriptmvc/jquery/event/destroyed/destroyed_menu.html +96 -0
- data/lib/javascriptmvc/jquery/event/destroyed/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/event/destroyed/test/qunit/destroyed_test.js +12 -0
- data/lib/javascriptmvc/jquery/event/destroyed/test/qunit/qunit.js +6 -0
- data/lib/javascriptmvc/jquery/event/drag/drag.html +105 -0
- data/lib/javascriptmvc/jquery/event/drag/drag.js +466 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/limit.html +74 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/limit.js +56 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/scripts/compress.js +6 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/scripts/doc.js +6 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/funcunit/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/funcunit/limit_test.js +11 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/qunit/limit_test.js +4 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/event/drag/limit/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/event/drag/qunit.html +16 -0
- data/lib/javascriptmvc/jquery/event/drag/scroll/scroll.js +120 -0
- data/lib/javascriptmvc/jquery/event/drag/test/qunit/drag_test.js +130 -0
- data/lib/javascriptmvc/jquery/event/drag/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/event/drop/drop.html +74 -0
- data/lib/javascriptmvc/jquery/event/drop/drop.js +301 -0
- data/lib/javascriptmvc/jquery/event/event.js +6 -0
- data/lib/javascriptmvc/jquery/event/hashchange/hashchange.js +245 -0
- data/lib/javascriptmvc/jquery/event/hover/compress.js +7 -0
- data/lib/javascriptmvc/jquery/event/hover/hover.html +56 -0
- data/lib/javascriptmvc/jquery/event/hover/hover.js +219 -0
- data/lib/javascriptmvc/jquery/event/hover/qunit.html +16 -0
- data/lib/javascriptmvc/jquery/event/hover/test/qunit/hover_test.js +55 -0
- data/lib/javascriptmvc/jquery/event/hover/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/event/livehack/compress.js +7 -0
- data/lib/javascriptmvc/jquery/event/livehack/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/event/livehack/livehack.html +25 -0
- data/lib/javascriptmvc/jquery/event/livehack/livehack.js +167 -0
- data/lib/javascriptmvc/jquery/event/offline/funcunit.html +20 -0
- data/lib/javascriptmvc/jquery/event/offline/offline.html +26 -0
- data/lib/javascriptmvc/jquery/event/offline/offline.js +36 -0
- data/lib/javascriptmvc/jquery/event/offline/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/event/offline/scripts/compress.js +3 -0
- data/lib/javascriptmvc/jquery/event/offline/scripts/doc.js +4 -0
- data/lib/javascriptmvc/jquery/event/offline/settings.js +41 -0
- data/lib/javascriptmvc/jquery/event/offline/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/event/offline/test/funcunit/tests/basic.js +11 -0
- data/lib/javascriptmvc/jquery/event/offline/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/event/offline/test/qunit/tests/basic.js +4 -0
- data/lib/javascriptmvc/jquery/event/resize/funcunit.html +20 -0
- data/lib/javascriptmvc/jquery/event/resize/qunit.html +22 -0
- data/lib/javascriptmvc/jquery/event/resize/resize.html +23 -0
- data/lib/javascriptmvc/jquery/event/resize/resize.js +50 -0
- data/lib/javascriptmvc/jquery/event/resize/scripts/compress.js +3 -0
- data/lib/javascriptmvc/jquery/event/resize/scripts/doc.js +4 -0
- data/lib/javascriptmvc/jquery/event/resize/scripts/test.js +55 -0
- data/lib/javascriptmvc/jquery/event/resize/settings.js +40 -0
- data/lib/javascriptmvc/jquery/event/resize/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/event/resize/test/funcunit/tests/basic.js +11 -0
- data/lib/javascriptmvc/jquery/event/resize/test/qunit/qunit.js +4 -0
- data/lib/javascriptmvc/jquery/event/resize/test/qunit/tests/basic.js +4 -0
- data/lib/javascriptmvc/jquery/event/select/scripts/compress.js +6 -0
- data/lib/javascriptmvc/jquery/event/select/scripts/doc.js +6 -0
- data/lib/javascriptmvc/jquery/event/select/select.html +63 -0
- data/lib/javascriptmvc/jquery/event/select/select.js +65 -0
- data/lib/javascriptmvc/jquery/event/select/test/funcunit/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/event/select/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/event/select/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/event/select/test/funcunit/select_test.js +11 -0
- data/lib/javascriptmvc/jquery/event/select/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/event/select/test/qunit/qunit.js +5 -0
- data/lib/javascriptmvc/jquery/event/select/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/event/select/test/qunit/select_test.js +4 -0
- data/lib/javascriptmvc/jquery/generate/app +23 -0
- data/lib/javascriptmvc/jquery/generate/controller +21 -0
- data/lib/javascriptmvc/jquery/generate/model +26 -0
- data/lib/javascriptmvc/jquery/generate/page +20 -0
- data/lib/javascriptmvc/jquery/generate/plugin +20 -0
- data/lib/javascriptmvc/jquery/generate/scaffold +23 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/(application_name).css.ejs +4 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/(application_name).html.ejs +23 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/(application_name).js.ejs +21 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/controllers/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/docs/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/fixtures/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/funcunit.html.ejs +15 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/models/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/qunit.html.ejs +20 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/resources/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/scripts/build.js.ejs +6 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/scripts/clean.js.ejs +6 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/scripts/docs.js.ejs +4 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/test/funcunit/(application_name)_test.js.ejs +9 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/test/funcunit/funcunit.js.ejs +3 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/test/qunit/(application_name)_test.js.ejs +5 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/test/qunit/qunit.js.ejs +3 -0
- data/lib/javascriptmvc/jquery/generate/templates/app/views/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/controller/controllers/(underscore)_controller.js.ejs +12 -0
- data/lib/javascriptmvc/jquery/generate/templates/model/fixtures.link +1 -0
- data/lib/javascriptmvc/jquery/generate/templates/model/models.link +1 -0
- data/lib/javascriptmvc/jquery/generate/templates/model/test/qunit.link +1 -0
- data/lib/javascriptmvc/jquery/generate/templates/page.ejs +23 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/(application_name).html.ejs +23 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/(application_name).js.ejs +3 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/fixtures/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/funcunit.html.ejs +15 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/qunit.html.ejs +20 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/resources/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/scripts.link +1 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/test.link +1 -0
- data/lib/javascriptmvc/jquery/generate/templates/plugin/views/.ignore +0 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/controllers/(underscore)_controller.js.ejs +96 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/fixtures/(plural).json.get.ejs +3 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/models/(underscore).js.ejs +83 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/test/funcunit/(underscore)_controller_test.js.ejs +63 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/test/qunit/(underscore)_test.js.ejs +45 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/views/(underscore)/edit.ejs.ejs +10 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/views/(underscore)/init.ejs.ejs +26 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/views/(underscore)/list.ejs.ejs +5 -0
- data/lib/javascriptmvc/jquery/generate/templates/scaffold/views/(underscore)/show.ejs.ejs +10 -0
- data/lib/javascriptmvc/jquery/jquery.js +6360 -0
- data/lib/javascriptmvc/jquery/lang/json/json.html +25 -0
- data/lib/javascriptmvc/jquery/lang/json/json.js +201 -0
- data/lib/javascriptmvc/jquery/lang/json/scripts/compress.js +6 -0
- data/lib/javascriptmvc/jquery/lang/json/scripts/doc.js +6 -0
- data/lib/javascriptmvc/jquery/lang/json/test/funcunit/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/lang/json/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/lang/json/test/funcunit/json_test.js +11 -0
- data/lib/javascriptmvc/jquery/lang/json/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/lang/json/test/qunit/json_test.js +4 -0
- data/lib/javascriptmvc/jquery/lang/json/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/lang/json/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/lang/json/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/lang/lang.html +27 -0
- data/lib/javascriptmvc/jquery/lang/lang.js +104 -0
- data/lib/javascriptmvc/jquery/lang/openajax/openajax.js +202 -0
- data/lib/javascriptmvc/jquery/lang/rsplit/rsplit.js +31 -0
- data/lib/javascriptmvc/jquery/lang/vector/vector.js +167 -0
- data/lib/javascriptmvc/jquery/model/associations/associations.html +25 -0
- data/lib/javascriptmvc/jquery/model/associations/associations.js +46 -0
- data/lib/javascriptmvc/jquery/model/associations/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/model/associations/test/qunit/associations_test.js +51 -0
- data/lib/javascriptmvc/jquery/model/associations/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/model/associations/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/model/backup/backup.js +82 -0
- data/lib/javascriptmvc/jquery/model/json_rest/json_rest.js +91 -0
- data/lib/javascriptmvc/jquery/model/list/list.js +148 -0
- data/lib/javascriptmvc/jquery/model/list/qunit.html +16 -0
- data/lib/javascriptmvc/jquery/model/list/test/qunit/list_test.js +58 -0
- data/lib/javascriptmvc/jquery/model/list/test/qunit/qunit.js +6 -0
- data/lib/javascriptmvc/jquery/model/list/test/qunit/run.js +0 -0
- data/lib/javascriptmvc/jquery/model/model.js +537 -0
- data/lib/javascriptmvc/jquery/model/qunit.html +17 -0
- data/lib/javascriptmvc/jquery/model/store/store.js +66 -0
- data/lib/javascriptmvc/jquery/model/test/qunit/model_test.js +71 -0
- data/lib/javascriptmvc/jquery/model/test/qunit/qunit.js +5 -0
- data/lib/javascriptmvc/jquery/qunit.html +15 -0
- data/lib/javascriptmvc/jquery/test/funcunit/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/test/funcunit/jquerytest_test.js +11 -0
- data/lib/javascriptmvc/jquery/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/test/qunit/qunit.js +22 -0
- data/lib/javascriptmvc/jquery/update +5 -0
- data/lib/javascriptmvc/jquery/view/compress.js +7 -0
- data/lib/javascriptmvc/jquery/view/ejs/ejs.html +25 -0
- data/lib/javascriptmvc/jquery/view/ejs/ejs.js +489 -0
- data/lib/javascriptmvc/jquery/view/ejs/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/view/ejs/test/funcunit/ejs_test.js +11 -0
- data/lib/javascriptmvc/jquery/view/ejs/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/view/ejs/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/view/ejs/test/qunit/ejs_test.js +4 -0
- data/lib/javascriptmvc/jquery/view/ejs/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/view/ejs/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/view/ejs/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/view/fulljslint.js +3774 -0
- data/lib/javascriptmvc/jquery/view/helpers/helpers.js +338 -0
- data/lib/javascriptmvc/jquery/view/jaml/compress.js +7 -0
- data/lib/javascriptmvc/jquery/view/jaml/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/view/jaml/jaml.html +25 -0
- data/lib/javascriptmvc/jquery/view/jaml/jaml.js +73 -0
- data/lib/javascriptmvc/jquery/view/jaml/node.js +149 -0
- data/lib/javascriptmvc/jquery/view/jaml/template.js +131 -0
- data/lib/javascriptmvc/jquery/view/jaml/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/view/jaml/test/funcunit/jaml_test.js +11 -0
- data/lib/javascriptmvc/jquery/view/jaml/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/view/jaml/test/qunit/jaml_test.js +4 -0
- data/lib/javascriptmvc/jquery/view/jaml/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/view/jaml/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/view/jaml/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/view/micro/compress.js +7 -0
- data/lib/javascriptmvc/jquery/view/micro/funcunit.html +21 -0
- data/lib/javascriptmvc/jquery/view/micro/micro.html +25 -0
- data/lib/javascriptmvc/jquery/view/micro/micro.js +57 -0
- data/lib/javascriptmvc/jquery/view/micro/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/view/micro/test/funcunit/micro_test.js +11 -0
- data/lib/javascriptmvc/jquery/view/micro/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/view/micro/test/qunit/micro_test.js +4 -0
- data/lib/javascriptmvc/jquery/view/micro/test/qunit/qunit.html +21 -0
- data/lib/javascriptmvc/jquery/view/micro/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/view/micro/test/qunit/run.js +2 -0
- data/lib/javascriptmvc/jquery/view/qunit.html +16 -0
- data/lib/javascriptmvc/jquery/view/test/compression/compression.html +12 -0
- data/lib/javascriptmvc/jquery/view/test/compression/compression.js +11 -0
- data/lib/javascriptmvc/jquery/view/test/compression/run.js +36 -0
- data/lib/javascriptmvc/jquery/view/test/funcunit/funcunit.js +3 -0
- data/lib/javascriptmvc/jquery/view/test/funcunit/run.js +10 -0
- data/lib/javascriptmvc/jquery/view/test/funcunit/view_test.js +11 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/nested_plugin.ejs +1 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/plugin.ejs +1 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/qunit.js +9 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/template.ejs +1 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/template.jaml +3 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/template.micro +1 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/template.tmpl +1 -0
- data/lib/javascriptmvc/jquery/view/test/qunit/view_test.js +24 -0
- data/lib/javascriptmvc/jquery/view/tmpl/tmpl.js +150 -0
- data/lib/javascriptmvc/jquery/view/view.html +65 -0
- data/lib/javascriptmvc/jquery/view/view.js +296 -0
- data/lib/javascriptmvc/js +56 -0
- data/lib/javascriptmvc/js.bat +57 -0
- data/lib/javascriptmvc/steal/README +26 -0
- data/lib/javascriptmvc/steal/build/apps/apps.js +208 -0
- data/lib/javascriptmvc/steal/build/apps/test.js +4 -0
- data/lib/javascriptmvc/steal/build/build.js +281 -0
- data/lib/javascriptmvc/steal/build/pluginify.js +73 -0
- data/lib/javascriptmvc/steal/build/scripts/compiler.jar +0 -0
- data/lib/javascriptmvc/steal/build/scripts/scripts.js +155 -0
- data/lib/javascriptmvc/steal/build/styles/cssmin.js +17 -0
- data/lib/javascriptmvc/steal/build/styles/styles.js +84 -0
- data/lib/javascriptmvc/steal/build/test/basicpage.html +6 -0
- data/lib/javascriptmvc/steal/build/test/basicproduction.js +1 -0
- data/lib/javascriptmvc/steal/build/test/basicsource.js +6 -0
- data/lib/javascriptmvc/steal/build/test/css/css/css1.css +1 -0
- data/lib/javascriptmvc/steal/build/test/css/css/justin.png +0 -0
- data/lib/javascriptmvc/steal/build/test/css/css2.css +5 -0
- data/lib/javascriptmvc/steal/build/test/css/page.html +9 -0
- data/lib/javascriptmvc/steal/build/test/css/production.css +1 -0
- data/lib/javascriptmvc/steal/build/test/css/test.js +7 -0
- data/lib/javascriptmvc/steal/build/test/css/upload.PNG +0 -0
- data/lib/javascriptmvc/steal/build/test/foreign.html +6 -0
- data/lib/javascriptmvc/steal/build/test/foreign.js +2 -0
- data/lib/javascriptmvc/steal/build/test/removecode.js +11 -0
- data/lib/javascriptmvc/steal/build/test/run.js +57 -0
- data/lib/javascriptmvc/steal/build/test/stealpage.html +10 -0
- data/lib/javascriptmvc/steal/build/test/stealprodpage.html +10 -0
- data/lib/javascriptmvc/steal/build/test/test.js +3 -0
- data/lib/javascriptmvc/steal/buildjs +21 -0
- data/lib/javascriptmvc/steal/clean/beautify.js +1108 -0
- data/lib/javascriptmvc/steal/clean/clean.js +179 -0
- data/lib/javascriptmvc/steal/clean/jslint.js +5662 -0
- data/lib/javascriptmvc/steal/clean/test.js +7 -0
- data/lib/javascriptmvc/steal/cleanjs +5 -0
- data/lib/javascriptmvc/steal/coffee/coffee-script.js +9 -0
- data/lib/javascriptmvc/steal/coffee/coffee.js +56 -0
- data/lib/javascriptmvc/steal/dev/dev.js +83 -0
- data/lib/javascriptmvc/steal/end.js +1 -0
- data/lib/javascriptmvc/steal/generate/app +23 -0
- data/lib/javascriptmvc/steal/generate/ejs.js +470 -0
- data/lib/javascriptmvc/steal/generate/generate.js +211 -0
- data/lib/javascriptmvc/steal/generate/inflector.js +117 -0
- data/lib/javascriptmvc/steal/generate/system.js +33 -0
- data/lib/javascriptmvc/steal/generate/templates/app/(application_name).css.ejs +10 -0
- data/lib/javascriptmvc/steal/generate/templates/app/(application_name).html.ejs +18 -0
- data/lib/javascriptmvc/steal/generate/templates/app/(application_name).js.ejs +10 -0
- data/lib/javascriptmvc/steal/generate/templates/app/docs/.ignore +0 -0
- data/lib/javascriptmvc/steal/generate/templates/app/resources/.ignore +0 -0
- data/lib/javascriptmvc/steal/generate/templates/app/resources/example.coffee.ejs +5 -0
- data/lib/javascriptmvc/steal/generate/templates/app/resources/example.js.ejs +13 -0
- data/lib/javascriptmvc/steal/generate/templates/app/resources/example.less.ejs +9 -0
- data/lib/javascriptmvc/steal/generate/templates/app/scripts/build.js.ejs +6 -0
- data/lib/javascriptmvc/steal/generate/templates/app/scripts/clean.js.ejs +6 -0
- data/lib/javascriptmvc/steal/generate/templates/app/test/.ignore +0 -0
- data/lib/javascriptmvc/steal/generate/templates/page.ejs +23 -0
- data/lib/javascriptmvc/steal/generate/test/test.js +92 -0
- data/lib/javascriptmvc/steal/get/get.js +163 -0
- data/lib/javascriptmvc/steal/get/gets.json +10 -0
- data/lib/javascriptmvc/steal/get/getter.js +115 -0
- data/lib/javascriptmvc/steal/get/github.js +134 -0
- data/lib/javascriptmvc/steal/get/json.js +172 -0
- data/lib/javascriptmvc/steal/getjs +5 -0
- data/lib/javascriptmvc/steal/js +56 -0
- data/lib/javascriptmvc/steal/js.bat +57 -0
- data/lib/javascriptmvc/steal/less/less.js +117 -0
- data/lib/javascriptmvc/steal/less/less_engine.js +2529 -0
- data/lib/javascriptmvc/steal/rhino/blank.html +6 -0
- data/lib/javascriptmvc/steal/rhino/build.js +31 -0
- data/lib/javascriptmvc/steal/rhino/docs.js +68 -0
- data/lib/javascriptmvc/steal/rhino/empty.html +12 -0
- data/lib/javascriptmvc/steal/rhino/env.js +11537 -0
- data/lib/javascriptmvc/steal/rhino/file.js +299 -0
- data/lib/javascriptmvc/steal/rhino/js.jar +0 -0
- data/lib/javascriptmvc/steal/rhino/loader.js +8 -0
- data/lib/javascriptmvc/steal/rhino/prompt.js +49 -0
- data/lib/javascriptmvc/steal/rhino/steal.js +122 -0
- data/lib/javascriptmvc/steal/rhino/test.js +16 -0
- data/lib/javascriptmvc/steal/steal.js +1317 -0
- data/lib/javascriptmvc/steal/steal.production.js +23 -0
- data/lib/javascriptmvc/steal/test/absoluteurl.html +7 -0
- data/lib/javascriptmvc/steal/test/absoluteurl/absoluteurl.js +1 -0
- data/lib/javascriptmvc/steal/test/absoluteurl/alert.js +1 -0
- data/lib/javascriptmvc/steal/test/another/two.js +2 -0
- data/lib/javascriptmvc/steal/test/one/four.js +1 -0
- data/lib/javascriptmvc/steal/test/one/one.js +6 -0
- data/lib/javascriptmvc/steal/test/qunit/qunit.html +22 -0
- data/lib/javascriptmvc/steal/test/qunit/qunit.js +3 -0
- data/lib/javascriptmvc/steal/test/qunit/steal_test.js +197 -0
- data/lib/javascriptmvc/steal/test/run.js +12 -0
- data/lib/javascriptmvc/steal/test/steal.html +37 -0
- data/lib/javascriptmvc/steal/test/test.js +82 -0
- data/lib/javascriptmvc/steal/test/three.js +3 -0
- data/lib/javascriptmvc/steal/testing/test.html +20 -0
- data/lib/javascriptmvc/steal/testing/testing.js +48 -0
- data/lib/javascriptmvc/steal/update +5 -0
- metadata +622 -0
File without changes
|
@@ -0,0 +1,537 @@
|
|
1
|
+
steal.plugins('jquery', 'jquery/class', 'jquery/lang', 'jquery/lang/openajax').then(function() {
|
2
|
+
//a cache for attribute capitalization ... slowest part of inti.
|
3
|
+
var capitalize = $.String.capitalize,
|
4
|
+
underscore = $.String.underscore;
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @tag core
|
8
|
+
* Models wrap an application's data layer. In large applications, a model is critical for:
|
9
|
+
* <ul>
|
10
|
+
* <li>Abstracting service dependencies inside the model, making it so
|
11
|
+
* Controllers + Views don't care where data comes from.</li>
|
12
|
+
* <li>Providing helper functions that make manipulating and abstracting raw service data easier.</li>
|
13
|
+
* </ul>
|
14
|
+
* This is done in two ways:
|
15
|
+
* <ul>
|
16
|
+
* <li>Requesting data from and interacting with services</li>
|
17
|
+
* <li>Converting or wrapping raw service data into a more useful form.</li>
|
18
|
+
* </ul>
|
19
|
+
*
|
20
|
+
* <h2>Basic Use</h2>
|
21
|
+
*
|
22
|
+
* The [jQuery.Model] class provides a basic skeleton to organize pieces of your application's data layer.
|
23
|
+
* First, consider doing Ajax <b>without</b> a model. In our imaginary app, you:
|
24
|
+
* <ul>
|
25
|
+
* <li>retrieve a list of tasks</li>
|
26
|
+
* <li>display the number of days remaining for each task</li>
|
27
|
+
* <li>mark tasks as complete after users click them</li>
|
28
|
+
* </ul>
|
29
|
+
* Let's see how that might look without a model:
|
30
|
+
* @codestart
|
31
|
+
* $.Controller.extend("MyApp.Controllers.Tasks",{onDocument: true},
|
32
|
+
* {
|
33
|
+
* // get tasks when the page is ready
|
34
|
+
* ready: function() {
|
35
|
+
* $.get('/tasks.json', this.callback('gotTasks'), 'json')
|
36
|
+
* },
|
37
|
+
* /*
|
38
|
+
* * assume json is an array like [{name: "trash", due_date: 1247111409283}, ...]
|
39
|
+
* *|
|
40
|
+
* gotTasks: function( json ) {
|
41
|
+
* for(var i =0; i < json.length; i++){
|
42
|
+
* var taskJson = json[i];
|
43
|
+
*
|
44
|
+
* //calculate time remaining
|
45
|
+
* var remaininTime = new Date() - new Date(taskJson.due_date);
|
46
|
+
*
|
47
|
+
* //append some html
|
48
|
+
* $("#tasks").append("<div class='task' taskid='"+taskJson.id+"'>"+
|
49
|
+
* "<label>"+taskJson.name+"</label>"+
|
50
|
+
* "Due Date = "+remaininTime+"</div>")
|
51
|
+
* }
|
52
|
+
* },
|
53
|
+
* // when a task is complete, get the id, make a request, remove it
|
54
|
+
* ".task click" : function( el ) {
|
55
|
+
* $.post('/task_complete',{id: el.attr('data-taskid')}, function(){
|
56
|
+
* el.remove();
|
57
|
+
* })
|
58
|
+
* }
|
59
|
+
* })
|
60
|
+
* @codeend
|
61
|
+
* This code might seem fine for right now, but what if:
|
62
|
+
* <ul>
|
63
|
+
* <li>The service changes?</li>
|
64
|
+
* <li>Other parts of the app want to calculate <code>remaininTime</code>?</li>
|
65
|
+
* <li>Other parts of the app want to get tasks?</li>
|
66
|
+
* <li>The same task is represented multiple palces on the page?</li>
|
67
|
+
* </ul>
|
68
|
+
* The solution is of course a strong model layer. Lets look at what a
|
69
|
+
* a good model does for a controller before we learn how to make one:
|
70
|
+
* @codestart
|
71
|
+
* $.Controller.extend("MyApp.Controllers.Tasks",{onDocument: true},
|
72
|
+
* {
|
73
|
+
* load: function() {
|
74
|
+
* Task.findAll({},this.callback('list'))
|
75
|
+
* },
|
76
|
+
* list: function( tasks ) {
|
77
|
+
* $("#tasks").html(this.view(tasks))
|
78
|
+
* },
|
79
|
+
* ".task click" : function( el ) {
|
80
|
+
* el.models()[0].complete(function(){
|
81
|
+
* el.remove();
|
82
|
+
* });
|
83
|
+
* }
|
84
|
+
* })
|
85
|
+
* @codeend
|
86
|
+
* In views/tasks/list.ejs
|
87
|
+
* @codestart html
|
88
|
+
* <% for(var i =0; i < tasks.length; i++){ %>
|
89
|
+
* <div class='task <%= tasks[i].<b>identity</b>() %>'>
|
90
|
+
* <label><%= tasks[i].name %></label>
|
91
|
+
* <%= tasks[i].<b>timeRemaining</b>() %>
|
92
|
+
* </div>
|
93
|
+
* <% } %>
|
94
|
+
* @codeend
|
95
|
+
*
|
96
|
+
* Isn't that better! Granted, some of the improvement comes because we used a view, but we've
|
97
|
+
* also made our controller completely understandable. Now lets take a look at the model:
|
98
|
+
* @codestart
|
99
|
+
* $.Model.extend("Task",
|
100
|
+
* {
|
101
|
+
* findAll: function( params,success ) {
|
102
|
+
* $.get("/tasks.json", params, this.callback(["wrapMany",success]),"json");
|
103
|
+
* }
|
104
|
+
* },
|
105
|
+
* {
|
106
|
+
* timeRemaining: function() {
|
107
|
+
* return new Date() - new Date(this.due_date)
|
108
|
+
* },
|
109
|
+
* complete: function( success ) {
|
110
|
+
* $.get("/task_complete", {id: this.id }, success,"json");
|
111
|
+
* }
|
112
|
+
* })
|
113
|
+
* @codeend
|
114
|
+
* There, much better! Now you have a single place where you can organize Ajax functionality and
|
115
|
+
* wrap the data that it returned. Lets go through each bolded item in the controller and view.<br/>
|
116
|
+
*
|
117
|
+
* <h3>Task.findAll</h3>
|
118
|
+
* The findAll function requests data from "/tasks.json". When the data is returned, it it is run through
|
119
|
+
* the "wrapMany" function before being passed to the success callback.<br/>
|
120
|
+
* If you don't understand how the callback works, you might want to check out
|
121
|
+
* [jQuery.Model.static.wrapMany wrapMany] and [jQuery.Class.static.callback callback].
|
122
|
+
* <h3>el.models</h3>
|
123
|
+
* [jQuery.fn.models models] is a jQuery helper that returns model instances. It uses
|
124
|
+
* the jQuery's elements' shortNames to find matching model instances. For example:
|
125
|
+
* @codestart html
|
126
|
+
* <div class='task task_5'> ... </div>
|
127
|
+
* @codeend
|
128
|
+
* It knows to return a task with id = 5.
|
129
|
+
* <h3>complete</h3>
|
130
|
+
* This should be pretty obvious.
|
131
|
+
* <h3>identity</h3>
|
132
|
+
* [jQuery.Model.prototype.identity Identity] returns a unique identifier that [jQuery.fn.models] can use
|
133
|
+
* to retrieve your model instance.
|
134
|
+
* <h3>timeRemaining</h3>
|
135
|
+
* timeRemaining is a good example of wrapping your model's raw data with more useful functionality.
|
136
|
+
* <h2>Validations</h2>
|
137
|
+
* You can validate your model's attributes with another plugin. See [validation].
|
138
|
+
*/
|
139
|
+
|
140
|
+
|
141
|
+
jQuery.Class.extend("jQuery.Model",
|
142
|
+
/**
|
143
|
+
* @Static
|
144
|
+
*/
|
145
|
+
{
|
146
|
+
setup: function() {
|
147
|
+
// clear everything that shouldn't be reused
|
148
|
+
this.validations = [];
|
149
|
+
this.attributes = {}; //list of all attributes ever given to this model
|
150
|
+
this.associations = {};
|
151
|
+
this._fullName = underscore(this.fullName.replace(/\./g, "_"));
|
152
|
+
|
153
|
+
if ( this.fullName.substr(0, 7) == "jQuery." ) {
|
154
|
+
return;
|
155
|
+
}
|
156
|
+
jQuery.Model.models[this._fullName] = this;
|
157
|
+
if ( this.storeType ) {
|
158
|
+
this.store = new this.storeType(this);
|
159
|
+
}
|
160
|
+
|
161
|
+
},
|
162
|
+
/**
|
163
|
+
* @attribute defaults
|
164
|
+
* An object of default values to be set on all instances.
|
165
|
+
*/
|
166
|
+
defaults: {},
|
167
|
+
/**
|
168
|
+
* Used to create an existing object from attributes
|
169
|
+
* @param {Object} attributes
|
170
|
+
* @return {Model} an instance of the model
|
171
|
+
*/
|
172
|
+
wrap: function( attributes ) {
|
173
|
+
if (!attributes ) {
|
174
|
+
return null;
|
175
|
+
}
|
176
|
+
return new this(
|
177
|
+
// checks for properties in an object (like rails 2.0 gives);
|
178
|
+
attributes[this.singularName] || attributes.attributes || attributes);
|
179
|
+
},
|
180
|
+
/**
|
181
|
+
* Creates many instances
|
182
|
+
* @param {Array} instancesRawData an array of raw name - value pairs.
|
183
|
+
* @return {Array} an array of instances of the model
|
184
|
+
*/
|
185
|
+
wrapMany: function( instances ) {
|
186
|
+
if (!instances ) return null;
|
187
|
+
var res = new(this.List || Array),
|
188
|
+
arr = $.isArray(instances),
|
189
|
+
raw = arr ? instances : instances.data,
|
190
|
+
length = raw.length,
|
191
|
+
i = 0;
|
192
|
+
res._use_call = true; //so we don't call next function with all of these
|
193
|
+
for (; i < length; i++ ) {
|
194
|
+
res.push(this.wrap(raw[i]));
|
195
|
+
}
|
196
|
+
if (!arr ) { //push other stuff onto array
|
197
|
+
for ( var prop in instances ) {
|
198
|
+
if ( prop !== 'data' ) {
|
199
|
+
res[prop] = instances[prop];
|
200
|
+
}
|
201
|
+
|
202
|
+
}
|
203
|
+
}
|
204
|
+
return res; //model list?
|
205
|
+
},
|
206
|
+
/**
|
207
|
+
* The name of the id field. Defaults to 'id'. Change this if it is something different.
|
208
|
+
*/
|
209
|
+
id: 'id',
|
210
|
+
//if null, maybe treat as an array?
|
211
|
+
/**
|
212
|
+
* Adds an attribute to the list of attributes for this class.
|
213
|
+
* @hide
|
214
|
+
* @param {String} property
|
215
|
+
* @param {String} type
|
216
|
+
*/
|
217
|
+
addAttr: function( property, type ) {
|
218
|
+
if ( this.associations[property] ) return;
|
219
|
+
this.attributes[property] || (this.attributes[property] = type);
|
220
|
+
return type
|
221
|
+
},
|
222
|
+
models: {},
|
223
|
+
/**
|
224
|
+
* Publishes to open ajax hub. Always adds the shortName.event
|
225
|
+
* @param {Object} event
|
226
|
+
* @param {Object} data
|
227
|
+
*/
|
228
|
+
publish: function( event, data ) {
|
229
|
+
//@steal-remove-start
|
230
|
+
steal.dev.log("Model.js - publishing " + underscore(this.shortName) + "." + event)
|
231
|
+
//@steal-remove-end
|
232
|
+
if ( window.OpenAjax ) {
|
233
|
+
OpenAjax.hub.publish(underscore(this.shortName) + "." + event, data);
|
234
|
+
}
|
235
|
+
|
236
|
+
},
|
237
|
+
/**
|
238
|
+
* Guesses at the type of an object. This is useful when you want to know more than just typeof.
|
239
|
+
* @param {Object} object the object you want to test.
|
240
|
+
* @return {String} one of string, object, date, array, boolean, number, function
|
241
|
+
*/
|
242
|
+
guessType: function( object ) {
|
243
|
+
if ( typeof object != 'string' ) {
|
244
|
+
if ( object == null ) return typeof object;
|
245
|
+
if ( object.constructor == Date ) return 'date';
|
246
|
+
if ( $.isArray(object) ) return 'array';
|
247
|
+
return typeof object;
|
248
|
+
}
|
249
|
+
if ( object == "" ) return 'string';
|
250
|
+
//check if true or false
|
251
|
+
if ( object == 'true' || object == 'false' ) return 'boolean';
|
252
|
+
if (!isNaN(object) ) return 'number'
|
253
|
+
return typeof object;
|
254
|
+
},
|
255
|
+
converters: {
|
256
|
+
"date": function( val ) {
|
257
|
+
return this._parseDate(val)
|
258
|
+
},
|
259
|
+
"number": function( val ) {
|
260
|
+
return parseFloat(val)
|
261
|
+
},
|
262
|
+
"boolean": function( val ) {
|
263
|
+
return Boolean(val)
|
264
|
+
}
|
265
|
+
},
|
266
|
+
findAll: function( params, success, error ) {},
|
267
|
+
findOne: function( id, params, success, error ) {},
|
268
|
+
/**
|
269
|
+
* Implement this function!
|
270
|
+
* Create is called by save to create a new instance. If you want to be able to call save on an instance
|
271
|
+
* you have to implement create.
|
272
|
+
*/
|
273
|
+
create: function( attrs, success, error ) {
|
274
|
+
throw "Model: Implement Create"
|
275
|
+
},
|
276
|
+
/**
|
277
|
+
* Implement this function!
|
278
|
+
* Update is called by save to update an instance. If you want to be able to call save on an instance
|
279
|
+
* you have to implement update.
|
280
|
+
*/
|
281
|
+
update: function( id, attrs, success, error ) {
|
282
|
+
throw "Model: Implement " + this.fullName + "'s \"update\"!"
|
283
|
+
},
|
284
|
+
/**
|
285
|
+
* Implement this function!
|
286
|
+
* Destroy is called by destroy to remove an instance. If you want to be able to call destroy on an instance
|
287
|
+
* you have to implement update.
|
288
|
+
* @param {String|Number} id the id of the instance you want destroyed
|
289
|
+
*/
|
290
|
+
destroy: function( id, success, error ) {
|
291
|
+
throw "Model: Implement " + this.fullName + "'s \"destroy\"!"
|
292
|
+
},
|
293
|
+
/**
|
294
|
+
* Turns a string into a date
|
295
|
+
* @param {String} str a string representation of a date
|
296
|
+
* @return {Date} a date
|
297
|
+
*/
|
298
|
+
_parseDate: function( str ) {
|
299
|
+
return typeof str == "string" ? (Date.parse(str) == NaN ? null : Date.parse(str)) : str
|
300
|
+
}
|
301
|
+
},
|
302
|
+
/**
|
303
|
+
* @Prototype
|
304
|
+
*/
|
305
|
+
{
|
306
|
+
/**
|
307
|
+
* Creates, but does not save a new instance of this class
|
308
|
+
* @param {Object} attributes a hash of attributes
|
309
|
+
*/
|
310
|
+
init: function( attributes ) {
|
311
|
+
this.Class.defaults && this.attrs(this.Class.defaults);
|
312
|
+
this.attrs(attributes);
|
313
|
+
/**
|
314
|
+
* @attribute errors
|
315
|
+
* A hash of errors for this model instance.
|
316
|
+
*/
|
317
|
+
this.errors = {};
|
318
|
+
},
|
319
|
+
/**
|
320
|
+
* Sets the attributes on this instance and calls save.
|
321
|
+
* @param {Object} attrs the model's attributes
|
322
|
+
* @param {Function} success
|
323
|
+
* @param {Function} error
|
324
|
+
*/
|
325
|
+
update: function( attrs, success, error ) {
|
326
|
+
this.attrs(attrs);
|
327
|
+
return this.save(success, error); //on success, we should
|
328
|
+
},
|
329
|
+
valid: function() {
|
330
|
+
for ( var attr in this.errors )
|
331
|
+
return false;
|
332
|
+
return true;
|
333
|
+
},
|
334
|
+
/**
|
335
|
+
* Validates this model instance (usually called by [jQuery.Model.prototype.save|save])
|
336
|
+
*/
|
337
|
+
validate: function() {
|
338
|
+
this.errors = {};
|
339
|
+
var self = this;
|
340
|
+
$.each(this.Class.validations || [], function( i, func ) {
|
341
|
+
func.call(self)
|
342
|
+
});
|
343
|
+
},
|
344
|
+
/**
|
345
|
+
* Gets or sets an attribute on the model.
|
346
|
+
* @param {String} attribute the attribute you want to set or get
|
347
|
+
* @param {String_Number_Boolean} [opt1] value the value you want to set.
|
348
|
+
*/
|
349
|
+
attr: function( attribute, value ) {
|
350
|
+
var cap = capitalize(attribute),
|
351
|
+
get = "get" + cap;
|
352
|
+
if ( value !== undefined ) this._setProperty(attribute, value, cap);
|
353
|
+
return this[get] ? this[get]() : this[attribute];
|
354
|
+
},
|
355
|
+
/**
|
356
|
+
* Checks if there is a set_<i>property</i> value. If it returns true, lets it handle; otherwise
|
357
|
+
* saves it.
|
358
|
+
* @hide
|
359
|
+
* @param {Object} property
|
360
|
+
* @param {Object} value
|
361
|
+
*/
|
362
|
+
_setProperty: function( property, value, capitalized ) {
|
363
|
+
var funcName = "set" + capitalized,
|
364
|
+
old = this[property],
|
365
|
+
Class = this.Class,
|
366
|
+
type = Class.attributes[property] || Class.addAttr(property, Class.guessType(value)),
|
367
|
+
converter = Class.converters[type],
|
368
|
+
val;
|
369
|
+
|
370
|
+
if ( this[funcName] && !(value = this[funcName](value)) ) return;
|
371
|
+
|
372
|
+
//convert to value
|
373
|
+
val = this[property] = value == null ? null : (converter ? converter.call(Class, value) : value)
|
374
|
+
|
375
|
+
|
376
|
+
if ( property == Class.id && val != null && Class.store ) {
|
377
|
+
if (!old ) {
|
378
|
+
Class.store.create(this);
|
379
|
+
} else if ( old != val ) {
|
380
|
+
Class.store.destroy(old);
|
381
|
+
Class.store.create(this);
|
382
|
+
}
|
383
|
+
}
|
384
|
+
},
|
385
|
+
/**
|
386
|
+
* Gets or sets a list of attributes
|
387
|
+
* @param {Object} [opt2] attributes if present, the list of attributes to send
|
388
|
+
* @return {Object} the curent attributes of the model
|
389
|
+
*/
|
390
|
+
attrs: function( attributes ) {
|
391
|
+
var key;
|
392
|
+
if (!attributes ) {
|
393
|
+
attributes = {};
|
394
|
+
for ( key in this.Class.attributes ) {
|
395
|
+
attributes[key] = this.attr(key);
|
396
|
+
}
|
397
|
+
} else {
|
398
|
+
var idName = this.Class.id;
|
399
|
+
for ( key in attributes ) {
|
400
|
+
if ( key != idName ) this.attr(key, attributes[key]);
|
401
|
+
}
|
402
|
+
if ( idName in attributes ) {
|
403
|
+
this.attr(idName, attributes[idName]);
|
404
|
+
}
|
405
|
+
|
406
|
+
}
|
407
|
+
return attributes;
|
408
|
+
},
|
409
|
+
/**
|
410
|
+
* Returns if the instance is a new object
|
411
|
+
*/
|
412
|
+
isNew: function() {
|
413
|
+
return this[this.Class.id] == null;
|
414
|
+
},
|
415
|
+
/**
|
416
|
+
* Saves the instance
|
417
|
+
* @param {Function} [opt3] callbacks onComplete function or object of callbacks
|
418
|
+
*/
|
419
|
+
save: function( success, error ) {
|
420
|
+
this.validate();
|
421
|
+
|
422
|
+
if (!this.valid() ) {
|
423
|
+
return false;
|
424
|
+
}
|
425
|
+
this.isNew() ? this.Class.create(this.attrs(), this.callback(['created', success]), error) : this.Class.update(this[this.Class.id], this.attrs(), this.callback(['updated', success]), error);
|
426
|
+
|
427
|
+
//this.is_new_record = this.Class.new_record_func;
|
428
|
+
return true;
|
429
|
+
},
|
430
|
+
|
431
|
+
/**
|
432
|
+
* Destroys the instance
|
433
|
+
* @param {Function} [opt4] callback or object of callbacks
|
434
|
+
*/
|
435
|
+
destroy: function( success, error ) {
|
436
|
+
this.Class.destroy(this[this.Class.id], this.callback(["destroyed", success]), error);
|
437
|
+
},
|
438
|
+
|
439
|
+
|
440
|
+
/**
|
441
|
+
* Returns a unique identifier for the model instance. For example:
|
442
|
+
* @codestart
|
443
|
+
* new Todo({id: 5}).identity() //-> 'todo_5'
|
444
|
+
* @codeend
|
445
|
+
* Typically this is used in an element's shortName property so you can find all elements
|
446
|
+
* for a model with [jQuery.Model.prototype.elements elements].
|
447
|
+
* @return {String}
|
448
|
+
*/
|
449
|
+
identity: function() {
|
450
|
+
var id = this[this.Class.id]
|
451
|
+
return this.Class._fullName + '_' + (this.Class.escapeIdentity ? encodeURIComponent(id) : id);
|
452
|
+
},
|
453
|
+
/**
|
454
|
+
* Returns elements that represent this model instance. For this to work, your element's should
|
455
|
+
* us the [jQuery.Model.prototype.identity identity] function in their class name. Example:
|
456
|
+
* @codestart html
|
457
|
+
* <div class='todo <%= todo.identity() %>'> ... </div>
|
458
|
+
* @codeend
|
459
|
+
* This function should only rarely be used. It breaks the architecture.
|
460
|
+
* @param {String|jQuery|element} context -
|
461
|
+
*/
|
462
|
+
elements: function( context ) {
|
463
|
+
return $("." + this.identity(), context);
|
464
|
+
},
|
465
|
+
/**
|
466
|
+
* Publishes to open ajax hub
|
467
|
+
* @param {String} event
|
468
|
+
* @param {Object} [opt6] data if missing, uses the instance in {data: this}
|
469
|
+
*/
|
470
|
+
publish: function( event, data ) {
|
471
|
+
this.Class.publish(event, data || this);
|
472
|
+
},
|
473
|
+
hookup: function( el ) {
|
474
|
+
var shortName = underscore(this.Class.shortName),
|
475
|
+
models = $.data(el, "models") || $.data(el, "models", {});
|
476
|
+
$(el).addClass(shortName + " " + this.identity())
|
477
|
+
models[shortName] = this;
|
478
|
+
}
|
479
|
+
});
|
480
|
+
|
481
|
+
$.each([
|
482
|
+
/**
|
483
|
+
* @function created
|
484
|
+
* Called by save after a new instance is created. Publishes 'created'.
|
485
|
+
* @param {Object} attrs
|
486
|
+
*/
|
487
|
+
"created",
|
488
|
+
/**
|
489
|
+
* @function destroyed
|
490
|
+
* Called by save after an instance is updated. Publishes 'updated'.
|
491
|
+
* @param {Object} attrs
|
492
|
+
*/
|
493
|
+
"updated",
|
494
|
+
/**
|
495
|
+
* @function destroyed
|
496
|
+
* Called after an instance is destroyed. Publishes
|
497
|
+
* "shortName.destroyed"
|
498
|
+
*/
|
499
|
+
"destroyed"], function( i, funcName ) {
|
500
|
+
$.Model.prototype[funcName] = function( attrs ) {
|
501
|
+
if ( funcName === 'destroyed' && this.Class.store ) {
|
502
|
+
this.Class.store.destroy(this[this.Class.id]);
|
503
|
+
}
|
504
|
+
attrs && typeof attrs == 'object' && this.attrs(attrs.attrs ? attrs.attrs() : attrs);
|
505
|
+
this.publish(funcName, this)
|
506
|
+
return [this].concat($.makeArray(arguments));
|
507
|
+
}
|
508
|
+
})
|
509
|
+
|
510
|
+
/**
|
511
|
+
* @add jQuery.fn
|
512
|
+
*/
|
513
|
+
// break
|
514
|
+
/**
|
515
|
+
* @function models
|
516
|
+
* @param {jQuery.Model} model if present only returns models of the provided type.
|
517
|
+
* @return {Array} returns an array of model instances that are represented by the contained elements.
|
518
|
+
*/
|
519
|
+
$.fn.models = function( type ) {
|
520
|
+
//get it from the data
|
521
|
+
var collection = [],
|
522
|
+
kind, ret;
|
523
|
+
this.each(function() {
|
524
|
+
$.each($.data(this, "models") || {}, function( name, instance ) {
|
525
|
+
//either null or the list type shared by all classes
|
526
|
+
kind = kind === undefined ? instance.Class.List || null : (instance.Class.List === kind ? kind : null)
|
527
|
+
collection.push(instance)
|
528
|
+
})
|
529
|
+
});
|
530
|
+
ret = new(kind || $.Model.list || Array)()
|
531
|
+
ret.push.apply(ret, $.unique(collection))
|
532
|
+
return ret;
|
533
|
+
}
|
534
|
+
$.fn.model = function() {
|
535
|
+
return this.models.apply(this, arguments)[0];
|
536
|
+
}
|
537
|
+
});
|