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
@@ -0,0 +1,17 @@
|
|
1
|
+
steal(function(steal){
|
2
|
+
var comments = /\/\*.*?\*\//g,
|
3
|
+
newLines = /\n*/g,
|
4
|
+
space = /[ ]+/g,
|
5
|
+
spaceChars = /\s?([;:{},+>])\s?/g,
|
6
|
+
lastSemi = /;}/g;
|
7
|
+
|
8
|
+
|
9
|
+
steal.cssMin = function(css){
|
10
|
+
//remove comments
|
11
|
+
return css .replace(comments,"")
|
12
|
+
.replace(newLines,"")
|
13
|
+
.replace(space," ")
|
14
|
+
.replace(spaceChars,'$1')
|
15
|
+
.replace(lastSemi,'}')
|
16
|
+
}
|
17
|
+
})
|
@@ -0,0 +1,84 @@
|
|
1
|
+
steal(function(steal){
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Builds and compresses CSS files.
|
5
|
+
* @param {Object} opener
|
6
|
+
* @param {Object} options
|
7
|
+
*/
|
8
|
+
var styles = (steal.build.builders.styles = function(opener, options){
|
9
|
+
print("\nBUILDING STYLES --------------- ");
|
10
|
+
//where we are putting stuff
|
11
|
+
var folder = options.to.substr(0, options.to.length -1),
|
12
|
+
//where the page is
|
13
|
+
pageFolder = steal.File(opener.url).dir(),
|
14
|
+
currentPackage = [];
|
15
|
+
|
16
|
+
opener.each('link',function(link, text, i){
|
17
|
+
print(link.type)
|
18
|
+
//let people know we are adding it
|
19
|
+
if(link.href && steal.build.types[link.type]){
|
20
|
+
print(link.href)
|
21
|
+
|
22
|
+
var loc = steal.File(pageFolder).join(link.href),
|
23
|
+
converted = convert(text, loc, folder)
|
24
|
+
|
25
|
+
|
26
|
+
currentPackage.push( steal.cssMin(converted) )
|
27
|
+
|
28
|
+
}
|
29
|
+
|
30
|
+
});
|
31
|
+
print("")
|
32
|
+
if(currentPackage.length){
|
33
|
+
print("STYLE BUNDLE > "+folder+"/production.css\n")
|
34
|
+
steal.File(folder+"/production.css").save(currentPackage.join(''));
|
35
|
+
}else{
|
36
|
+
print("no styles\n")
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
});
|
42
|
+
//used to convert css referencs in one file so they will make sense from prodLocation
|
43
|
+
var convert = function(css, cssLocation, prodLocation){
|
44
|
+
//how do we go from prod to css
|
45
|
+
|
46
|
+
var cssLoc = new steal.File(cssLocation).dir(),
|
47
|
+
newCSss = css.replace(/url\(([^\)]*)\)/g, function(whole, part){
|
48
|
+
|
49
|
+
//check if url is relative
|
50
|
+
if(! isRelative(part) ) {
|
51
|
+
return whole
|
52
|
+
}
|
53
|
+
|
54
|
+
//it's a relative path from cssLocation, need to convert to
|
55
|
+
// prodLocation
|
56
|
+
var imagePath = steal.File(part).joinFrom( cssLoc),
|
57
|
+
fin = steal.File(imagePath).toReferenceFromSameDomain(prodLocation);
|
58
|
+
//print(" -> "+imagePath);
|
59
|
+
print(" "+part+" > "+fin);
|
60
|
+
return "url("+fin+")";
|
61
|
+
});
|
62
|
+
return newCSss;
|
63
|
+
},
|
64
|
+
isRelative = function(part){
|
65
|
+
return !/^(http:\/\/|https:\/\/|\/\.\/|\.\.\/)/.test(part)
|
66
|
+
}
|
67
|
+
|
68
|
+
var comments = /\/\*.*?\*\//g,
|
69
|
+
newLines = /\n*/g,
|
70
|
+
space = /[ ]+/g,
|
71
|
+
spaceChars = /\s?([;:{},+>])\s?/g,
|
72
|
+
lastSemi = /;}/g;
|
73
|
+
|
74
|
+
|
75
|
+
steal.cssMin = function(css){
|
76
|
+
//remove comments
|
77
|
+
return css .replace(comments,"")
|
78
|
+
.replace(newLines,"")
|
79
|
+
.replace(space," ")
|
80
|
+
.replace(spaceChars,'$1')
|
81
|
+
.replace(lastSemi,'}')
|
82
|
+
}
|
83
|
+
|
84
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
BasicSource=5;(function(hereIsAVeryLongName){hereIsAVeryLongName++;BasicSource=hereIsAVeryLongName})(BasicSource);
|
@@ -0,0 +1 @@
|
|
1
|
+
.background1 { background-image: url(justin.png) }
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
.background1{background-image:url(css/justin.png)}.background2{background-image:url(upload.PNG)}
|
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
removeRemoveSteal = function(text){
|
2
|
+
return String(java.lang.String(text)
|
3
|
+
.replaceAll("(?s)\/\/@steal-remove-start(.*?)\/\/@steal-remove-end","")
|
4
|
+
.replaceAll("steal[\n\s\r]*\.[\n\s\r]*dev[\n\s\r]*\.[\n\s\r]*(\w+)[\n\s\r]*\([^\)]*\)",""))
|
5
|
+
}
|
6
|
+
//@steal-remove-start
|
7
|
+
print( removeRemoveSteal(readFile("steal/compress/test/removecode.js")) )
|
8
|
+
//@steal-remove-end
|
9
|
+
steal = {dev : {log: function(){},isHappyName: function(){}}}
|
10
|
+
steal.dev.log()
|
11
|
+
var foo = bar;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
// load('steal/compress/test/run.js')
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Tests compressing a very basic page and one that is using steal
|
5
|
+
*/
|
6
|
+
load('steal/rhino/steal.js')
|
7
|
+
steal('//steal/test/test', function(s){
|
8
|
+
|
9
|
+
//lets see if we can clear everything
|
10
|
+
s.test.clear();
|
11
|
+
|
12
|
+
load('steal/rhino/steal.js')
|
13
|
+
steal("//steal/compress/compress")
|
14
|
+
|
15
|
+
steal.compress("steal/compress/test/basicpage.html",{
|
16
|
+
output : 'steal/compress/test'
|
17
|
+
})
|
18
|
+
|
19
|
+
s.test.clear();
|
20
|
+
|
21
|
+
load("steal/compress/test/basicproduction.js")
|
22
|
+
s.test.equals(BasicSource, 6, "Basic source not right number")
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
});
|
27
|
+
/*
|
28
|
+
_S.clear();
|
29
|
+
_S.remove('steal/compress/test/basicproduction.js')
|
30
|
+
|
31
|
+
print("-- Compress page using steal --");
|
32
|
+
load("steal/compress/compress.js")
|
33
|
+
new steal.Compress(['steal/compress/test/stealpage.html','steal/compress/test']);
|
34
|
+
_S.clear();
|
35
|
+
|
36
|
+
_S.open('steal/compress/test/stealprodpage.html')
|
37
|
+
_S.equals(BasicSource, 7, "Basic source not right number")
|
38
|
+
_S.clear();
|
39
|
+
|
40
|
+
_S.remove('steal/compress/test/production.js')
|
41
|
+
|
42
|
+
print("-- Compress page with foreign characters --");
|
43
|
+
load("steal/compress/compress.js");
|
44
|
+
new steal.Compress(['steal/compress/test/foreign.html','steal/compress/test']);
|
45
|
+
_S.clear();
|
46
|
+
|
47
|
+
//load("steal/compress/test/foreignproduction.js")
|
48
|
+
//check that srcs are equal
|
49
|
+
f1 = readFile('foreign.js').replace(/\r/,"");
|
50
|
+
f2 = readFile('foreignproduction.js');
|
51
|
+
if(f1 != f2){
|
52
|
+
print(f1+"\n---------------------------\n"+f2);
|
53
|
+
throw "Foreign characters aren't right";
|
54
|
+
}
|
55
|
+
|
56
|
+
_S.clear();
|
57
|
+
_S.remove('steal/compress/test/foreignproduction.js')*/
|
@@ -0,0 +1,21 @@
|
|
1
|
+
load("steal/rhino/steal.js");
|
2
|
+
steal.plugins('steal/build','steal/build/scripts','steal/build/styles','steal/build/apps',function(){
|
3
|
+
//check if args
|
4
|
+
var urls = [];
|
5
|
+
while(_args.length){
|
6
|
+
if( _args[0].indexOf('-') != 0 ) {
|
7
|
+
urls.push(_args.shift())
|
8
|
+
}else{
|
9
|
+
break;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
if(urls.length > 1){
|
16
|
+
steal.build.apps(urls)
|
17
|
+
}else{
|
18
|
+
steal.build(urls[0],_args)
|
19
|
+
}
|
20
|
+
|
21
|
+
})
|
@@ -0,0 +1,1108 @@
|
|
1
|
+
/*jslint onevar: false, plusplus: false */
|
2
|
+
/*
|
3
|
+
|
4
|
+
JS Beautifier
|
5
|
+
---------------
|
6
|
+
|
7
|
+
|
8
|
+
Written by Einar Lielmanis, <einar@jsbeautifier.org>
|
9
|
+
http://jsbeautifier.org/
|
10
|
+
|
11
|
+
Originally converted to javascript by Vital, <vital76@gmail.com>
|
12
|
+
|
13
|
+
You are free to use this in any way you want, in case you find this useful or working for you.
|
14
|
+
|
15
|
+
Usage:
|
16
|
+
js_beautify(js_source_text);
|
17
|
+
js_beautify(js_source_text, options);
|
18
|
+
|
19
|
+
The options are:
|
20
|
+
indent_size (default 4) — indentation size,
|
21
|
+
indent_char (default space) — character to indent with,
|
22
|
+
preserve_newlines (default true) — whether existing line breaks should be preserved,
|
23
|
+
indent_level (default 0) — initial indentation level, you probably won't need this ever,
|
24
|
+
|
25
|
+
space_after_anon_function (default false) — if true, then space is added between "function ()"
|
26
|
+
(jslint is happy about this); if false, then the common "function()" output is used.
|
27
|
+
braces_on_own_line (default false) - ANSI / Allman brace style, each opening/closing brace gets its own line.
|
28
|
+
|
29
|
+
e.g
|
30
|
+
|
31
|
+
js_beautify(js_source_text, {indent_size: 1, indent_char: '\t'});
|
32
|
+
|
33
|
+
|
34
|
+
*/
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
function js_beautify(js_source_text, options) {
|
39
|
+
|
40
|
+
var input, output, token_text, last_type, last_text, last_last_text, last_word, flags, flag_store, indent_string;
|
41
|
+
var whitespace, wordchar, punct, parser_pos, line_starters, digits;
|
42
|
+
var prefix, token_type, do_block_just_closed, in_statement_expression = false, expression_has_word = false;
|
43
|
+
var wanted_newline, just_added_newline, n_newlines;
|
44
|
+
var paren_count = 0, paren_spots = {};
|
45
|
+
|
46
|
+
|
47
|
+
// Some interpreters have unexpected results with foo = baz || bar;
|
48
|
+
options = options ? options : {};
|
49
|
+
var opt_braces_on_own_line = options.braces_on_own_line ? options.braces_on_own_line : false;
|
50
|
+
var opt_indent_size = options.indent_size ? options.indent_size : 4;
|
51
|
+
var opt_indent_char = options.indent_char ? options.indent_char : ' ';
|
52
|
+
var opt_preserve_newlines = typeof options.preserve_newlines === 'undefined' ? true : options.preserve_newlines;
|
53
|
+
var opt_indent_level = options.indent_level ? options.indent_level : 0; // starting indentation
|
54
|
+
var opt_space_after_anon_function = options.space_after_anon_function === 'undefined' ? false : options.space_after_anon_function;
|
55
|
+
var opt_keep_array_indentation = typeof options.keep_array_indentation === 'undefined' ? false : options.keep_array_indentation;
|
56
|
+
var opt_space_statement_expression = typeof options.space_statement_expression === 'undefined' ? false : options.space_statement_expression;
|
57
|
+
|
58
|
+
just_added_newline = false;
|
59
|
+
|
60
|
+
// cache the source's length.
|
61
|
+
var input_length = js_source_text.length;
|
62
|
+
|
63
|
+
function trim_output() {
|
64
|
+
while (output.length && (output[output.length - 1] === ' ' || output[output.length - 1] === indent_string)) {
|
65
|
+
output.pop();
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
function is_array(mode) {
|
70
|
+
return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]';
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
function print_newline(ignore_repeated) {
|
75
|
+
|
76
|
+
flags.eat_next_space = false;
|
77
|
+
if (opt_keep_array_indentation && is_array(flags.mode)) {
|
78
|
+
return;
|
79
|
+
}
|
80
|
+
|
81
|
+
ignore_repeated = typeof ignore_repeated === 'undefined' ? true : ignore_repeated;
|
82
|
+
|
83
|
+
flags.if_line = false;
|
84
|
+
trim_output();
|
85
|
+
|
86
|
+
if (!output.length) {
|
87
|
+
return; // no newline on start of file
|
88
|
+
}
|
89
|
+
|
90
|
+
if (output[output.length - 1] !== "\n" || !ignore_repeated) {
|
91
|
+
just_added_newline = true;
|
92
|
+
output.push("\n");
|
93
|
+
}
|
94
|
+
for (var i = 0; i < flags.indentation_level; i += 1) {
|
95
|
+
output.push(indent_string);
|
96
|
+
}
|
97
|
+
if (flags.var_line && flags.var_line_reindented) {
|
98
|
+
if (opt_indent_char === ' ') {
|
99
|
+
output.push(' '); // var_line always pushes 4 spaces, so that the variables would be one under another
|
100
|
+
} else {
|
101
|
+
output.push(indent_string); // skip space-stuffing, if indenting with a tab
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
function print_single_space() {
|
109
|
+
if (flags.eat_next_space) {
|
110
|
+
flags.eat_next_space = false;
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
var last_output = ' ';
|
114
|
+
if (output.length) {
|
115
|
+
last_output = output[output.length - 1];
|
116
|
+
}
|
117
|
+
if (last_output !== ' ' && last_output !== '\n' && last_output !== indent_string) { // prevent occassional duplicate space
|
118
|
+
output.push(' ');
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
|
123
|
+
function print_token() {
|
124
|
+
just_added_newline = false;
|
125
|
+
flags.eat_next_space = false;
|
126
|
+
output.push(token_text);
|
127
|
+
}
|
128
|
+
|
129
|
+
function indent() {
|
130
|
+
flags.indentation_level += 1;
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
function remove_indent() {
|
135
|
+
if (output.length && output[output.length - 1] === indent_string) {
|
136
|
+
output.pop();
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
function set_mode(mode) {
|
141
|
+
if (flags) {
|
142
|
+
flag_store.push(flags);
|
143
|
+
}
|
144
|
+
flags = {
|
145
|
+
previous_mode: flags ? flags.mode : 'BLOCK',
|
146
|
+
mode: mode,
|
147
|
+
var_line: false,
|
148
|
+
var_line_tainted: false,
|
149
|
+
var_line_reindented: false,
|
150
|
+
in_html_comment: false,
|
151
|
+
if_line: false,
|
152
|
+
in_case: false,
|
153
|
+
eat_next_space: false,
|
154
|
+
indentation_baseline: -1,
|
155
|
+
indentation_level: (flags ? flags.indentation_level + ((flags.var_line && flags.var_line_reindented) ? 1 : 0) : opt_indent_level)
|
156
|
+
};
|
157
|
+
}
|
158
|
+
|
159
|
+
function is_array(mode) {
|
160
|
+
return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]';
|
161
|
+
}
|
162
|
+
|
163
|
+
function is_expression(mode) {
|
164
|
+
return mode === '[EXPRESSION]' || mode === '[INDENTED-EXPRESSION]' || mode === '(EXPRESSION)';
|
165
|
+
}
|
166
|
+
|
167
|
+
function restore_mode() {
|
168
|
+
do_block_just_closed = flags.mode === 'DO_BLOCK';
|
169
|
+
if (flag_store.length > 0) {
|
170
|
+
flags = flag_store.pop();
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
|
175
|
+
function in_array(what, arr) {
|
176
|
+
for (var i = 0; i < arr.length; i += 1) {
|
177
|
+
if (arr[i] === what) {
|
178
|
+
return true;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
return false;
|
182
|
+
}
|
183
|
+
|
184
|
+
// Walk backwards from the colon to find a '?' (colon is part of a ternary op)
|
185
|
+
// or a '{' (colon is part of a class literal). Along the way, keep track of
|
186
|
+
// the blocks and expressions we pass so we only trigger on those chars in our
|
187
|
+
// own level, and keep track of the colons so we only trigger on the matching '?'.
|
188
|
+
|
189
|
+
|
190
|
+
function is_ternary_op() {
|
191
|
+
var level = 0,
|
192
|
+
colon_count = 0;
|
193
|
+
for (var i = output.length - 1; i >= 0; i--) {
|
194
|
+
switch (output[i]) {
|
195
|
+
case ':':
|
196
|
+
if (level === 0) {
|
197
|
+
colon_count++;
|
198
|
+
}
|
199
|
+
break;
|
200
|
+
case '?':
|
201
|
+
if (level === 0) {
|
202
|
+
if (colon_count === 0) {
|
203
|
+
return true;
|
204
|
+
} else {
|
205
|
+
colon_count--;
|
206
|
+
}
|
207
|
+
}
|
208
|
+
break;
|
209
|
+
case '{':
|
210
|
+
if (level === 0) {
|
211
|
+
return false;
|
212
|
+
}
|
213
|
+
level--;
|
214
|
+
break;
|
215
|
+
case '(':
|
216
|
+
case '[':
|
217
|
+
level--;
|
218
|
+
break;
|
219
|
+
case ')':
|
220
|
+
case ']':
|
221
|
+
case '}':
|
222
|
+
level++;
|
223
|
+
break;
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
function get_next_token() {
|
229
|
+
n_newlines = 0;
|
230
|
+
|
231
|
+
if (parser_pos >= input_length) {
|
232
|
+
return ['', 'TK_EOF'];
|
233
|
+
}
|
234
|
+
|
235
|
+
wanted_newline = false;
|
236
|
+
|
237
|
+
var c = input.charAt(parser_pos);
|
238
|
+
parser_pos += 1;
|
239
|
+
|
240
|
+
|
241
|
+
var keep_whitespace = opt_keep_array_indentation && is_array(flags.mode);
|
242
|
+
|
243
|
+
if (keep_whitespace) {
|
244
|
+
|
245
|
+
//
|
246
|
+
// slight mess to allow nice preservation of array indentation and reindent that correctly
|
247
|
+
// first time when we get to the arrays:
|
248
|
+
// var a = [
|
249
|
+
// ....'something'
|
250
|
+
// we make note of whitespace_count = 4 into flags.indentation_baseline
|
251
|
+
// so we know that 4 whitespaces in original source match indent_level of reindented source
|
252
|
+
//
|
253
|
+
// and afterwards, when we get to
|
254
|
+
// 'something,
|
255
|
+
// .......'something else'
|
256
|
+
// we know that this should be indented to indent_level + (7 - indentation_baseline) spaces
|
257
|
+
//
|
258
|
+
var whitespace_count = 0;
|
259
|
+
|
260
|
+
while (in_array(c, whitespace)) {
|
261
|
+
|
262
|
+
if (c === "\n") {
|
263
|
+
trim_output();
|
264
|
+
output.push("\n");
|
265
|
+
just_added_newline = true;
|
266
|
+
whitespace_count = 0;
|
267
|
+
} else {
|
268
|
+
if (c === '\t') {
|
269
|
+
whitespace_count += 4;
|
270
|
+
} else {
|
271
|
+
whitespace_count += 1;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
if (parser_pos >= input_length) {
|
276
|
+
return ['', 'TK_EOF'];
|
277
|
+
}
|
278
|
+
|
279
|
+
c = input.charAt(parser_pos);
|
280
|
+
parser_pos += 1;
|
281
|
+
|
282
|
+
}
|
283
|
+
if (flags.indentation_baseline === -1) {
|
284
|
+
flags.indentation_baseline = whitespace_count;
|
285
|
+
}
|
286
|
+
|
287
|
+
if (just_added_newline) {
|
288
|
+
var i;
|
289
|
+
for (i = 0; i < flags.indentation_level + 1; i += 1) {
|
290
|
+
output.push(indent_string);
|
291
|
+
}
|
292
|
+
if (flags.indentation_baseline !== -1) {
|
293
|
+
for (i = 0; i < whitespace_count - flags.indentation_baseline; i++) {
|
294
|
+
output.push(' ');
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}
|
298
|
+
|
299
|
+
} else {
|
300
|
+
while (in_array(c, whitespace)) {
|
301
|
+
|
302
|
+
if (c === "\n") {
|
303
|
+
n_newlines += 1;
|
304
|
+
}
|
305
|
+
|
306
|
+
|
307
|
+
if (parser_pos >= input_length) {
|
308
|
+
return ['', 'TK_EOF'];
|
309
|
+
}
|
310
|
+
|
311
|
+
c = input.charAt(parser_pos);
|
312
|
+
parser_pos += 1;
|
313
|
+
|
314
|
+
}
|
315
|
+
|
316
|
+
if (opt_preserve_newlines) {
|
317
|
+
if (n_newlines > 1) {
|
318
|
+
for (i = 0; i < n_newlines; i += 1) {
|
319
|
+
print_newline(i === 0);
|
320
|
+
just_added_newline = true;
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
wanted_newline = n_newlines > 0;
|
325
|
+
}
|
326
|
+
|
327
|
+
|
328
|
+
if (in_array(c, wordchar)) {
|
329
|
+
if (parser_pos < input_length) {
|
330
|
+
while (in_array(input.charAt(parser_pos), wordchar)) {
|
331
|
+
c += input.charAt(parser_pos);
|
332
|
+
parser_pos += 1;
|
333
|
+
if (parser_pos === input_length) {
|
334
|
+
break;
|
335
|
+
}
|
336
|
+
}
|
337
|
+
}
|
338
|
+
|
339
|
+
// small and surprisingly unugly hack for 1E-10 representation
|
340
|
+
if (parser_pos !== input_length && c.match(/^[0-9]+[Ee]$/) && (input.charAt(parser_pos) === '-' || input.charAt(parser_pos) === '+')) {
|
341
|
+
|
342
|
+
var sign = input.charAt(parser_pos);
|
343
|
+
parser_pos += 1;
|
344
|
+
|
345
|
+
var t = get_next_token(parser_pos);
|
346
|
+
c += sign + t[0];
|
347
|
+
return [c, 'TK_WORD'];
|
348
|
+
}
|
349
|
+
|
350
|
+
if (c === 'in') { // hack for 'in' operator
|
351
|
+
return [c, 'TK_OPERATOR'];
|
352
|
+
}
|
353
|
+
if (wanted_newline && last_type !== 'TK_OPERATOR' && !flags.if_line && (opt_preserve_newlines || last_text !== 'var')) {
|
354
|
+
print_newline();
|
355
|
+
}
|
356
|
+
return [c, 'TK_WORD'];
|
357
|
+
}
|
358
|
+
|
359
|
+
if (c === '(' || c === '[') {
|
360
|
+
return [c, 'TK_START_EXPR'];
|
361
|
+
}
|
362
|
+
|
363
|
+
if (c === ')' || c === ']') {
|
364
|
+
return [c, 'TK_END_EXPR'];
|
365
|
+
}
|
366
|
+
|
367
|
+
if (c === '{') {
|
368
|
+
return [c, 'TK_START_BLOCK'];
|
369
|
+
}
|
370
|
+
|
371
|
+
if (c === '}') {
|
372
|
+
return [c, 'TK_END_BLOCK'];
|
373
|
+
}
|
374
|
+
|
375
|
+
if (c === ';') {
|
376
|
+
return [c, 'TK_SEMICOLON'];
|
377
|
+
}
|
378
|
+
|
379
|
+
if (c === '/') {
|
380
|
+
var comment = '';
|
381
|
+
// peek for comment /* ... */
|
382
|
+
var inline_comment = true;
|
383
|
+
if (input.charAt(parser_pos) === '*') {
|
384
|
+
parser_pos += 1;
|
385
|
+
if (parser_pos < input_length) {
|
386
|
+
while (! (input.charAt(parser_pos) === '*' && input.charAt(parser_pos + 1) && input.charAt(parser_pos + 1) === '/') && parser_pos < input_length) {
|
387
|
+
c = input.charAt(parser_pos);
|
388
|
+
comment += c;
|
389
|
+
if (c === '\x0d' || c === '\x0a') {
|
390
|
+
inline_comment = false;
|
391
|
+
}
|
392
|
+
parser_pos += 1;
|
393
|
+
if (parser_pos >= input_length) {
|
394
|
+
break;
|
395
|
+
}
|
396
|
+
}
|
397
|
+
}
|
398
|
+
parser_pos += 2;
|
399
|
+
if (inline_comment) {
|
400
|
+
return ['/*' + comment + '*/', 'TK_INLINE_COMMENT'];
|
401
|
+
} else {
|
402
|
+
return ['/*' + comment + '*/', 'TK_BLOCK_COMMENT'];
|
403
|
+
}
|
404
|
+
}
|
405
|
+
// peek for comment // ...
|
406
|
+
if (input.charAt(parser_pos) === '/') {
|
407
|
+
comment = c;
|
408
|
+
while (input.charAt(parser_pos) !== "\x0d" && input.charAt(parser_pos) !== "\x0a") {
|
409
|
+
comment += input.charAt(parser_pos);
|
410
|
+
parser_pos += 1;
|
411
|
+
if (parser_pos >= input_length) {
|
412
|
+
break;
|
413
|
+
}
|
414
|
+
}
|
415
|
+
parser_pos += 1;
|
416
|
+
if (wanted_newline) {
|
417
|
+
print_newline();
|
418
|
+
}
|
419
|
+
return [comment, 'TK_COMMENT'];
|
420
|
+
}
|
421
|
+
|
422
|
+
}
|
423
|
+
|
424
|
+
if (c === "'" || // string
|
425
|
+
c === '"' || // string
|
426
|
+
(c === '/' && ((last_type === 'TK_WORD' && in_array(last_text, ['return', 'do'])) || (last_type === 'TK_START_EXPR' || last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_OPERATOR' || last_type === 'TK_EQUALS' || last_type === 'TK_EOF' || last_type === 'TK_SEMICOLON')))) { // regexp
|
427
|
+
var sep = c;
|
428
|
+
var esc = false;
|
429
|
+
var resulting_string = c;
|
430
|
+
|
431
|
+
if (parser_pos < input_length) {
|
432
|
+
if (sep === '/') {
|
433
|
+
//
|
434
|
+
// handle regexp separately...
|
435
|
+
//
|
436
|
+
var in_char_class = false;
|
437
|
+
while (esc || in_char_class || input.charAt(parser_pos) !== sep) {
|
438
|
+
resulting_string += input.charAt(parser_pos);
|
439
|
+
if (!esc) {
|
440
|
+
esc = input.charAt(parser_pos) === '\\';
|
441
|
+
if (input.charAt(parser_pos) === '[') {
|
442
|
+
in_char_class = true;
|
443
|
+
} else if (input.charAt(parser_pos) === ']') {
|
444
|
+
in_char_class = false;
|
445
|
+
}
|
446
|
+
} else {
|
447
|
+
esc = false;
|
448
|
+
}
|
449
|
+
parser_pos += 1;
|
450
|
+
if (parser_pos >= input_length) {
|
451
|
+
// incomplete string/rexp when end-of-file reached.
|
452
|
+
// bail out with what had been received so far.
|
453
|
+
return [resulting_string, 'TK_STRING'];
|
454
|
+
}
|
455
|
+
}
|
456
|
+
|
457
|
+
} else {
|
458
|
+
//
|
459
|
+
// and handle string also separately
|
460
|
+
//
|
461
|
+
while (esc || input.charAt(parser_pos) !== sep) {
|
462
|
+
resulting_string += input.charAt(parser_pos);
|
463
|
+
if (!esc) {
|
464
|
+
esc = input.charAt(parser_pos) === '\\';
|
465
|
+
} else {
|
466
|
+
esc = false;
|
467
|
+
}
|
468
|
+
parser_pos += 1;
|
469
|
+
if (parser_pos >= input_length) {
|
470
|
+
// incomplete string/rexp when end-of-file reached.
|
471
|
+
// bail out with what had been received so far.
|
472
|
+
return [resulting_string, 'TK_STRING'];
|
473
|
+
}
|
474
|
+
}
|
475
|
+
}
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
}
|
480
|
+
|
481
|
+
parser_pos += 1;
|
482
|
+
|
483
|
+
resulting_string += sep;
|
484
|
+
|
485
|
+
if (sep === '/') {
|
486
|
+
// regexps may have modifiers /regexp/MOD , so fetch those, too
|
487
|
+
while (parser_pos < input_length && in_array(input.charAt(parser_pos), wordchar)) {
|
488
|
+
resulting_string += input.charAt(parser_pos);
|
489
|
+
parser_pos += 1;
|
490
|
+
}
|
491
|
+
}
|
492
|
+
return [resulting_string, 'TK_STRING'];
|
493
|
+
}
|
494
|
+
|
495
|
+
if (c === '#') {
|
496
|
+
// Spidermonkey-specific sharp variables for circular references
|
497
|
+
// https://developer.mozilla.org/En/Sharp_variables_in_JavaScript
|
498
|
+
// http://mxr.mozilla.org/mozilla-central/source/js/src/jsscan.cpp around line 1935
|
499
|
+
var sharp = '#';
|
500
|
+
if (parser_pos < input_length && in_array(input.charAt(parser_pos), digits)) {
|
501
|
+
do {
|
502
|
+
c = input.charAt(parser_pos);
|
503
|
+
sharp += c;
|
504
|
+
parser_pos += 1;
|
505
|
+
} while (parser_pos < input_length && c !== '#' && c !== '=');
|
506
|
+
if (c === '#') {
|
507
|
+
//
|
508
|
+
} else if (input.charAt(parser_pos) === '[' && input.charAt(parser_pos + 1) === ']') {
|
509
|
+
sharp += '[]';
|
510
|
+
parser_pos += 2;
|
511
|
+
} else if (input.charAt(parser_pos) === '{' && input.charAt(parser_pos + 1) === '}') {
|
512
|
+
sharp += '{}';
|
513
|
+
parser_pos += 2;
|
514
|
+
}
|
515
|
+
return [sharp, 'TK_WORD'];
|
516
|
+
}
|
517
|
+
}
|
518
|
+
|
519
|
+
if (c === '<' && input.substring(parser_pos - 1, parser_pos + 3) === '<!--') {
|
520
|
+
parser_pos += 3;
|
521
|
+
flags.in_html_comment = true;
|
522
|
+
return ['<!--', 'TK_COMMENT'];
|
523
|
+
}
|
524
|
+
|
525
|
+
if (c === '-' && flags.in_html_comment && input.substring(parser_pos - 1, parser_pos + 2) === '-->') {
|
526
|
+
flags.in_html_comment = false;
|
527
|
+
parser_pos += 2;
|
528
|
+
if (wanted_newline) {
|
529
|
+
print_newline();
|
530
|
+
}
|
531
|
+
return ['-->', 'TK_COMMENT'];
|
532
|
+
}
|
533
|
+
|
534
|
+
if (in_array(c, punct)) {
|
535
|
+
while (parser_pos < input_length && in_array(c + input.charAt(parser_pos), punct)) {
|
536
|
+
c += input.charAt(parser_pos);
|
537
|
+
parser_pos += 1;
|
538
|
+
if (parser_pos >= input_length) {
|
539
|
+
break;
|
540
|
+
}
|
541
|
+
}
|
542
|
+
|
543
|
+
if (c === '=') {
|
544
|
+
return [c, 'TK_EQUALS'];
|
545
|
+
} else {
|
546
|
+
return [c, 'TK_OPERATOR'];
|
547
|
+
}
|
548
|
+
}
|
549
|
+
|
550
|
+
return [c, 'TK_UNKNOWN'];
|
551
|
+
}
|
552
|
+
|
553
|
+
//----------------------------------
|
554
|
+
indent_string = '';
|
555
|
+
while (opt_indent_size > 0) {
|
556
|
+
indent_string += opt_indent_char;
|
557
|
+
opt_indent_size -= 1;
|
558
|
+
}
|
559
|
+
|
560
|
+
input = js_source_text;
|
561
|
+
|
562
|
+
last_word = ''; // last 'TK_WORD' passed
|
563
|
+
last_type = 'TK_START_EXPR'; // last token type
|
564
|
+
last_text = ''; // last token text
|
565
|
+
last_last_text = ''; // pre-last token text
|
566
|
+
output = [];
|
567
|
+
|
568
|
+
do_block_just_closed = false;
|
569
|
+
|
570
|
+
whitespace = "\n\r\t ".split('');
|
571
|
+
wordchar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'.split('');
|
572
|
+
digits = '0123456789'.split('');
|
573
|
+
|
574
|
+
punct = '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::'.split(' ');
|
575
|
+
|
576
|
+
// words which should always start on new line.
|
577
|
+
line_starters = 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(',');
|
578
|
+
|
579
|
+
// states showing if we are currently in expression (i.e. "if" case) - 'EXPRESSION', or in usual block (like, procedure), 'BLOCK'.
|
580
|
+
// some formatting depends on that.
|
581
|
+
flag_store = [];
|
582
|
+
set_mode('BLOCK');
|
583
|
+
|
584
|
+
parser_pos = 0;
|
585
|
+
while (true) {
|
586
|
+
var t = get_next_token(parser_pos);
|
587
|
+
token_text = t[0];
|
588
|
+
token_type = t[1];
|
589
|
+
if (token_type === 'TK_EOF') {
|
590
|
+
break;
|
591
|
+
}
|
592
|
+
|
593
|
+
//print(token_text+" = "+token_type);
|
594
|
+
switch (token_type) {
|
595
|
+
|
596
|
+
case 'TK_START_EXPR':
|
597
|
+
|
598
|
+
if (token_text === '[') {
|
599
|
+
|
600
|
+
if (last_type === 'TK_WORD' || last_text === ')') {
|
601
|
+
// this is array index specifier, break immediately
|
602
|
+
// a[x], fn()[x]
|
603
|
+
if (in_array(last_text, line_starters)) {
|
604
|
+
print_single_space();
|
605
|
+
}
|
606
|
+
set_mode('(EXPRESSION)');
|
607
|
+
print_token();
|
608
|
+
break;
|
609
|
+
}
|
610
|
+
|
611
|
+
if (flags.mode === '[EXPRESSION]' || flags.mode === '[INDENTED-EXPRESSION]') {
|
612
|
+
if (last_last_text === ']' && last_text === ',') {
|
613
|
+
// ], [ goes to new line
|
614
|
+
if (flags.mode === '[EXPRESSION]') {
|
615
|
+
flags.mode = '[INDENTED-EXPRESSION]';
|
616
|
+
if (!opt_keep_array_indentation) {
|
617
|
+
indent();
|
618
|
+
}
|
619
|
+
}
|
620
|
+
set_mode('[EXPRESSION]');
|
621
|
+
if (!opt_keep_array_indentation) {
|
622
|
+
print_newline();
|
623
|
+
}
|
624
|
+
} else if (last_text === '[') {
|
625
|
+
if (flags.mode === '[EXPRESSION]') {
|
626
|
+
flags.mode = '[INDENTED-EXPRESSION]';
|
627
|
+
if (!opt_keep_array_indentation) {
|
628
|
+
indent();
|
629
|
+
}
|
630
|
+
}
|
631
|
+
set_mode('[EXPRESSION]');
|
632
|
+
|
633
|
+
if (!opt_keep_array_indentation) {
|
634
|
+
print_newline();
|
635
|
+
}
|
636
|
+
} else {
|
637
|
+
set_mode('[EXPRESSION]');
|
638
|
+
}
|
639
|
+
} else {
|
640
|
+
set_mode('[EXPRESSION]');
|
641
|
+
}
|
642
|
+
|
643
|
+
|
644
|
+
|
645
|
+
} else {
|
646
|
+
set_mode('(EXPRESSION)');
|
647
|
+
}
|
648
|
+
if(token_text == "("){
|
649
|
+
paren_count++;
|
650
|
+
}
|
651
|
+
if (last_text === ';' || last_type === 'TK_START_BLOCK') {
|
652
|
+
print_newline();
|
653
|
+
} else if (last_type === 'TK_END_EXPR' || last_type === 'TK_START_EXPR' || last_type === 'TK_END_BLOCK' || last_text === '.') {
|
654
|
+
// do nothing on (( and )( and ][ and ]( and .(
|
655
|
+
} else if (last_type !== 'TK_WORD' && last_type !== 'TK_OPERATOR') {
|
656
|
+
print_single_space();
|
657
|
+
} else if (last_word === 'function') {
|
658
|
+
// function() vs function ()
|
659
|
+
if (opt_space_after_anon_function) {
|
660
|
+
print_single_space();
|
661
|
+
}
|
662
|
+
paren_spots[paren_count] = false;
|
663
|
+
//in_statement_expression = true;
|
664
|
+
|
665
|
+
} else if (in_array(last_text, line_starters) || last_text === 'catch') {
|
666
|
+
print_single_space();
|
667
|
+
}
|
668
|
+
if(last_text === 'for' || last_text === 'if' || last_text === 'while' || last_text === 'switch' || last_text === 'with'){
|
669
|
+
paren_spots[paren_count] = false;
|
670
|
+
//in_statement_expression = true;
|
671
|
+
}
|
672
|
+
|
673
|
+
print_token();
|
674
|
+
break;
|
675
|
+
|
676
|
+
case 'TK_END_EXPR':
|
677
|
+
|
678
|
+
if(token_text == ")"){
|
679
|
+
//is there someone waiting
|
680
|
+
var ps = paren_spots[paren_count];
|
681
|
+
if(ps && opt_space_statement_expression){
|
682
|
+
print_single_space();
|
683
|
+
}
|
684
|
+
delete paren_spots[paren_count];
|
685
|
+
paren_count--;
|
686
|
+
}
|
687
|
+
if (token_text === ']') {
|
688
|
+
if (opt_keep_array_indentation) {
|
689
|
+
if (last_text === '}') {
|
690
|
+
// trim_output();
|
691
|
+
// print_newline(true);
|
692
|
+
remove_indent();
|
693
|
+
print_token();
|
694
|
+
restore_mode();
|
695
|
+
break;
|
696
|
+
}
|
697
|
+
} else {
|
698
|
+
if (flags.mode === '[INDENTED-EXPRESSION]') {
|
699
|
+
if (last_text === ']') {
|
700
|
+
restore_mode();
|
701
|
+
print_newline();
|
702
|
+
print_token();
|
703
|
+
break;
|
704
|
+
}
|
705
|
+
}
|
706
|
+
}
|
707
|
+
}
|
708
|
+
restore_mode();
|
709
|
+
print_token();
|
710
|
+
break;
|
711
|
+
|
712
|
+
case 'TK_START_BLOCK':
|
713
|
+
|
714
|
+
if (last_word === 'do') {
|
715
|
+
set_mode('DO_BLOCK');
|
716
|
+
} else {
|
717
|
+
set_mode('BLOCK');
|
718
|
+
}
|
719
|
+
if (opt_braces_on_own_line) {
|
720
|
+
if (last_type !== 'TK_OPERATOR') {
|
721
|
+
if (last_text == 'return') {
|
722
|
+
print_single_space();
|
723
|
+
} else {
|
724
|
+
print_newline(true);
|
725
|
+
}
|
726
|
+
}
|
727
|
+
print_token();
|
728
|
+
indent();
|
729
|
+
} else {
|
730
|
+
if (last_type !== 'TK_OPERATOR' && last_type !== 'TK_START_EXPR') {
|
731
|
+
if (last_type === 'TK_START_BLOCK') {
|
732
|
+
print_newline();
|
733
|
+
} else {
|
734
|
+
print_single_space();
|
735
|
+
}
|
736
|
+
} else {
|
737
|
+
// if TK_OPERATOR or TK_START_EXPR
|
738
|
+
if (is_array(flags.previous_mode) && last_text === ',') {
|
739
|
+
print_newline(); // [a, b, c, {
|
740
|
+
}
|
741
|
+
}
|
742
|
+
indent();
|
743
|
+
print_token();
|
744
|
+
}
|
745
|
+
|
746
|
+
break;
|
747
|
+
|
748
|
+
case 'TK_END_BLOCK':
|
749
|
+
restore_mode();
|
750
|
+
if (opt_braces_on_own_line) {
|
751
|
+
print_newline();
|
752
|
+
print_token();
|
753
|
+
} else {
|
754
|
+
if (last_type === 'TK_START_BLOCK') {
|
755
|
+
// nothing
|
756
|
+
if (just_added_newline) {
|
757
|
+
remove_indent();
|
758
|
+
} else {
|
759
|
+
// {}
|
760
|
+
trim_output();
|
761
|
+
}
|
762
|
+
} else {
|
763
|
+
print_newline();
|
764
|
+
}
|
765
|
+
print_token();
|
766
|
+
}
|
767
|
+
break;
|
768
|
+
|
769
|
+
case 'TK_WORD':
|
770
|
+
if(typeof paren_spots[paren_count] == 'boolean'){
|
771
|
+
|
772
|
+
if(opt_space_statement_expression && ( last_text === "," || last_text == "(" )){
|
773
|
+
print_single_space();
|
774
|
+
}
|
775
|
+
paren_spots[paren_count] = true;
|
776
|
+
}
|
777
|
+
// no, it's not you. even I have problems understanding how this works
|
778
|
+
// and what does what.
|
779
|
+
if (do_block_just_closed) {
|
780
|
+
// do {} ## while ()
|
781
|
+
print_single_space();
|
782
|
+
print_token();
|
783
|
+
print_single_space();
|
784
|
+
do_block_just_closed = false;
|
785
|
+
break;
|
786
|
+
}
|
787
|
+
|
788
|
+
if (token_text === 'function') {
|
789
|
+
if ((just_added_newline || last_text === ';') && last_text !== '{') {
|
790
|
+
// make sure there is a nice clean space of at least one blank line
|
791
|
+
// before a new function definition
|
792
|
+
n_newlines = just_added_newline ? n_newlines : 0;
|
793
|
+
|
794
|
+
for (var i = 0; i < 2 - n_newlines; i++) {
|
795
|
+
print_newline(false);
|
796
|
+
}
|
797
|
+
|
798
|
+
}
|
799
|
+
}
|
800
|
+
|
801
|
+
if (token_text === 'case' || token_text === 'default') {
|
802
|
+
if (last_text === ':') {
|
803
|
+
// switch cases following one another
|
804
|
+
remove_indent();
|
805
|
+
} else {
|
806
|
+
// case statement starts in the same line where switch
|
807
|
+
flags.indentation_level--;
|
808
|
+
print_newline();
|
809
|
+
flags.indentation_level++;
|
810
|
+
}
|
811
|
+
print_token();
|
812
|
+
flags.in_case = true;
|
813
|
+
break;
|
814
|
+
}
|
815
|
+
|
816
|
+
prefix = 'NONE';
|
817
|
+
|
818
|
+
if (last_type === 'TK_END_BLOCK') {
|
819
|
+
if (!in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
|
820
|
+
prefix = 'NEWLINE';
|
821
|
+
} else {
|
822
|
+
if (opt_braces_on_own_line) {
|
823
|
+
prefix = 'NEWLINE';
|
824
|
+
} else {
|
825
|
+
prefix = 'SPACE';
|
826
|
+
print_single_space();
|
827
|
+
}
|
828
|
+
}
|
829
|
+
} else if (last_type === 'TK_SEMICOLON' && (flags.mode === 'BLOCK' || flags.mode === 'DO_BLOCK')) {
|
830
|
+
prefix = 'NEWLINE';
|
831
|
+
} else if (last_type === 'TK_SEMICOLON' && is_expression(flags.mode)) {
|
832
|
+
prefix = 'SPACE';
|
833
|
+
} else if (last_type === 'TK_STRING') {
|
834
|
+
prefix = 'NEWLINE';
|
835
|
+
} else if (last_type === 'TK_WORD') {
|
836
|
+
prefix = 'SPACE';
|
837
|
+
} else if (last_type === 'TK_START_BLOCK') {
|
838
|
+
prefix = 'NEWLINE';
|
839
|
+
} else if (last_type === 'TK_END_EXPR') {
|
840
|
+
print_single_space();
|
841
|
+
prefix = 'NEWLINE';
|
842
|
+
}
|
843
|
+
|
844
|
+
if (last_type !== 'TK_END_BLOCK' && in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
|
845
|
+
print_newline();
|
846
|
+
} else if (in_array(token_text, line_starters) || prefix === 'NEWLINE') {
|
847
|
+
if (last_text === 'else') {
|
848
|
+
// no need to force newline on else break
|
849
|
+
print_single_space();
|
850
|
+
} else if ((last_type === 'TK_START_EXPR' || last_text === '=' || last_text === ',') && token_text === 'function') {
|
851
|
+
// no need to force newline on 'function': (function
|
852
|
+
// DONOTHING
|
853
|
+
} else if (last_text === 'return' || last_text === 'throw') {
|
854
|
+
// no newline between 'return nnn'
|
855
|
+
print_single_space();
|
856
|
+
} else if (last_type !== 'TK_END_EXPR') {
|
857
|
+
if ((last_type !== 'TK_START_EXPR' || token_text !== 'var') && last_text !== ':') {
|
858
|
+
// no need to force newline on 'var': for (var x = 0...)
|
859
|
+
if (token_text === 'if' && last_word === 'else' && last_text !== '{') {
|
860
|
+
// no newline for } else if {
|
861
|
+
print_single_space();
|
862
|
+
} else {
|
863
|
+
print_newline();
|
864
|
+
}
|
865
|
+
}
|
866
|
+
} else {
|
867
|
+
if (in_array(token_text, line_starters) && last_text !== ')') {
|
868
|
+
print_newline();
|
869
|
+
}
|
870
|
+
}
|
871
|
+
} else if (is_array(flags.mode) && last_text === ',' && last_last_text === '}') {
|
872
|
+
print_newline(); // }, in lists get a newline treatment
|
873
|
+
} else if (prefix === 'SPACE') {
|
874
|
+
print_single_space();
|
875
|
+
}
|
876
|
+
print_token();
|
877
|
+
last_word = token_text;
|
878
|
+
|
879
|
+
if (token_text === 'var') {
|
880
|
+
flags.var_line = true;
|
881
|
+
flags.var_line_reindented = false;
|
882
|
+
flags.var_line_tainted = false;
|
883
|
+
}
|
884
|
+
|
885
|
+
if (token_text === 'if' || token_text === 'else') {
|
886
|
+
flags.if_line = true;
|
887
|
+
}
|
888
|
+
|
889
|
+
break;
|
890
|
+
|
891
|
+
case 'TK_SEMICOLON':
|
892
|
+
|
893
|
+
print_token();
|
894
|
+
flags.var_line = false;
|
895
|
+
flags.var_line_reindented = false;
|
896
|
+
break;
|
897
|
+
|
898
|
+
case 'TK_STRING':
|
899
|
+
|
900
|
+
if (last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK' || last_type === 'TK_SEMICOLON') {
|
901
|
+
print_newline();
|
902
|
+
} else if (last_type === 'TK_WORD') {
|
903
|
+
print_single_space();
|
904
|
+
}
|
905
|
+
print_token();
|
906
|
+
break;
|
907
|
+
|
908
|
+
case 'TK_EQUALS':
|
909
|
+
if (flags.var_line) {
|
910
|
+
// just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
|
911
|
+
flags.var_line_tainted = true;
|
912
|
+
}
|
913
|
+
print_single_space();
|
914
|
+
print_token();
|
915
|
+
print_single_space();
|
916
|
+
break;
|
917
|
+
|
918
|
+
case 'TK_OPERATOR':
|
919
|
+
|
920
|
+
var space_before = true;
|
921
|
+
var space_after = true;
|
922
|
+
|
923
|
+
if (flags.var_line && token_text === ',' && (is_expression(flags.mode))) {
|
924
|
+
// do not break on comma, for(var a = 1, b = 2)
|
925
|
+
flags.var_line_tainted = false;
|
926
|
+
}
|
927
|
+
|
928
|
+
if (flags.var_line) {
|
929
|
+
if (token_text === ',') {
|
930
|
+
if (flags.var_line_tainted) {
|
931
|
+
print_token();
|
932
|
+
flags.var_line_reindented = true;
|
933
|
+
flags.var_line_tainted = false;
|
934
|
+
print_newline();
|
935
|
+
break;
|
936
|
+
} else {
|
937
|
+
flags.var_line_tainted = false;
|
938
|
+
}
|
939
|
+
// } else if (token_text === ':') {
|
940
|
+
// hmm, when does this happen? tests don't catch this
|
941
|
+
// flags.var_line = false;
|
942
|
+
}
|
943
|
+
}
|
944
|
+
|
945
|
+
if (last_text === 'return' || last_text === 'throw') {
|
946
|
+
// "return" had a special handling in TK_WORD. Now we need to return the favor
|
947
|
+
print_single_space();
|
948
|
+
print_token();
|
949
|
+
break;
|
950
|
+
}
|
951
|
+
|
952
|
+
if (token_text === ':' && flags.in_case) {
|
953
|
+
print_token(); // colon really asks for separate treatment
|
954
|
+
print_newline();
|
955
|
+
flags.in_case = false;
|
956
|
+
break;
|
957
|
+
}
|
958
|
+
|
959
|
+
if (token_text === '::') {
|
960
|
+
// no spaces around exotic namespacing syntax operator
|
961
|
+
print_token();
|
962
|
+
break;
|
963
|
+
}
|
964
|
+
|
965
|
+
if (token_text === ',') {
|
966
|
+
if (flags.var_line) {
|
967
|
+
if (flags.var_line_tainted) {
|
968
|
+
print_token();
|
969
|
+
print_newline();
|
970
|
+
flags.var_line_tainted = false;
|
971
|
+
} else {
|
972
|
+
print_token();
|
973
|
+
print_single_space();
|
974
|
+
}
|
975
|
+
} else if (last_type === 'TK_END_BLOCK' && flags.mode !== "(EXPRESSION)") {
|
976
|
+
print_token();
|
977
|
+
if (flags.mode === 'OBJECT' && last_text === '}') {
|
978
|
+
print_newline();
|
979
|
+
} else {
|
980
|
+
print_single_space();
|
981
|
+
}
|
982
|
+
} else {
|
983
|
+
if (flags.mode === 'OBJECT') {
|
984
|
+
print_token();
|
985
|
+
print_newline();
|
986
|
+
} else {
|
987
|
+
// EXPR or DO_BLOCK
|
988
|
+
print_token();
|
989
|
+
print_single_space();
|
990
|
+
}
|
991
|
+
}
|
992
|
+
break;
|
993
|
+
// } else if (in_array(token_text, ['--', '++', '!']) || (in_array(token_text, ['-', '+']) && (in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS']) || in_array(last_text, line_starters) || in_array(last_text, ['==', '!=', '+=', '-=', '*=', '/=', '+', '-'])))) {
|
994
|
+
} else if (in_array(token_text, ['--', '++', '!']) || (in_array(token_text, ['-', '+']) && (in_array(last_type, ['TK_START_BLOCK', 'TK_START_EXPR', 'TK_EQUALS', 'TK_OPERATOR']) || in_array(last_text, line_starters)))) {
|
995
|
+
// unary operators (and binary +/- pretending to be unary) special cases
|
996
|
+
|
997
|
+
space_before = false;
|
998
|
+
space_after = false;
|
999
|
+
|
1000
|
+
if (last_text === ';' && is_expression(flags.mode)) {
|
1001
|
+
// for (;; ++i)
|
1002
|
+
// ^^^
|
1003
|
+
space_before = true;
|
1004
|
+
}
|
1005
|
+
if (last_type === 'TK_WORD' && in_array(last_text, line_starters)) {
|
1006
|
+
space_before = true;
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
if (flags.mode === 'BLOCK' && (last_text === '{' || last_text === ';')) {
|
1010
|
+
// { foo; --i }
|
1011
|
+
// foo(); --bar;
|
1012
|
+
print_newline();
|
1013
|
+
}
|
1014
|
+
} else if (token_text === '.') {
|
1015
|
+
// decimal digits or object.property
|
1016
|
+
space_before = false;
|
1017
|
+
|
1018
|
+
} else if (token_text === ':') {
|
1019
|
+
if (!is_ternary_op()) {
|
1020
|
+
flags.mode = 'OBJECT';
|
1021
|
+
space_before = false;
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
if (space_before) {
|
1025
|
+
print_single_space();
|
1026
|
+
}
|
1027
|
+
|
1028
|
+
print_token();
|
1029
|
+
|
1030
|
+
if (space_after) {
|
1031
|
+
print_single_space();
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
if (token_text === '!') {
|
1035
|
+
// flags.eat_next_space = true;
|
1036
|
+
}
|
1037
|
+
|
1038
|
+
break;
|
1039
|
+
|
1040
|
+
case 'TK_BLOCK_COMMENT':
|
1041
|
+
|
1042
|
+
var lines = token_text.split(/\x0a|\x0d\x0a/);
|
1043
|
+
|
1044
|
+
if (/^\/\*\*/.test(token_text)) {
|
1045
|
+
// javadoc: reformat and reindent
|
1046
|
+
print_newline();
|
1047
|
+
output.push(lines[0]);
|
1048
|
+
for (i = 1; i < lines.length; i++) {
|
1049
|
+
print_newline();
|
1050
|
+
output.push(' ');
|
1051
|
+
output.push(lines[i].replace(/^\s\s*|\s\s*$/, ''));
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
} else {
|
1055
|
+
// simple block comment: leave intact
|
1056
|
+
if (lines.length > 1) {
|
1057
|
+
// multiline comment block starts with a new line
|
1058
|
+
print_newline();
|
1059
|
+
trim_output();
|
1060
|
+
} else {
|
1061
|
+
// single-line /* comment */ stays where it is
|
1062
|
+
print_single_space();
|
1063
|
+
}
|
1064
|
+
for (i = 0; i < lines.length; i++) {
|
1065
|
+
output.push(lines[i]);
|
1066
|
+
output.push('\n');
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
}
|
1070
|
+
print_newline();
|
1071
|
+
break;
|
1072
|
+
|
1073
|
+
case 'TK_INLINE_COMMENT':
|
1074
|
+
|
1075
|
+
print_single_space();
|
1076
|
+
print_token();
|
1077
|
+
if (is_expression(flags.mode)) {
|
1078
|
+
print_single_space();
|
1079
|
+
} else {
|
1080
|
+
print_newline();
|
1081
|
+
}
|
1082
|
+
break;
|
1083
|
+
|
1084
|
+
case 'TK_COMMENT':
|
1085
|
+
|
1086
|
+
// print_newline();
|
1087
|
+
if (wanted_newline) {
|
1088
|
+
print_newline();
|
1089
|
+
} else {
|
1090
|
+
print_single_space();
|
1091
|
+
}
|
1092
|
+
print_token();
|
1093
|
+
print_newline();
|
1094
|
+
break;
|
1095
|
+
|
1096
|
+
case 'TK_UNKNOWN':
|
1097
|
+
print_token();
|
1098
|
+
break;
|
1099
|
+
}
|
1100
|
+
|
1101
|
+
last_last_text = last_text;
|
1102
|
+
last_type = token_type;
|
1103
|
+
last_text = token_text;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
return output.join('').replace(/[\n ]+$/, '');
|
1107
|
+
|
1108
|
+
}
|