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,172 @@
|
|
1
|
+
(function(){
|
2
|
+
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
3
|
+
isArray = function(arr){
|
4
|
+
return Object.prototype.toString.call(arr) === "[object Array]"
|
5
|
+
}
|
6
|
+
|
7
|
+
|
8
|
+
JSONparse = function (text, reviver) {
|
9
|
+
|
10
|
+
var j;
|
11
|
+
|
12
|
+
function walk(holder, key) {
|
13
|
+
var k, v, value = holder[key];
|
14
|
+
if (value && typeof value === 'object') {
|
15
|
+
for (k in value) {
|
16
|
+
if (Object.hasOwnProperty.call(value, k)) {
|
17
|
+
v = walk(value, k);
|
18
|
+
if (v !== undefined) {
|
19
|
+
value[k] = v;
|
20
|
+
} else {
|
21
|
+
delete value[k];
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
return reviver.call(holder, key, value);
|
27
|
+
}
|
28
|
+
|
29
|
+
cx.lastIndex = 0;
|
30
|
+
if (cx.test(text)) {
|
31
|
+
text = text.replace(cx, function (a) {
|
32
|
+
return '\\u' +
|
33
|
+
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
if (/^[\],:{}\s]*$/.
|
37
|
+
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
|
38
|
+
replace(/["'][^"\\\n\r]*["']|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
|
39
|
+
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
40
|
+
|
41
|
+
|
42
|
+
j = eval('(' + text + ')');
|
43
|
+
|
44
|
+
// In the optional fourth stage, we recursively walk the new structure, passing
|
45
|
+
// each name/value pair to a reviver function for possible transformation.
|
46
|
+
return typeof reviver === 'function' ? walk({'': j}, '') : j;
|
47
|
+
}
|
48
|
+
|
49
|
+
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
50
|
+
|
51
|
+
throw new SyntaxError('JSONparse');
|
52
|
+
};
|
53
|
+
|
54
|
+
|
55
|
+
var toIntegersAtLease =function (n)
|
56
|
+
// Format integers to have at least two digits.
|
57
|
+
{
|
58
|
+
return n < 10 ? '0' + n : n;
|
59
|
+
}
|
60
|
+
|
61
|
+
Date.prototype.toJSON = function(date)
|
62
|
+
// Yes, it polutes the Date namespace, but we'll allow it here, as
|
63
|
+
// it's damned usefull.
|
64
|
+
{
|
65
|
+
return this.getUTCFullYear() + '-' +
|
66
|
+
toIntegersAtLease(this.getUTCMonth()) + '-' +
|
67
|
+
toIntegersAtLease(this.getUTCDate());
|
68
|
+
};
|
69
|
+
|
70
|
+
var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g;
|
71
|
+
var meta = { // table of character substitutions
|
72
|
+
'\b': '\\b',
|
73
|
+
'\t': '\\t',
|
74
|
+
'\n': '\\n',
|
75
|
+
'\f': '\\f',
|
76
|
+
'\r': '\\r',
|
77
|
+
'"' : '\\"',
|
78
|
+
'\\': '\\\\'
|
79
|
+
};
|
80
|
+
|
81
|
+
var quoteString = function(string)
|
82
|
+
// Places quotes around a string, inteligently.
|
83
|
+
// If the string contains no control characters, no quote characters, and no
|
84
|
+
// backslash characters, then we can safely slap some quotes around it.
|
85
|
+
// Otherwise we must also replace the offending characters with safe escape
|
86
|
+
// sequences.
|
87
|
+
{
|
88
|
+
if (escapeable.test(string))
|
89
|
+
{
|
90
|
+
return '"' + string.replace(escapeable, function (a)
|
91
|
+
{
|
92
|
+
var c = meta[a];
|
93
|
+
if (typeof c === 'string') {
|
94
|
+
return c;
|
95
|
+
}
|
96
|
+
c = a.charCodeAt();
|
97
|
+
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
|
98
|
+
}) + '"';
|
99
|
+
}
|
100
|
+
return '"' + string + '"';
|
101
|
+
};
|
102
|
+
var vtoJSON = null;
|
103
|
+
var steal = steal;
|
104
|
+
vtoJSON = function(o, compact)
|
105
|
+
{
|
106
|
+
var type = typeof(o);
|
107
|
+
|
108
|
+
if (type == "undefined")
|
109
|
+
return "undefined";
|
110
|
+
else if (type == "number" || type == "boolean")
|
111
|
+
return o + "";
|
112
|
+
else if (o === null)
|
113
|
+
return "null";
|
114
|
+
|
115
|
+
// Is it a string?
|
116
|
+
if (type == "string")
|
117
|
+
{
|
118
|
+
return quoteString(o);
|
119
|
+
}
|
120
|
+
|
121
|
+
// Does it have a .toJSON function?
|
122
|
+
if (type == "object" && typeof o.toJSON == "function")
|
123
|
+
return o.toJSON(compact);
|
124
|
+
|
125
|
+
// Is it an array?
|
126
|
+
if(isArray(o))
|
127
|
+
{
|
128
|
+
var ret = [];
|
129
|
+
for (var i = 0; i < o.length; i++) {
|
130
|
+
ret.push( vtoJSON(o[i], compact) );
|
131
|
+
}
|
132
|
+
if (compact)
|
133
|
+
return "[" + ret.join(",") + "]";
|
134
|
+
else
|
135
|
+
return "[" + ret.join(", ") + "]";
|
136
|
+
}
|
137
|
+
|
138
|
+
// If it's a function, we have to warn somebody!
|
139
|
+
if (type == "function") {
|
140
|
+
throw new TypeError("Unable to convert object of type 'function' to json.");
|
141
|
+
}
|
142
|
+
|
143
|
+
// It's probably an object, then.
|
144
|
+
var ret = [];
|
145
|
+
for (var k in o) {
|
146
|
+
var name;
|
147
|
+
type = typeof(k);
|
148
|
+
|
149
|
+
if (type == "number")
|
150
|
+
name = '"' + k + '"';
|
151
|
+
else if (type == "string")
|
152
|
+
name = quoteString(k);
|
153
|
+
else
|
154
|
+
continue; //skip non-string or number keys
|
155
|
+
|
156
|
+
var val = vtoJSON(o[k], compact);
|
157
|
+
if (typeof(val) != "string") {
|
158
|
+
// skip non-serializable values
|
159
|
+
continue;
|
160
|
+
}
|
161
|
+
|
162
|
+
if (compact)
|
163
|
+
ret.push(name + ":" + val);
|
164
|
+
else
|
165
|
+
ret.push(name + ": " + val);
|
166
|
+
}
|
167
|
+
return "{" + ret.join(", ") + "}";
|
168
|
+
};
|
169
|
+
toJSON = vtoJSON;
|
170
|
+
|
171
|
+
|
172
|
+
})();
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# This script checks for arguments, if they don't exist it opens the Rhino dialog
|
3
|
+
# if arguments do exist, it loads the script in the first argument and passes the other arguments to the script
|
4
|
+
# ie: ./js steal/script/controller Todo
|
5
|
+
|
6
|
+
if [ $# -eq 0 ]
|
7
|
+
then
|
8
|
+
java -cp steal/rhino/js.jar:funcunit/dist/selenium/selenium/selenium-java-client-driver.jar org.mozilla.javascript.tools.shell.Main
|
9
|
+
exit 127
|
10
|
+
fi
|
11
|
+
if [ $1 = "-selenium" ]
|
12
|
+
then
|
13
|
+
java -jar funcunit/dist/selenium/selenium/selenium-server.jar
|
14
|
+
exit 127
|
15
|
+
fi
|
16
|
+
CP=funcunit/dist/selenium/selenium/selenium-java-client-driver.jar:steal/rhino/js.jar
|
17
|
+
if [ $1 = "-mail" ]
|
18
|
+
then
|
19
|
+
CP=steal/rhino/mail.jar:funcunit/dist/selenium/selenium/selenium-java-client-driver.jar:steal/rhino/js.jar
|
20
|
+
shift
|
21
|
+
fi
|
22
|
+
|
23
|
+
if [ $1 = "-h" -o $1 = "-?" -o $1 = "--help" ]
|
24
|
+
then
|
25
|
+
echo Load a command line Rhino JavaScript environment or run JavaScript script files in Rhino.
|
26
|
+
echo Available commands:
|
27
|
+
echo -e "./js\t\t\t\tOpens a command line JavaScript environment"
|
28
|
+
echo -e "./js -d\t\t\t\tOpens the Rhino debugger"
|
29
|
+
echo -e "./js [FILE]\t\t\tRuns FILE in the Rhino environment"
|
30
|
+
echo -e ""
|
31
|
+
echo -e "JavaScriptMVC script usage:"
|
32
|
+
echo -e "./js steal/generate/app [NAME]\t\tCreates a new JavaScriptMVC application"
|
33
|
+
echo -e "./js steal/generate/page [APP] [PAGE]\tGenerates a page for the application"
|
34
|
+
echo -e "./js steal/generate/controller [NAME]\tGenerates a Controller file"
|
35
|
+
echo -e "./js steal/generate/model [TYPE] [NAME]\tGenerates a Model file"
|
36
|
+
echo -e "./js apps/[NAME]/compress.js\t\tCompress your application and generate documentation"
|
37
|
+
exit 127
|
38
|
+
fi
|
39
|
+
|
40
|
+
|
41
|
+
if [ $1 = "-d" ]
|
42
|
+
then
|
43
|
+
java -classpath steal/rhino/js.jar:steal/rhino/selenium-java-client-driver.jar org.mozilla.javascript.tools.debugger.Main
|
44
|
+
exit 127
|
45
|
+
fi
|
46
|
+
|
47
|
+
ARGS=[
|
48
|
+
for arg
|
49
|
+
do
|
50
|
+
if [ $arg != $1 ]
|
51
|
+
then
|
52
|
+
ARGS=$ARGS"'$arg'",
|
53
|
+
fi
|
54
|
+
done
|
55
|
+
ARGS=$ARGS]
|
56
|
+
java -Xss1024k -cp $CP org.mozilla.javascript.tools.shell.Main -e _args=$ARGS -opt -1 -e 'load('"'"$1"'"')'
|
@@ -0,0 +1,57 @@
|
|
1
|
+
:: This script checks for arguments, if they don't exist it opens the Rhino dialog
|
2
|
+
:: if arguments do exist, it loads the script in the first argument and passes the other arguments to the script
|
3
|
+
:: ie: js jmvc\script\controller Todo
|
4
|
+
@echo off
|
5
|
+
SETLOCAL ENABLEDELAYEDEXPANSION
|
6
|
+
if "%1"=="" (
|
7
|
+
java -cp steal\rhino\js.jar org.mozilla.javascript.tools.shell.Main
|
8
|
+
GOTO END
|
9
|
+
)
|
10
|
+
if "%1"=="-h" GOTO PRINT_HELP
|
11
|
+
if "%1"=="-?" GOTO PRINT_HELP
|
12
|
+
if "%1"=="--help" GOTO PRINT_HELP
|
13
|
+
|
14
|
+
if "%1"=="-d" (
|
15
|
+
java -classpath funcunit/dist/selenium/selenium/selenium-java-client-driver.jar;steal/rhino/js.jar org.mozilla.javascript.tools.debugger.Main
|
16
|
+
GOTO END
|
17
|
+
)
|
18
|
+
if "%1"=="-selenium" (
|
19
|
+
java -jar funcunit\java\selenium-server.jar
|
20
|
+
GOTO END
|
21
|
+
)
|
22
|
+
SET CP=funcunit/dist/selenium/selenium/selenium-java-client-driver.jar;steal\rhino\js.jar
|
23
|
+
if "%1"=="-mail" (
|
24
|
+
SET CP=steal/rhino/mail.jar;funcunit/dist/selenium/selenium/selenium-java-client-driver.jar;steal\rhino\js.jar
|
25
|
+
SHIFT /0
|
26
|
+
)
|
27
|
+
SET ARGS=[
|
28
|
+
SET FILENAME=%1
|
29
|
+
SET FILENAME=%FILENAME:\=/%
|
30
|
+
::haven't seen any way to loop through all args yet, so for now this goes through arg 2-7
|
31
|
+
for /f "tokens=2,3,4,5,6,7 delims= " %%a in ("%*") do SET ARGS=!ARGS!'%%a','%%b','%%c','%%d','%%e','%%f'
|
32
|
+
::remove the commas
|
33
|
+
for %%a in (",''=") do ( call set ARGS=%%ARGS:%%~a%% )
|
34
|
+
::remove the spaces
|
35
|
+
for /f "tokens=1*" %%A in ("%ARGS%") do SET ARGS=%%A
|
36
|
+
SET ARGS=%ARGS%]
|
37
|
+
set ARGS=%ARGS:\=/%
|
38
|
+
java -Xss1024k -cp %CP% org.mozilla.javascript.tools.shell.Main -opt -1 -e _args=%ARGS% -e load('%FILENAME%')
|
39
|
+
|
40
|
+
GOTO END
|
41
|
+
|
42
|
+
:PRINT_HELP
|
43
|
+
echo Load a command line Rhino JavaScript environment or run JavaScript script files in Rhino.
|
44
|
+
echo Available commands:
|
45
|
+
echo js Opens a command line JavaScript environment
|
46
|
+
echo js -d Opens the Rhino debugger
|
47
|
+
echo js -selenium Starts selenium server
|
48
|
+
echo js [FILE] Runs FILE in the Rhino environment
|
49
|
+
|
50
|
+
echo JavaScriptMVC script usage:
|
51
|
+
echo js steal/generate/app [NAME] Creates a new JavaScriptMVC application
|
52
|
+
echo js steal/generate/page [APP] [PAGE] Generates a page for the application
|
53
|
+
echo js steal/generate/controller [NAME] Generates a Controller file
|
54
|
+
echo js steal/generate/model [TYPE] [NAME] Generates a Model file
|
55
|
+
echo js apps/[NAME]/compress.js Compress your application and generate documentation
|
56
|
+
|
57
|
+
:END
|
@@ -0,0 +1,117 @@
|
|
1
|
+
/**
|
2
|
+
* @add steal static
|
3
|
+
*/
|
4
|
+
steal({path: "less_engine.js",ignore: true},function(){
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @function less
|
8
|
+
* @plugin steal/less
|
9
|
+
* <p>Lets you build and compile [http://lesscss.org/ Less ] css styles.</p>
|
10
|
+
* <p>Less is an extension of CSS that adds variables, mixins, and quite a bit more.
|
11
|
+
* You can write css like:
|
12
|
+
* </p>
|
13
|
+
* @codestart css
|
14
|
+
* @@brand_color: #4D926F;
|
15
|
+
* #header {
|
16
|
+
* color: @@brand_color;
|
17
|
+
* }
|
18
|
+
* h2 {
|
19
|
+
* color: @@brand_color;
|
20
|
+
* }
|
21
|
+
* @codeend
|
22
|
+
* <h2>Use</h2>
|
23
|
+
* <p>First, create a less file like:</p>
|
24
|
+
* @codestart css
|
25
|
+
* @@my_color red
|
26
|
+
*
|
27
|
+
* body { color: @@my_color; }
|
28
|
+
* @codeend
|
29
|
+
* <p>Save this in a file named <code>red.less</code>.</p>
|
30
|
+
* <p>Next, you have to require the <code>steal/less</code> plugin and then use
|
31
|
+
* steal.less to load your less style:
|
32
|
+
* </p>
|
33
|
+
* @codestart
|
34
|
+
* steal.plugins('steal/less').then(function(){
|
35
|
+
* steal.less('red');
|
36
|
+
* });
|
37
|
+
* @codeend
|
38
|
+
*
|
39
|
+
* Loads Less files relative to the current file. It's expected that all
|
40
|
+
* Less files end with <code>less</code>.
|
41
|
+
* @param {String+} path the relative path from the current file to the less file.
|
42
|
+
* You can pass multiple paths.
|
43
|
+
* @return {steal} returns the steal function.
|
44
|
+
*/
|
45
|
+
steal.less = function(){
|
46
|
+
//if production,
|
47
|
+
if(steal.options.env == 'production'){
|
48
|
+
if(steal.loadedProductionCSS){
|
49
|
+
return steal;
|
50
|
+
}else{
|
51
|
+
var productionCssPath = steal.File( steal.options.production.replace(".js", ".css") ).normalize();
|
52
|
+
productionCssPath = steal.root.join( productionCssPath );
|
53
|
+
steal.createLink( productionCssPath );
|
54
|
+
loadedProductionCSS = true;
|
55
|
+
return steal;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
//@steal-remove-start
|
59
|
+
var current, path;
|
60
|
+
for(var i=0; i < arguments.length; i++){
|
61
|
+
current = new steal.File(arguments[i]+".less").joinCurrent();
|
62
|
+
path = steal.root.join(current)
|
63
|
+
if(steal.browser.rhino){
|
64
|
+
//rhino will just look for this
|
65
|
+
steal.createLink(path, {
|
66
|
+
type : "text/less"
|
67
|
+
})
|
68
|
+
}else{
|
69
|
+
var src = steal.request(path);
|
70
|
+
//get and insert stype
|
71
|
+
new (less.Parser)({
|
72
|
+
optimization: less.optimization,
|
73
|
+
paths: [path.replace(/[\w\.-]+$/, '')]
|
74
|
+
}).parse(src, function (e, root) {
|
75
|
+
var styles = root.toCSS(),
|
76
|
+
css = document.createElement('style');
|
77
|
+
|
78
|
+
css.type = 'text/css';
|
79
|
+
css.id = steal.cleanId(path)
|
80
|
+
|
81
|
+
document.getElementsByTagName('head')[0].appendChild(css);
|
82
|
+
|
83
|
+
if (css.styleSheet) { // IE
|
84
|
+
css.styleSheet.cssText = styles;
|
85
|
+
} else {
|
86
|
+
(function (node) {
|
87
|
+
if (css.childNodes.length > 0) {
|
88
|
+
if (css.firstChild.nodeValue !== node.nodeValue) {
|
89
|
+
css.replaceChild(node, css.firstChild);
|
90
|
+
}
|
91
|
+
} else {
|
92
|
+
css.appendChild(node);
|
93
|
+
}
|
94
|
+
})(document.createTextNode(styles));
|
95
|
+
}
|
96
|
+
|
97
|
+
});
|
98
|
+
}
|
99
|
+
}
|
100
|
+
//@steal-remove-end
|
101
|
+
return steal;
|
102
|
+
}
|
103
|
+
//@steal-remove-start
|
104
|
+
steal.build.types['text/less'] = function(script, loadScriptText){
|
105
|
+
var text = script.text || loadScriptText(script.href, script),
|
106
|
+
styles;
|
107
|
+
new (less.Parser)({
|
108
|
+
optimization: less.optimization,
|
109
|
+
paths: [script.href.replace(/[\w\.-]+$/, '')]
|
110
|
+
}).parse(text, function (e, root) {
|
111
|
+
styles = root.toCSS();
|
112
|
+
});
|
113
|
+
return styles;
|
114
|
+
}
|
115
|
+
//@steal-remove-end
|
116
|
+
})
|
117
|
+
|
@@ -0,0 +1,2529 @@
|
|
1
|
+
//@steal-clean
|
2
|
+
//
|
3
|
+
// LESS - Leaner CSS v1.0.34
|
4
|
+
// http://lesscss.org
|
5
|
+
//
|
6
|
+
// Copyright (c) 2010, Alexis Sellier
|
7
|
+
// Licensed under the Apache 2.0 License.
|
8
|
+
//
|
9
|
+
(function (window, undefined) {
|
10
|
+
//
|
11
|
+
// Stub out `require` in the browser
|
12
|
+
//
|
13
|
+
function require(arg) {
|
14
|
+
return window.less[arg.split('/')[1]];
|
15
|
+
};
|
16
|
+
|
17
|
+
|
18
|
+
// ecma-5.js
|
19
|
+
//
|
20
|
+
// -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
|
21
|
+
// -- tlrobinson Tom Robinson
|
22
|
+
// dantman Daniel Friesen
|
23
|
+
|
24
|
+
//
|
25
|
+
// Array
|
26
|
+
//
|
27
|
+
if (!Array.isArray) {
|
28
|
+
Array.isArray = function(obj) {
|
29
|
+
return Object.prototype.toString.call(obj) === "[object Array]" ||
|
30
|
+
(obj instanceof Array);
|
31
|
+
};
|
32
|
+
}
|
33
|
+
if (!Array.prototype.forEach) {
|
34
|
+
Array.prototype.forEach = function(block, thisObject) {
|
35
|
+
var len = this.length >>> 0;
|
36
|
+
for (var i = 0; i < len; i++) {
|
37
|
+
if (i in this) {
|
38
|
+
block.call(thisObject, this[i], i, this);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
};
|
42
|
+
}
|
43
|
+
if (!Array.prototype.map) {
|
44
|
+
Array.prototype.map = function(fun /*, thisp*/) {
|
45
|
+
var len = this.length >>> 0;
|
46
|
+
var res = new Array(len);
|
47
|
+
var thisp = arguments[1];
|
48
|
+
|
49
|
+
for (var i = 0; i < len; i++) {
|
50
|
+
if (i in this) {
|
51
|
+
res[i] = fun.call(thisp, this[i], i, this);
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return res;
|
55
|
+
};
|
56
|
+
}
|
57
|
+
if (!Array.prototype.filter) {
|
58
|
+
Array.prototype.filter = function (block /*, thisp */) {
|
59
|
+
var values = [];
|
60
|
+
var thisp = arguments[1];
|
61
|
+
for (var i = 0; i < this.length; i++) {
|
62
|
+
if (block.call(thisp, this[i])) {
|
63
|
+
values.push(this[i]);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
return values;
|
67
|
+
};
|
68
|
+
}
|
69
|
+
if (!Array.prototype.reduce) {
|
70
|
+
Array.prototype.reduce = function(fun /*, initial*/) {
|
71
|
+
var len = this.length >>> 0;
|
72
|
+
var i = 0;
|
73
|
+
|
74
|
+
// no value to return if no initial value and an empty array
|
75
|
+
if (len === 0 && arguments.length === 1) throw new TypeError();
|
76
|
+
|
77
|
+
if (arguments.length >= 2) {
|
78
|
+
var rv = arguments[1];
|
79
|
+
} else {
|
80
|
+
do {
|
81
|
+
if (i in this) {
|
82
|
+
rv = this[i++];
|
83
|
+
break;
|
84
|
+
}
|
85
|
+
// if array contains no values, no initial value to return
|
86
|
+
if (++i >= len) throw new TypeError();
|
87
|
+
} while (true);
|
88
|
+
}
|
89
|
+
for (; i < len; i++) {
|
90
|
+
if (i in this) {
|
91
|
+
rv = fun.call(null, rv, this[i], i, this);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return rv;
|
95
|
+
};
|
96
|
+
}
|
97
|
+
if (!Array.prototype.indexOf) {
|
98
|
+
Array.prototype.indexOf = function (value /*, fromIndex */ ) {
|
99
|
+
var length = this.length;
|
100
|
+
var i = arguments[1] || 0;
|
101
|
+
|
102
|
+
if (!length) return -1;
|
103
|
+
if (i >= length) return -1;
|
104
|
+
if (i < 0) i += length;
|
105
|
+
|
106
|
+
for (; i < length; i++) {
|
107
|
+
if (!Object.prototype.hasOwnProperty.call(this, i)) { continue }
|
108
|
+
if (value === this[i]) return i;
|
109
|
+
}
|
110
|
+
return -1;
|
111
|
+
};
|
112
|
+
}
|
113
|
+
|
114
|
+
//
|
115
|
+
// Object
|
116
|
+
//
|
117
|
+
if (!Object.keys) {
|
118
|
+
Object.keys = function (object) {
|
119
|
+
var keys = [];
|
120
|
+
for (var name in object) {
|
121
|
+
if (Object.prototype.hasOwnProperty.call(object, name)) {
|
122
|
+
keys.push(name);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
return keys;
|
126
|
+
};
|
127
|
+
}
|
128
|
+
|
129
|
+
//
|
130
|
+
// String
|
131
|
+
//
|
132
|
+
if (!String.prototype.trim) {
|
133
|
+
String.prototype.trim = function () {
|
134
|
+
return String(this).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
135
|
+
};
|
136
|
+
}
|
137
|
+
var less, tree;
|
138
|
+
|
139
|
+
if (typeof(window) === 'undefined') {
|
140
|
+
less = exports,
|
141
|
+
tree = require('less/tree');
|
142
|
+
} else {
|
143
|
+
if (typeof(window.less) === 'undefined') { window.less = {} }
|
144
|
+
less = window.less,
|
145
|
+
tree = window.less.tree = {};
|
146
|
+
}
|
147
|
+
//
|
148
|
+
// less.js - parser
|
149
|
+
//
|
150
|
+
// A relatively straight-forward predictive parser.
|
151
|
+
// There is no tokenization/lexing stage, the input is parsed
|
152
|
+
// in one sweep.
|
153
|
+
//
|
154
|
+
// To make the parser fast enough to run in the browser, several
|
155
|
+
// optimization had to be made:
|
156
|
+
//
|
157
|
+
// - Matching and slicing on a huge input is often cause of slowdowns.
|
158
|
+
// The solution is to chunkify the input into smaller strings.
|
159
|
+
// The chunks are stored in the `chunks` var,
|
160
|
+
// `j` holds the current chunk index, and `current` holds
|
161
|
+
// the index of the current chunk in relation to `input`.
|
162
|
+
// This gives us an almost 4x speed-up.
|
163
|
+
//
|
164
|
+
// - In many cases, we don't need to match individual tokens;
|
165
|
+
// for example, if a value doesn't hold any variables, operations
|
166
|
+
// or dynamic references, the parser can effectively 'skip' it,
|
167
|
+
// treating it as a literal.
|
168
|
+
// An example would be '1px solid #000' - which evaluates to itself,
|
169
|
+
// we don't need to know what the individual components are.
|
170
|
+
// The drawback, of course is that you don't get the benefits of
|
171
|
+
// syntax-checking on the CSS. This gives us a 50% speed-up in the parser,
|
172
|
+
// and a smaller speed-up in the code-gen.
|
173
|
+
//
|
174
|
+
//
|
175
|
+
// Token matching is done with the `$` function, which either takes
|
176
|
+
// a terminal string or regexp, or a non-terminal function to call.
|
177
|
+
// It also takes care of moving all the indices forwards.
|
178
|
+
//
|
179
|
+
//
|
180
|
+
less.Parser = function Parser(env) {
|
181
|
+
var input, // LeSS input string
|
182
|
+
i, // current index in `input`
|
183
|
+
j, // current chunk
|
184
|
+
temp, // temporarily holds a chunk's state, for backtracking
|
185
|
+
memo, // temporarily holds `i`, when backtracking
|
186
|
+
furthest, // furthest index the parser has gone to
|
187
|
+
chunks, // chunkified input
|
188
|
+
current, // index of current chunk, in `input`
|
189
|
+
parser;
|
190
|
+
|
191
|
+
var that = this;
|
192
|
+
|
193
|
+
// This function is called after all files
|
194
|
+
// have been imported through `@import`.
|
195
|
+
var finish = function () {};
|
196
|
+
|
197
|
+
var imports = this.imports = {
|
198
|
+
paths: env && env.paths || [], // Search paths, when importing
|
199
|
+
queue: [], // Files which haven't been imported yet
|
200
|
+
files: {}, // Holds the imported parse trees
|
201
|
+
push: function (path, callback) {
|
202
|
+
var that = this;
|
203
|
+
this.queue.push(path);
|
204
|
+
|
205
|
+
//
|
206
|
+
// Import a file asynchronously
|
207
|
+
//
|
208
|
+
less.Parser.importer(path, this.paths, function (root) {
|
209
|
+
that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue
|
210
|
+
that.files[path] = root; // Store the root
|
211
|
+
|
212
|
+
callback(root);
|
213
|
+
|
214
|
+
if (that.queue.length === 0) { finish() } // Call `finish` if we're done importing
|
215
|
+
});
|
216
|
+
}
|
217
|
+
};
|
218
|
+
|
219
|
+
function save() { temp = chunks[j], memo = i, current = i }
|
220
|
+
function restore() { chunks[j] = temp, i = memo, current = i }
|
221
|
+
|
222
|
+
function sync() {
|
223
|
+
if (i > current) {
|
224
|
+
chunks[j] = chunks[j].slice(i - current);
|
225
|
+
current = i;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
//
|
229
|
+
// Parse from a token, regexp or string, and move forward if match
|
230
|
+
//
|
231
|
+
function $(tok) {
|
232
|
+
var match, args, length, c, index, endIndex, k;
|
233
|
+
|
234
|
+
//
|
235
|
+
// Non-terminal
|
236
|
+
//
|
237
|
+
if (tok instanceof Function) {
|
238
|
+
return tok.call(parser.parsers);
|
239
|
+
//
|
240
|
+
// Terminal
|
241
|
+
//
|
242
|
+
// Either match a single character in the input,
|
243
|
+
// or match a regexp in the current chunk (chunk[j]).
|
244
|
+
//
|
245
|
+
} else if (typeof(tok) === 'string') {
|
246
|
+
match = input.charAt(i) === tok ? tok : null;
|
247
|
+
length = 1;
|
248
|
+
sync ();
|
249
|
+
|
250
|
+
// 1. We move to the next chunk, if necessary.
|
251
|
+
// 2. Set the `lastIndex` to be relative
|
252
|
+
// to the current chunk, and try to match in it.
|
253
|
+
// 3. Make sure we matched at `index`. Because we use
|
254
|
+
// the /g flag, the match could be anywhere in the
|
255
|
+
// chunk. We have to make sure it's at our previous
|
256
|
+
// index, which we stored in [2].
|
257
|
+
//
|
258
|
+
} else {
|
259
|
+
sync ();
|
260
|
+
|
261
|
+
if (match = tok.exec(chunks[j])) { // 3.
|
262
|
+
length = match[0].length;
|
263
|
+
} else {
|
264
|
+
return null;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
// The match is confirmed, add the match length to `i`,
|
269
|
+
// and consume any extra white-space characters (' ' || '\n')
|
270
|
+
// which come after that. The reason for this is that LeSS's
|
271
|
+
// grammar is mostly white-space insensitive.
|
272
|
+
//
|
273
|
+
if (match) {
|
274
|
+
mem = i += length;
|
275
|
+
endIndex = i + chunks[j].length - length;
|
276
|
+
|
277
|
+
while (i < endIndex) {
|
278
|
+
c = input.charCodeAt(i);
|
279
|
+
if (! (c === 32 || c === 10 || c === 9)) { break }
|
280
|
+
i++;
|
281
|
+
}
|
282
|
+
chunks[j] = chunks[j].slice(length + (i - mem));
|
283
|
+
current = i;
|
284
|
+
|
285
|
+
if (chunks[j].length === 0 && j < chunks.length - 1) { j++ }
|
286
|
+
|
287
|
+
if(typeof(match) === 'string') {
|
288
|
+
return match;
|
289
|
+
} else {
|
290
|
+
return match.length === 1 ? match[0] : match;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
// Same as $(), but don't change the state of the parser,
|
296
|
+
// just return the match.
|
297
|
+
function peek(tok) {
|
298
|
+
if (typeof(tok) === 'string') {
|
299
|
+
return input.charAt(i) === tok;
|
300
|
+
} else {
|
301
|
+
if (tok.test(chunks[j])) {
|
302
|
+
return true;
|
303
|
+
} else {
|
304
|
+
return false;
|
305
|
+
}
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
this.env = env = env || {};
|
310
|
+
|
311
|
+
// The optimization level dictates the thoroughness of the parser,
|
312
|
+
// the lower the number, the less nodes it will create in the tree.
|
313
|
+
// This could matter for debugging, or if you want to access
|
314
|
+
// the individual nodes in the tree.
|
315
|
+
this.optimization = ('optimization' in this.env) ? this.env.optimization : 1;
|
316
|
+
|
317
|
+
this.env.filename = this.env.filename || null;
|
318
|
+
|
319
|
+
//
|
320
|
+
// The Parser
|
321
|
+
//
|
322
|
+
return parser = {
|
323
|
+
|
324
|
+
imports: imports,
|
325
|
+
//
|
326
|
+
// Parse an input string into an abstract syntax tree,
|
327
|
+
// call `callback` when done.
|
328
|
+
//
|
329
|
+
parse: function (str, callback) {
|
330
|
+
var root, start, end, zone, line, lines, buff = [], c, error = null;
|
331
|
+
|
332
|
+
i = j = current = furthest = 0;
|
333
|
+
chunks = [];
|
334
|
+
input = str.replace(/\r\n/g, '\n');
|
335
|
+
|
336
|
+
// Split the input into chunks.
|
337
|
+
chunks = (function (chunks) {
|
338
|
+
var j = 0,
|
339
|
+
skip = /[^"'`\{\}\/]+/g,
|
340
|
+
comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
|
341
|
+
level = 0,
|
342
|
+
match,
|
343
|
+
chunk = chunks[0],
|
344
|
+
inString;
|
345
|
+
|
346
|
+
for (var i = 0, c, cc; i < input.length; i++) {
|
347
|
+
skip.lastIndex = i;
|
348
|
+
if (match = skip.exec(input)) {
|
349
|
+
if (match.index === i) {
|
350
|
+
i += match[0].length;
|
351
|
+
chunk.push(match[0]);
|
352
|
+
}
|
353
|
+
}
|
354
|
+
c = input.charAt(i);
|
355
|
+
comment.lastIndex = i;
|
356
|
+
|
357
|
+
if (!inString && c === '/') {
|
358
|
+
cc = input.charAt(i + 1);
|
359
|
+
if (cc === '/' || cc === '*') {
|
360
|
+
if (match = comment.exec(input)) {
|
361
|
+
if (match.index === i) {
|
362
|
+
i += match[0].length;
|
363
|
+
chunk.push(match[0]);
|
364
|
+
c = input.charAt(i);
|
365
|
+
}
|
366
|
+
}
|
367
|
+
}
|
368
|
+
}
|
369
|
+
|
370
|
+
if (c === '{' && !inString) { level ++;
|
371
|
+
chunk.push(c);
|
372
|
+
} else if (c === '}' && !inString) { level --;
|
373
|
+
chunk.push(c);
|
374
|
+
chunks[++j] = chunk = [];
|
375
|
+
} else {
|
376
|
+
if (c === '"' || c === "'" || c === '`') {
|
377
|
+
if (! inString) {
|
378
|
+
inString = c;
|
379
|
+
} else {
|
380
|
+
inString = inString === c ? false : inString;
|
381
|
+
}
|
382
|
+
}
|
383
|
+
chunk.push(c);
|
384
|
+
}
|
385
|
+
}
|
386
|
+
if (level > 0) { throw new(Error)("Missing closing '}'") }
|
387
|
+
|
388
|
+
return chunks.map(function (c) { return c.join('') });;
|
389
|
+
})([[]]);
|
390
|
+
|
391
|
+
// Start with the primary rule.
|
392
|
+
// The whole syntax tree is held under a Ruleset node,
|
393
|
+
// with the `root` property set to true, so no `{}` are
|
394
|
+
// output. The callback is called when the input is parsed.
|
395
|
+
root = new(tree.Ruleset)([], $(this.parsers.primary));
|
396
|
+
root.root = true;
|
397
|
+
|
398
|
+
root.toCSS = (function (evaluate) {
|
399
|
+
var line, lines, column;
|
400
|
+
|
401
|
+
return function (options, variables) {
|
402
|
+
var frames = [];
|
403
|
+
|
404
|
+
options = options || {};
|
405
|
+
//
|
406
|
+
// Allows setting variables with a hash, so:
|
407
|
+
//
|
408
|
+
// `{ color: new(tree.Color)('#f01') }` will become:
|
409
|
+
//
|
410
|
+
// new(tree.Rule)('@color',
|
411
|
+
// new(tree.Value)([
|
412
|
+
// new(tree.Expression)([
|
413
|
+
// new(tree.Color)('#f01')
|
414
|
+
// ])
|
415
|
+
// ])
|
416
|
+
// )
|
417
|
+
//
|
418
|
+
if (typeof(variables) === 'object' && !Array.isArray(variables)) {
|
419
|
+
variables = Object.keys(variables).map(function (k) {
|
420
|
+
var value = variables[k];
|
421
|
+
|
422
|
+
if (! (value instanceof tree.Value)) {
|
423
|
+
if (! (value instanceof tree.Expression)) {
|
424
|
+
value = new(tree.Expression)([value]);
|
425
|
+
}
|
426
|
+
value = new(tree.Value)([value]);
|
427
|
+
}
|
428
|
+
return new(tree.Rule)('@' + k, value, false, 0);
|
429
|
+
});
|
430
|
+
frames = [new(tree.Ruleset)(null, variables)];
|
431
|
+
}
|
432
|
+
|
433
|
+
try {
|
434
|
+
var css = evaluate.call(this, { frames: frames })
|
435
|
+
.toCSS([], { compress: options.compress || false });
|
436
|
+
} catch (e) {
|
437
|
+
lines = input.split('\n');
|
438
|
+
line = getLine(e.index);
|
439
|
+
|
440
|
+
for (var n = e.index, column = -1;
|
441
|
+
n >= 0 && input.charAt(n) !== '\n';
|
442
|
+
n--) { column++ }
|
443
|
+
|
444
|
+
throw {
|
445
|
+
type: e.type,
|
446
|
+
message: e.message,
|
447
|
+
filename: env.filename,
|
448
|
+
index: e.index,
|
449
|
+
line: typeof(line) === 'number' ? line + 1 : null,
|
450
|
+
callLine: e.call && (getLine(e.call) + 1),
|
451
|
+
callExtract: lines[getLine(e.call)],
|
452
|
+
stack: e.stack,
|
453
|
+
column: column,
|
454
|
+
extract: [
|
455
|
+
lines[line - 1],
|
456
|
+
lines[line],
|
457
|
+
lines[line + 1]
|
458
|
+
]
|
459
|
+
};
|
460
|
+
}
|
461
|
+
if (options.compress) {
|
462
|
+
return css.replace(/(\s)+/g, "$1");
|
463
|
+
} else {
|
464
|
+
return css;
|
465
|
+
}
|
466
|
+
|
467
|
+
function getLine(index) {
|
468
|
+
return index ? (input.slice(0, index).match(/\n/g) || "").length : null;
|
469
|
+
}
|
470
|
+
};
|
471
|
+
})(root.eval);
|
472
|
+
|
473
|
+
// If `i` is smaller than the `input.length - 1`,
|
474
|
+
// it means the parser wasn't able to parse the whole
|
475
|
+
// string, so we've got a parsing error.
|
476
|
+
//
|
477
|
+
// We try to extract a \n delimited string,
|
478
|
+
// showing the line where the parse error occured.
|
479
|
+
// We split it up into two parts (the part which parsed,
|
480
|
+
// and the part which didn't), so we can color them differently.
|
481
|
+
if (i < input.length - 1) {
|
482
|
+
i = furthest;
|
483
|
+
lines = input.split('\n');
|
484
|
+
line = (input.slice(0, i).match(/\n/g) || "").length + 1;
|
485
|
+
|
486
|
+
for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ }
|
487
|
+
|
488
|
+
error = {
|
489
|
+
name: "ParseError",
|
490
|
+
message: "Syntax Error on line " + line,
|
491
|
+
filename: env.filename,
|
492
|
+
line: line,
|
493
|
+
column: column,
|
494
|
+
extract: [
|
495
|
+
lines[line - 2],
|
496
|
+
lines[line - 1],
|
497
|
+
lines[line]
|
498
|
+
]
|
499
|
+
};
|
500
|
+
}
|
501
|
+
|
502
|
+
if (this.imports.queue.length > 0) {
|
503
|
+
finish = function () { callback(error, root) };
|
504
|
+
} else {
|
505
|
+
callback(error, root);
|
506
|
+
}
|
507
|
+
},
|
508
|
+
|
509
|
+
//
|
510
|
+
// Here in, the parsing rules/functions
|
511
|
+
//
|
512
|
+
// The basic structure of the syntax tree generated is as follows:
|
513
|
+
//
|
514
|
+
// Ruleset -> Rule -> Value -> Expression -> Entity
|
515
|
+
//
|
516
|
+
// Here's some LESS code:
|
517
|
+
//
|
518
|
+
// .class {
|
519
|
+
// color: #fff;
|
520
|
+
// border: 1px solid #000;
|
521
|
+
// width: @w + 4px;
|
522
|
+
// > .child {...}
|
523
|
+
// }
|
524
|
+
//
|
525
|
+
// And here's what the parse tree might look like:
|
526
|
+
//
|
527
|
+
// Ruleset (Selector '.class', [
|
528
|
+
// Rule ("color", Value ([Expression [Color #fff]]))
|
529
|
+
// Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]]))
|
530
|
+
// Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]]))
|
531
|
+
// Ruleset (Selector [Element '>', '.child'], [...])
|
532
|
+
// ])
|
533
|
+
//
|
534
|
+
// In general, most rules will try to parse a token with the `$()` function, and if the return
|
535
|
+
// value is truly, will return a new node, of the relevant type. Sometimes, we need to check
|
536
|
+
// first, before parsing, that's when we use `peek()`.
|
537
|
+
//
|
538
|
+
parsers: {
|
539
|
+
//
|
540
|
+
// The `primary` rule is the *entry* and *exit* point of the parser.
|
541
|
+
// The rules here can appear at any level of the parse tree.
|
542
|
+
//
|
543
|
+
// The recursive nature of the grammar is an interplay between the `block`
|
544
|
+
// rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,
|
545
|
+
// as represented by this simplified grammar:
|
546
|
+
//
|
547
|
+
// primary → (ruleset | rule)+
|
548
|
+
// ruleset → selector+ block
|
549
|
+
// block → '{' primary '}'
|
550
|
+
//
|
551
|
+
// Only at one point is the primary rule not called from the
|
552
|
+
// block rule: at the root level.
|
553
|
+
//
|
554
|
+
primary: function () {
|
555
|
+
var node, root = [];
|
556
|
+
|
557
|
+
while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
|
558
|
+
$(this.mixin.call) || $(this.comment) || $(this.directive))
|
559
|
+
|| $(/^[\s\n]+/)) {
|
560
|
+
node && root.push(node);
|
561
|
+
}
|
562
|
+
return root;
|
563
|
+
},
|
564
|
+
|
565
|
+
// We create a Comment node for CSS comments `/* */`,
|
566
|
+
// but keep the LeSS comments `//` silent, by just skipping
|
567
|
+
// over them.
|
568
|
+
comment: function () {
|
569
|
+
var comment;
|
570
|
+
|
571
|
+
if (input.charAt(i) !== '/') return;
|
572
|
+
|
573
|
+
if (input.charAt(i + 1) === '/') {
|
574
|
+
return new(tree.Comment)($(/^\/\/.*/), true);
|
575
|
+
} else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) {
|
576
|
+
return new(tree.Comment)(comment);
|
577
|
+
}
|
578
|
+
},
|
579
|
+
|
580
|
+
//
|
581
|
+
// Entities are tokens which can be found inside an Expression
|
582
|
+
//
|
583
|
+
entities: {
|
584
|
+
//
|
585
|
+
// A string, which supports escaping " and '
|
586
|
+
//
|
587
|
+
// "milky way" 'he\'s the one!'
|
588
|
+
//
|
589
|
+
quoted: function () {
|
590
|
+
var str;
|
591
|
+
if (input.charAt(i) !== '"' && input.charAt(i) !== "'") return;
|
592
|
+
|
593
|
+
if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) {
|
594
|
+
return new(tree.Quoted)(str[0], str[1] || str[2]);
|
595
|
+
}
|
596
|
+
},
|
597
|
+
|
598
|
+
//
|
599
|
+
// A catch-all word, such as:
|
600
|
+
//
|
601
|
+
// black border-collapse
|
602
|
+
//
|
603
|
+
keyword: function () {
|
604
|
+
var k;
|
605
|
+
if (k = $(/^[A-Za-z-]+/)) { return new(tree.Keyword)(k) }
|
606
|
+
},
|
607
|
+
|
608
|
+
//
|
609
|
+
// A function call
|
610
|
+
//
|
611
|
+
// rgb(255, 0, 255)
|
612
|
+
//
|
613
|
+
// We also try to catch IE's `alpha()`, but let the `alpha` parser
|
614
|
+
// deal with the details.
|
615
|
+
//
|
616
|
+
// The arguments are parsed with the `entities.arguments` parser.
|
617
|
+
//
|
618
|
+
call: function () {
|
619
|
+
var name, args;
|
620
|
+
|
621
|
+
if (! (name = /^([\w-]+|%)\(/.exec(chunks[j]))) return;
|
622
|
+
|
623
|
+
name = name[1].toLowerCase();
|
624
|
+
|
625
|
+
if (name === 'url') { return null }
|
626
|
+
else { i += name.length + 1 }
|
627
|
+
|
628
|
+
if (name === 'alpha') { return $(this.alpha) }
|
629
|
+
|
630
|
+
args = $(this.entities.arguments);
|
631
|
+
|
632
|
+
if (! $(')')) return;
|
633
|
+
|
634
|
+
if (name) { return new(tree.Call)(name, args) }
|
635
|
+
},
|
636
|
+
arguments: function () {
|
637
|
+
var args = [], arg;
|
638
|
+
|
639
|
+
while (arg = $(this.expression)) {
|
640
|
+
args.push(arg);
|
641
|
+
if (! $(',')) { break }
|
642
|
+
}
|
643
|
+
return args;
|
644
|
+
},
|
645
|
+
literal: function () {
|
646
|
+
return $(this.entities.dimension) ||
|
647
|
+
$(this.entities.color) ||
|
648
|
+
$(this.entities.quoted);
|
649
|
+
},
|
650
|
+
|
651
|
+
//
|
652
|
+
// Parse url() tokens
|
653
|
+
//
|
654
|
+
// We use a specific rule for urls, because they don't really behave like
|
655
|
+
// standard function calls. The difference is that the argument doesn't have
|
656
|
+
// to be enclosed within a string, so it can't be parsed as an Expression.
|
657
|
+
//
|
658
|
+
url: function () {
|
659
|
+
var value;
|
660
|
+
|
661
|
+
if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
|
662
|
+
value = $(this.entities.quoted) || $(this.entities.variable) || $(/^[-\w%@$\/.&=:;#+?]+/) || "";
|
663
|
+
if (! $(')')) throw new(Error)("missing closing ) for url()");
|
664
|
+
|
665
|
+
return new(tree.URL)((value.value || value instanceof tree.Variable)
|
666
|
+
? value : new(tree.Anonymous)(value), imports.paths);
|
667
|
+
},
|
668
|
+
|
669
|
+
//
|
670
|
+
// A Variable entity, such as `@fink`, in
|
671
|
+
//
|
672
|
+
// width: @fink + 2px
|
673
|
+
//
|
674
|
+
// We use a different parser for variable definitions,
|
675
|
+
// see `parsers.variable`.
|
676
|
+
//
|
677
|
+
variable: function () {
|
678
|
+
var name, index = i;
|
679
|
+
|
680
|
+
if (input.charAt(i) === '@' && (name = $(/^@[\w-]+/))) {
|
681
|
+
return new(tree.Variable)(name, index);
|
682
|
+
}
|
683
|
+
},
|
684
|
+
|
685
|
+
//
|
686
|
+
// A Hexadecimal color
|
687
|
+
//
|
688
|
+
// #4F3C2F
|
689
|
+
//
|
690
|
+
// `rgb` and `hsl` colors are parsed through the `entities.call` parser.
|
691
|
+
//
|
692
|
+
color: function () {
|
693
|
+
var rgb;
|
694
|
+
|
695
|
+
if (input.charAt(i) === '#' && (rgb = $(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/))) {
|
696
|
+
return new(tree.Color)(rgb[1]);
|
697
|
+
}
|
698
|
+
},
|
699
|
+
|
700
|
+
//
|
701
|
+
// A Dimension, that is, a number and a unit
|
702
|
+
//
|
703
|
+
// 0.5em 95%
|
704
|
+
//
|
705
|
+
dimension: function () {
|
706
|
+
var value, c = input.charCodeAt(i);
|
707
|
+
if ((c > 57 || c < 45) || c === 47) return;
|
708
|
+
|
709
|
+
if (value = $(/^(-?\d*\.?\d+)(px|%|em|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/)) {
|
710
|
+
return new(tree.Dimension)(value[1], value[2]);
|
711
|
+
}
|
712
|
+
},
|
713
|
+
|
714
|
+
//
|
715
|
+
// JavaScript code to be evaluated
|
716
|
+
//
|
717
|
+
// `window.location.href`
|
718
|
+
//
|
719
|
+
javascript: function () {
|
720
|
+
var str;
|
721
|
+
|
722
|
+
if (input.charAt(i) !== '`') { return }
|
723
|
+
|
724
|
+
if (str = $(/^`([^`]*)`/)) {
|
725
|
+
return new(tree.JavaScript)(str[1], i);
|
726
|
+
}
|
727
|
+
}
|
728
|
+
},
|
729
|
+
|
730
|
+
//
|
731
|
+
// The variable part of a variable definition. Used in the `rule` parser
|
732
|
+
//
|
733
|
+
// @fink:
|
734
|
+
//
|
735
|
+
variable: function () {
|
736
|
+
var name;
|
737
|
+
|
738
|
+
if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] }
|
739
|
+
},
|
740
|
+
|
741
|
+
//
|
742
|
+
// A font size/line-height shorthand
|
743
|
+
//
|
744
|
+
// small/12px
|
745
|
+
//
|
746
|
+
// We need to peek first, or we'll match on keywords and dimensions
|
747
|
+
//
|
748
|
+
shorthand: function () {
|
749
|
+
var a, b;
|
750
|
+
|
751
|
+
if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;
|
752
|
+
|
753
|
+
if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
|
754
|
+
return new(tree.Shorthand)(a, b);
|
755
|
+
}
|
756
|
+
},
|
757
|
+
|
758
|
+
//
|
759
|
+
// Mixins
|
760
|
+
//
|
761
|
+
mixin: {
|
762
|
+
//
|
763
|
+
// A Mixin call, with an optional argument list
|
764
|
+
//
|
765
|
+
// #mixins > .square(#fff);
|
766
|
+
// .rounded(4px, black);
|
767
|
+
// .button;
|
768
|
+
//
|
769
|
+
// The `while` loop is there because mixins can be
|
770
|
+
// namespaced, but we only support the child and descendant
|
771
|
+
// selector for now.
|
772
|
+
//
|
773
|
+
call: function () {
|
774
|
+
var elements = [], e, c, args, index = i, s = input.charAt(i);
|
775
|
+
|
776
|
+
if (s !== '.' && s !== '#') { return }
|
777
|
+
|
778
|
+
while (e = $(/^[#.][\w-]+/)) {
|
779
|
+
elements.push(new(tree.Element)(c, e));
|
780
|
+
c = $('>');
|
781
|
+
}
|
782
|
+
$('(') && (args = $(this.entities.arguments)) && $(')');
|
783
|
+
|
784
|
+
if (elements.length > 0 && ($(';') || peek('}'))) {
|
785
|
+
return new(tree.mixin.Call)(elements, args, index);
|
786
|
+
}
|
787
|
+
},
|
788
|
+
|
789
|
+
//
|
790
|
+
// A Mixin definition, with a list of parameters
|
791
|
+
//
|
792
|
+
// .rounded (@radius: 2px, @color) {
|
793
|
+
// ...
|
794
|
+
// }
|
795
|
+
//
|
796
|
+
// Until we have a finer grained state-machine, we have to
|
797
|
+
// do a look-ahead, to make sure we don't have a mixin call.
|
798
|
+
// See the `rule` function for more information.
|
799
|
+
//
|
800
|
+
// We start by matching `.rounded (`, and then proceed on to
|
801
|
+
// the argument list, which has optional default values.
|
802
|
+
// We store the parameters in `params`, with a `value` key,
|
803
|
+
// if there is a value, such as in the case of `@radius`.
|
804
|
+
//
|
805
|
+
// Once we've got our params list, and a closing `)`, we parse
|
806
|
+
// the `{...}` block.
|
807
|
+
//
|
808
|
+
definition: function () {
|
809
|
+
var name, params = [], match, ruleset, param, value;
|
810
|
+
|
811
|
+
if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
|
812
|
+
peek(/^[^{]*(;|})/)) return;
|
813
|
+
|
814
|
+
if (match = $(/^([#.][\w-]+)\s*\(/)) {
|
815
|
+
name = match[1];
|
816
|
+
|
817
|
+
while (param = $(this.entities.variable) || $(this.entities.literal)
|
818
|
+
|| $(this.entities.keyword)) {
|
819
|
+
// Variable
|
820
|
+
if (param instanceof tree.Variable) {
|
821
|
+
if ($(':')) {
|
822
|
+
if (value = $(this.expression)) {
|
823
|
+
params.push({ name: param.name, value: value });
|
824
|
+
} else {
|
825
|
+
throw new(Error)("Expected value");
|
826
|
+
}
|
827
|
+
} else {
|
828
|
+
params.push({ name: param.name });
|
829
|
+
}
|
830
|
+
} else {
|
831
|
+
params.push({ value: param });
|
832
|
+
}
|
833
|
+
if (! $(',')) { break }
|
834
|
+
}
|
835
|
+
if (! $(')')) throw new(Error)("Expected )");
|
836
|
+
|
837
|
+
ruleset = $(this.block);
|
838
|
+
|
839
|
+
if (ruleset) {
|
840
|
+
return new(tree.mixin.Definition)(name, params, ruleset);
|
841
|
+
}
|
842
|
+
}
|
843
|
+
}
|
844
|
+
},
|
845
|
+
|
846
|
+
//
|
847
|
+
// Entities are the smallest recognized token,
|
848
|
+
// and can be found inside a rule's value.
|
849
|
+
//
|
850
|
+
entity: function () {
|
851
|
+
return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
|
852
|
+
$(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript);
|
853
|
+
},
|
854
|
+
|
855
|
+
//
|
856
|
+
// A Rule terminator. Note that we use `peek()` to check for '}',
|
857
|
+
// because the `block` rule will be expecting it, but we still need to make sure
|
858
|
+
// it's there, if ';' was ommitted.
|
859
|
+
//
|
860
|
+
end: function () {
|
861
|
+
return $(';') || peek('}');
|
862
|
+
},
|
863
|
+
|
864
|
+
//
|
865
|
+
// IE's alpha function
|
866
|
+
//
|
867
|
+
// alpha(opacity=88)
|
868
|
+
//
|
869
|
+
alpha: function () {
|
870
|
+
var value;
|
871
|
+
|
872
|
+
if (! $(/^opacity=/i)) return;
|
873
|
+
if (value = $(/^\d+/) || $(this.entities.variable)) {
|
874
|
+
if (! $(')')) throw new(Error)("missing closing ) for alpha()");
|
875
|
+
return new(tree.Alpha)(value);
|
876
|
+
}
|
877
|
+
},
|
878
|
+
|
879
|
+
//
|
880
|
+
// A Selector Element
|
881
|
+
//
|
882
|
+
// div
|
883
|
+
// + h1
|
884
|
+
// #socks
|
885
|
+
// input[type="text"]
|
886
|
+
//
|
887
|
+
// Elements are the building blocks for Selectors,
|
888
|
+
// they are made out of a `Combinator` (see combinator rule),
|
889
|
+
// and an element name, such as a tag a class, or `*`.
|
890
|
+
//
|
891
|
+
element: function () {
|
892
|
+
var e, t;
|
893
|
+
|
894
|
+
c = $(this.combinator);
|
895
|
+
e = $(/^[.#:]?[\w-]+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/);
|
896
|
+
|
897
|
+
if (e) { return new(tree.Element)(c, e) }
|
898
|
+
},
|
899
|
+
|
900
|
+
//
|
901
|
+
// Combinators combine elements together, in a Selector.
|
902
|
+
//
|
903
|
+
// Because our parser isn't white-space sensitive, special care
|
904
|
+
// has to be taken, when parsing the descendant combinator, ` `,
|
905
|
+
// as it's an empty space. We have to check the previous character
|
906
|
+
// in the input, to see if it's a ` ` character. More info on how
|
907
|
+
// we deal with this in *combinator.js*.
|
908
|
+
//
|
909
|
+
combinator: function () {
|
910
|
+
var match, c = input.charAt(i);
|
911
|
+
|
912
|
+
if (c === '>' || c === '&' || c === '+' || c === '~') {
|
913
|
+
i++;
|
914
|
+
while (input.charAt(i) === ' ') { i++ }
|
915
|
+
return new(tree.Combinator)(c);
|
916
|
+
} else if (c === ':' && input.charAt(i + 1) === ':') {
|
917
|
+
i += 2;
|
918
|
+
while (input.charAt(i) === ' ') { i++ }
|
919
|
+
return new(tree.Combinator)('::');
|
920
|
+
} else if (input.charAt(i - 1) === ' ') {
|
921
|
+
return new(tree.Combinator)(" ");
|
922
|
+
} else {
|
923
|
+
return new(tree.Combinator)(null);
|
924
|
+
}
|
925
|
+
},
|
926
|
+
|
927
|
+
//
|
928
|
+
// A CSS Selector
|
929
|
+
//
|
930
|
+
// .class > div + h1
|
931
|
+
// li a:hover
|
932
|
+
//
|
933
|
+
// Selectors are made out of one or more Elements, see above.
|
934
|
+
//
|
935
|
+
selector: function () {
|
936
|
+
var sel, e, elements = [], c, match;
|
937
|
+
|
938
|
+
while (e = $(this.element)) {
|
939
|
+
c = input.charAt(i);
|
940
|
+
elements.push(e)
|
941
|
+
if (c === '{' || c === '}' || c === ';' || c === ',') { break }
|
942
|
+
}
|
943
|
+
|
944
|
+
if (elements.length > 0) { return new(tree.Selector)(elements) }
|
945
|
+
},
|
946
|
+
tag: function () {
|
947
|
+
return $(/^[a-zA-Z][a-zA-Z-]*[0-9]?/) || $('*');
|
948
|
+
},
|
949
|
+
attribute: function () {
|
950
|
+
var attr = '', key, val, op;
|
951
|
+
|
952
|
+
if (! $('[')) return;
|
953
|
+
|
954
|
+
if (key = $(/^[a-zA-Z-]+/) || $(this.entities.quoted)) {
|
955
|
+
if ((op = $(/^[|~*$^]?=/)) &&
|
956
|
+
(val = $(this.entities.quoted) || $(/^[\w-]+/))) {
|
957
|
+
attr = [key, op, val.toCSS ? val.toCSS() : val].join('');
|
958
|
+
} else { attr = key }
|
959
|
+
}
|
960
|
+
|
961
|
+
if (! $(']')) return;
|
962
|
+
|
963
|
+
if (attr) { return "[" + attr + "]" }
|
964
|
+
},
|
965
|
+
|
966
|
+
//
|
967
|
+
// The `block` rule is used by `ruleset` and `mixin.definition`.
|
968
|
+
// It's a wrapper around the `primary` rule, with added `{}`.
|
969
|
+
//
|
970
|
+
block: function () {
|
971
|
+
var content;
|
972
|
+
|
973
|
+
if ($('{') && (content = $(this.primary)) && $('}')) {
|
974
|
+
return content;
|
975
|
+
}
|
976
|
+
},
|
977
|
+
|
978
|
+
//
|
979
|
+
// div, .class, body > p {...}
|
980
|
+
//
|
981
|
+
ruleset: function () {
|
982
|
+
var selectors = [], s, rules, match;
|
983
|
+
save();
|
984
|
+
|
985
|
+
if (match = /^([.#: \w-]+)[\s\n]*\{/.exec(chunks[j])) {
|
986
|
+
i += match[0].length - 1;
|
987
|
+
selectors = [new(tree.Selector)([new(tree.Element)(null, match[1])])];
|
988
|
+
} else {
|
989
|
+
while (s = $(this.selector)) {
|
990
|
+
selectors.push(s);
|
991
|
+
if (! $(',')) { break }
|
992
|
+
}
|
993
|
+
if (s) $(this.comment);
|
994
|
+
}
|
995
|
+
|
996
|
+
if (selectors.length > 0 && (rules = $(this.block))) {
|
997
|
+
return new(tree.Ruleset)(selectors, rules);
|
998
|
+
} else {
|
999
|
+
// Backtrack
|
1000
|
+
furthest = i;
|
1001
|
+
restore();
|
1002
|
+
}
|
1003
|
+
},
|
1004
|
+
rule: function () {
|
1005
|
+
var value, c = input.charAt(i), important;
|
1006
|
+
save();
|
1007
|
+
|
1008
|
+
if (c === '.' || c === '#' || c === '&') { return }
|
1009
|
+
|
1010
|
+
if (name = $(this.variable) || $(this.property)) {
|
1011
|
+
if ((name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) {
|
1012
|
+
i += match[0].length - 1;
|
1013
|
+
value = new(tree.Anonymous)(match[1]);
|
1014
|
+
} else if (name === "font") {
|
1015
|
+
value = $(this.font);
|
1016
|
+
} else {
|
1017
|
+
value = $(this.value);
|
1018
|
+
}
|
1019
|
+
important = $(this.important);
|
1020
|
+
|
1021
|
+
if (value && $(this.end)) {
|
1022
|
+
return new(tree.Rule)(name, value, important, memo);
|
1023
|
+
} else {
|
1024
|
+
furthest = i;
|
1025
|
+
restore();
|
1026
|
+
}
|
1027
|
+
}
|
1028
|
+
},
|
1029
|
+
|
1030
|
+
//
|
1031
|
+
// An @import directive
|
1032
|
+
//
|
1033
|
+
// @import "lib";
|
1034
|
+
//
|
1035
|
+
// Depending on our environemnt, importing is done differently:
|
1036
|
+
// In the browser, it's an XHR request, in Node, it would be a
|
1037
|
+
// file-system operation. The function used for importing is
|
1038
|
+
// stored in `import`, which we pass to the Import constructor.
|
1039
|
+
//
|
1040
|
+
"import": function () {
|
1041
|
+
var path;
|
1042
|
+
if ($(/^@import\s+/) &&
|
1043
|
+
(path = $(this.entities.quoted) || $(this.entities.url)) &&
|
1044
|
+
$(';')) {
|
1045
|
+
return new(tree.Import)(path, imports);
|
1046
|
+
}
|
1047
|
+
},
|
1048
|
+
|
1049
|
+
//
|
1050
|
+
// A CSS Directive
|
1051
|
+
//
|
1052
|
+
// @charset "utf-8";
|
1053
|
+
//
|
1054
|
+
directive: function () {
|
1055
|
+
var name, value, rules, types;
|
1056
|
+
|
1057
|
+
if (input.charAt(i) !== '@') return;
|
1058
|
+
|
1059
|
+
if (value = $(this['import'])) {
|
1060
|
+
return value;
|
1061
|
+
} else if (name = $(/^@media|@page/)) {
|
1062
|
+
types = $(/^[^{]+/).trim();
|
1063
|
+
if (rules = $(this.block)) {
|
1064
|
+
return new(tree.Directive)(name + " " + types, rules);
|
1065
|
+
}
|
1066
|
+
} else if (name = $(/^@[-a-z]+/)) {
|
1067
|
+
if (name === '@font-face') {
|
1068
|
+
if (rules = $(this.block)) {
|
1069
|
+
return new(tree.Directive)(name, rules);
|
1070
|
+
}
|
1071
|
+
} else if ((value = $(this.entity)) && $(';')) {
|
1072
|
+
return new(tree.Directive)(name, value);
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
},
|
1076
|
+
font: function () {
|
1077
|
+
var value = [], expression = [], weight, shorthand, font, e;
|
1078
|
+
|
1079
|
+
while (e = $(this.shorthand) || $(this.entity)) {
|
1080
|
+
expression.push(e);
|
1081
|
+
}
|
1082
|
+
value.push(new(tree.Expression)(expression));
|
1083
|
+
|
1084
|
+
if ($(',')) {
|
1085
|
+
while (e = $(this.expression)) {
|
1086
|
+
value.push(e);
|
1087
|
+
if (! $(',')) { break }
|
1088
|
+
}
|
1089
|
+
}
|
1090
|
+
return new(tree.Value)(value);
|
1091
|
+
},
|
1092
|
+
|
1093
|
+
//
|
1094
|
+
// A Value is a comma-delimited list of Expressions
|
1095
|
+
//
|
1096
|
+
// font-family: Baskerville, Georgia, serif;
|
1097
|
+
//
|
1098
|
+
// In a Rule, a Value represents everything after the `:`,
|
1099
|
+
// and before the `;`.
|
1100
|
+
//
|
1101
|
+
value: function () {
|
1102
|
+
var e, expressions = [], important;
|
1103
|
+
|
1104
|
+
while (e = $(this.expression)) {
|
1105
|
+
expressions.push(e);
|
1106
|
+
if (! $(',')) { break }
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
if (expressions.length > 0) {
|
1110
|
+
return new(tree.Value)(expressions);
|
1111
|
+
}
|
1112
|
+
},
|
1113
|
+
important: function () {
|
1114
|
+
if (input.charAt(i) === '!') {
|
1115
|
+
return $(/^! *important/);
|
1116
|
+
}
|
1117
|
+
},
|
1118
|
+
sub: function () {
|
1119
|
+
var e;
|
1120
|
+
|
1121
|
+
if ($('(') && (e = $(this.expression)) && $(')')) {
|
1122
|
+
return e;
|
1123
|
+
}
|
1124
|
+
},
|
1125
|
+
multiplication: function () {
|
1126
|
+
var m, a, op, operation;
|
1127
|
+
if (m = $(this.operand)) {
|
1128
|
+
while ((op = ($('/') || $('*'))) && (a = $(this.operand))) {
|
1129
|
+
operation = new(tree.Operation)(op, [operation || m, a]);
|
1130
|
+
}
|
1131
|
+
return operation || m;
|
1132
|
+
}
|
1133
|
+
},
|
1134
|
+
addition: function () {
|
1135
|
+
var m, a, op, operation;
|
1136
|
+
if (m = $(this.multiplication)) {
|
1137
|
+
while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) &&
|
1138
|
+
(a = $(this.multiplication))) {
|
1139
|
+
operation = new(tree.Operation)(op, [operation || m, a]);
|
1140
|
+
}
|
1141
|
+
return operation || m;
|
1142
|
+
}
|
1143
|
+
},
|
1144
|
+
|
1145
|
+
//
|
1146
|
+
// An operand is anything that can be part of an operation,
|
1147
|
+
// such as a Color, or a Variable
|
1148
|
+
//
|
1149
|
+
operand: function () {
|
1150
|
+
return $(this.sub) || $(this.entities.dimension) ||
|
1151
|
+
$(this.entities.color) || $(this.entities.variable) ||
|
1152
|
+
$(this.entities.call);
|
1153
|
+
},
|
1154
|
+
|
1155
|
+
//
|
1156
|
+
// Expressions either represent mathematical operations,
|
1157
|
+
// or white-space delimited Entities.
|
1158
|
+
//
|
1159
|
+
// 1px solid black
|
1160
|
+
// @var * 2
|
1161
|
+
//
|
1162
|
+
expression: function () {
|
1163
|
+
var e, delim, entities = [], d;
|
1164
|
+
|
1165
|
+
while (e = $(this.addition) || $(this.entity)) {
|
1166
|
+
entities.push(e);
|
1167
|
+
}
|
1168
|
+
if (entities.length > 0) {
|
1169
|
+
return new(tree.Expression)(entities);
|
1170
|
+
}
|
1171
|
+
},
|
1172
|
+
property: function () {
|
1173
|
+
var name;
|
1174
|
+
|
1175
|
+
if (name = $(/^(\*?-?[-a-z_0-9]+)\s*:/)) {
|
1176
|
+
return name[1];
|
1177
|
+
}
|
1178
|
+
}
|
1179
|
+
}
|
1180
|
+
};
|
1181
|
+
};
|
1182
|
+
|
1183
|
+
if (typeof(window) !== 'undefined') {
|
1184
|
+
//
|
1185
|
+
// Used by `@import` directives
|
1186
|
+
//
|
1187
|
+
less.Parser.importer = function (path, paths, callback) {
|
1188
|
+
if (path.charAt(0) !== '/' && paths.length > 0) {
|
1189
|
+
path = paths[0] + path;
|
1190
|
+
}
|
1191
|
+
// We pass `true` as 3rd argument, to force the reload of the import.
|
1192
|
+
// This is so we can get the syntax tree as opposed to just the CSS output,
|
1193
|
+
// as we need this to evaluate the current stylesheet.
|
1194
|
+
loadStyleSheet({ href: path, title: path }, callback, true);
|
1195
|
+
};
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
(function (tree) {
|
1199
|
+
|
1200
|
+
tree.functions = {
|
1201
|
+
rgb: function (r, g, b) {
|
1202
|
+
return this.rgba(r, g, b, 1.0);
|
1203
|
+
},
|
1204
|
+
rgba: function (r, g, b, a) {
|
1205
|
+
var rgb = [r, g, b].map(function (c) { return number(c) }),
|
1206
|
+
a = number(a);
|
1207
|
+
return new(tree.Color)(rgb, a);
|
1208
|
+
},
|
1209
|
+
hsl: function (h, s, l) {
|
1210
|
+
return this.hsla(h, s, l, 1.0);
|
1211
|
+
},
|
1212
|
+
hsla: function (h, s, l, a) {
|
1213
|
+
h = (number(h) % 360) / 360;
|
1214
|
+
s = number(s); l = number(l); a = number(a);
|
1215
|
+
|
1216
|
+
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
1217
|
+
var m1 = l * 2 - m2;
|
1218
|
+
|
1219
|
+
return this.rgba(hue(h + 1/3) * 255,
|
1220
|
+
hue(h) * 255,
|
1221
|
+
hue(h - 1/3) * 255,
|
1222
|
+
a);
|
1223
|
+
|
1224
|
+
function hue(h) {
|
1225
|
+
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
|
1226
|
+
if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
|
1227
|
+
else if (h * 2 < 1) return m2;
|
1228
|
+
else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6;
|
1229
|
+
else return m1;
|
1230
|
+
}
|
1231
|
+
},
|
1232
|
+
hue: function (color) {
|
1233
|
+
return new(tree.Dimension)(Math.round(color.toHSL().h));
|
1234
|
+
},
|
1235
|
+
saturation: function (color) {
|
1236
|
+
return new(tree.Dimension)(Math.round(color.toHSL().s * 100), '%');
|
1237
|
+
},
|
1238
|
+
lightness: function (color) {
|
1239
|
+
return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%');
|
1240
|
+
},
|
1241
|
+
alpha: function (color) {
|
1242
|
+
return new(tree.Dimension)(color.toHSL().a);
|
1243
|
+
},
|
1244
|
+
saturate: function (color, amount) {
|
1245
|
+
var hsl = color.toHSL();
|
1246
|
+
|
1247
|
+
hsl.s += amount.value / 100;
|
1248
|
+
hsl.s = clamp(hsl.s);
|
1249
|
+
return hsla(hsl);
|
1250
|
+
},
|
1251
|
+
desaturate: function (color, amount) {
|
1252
|
+
var hsl = color.toHSL();
|
1253
|
+
|
1254
|
+
hsl.s -= amount.value / 100;
|
1255
|
+
hsl.s = clamp(hsl.s);
|
1256
|
+
return hsla(hsl);
|
1257
|
+
},
|
1258
|
+
lighten: function (color, amount) {
|
1259
|
+
var hsl = color.toHSL();
|
1260
|
+
|
1261
|
+
hsl.l += amount.value / 100;
|
1262
|
+
hsl.l = clamp(hsl.l);
|
1263
|
+
return hsla(hsl);
|
1264
|
+
},
|
1265
|
+
darken: function (color, amount) {
|
1266
|
+
var hsl = color.toHSL();
|
1267
|
+
|
1268
|
+
hsl.l -= amount.value / 100;
|
1269
|
+
hsl.l = clamp(hsl.l);
|
1270
|
+
return hsla(hsl);
|
1271
|
+
},
|
1272
|
+
spin: function (color, amount) {
|
1273
|
+
var hsl = color.toHSL();
|
1274
|
+
var hue = (hsl.h + amount.value) % 360;
|
1275
|
+
|
1276
|
+
hsl.h = hue < 0 ? 360 + hue : hue;
|
1277
|
+
|
1278
|
+
return hsla(hsl);
|
1279
|
+
},
|
1280
|
+
greyscale: function (color) {
|
1281
|
+
return this.desaturate(color, new(tree.Dimension)(100));
|
1282
|
+
},
|
1283
|
+
e: function (str) {
|
1284
|
+
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
|
1285
|
+
},
|
1286
|
+
'%': function (quoted /* arg, arg, ...*/) {
|
1287
|
+
var args = Array.prototype.slice.call(arguments, 1),
|
1288
|
+
str = quoted.value;
|
1289
|
+
|
1290
|
+
for (var i = 0; i < args.length; i++) {
|
1291
|
+
str = str.replace(/%s/, args[i].value)
|
1292
|
+
.replace(/%[da]/, args[i].toCSS());
|
1293
|
+
}
|
1294
|
+
str = str.replace(/%%/g, '%');
|
1295
|
+
return new(tree.Quoted)('"' + str + '"', str);
|
1296
|
+
}
|
1297
|
+
};
|
1298
|
+
|
1299
|
+
function hsla(hsla) {
|
1300
|
+
return tree.functions.hsla(hsla.h, hsla.s, hsla.l, hsla.a);
|
1301
|
+
}
|
1302
|
+
|
1303
|
+
function number(n) {
|
1304
|
+
if (n instanceof tree.Dimension) {
|
1305
|
+
return parseFloat(n.unit == '%' ? n.value / 100 : n.value);
|
1306
|
+
} else if (typeof(n) === 'number') {
|
1307
|
+
return n;
|
1308
|
+
} else {
|
1309
|
+
throw {
|
1310
|
+
error: "RuntimeError",
|
1311
|
+
message: "color functions take numbers as parameters"
|
1312
|
+
};
|
1313
|
+
}
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
function clamp(val) {
|
1317
|
+
return Math.min(1, Math.max(0, val));
|
1318
|
+
}
|
1319
|
+
|
1320
|
+
})(require('less/tree'));
|
1321
|
+
(function (tree) {
|
1322
|
+
|
1323
|
+
tree.Alpha = function (val) {
|
1324
|
+
this.value = val;
|
1325
|
+
};
|
1326
|
+
tree.Alpha.prototype = {
|
1327
|
+
toCSS: function () {
|
1328
|
+
return "alpha(opacity=" +
|
1329
|
+
(this.value.toCSS ? this.value.toCSS() : this.value) + ")";
|
1330
|
+
},
|
1331
|
+
eval: function () { return this }
|
1332
|
+
};
|
1333
|
+
|
1334
|
+
})(require('less/tree'));
|
1335
|
+
(function (tree) {
|
1336
|
+
|
1337
|
+
tree.Anonymous = function (string) {
|
1338
|
+
this.value = string.value || string;
|
1339
|
+
};
|
1340
|
+
tree.Anonymous.prototype = {
|
1341
|
+
toCSS: function () {
|
1342
|
+
return this.value;
|
1343
|
+
},
|
1344
|
+
eval: function () { return this }
|
1345
|
+
};
|
1346
|
+
|
1347
|
+
})(require('less/tree'));
|
1348
|
+
(function (tree) {
|
1349
|
+
|
1350
|
+
//
|
1351
|
+
// A function call node.
|
1352
|
+
//
|
1353
|
+
tree.Call = function (name, args) {
|
1354
|
+
this.name = name;
|
1355
|
+
this.args = args;
|
1356
|
+
};
|
1357
|
+
tree.Call.prototype = {
|
1358
|
+
//
|
1359
|
+
// When evaluating a function call,
|
1360
|
+
// we either find the function in `tree.functions` [1],
|
1361
|
+
// in which case we call it, passing the evaluated arguments,
|
1362
|
+
// or we simply print it out as it appeared originally [2].
|
1363
|
+
//
|
1364
|
+
// The *functions.js* file contains the built-in functions.
|
1365
|
+
//
|
1366
|
+
// The reason why we evaluate the arguments, is in the case where
|
1367
|
+
// we try to pass a variable to a function, like: `saturate(@color)`.
|
1368
|
+
// The function should receive the value, not the variable.
|
1369
|
+
//
|
1370
|
+
eval: function (env) {
|
1371
|
+
var args = this.args.map(function (a) { return a.eval(env) });
|
1372
|
+
|
1373
|
+
if (this.name in tree.functions) { // 1.
|
1374
|
+
return tree.functions[this.name].apply(tree.functions, args);
|
1375
|
+
} else { // 2.
|
1376
|
+
return new(tree.Anonymous)(this.name +
|
1377
|
+
"(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");
|
1378
|
+
}
|
1379
|
+
},
|
1380
|
+
|
1381
|
+
toCSS: function (env) {
|
1382
|
+
return this.eval(env).toCSS();
|
1383
|
+
}
|
1384
|
+
};
|
1385
|
+
|
1386
|
+
})(require('less/tree'));
|
1387
|
+
(function (tree) {
|
1388
|
+
//
|
1389
|
+
// RGB Colors - #ff0014, #eee
|
1390
|
+
//
|
1391
|
+
tree.Color = function (rgb, a) {
|
1392
|
+
//
|
1393
|
+
// The end goal here, is to parse the arguments
|
1394
|
+
// into an integer triplet, such as `128, 255, 0`
|
1395
|
+
//
|
1396
|
+
// This facilitates operations and conversions.
|
1397
|
+
//
|
1398
|
+
if (Array.isArray(rgb)) {
|
1399
|
+
this.rgb = rgb;
|
1400
|
+
} else if (rgb.length == 6) {
|
1401
|
+
this.rgb = rgb.match(/.{2}/g).map(function (c) {
|
1402
|
+
return parseInt(c, 16);
|
1403
|
+
});
|
1404
|
+
} else {
|
1405
|
+
this.rgb = rgb.split('').map(function (c) {
|
1406
|
+
return parseInt(c + c, 16);
|
1407
|
+
});
|
1408
|
+
}
|
1409
|
+
this.alpha = typeof(a) === 'number' ? a : 1;
|
1410
|
+
};
|
1411
|
+
tree.Color.prototype = {
|
1412
|
+
eval: function () { return this },
|
1413
|
+
|
1414
|
+
//
|
1415
|
+
// If we have some transparency, the only way to represent it
|
1416
|
+
// is via `rgba`. Otherwise, we use the hex representation,
|
1417
|
+
// which has better compatibility with older browsers.
|
1418
|
+
// Values are capped between `0` and `255`, rounded and zero-padded.
|
1419
|
+
//
|
1420
|
+
toCSS: function () {
|
1421
|
+
if (this.alpha < 1.0) {
|
1422
|
+
return "rgba(" + this.rgb.map(function (c) {
|
1423
|
+
return Math.round(c);
|
1424
|
+
}).concat(this.alpha).join(', ') + ")";
|
1425
|
+
} else {
|
1426
|
+
return '#' + this.rgb.map(function (i) {
|
1427
|
+
i = Math.round(i);
|
1428
|
+
i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16);
|
1429
|
+
return i.length === 1 ? '0' + i : i;
|
1430
|
+
}).join('');
|
1431
|
+
}
|
1432
|
+
},
|
1433
|
+
|
1434
|
+
//
|
1435
|
+
// Operations have to be done per-channel, if not,
|
1436
|
+
// channels will spill onto each other. Once we have
|
1437
|
+
// our result, in the form of an integer triplet,
|
1438
|
+
// we create a new Color node to hold the result.
|
1439
|
+
//
|
1440
|
+
operate: function (op, other) {
|
1441
|
+
var result = [];
|
1442
|
+
|
1443
|
+
if (! (other instanceof tree.Color)) {
|
1444
|
+
other = other.toColor();
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
for (var c = 0; c < 3; c++) {
|
1448
|
+
result[c] = tree.operate(op, this.rgb[c], other.rgb[c]);
|
1449
|
+
}
|
1450
|
+
return new(tree.Color)(result);
|
1451
|
+
},
|
1452
|
+
|
1453
|
+
toHSL: function () {
|
1454
|
+
var r = this.rgb[0] / 255,
|
1455
|
+
g = this.rgb[1] / 255,
|
1456
|
+
b = this.rgb[2] / 255,
|
1457
|
+
a = this.alpha;
|
1458
|
+
|
1459
|
+
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
1460
|
+
var h, s, l = (max + min) / 2, d = max - min;
|
1461
|
+
|
1462
|
+
if (max === min) {
|
1463
|
+
h = s = 0;
|
1464
|
+
} else {
|
1465
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
1466
|
+
|
1467
|
+
switch (max) {
|
1468
|
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
1469
|
+
case g: h = (b - r) / d + 2; break;
|
1470
|
+
case b: h = (r - g) / d + 4; break;
|
1471
|
+
}
|
1472
|
+
h /= 6;
|
1473
|
+
}
|
1474
|
+
return { h: h * 360, s: s, l: l, a: a };
|
1475
|
+
}
|
1476
|
+
};
|
1477
|
+
|
1478
|
+
|
1479
|
+
})(require('less/tree'));
|
1480
|
+
(function (tree) {
|
1481
|
+
|
1482
|
+
tree.Comment = function (value, silent) {
|
1483
|
+
this.value = value;
|
1484
|
+
this.silent = !!silent;
|
1485
|
+
};
|
1486
|
+
tree.Comment.prototype = {
|
1487
|
+
toCSS: function (env) {
|
1488
|
+
return env.compress ? '' : this.value;
|
1489
|
+
},
|
1490
|
+
eval: function () { return this }
|
1491
|
+
};
|
1492
|
+
|
1493
|
+
})(require('less/tree'));
|
1494
|
+
(function (tree) {
|
1495
|
+
|
1496
|
+
//
|
1497
|
+
// A number with a unit
|
1498
|
+
//
|
1499
|
+
tree.Dimension = function (value, unit) {
|
1500
|
+
this.value = parseFloat(value);
|
1501
|
+
this.unit = unit || null;
|
1502
|
+
};
|
1503
|
+
|
1504
|
+
tree.Dimension.prototype = {
|
1505
|
+
eval: function () { return this },
|
1506
|
+
toColor: function () {
|
1507
|
+
return new(tree.Color)([this.value, this.value, this.value]);
|
1508
|
+
},
|
1509
|
+
toCSS: function () {
|
1510
|
+
var css = this.value + this.unit;
|
1511
|
+
return css;
|
1512
|
+
},
|
1513
|
+
|
1514
|
+
// In an operation between two Dimensions,
|
1515
|
+
// we default to the first Dimension's unit,
|
1516
|
+
// so `1px + 2em` will yield `3px`.
|
1517
|
+
// In the future, we could implement some unit
|
1518
|
+
// conversions such that `100cm + 10mm` would yield
|
1519
|
+
// `101cm`.
|
1520
|
+
operate: function (op, other) {
|
1521
|
+
return new(tree.Dimension)
|
1522
|
+
(tree.operate(op, this.value, other.value),
|
1523
|
+
this.unit || other.unit);
|
1524
|
+
}
|
1525
|
+
};
|
1526
|
+
|
1527
|
+
})(require('less/tree'));
|
1528
|
+
(function (tree) {
|
1529
|
+
|
1530
|
+
tree.Directive = function (name, value) {
|
1531
|
+
this.name = name;
|
1532
|
+
if (Array.isArray(value)) {
|
1533
|
+
this.ruleset = new(tree.Ruleset)([], value);
|
1534
|
+
} else {
|
1535
|
+
this.value = value;
|
1536
|
+
}
|
1537
|
+
};
|
1538
|
+
tree.Directive.prototype = {
|
1539
|
+
toCSS: function (ctx, env) {
|
1540
|
+
if (this.ruleset) {
|
1541
|
+
this.ruleset.root = true;
|
1542
|
+
return this.name + (env.compress ? '{' : ' {\n ') +
|
1543
|
+
this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
|
1544
|
+
(env.compress ? '}': '\n}\n');
|
1545
|
+
} else {
|
1546
|
+
return this.name + ' ' + this.value.toCSS() + ';\n';
|
1547
|
+
}
|
1548
|
+
},
|
1549
|
+
eval: function (env) {
|
1550
|
+
env.frames.unshift(this);
|
1551
|
+
this.ruleset = this.ruleset && this.ruleset.eval(env);
|
1552
|
+
env.frames.shift();
|
1553
|
+
return this;
|
1554
|
+
},
|
1555
|
+
variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
|
1556
|
+
find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
|
1557
|
+
rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }
|
1558
|
+
};
|
1559
|
+
|
1560
|
+
})(require('less/tree'));
|
1561
|
+
(function (tree) {
|
1562
|
+
|
1563
|
+
tree.Element = function (combinator, value) {
|
1564
|
+
this.combinator = combinator instanceof tree.Combinator ?
|
1565
|
+
combinator : new(tree.Combinator)(combinator);
|
1566
|
+
this.value = value.trim();
|
1567
|
+
};
|
1568
|
+
tree.Element.prototype.toCSS = function (env) {
|
1569
|
+
return this.combinator.toCSS(env || {}) + this.value;
|
1570
|
+
};
|
1571
|
+
|
1572
|
+
tree.Combinator = function (value) {
|
1573
|
+
if (value === ' ') {
|
1574
|
+
this.value = ' ';
|
1575
|
+
} else {
|
1576
|
+
this.value = value ? value.trim() : "";
|
1577
|
+
}
|
1578
|
+
};
|
1579
|
+
tree.Combinator.prototype.toCSS = function (env) {
|
1580
|
+
return {
|
1581
|
+
'' : '',
|
1582
|
+
' ' : ' ',
|
1583
|
+
'&' : '',
|
1584
|
+
':' : ' :',
|
1585
|
+
'::': '::',
|
1586
|
+
'+' : env.compress ? '+' : ' + ',
|
1587
|
+
'~' : env.compress ? '~' : ' ~ ',
|
1588
|
+
'>' : env.compress ? '>' : ' > '
|
1589
|
+
}[this.value];
|
1590
|
+
};
|
1591
|
+
|
1592
|
+
})(require('less/tree'));
|
1593
|
+
(function (tree) {
|
1594
|
+
|
1595
|
+
tree.Expression = function (value) { this.value = value };
|
1596
|
+
tree.Expression.prototype = {
|
1597
|
+
eval: function (env) {
|
1598
|
+
if (this.value.length > 1) {
|
1599
|
+
return new(tree.Expression)(this.value.map(function (e) {
|
1600
|
+
return e.eval(env);
|
1601
|
+
}));
|
1602
|
+
} else {
|
1603
|
+
return this.value[0].eval(env);
|
1604
|
+
}
|
1605
|
+
},
|
1606
|
+
toCSS: function (env) {
|
1607
|
+
return this.value.map(function (e) {
|
1608
|
+
return e.toCSS(env);
|
1609
|
+
}).join(' ');
|
1610
|
+
}
|
1611
|
+
};
|
1612
|
+
|
1613
|
+
})(require('less/tree'));
|
1614
|
+
(function (tree) {
|
1615
|
+
//
|
1616
|
+
// CSS @import node
|
1617
|
+
//
|
1618
|
+
// The general strategy here is that we don't want to wait
|
1619
|
+
// for the parsing to be completed, before we start importing
|
1620
|
+
// the file. That's because in the context of a browser,
|
1621
|
+
// most of the time will be spent waiting for the server to respond.
|
1622
|
+
//
|
1623
|
+
// On creation, we push the import path to our import queue, though
|
1624
|
+
// `import,push`, we also pass it a callback, which it'll call once
|
1625
|
+
// the file has been fetched, and parsed.
|
1626
|
+
//
|
1627
|
+
tree.Import = function (path, imports) {
|
1628
|
+
var that = this;
|
1629
|
+
|
1630
|
+
this._path = path;
|
1631
|
+
|
1632
|
+
// The '.less' extension is optional
|
1633
|
+
if (path instanceof tree.Quoted) {
|
1634
|
+
this.path = /\.(le?|c)ss$/.test(path.value) ? path.value : path.value + '.less';
|
1635
|
+
} else {
|
1636
|
+
this.path = path.value.value || path.value;
|
1637
|
+
}
|
1638
|
+
|
1639
|
+
this.css = /css$/.test(this.path);
|
1640
|
+
|
1641
|
+
// Only pre-compile .less files
|
1642
|
+
if (! this.css) {
|
1643
|
+
imports.push(this.path, function (root) {
|
1644
|
+
if (! root) {
|
1645
|
+
throw new(Error)("Error parsing " + that.path);
|
1646
|
+
}
|
1647
|
+
that.root = root;
|
1648
|
+
});
|
1649
|
+
}
|
1650
|
+
};
|
1651
|
+
|
1652
|
+
//
|
1653
|
+
// The actual import node doesn't return anything, when converted to CSS.
|
1654
|
+
// The reason is that it's used at the evaluation stage, so that the rules
|
1655
|
+
// it imports can be treated like any other rules.
|
1656
|
+
//
|
1657
|
+
// In `eval`, we make sure all Import nodes get evaluated, recursively, so
|
1658
|
+
// we end up with a flat structure, which can easily be imported in the parent
|
1659
|
+
// ruleset.
|
1660
|
+
//
|
1661
|
+
tree.Import.prototype = {
|
1662
|
+
toCSS: function () {
|
1663
|
+
if (this.css) {
|
1664
|
+
return "@import " + this._path.toCSS() + ';\n';
|
1665
|
+
} else {
|
1666
|
+
return "";
|
1667
|
+
}
|
1668
|
+
},
|
1669
|
+
eval: function (env) {
|
1670
|
+
var ruleset;
|
1671
|
+
|
1672
|
+
if (this.css) {
|
1673
|
+
return this;
|
1674
|
+
} else {
|
1675
|
+
ruleset = new(tree.Ruleset)(null, this.root.rules.slice(0));
|
1676
|
+
|
1677
|
+
for (var i = 0; i < ruleset.rules.length; i++) {
|
1678
|
+
if (ruleset.rules[i] instanceof tree.Import) {
|
1679
|
+
Array.prototype
|
1680
|
+
.splice
|
1681
|
+
.apply(ruleset.rules,
|
1682
|
+
[i, 1].concat(ruleset.rules[i].eval(env)));
|
1683
|
+
}
|
1684
|
+
}
|
1685
|
+
return ruleset.rules;
|
1686
|
+
}
|
1687
|
+
}
|
1688
|
+
};
|
1689
|
+
|
1690
|
+
})(require('less/tree'));
|
1691
|
+
(function (tree) {
|
1692
|
+
|
1693
|
+
tree.JavaScript = function (string, index) {
|
1694
|
+
this.expression = string;
|
1695
|
+
this.index = index;
|
1696
|
+
};
|
1697
|
+
tree.JavaScript.prototype = {
|
1698
|
+
toCSS: function () {
|
1699
|
+
return JSON.stringify(this.evaluated);
|
1700
|
+
},
|
1701
|
+
eval: function (env) {
|
1702
|
+
var result,
|
1703
|
+
expression = new(Function)('return (' + this.expression + ')'),
|
1704
|
+
context = {};
|
1705
|
+
|
1706
|
+
for (var k in env.frames[0].variables()) {
|
1707
|
+
context[k.slice(1)] = {
|
1708
|
+
value: env.frames[0].variables()[k].value,
|
1709
|
+
toJS: function () {
|
1710
|
+
return this.value.eval(env).toCSS();
|
1711
|
+
}
|
1712
|
+
};
|
1713
|
+
}
|
1714
|
+
|
1715
|
+
try {
|
1716
|
+
this.evaluated = expression.call(context);
|
1717
|
+
} catch (e) {
|
1718
|
+
throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" ,
|
1719
|
+
index: this.index };
|
1720
|
+
}
|
1721
|
+
return this;
|
1722
|
+
}
|
1723
|
+
};
|
1724
|
+
|
1725
|
+
})(require('less/tree'));
|
1726
|
+
|
1727
|
+
(function (tree) {
|
1728
|
+
|
1729
|
+
tree.Keyword = function (value) { this.value = value };
|
1730
|
+
tree.Keyword.prototype = {
|
1731
|
+
eval: function () { return this },
|
1732
|
+
toCSS: function () { return this.value }
|
1733
|
+
};
|
1734
|
+
|
1735
|
+
})(require('less/tree'));
|
1736
|
+
(function (tree) {
|
1737
|
+
|
1738
|
+
tree.mixin = {};
|
1739
|
+
tree.mixin.Call = function (elements, args, index) {
|
1740
|
+
this.selector = new(tree.Selector)(elements);
|
1741
|
+
this.arguments = args;
|
1742
|
+
this.index = index;
|
1743
|
+
};
|
1744
|
+
tree.mixin.Call.prototype = {
|
1745
|
+
eval: function (env) {
|
1746
|
+
var mixins, rules = [], match = false;
|
1747
|
+
|
1748
|
+
for (var i = 0; i < env.frames.length; i++) {
|
1749
|
+
if ((mixins = env.frames[i].find(this.selector)).length > 0) {
|
1750
|
+
for (var m = 0; m < mixins.length; m++) {
|
1751
|
+
if (mixins[m].match(this.arguments, env)) {
|
1752
|
+
try {
|
1753
|
+
Array.prototype.push.apply(
|
1754
|
+
rules, mixins[m].eval(env, this.arguments).rules);
|
1755
|
+
match = true;
|
1756
|
+
} catch (e) {
|
1757
|
+
throw { message: e.message, index: e.index, stack: e.stack, call: this.index };
|
1758
|
+
}
|
1759
|
+
}
|
1760
|
+
}
|
1761
|
+
if (match) {
|
1762
|
+
return rules;
|
1763
|
+
} else {
|
1764
|
+
throw { message: 'No matching definition was found for `' +
|
1765
|
+
this.selector.toCSS().trim() + '(' +
|
1766
|
+
this.arguments.map(function (a) {
|
1767
|
+
return a.toCSS();
|
1768
|
+
}).join(', ') + ")`",
|
1769
|
+
index: this.index };
|
1770
|
+
}
|
1771
|
+
}
|
1772
|
+
}
|
1773
|
+
throw { message: this.selector.toCSS().trim() + " is undefined",
|
1774
|
+
index: this.index };
|
1775
|
+
}
|
1776
|
+
};
|
1777
|
+
|
1778
|
+
tree.mixin.Definition = function (name, params, rules) {
|
1779
|
+
this.name = name;
|
1780
|
+
this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])];
|
1781
|
+
this.params = params;
|
1782
|
+
this.arity = params.length;
|
1783
|
+
this.rules = rules;
|
1784
|
+
this._lookups = {};
|
1785
|
+
this.required = params.reduce(function (count, p) {
|
1786
|
+
if (p.name && !p.value) { return count + 1 }
|
1787
|
+
else { return count }
|
1788
|
+
}, 0);
|
1789
|
+
this.parent = tree.Ruleset.prototype;
|
1790
|
+
this.frames = [];
|
1791
|
+
};
|
1792
|
+
tree.mixin.Definition.prototype = {
|
1793
|
+
toCSS: function () { return "" },
|
1794
|
+
variable: function (name) { return this.parent.variable.call(this, name) },
|
1795
|
+
variables: function () { return this.parent.variables.call(this) },
|
1796
|
+
find: function () { return this.parent.find.apply(this, arguments) },
|
1797
|
+
rulesets: function () { return this.parent.rulesets.apply(this) },
|
1798
|
+
|
1799
|
+
eval: function (env, args) {
|
1800
|
+
var frame = new(tree.Ruleset)(null, []), context;
|
1801
|
+
|
1802
|
+
for (var i = 0, val; i < this.params.length; i++) {
|
1803
|
+
if (this.params[i].name) {
|
1804
|
+
if (val = (args && args[i]) || this.params[i].value) {
|
1805
|
+
frame.rules.unshift(new(tree.Rule)(this.params[i].name, val.eval(env)));
|
1806
|
+
} else {
|
1807
|
+
throw { message: "wrong number of arguments for " + this.name +
|
1808
|
+
' (' + args.length + ' for ' + this.arity + ')' };
|
1809
|
+
}
|
1810
|
+
}
|
1811
|
+
}
|
1812
|
+
return new(tree.Ruleset)(null, this.rules.slice(0)).eval({
|
1813
|
+
frames: [this, frame].concat(this.frames, env.frames)
|
1814
|
+
});
|
1815
|
+
},
|
1816
|
+
match: function (args, env) {
|
1817
|
+
var argsLength = (args && args.length) || 0, len;
|
1818
|
+
|
1819
|
+
if (argsLength < this.required) { return false }
|
1820
|
+
|
1821
|
+
len = Math.min(argsLength, this.arity);
|
1822
|
+
|
1823
|
+
for (var i = 0; i < len; i++) {
|
1824
|
+
if (!this.params[i].name) {
|
1825
|
+
if (args[i].eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) {
|
1826
|
+
return false;
|
1827
|
+
}
|
1828
|
+
}
|
1829
|
+
}
|
1830
|
+
return true;
|
1831
|
+
}
|
1832
|
+
};
|
1833
|
+
|
1834
|
+
})(require('less/tree'));
|
1835
|
+
(function (tree) {
|
1836
|
+
|
1837
|
+
tree.Operation = function (op, operands) {
|
1838
|
+
this.op = op.trim();
|
1839
|
+
this.operands = operands;
|
1840
|
+
};
|
1841
|
+
tree.Operation.prototype.eval = function (env) {
|
1842
|
+
var a = this.operands[0].eval(env),
|
1843
|
+
b = this.operands[1].eval(env),
|
1844
|
+
temp;
|
1845
|
+
|
1846
|
+
if (a instanceof tree.Dimension && b instanceof tree.Color) {
|
1847
|
+
if (this.op === '*' || this.op === '+') {
|
1848
|
+
temp = b, b = a, a = temp;
|
1849
|
+
} else {
|
1850
|
+
throw { name: "OperationError",
|
1851
|
+
message: "Can't substract or divide a color from a number" };
|
1852
|
+
}
|
1853
|
+
}
|
1854
|
+
return a.operate(this.op, b);
|
1855
|
+
};
|
1856
|
+
|
1857
|
+
tree.operate = function (op, a, b) {
|
1858
|
+
switch (op) {
|
1859
|
+
case '+': return a + b;
|
1860
|
+
case '-': return a - b;
|
1861
|
+
case '*': return a * b;
|
1862
|
+
case '/': return a / b;
|
1863
|
+
}
|
1864
|
+
};
|
1865
|
+
|
1866
|
+
})(require('less/tree'));
|
1867
|
+
(function (tree) {
|
1868
|
+
|
1869
|
+
tree.Quoted = function (str, content) {
|
1870
|
+
this.value = content || '';
|
1871
|
+
this.quote = str.charAt(0);
|
1872
|
+
};
|
1873
|
+
tree.Quoted.prototype = {
|
1874
|
+
toCSS: function () {
|
1875
|
+
return this.quote + this.value + this.quote;
|
1876
|
+
},
|
1877
|
+
eval: function () {
|
1878
|
+
return this;
|
1879
|
+
}
|
1880
|
+
};
|
1881
|
+
|
1882
|
+
})(require('less/tree'));
|
1883
|
+
(function (tree) {
|
1884
|
+
|
1885
|
+
tree.Rule = function (name, value, important, index) {
|
1886
|
+
this.name = name;
|
1887
|
+
this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
|
1888
|
+
this.important = important ? ' ' + important.trim() : '';
|
1889
|
+
this.index = index;
|
1890
|
+
|
1891
|
+
if (name.charAt(0) === '@') {
|
1892
|
+
this.variable = true;
|
1893
|
+
} else { this.variable = false }
|
1894
|
+
};
|
1895
|
+
tree.Rule.prototype.toCSS = function (env) {
|
1896
|
+
if (this.variable) { return "" }
|
1897
|
+
else {
|
1898
|
+
return this.name + (env.compress ? ':' : ': ') +
|
1899
|
+
this.value.toCSS(env) +
|
1900
|
+
this.important + ";";
|
1901
|
+
}
|
1902
|
+
};
|
1903
|
+
|
1904
|
+
tree.Rule.prototype.eval = function (context) {
|
1905
|
+
return new(tree.Rule)(this.name, this.value.eval(context), this.important, this.index);
|
1906
|
+
};
|
1907
|
+
|
1908
|
+
tree.Shorthand = function (a, b) {
|
1909
|
+
this.a = a;
|
1910
|
+
this.b = b;
|
1911
|
+
};
|
1912
|
+
|
1913
|
+
tree.Shorthand.prototype = {
|
1914
|
+
toCSS: function (env) {
|
1915
|
+
return this.a.toCSS(env) + "/" + this.b.toCSS(env);
|
1916
|
+
},
|
1917
|
+
eval: function () { return this }
|
1918
|
+
};
|
1919
|
+
|
1920
|
+
})(require('less/tree'));
|
1921
|
+
(function (tree) {
|
1922
|
+
|
1923
|
+
tree.Ruleset = function (selectors, rules) {
|
1924
|
+
this.selectors = selectors;
|
1925
|
+
this.rules = rules;
|
1926
|
+
this._lookups = {};
|
1927
|
+
};
|
1928
|
+
tree.Ruleset.prototype = {
|
1929
|
+
eval: function (env) {
|
1930
|
+
var ruleset = new(tree.Ruleset)(this.selectors, this.rules.slice(0));
|
1931
|
+
|
1932
|
+
ruleset.root = this.root;
|
1933
|
+
|
1934
|
+
// push the current ruleset to the frames stack
|
1935
|
+
env.frames.unshift(ruleset);
|
1936
|
+
|
1937
|
+
// Evaluate imports
|
1938
|
+
if (ruleset.root) {
|
1939
|
+
for (var i = 0; i < ruleset.rules.length; i++) {
|
1940
|
+
if (ruleset.rules[i] instanceof tree.Import) {
|
1941
|
+
Array.prototype.splice
|
1942
|
+
.apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env)));
|
1943
|
+
}
|
1944
|
+
}
|
1945
|
+
}
|
1946
|
+
|
1947
|
+
// Store the frames around mixin definitions,
|
1948
|
+
// so they can be evaluated like closures when the time comes.
|
1949
|
+
for (var i = 0; i < ruleset.rules.length; i++) {
|
1950
|
+
if (ruleset.rules[i] instanceof tree.mixin.Definition) {
|
1951
|
+
ruleset.rules[i].frames = env.frames.slice(0);
|
1952
|
+
}
|
1953
|
+
}
|
1954
|
+
|
1955
|
+
// Evaluate mixin calls.
|
1956
|
+
for (var i = 0; i < ruleset.rules.length; i++) {
|
1957
|
+
if (ruleset.rules[i] instanceof tree.mixin.Call) {
|
1958
|
+
Array.prototype.splice
|
1959
|
+
.apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env)));
|
1960
|
+
}
|
1961
|
+
}
|
1962
|
+
|
1963
|
+
// Evaluate everything else
|
1964
|
+
for (var i = 0, rule; i < ruleset.rules.length; i++) {
|
1965
|
+
rule = ruleset.rules[i];
|
1966
|
+
|
1967
|
+
if (! (rule instanceof tree.mixin.Definition)) {
|
1968
|
+
ruleset.rules[i] = rule.eval ? rule.eval(env) : rule;
|
1969
|
+
}
|
1970
|
+
}
|
1971
|
+
|
1972
|
+
// Pop the stack
|
1973
|
+
env.frames.shift();
|
1974
|
+
|
1975
|
+
return ruleset;
|
1976
|
+
},
|
1977
|
+
match: function (args) {
|
1978
|
+
return !args || args.length === 0;
|
1979
|
+
},
|
1980
|
+
variables: function () {
|
1981
|
+
if (this._variables) { return this._variables }
|
1982
|
+
else {
|
1983
|
+
return this._variables = this.rules.reduce(function (hash, r) {
|
1984
|
+
if (r instanceof tree.Rule && r.variable === true) {
|
1985
|
+
hash[r.name] = r;
|
1986
|
+
}
|
1987
|
+
return hash;
|
1988
|
+
}, {});
|
1989
|
+
}
|
1990
|
+
},
|
1991
|
+
variable: function (name) {
|
1992
|
+
return this.variables()[name];
|
1993
|
+
},
|
1994
|
+
rulesets: function () {
|
1995
|
+
if (this._rulesets) { return this._rulesets }
|
1996
|
+
else {
|
1997
|
+
return this._rulesets = this.rules.filter(function (r) {
|
1998
|
+
return (r instanceof tree.Ruleset) || (r instanceof tree.mixin.Definition);
|
1999
|
+
});
|
2000
|
+
}
|
2001
|
+
},
|
2002
|
+
find: function (selector, self) {
|
2003
|
+
self = self || this;
|
2004
|
+
var rules = [], rule, match,
|
2005
|
+
key = selector.toCSS();
|
2006
|
+
|
2007
|
+
if (key in this._lookups) { return this._lookups[key] }
|
2008
|
+
|
2009
|
+
this.rulesets().forEach(function (rule) {
|
2010
|
+
if (rule !== self) {
|
2011
|
+
for (var j = 0; j < rule.selectors.length; j++) {
|
2012
|
+
if (match = selector.match(rule.selectors[j])) {
|
2013
|
+
if (selector.elements.length > 1) {
|
2014
|
+
Array.prototype.push.apply(rules, rule.find(
|
2015
|
+
new(tree.Selector)(selector.elements.slice(1)), self));
|
2016
|
+
} else {
|
2017
|
+
rules.push(rule);
|
2018
|
+
}
|
2019
|
+
break;
|
2020
|
+
}
|
2021
|
+
}
|
2022
|
+
}
|
2023
|
+
});
|
2024
|
+
return this._lookups[key] = rules;
|
2025
|
+
},
|
2026
|
+
//
|
2027
|
+
// Entry point for code generation
|
2028
|
+
//
|
2029
|
+
// `context` holds an array of arrays.
|
2030
|
+
//
|
2031
|
+
toCSS: function (context, env) {
|
2032
|
+
var css = [], // The CSS output
|
2033
|
+
rules = [], // node.Rule instances
|
2034
|
+
rulesets = [], // node.Ruleset instances
|
2035
|
+
paths = [], // Current selectors
|
2036
|
+
selector, // The fully rendered selector
|
2037
|
+
rule;
|
2038
|
+
|
2039
|
+
if (! this.root) {
|
2040
|
+
if (context.length === 0) {
|
2041
|
+
paths = this.selectors.map(function (s) { return [s] });
|
2042
|
+
} else {
|
2043
|
+
for (var s = 0; s < this.selectors.length; s++) {
|
2044
|
+
for (var c = 0; c < context.length; c++) {
|
2045
|
+
paths.push(context[c].concat([this.selectors[s]]));
|
2046
|
+
}
|
2047
|
+
}
|
2048
|
+
}
|
2049
|
+
}
|
2050
|
+
|
2051
|
+
// Compile rules and rulesets
|
2052
|
+
for (var i = 0; i < this.rules.length; i++) {
|
2053
|
+
rule = this.rules[i];
|
2054
|
+
|
2055
|
+
if (rule.rules || (rule instanceof tree.Directive)) {
|
2056
|
+
rulesets.push(rule.toCSS(paths, env));
|
2057
|
+
} else if (rule instanceof tree.Comment) {
|
2058
|
+
if (!rule.silent) {
|
2059
|
+
if (this.root) {
|
2060
|
+
rulesets.push(rule.toCSS(env));
|
2061
|
+
} else {
|
2062
|
+
rules.push(rule.toCSS(env));
|
2063
|
+
}
|
2064
|
+
}
|
2065
|
+
} else {
|
2066
|
+
if (rule.toCSS && !rule.variable) {
|
2067
|
+
rules.push(rule.toCSS(env));
|
2068
|
+
} else if (rule.value && !rule.variable) {
|
2069
|
+
rules.push(rule.value.toString());
|
2070
|
+
}
|
2071
|
+
}
|
2072
|
+
}
|
2073
|
+
|
2074
|
+
rulesets = rulesets.join('');
|
2075
|
+
|
2076
|
+
// If this is the root node, we don't render
|
2077
|
+
// a selector, or {}.
|
2078
|
+
// Otherwise, only output if this ruleset has rules.
|
2079
|
+
if (this.root) {
|
2080
|
+
css.push(rules.join(env.compress ? '' : '\n'));
|
2081
|
+
} else {
|
2082
|
+
if (rules.length > 0) {
|
2083
|
+
selector = paths.map(function (p) {
|
2084
|
+
return p.map(function (s) {
|
2085
|
+
return s.toCSS(env);
|
2086
|
+
}).join('').trim();
|
2087
|
+
}).join(env.compress ? ',' : (paths.length > 3 ? ',\n' : ', '));
|
2088
|
+
css.push(selector,
|
2089
|
+
(env.compress ? '{' : ' {\n ') +
|
2090
|
+
rules.join(env.compress ? '' : '\n ') +
|
2091
|
+
(env.compress ? '}' : '\n}\n'));
|
2092
|
+
}
|
2093
|
+
}
|
2094
|
+
css.push(rulesets);
|
2095
|
+
|
2096
|
+
return css.join('') + (env.compress ? '\n' : '');
|
2097
|
+
}
|
2098
|
+
};
|
2099
|
+
})(require('less/tree'));
|
2100
|
+
(function (tree) {
|
2101
|
+
|
2102
|
+
tree.Selector = function (elements) {
|
2103
|
+
this.elements = elements;
|
2104
|
+
if (this.elements[0].combinator.value === "") {
|
2105
|
+
this.elements[0].combinator.value = ' ';
|
2106
|
+
}
|
2107
|
+
};
|
2108
|
+
tree.Selector.prototype.match = function (other) {
|
2109
|
+
if (this.elements[0].value === other.elements[0].value) {
|
2110
|
+
return true;
|
2111
|
+
} else {
|
2112
|
+
return false;
|
2113
|
+
}
|
2114
|
+
};
|
2115
|
+
tree.Selector.prototype.toCSS = function (env) {
|
2116
|
+
if (this._css) { return this._css }
|
2117
|
+
|
2118
|
+
return this._css = this.elements.map(function (e) {
|
2119
|
+
if (typeof(e) === 'string') {
|
2120
|
+
return ' ' + e.trim();
|
2121
|
+
} else {
|
2122
|
+
return e.toCSS(env);
|
2123
|
+
}
|
2124
|
+
}).join('');
|
2125
|
+
};
|
2126
|
+
|
2127
|
+
})(require('less/tree'));
|
2128
|
+
(function (tree) {
|
2129
|
+
|
2130
|
+
tree.URL = function (val, paths) {
|
2131
|
+
// Add the base path if the URL is relative and we are in the browser
|
2132
|
+
if (!/^(?:http:\/)?\//.test(val.value) && paths.length > 0 && typeof(window) !== 'undefined') {
|
2133
|
+
val.value = [paths[0], val.value].join('/').replace('//', '/');
|
2134
|
+
}
|
2135
|
+
this.value = val;
|
2136
|
+
this.paths = paths;
|
2137
|
+
};
|
2138
|
+
tree.URL.prototype = {
|
2139
|
+
toCSS: function () {
|
2140
|
+
return "url(" + this.value.toCSS() + ")";
|
2141
|
+
},
|
2142
|
+
eval: function (ctx) {
|
2143
|
+
return new(tree.URL)(this.value.eval(ctx), this.paths);
|
2144
|
+
}
|
2145
|
+
};
|
2146
|
+
|
2147
|
+
})(require('less/tree'));
|
2148
|
+
(function (tree) {
|
2149
|
+
|
2150
|
+
tree.Value = function (value) {
|
2151
|
+
this.value = value;
|
2152
|
+
this.is = 'value';
|
2153
|
+
};
|
2154
|
+
tree.Value.prototype = {
|
2155
|
+
eval: function (env) {
|
2156
|
+
if (this.value.length === 1) {
|
2157
|
+
return this.value[0].eval(env);
|
2158
|
+
} else {
|
2159
|
+
return new(tree.Value)(this.value.map(function (v) {
|
2160
|
+
return v.eval(env);
|
2161
|
+
}));
|
2162
|
+
}
|
2163
|
+
},
|
2164
|
+
toCSS: function (env) {
|
2165
|
+
return this.value.map(function (e) {
|
2166
|
+
return e.toCSS(env);
|
2167
|
+
}).join(env.compress ? ',' : ', ');
|
2168
|
+
}
|
2169
|
+
};
|
2170
|
+
|
2171
|
+
})(require('less/tree'));
|
2172
|
+
(function (tree) {
|
2173
|
+
|
2174
|
+
tree.Variable = function (name, index) { this.name = name, this.index = index };
|
2175
|
+
tree.Variable.prototype = {
|
2176
|
+
eval: function (env) {
|
2177
|
+
var variable, v, name = this.name;
|
2178
|
+
|
2179
|
+
if (variable = tree.find(env.frames, function (frame) {
|
2180
|
+
if (v = frame.variable(name)) {
|
2181
|
+
return v.value.eval(env);
|
2182
|
+
}
|
2183
|
+
})) { return variable }
|
2184
|
+
else {
|
2185
|
+
throw { message: "variable " + this.name + " is undefined",
|
2186
|
+
index: this.index };
|
2187
|
+
}
|
2188
|
+
}
|
2189
|
+
};
|
2190
|
+
|
2191
|
+
})(require('less/tree'));
|
2192
|
+
require('less/tree').find = function (obj, fun) {
|
2193
|
+
for (var i = 0, r; i < obj.length; i++) {
|
2194
|
+
if (r = fun.call(obj, obj[i])) { return r }
|
2195
|
+
}
|
2196
|
+
return null;
|
2197
|
+
};
|
2198
|
+
//
|
2199
|
+
// browser.js - client-side engine
|
2200
|
+
//
|
2201
|
+
|
2202
|
+
var isFileProtocol = (location.protocol === 'file:' ||
|
2203
|
+
location.protocol === 'chrome:' ||
|
2204
|
+
location.protocol === 'resource:');
|
2205
|
+
|
2206
|
+
less.env = 'production';
|
2207
|
+
|
2208
|
+
// Load styles asynchronously (default: false)
|
2209
|
+
//
|
2210
|
+
// This is set to `false` by default, so that the body
|
2211
|
+
// doesn't start loading before the stylesheets are parsed.
|
2212
|
+
// Setting this to `true` can result in flickering.
|
2213
|
+
//
|
2214
|
+
less.async = false;
|
2215
|
+
|
2216
|
+
// Interval between watch polls
|
2217
|
+
less.poll = less.poll || (isFileProtocol ? 1000 : 1500);
|
2218
|
+
|
2219
|
+
//
|
2220
|
+
// Watch mode
|
2221
|
+
//
|
2222
|
+
less.watch = function () { return this.watchMode = true };
|
2223
|
+
less.unwatch = function () { return this.watchMode = false };
|
2224
|
+
|
2225
|
+
if (less.env === 'development') {
|
2226
|
+
less.optimization = 0;
|
2227
|
+
|
2228
|
+
if (/!watch/.test(location.hash)) {
|
2229
|
+
less.watch();
|
2230
|
+
}
|
2231
|
+
less.watchTimer = setInterval(function () {
|
2232
|
+
if (less.watchMode) {
|
2233
|
+
loadStyleSheets(function (root, sheet, env) {
|
2234
|
+
if (root) {
|
2235
|
+
createCSS(root.toCSS(), sheet, env.lastModified);
|
2236
|
+
}
|
2237
|
+
});
|
2238
|
+
}
|
2239
|
+
}, less.poll);
|
2240
|
+
} else {
|
2241
|
+
less.optimization = 3;
|
2242
|
+
}
|
2243
|
+
|
2244
|
+
var cache;
|
2245
|
+
|
2246
|
+
try {
|
2247
|
+
cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage;
|
2248
|
+
} catch (_) {
|
2249
|
+
cache = null;
|
2250
|
+
}
|
2251
|
+
|
2252
|
+
//
|
2253
|
+
// Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
|
2254
|
+
//
|
2255
|
+
var links = document.getElementsByTagName('link');
|
2256
|
+
var typePattern = /^text\/(x-)?less$/;
|
2257
|
+
|
2258
|
+
less.sheets = [];
|
2259
|
+
|
2260
|
+
for (var i = 0; i < links.length; i++) {
|
2261
|
+
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
|
2262
|
+
(links[i].type.match(typePattern)))) {
|
2263
|
+
less.sheets.push(links[i]);
|
2264
|
+
}
|
2265
|
+
}
|
2266
|
+
|
2267
|
+
|
2268
|
+
less.refresh = function (reload) {
|
2269
|
+
var startTime = endTime = new(Date);
|
2270
|
+
|
2271
|
+
loadStyleSheets(function (root, sheet, env) {
|
2272
|
+
if (env.local) {
|
2273
|
+
log("loading " + sheet.href + " from cache.");
|
2274
|
+
} else {
|
2275
|
+
log("parsed " + sheet.href + " successfully.");
|
2276
|
+
createCSS(root.toCSS(), sheet, env.lastModified);
|
2277
|
+
}
|
2278
|
+
log("css for " + sheet.href + " generated in " + (new(Date) - endTime) + 'ms');
|
2279
|
+
(env.remaining === 0) && log("css generated in " + (new(Date) - startTime) + 'ms');
|
2280
|
+
endTime = new(Date);
|
2281
|
+
}, reload);
|
2282
|
+
|
2283
|
+
loadStyles();
|
2284
|
+
};
|
2285
|
+
less.refreshStyles = loadStyles;
|
2286
|
+
|
2287
|
+
less.refresh(less.env === 'development');
|
2288
|
+
|
2289
|
+
function loadStyles() {
|
2290
|
+
var styles = document.getElementsByTagName('style');
|
2291
|
+
for (var i = 0; i < styles.length; i++) {
|
2292
|
+
if (styles[i].type.match(typePattern)) {
|
2293
|
+
new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) {
|
2294
|
+
styles[i].type = 'text/css';
|
2295
|
+
styles[i].innerHTML = tree.toCSS();
|
2296
|
+
});
|
2297
|
+
}
|
2298
|
+
}
|
2299
|
+
}
|
2300
|
+
|
2301
|
+
function loadStyleSheets(callback, reload) {
|
2302
|
+
for (var i = 0; i < less.sheets.length; i++) {
|
2303
|
+
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1));
|
2304
|
+
}
|
2305
|
+
}
|
2306
|
+
|
2307
|
+
function loadStyleSheet(sheet, callback, reload, remaining) {
|
2308
|
+
var href = sheet.href.replace(/\?.*$/, '');
|
2309
|
+
var css = cache && cache.getItem(href);
|
2310
|
+
var timestamp = cache && cache.getItem(href + ':timestamp');
|
2311
|
+
var styles = { css: css, timestamp: timestamp };
|
2312
|
+
|
2313
|
+
xhr(sheet.href, function (data, lastModified) {
|
2314
|
+
if (!reload && styles &&
|
2315
|
+
(new(Date)(lastModified).valueOf() ===
|
2316
|
+
new(Date)(styles.timestamp).valueOf())) {
|
2317
|
+
// Use local copy
|
2318
|
+
createCSS(styles.css, sheet);
|
2319
|
+
callback(null, sheet, { local: true, remaining: remaining });
|
2320
|
+
} else {
|
2321
|
+
// Use remote copy (re-parse)
|
2322
|
+
new(less.Parser)({
|
2323
|
+
optimization: less.optimization,
|
2324
|
+
paths: [href.replace(/[\w\.-]+$/, '')]
|
2325
|
+
}).parse(data, function (e, root) {
|
2326
|
+
if (e) { return error(e, href) }
|
2327
|
+
try {
|
2328
|
+
callback(root, sheet, { local: false, lastModified: lastModified, remaining: remaining });
|
2329
|
+
removeNode(document.getElementById('less-error-message:' + extractId(href)));
|
2330
|
+
} catch (e) {
|
2331
|
+
error(e, href);
|
2332
|
+
}
|
2333
|
+
});
|
2334
|
+
}
|
2335
|
+
}, function (status, url) {
|
2336
|
+
throw new(Error)("Couldn't load " + url+ " (" + status + ")");
|
2337
|
+
});
|
2338
|
+
}
|
2339
|
+
|
2340
|
+
function extractId(href) {
|
2341
|
+
return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain
|
2342
|
+
.replace(/^\//, '' ) // Remove root /
|
2343
|
+
.replace(/\?.*$/, '' ) // Remove query
|
2344
|
+
.replace(/\.[^\.\/]+$/, '' ) // Remove file extension
|
2345
|
+
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
|
2346
|
+
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
|
2347
|
+
}
|
2348
|
+
|
2349
|
+
function createCSS(styles, sheet, lastModified) {
|
2350
|
+
var css;
|
2351
|
+
|
2352
|
+
// Strip the query-string
|
2353
|
+
var href = sheet.href ? sheet.href.replace(/\?.*$/, '') : '';
|
2354
|
+
|
2355
|
+
// If there is no title set, use the filename, minus the extension
|
2356
|
+
var id = 'less:' + (sheet.title || extractId(href));
|
2357
|
+
|
2358
|
+
// If the stylesheet doesn't exist, create a new node
|
2359
|
+
if ((css = document.getElementById(id)) === null) {
|
2360
|
+
css = document.createElement('style');
|
2361
|
+
css.type = 'text/css';
|
2362
|
+
css.media = sheet.media;
|
2363
|
+
css.id = id;
|
2364
|
+
document.getElementsByTagName('head')[0].appendChild(css);
|
2365
|
+
}
|
2366
|
+
|
2367
|
+
if (css.styleSheet) { // IE
|
2368
|
+
try {
|
2369
|
+
css.styleSheet.cssText = styles;
|
2370
|
+
} catch (e) {
|
2371
|
+
throw new(Error)("Couldn't reassign styleSheet.cssText.");
|
2372
|
+
}
|
2373
|
+
} else {
|
2374
|
+
(function (node) {
|
2375
|
+
if (css.childNodes.length > 0) {
|
2376
|
+
if (css.firstChild.nodeValue !== node.nodeValue) {
|
2377
|
+
css.replaceChild(node, css.firstChild);
|
2378
|
+
}
|
2379
|
+
} else {
|
2380
|
+
css.appendChild(node);
|
2381
|
+
}
|
2382
|
+
})(document.createTextNode(styles));
|
2383
|
+
}
|
2384
|
+
|
2385
|
+
// Don't update the local store if the file wasn't modified
|
2386
|
+
if (lastModified && cache) {
|
2387
|
+
log('saving ' + href + ' to cache.');
|
2388
|
+
cache.setItem(href, styles);
|
2389
|
+
cache.setItem(href + ':timestamp', lastModified);
|
2390
|
+
}
|
2391
|
+
}
|
2392
|
+
|
2393
|
+
function xhr(url, callback, errback) {
|
2394
|
+
var xhr = getXMLHttpRequest();
|
2395
|
+
var async = isFileProtocol ? false : less.async;
|
2396
|
+
|
2397
|
+
if (typeof(xhr.overrideMimeType) === 'function') {
|
2398
|
+
xhr.overrideMimeType('text/css');
|
2399
|
+
}
|
2400
|
+
xhr.open('GET', url, async);
|
2401
|
+
xhr.send(null);
|
2402
|
+
|
2403
|
+
if (isFileProtocol) {
|
2404
|
+
if (xhr.status === 0) {
|
2405
|
+
callback(xhr.responseText);
|
2406
|
+
} else {
|
2407
|
+
errback(xhr.status);
|
2408
|
+
}
|
2409
|
+
} else if (async) {
|
2410
|
+
xhr.onreadystatechange = function () {
|
2411
|
+
if (xhr.readyState == 4) {
|
2412
|
+
handleResponse(xhr, callback, errback);
|
2413
|
+
}
|
2414
|
+
};
|
2415
|
+
} else {
|
2416
|
+
handleResponse(xhr, callback, errback);
|
2417
|
+
}
|
2418
|
+
|
2419
|
+
function handleResponse(xhr, callback, errback) {
|
2420
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
2421
|
+
callback(xhr.responseText,
|
2422
|
+
xhr.getResponseHeader("Last-Modified"));
|
2423
|
+
} else if (typeof(errback) === 'function') {
|
2424
|
+
errback(xhr.status, url);
|
2425
|
+
}
|
2426
|
+
}
|
2427
|
+
}
|
2428
|
+
|
2429
|
+
function getXMLHttpRequest() {
|
2430
|
+
if (window.XMLHttpRequest) {
|
2431
|
+
return new(XMLHttpRequest);
|
2432
|
+
} else {
|
2433
|
+
try {
|
2434
|
+
return new(ActiveXObject)("MSXML2.XMLHTTP.3.0");
|
2435
|
+
} catch (e) {
|
2436
|
+
log("browser doesn't support AJAX.");
|
2437
|
+
return null;
|
2438
|
+
}
|
2439
|
+
}
|
2440
|
+
}
|
2441
|
+
|
2442
|
+
function removeNode(node) {
|
2443
|
+
return node && node.parentNode.removeChild(node);
|
2444
|
+
}
|
2445
|
+
|
2446
|
+
function log(str) {
|
2447
|
+
if (less.env == 'development' && typeof(console) !== "undefined") { console.log('less: ' + str) }
|
2448
|
+
}
|
2449
|
+
|
2450
|
+
function error(e, href) {
|
2451
|
+
var id = 'less-error-message:' + extractId(href);
|
2452
|
+
|
2453
|
+
if (! e.extract) { throw e }
|
2454
|
+
|
2455
|
+
var template = ['<div>',
|
2456
|
+
'<pre class="ctx"><span>[-1]</span>{0}</pre>',
|
2457
|
+
'<pre><span>[0]</span>{current}</pre>',
|
2458
|
+
'<pre class="ctx"><span>[1]</span>{2}</pre>',
|
2459
|
+
'</div>'].join('\n');
|
2460
|
+
|
2461
|
+
var elem = document.createElement('div'), timer;
|
2462
|
+
elem.id = id;
|
2463
|
+
elem.className = "less-error-message";
|
2464
|
+
elem.innerHTML = '<h3>' + (e.message || 'There is an error in your .less file') + '</h3>' +
|
2465
|
+
'<p><a href="' + href + '">' + href + "</a> " +
|
2466
|
+
'on line ' + e.line + ', column ' + (e.column + 1) + ':</p>' +
|
2467
|
+
template.replace(/\[(-?\d)\]/g, function (_, i) {
|
2468
|
+
return (parseInt(e.line) + parseInt(i)) || '';
|
2469
|
+
}).replace(/\{(\d)\}/g, function (_, i) {
|
2470
|
+
return e.extract[parseInt(i)] || '';
|
2471
|
+
}).replace(/\{current\}/, e.extract[1].slice(0, e.column) +
|
2472
|
+
'<span class="error">' +
|
2473
|
+
e.extract[1].slice(e.column) +
|
2474
|
+
'</span>');
|
2475
|
+
// CSS for error messages
|
2476
|
+
createCSS([
|
2477
|
+
'.less-error-message span {',
|
2478
|
+
'margin-right: 15px;',
|
2479
|
+
'}',
|
2480
|
+
'.less-error-message pre {',
|
2481
|
+
'color: #ee4444;',
|
2482
|
+
'padding: 4px 0;',
|
2483
|
+
'margin: 0;',
|
2484
|
+
'}',
|
2485
|
+
'.less-error-message pre.ctx {',
|
2486
|
+
'color: #dd7777;',
|
2487
|
+
'}',
|
2488
|
+
'.less-error-message h3 {',
|
2489
|
+
'padding: 15px 0 5px 0;',
|
2490
|
+
'margin: 0;',
|
2491
|
+
'}',
|
2492
|
+
'.less-error-message a {',
|
2493
|
+
'color: #10a',
|
2494
|
+
'}',
|
2495
|
+
'.less-error-message .error {',
|
2496
|
+
'color: red;',
|
2497
|
+
'font-weight: bold;',
|
2498
|
+
'padding-bottom: 2px;',
|
2499
|
+
'border-bottom: 1px dashed red;',
|
2500
|
+
'}'
|
2501
|
+
].join('\n'), { title: 'error-message' });
|
2502
|
+
|
2503
|
+
elem.style.cssText = [
|
2504
|
+
"font-family: Arial, sans-serif",
|
2505
|
+
"border: 1px solid #e00",
|
2506
|
+
"background-color: #eee",
|
2507
|
+
"border-radius: 5px",
|
2508
|
+
"-webkit-border-radius: 5px",
|
2509
|
+
"-moz-border-radius: 5px",
|
2510
|
+
"color: #e00",
|
2511
|
+
"padding: 15px",
|
2512
|
+
"margin-bottom: 15px"
|
2513
|
+
].join(';');
|
2514
|
+
|
2515
|
+
/*if (less.env == 'development') {
|
2516
|
+
timer = setInterval(function () {
|
2517
|
+
if (document.body) {
|
2518
|
+
if (document.getElementById(id)) {
|
2519
|
+
document.body.replaceChild(elem, document.getElementById(id));
|
2520
|
+
} else {
|
2521
|
+
document.body.insertBefore(elem, document.body.firstChild);
|
2522
|
+
}
|
2523
|
+
clearInterval(timer);
|
2524
|
+
}
|
2525
|
+
}, 10);
|
2526
|
+
}*/
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
})(window);
|