@macallumharvey/first-test-wet 1.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/WetButton.d.ts +9 -0
- package/dist/WetModal.d.ts +6 -0
- package/dist/first-test-wet.cjs.development.js +26 -0
- package/dist/first-test-wet.cjs.development.js.map +1 -1
- package/dist/first-test-wet.cjs.production.min.js +1 -1
- package/dist/first-test-wet.cjs.production.min.js.map +1 -1
- package/dist/first-test-wet.esm.js +26 -1
- package/dist/first-test-wet.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/WetButton.tsx +19 -0
- package/src/WetModal.tsx +26 -0
- package/src/index.tsx +2 -2
- package/src/theme-wet-boew/assets/favicon-mobile.png +0 -0
- package/src/theme-wet-boew/assets/favicon.ico +0 -0
- package/src/theme-wet-boew/assets/logo.png +0 -0
- package/src/theme-wet-boew/assets/logo.svg +14 -0
- package/src/theme-wet-boew/css/ie8-theme.css +17370 -0
- package/src/theme-wet-boew/css/ie8-theme.min.css +193 -0
- package/src/theme-wet-boew/css/ie8-wet-boew.css +12 -0
- package/src/theme-wet-boew/css/ie8-wet-boew.min.css +7 -0
- package/src/theme-wet-boew/css/theme.css +11357 -0
- package/src/theme-wet-boew/css/theme.min.css +6 -0
- package/src/theme-wet-boew/css/wet-boew.css +12 -0
- package/src/theme-wet-boew/css/wet-boew.min.css +6 -0
- package/src/theme-wet-boew/payload.json +66 -0
- package/src/wet-boew/assets/cloud-popup-relative.png +0 -0
- package/src/wet-boew/assets/fd-slider-sprite.png +0 -0
- package/src/wet-boew/assets/loading.png +0 -0
- package/src/wet-boew/assets/mediacontrols.html +32 -0
- package/src/wet-boew/assets/sprites_share.png +0 -0
- package/src/wet-boew/assets/zoom-minus-mini.png +0 -0
- package/src/wet-boew/assets/zoom-plus-mini.png +0 -0
- package/src/wet-boew/assets/zoom-world-mini.png +0 -0
- package/src/wet-boew/css/noscript.css +112 -0
- package/src/wet-boew/css/noscript.min.css +6 -0
- package/src/wet-boew/css/polyfills/datalist.css +32 -0
- package/src/wet-boew/css/polyfills/datalist.min.css +1 -0
- package/src/wet-boew/css/polyfills/datepicker.css +47 -0
- package/src/wet-boew/css/polyfills/datepicker.min.css +1 -0
- package/src/wet-boew/css/polyfills/details.css +28 -0
- package/src/wet-boew/css/polyfills/details.min.css +1 -0
- package/src/wet-boew/css/polyfills/mathml.css +16 -0
- package/src/wet-boew/css/polyfills/mathml.min.css +1 -0
- package/src/wet-boew/css/polyfills/meter.css +24 -0
- package/src/wet-boew/css/polyfills/meter.min.css +1 -0
- package/src/wet-boew/css/polyfills/progress.css +8 -0
- package/src/wet-boew/css/polyfills/progress.min.css +1 -0
- package/src/wet-boew/css/polyfills/slider.css +229 -0
- package/src/wet-boew/css/polyfills/slider.min.css +1 -0
- package/src/wet-boew/fonts/glyphicons-halflings-regular.eot +0 -0
- package/src/wet-boew/fonts/glyphicons-halflings-regular.svg +288 -0
- package/src/wet-boew/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/src/wet-boew/fonts/glyphicons-halflings-regular.woff +0 -0
- package/src/wet-boew/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/src/wet-boew/js/MathJax/mml-chtml.js +1 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff +0 -0
- package/src/wet-boew/js/MathJax/output/chtml/fonts/woff-v2/MathJax_Zero.woff +0 -0
- package/src/wet-boew/js/deps/additional-methods.js +1512 -0
- package/src/wet-boew/js/deps/additional-methods.min.js +9 -0
- package/src/wet-boew/js/deps/geomap-lib.js +3758 -0
- package/src/wet-boew/js/deps/geomap-lib.min.js +1 -0
- package/src/wet-boew/js/deps/jquery.dataTables.js +15345 -0
- package/src/wet-boew/js/deps/jquery.dataTables.min.js +4 -0
- package/src/wet-boew/js/deps/jquery.flot.canvas.js +345 -0
- package/src/wet-boew/js/deps/jquery.flot.canvas.min.js +1 -0
- package/src/wet-boew/js/deps/jquery.flot.js +3168 -0
- package/src/wet-boew/js/deps/jquery.flot.min.js +1 -0
- package/src/wet-boew/js/deps/jquery.flot.orderBars.js +282 -0
- package/src/wet-boew/js/deps/jquery.flot.orderBars.min.js +1 -0
- package/src/wet-boew/js/deps/jquery.flot.pie.js +820 -0
- package/src/wet-boew/js/deps/jquery.flot.pie.min.js +1 -0
- package/src/wet-boew/js/deps/jquery.magnific-popup.js +2061 -0
- package/src/wet-boew/js/deps/jquery.magnific-popup.min.js +4 -0
- package/src/wet-boew/js/deps/jquery.validate.js +1661 -0
- package/src/wet-boew/js/deps/jquery.validate.min.js +9 -0
- package/src/wet-boew/js/deps/json-patch.js +315 -0
- package/src/wet-boew/js/deps/json-patch.min.js +1 -0
- package/src/wet-boew/js/deps/jsonpointer.js +349 -0
- package/src/wet-boew/js/deps/jsonpointer.min.js +1 -0
- package/src/wet-boew/js/deps/lang-apollo.js +53 -0
- package/src/wet-boew/js/deps/lang-apollo.min.js +1 -0
- package/src/wet-boew/js/deps/lang-basic.js +49 -0
- package/src/wet-boew/js/deps/lang-basic.min.js +1 -0
- package/src/wet-boew/js/deps/lang-clj.js +64 -0
- package/src/wet-boew/js/deps/lang-clj.min.js +1 -0
- package/src/wet-boew/js/deps/lang-css.js +160 -0
- package/src/wet-boew/js/deps/lang-css.min.js +1 -0
- package/src/wet-boew/js/deps/lang-dart.js +92 -0
- package/src/wet-boew/js/deps/lang-dart.min.js +1 -0
- package/src/wet-boew/js/deps/lang-erlang.js +94 -0
- package/src/wet-boew/js/deps/lang-erlang.min.js +1 -0
- package/src/wet-boew/js/deps/lang-go.js +59 -0
- package/src/wet-boew/js/deps/lang-go.min.js +1 -0
- package/src/wet-boew/js/deps/lang-hs.js +102 -0
- package/src/wet-boew/js/deps/lang-hs.min.js +1 -0
- package/src/wet-boew/js/deps/lang-lasso.js +67 -0
- package/src/wet-boew/js/deps/lang-lasso.min.js +1 -0
- package/src/wet-boew/js/deps/lang-lisp.js +95 -0
- package/src/wet-boew/js/deps/lang-lisp.min.js +1 -0
- package/src/wet-boew/js/deps/lang-llvm.js +63 -0
- package/src/wet-boew/js/deps/lang-llvm.min.js +1 -0
- package/src/wet-boew/js/deps/lang-logtalk.js +50 -0
- package/src/wet-boew/js/deps/lang-logtalk.min.js +1 -0
- package/src/wet-boew/js/deps/lang-lua.js +60 -0
- package/src/wet-boew/js/deps/lang-lua.min.js +1 -0
- package/src/wet-boew/js/deps/lang-matlab.js +183 -0
- package/src/wet-boew/js/deps/lang-matlab.min.js +1 -0
- package/src/wet-boew/js/deps/lang-ml.js +57 -0
- package/src/wet-boew/js/deps/lang-ml.min.js +1 -0
- package/src/wet-boew/js/deps/lang-mumps.js +140 -0
- package/src/wet-boew/js/deps/lang-mumps.min.js +1 -0
- package/src/wet-boew/js/deps/lang-n.js +67 -0
- package/src/wet-boew/js/deps/lang-n.min.js +1 -0
- package/src/wet-boew/js/deps/lang-pascal.js +49 -0
- package/src/wet-boew/js/deps/lang-pascal.min.js +1 -0
- package/src/wet-boew/js/deps/lang-proto.js +37 -0
- package/src/wet-boew/js/deps/lang-proto.min.js +1 -0
- package/src/wet-boew/js/deps/lang-r.js +59 -0
- package/src/wet-boew/js/deps/lang-r.min.js +1 -0
- package/src/wet-boew/js/deps/lang-rd.js +50 -0
- package/src/wet-boew/js/deps/lang-rd.min.js +1 -0
- package/src/wet-boew/js/deps/lang-rust.js +81 -0
- package/src/wet-boew/js/deps/lang-rust.min.js +1 -0
- package/src/wet-boew/js/deps/lang-scala.js +56 -0
- package/src/wet-boew/js/deps/lang-scala.min.js +1 -0
- package/src/wet-boew/js/deps/lang-sql.js +59 -0
- package/src/wet-boew/js/deps/lang-sql.min.js +1 -0
- package/src/wet-boew/js/deps/lang-swift.js +60 -0
- package/src/wet-boew/js/deps/lang-swift.min.js +1 -0
- package/src/wet-boew/js/deps/lang-tcl.js +63 -0
- package/src/wet-boew/js/deps/lang-tcl.min.js +1 -0
- package/src/wet-boew/js/deps/lang-tex.js +49 -0
- package/src/wet-boew/js/deps/lang-tex.min.js +1 -0
- package/src/wet-boew/js/deps/lang-vb.js +67 -0
- package/src/wet-boew/js/deps/lang-vb.min.js +1 -0
- package/src/wet-boew/js/deps/lang-vhdl.js +51 -0
- package/src/wet-boew/js/deps/lang-vhdl.min.js +1 -0
- package/src/wet-boew/js/deps/lang-wiki.js +55 -0
- package/src/wet-boew/js/deps/lang-wiki.min.js +1 -0
- package/src/wet-boew/js/deps/lang-xq.js +71 -0
- package/src/wet-boew/js/deps/lang-xq.min.js +1 -0
- package/src/wet-boew/js/deps/lang-yaml.js +45 -0
- package/src/wet-boew/js/deps/lang-yaml.min.js +1 -0
- package/src/wet-boew/js/deps/ol.js +1008 -0
- package/src/wet-boew/js/deps/ol.min.js +1 -0
- package/src/wet-boew/js/deps/prettify.js +1742 -0
- package/src/wet-boew/js/deps/prettify.min.js +1 -0
- package/src/wet-boew/js/deps/proj4.js +3 -0
- package/src/wet-boew/js/deps/proj4.min.js +1 -0
- package/src/wet-boew/js/deps/run_prettify.js +1998 -0
- package/src/wet-boew/js/deps/run_prettify.min.js +1 -0
- package/src/wet-boew/js/deps/tableparser.js +2216 -0
- package/src/wet-boew/js/deps/tableparser.min.js +1 -0
- package/src/wet-boew/js/deps/unorm.js +452 -0
- package/src/wet-boew/js/deps/unorm.min.js +1 -0
- package/src/wet-boew/js/i18n/af.js +246 -0
- package/src/wet-boew/js/i18n/af.min.js +7 -0
- package/src/wet-boew/js/i18n/ar.js +285 -0
- package/src/wet-boew/js/i18n/ar.min.js +7 -0
- package/src/wet-boew/js/i18n/bg.js +285 -0
- package/src/wet-boew/js/i18n/bg.min.js +7 -0
- package/src/wet-boew/js/i18n/cs.js +286 -0
- package/src/wet-boew/js/i18n/cs.min.js +7 -0
- package/src/wet-boew/js/i18n/de.js +355 -0
- package/src/wet-boew/js/i18n/de.min.js +7 -0
- package/src/wet-boew/js/i18n/el.js +285 -0
- package/src/wet-boew/js/i18n/el.min.js +7 -0
- package/src/wet-boew/js/i18n/en.js +246 -0
- package/src/wet-boew/js/i18n/en.min.js +7 -0
- package/src/wet-boew/js/i18n/es.js +288 -0
- package/src/wet-boew/js/i18n/es.min.js +7 -0
- package/src/wet-boew/js/i18n/et.js +283 -0
- package/src/wet-boew/js/i18n/et.min.js +7 -0
- package/src/wet-boew/js/i18n/fr.js +314 -0
- package/src/wet-boew/js/i18n/fr.min.js +7 -0
- package/src/wet-boew/js/i18n/hi.js +246 -0
- package/src/wet-boew/js/i18n/hi.min.js +7 -0
- package/src/wet-boew/js/i18n/hu.js +285 -0
- package/src/wet-boew/js/i18n/hu.min.js +7 -0
- package/src/wet-boew/js/i18n/hy.js +246 -0
- package/src/wet-boew/js/i18n/hy.min.js +7 -0
- package/src/wet-boew/js/i18n/id.js +284 -0
- package/src/wet-boew/js/i18n/id.min.js +7 -0
- package/src/wet-boew/js/i18n/is.js +283 -0
- package/src/wet-boew/js/i18n/is.min.js +7 -0
- package/src/wet-boew/js/i18n/it.js +312 -0
- package/src/wet-boew/js/i18n/it.min.js +7 -0
- package/src/wet-boew/js/i18n/iu.js +246 -0
- package/src/wet-boew/js/i18n/iu.min.js +7 -0
- package/src/wet-boew/js/i18n/ja.js +286 -0
- package/src/wet-boew/js/i18n/ja.min.js +7 -0
- package/src/wet-boew/js/i18n/ko.js +285 -0
- package/src/wet-boew/js/i18n/ko.min.js +7 -0
- package/src/wet-boew/js/i18n/lt.js +285 -0
- package/src/wet-boew/js/i18n/lt.min.js +7 -0
- package/src/wet-boew/js/i18n/lv.js +285 -0
- package/src/wet-boew/js/i18n/lv.min.js +7 -0
- package/src/wet-boew/js/i18n/nl.js +319 -0
- package/src/wet-boew/js/i18n/nl.min.js +7 -0
- package/src/wet-boew/js/i18n/pl.js +288 -0
- package/src/wet-boew/js/i18n/pl.min.js +7 -0
- package/src/wet-boew/js/i18n/pt-BR.js +246 -0
- package/src/wet-boew/js/i18n/pt-BR.min.js +7 -0
- package/src/wet-boew/js/i18n/pt.js +271 -0
- package/src/wet-boew/js/i18n/pt.min.js +7 -0
- package/src/wet-boew/js/i18n/ru.js +285 -0
- package/src/wet-boew/js/i18n/ru.min.js +7 -0
- package/src/wet-boew/js/i18n/sk.js +283 -0
- package/src/wet-boew/js/i18n/sk.min.js +7 -0
- package/src/wet-boew/js/i18n/sq.js +246 -0
- package/src/wet-boew/js/i18n/sq.min.js +7 -0
- package/src/wet-boew/js/i18n/th.js +285 -0
- package/src/wet-boew/js/i18n/th.min.js +7 -0
- package/src/wet-boew/js/i18n/tr.js +287 -0
- package/src/wet-boew/js/i18n/tr.min.js +7 -0
- package/src/wet-boew/js/i18n/uk.js +285 -0
- package/src/wet-boew/js/i18n/uk.min.js +7 -0
- package/src/wet-boew/js/i18n/vi.js +285 -0
- package/src/wet-boew/js/i18n/vi.min.js +7 -0
- package/src/wet-boew/js/i18n/zh-Hans.js +246 -0
- package/src/wet-boew/js/i18n/zh-Hans.min.js +7 -0
- package/src/wet-boew/js/i18n/zh.js +286 -0
- package/src/wet-boew/js/i18n/zh.min.js +7 -0
- package/src/wet-boew/js/ie8-wet-boew.js +3992 -0
- package/src/wet-boew/js/ie8-wet-boew.min.js +7 -0
- package/src/wet-boew/js/ie8-wet-boew2.js +15294 -0
- package/src/wet-boew/js/ie8-wet-boew2.min.js +7 -0
- package/src/wet-boew/js/jquery/2.2.4/jquery.js +9814 -0
- package/src/wet-boew/js/jquery/2.2.4/jquery.min.js +4 -0
- package/src/wet-boew/js/jquery/2.2.4/jquery.min.map +1 -0
- package/src/wet-boew/js/polyfills/datalist.js +423 -0
- package/src/wet-boew/js/polyfills/datalist.min.js +8 -0
- package/src/wet-boew/js/polyfills/datalist.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/datalist_dynamic.js +50 -0
- package/src/wet-boew/js/polyfills/datalist_dynamic.min.js +8 -0
- package/src/wet-boew/js/polyfills/datalist_dynamic.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/datepicker.js +338 -0
- package/src/wet-boew/js/polyfills/datepicker.min.js +8 -0
- package/src/wet-boew/js/polyfills/datepicker.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/details.js +126 -0
- package/src/wet-boew/js/polyfills/details.min.js +8 -0
- package/src/wet-boew/js/polyfills/details.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/jawsariafixes.js +47 -0
- package/src/wet-boew/js/polyfills/jawsariafixes.min.js +16 -0
- package/src/wet-boew/js/polyfills/jawsariafixes.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/meter.js +140 -0
- package/src/wet-boew/js/polyfills/meter.min.js +8 -0
- package/src/wet-boew/js/polyfills/meter.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/mobile.js +783 -0
- package/src/wet-boew/js/polyfills/mobile.min.js +8 -0
- package/src/wet-boew/js/polyfills/mobile.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/progress.js +107 -0
- package/src/wet-boew/js/polyfills/progress.min.js +8 -0
- package/src/wet-boew/js/polyfills/progress.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/slider.js +1343 -0
- package/src/wet-boew/js/polyfills/slider.min.js +9 -0
- package/src/wet-boew/js/polyfills/slider.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/slider_wrapper.js +73 -0
- package/src/wet-boew/js/polyfills/slider_wrapper.min.js +8 -0
- package/src/wet-boew/js/polyfills/slider_wrapper.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/svg.js +29 -0
- package/src/wet-boew/js/polyfills/svg.min.js +8 -0
- package/src/wet-boew/js/polyfills/svg.min.js.map +1 -0
- package/src/wet-boew/js/polyfills/test.js +603 -0
- package/src/wet-boew/js/polyfills/test.min.js +8 -0
- package/src/wet-boew/js/polyfills/test.min.js.map +1 -0
- package/src/wet-boew/js/wet-boew.js +17714 -0
- package/src/wet-boew/js/wet-boew.min.js +9 -0
- package/src/wet-boew/js/wet-boew.min.js.map +1 -0
- package/src/wet-boew/payload.json +1722 -0
@@ -0,0 +1,1343 @@
|
|
1
|
+
/*! Unobtrusive Slider Control / HTML5 Input Range polyfill - MIT/GPL2 @freqdec */
|
2
|
+
/*jshint sub:true, evil:true, boss:true */
|
3
|
+
var fdSlider = (function() {
|
4
|
+
var sliders = {},
|
5
|
+
uniqueid = 0,
|
6
|
+
mouseWheelEnabled = true,
|
7
|
+
fullARIA = true,
|
8
|
+
describedBy = "fd-slider-describedby",
|
9
|
+
varSetRules = {
|
10
|
+
onfocus:true,
|
11
|
+
onvalue:true
|
12
|
+
},
|
13
|
+
noRangeBar = false,
|
14
|
+
html5Animation = "jump",
|
15
|
+
useDOMAttrModEvt = false,
|
16
|
+
isOpera = Object.prototype.toString.call(window.opera) === "[object Opera]",
|
17
|
+
fpRegExp = /^([\-]{0,1}[0-9]+(\.[0-9]+){0,1})$/,
|
18
|
+
stepRegExp = /^([0-9]+(\.[0-9]+){0,1})$/;
|
19
|
+
|
20
|
+
var parseJSON = function(str) {
|
21
|
+
if(typeof str !== "string" || str === "") {
|
22
|
+
return {};
|
23
|
+
}
|
24
|
+
try {
|
25
|
+
// Does a JSON (native or not) Object exist
|
26
|
+
if(typeof JSON === "object" && typeof(JSON.parse) === "function") {
|
27
|
+
return JSON.parse(str);
|
28
|
+
// Genious code taken from: https://web.archive.org/web/20140715200301/http://kentbrewster.com/badges/
|
29
|
+
} else if(/mousewheelenabled|fullaria|describedby|norangebar|html5animation|varsetrules/.test(str.toLowerCase())) {
|
30
|
+
var f = Function(['var document,top,self,window,parent,Number,Date,Object,Function,',
|
31
|
+
'Array,String,Math,RegExp,Image,ActiveXObject;',
|
32
|
+
'return (' , str.replace(/<\!--.+-->/gim,'').replace(/\bfunction\b/g,'function-') , ');'].join(''));
|
33
|
+
return f();
|
34
|
+
}
|
35
|
+
} catch (e) { }
|
36
|
+
|
37
|
+
return {"err":"Could not parse the JSON object"};
|
38
|
+
};
|
39
|
+
|
40
|
+
var affectJSON = function(json) {
|
41
|
+
if(typeof json !== "object") {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
for(var key in json) {
|
45
|
+
value = json[key];
|
46
|
+
switch(key.toLowerCase()) {
|
47
|
+
case "mousewheelenabled":
|
48
|
+
mouseWheelEnabled = !!value;
|
49
|
+
break;
|
50
|
+
case "fullaria":
|
51
|
+
fullARIA = !!value;
|
52
|
+
break;
|
53
|
+
case "describedby":
|
54
|
+
describedBy = String(value);
|
55
|
+
break;
|
56
|
+
case "norangebar":
|
57
|
+
noRangeBar = !!value;
|
58
|
+
break;
|
59
|
+
case "html5animation":
|
60
|
+
html5Animation = String(value).search(/^(jump|tween|timed)$/i) != -1 ? String(value).toLowerCase() : "jump";
|
61
|
+
break;
|
62
|
+
case "watchattributes":
|
63
|
+
useDOMAttrModEvt = !!value;
|
64
|
+
break;
|
65
|
+
case "varsetrules":
|
66
|
+
if("onfocus" in value) {
|
67
|
+
varSetRules.onfocus = !!value.onfocus;
|
68
|
+
}
|
69
|
+
if("onvalue" in value) {
|
70
|
+
varSetRules.onvalue = !!value.onvalue;
|
71
|
+
}
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
};
|
76
|
+
var addEvent = function(obj, type, fn) {
|
77
|
+
if(obj.addEventListener) {
|
78
|
+
obj.addEventListener(type, fn, true);
|
79
|
+
} else if(obj.attachEvent) {
|
80
|
+
obj.attachEvent("on"+type, fn);
|
81
|
+
}
|
82
|
+
};
|
83
|
+
var removeEvent = function(obj, type, fn) {
|
84
|
+
try {
|
85
|
+
if(obj.removeEventListener) {
|
86
|
+
obj.removeEventListener(type, fn, true);
|
87
|
+
} else if(obj.detachEvent) {
|
88
|
+
obj.detachEvent("on"+type, fn);
|
89
|
+
}
|
90
|
+
} catch(err) {}
|
91
|
+
};
|
92
|
+
var stopEvent = function(e) {
|
93
|
+
e = e || window.event;
|
94
|
+
if(e.stopPropagation) {
|
95
|
+
e.stopPropagation();
|
96
|
+
e.preventDefault();
|
97
|
+
}
|
98
|
+
|
99
|
+
/*@cc_on@*/
|
100
|
+
/*@if(@_win32)
|
101
|
+
e.cancelBubble = true;
|
102
|
+
e.returnValue = false;
|
103
|
+
/*@end@*/
|
104
|
+
|
105
|
+
return false;
|
106
|
+
};
|
107
|
+
var preventDefault = function(e) {
|
108
|
+
e = e || window.event;
|
109
|
+
if(e.preventDefault) {
|
110
|
+
e.preventDefault();
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
e.returnValue = false;
|
114
|
+
};
|
115
|
+
// Add/Remove classname utility functions
|
116
|
+
var addClass = function(e,c) {
|
117
|
+
if(new RegExp("(^|\\s)" + c + "(\\s|$)").test(e.className)) {
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
e.className += ( e.className ? " " : "" ) + c;
|
121
|
+
};
|
122
|
+
var removeClass = function(e,c) {
|
123
|
+
e.className = !c ? "" : e.className.replace(new RegExp("(^|\\s)" + c + "(\\s|$)"), " ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
124
|
+
};
|
125
|
+
// Returns an Object of key value pairs indicating which sliders have values
|
126
|
+
// that have been "set" by the user. Normally used within form validation code
|
127
|
+
var getValueSet = function() {
|
128
|
+
var obj = {};
|
129
|
+
for(var id in sliders) {
|
130
|
+
obj[id] = sliders[id].getValueSet();
|
131
|
+
}
|
132
|
+
return obj;
|
133
|
+
};
|
134
|
+
// Sets the valueSet variable for a specific slider
|
135
|
+
var setValueSet = function(sliderId, tf) {
|
136
|
+
sliders[sliderId].setValueSet(!!tf);
|
137
|
+
};
|
138
|
+
// Does the slider exist in memory
|
139
|
+
var sliderExists = function(slider) {
|
140
|
+
return !!(slider in sliders && sliders.hasOwnProperty(slider));
|
141
|
+
};
|
142
|
+
// Javascript instantiation of a slider (input type="text|range" or select list)
|
143
|
+
var createSlider = function(options) {
|
144
|
+
if(!options || !options.inp || !options.inp.tagName || options.inp.tagName.search(/^input|select/i) == -1) { return false; }
|
145
|
+
|
146
|
+
options.html5Shim = options.html5Shim || false;
|
147
|
+
|
148
|
+
if(options.inp.tagName.toLowerCase() == "select") {
|
149
|
+
if(options.inp.options.length < 2) {
|
150
|
+
return false;
|
151
|
+
}
|
152
|
+
options.min = 0;
|
153
|
+
options.max = options.inp.options.length - 1;
|
154
|
+
options.step = 1;
|
155
|
+
options.precision = 0;
|
156
|
+
options.scale = false;
|
157
|
+
options.forceValue = true;
|
158
|
+
} else {
|
159
|
+
if(String(options.inp.type).search(/^(text|range)$/i) == -1) {
|
160
|
+
return false;
|
161
|
+
}
|
162
|
+
options.min = options.min && String(options.min).search(fpRegExp) != -1 ? +options.min : 0;
|
163
|
+
options.max = options.max && String(options.max).search(fpRegExp) != -1 ? +options.max : 100;
|
164
|
+
options.step = options.step && String(options.step).search(stepRegExp) != -1 ? options.step : 1;
|
165
|
+
options.precision = options.precision && String(options.precision).search(/^[0-9]+$/) != -1 ? options.precision : (String(options.step).search(/\.([0-9]+)$/) != -1 ? String(options.step).match(/\.([0-9]+)$/)[1].length : 0);
|
166
|
+
options.scale = options.scale || false;
|
167
|
+
options.forceValue = ("forceValue" in options) ? !!options.forceValue : false;
|
168
|
+
options.userSnap = ("userSnap" in options) ? !!options.userSnap : false;
|
169
|
+
}
|
170
|
+
options.ariaFormat = ("ariaFormat" in options) && typeof options.ariaFormat == "function" ? options.ariaFormat : false;
|
171
|
+
options.maxStep = options.maxStep && String(options.maxStep).search(stepRegExp) != -1 ? +options.maxStep : +options.step * 2;
|
172
|
+
options.classNames = options.classNames || "";
|
173
|
+
options.callbacks = options.callbacks || false;
|
174
|
+
|
175
|
+
destroySingleSlider(options.inp.id);
|
176
|
+
sliders[options.inp.id] = new fdRange(options);
|
177
|
+
return true;
|
178
|
+
};
|
179
|
+
var getAttribute = function(elem, att) {
|
180
|
+
return elem.getAttribute(att) || "";
|
181
|
+
};
|
182
|
+
// HTML5 input type="range" shim - called onload or onDomReady
|
183
|
+
var init = function() {
|
184
|
+
var inputs = document.getElementsByTagName("input"),
|
185
|
+
options,
|
186
|
+
defs;
|
187
|
+
|
188
|
+
for(var i = 0, inp; inp = inputs[i]; i++) {
|
189
|
+
|
190
|
+
if(inp.tagName.toLowerCase() == "input" &&
|
191
|
+
(getAttribute(inp,"type") && getAttribute(inp,"type").toLowerCase() == "range") &&
|
192
|
+
(getAttribute(inp, "min") && getAttribute(inp, "min").search(fpRegExp) != -1 ||
|
193
|
+
getAttribute(inp, "max") && getAttribute(inp, "max").search(fpRegExp) != -1 ||
|
194
|
+
getAttribute(inp, "step") && getAttribute(inp, "step").search(/^(any|([0-9]+(\.[0-9]+){0,1}))$/i) != -1
|
195
|
+
)) {
|
196
|
+
|
197
|
+
// Skip elements that have already been created are are resident in the DOM
|
198
|
+
if(inp.id && document.getElementById("fd-slider-"+inp.id)) {
|
199
|
+
continue;
|
200
|
+
// Destroy elements that have already been created but not resident in the DOM
|
201
|
+
} else if(inp.id && !document.getElementById("fd-slider-"+inp.id)) {
|
202
|
+
destroySingleSlider(inp.id);
|
203
|
+
}
|
204
|
+
|
205
|
+
// Create an id for the form element if necessary
|
206
|
+
if(!inp.id) {
|
207
|
+
inp.id = "fd-slider-form-elem-" + uniqueid++;
|
208
|
+
}
|
209
|
+
|
210
|
+
// Basic option Object
|
211
|
+
options = {
|
212
|
+
inp: inp,
|
213
|
+
callbacks: [],
|
214
|
+
animation: html5Animation,
|
215
|
+
vertical: getAttribute(inp, "data-fd-slider-vertical") ? true : (inp.offsetHeight > inp.offsetWidth),
|
216
|
+
classNames: getAttribute(inp, "data-fd-slider-vertical"),
|
217
|
+
html5Shim: true
|
218
|
+
};
|
219
|
+
|
220
|
+
if(options.vertical && !getAttribute(inp, "data-fd-slider-vertical")) {
|
221
|
+
options.inpHeight = inp.offsetHeight;
|
222
|
+
}
|
223
|
+
|
224
|
+
defs = getInputAttributes(inp);
|
225
|
+
|
226
|
+
options.min = defs.min;
|
227
|
+
options.max = defs.max;
|
228
|
+
options.step = defs.step;
|
229
|
+
options.precision = String(options.step).search(/\.([0-9]+)$/) != -1 ? String(options.step).match(/\.([0-9]+)$/)[1].length : 0;
|
230
|
+
options.maxStep = options.step * 2;
|
231
|
+
|
232
|
+
destroySingleSlider(options.inp.id);
|
233
|
+
sliders[options.inp.id] = new fdRange(options);
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
return true;
|
238
|
+
};
|
239
|
+
var getInputAttributes = function(inp) {
|
240
|
+
return {
|
241
|
+
"min":+(getAttribute(inp, "min") || 0),
|
242
|
+
"max":+(getAttribute(inp, "max") || 100),
|
243
|
+
"step":+(getAttribute(inp, "step").search(stepRegExp) != -1 ? inp.getAttribute("step") : 1)
|
244
|
+
};
|
245
|
+
};
|
246
|
+
var destroySingleSlider = function(id) {
|
247
|
+
if(id in sliders && sliders.hasOwnProperty(id)) {
|
248
|
+
sliders[id].destroy();
|
249
|
+
delete sliders[id];
|
250
|
+
return true;
|
251
|
+
};
|
252
|
+
return false;
|
253
|
+
};
|
254
|
+
var destroyAllsliders = function(e) {
|
255
|
+
for(var slider in sliders) {
|
256
|
+
if(sliders.hasOwnProperty(slider)) {
|
257
|
+
sliders[slider].destroy();
|
258
|
+
}
|
259
|
+
}
|
260
|
+
sliders = [];
|
261
|
+
};
|
262
|
+
var unload = function(e) {
|
263
|
+
destroyAllsliders();
|
264
|
+
sliders = null;
|
265
|
+
};
|
266
|
+
var resize = function(e) {
|
267
|
+
for(var slider in sliders) {
|
268
|
+
if(sliders.hasOwnProperty(slider)) {
|
269
|
+
sliders[slider].onResize();
|
270
|
+
}
|
271
|
+
}
|
272
|
+
};
|
273
|
+
var rescanAttributes = function() {
|
274
|
+
for(var slider in sliders) {
|
275
|
+
if(sliders.hasOwnProperty(slider)) {
|
276
|
+
sliders[slider].rescan();
|
277
|
+
}
|
278
|
+
}
|
279
|
+
};
|
280
|
+
var onDomReady = function() {
|
281
|
+
removeOnLoadEvent();
|
282
|
+
init();
|
283
|
+
};
|
284
|
+
var removeOnLoadEvent = function() {
|
285
|
+
removeEvent(window, "load", init);
|
286
|
+
};
|
287
|
+
function fdRange(options) {
|
288
|
+
var inp = options.inp,
|
289
|
+
disabled = false,
|
290
|
+
tagName = inp.tagName.toLowerCase(),
|
291
|
+
min = +options.min,
|
292
|
+
max = +options.max,
|
293
|
+
rMin = +options.min,
|
294
|
+
rMax = +options.max,
|
295
|
+
range = Math.abs(max - min),
|
296
|
+
step = tagName == "select" ? 1 : +options.step,
|
297
|
+
maxStep = options.maxStep ? +options.maxStep : step * 2,
|
298
|
+
precision = options.precision || 0,
|
299
|
+
steps = Math.ceil(range / step),
|
300
|
+
scale = options.scale || false,
|
301
|
+
hideInput = !!options.hideInput,
|
302
|
+
animation = options.animation || "",
|
303
|
+
vertical = !!options.vertical,
|
304
|
+
callbacks = options.callbacks || {},
|
305
|
+
classNames = options.classNames || "",
|
306
|
+
html5Shim = !!options.html5Shim,
|
307
|
+
defaultVal = max < min ? min : min + ((max - min) / 2),
|
308
|
+
resetDef = tagName == "select" ? inp.selectedIndex : inp.defaultValue || defaultVal,
|
309
|
+
forceValue = html5Shim || !!options.forceValue,
|
310
|
+
inpHeight = html5Shim && vertical && ("inpHeight" in options) ? options.inpHeight : false,
|
311
|
+
ariaFormat = !html5Shim && options.ariaFormat ? options.ariaFormat : false,
|
312
|
+
userSnap = !html5Shim && !(tagName == "select") && ("userSnap" in options) ? !!options.userSnap : false,
|
313
|
+
userInput = false,
|
314
|
+
timer = null,
|
315
|
+
kbEnabled = true,
|
316
|
+
initialVal = tagName == "select" ? inp.selectedIndex : inp.value,
|
317
|
+
sliderH = 0,
|
318
|
+
sliderW = 0,
|
319
|
+
tweenX = 0,
|
320
|
+
tweenB = 0,
|
321
|
+
tweenC = 0,
|
322
|
+
tweenD = 0,
|
323
|
+
frame = 0,
|
324
|
+
x = 0,
|
325
|
+
y = 0,
|
326
|
+
rMaxPx = 0,
|
327
|
+
rMinPx = 0,
|
328
|
+
handlePos = 0,
|
329
|
+
destPos = 0,
|
330
|
+
mousePos = 0,
|
331
|
+
stepPx = 0,
|
332
|
+
userSet = false,
|
333
|
+
touchEvents = false,
|
334
|
+
outerWrapper,
|
335
|
+
innerWrapper,
|
336
|
+
ieBlur,
|
337
|
+
handle,
|
338
|
+
rangeBar,
|
339
|
+
bar;
|
340
|
+
|
341
|
+
// For the reset event to work we have to set a defaultValue
|
342
|
+
if(tagName == "input" && forceValue && !inp.defaultValue) {
|
343
|
+
inp.defaultValue = getWorkingValueFromInput();
|
344
|
+
}
|
345
|
+
|
346
|
+
// Make sure we have a negative step if the max < min
|
347
|
+
if(max < min) {
|
348
|
+
step = -Math.abs(step);
|
349
|
+
maxStep = -Math.abs(maxStep);
|
350
|
+
}
|
351
|
+
|
352
|
+
// Add the 100% scale mark if needs be. This is hacky.
|
353
|
+
if(scale) {
|
354
|
+
scale[100] = max;
|
355
|
+
}
|
356
|
+
|
357
|
+
// Set the "userSet" variable programmatically for this slider
|
358
|
+
function valueSet(tf) {
|
359
|
+
tf = !!tf;
|
360
|
+
if(tf != userSet) {
|
361
|
+
userSet = tf;
|
362
|
+
valueToPixels(getWorkingValueFromInput());
|
363
|
+
}
|
364
|
+
}
|
365
|
+
|
366
|
+
function rescanAttrs() {
|
367
|
+
if(!useDOMAttrModEvt || tagName == "select") {
|
368
|
+
return;
|
369
|
+
}
|
370
|
+
|
371
|
+
var defs = getInputAttributes(inp);
|
372
|
+
|
373
|
+
if(defs.min == min && defs.max == max && defs.step == step) {
|
374
|
+
return;
|
375
|
+
}
|
376
|
+
|
377
|
+
min = +defs.min;
|
378
|
+
max = +defs.max;
|
379
|
+
rMin = min;
|
380
|
+
rMax = max;
|
381
|
+
step = +defs.step;
|
382
|
+
range = Math.abs(max - min);
|
383
|
+
maxStep = step * 2;
|
384
|
+
steps = Math.ceil(range / step);
|
385
|
+
userSet = false;
|
386
|
+
setSliderRange(min, max);
|
387
|
+
}
|
388
|
+
|
389
|
+
function disableSlider(noCallback) {
|
390
|
+
if(disabled && !noCallback) {
|
391
|
+
return;
|
392
|
+
}
|
393
|
+
|
394
|
+
try {
|
395
|
+
setTabIndex(handle, -1);
|
396
|
+
removeEvent(handle, "focus", onFocus);
|
397
|
+
removeEvent(handle, "blur", onBlur);
|
398
|
+
|
399
|
+
if(!isOpera) {
|
400
|
+
removeEvent(handle, "keydown", onKeyDown);
|
401
|
+
removeEvent(handle, "keypress", onKeyPress);
|
402
|
+
} else {
|
403
|
+
removeEvent(handle, "keypress", onKeyDown);
|
404
|
+
}
|
405
|
+
|
406
|
+
removeEvent(outerWrapper, "mouseover", onMouseOver);
|
407
|
+
removeEvent(outerWrapper, "mouseout", onMouseOut);
|
408
|
+
removeEvent(outerWrapper, "mousedown", onMouseDown);
|
409
|
+
removeEvent(outerWrapper, "touchstart", onMouseDown);
|
410
|
+
|
411
|
+
if(mouseWheelEnabled) {
|
412
|
+
if (window.addEventListener && !window.devicePixelRatio) window.removeEventListener('DOMMouseScroll', trackMouseWheel, false);
|
413
|
+
else {
|
414
|
+
removeEvent(document, "mousewheel", trackMouseWheel);
|
415
|
+
removeEvent(window, "mousewheel", trackMouseWheel);
|
416
|
+
}
|
417
|
+
}
|
418
|
+
} catch(err) {}
|
419
|
+
|
420
|
+
removeClass(innerWrapper, "fd-slider-focused");
|
421
|
+
removeClass(innerWrapper, "fd-slider-active");
|
422
|
+
|
423
|
+
addClass(innerWrapper, "fd-slider-disabled");
|
424
|
+
outerWrapper.setAttribute("aria-disabled", true);
|
425
|
+
inp.disabled = disabled = true;
|
426
|
+
clearTimeout(timer);
|
427
|
+
|
428
|
+
if(!noCallback) {
|
429
|
+
callback("disable");
|
430
|
+
}
|
431
|
+
}
|
432
|
+
|
433
|
+
function enableSlider(noCallback) {
|
434
|
+
if(!disabled && !noCallback) {
|
435
|
+
return;
|
436
|
+
}
|
437
|
+
|
438
|
+
setTabIndex(handle, 0);
|
439
|
+
addEvent(handle, "focus", onFocus);
|
440
|
+
addEvent(handle, "blur", onBlur);
|
441
|
+
|
442
|
+
if(!isOpera) {
|
443
|
+
addEvent(handle, "keydown", onKeyDown);
|
444
|
+
addEvent(handle, "keypress", onKeyPress);
|
445
|
+
} else {
|
446
|
+
addEvent(handle, "keypress", onKeyDown);
|
447
|
+
}
|
448
|
+
|
449
|
+
addEvent(outerWrapper, "touchstart", onMouseDown);
|
450
|
+
addEvent(outerWrapper, "mousedown", onMouseDown);
|
451
|
+
addEvent(outerWrapper, "mouseover", onMouseOver);
|
452
|
+
addEvent(outerWrapper, "mouseout", onMouseOut);
|
453
|
+
|
454
|
+
removeClass(innerWrapper, "fd-slider-disabled");
|
455
|
+
outerWrapper.setAttribute("aria-disabled", false);
|
456
|
+
inp.disabled = disabled = touchEvents = false;
|
457
|
+
|
458
|
+
if(!noCallback) {
|
459
|
+
callback("enable");
|
460
|
+
}
|
461
|
+
}
|
462
|
+
|
463
|
+
// Destroys a slider
|
464
|
+
function destroySlider() {
|
465
|
+
clearTimeout(timer);
|
466
|
+
ieBlur = bar = handle = outerWrapper = innerWrapper = timer = null;
|
467
|
+
callback("destroy");
|
468
|
+
callbacks = null;
|
469
|
+
}
|
470
|
+
|
471
|
+
// Calculates the pixel increment etc
|
472
|
+
function redraw() {
|
473
|
+
locate();
|
474
|
+
// Internet Explorer requires the try catch as hidden
|
475
|
+
// elements throw errors
|
476
|
+
try {
|
477
|
+
var sW = outerWrapper.offsetWidth,
|
478
|
+
sH = outerWrapper.offsetHeight,
|
479
|
+
hW = handle.offsetWidth,
|
480
|
+
hH = handle.offsetHeight,
|
481
|
+
bH = bar.offsetHeight,
|
482
|
+
bW = bar.offsetWidth,
|
483
|
+
mPx = vertical ? sH - hH : sW - hW;
|
484
|
+
|
485
|
+
stepPx = mPx / steps;
|
486
|
+
rMinPx = Math.max(scale ? percentToPixels(valueToPercent(rMin)) : Math.abs((rMin - min) / step) * stepPx, 0);
|
487
|
+
rMaxPx = Math.min(scale ? percentToPixels(valueToPercent(rMax)) : Math.abs((rMax - min) / step) * stepPx, Math.floor(vertical ? sH - hH : sW - hW));
|
488
|
+
|
489
|
+
sliderW = sW;
|
490
|
+
sliderH = sH;
|
491
|
+
|
492
|
+
valueToPixels(forceValue ? getWorkingValueFromInput() : (tagName == "select" ? inp.selectedIndex : parseFloat(inp.value)), false);
|
493
|
+
|
494
|
+
} catch(err) {}
|
495
|
+
callback("redraw");
|
496
|
+
}
|
497
|
+
|
498
|
+
// Calls a callback function
|
499
|
+
function callback(type) {
|
500
|
+
if(!html5Shim) {
|
501
|
+
if(callbacks.hasOwnProperty(type)) {
|
502
|
+
var cbObj = {"userSet":userSet, "disabled":disabled, "elem":inp, "value":tagName == "select" ? inp.options[inp.selectedIndex].value : inp.value};
|
503
|
+
|
504
|
+
// Call all functions in sequence
|
505
|
+
for(var i = 0, func; func = callbacks[type][i]; i++) {
|
506
|
+
func.call(inp, cbObj);
|
507
|
+
}
|
508
|
+
}
|
509
|
+
} else if(type.match(/^(blur|focus|change)$/i)) {
|
510
|
+
var e;
|
511
|
+
if(typeof(document.createEvent) != 'undefined') {
|
512
|
+
e = document.createEvent('HTMLEvents');
|
513
|
+
e.initEvent(type, true, true);
|
514
|
+
inp.dispatchEvent(e);
|
515
|
+
} else if(typeof(document.createEventObject) != 'undefined') {
|
516
|
+
try {
|
517
|
+
e = document.createEventObject();
|
518
|
+
inp.fireEvent('on' + type.toLowerCase(), e);
|
519
|
+
} catch(err){ }
|
520
|
+
}
|
521
|
+
}
|
522
|
+
}
|
523
|
+
|
524
|
+
// FOCUS & BLUR events
|
525
|
+
function onFocus(e) {
|
526
|
+
addClass(innerWrapper, 'fd-slider-focused');
|
527
|
+
|
528
|
+
// Is the value said to have been set by the user onfocus
|
529
|
+
if(varSetRules.onfocus) {
|
530
|
+
userSet = true;
|
531
|
+
valueToPixels(getWorkingValueFromInput());
|
532
|
+
}
|
533
|
+
|
534
|
+
// If mousewheel events required then add them
|
535
|
+
if(mouseWheelEnabled) {
|
536
|
+
addEvent(window, 'DOMMouseScroll', trackMouseWheel);
|
537
|
+
addEvent(document, 'mousewheel', trackMouseWheel);
|
538
|
+
if(!isOpera) {
|
539
|
+
addEvent(window, 'mousewheel', trackMouseWheel);
|
540
|
+
}
|
541
|
+
}
|
542
|
+
|
543
|
+
callback("focus");
|
544
|
+
return true;
|
545
|
+
}
|
546
|
+
|
547
|
+
function onBlur(e) {
|
548
|
+
removeClass(innerWrapper, 'fd-slider-focused');
|
549
|
+
|
550
|
+
// Remove mousewheel events if necessary
|
551
|
+
if(mouseWheelEnabled) {
|
552
|
+
removeEvent(document, 'mousewheel', trackMouseWheel);
|
553
|
+
removeEvent(window, 'DOMMouseScroll', trackMouseWheel);
|
554
|
+
if(!isOpera) {
|
555
|
+
removeEvent(window, 'mousewheel', trackMouseWheel);
|
556
|
+
}
|
557
|
+
}
|
558
|
+
|
559
|
+
kbEnabled = true;
|
560
|
+
callback("blur");
|
561
|
+
}
|
562
|
+
|
563
|
+
// MOUSEWHEEL events
|
564
|
+
function trackMouseWheel(e) {
|
565
|
+
if(!kbEnabled) {
|
566
|
+
return;
|
567
|
+
}
|
568
|
+
|
569
|
+
e = e || window.event;
|
570
|
+
var delta = 0,
|
571
|
+
value;
|
572
|
+
|
573
|
+
if (e.wheelDelta) {
|
574
|
+
delta = e.wheelDelta/120;
|
575
|
+
// Older versions of Opera require a small hack to inverse the delta
|
576
|
+
if (isOpera && window.opera.version() < 9.2) {
|
577
|
+
delta = -delta;
|
578
|
+
}
|
579
|
+
} else if(e.detail) {
|
580
|
+
delta = -e.detail/3;
|
581
|
+
}
|
582
|
+
|
583
|
+
if(vertical) {
|
584
|
+
delta = -delta;
|
585
|
+
}
|
586
|
+
|
587
|
+
if(delta) {
|
588
|
+
value = getWorkingValueFromInput();
|
589
|
+
value += (delta < 0) ? -step : step;
|
590
|
+
userSet = true;
|
591
|
+
valueToPixels(getValidValue(value));
|
592
|
+
}
|
593
|
+
|
594
|
+
preventDefault(e);
|
595
|
+
}
|
596
|
+
|
597
|
+
// KEYBOARD events
|
598
|
+
function onKeyPress(e) {
|
599
|
+
e = e || window.event;
|
600
|
+
// Let all non-hijacked keyboard events pass
|
601
|
+
if((e.keyCode >= 33 && e.keyCode <= 40) || !kbEnabled || e.keyCode == 45 || e.keyCode == 46) {
|
602
|
+
return stopEvent(e);
|
603
|
+
}
|
604
|
+
return true;
|
605
|
+
}
|
606
|
+
|
607
|
+
function onKeyDown(e) {
|
608
|
+
if(!kbEnabled) {
|
609
|
+
return true;
|
610
|
+
}
|
611
|
+
|
612
|
+
e = e || window.event;
|
613
|
+
var kc = e.keyCode !== null ? e.keyCode : e.charCode,
|
614
|
+
value;
|
615
|
+
|
616
|
+
if(kc < 33 || (kc > 40 && (kc != 45 && kc != 46))) {
|
617
|
+
return true;
|
618
|
+
}
|
619
|
+
|
620
|
+
value = getWorkingValueFromInput();
|
621
|
+
|
622
|
+
if( kc == 37 || kc == 40 || kc == 46 || kc == 34) {
|
623
|
+
// left, down, ins, page down
|
624
|
+
value -= (e.ctrlKey || kc == 34 ? +maxStep : +step);
|
625
|
+
} else if( kc == 39 || kc == 38 || kc == 45 || kc == 33) {
|
626
|
+
// right, up, del, page up
|
627
|
+
value += (e.ctrlKey || kc == 33 ? +maxStep : +step);
|
628
|
+
} else if( kc == 35 ) {
|
629
|
+
// max
|
630
|
+
value = rMax;
|
631
|
+
} else if( kc == 36 ) {
|
632
|
+
// min
|
633
|
+
value = rMin;
|
634
|
+
}
|
635
|
+
|
636
|
+
userSet = true;
|
637
|
+
valueToPixels(getValidValue(value));
|
638
|
+
|
639
|
+
callback("update");
|
640
|
+
|
641
|
+
// Opera doesn't let us cancel key events so the up/down arrows and home/end buttons will scroll the screen - which sucks
|
642
|
+
preventDefault(e);
|
643
|
+
}
|
644
|
+
|
645
|
+
// MOUSE & TOUCH events
|
646
|
+
|
647
|
+
function onMouseOver(e) {
|
648
|
+
addClass(innerWrapper, 'fd-slider-hover');
|
649
|
+
}
|
650
|
+
|
651
|
+
function onMouseOut(e) {
|
652
|
+
// Should really check we are not still in the slider
|
653
|
+
removeClass(innerWrapper, 'fd-slider-hover');
|
654
|
+
}
|
655
|
+
|
656
|
+
// Mousedown on the slider
|
657
|
+
function onMouseDown(e) {
|
658
|
+
e = e || window.event;
|
659
|
+
|
660
|
+
// Stop page scrolling
|
661
|
+
preventDefault(e);
|
662
|
+
|
663
|
+
// Grab the event target
|
664
|
+
var targ;
|
665
|
+
if (e.target) {
|
666
|
+
targ = e.target;
|
667
|
+
} else if (e.srcElement) {
|
668
|
+
targ = e.srcElement;
|
669
|
+
}
|
670
|
+
if(targ && targ.nodeType == 3) {
|
671
|
+
targ = targ.parentNode;
|
672
|
+
}
|
673
|
+
|
674
|
+
// Are we using touchEvents
|
675
|
+
if(e.touches) {
|
676
|
+
// Skip gestures
|
677
|
+
if(e.targetTouches && e.targetTouches.length != 1) {
|
678
|
+
return false;
|
679
|
+
}
|
680
|
+
|
681
|
+
e = e.touches[0];
|
682
|
+
touchEvents = true;
|
683
|
+
}
|
684
|
+
|
685
|
+
// Stop any animation timers
|
686
|
+
clearTimeout(timer);
|
687
|
+
timer = null;
|
688
|
+
|
689
|
+
// Not keyboard enabled
|
690
|
+
kbEnabled = false;
|
691
|
+
|
692
|
+
// User has set a value
|
693
|
+
userSet = true;
|
694
|
+
|
695
|
+
// Handle mousedown - initiate drag
|
696
|
+
if(targ.className.search("fd-slider-handle") != -1) {
|
697
|
+
mousePos = vertical ? e.clientY : e.clientX;
|
698
|
+
handlePos = parseInt(vertical ? handle.offsetTop : handle.offsetLeft)||0;
|
699
|
+
|
700
|
+
// Set a value on first click even if no movement
|
701
|
+
trackMouse(e);
|
702
|
+
|
703
|
+
if(!touchEvents) {
|
704
|
+
addEvent(document, 'mousemove', trackMouse);
|
705
|
+
addEvent(document, 'mouseup', stopDrag);
|
706
|
+
} else {
|
707
|
+
addEvent(document, 'touchmove', trackMouse);
|
708
|
+
addEvent(document, 'touchend', stopDrag);
|
709
|
+
// Remove mouseEvents to stop them firing after the touch event
|
710
|
+
removeEvent(outerWrapper, "mousedown", onMouseDown);
|
711
|
+
}
|
712
|
+
|
713
|
+
addClass(innerWrapper, 'fd-slider-active');
|
714
|
+
addClass(document.body, "fd-slider-drag-" + (vertical ? "vertical" : "horizontal"));
|
715
|
+
|
716
|
+
callback("dragstart");
|
717
|
+
|
718
|
+
// Wrapper mousedown - initiate animation to click point
|
719
|
+
} else {
|
720
|
+
locate();
|
721
|
+
|
722
|
+
var posx = 0;
|
723
|
+
|
724
|
+
if(e.pageX || e.pageY) {
|
725
|
+
posx = vertical ? e.pageY : e.pageX;
|
726
|
+
} else if (e.clientX || e.clientY) {
|
727
|
+
posx = vertical ? e.clientY + document.body.scrollTop + document.documentElement.scrollTop : e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
728
|
+
}
|
729
|
+
|
730
|
+
posx -= vertical ? y + Math.round(handle.offsetHeight / 2) : x + Math.round(handle.offsetWidth / 2);
|
731
|
+
posx = snapToPxValue(posx);
|
732
|
+
|
733
|
+
// Tween animation to click point
|
734
|
+
if(animation == "tween") {
|
735
|
+
addClass(innerWrapper, 'fd-slider-active');
|
736
|
+
tweenTo(posx);
|
737
|
+
// Progressive increment to click point
|
738
|
+
} else if(animation == "timed") {
|
739
|
+
addClass(innerWrapper, 'fd-slider-active');
|
740
|
+
addEvent(document, touchEvents ? 'touchend' : 'mouseup', onDocMouseUp);
|
741
|
+
destPos = posx;
|
742
|
+
onTimer();
|
743
|
+
// Immediate jump to click point
|
744
|
+
} else {
|
745
|
+
pixelsToValue(posx);
|
746
|
+
//addEvent(document, touchEvents ? 'touchend' : 'mouseup', onMouseUp);
|
747
|
+
}
|
748
|
+
}
|
749
|
+
|
750
|
+
return false;
|
751
|
+
}
|
752
|
+
|
753
|
+
// Progressive increment to click point - clear the animation timer and remove the mouseup/touchend event
|
754
|
+
function onDocMouseUp( e ) {
|
755
|
+
e = e || window.event;
|
756
|
+
|
757
|
+
preventDefault(e);
|
758
|
+
removeEvent(document, touchEvents ? 'touchend' : 'mouseup', onDocMouseUp);
|
759
|
+
removeClass(innerWrapper, "fd-slider-active");
|
760
|
+
|
761
|
+
clearTimeout(timer);
|
762
|
+
timer = null;
|
763
|
+
kbEnabled = true;
|
764
|
+
|
765
|
+
return false;
|
766
|
+
}
|
767
|
+
|
768
|
+
// Mouseup or touchend event on the document to stop drag
|
769
|
+
function stopDrag(e) {
|
770
|
+
e = e || window.event;
|
771
|
+
|
772
|
+
preventDefault(e);
|
773
|
+
|
774
|
+
if(touchEvents) {
|
775
|
+
removeEvent(document, 'touchmove', trackMouse);
|
776
|
+
removeEvent(document, 'touchend', stopDrag);
|
777
|
+
} else {
|
778
|
+
removeEvent(document, 'mousemove', trackMouse);
|
779
|
+
removeEvent(document, 'mouseup', stopDrag);
|
780
|
+
}
|
781
|
+
|
782
|
+
kbEnabled = true;
|
783
|
+
removeClass(document.body, "fd-slider-drag-" + (vertical ? "vertical" : "horizontal"));
|
784
|
+
removeClass(innerWrapper, "fd-slider-active");
|
785
|
+
|
786
|
+
callback("dragend");
|
787
|
+
|
788
|
+
return false;
|
789
|
+
}
|
790
|
+
|
791
|
+
// Mousemove or touchmove event on the drag handle
|
792
|
+
function trackMouse(e) {
|
793
|
+
e = e || window.event;
|
794
|
+
|
795
|
+
preventDefault(e);
|
796
|
+
|
797
|
+
if(e.touches) {
|
798
|
+
// Skip gestures
|
799
|
+
if(e.targetTouches && e.targetTouches.length != 1) {
|
800
|
+
return false;
|
801
|
+
}
|
802
|
+
e = e.touches[0];
|
803
|
+
}
|
804
|
+
|
805
|
+
pixelsToValue(snapToPxValue(handlePos + (vertical ? e.clientY - mousePos : e.clientX - mousePos)));
|
806
|
+
|
807
|
+
return false;
|
808
|
+
}
|
809
|
+
|
810
|
+
// Increments the slider by "inc" steps
|
811
|
+
function increment(inc) {
|
812
|
+
var value = getWorkingValueFromInput();
|
813
|
+
userSet = true;
|
814
|
+
value += inc * step;
|
815
|
+
valueToPixels(getValidValue(value));
|
816
|
+
}
|
817
|
+
|
818
|
+
// Attempts to locate the on-screen position of the slider
|
819
|
+
function locate(){
|
820
|
+
var curleft = 0,
|
821
|
+
curtop = 0,
|
822
|
+
obj = outerWrapper;
|
823
|
+
|
824
|
+
// Try catch for IE's benefit
|
825
|
+
try {
|
826
|
+
do {
|
827
|
+
curleft += obj.offsetLeft;
|
828
|
+
curtop += obj.offsetTop;
|
829
|
+
} while(obj = obj.offsetParent);
|
830
|
+
} catch(err) {}
|
831
|
+
x = curleft;
|
832
|
+
y = curtop;
|
833
|
+
}
|
834
|
+
|
835
|
+
// Used during the progressive animation to click point
|
836
|
+
function onTimer() {
|
837
|
+
var xtmp = parseInt(vertical ? handle.offsetTop : handle.offsetLeft, 10);
|
838
|
+
xtmp = Math.round((destPos < xtmp) ? Math.max(destPos, Math.floor(xtmp - stepPx)) : Math.min(destPos, Math.ceil(xtmp + stepPx)));
|
839
|
+
|
840
|
+
pixelsToValue(snapToPxValue(xtmp));
|
841
|
+
if(xtmp != destPos) {
|
842
|
+
timer = setTimeout(onTimer, steps > 20 ? 50 : 100);
|
843
|
+
} else {
|
844
|
+
kbEnabled = true;
|
845
|
+
removeClass(innerWrapper, "fd-slider-active");
|
846
|
+
callback("finalise");
|
847
|
+
}
|
848
|
+
}
|
849
|
+
|
850
|
+
var tween = function(){
|
851
|
+
frame++;
|
852
|
+
var c = tweenC,
|
853
|
+
d = 20,
|
854
|
+
t = frame,
|
855
|
+
b = tweenB,
|
856
|
+
x = Math.ceil((t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b);
|
857
|
+
|
858
|
+
pixelsToValue(t == d ? tweenX : x);
|
859
|
+
|
860
|
+
if(t!=d) {
|
861
|
+
// Call the "move" callback on each animation increment
|
862
|
+
callback("move");
|
863
|
+
timer = setTimeout(tween, 20);
|
864
|
+
} else {
|
865
|
+
clearTimeout(timer);
|
866
|
+
timer = null;
|
867
|
+
kbEnabled = true;
|
868
|
+
|
869
|
+
removeClass(innerWrapper, "fd-slider-focused");
|
870
|
+
removeClass(innerWrapper, "fd-slider-active");
|
871
|
+
|
872
|
+
// Call the "finalise" callback whenever the animation is complete
|
873
|
+
callback("finalise");
|
874
|
+
}
|
875
|
+
};
|
876
|
+
|
877
|
+
function tweenTo(tx){
|
878
|
+
kbEnabled = false;
|
879
|
+
tweenX = parseInt(tx, 10);
|
880
|
+
tweenB = parseInt(vertical ? handle.offsetTop : handle.offsetLeft, 10);
|
881
|
+
tweenC = tweenX - tweenB;
|
882
|
+
tweenD = 20;
|
883
|
+
frame = 0;
|
884
|
+
|
885
|
+
if(!timer) {
|
886
|
+
timer = setTimeout(tween, 20);
|
887
|
+
}
|
888
|
+
}
|
889
|
+
|
890
|
+
// Returns a value within the range & sets the userSet var
|
891
|
+
// i.e. has the user entered a valid value
|
892
|
+
function checkValue(value) {
|
893
|
+
if(isNaN(value) || value === "" || typeof value == "undefined") {
|
894
|
+
userSet = false;
|
895
|
+
return defaultVal;
|
896
|
+
} else if(value < Math.min(rMin,rMax)) {
|
897
|
+
userSet = false;
|
898
|
+
return Math.min(rMin,rMax);
|
899
|
+
} else if(value > Math.max(rMin,rMax)) {
|
900
|
+
userSet = false;
|
901
|
+
return Math.max(rMin,rMax);
|
902
|
+
}
|
903
|
+
userSet = true;
|
904
|
+
return value;
|
905
|
+
}
|
906
|
+
|
907
|
+
// Returns a value within a range - uses the form element value as base
|
908
|
+
function getWorkingValueFromInput() {
|
909
|
+
return getValidValue(tagName == "input" ? parseFloat(inp.value) : inp.selectedIndex);
|
910
|
+
}
|
911
|
+
|
912
|
+
// Returns a value within the range
|
913
|
+
function getValidValue(value) {
|
914
|
+
return (isNaN(value) || value === "" || typeof value == "undefined") ? defaultVal : Math.min(Math.max(value, Math.min(rMin,rMax)), Math.max(rMin,rMax));
|
915
|
+
}
|
916
|
+
|
917
|
+
// Calculates value according to pixel position of slider handle
|
918
|
+
function pixelsToValue(px) {
|
919
|
+
var val = getValidValue(scale ? percentToValue(pixelsToPercent(px)) : vertical ? max - (Math.round(px / stepPx) * step) : min + (Math.round(px / stepPx) * step));
|
920
|
+
|
921
|
+
handle.style[vertical ? "top" : "left"] = (px || 0) + "px";
|
922
|
+
redrawRange();
|
923
|
+
setInputValue((tagName == "select" || step == 1) ? Math.round(val) : val);
|
924
|
+
}
|
925
|
+
|
926
|
+
// Calculates pixel position according to form element value
|
927
|
+
function valueToPixels(val, updateInputValue) {
|
928
|
+
var clearVal = false,
|
929
|
+
value;
|
930
|
+
|
931
|
+
// Allow empty values for non-polyfill sliders
|
932
|
+
if((typeof val === "undefined" || isNaN(val) || val === "") && tagName == "input" && !forceValue) {
|
933
|
+
value = defaultVal;
|
934
|
+
clearVal = true;
|
935
|
+
userSet = false;
|
936
|
+
} else {
|
937
|
+
value = checkValue(val);
|
938
|
+
}
|
939
|
+
|
940
|
+
handle.style[vertical ? "top" : "left"] = (scale ? percentToPixels(valueToPercent(value)) : vertical ? Math.round(((max - value) / step) * stepPx) : Math.round(((value - min) / step) * stepPx)) + "px";
|
941
|
+
redrawRange();
|
942
|
+
if(typeof updateInputValue !== false) {
|
943
|
+
setInputValue(clearVal ? "" : value);
|
944
|
+
}
|
945
|
+
}
|
946
|
+
|
947
|
+
// Rounds a pixel value to the nearest "snap" point on the slider scale
|
948
|
+
function snapToPxValue(px) {
|
949
|
+
if(scale) {
|
950
|
+
return Math.max(Math.min(rMaxPx, px), rMinPx);
|
951
|
+
} else {
|
952
|
+
var rem = px % stepPx;
|
953
|
+
if(rem && rem >= (stepPx / 2)) {
|
954
|
+
px += (stepPx - rem);
|
955
|
+
} else {
|
956
|
+
px -= rem;
|
957
|
+
}
|
958
|
+
|
959
|
+
if(px < Math.min(Math.abs(rMinPx), Math.abs(rMaxPx))) {
|
960
|
+
px = Math.min(Math.abs(rMinPx), Math.abs(rMaxPx));
|
961
|
+
} else if(px > Math.max(Math.abs(rMinPx), Math.abs(rMaxPx))) {
|
962
|
+
px = Math.max(Math.abs(rMinPx), Math.abs(rMaxPx));
|
963
|
+
}
|
964
|
+
|
965
|
+
return Math.min(Math.max(px, 0), rMaxPx);
|
966
|
+
}
|
967
|
+
}
|
968
|
+
|
969
|
+
// Calculates a value according to percentage of distance handle has travelled
|
970
|
+
function percentToValue(pct) {
|
971
|
+
var st = 0,
|
972
|
+
fr = min,
|
973
|
+
value;
|
974
|
+
|
975
|
+
for(var s in scale) {
|
976
|
+
if(!scale.hasOwnProperty(s)) {
|
977
|
+
continue;
|
978
|
+
}
|
979
|
+
|
980
|
+
if(pct >= st && pct <= +s ) {
|
981
|
+
value = fr + ((pct - st) * (+scale[s] - fr) ) / (+s - st);
|
982
|
+
}
|
983
|
+
|
984
|
+
st = +s;
|
985
|
+
fr = +scale[s];
|
986
|
+
}
|
987
|
+
|
988
|
+
return value;
|
989
|
+
}
|
990
|
+
|
991
|
+
// Calculates the percentage handle position according to form element value
|
992
|
+
function valueToPercent(value) {
|
993
|
+
var st = 0,
|
994
|
+
fr = min,
|
995
|
+
pct = 0;
|
996
|
+
|
997
|
+
for(var s in scale) {
|
998
|
+
if(!scale.hasOwnProperty(s)) {
|
999
|
+
continue;
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
if(value >= fr && value <= +scale[s]){
|
1003
|
+
pct = st + (value - fr) * (+s - st) / (+scale[s] - fr);
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
st = +s;
|
1007
|
+
fr = +scale[s];
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
return pct;
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
function percentToPixels(percent) {
|
1014
|
+
return ((outerWrapper[vertical ? "offsetHeight" : "offsetWidth"] - handle[vertical ? "offsetHeight" : "offsetWidth"]) / 100) * percent;
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
function pixelsToPercent(pixels) {
|
1018
|
+
return pixels / ((outerWrapper[vertical ? "offsetHeight" : "offsetWidth"] - outerWrapper[handle ? "offsetHeight" : "offsetWidth"]) / 100);
|
1019
|
+
}
|
1020
|
+
|
1021
|
+
// Sets the form element with a valid value
|
1022
|
+
function setInputValue(val) {
|
1023
|
+
// The update callback doesn't mean the input value has changed
|
1024
|
+
callback("update");
|
1025
|
+
|
1026
|
+
// If the user has not set this value or has entered an incorrect value then set a class
|
1027
|
+
// to enable styling of the slider
|
1028
|
+
if(!userSet) {
|
1029
|
+
addClass(innerWrapper, "fd-slider-no-value");
|
1030
|
+
} else {
|
1031
|
+
removeClass(innerWrapper, "fd-slider-no-value");
|
1032
|
+
}
|
1033
|
+
|
1034
|
+
if(tagName == "select") {
|
1035
|
+
try {
|
1036
|
+
val = parseInt(val, 10);
|
1037
|
+
if(inp.selectedIndex === val) {
|
1038
|
+
updateAriaValues();
|
1039
|
+
return;
|
1040
|
+
}
|
1041
|
+
inp.options[val].selected = true;
|
1042
|
+
} catch (err) {}
|
1043
|
+
} else {
|
1044
|
+
if(val !== "" && !userInput) {
|
1045
|
+
val = (min + (Math.round((+val - min) / step) * step)).toFixed(precision);
|
1046
|
+
}
|
1047
|
+
if(inp.value === val) {
|
1048
|
+
updateAriaValues();
|
1049
|
+
return;
|
1050
|
+
}
|
1051
|
+
inp.value = val;
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
updateAriaValues();
|
1055
|
+
callback("change");
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
function checkInputValue(value) {
|
1059
|
+
return !(isNaN(value) || value === "" || value < Math.min(rMin,rMax) || value > Math.max(rMin,rMax));
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
function setSliderRange(newMin, newMax) {
|
1063
|
+
if(rMin > rMax) {
|
1064
|
+
newMin = Math.min(min, Math.max(newMin, newMax));
|
1065
|
+
newMax = Math.max(max, Math.min(newMin, newMax));
|
1066
|
+
rMin = Math.max(newMin, newMax);
|
1067
|
+
rMax = Math.min(newMin, newMax);
|
1068
|
+
} else {
|
1069
|
+
newMin = Math.max(min, Math.min(newMin, newMax));
|
1070
|
+
newMax = Math.min(max, Math.max(newMin, newMax));
|
1071
|
+
rMin = Math.min(newMin, newMax);
|
1072
|
+
rMax = Math.max(newMin, newMax);
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
if(defaultVal < Math.min(rMin, rMax)) {
|
1076
|
+
defaultVal = Math.min(rMin, rMax);
|
1077
|
+
} else if(defaultVal > Math.max(rMin, rMax)) {
|
1078
|
+
defaultVal = Math.max(rMin, rMax);
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
handle.setAttribute("aria-valuemin", rMin);
|
1082
|
+
handle.setAttribute("aria-valuemax", rMax);
|
1083
|
+
|
1084
|
+
checkValue(tagName == "input" ? parseFloat(inp.value) : inp.selectedIndex);
|
1085
|
+
redraw();
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
function redrawRange() {
|
1089
|
+
if(noRangeBar) {
|
1090
|
+
return;
|
1091
|
+
}
|
1092
|
+
if(vertical) {
|
1093
|
+
rangeBar.style["height"] = Math.max(1, (bar.offsetHeight - handle.offsetTop)) + "px";
|
1094
|
+
} else {
|
1095
|
+
rangeBar.style["width"] = Math.max(1, handle.offsetLeft) + "px";
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
function findLabel() {
|
1100
|
+
var label = false,
|
1101
|
+
labelList = document.getElementsByTagName('label');
|
1102
|
+
// loop through label array attempting to match each 'for' attribute to the id of the current element
|
1103
|
+
for(var i = 0, lbl; lbl = labelList[i]; i++) {
|
1104
|
+
// Internet Explorer requires the htmlFor test
|
1105
|
+
if((lbl['htmlFor'] && lbl['htmlFor'] == inp.id) || (lbl.getAttribute('for') == inp.id)) {
|
1106
|
+
label = lbl;
|
1107
|
+
break;
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
if(label && !label.id) {
|
1112
|
+
label.id = inp.id + "_label";
|
1113
|
+
}
|
1114
|
+
|
1115
|
+
return label;
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
function updateAriaValues() {
|
1119
|
+
var val = tagName == "select" ? inp.options[inp.selectedIndex].value : inp.value,
|
1120
|
+
valTxt = ariaFormat ? ariaFormat(val) : tagName == "select" ? (inp.options[inp.selectedIndex].text ? inp.options[inp.selectedIndex].text : val) : val;
|
1121
|
+
|
1122
|
+
handle.setAttribute("aria-valuenow", val);
|
1123
|
+
handle.setAttribute("aria-valuetext", valTxt);
|
1124
|
+
}
|
1125
|
+
|
1126
|
+
function onInputChange(e) {
|
1127
|
+
userSet = true;
|
1128
|
+
userInput = userSnap;
|
1129
|
+
valueToPixels(tagName == "input" ? parseFloat(inp.value) : inp.selectedIndex);
|
1130
|
+
updateAriaValues();
|
1131
|
+
userInput = false;
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
function onReset(e) {
|
1135
|
+
if(tagName == "input") {
|
1136
|
+
inp.value = inp.defaultValue;
|
1137
|
+
} else {
|
1138
|
+
inp.selectedIndex = resetDef;
|
1139
|
+
}
|
1140
|
+
checkValue(tagName == "select" ? inp.options[inp.selectedIndex].value : inp.value);
|
1141
|
+
redraw();
|
1142
|
+
updateAriaValues();
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
// Sets a tabindex attribute on an element, bends over for IE.
|
1146
|
+
function setTabIndex(e, i) {
|
1147
|
+
e.setAttribute(!/*@cc_on!@*/false ? "tabIndex" : "tabindex", i);
|
1148
|
+
e.tabIndex = i;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
(function() {
|
1152
|
+
if(html5Shim || hideInput) {
|
1153
|
+
addClass(inp, "fd-form-element-hidden");
|
1154
|
+
try {
|
1155
|
+
// FF21 hack to change input type to text
|
1156
|
+
if(inp.type != "range"
|
1157
|
+
&&
|
1158
|
+
getAttribute(inp, "type") == "range"
|
1159
|
+
&&
|
1160
|
+
document.defaultView.getComputedStyle(inp, null).getPropertyValue("display") == "inline-block") {
|
1161
|
+
inp.type="number";
|
1162
|
+
}
|
1163
|
+
} catch(err){};
|
1164
|
+
} else {
|
1165
|
+
addEvent(inp, 'change', onInputChange);
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
// Add stepUp & stepDown methods to input element if using the html5Shim
|
1169
|
+
if(html5Shim) {
|
1170
|
+
inp.setAttribute("fd-range-enabled", 1);
|
1171
|
+
inp.stepUp = function(n) { increment(n||1); };
|
1172
|
+
inp.stepDown = function(n) { increment(n||-1); };
|
1173
|
+
|
1174
|
+
if(useDOMAttrModEvt) {
|
1175
|
+
addEvent(inp, typeof(inp.onpropertychange) == "object" ? "propertychange" : "DOMAttrModified", rescanAttrs);
|
1176
|
+
}
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
outerWrapper = document.createElement('span');
|
1180
|
+
outerWrapper.className = "fd-slider" + (vertical ? "-vertical " : " ") + classNames;
|
1181
|
+
outerWrapper.id = "fd-slider-" + inp.id;
|
1182
|
+
|
1183
|
+
if(vertical && inpHeight) {
|
1184
|
+
outerWrapper.style.height = inpHeight + "px";
|
1185
|
+
}
|
1186
|
+
|
1187
|
+
innerWrapper = document.createElement('span');
|
1188
|
+
innerWrapper.className = "fd-slider-wrapper" + (!html5Shim ? " fd-slider-no-value" : "");
|
1189
|
+
|
1190
|
+
ieBlur = document.createElement('span');
|
1191
|
+
ieBlur.className = "fd-slider-inner";
|
1192
|
+
|
1193
|
+
bar = document.createElement('span');
|
1194
|
+
bar.className = "fd-slider-bar";
|
1195
|
+
|
1196
|
+
if(fullARIA) {
|
1197
|
+
handle = document.createElement('span');
|
1198
|
+
} else {
|
1199
|
+
handle = document.createElement('a');
|
1200
|
+
handle.setAttribute("href", "#");
|
1201
|
+
addEvent(handle, "click", stopEvent);
|
1202
|
+
}
|
1203
|
+
|
1204
|
+
setTabIndex(handle, 0);
|
1205
|
+
|
1206
|
+
handle.className = "fd-slider-handle";
|
1207
|
+
handle.appendChild(document.createTextNode(String.fromCharCode(160)));
|
1208
|
+
|
1209
|
+
innerWrapper.appendChild(ieBlur);
|
1210
|
+
|
1211
|
+
if(!noRangeBar) {
|
1212
|
+
rangeBar = document.createElement('span');
|
1213
|
+
rangeBar.className = "fd-slider-range";
|
1214
|
+
innerWrapper.appendChild(rangeBar);
|
1215
|
+
}
|
1216
|
+
|
1217
|
+
innerWrapper.appendChild(bar);
|
1218
|
+
innerWrapper.appendChild(handle);
|
1219
|
+
outerWrapper.appendChild(innerWrapper);
|
1220
|
+
|
1221
|
+
inp.parentNode.insertBefore(outerWrapper, inp);
|
1222
|
+
|
1223
|
+
if(isOpera || /*@cc_on!@*/!true) {
|
1224
|
+
handle.unselectable = "on";
|
1225
|
+
bar.unselectable = "on";
|
1226
|
+
ieBlur.unselectable = "on";
|
1227
|
+
outerWrapper.unselectable = "on";
|
1228
|
+
innerWrapper.unselectable = "on";
|
1229
|
+
if(!noRangeBar) {
|
1230
|
+
rangeBar.unselectable = "on";
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
// Add ARIA accessibility info programmatically
|
1235
|
+
outerWrapper.setAttribute("role", "application");
|
1236
|
+
|
1237
|
+
handle.setAttribute("role", "slider");
|
1238
|
+
handle.setAttribute("aria-valuemin", tagName == "select" ? inp.options[0].value : min);
|
1239
|
+
handle.setAttribute("aria-valuemax", tagName == "select" ? inp.options[inp.options.length - 1].value : max);
|
1240
|
+
|
1241
|
+
var lbl = findLabel();
|
1242
|
+
if(lbl) {
|
1243
|
+
handle.setAttribute("aria-labelledby", lbl.id);
|
1244
|
+
handle.id = "fd-slider-handle-" + inp.id;
|
1245
|
+
/*@cc_on@*/
|
1246
|
+
/*@if(@_win32)
|
1247
|
+
lbl.setAttribute("htmlFor", handle.id);
|
1248
|
+
@else @*/
|
1249
|
+
lbl.setAttribute("for", handle.id);
|
1250
|
+
/*@end@*/
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
// Are there page instructions
|
1254
|
+
if(document.getElementById(describedBy)) {
|
1255
|
+
handle.setAttribute("aria-describedby", describedBy);
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
// Is the form element initially disabled
|
1259
|
+
if(inp.getAttribute("disabled") == true || inp.getAttribute("disabled") == "disabled") {
|
1260
|
+
disableSlider(true);
|
1261
|
+
} else {
|
1262
|
+
enableSlider(true);
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
// Does an initial form element value mean the user has set a valid value?
|
1266
|
+
// Also called onload in case browsers have automatically set the input value
|
1267
|
+
if(varSetRules.onvalue) {
|
1268
|
+
userSet = true;
|
1269
|
+
checkValue(tagName == "input" ? parseFloat(inp.value) : inp.selectedIndex);
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
// Catch form reset events
|
1273
|
+
if(inp.form) {
|
1274
|
+
addEvent(inp.form, "reset", onReset);
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
updateAriaValues();
|
1278
|
+
callback("create");
|
1279
|
+
redraw();
|
1280
|
+
})();
|
1281
|
+
|
1282
|
+
return {
|
1283
|
+
onResize: function(e) { if(outerWrapper.offsetHeight != sliderH || outerWrapper.offsetWidth != sliderW) { redraw(); } },
|
1284
|
+
destroy: function() { destroySlider(); },
|
1285
|
+
reset: function() { valueToPixels(tagName == "input" ? parseFloat(inp.value) : inp.selectedIndex); },
|
1286
|
+
stepUp: function(n) { increment(Math.abs(n)||1); },
|
1287
|
+
stepDown: function(n) { increment(-Math.abs(n)||-1); },
|
1288
|
+
increment: function(n) { increment(n); },
|
1289
|
+
disable: function() { disableSlider(); },
|
1290
|
+
enable: function() { enableSlider(); },
|
1291
|
+
setRange: function(mi, mx) { setSliderRange(mi, mx); },
|
1292
|
+
getValueSet: function() { return !!userSet; },
|
1293
|
+
setValueSet: function(tf) { valueSet(tf); },
|
1294
|
+
rescan: function() { rescanAttrs(); },
|
1295
|
+
checkValue: function() { if(varSetRules.onvalue) { userSet = true; checkValue(tagName == "input" ? parseFloat(inp.value) : inp.selectedIndex); } updateAriaValues(); redraw(); }
|
1296
|
+
};
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
addEvent(window, "load", init);
|
1300
|
+
addEvent(window, "load", function() { setTimeout(function() { var slider; for(slider in sliders) { sliders[slider].checkValue(); } }, 0); });
|
1301
|
+
addEvent(window, "resize", resize);
|
1302
|
+
addEvent(window, "unload", unload);
|
1303
|
+
|
1304
|
+
// Have we been passed JSON within the including script tag
|
1305
|
+
(function() {
|
1306
|
+
var scriptFiles = document.getElementsByTagName('script'),
|
1307
|
+
json = parseJSON(String(scriptFiles[scriptFiles.length - 1].innerHTML).replace(/[\n\r\s\t]+/g, " ").replace(/^\s+/, "").replace(/\s+$/, ""));
|
1308
|
+
|
1309
|
+
if(typeof json === "object" && !("err" in json)) {
|
1310
|
+
affectJSON(json);
|
1311
|
+
}
|
1312
|
+
})();
|
1313
|
+
|
1314
|
+
// Add oldie class if needed for IE < 9
|
1315
|
+
/*@cc_on@*/
|
1316
|
+
/*@if (@_jscript_version < 9)
|
1317
|
+
addClass(document.documentElement, "oldie");
|
1318
|
+
/*@end@*/
|
1319
|
+
|
1320
|
+
return {
|
1321
|
+
rescanDocument: init,
|
1322
|
+
createSlider: function(opts) { return createSlider(opts); },
|
1323
|
+
onDomReady: function() { onDomReady(); },
|
1324
|
+
destroyAll: function() { destroyAllsliders(); },
|
1325
|
+
destroySlider: function(id) { return destroySingleSlider(id); },
|
1326
|
+
redrawAll: function() { resize(); },
|
1327
|
+
addEvent: addEvent,
|
1328
|
+
removeEvent: removeEvent,
|
1329
|
+
stopEvent: stopEvent,
|
1330
|
+
increment: function(id, numSteps) { if(!sliderExists(id)) { return false; } sliders[id].increment(numSteps); },
|
1331
|
+
stepUp: function(id, n) { if(!sliderExists(id)) { return false; } sliders[id].stepUp(Math.abs(n)||1); },
|
1332
|
+
stepDown: function(id, n) { if(!sliderExists(id)) { return false; } sliders[id].stepDown(-Math.abs(n)||-1); },
|
1333
|
+
setRange: function(id, newMin, newMax) { if(!sliderExists(id)) { return false; } sliders[id].setRange(newMin, newMax); },
|
1334
|
+
updateSlider: function(id) { if(!sliderExists(id)) { return false; } sliders[id].onResize(); sliders[id].reset(); },
|
1335
|
+
disable: function(id) { if(!sliderExists(id)) { return false; } sliders[id].disable(); },
|
1336
|
+
enable: function(id) { if(!sliderExists(id)) { return false; } sliders[id].enable(); },
|
1337
|
+
getValueSet: function() { return getValueSet(); },
|
1338
|
+
setValueSet: function(a, tf) { if(!sliderExists(id)) { return false; } setValueSet(a, tf); },
|
1339
|
+
setGlobalVariables: function(json) { affectJSON(json); },
|
1340
|
+
removeOnload: function() { removeOnLoadEvent(); },
|
1341
|
+
rescanAttributes: rescanAttributes
|
1342
|
+
};
|
1343
|
+
})();
|