From a572175ce88d5ffcc48d9edb0d281b8b065c488c Mon Sep 17 00:00:00 2001 From: Denis Chenu Date: Wed, 4 Jan 2017 15:47:05 +0100 Subject: [PATCH] Fixed issue #12021: Have a real rtl slider Dev: update to boostrap-slider v9.6.0 Dev: Add default bs-slider.css and fix it in question package Dev: for color : only template.css --- application/config/third_party.php | 9 +- .../numeric-slider/numeric-slider.css | 238 +---------- .../numeric-slider/numeric-slider.js | 5 +- application/helpers/qanda_helper.php | 4 +- .../rows/sliders/answer_row.php | 4 +- templates/default/css/template.css | 22 ++ third_party/bootstrap-slider/CHANGELOG.md | 89 ++++- third_party/bootstrap-slider/LICENSE.md | 2 +- third_party/bootstrap-slider/README.md | 80 +++- .../bootstrap-slider/bootstrap-slider.js | 372 ++++++++++++++---- .../bootstrap-slider/bootstrap-slider.min.js | 5 +- 11 files changed, 490 insertions(+), 340 deletions(-) diff --git a/application/config/third_party.php b/application/config/third_party.php index cdb63414dae..e918065b990 100755 --- a/application/config/third_party.php +++ b/application/config/third_party.php @@ -46,10 +46,15 @@ // bootstrap-slider : for multinumeric with slider 'bootstrap-slider' => array( 'basePath' => 'third_party.bootstrap-slider', + 'css'=> array( + 'css/bootstrap-slider'.$minVersion.'.css' + ), 'js' => array( - 'bootstrap-slider.min.js' + 'bootstrap-slider'.$minVersion.'.js' ), - /* according to readme : JQuery is optional and the plugin can operate with or without it. boostrap must be loaded for css only */ + 'depends' => array( + 'jquery', + ) ), 'fontawesome' => array( diff --git a/application/core/packages/questions/numeric-slider/numeric-slider.css b/application/core/packages/questions/numeric-slider/numeric-slider.css index 0be7bc3e306..ecb35fbf558 100644 --- a/application/core/packages/questions/numeric-slider/numeric-slider.css +++ b/application/core/packages/questions/numeric-slider/numeric-slider.css @@ -1,180 +1,11 @@ /* This file is part of LimeSurvey - http://www.limesurvey.org */ -/** - * Based on bootstrap-slider.css - * @licence apache - * @author Stefan Petre - * @author Kyle Kemp (seiyria) - * @author Rohit Kalkur 'rovolution) -/** -* Slider custom handle -*/ - -.slider { - display: inline-block; - vertical-align: middle; - position: relative; -} +/* reset the width of slider horizontal */ .slider.slider-horizontal { width: 100%; - height: 20px; -} -.slider.slider-horizontal .slider-track { - height: 10px; - width: 100%; - margin-top: -5px; - top: 50%; - left: 0; -} -.slider.slider-horizontal .slider-selection, -.slider.slider-horizontal .slider-track-low, -.slider.slider-horizontal .slider-track-high { - height: 100%; - top: 0; - bottom: 0; -} -.slider.slider-horizontal .slider-tick, -.slider.slider-horizontal .slider-handle { - margin-left: -10px; -} -.slider.slider-horizontal .slider-tick.triangle, -.slider.slider-horizontal .slider-handle.triangle { - position: relative; - top: 50%; - transform: translateY(-50%); - border-width: 0 10px 10px 10px; - width: 0; - height: 0; - border-bottom-color: #0480be; - margin-top: 0; -} -.slider.slider-horizontal .slider-tick-container { - white-space: nowrap; - position: absolute; - top: 0; - left: 0; - width: 100%; -} -.slider.slider-horizontal .slider-tick-label-container { - white-space: nowrap; - margin-top: 20px; -} -.slider.slider-horizontal .slider-tick-label-container .slider-tick-label { - padding-top: 4px; - display: inline-block; - text-align: center; -} -.slider.slider-vertical { - height: 210px; - width: 20px; -} -.slider.slider-vertical .slider-track { - width: 10px; - height: 100%; - left: 25%; - top: 0; -} -.slider.slider-vertical .slider-selection { - width: 100%; - left: 0; - top: 0; - bottom: 0; -} -.slider.slider-vertical .slider-track-low, -.slider.slider-vertical .slider-track-high { - width: 100%; - left: 0; - right: 0; -} -.slider.slider-vertical .slider-tick, -.slider.slider-vertical .slider-handle { - margin-top: -10px; -} -.slider.slider-vertical .slider-tick.triangle, -.slider.slider-vertical .slider-handle.triangle { - border-width: 10px 0 10px 10px; - width: 1px; - height: 1px; - border-left-color: #0480be; - margin-left: 0; -} -.slider.slider-vertical .slider-tick-label-container { - white-space: nowrap; -} -.slider.slider-vertical .slider-tick-label-container .slider-tick-label { - padding-left: 4px; -} -.slider.slider-disabled .slider-handle { - background-image: -webkit-linear-gradient(top, #dfdfdf 0%, #bebebe 100%); - background-image: -o-linear-gradient(top, #dfdfdf 0%, #bebebe 100%); - background-image: linear-gradient(to bottom, #dfdfdf 0%, #bebebe 100%); - background-repeat: repeat-x; } -.slider.slider-disabled .slider-track { - background-image: -webkit-linear-gradient(top, #e5e5e5 0%, #e9e9e9 100%); - background-image: -o-linear-gradient(top, #e5e5e5 0%, #e9e9e9 100%); - background-image: linear-gradient(to bottom, #e5e5e5 0%, #e9e9e9 100%); - background-repeat: repeat-x; - cursor: not-allowed; -} -.slider input { - display: none; -} -.slider .tooltip.top { - margin-top: -36px; -} -.slider .tooltip-inner { - white-space: nowrap; - max-width: none; -} -.slider .hide { - display: none; -} -.slider-track { - position: absolute; - cursor: pointer; - background-image: -webkit-linear-gradient(top, #f5f5f5 0%, #f9f9f9 100%); - background-image: -o-linear-gradient(top, #f5f5f5 0%, #f9f9f9 100%); - background-image: linear-gradient(to bottom, #f5f5f5 0%, #f9f9f9 100%); - background-repeat: repeat-x; - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - border-radius: 4px; -} -.slider-selection { - position: absolute; - background-image: -webkit-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%); - background-image: -o-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%); - background-image: linear-gradient(to bottom, #f9f9f9 0%, #f5f5f5 100%); - background-repeat: repeat-x; - -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - border-radius: 4px; -} -.slider-selection.tick-slider-selection { - background-image: -webkit-linear-gradient(top, #89cdef 0%, #81bfde 100%); - background-image: -o-linear-gradient(top, #89cdef 0%, #81bfde 100%); - background-image: linear-gradient(to bottom, #89cdef 0%, #81bfde 100%); - background-repeat: repeat-x; -} -.slider-track-low, -.slider-track-high { - position: absolute; - background: transparent; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - border-radius: 4px; -} -/* Adding a backgrond image, don't touch on default bd-info color */ +/* Use a transparent background-image (more easy for user to update background-color only */ .slider-handle { - position: absolute; - top: 0; - width: 20px; - height: 20px; background-image: -moz-linear-gradient(top, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); background-image: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,0.3)), color-stop(100%, rgba(255,255,255,0))); background-image: -webkit-linear-gradient(top, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); @@ -183,70 +14,11 @@ background-image: linear-gradient(to bottom, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); - border: 0px solid transparent; -} -.slider-handle.round { - border-radius: 50%; - background-image: -moz-radial-gradient(center, ellipse cover, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); - background-image: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, rgba(255,255,255,0.3)), color-stop(100%, rgba(255,255,255,0))); - background-image: -webkit-radial-gradient(center, ellipse cover, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); - background-image: -o-radial-gradient(center, ellipse cover, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); - background-image: -ms-radial-gradient(center, ellipse cover, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); - background-image: radial-gradient(ellipse at center, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); -} -.slider-handle.triangle { - background: transparent none; -} -.slider-handle.custom { - background: transparent none; } +/* FA for custom */ .slider-handle.custom::before { - line-height: 20px; - font-size: 20px; - font-family: FontAwesome; - content: '\f1ae'; /*Set by javascript ;*/; -} -.slider-tick { - position: absolute; - width: 20px; - height: 20px; - background-image: -webkit-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%); - background-image: -o-linear-gradient(top, #f9f9f9 0%, #f5f5f5 100%); - background-image: linear-gradient(to bottom, #f9f9f9 0%, #f5f5f5 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff9f9f9', endColorstr='#fff5f5f5', GradientType=0); - -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - opacity: 0.8; - border: 0px solid transparent; -} -.slider-tick.round { - border-radius: 50%; -} -.slider-tick.triangle { - background: transparent none; -} -.slider-tick.custom { - background: transparent none; +font-family: FontAwesome; } -.slider-tick.custom::before { - line-height: 20px; - font-size: 20px; - content: '\2605'; - color: #726204; -} -.slider-tick.in-selection { - background-image: -webkit-linear-gradient(top, #89cdef 0%, #81bfde 100%); - background-image: -o-linear-gradient(top, #89cdef 0%, #81bfde 100%); - background-image: linear-gradient(to bottom, #89cdef 0%, #81bfde 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff89cdef', endColorstr='#ff81bfde', GradientType=0); - opacity: 1; -} - /* Add some margin for the tooltip */ /* same line */ .slider-list .slider-container{margin-top:2em} @@ -257,7 +29,7 @@ .slider-list .slider-item .control-label{margin-top:2em} .slider-list .slider-left,.slider-list .slider-right {margin-top: 2em;} } -} + /* different line */ .slider-list .slider-item .control-label.col-sm-12{margin-top:0.5em;margin-bottom: 2em;} .slider-list .slider-item .col-sm-12 .ls-input-group{margin-top:0.5em;margin-bottom: 2em;} diff --git a/application/core/packages/questions/numeric-slider/numeric-slider.js b/application/core/packages/questions/numeric-slider/numeric-slider.js index ddf996f598b..61429c73f25 100644 --- a/application/core/packages/questions/numeric-slider/numeric-slider.js +++ b/application/core/packages/questions/numeric-slider/numeric-slider.js @@ -28,8 +28,6 @@ function doNumericSlider(qID,options) { return prefix + displayValue + suffix; } }); - /* Put some color taken from default boostrap file : allow user to more easily update it*/ - $(this).find(".slider-handle").addClass("bg-primary");// bg-info is not dark enough /* If dispVal is not set : move to this : but don't set value : event is set to false,false */ if(dispVal===''){ $('#javatbd' + myfname).find('div.tooltip').hide(); @@ -47,10 +45,9 @@ function doNumericSlider(qID,options) { $(inputEl).val(displayValue); // We parse it to the element }); theSlider.on('change', function(event) { + // Don't we need to update too ? }); theSlider.on('slideStop', function(event) { - console.log(separator); - console.log(event.value.toString().replace('.',separator)); $(inputEl).val(event.value.toString().replace('.',separator)).trigger('keyup');// We call the EM by the event }); diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index 832413c6dc7..43f11661e3a 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -3073,7 +3073,7 @@ function do_multiplenumeric($ia) }else{ $slider_reversed = 'false'; } - + } else { @@ -3340,7 +3340,7 @@ function do_multiplenumeric($ia) App()->getClientScript()->registerScript("sliderTranslation","var sliderTranslation=".json_encode($sliderTranslation).";\n",CClientScript::POS_HEAD); App()->getClientScript()->registerPackage("question-numeric-slider"); if($slider_handle == 'custom'){/* unsure we still need it : in aJsonOptions : must choose the best */ - App()->getClientScript()->registerCss("cssNumericSlider{$ia[0]}","#question{$ia[0]} .slider-handle.custom::before{ content: '\\{$slider_custom_handle}}';"); + App()->getClientScript()->registerCss("cssNumericSlider{$ia[0]}","#question{$ia[0]} .slider-handle.custom::before{ content: '\\{$slider_custom_handle}'};"); } $aJsonOptions=json_encode(array( 'slider_custom_handle'=>$slider_custom_handle diff --git a/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php b/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php index ddecb559c02..e5bed21dc3e 100644 --- a/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php +++ b/application/views/survey/questions/answer/multiplenumeric/rows/sliders/answer_row.php @@ -63,8 +63,8 @@ )); ?> -
help-block'>
-
help-block'>
+
+
diff --git a/templates/default/css/template.css b/templates/default/css/template.css index 646b00420dd..2ceb61a8388 100644 --- a/templates/default/css/template.css +++ b/templates/default/css/template.css @@ -209,6 +209,28 @@ padding-top:1em;padding-bottom:1em;margin-bottom:2em; .js td.radio-item,.js td.checkbox-item{ cursor: pointer; } +/* slider : take bg-primary color */ +.bg-primary { + background-color: #2c3e50; +} +.slider.slider-horizontal .slider-tick.triangle, +.slider.slider-horizontal .slider-handle.triangle { + border-bottom-color: #2c3e50; +} +.slider.slider-vertical .slider-tick.triangle, +.slider.slider-vertical .slider-handle.triangle { + border-left-color: #2c3e50; + border-right-color: #2c3e50; +} +.slider-handle { + background-color: #2c3e50; +} +.slider-handle.custom::before { + color: #2c3e50; +} +.slider-tick.custom::before { + color: #2c3e50; +} /* Show more the heading in table */ .ls-answers .ls-heading th{font-weight:700} /* Max width for some answer part */ diff --git a/third_party/bootstrap-slider/CHANGELOG.md b/third_party/bootstrap-slider/CHANGELOG.md index f3717198a8e..277c2bc6ecd 100644 --- a/third_party/bootstrap-slider/CHANGELOG.md +++ b/third_party/bootstrap-slider/CHANGELOG.md @@ -1,4 +1,89 @@ -7.0.0 / 2016-04-03 +9.6.0 / 2017-01-03 +================== +* **New Feature:** Adds ability to set direction (using HTML5 `dir` attribute). [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/679). Thanks to [Denis Chenu](https://github.com/Shnoulle). + +9.5.4 / 2016-12-18 +================== +* **Bug Fix:** Fixes issue where dragging slider handle outside of modal and releasing cursor would close the modal. [See original issue for further details](https://github.com/seiyria/bootstrap-slider/issues/339). Thanks to [ZeVS777](https://github.com/ZeVS777). + +9.5.3 / 2016-12-01 +================== +* **Bug Fix:** Fixes typo from previous update to SCSS rules. Thanks to [Julien Bachmann](https://github.com/julienbachmann). + +9.5.2 / 2016-11-30 +================== +* **Bug Fix:** Fixes SCSS rules. [See original issue for further details](https://github.com/seiyria/bootstrap-slider/issues/662). Thanks to [Julien Bachmann](https://github.com/julienbachmann). + +9.5.1 / 2016-11-23 +================== +* **Bug Fix:** Removes `'none'` classes after selection change. [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/659). Thanks to [John Clarke](https://github.com/john-clarke). + +9.5.0 / 2016-11-21 +================== +* **New Feature:** Adds `aria-valuetext` attribute to each slider handle element, which is set to be the current formatted value of the slider (based on the `formatter` option). [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/646). Thanks to [mediaformat](https://github.com/mediaformat). + +9.4.1 / 2016-11-04 +================== +* **Documentation Fix:** Fixing an inconsistency with the licensing information in our source files. [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/652). Thanks to [Tom Yue](https://github.com/yuethomas) for identifying this issue. + +9.4.0 / 2016-10-31 +================== +* **New Feature:** Adds the ability to set the slider value using stringified numbers. [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/642). Thanks to [Ryan Bruns](https://github.com/snurby7) + +9.3.2 / 2016-10-30 +================== +* **Bug Fix:** Fixes reported bug where a slider was unable to be destroyed and re-created if there were event listeners bound to it. [See here for further details](https://github.com/seiyria/bootstrap-slider/issues/640). + +9.3.0 / 2016-10-20 +================== +* **New Feature:** Adds the ability to enable/disable tooltips when hovering over ticks via the `ticks_tooltip` option. [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/638). Thanks to [Ryan Bruns](https://github.com/snurby7) + +9.2.2 / 2016-10-18 +================== +* **Bug Fix:** Resolves issue where range highlights were not being applied properly for reversed sliders. [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/637). Thanks to [Bernard Gorman](https://github.com/gormanb) + +9.2.0 / 2016-09-26 +================== +* **New Feature:** Adding the ability to target certain ranges of the slider track via CSS in order to highlight them. [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/619). Thanks to [lipoczkit](https://github.com/lipoczkit) + +9.1.3 / 2016-08-06 +================== +* **Bug Fix:** Checks for `window` object before attempting to attach `console` polyfills. [Resolves this issue](https://github.com/seiyria/bootstrap-slider/issues/607) + +9.1.2 / 2016-08-06 +================== +* Accidental publish + +9.1.1 / 2016-07-15 +================== +* **Bug Fix:** Adds `.npmignore` file to repository. [Resolves this issue](https://github.com/seiyria/bootstrap-slider/issues/601) + +9.1.0 / 2016-07-14 +================== +* **New Feature:** Always binding to the `$.fn.bootstrapSlider` namespace and printing a console warning when the `$.fn.slider` namespace is already bound. Idea came from discussion [in this issue](https://github.com/seiyria/bootstrap-slider/issues/575) + +9.0.0 / 2016-07-13 +================== +* **New Feature:** Wraps all of the ticks within a single container element with the class `.slider-tick-container` as opposed to being within the `.slider-track` element. This enables individual ticks to be more easily targeted with CSS selectors such as `nth-of-type(n)`. Idea came from discussion [in this issue](https://github.com/seiyria/bootstrap-slider/issues/500) + +8.0.0 / 2016-07-13 +================== +* **Revert:** Reverting bug fix made in `7.0.4 - 7.0.5` because it breaks UMD module definition and r.js build tool [as reported in this issue](https://github.com/seiyria/bootstrap-slider/issues/589#issuecomment-232429818). Updated README to address how to stub out optional JQuery dependency for Webpack builds. + +7.1.0 - 7.1.1 / 2016-05-26 +================== +* **New Feature:** Allow LESS/SASS variables to be overridden, but fall back to defaults if needed. [See here for further details](https://github.com/seiyria/bootstrap-slider/pull/579). Thanks to [Jonathan Rehm + (jkrehm)](https://github.com/jkrehm) + +7.0.4 - 7.0.5 / 2016-05-26 +================== +* **Bug Fix:** Changes webpack AMD build error on define() for optional jQuery dependency to be a warning, which allows webpack builds to be completed. [See here for further details](https://github.com/seiyria/bootstrap-slider/issues/578). Thanks to [Tomi Saarinen (TomiS)](https://github.com/TomiS) + +7.0.2 / 2016-04-05 +================== +* **Bug Fix:** Fixes overlap issue with range slider. [See here for further details](https://github.com/seiyria/bootstrap-slider/issues/435). Thanks to [Jerry (jerrylow)](https://github.com/jerrylow) + +7.0.0 / 2016-04-05 ================== * **Breaking Change:** Restructured and refactored SASS source files to eliminate compass dependency and be more organized. Thanks to [Jacob van Mourik (jcbvm)](https://github.com/jcbvm) @@ -18,7 +103,7 @@ 6.1.0 / 2016-02-28 ================== * **New Feature:** Auto-registering/intializing slider via `data-provide="slider"` attribute. Thanks to [MaZderMind](https://github.com/MaZderMind) -* Adding Github Templates for Issues, Pull Requeusts, and Contributions +* Adding Github Templates for Issues, Pull Requests, and Contributions 6.0.16 / 2016-02-04 ================== diff --git a/third_party/bootstrap-slider/LICENSE.md b/third_party/bootstrap-slider/LICENSE.md index c680511dd6d..608deb5db9b 100644 --- a/third_party/bootstrap-slider/LICENSE.md +++ b/third_party/bootstrap-slider/LICENSE.md @@ -1,6 +1,6 @@ ---------------------------------------------------------------------- bootstrap-slider is released under the MIT License -Copyright (c) 2015-2016 Kyle Kemp, Rohit Kalkur, and contributors +Copyright (c) 2016 Kyle Kemp, Rohit Kalkur, and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/third_party/bootstrap-slider/README.md b/third_party/bootstrap-slider/README.md index 332220ab631..444c2241368 100644 --- a/third_party/bootstrap-slider/README.md +++ b/third_party/bootstrap-slider/README.md @@ -2,9 +2,9 @@ bootstrap-slider [![Build Status](https://travis-ci.org/seiyria/bootstrap-slider ================ Originally began as a loose "fork" of bootstrap-slider found on http://www.eyecon.ro/ by Stefan Petre. -Over time, this project has diverged sigfinicantly from Stefan Petre's version and is now almost completly different. +Over time, this project has diverged sigfinicantly from Stefan Petre's version and is now almost completely different. -__Please ensure that you are using this library instead of the Petre version before creating issues in the repository Issue tracker!!__ +__Please ensure that you are using this library instead of the Petre version before creating issues in the repository issue tracker!!__ Installation ============ @@ -14,13 +14,9 @@ Want to use npm? `npm install bootstrap-slider` Want to get it from a CDN? https://cdnjs.com/libraries/bootstrap-slider -__NOTE for NPM users__: In order to keep the version numbers in our dist/ file consistent with our Github tags, we do a patch version bump, generate a new dist, and create a commit/tag on postpublish. - -This does mean the Github repo will always be one patch commit off of what is published to NPM. Note that this will not affect functionality, and is only used to keep package management system files and the dist file version numbers in sync. - Basic Setup ============ -Load the plugin CSS and JavaScript into your web page, and everything should work! +Grab the compiled JS/CSS (minified or non-minified versions) from the [/dist](https://github.com/seiyria/bootstrap-slider/tree/master/dist) directory, load them into your web page, and everything should work! Remember to load the plugin code after loading the Bootstrap CSS and JQuery. @@ -39,6 +35,7 @@ You can see all of our API examples [here](http://seiyria.github.io/bootstrap-sl Using bootstrap-slider (with JQuery) ====================== +### Using `.slider` namespace Create an input element and call .slider() on it: ```js @@ -54,6 +51,22 @@ var value = mySlider.slider('getValue'); .slider('setValue', 7); ``` +### Using `.bootstrapSlider` namespace +Create an input element and call .bootstrapSlider() on it: + +```js +// Instantiate a slider +var mySlider = $("input.slider").bootstrapSlider(); + +// Call a method on the slider +var value = mySlider.bootstrapSlider('getValue'); + +// For non-getter methods, you can chain together commands + mySlider + .bootstrapSlider('setValue', 5) + .bootstrapSlider('setValue', 7); +``` + Using bootstrap-slider (via `data-provide`-API) ====================== @@ -78,7 +91,7 @@ turns it into a slider. Options can be supplied via `data-slider-` attributes. What if there is already a _slider_ plugin bound to the JQuery namespace? ====================== -If there is already a JQuery plugin named _slider_ bound to the JQuery namespace, then this plugin will take on the alternate namespace _bootstrapSlider_. +If there is already a JQuery plugin named _slider_ bound to the JQuery namespace, then this plugin will emit a console warning telling you this namespace has already been taken and will encourage you to use the alternate namespace _bootstrapSlider_ instead. ```js // Instantiate a slider @@ -123,13 +136,34 @@ var Slider = require("bootstrap-slider"); var mySlider = new Slider(); ``` -Note that the JQuery dependency is considered to be optional. For example, to exclude JQuery from being part of your Browserify build, you would call something like the following (assuming main.js is requiring bootstrap-slider as a dependency): +How do I exclude the optional JQuery dependency from my build? +======= +### Browserify +__Note that the JQuery dependency is considered to be optional.__ For example, to exclude JQuery from being part of your Browserify build, you would call something like the following (assuming `main.js` is requiring bootstrap-slider as a dependency): -``` +```BASH browserify -u jquery main.js > bundle.js ``` +### Webpack +To exclude JQuery from your Webpack build, you will have to go into the Webpack config file for your specific project and add something like the following to your `resolve.alias` section: -Please see the documentation for the specific CommonJS loader you are using to find out how to exclude dependencies. +```js +resolve: { + alias: { + "jquery": path.join(__dirname, "./jquery-stub.js"); + } +} +``` + +Then in your project, you will have to create a stub module for jquery that exports a `null` value. Whenever `require("jquery")` is mentioned in your project, it will load this stubbed module. + +```js +// Path: ./jquery-stub.js +module.exports = null; +``` + +### Other +Please see the documentation for the specific module loader you are using to find out how to exclude dependencies. Options ======= @@ -152,16 +186,19 @@ Options can be passed either as a data (data-slider-foo) attribute, or as part o | tooltip_position | string | null | Position of tooltip, relative to slider. Accepts 'top'/'bottom' for horizontal sliders and 'left'/'right' for vertically orientated sliders. Default positions are 'top' for horizontal and 'right' for vertical slider. | | handle | string | 'round' | handle shape. Accepts: 'round', 'square', 'triangle' or 'custom' | | reversed | bool | false | whether or not the slider should be reversed | +| rtl | bool|string | 'auto' | whether or not the slider should be shown in rtl mode. Accepts true, false, 'auto'. Default 'auto' : use actual direction of HTML (`dir='rtl'`) | | enabled | bool | true | whether or not the slider is initially enabled | -| formatter | function | returns the plain value | formatter callback. Return the value wanted to be displayed in the tooltip | +| formatter | function | returns the plain value | formatter callback. Return the value wanted to be displayed in the tooltip, useful for string values. If a string is returned it will be indicated in an `aria-valuetext` attribute. | | natural_arrow_keys | bool | false | The natural order is used for the arrow keys. Arrow up select the upper slider value for vertical sliders, arrow right the righter slider value for a horizontal slider - no matter if the slider was reversed or not. By default the arrow keys are oriented by arrow up/right to the higher slider value, arrow down/left to the lower slider value. | | ticks | array | [ ] | Used to define the values of ticks. Tick marks are indicators to denote special values in the range. This option overwrites min and max options. | | ticks_positions | array | [ ] | Defines the positions of the tick values in percentages. The first value should always be 0, the last value should always be 100 percent. | | ticks_labels | array | [ ] | Defines the labels below the tick marks. Accepts HTML input. | | ticks_snap_bounds | float | 0 | Used to define the snap bounds of a tick. Snaps to the tick if value is within these bounds. | +| ticks_tooltip | bool | false | Used to allow for a user to hover over a given tick to see it's value. Useful if custom formatter passed in | | scale | string | 'linear' | Set to 'logarithmic' to use a logarithmic scale. | | focus | bool | false | Focus the appropriate slider handle after a value change. | | labelledby | string,array | null | ARIA labels for the slider handle's, Use array for multiple values in a range slider. | +| rangeHighlights | array | [] | Defines a range array that you want to highlight, for example: [{'start':val1, 'end': val2}]. | Functions ========= @@ -170,7 +207,7 @@ __NOTE:__ Optional parameters are italicized. | Function | Parameters | Description | | -------- | ----------- | ----------- | | getValue | --- | Get the current value from the slider | -| setValue | newValue, _triggerSlideEvent_, _triggerChangeEvent_ | Set a new value for the slider. If optional triggerSlideEvent parameter is _true_, 'slide' events will be triggered. If optional triggerChangeEvent parameter is _true_, 'change' events will be triggered. This function takes `newValue` as either a `Number` or `Array`.| +| setValue | newValue, _triggerSlideEvent_, _triggerChangeEvent_ | Set a new value for the slider. If optional triggerSlideEvent parameter is _true_, 'slide' events will be triggered. If optional triggerChangeEvent parameter is _true_, 'change' events will be triggered. This function takes `newValue` as either a `Number`, `String`, `Array`. If the value is of type `String` it must be convertable to an integer or it will throw an error.| | getElement | --- | Get the div slider element | | destroy | --- | Properly clean up and remove the slider instance | | disable | ---| Disables the slider and prevents the user from changing the value | @@ -226,13 +263,18 @@ The following is a list of the commonly-used command line tasks: Version Bumping and Publishing (Maintainers Only) ======= -To bump the version number across all the various packagement systems the plugin is registered with, please use the [grunt bump](https://github.com/vojtajina/grunt-bump) plugin. +To do the following release tasks: +* bump the version +* publish a new version to NPM +* update the `gh-pages` branch +* push a new `dist` bundle to the `master` branch on the remote `origin` +* push new tags to the remote `origin` + +Type the following command: -* _grunt bump:patch_ - patch version bump, __0.0.0 -> 0.0.1__ -* _grunt bump:minor_ - minor version bump, __0.0.0 -> 0.1.0__ -* _grunt bump:major_ - major version bump, __0.0.0 -> 1.0.0__ +`npm run release ` -After bumping, type `npm publish` to update on NPM. +If you do not specify a version bump type, the script will automatically defer to a patch bump. Other Platforms & Libraries @@ -241,7 +283,7 @@ Other Platforms & Libraries - [knockout.js](https://github.com/cosminstefanxp/bootstrap-slider-knockout-binding) ([@cosminstefanxp](https://github.com/cosminstefanxp), [#81](https://github.com/seiyria/bootstrap-slider/issues/81)) - [AngularJS](https://github.com/seiyria/angular-bootstrap-slider) - [EmberJS](https://github.com/lifegadget/ui-slider) ([@ksnyde](https://github.com/ksnyde)) -- [ReactJS](https://github.com/brownieboy/react.bootstrap.slidertest) +- [ReactJS](https://github.com/brownieboy/react-bootstrap-slider) - [NuGet](https://www.nuget.org/packages/bootstrap-slider/) ([@ChrisMissal](https://github.com/ChrisMissal)) - [MeteorJS](https://github.com/kidovate/meteor-bootstrap-slider) - [Maven](http://mvnrepository.com/artifact/org.webjars.bower/seiyria-bootstrap-slider) diff --git a/third_party/bootstrap-slider/bootstrap-slider.js b/third_party/bootstrap-slider/bootstrap-slider.js index 7e5f126c973..7eb583bfc7d 100644 --- a/third_party/bootstrap-slider/bootstrap-slider.js +++ b/third_party/bootstrap-slider/bootstrap-slider.js @@ -1,9 +1,9 @@ /*! ======================================================= - VERSION 9.1.3 + VERSION 9.6.0 ========================================================= */ "use strict"; -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /*! ========================================================= * bootstrap-slider.js @@ -18,17 +18,30 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol * * ========================================================= * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * bootstrap-slider is released under the MIT License + * Copyright (c) 2016 Kyle Kemp, Rohit Kalkur, and contributors * - * http://www.apache.org/licenses/LICENSE-2.0 + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. * ========================================================= */ /** @@ -319,7 +332,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win /* The internal state object is used to store data about the current 'state' of slider. - This includes values such as the `value`, `enabled`, etc... + This includes values such as the `value`, `enabled`, etc... */ this._state = { value: null, @@ -331,6 +344,10 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win over: false }; + // The objects used to store the reference to the tick methods if ticks_tooltip is on + this.ticksCallbackMap = {}; + this.handleCallbackMap = {}; + if (typeof element === "string") { this.element = document.querySelector(element); } else if (element instanceof HTMLElement) { @@ -360,15 +377,23 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win this.options[optName] = val; } + // Check options.rtl + if (this.options.rtl === 'auto') { + this.options.rtl = window.getComputedStyle(this.element).direction === 'rtl'; + } + /* Validate `tooltip_position` against 'orientation` - if `tooltip_position` is incompatible with orientation, swith it to a default compatible with specified `orientation` - -- default for "vertical" -> "right" - -- default for "horizontal" -> "left" + -- default for "vertical" -> "right", "left" if rtl + -- default for "horizontal" -> "top" */ if (this.options.orientation === "vertical" && (this.options.tooltip_position === "top" || this.options.tooltip_position === "bottom")) { - - this.options.tooltip_position = "right"; + if (this.options.rtl) { + this.options.tooltip_position = "left"; + } else { + this.options.tooltip_position = "right"; + } } else if (this.options.orientation === "horizontal" && (this.options.tooltip_position === "left" || this.options.tooltip_position === "right")) { this.options.tooltip_position = "top"; @@ -433,6 +458,19 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win sliderTrack.appendChild(sliderTrackSelection); sliderTrack.appendChild(sliderTrackHigh); + /* Create highlight range elements */ + this.rangeHighlightElements = []; + if (Array.isArray(this.options.rangeHighlights) && this.options.rangeHighlights.length > 0) { + for (var j = 0; j < this.options.rangeHighlights.length; j++) { + + var rangeHighlightElement = document.createElement("div"); + rangeHighlightElement.className = "slider-rangeHighlight slider-selection"; + + this.rangeHighlightElements.push(rangeHighlightElement); + sliderTrack.appendChild(rangeHighlightElement); + } + } + /* Add aria-labelledby to handle's */ var isLabelledbyArray = Array.isArray(this.options.labelledby); if (isLabelledbyArray && this.options.labelledby[0]) { @@ -455,6 +493,16 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win for (i = 0; i < this.options.ticks.length; i++) { var tick = document.createElement('div'); tick.className = 'slider-tick'; + if (this.options.ticks_tooltip) { + var tickListenerReference = this._addTickListener(); + var enterCallback = tickListenerReference.addMouseEnter(this, tick, i); + var leaveCallback = tickListenerReference.addMouseLeave(this, tick); + + this.ticksCallbackMap[i] = { + mouseEnter: enterCallback, + mouseLeave: leaveCallback + }; + } this.ticks.push(tick); this.ticksContainer.appendChild(tick); } @@ -562,12 +610,13 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win // Reset classes this._removeClass(this.sliderElem, 'slider-horizontal'); this._removeClass(this.sliderElem, 'slider-vertical'); + this._removeClass(this.sliderElem, 'slider-rtl'); this._removeClass(this.tooltip, 'hide'); this._removeClass(this.tooltip_min, 'hide'); this._removeClass(this.tooltip_max, 'hide'); // Undo existing inline styles for track - ["left", "top", "width", "height"].forEach(function (prop) { + ["left", "right", "top", "width", "height"].forEach(function (prop) { this._removeProperty(this.trackLow, prop); this._removeProperty(this.trackSelection, prop); this._removeProperty(this.trackHigh, prop); @@ -576,17 +625,21 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win // Undo inline styles on handles [this.handle1, this.handle2].forEach(function (handle) { this._removeProperty(handle, 'left'); + this._removeProperty(handle, 'right'); this._removeProperty(handle, 'top'); }, this); // Undo inline styles and classes on tooltips [this.tooltip, this.tooltip_min, this.tooltip_max].forEach(function (tooltip) { this._removeProperty(tooltip, 'left'); + this._removeProperty(tooltip, 'right'); this._removeProperty(tooltip, 'top'); this._removeProperty(tooltip, 'margin-left'); + this._removeProperty(tooltip, 'margin-right'); this._removeProperty(tooltip, 'margin-top'); this._removeClass(tooltip, 'right'); + this._removeClass(tooltip, 'left'); this._removeClass(tooltip, 'top'); }, this); } @@ -600,10 +653,18 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win this._addClass(this.sliderElem, 'slider-horizontal'); this.sliderElem.style.width = origWidth; this.options.orientation = 'horizontal'; - this.stylePos = 'left'; + if (this.options.rtl) { + this.stylePos = 'right'; + } else { + this.stylePos = 'left'; + } this.mousePos = 'pageX'; this.sizePos = 'offsetWidth'; } + // specific rtl class + if (this.options.rtl) { + this._addClass(this.sliderElem, 'slider-rtl'); + } this._setTooltipPosition(); /* In case ticks are specified, overwrite the min and max bounds */ if (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) { @@ -629,6 +690,10 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win this._addClass(this.trackLow, 'hide'); this._addClass(this.trackSelection, 'hide'); this._addClass(this.trackHigh, 'hide'); + } else if (this.options.selection === 'after' || this.options.selection === 'before') { + this._removeClass(this.trackLow, 'hide'); + this._removeClass(this.trackSelection, 'hide'); + this._removeClass(this.trackHigh, 'hide'); } this.handle1 = sliderMinHandle || this.handle1; @@ -697,8 +762,26 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win this.showTooltip = this._showTooltip.bind(this); this.hideTooltip = this._hideTooltip.bind(this); - this.sliderElem.addEventListener("mouseenter", this.showTooltip, false); - this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false); + if (this.options.ticks_tooltip) { + var callbackHandle = this._addTickListener(); + //create handle1 listeners and store references in map + var mouseEnter = callbackHandle.addMouseEnter(this, this.handle1); + var mouseLeave = callbackHandle.addMouseLeave(this, this.handle1); + this.handleCallbackMap.handle1 = { + mouseEnter: mouseEnter, + mouseLeave: mouseLeave + }; + //create handle2 listeners and store references in map + mouseEnter = callbackHandle.addMouseEnter(this, this.handle2); + mouseLeave = callbackHandle.addMouseLeave(this, this.handle2); + this.handleCallbackMap.handle2 = { + mouseEnter: mouseEnter, + mouseLeave: mouseLeave + }; + } else { + this.sliderElem.addEventListener("mouseenter", this.showTooltip, false); + this.sliderElem.addEventListener("mouseleave", this.hideTooltip, false); + } this.handle1.addEventListener("focus", this.showTooltip, false); this.handle1.addEventListener("blur", this.hideTooltip, false); @@ -731,13 +814,14 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win step: 1, precision: 0, orientation: 'horizontal', - value: null, + value: 5, range: false, selection: 'before', tooltip: 'show', tooltip_split: false, handle: 'round', reversed: false, + rtl: 'auto', enabled: true, formatter: function formatter(val) { if (Array.isArray(val)) { @@ -751,10 +835,12 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win ticks_positions: [], ticks_labels: [], ticks_snap_bounds: 0, + ticks_tooltip: false, scale: 'linear', focus: false, tooltip_position: null, - labelledby: null + labelledby: null, + rangeHighlights: [] }, getElement: function getElement() { @@ -762,7 +848,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win }, getValue: function getValue() { - if (this.options.range || this._state.value === null) { + if (this.options.range) { return this._state.value; } else { return this._state.value[0]; @@ -771,7 +857,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win setValue: function setValue(val, triggerSlideEvent, triggerChangeEvent) { if (!val) { - val = null; + val = 0; } var oldValue = this.getValue(); this._state.value = this._validateInputValue(val); @@ -919,13 +1005,29 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win HELPERS - Any method that is not part of the public interface. - Place it underneath this comment block and write its signature like so: - _fnName : function() {...} + _fnName : function() {...} ********************************/ _removeSliderEventHandlers: function _removeSliderEventHandlers() { // Remove keydown event listeners this.handle1.removeEventListener("keydown", this.handle1Keydown, false); this.handle2.removeEventListener("keydown", this.handle2Keydown, false); + //remove the listeners from the ticks and handles if they had their own listeners + if (this.options.ticks_tooltip) { + var ticks = this.ticksContainer.getElementsByClassName('slider-tick'); + for (var i = 0; i < ticks.length; i++) { + ticks[i].removeEventListener('mouseenter', this.ticksCallbackMap[i].mouseEnter, false); + ticks[i].removeEventListener('mouseleave', this.ticksCallbackMap[i].mouseLeave, false); + } + this.handle1.removeEventListener('mouseenter', this.handleCallbackMap.handle1.mouseEnter, false); + this.handle2.removeEventListener('mouseenter', this.handleCallbackMap.handle2.mouseEnter, false); + this.handle1.removeEventListener('mouseleave', this.handleCallbackMap.handle1.mouseLeave, false); + this.handle2.removeEventListener('mouseleave', this.handleCallbackMap.handle2.mouseLeave, false); + } + + this.handleCallbackMap = null; + this.ticksCallbackMap = null; + if (this.showTooltip) { this.handle1.removeEventListener("focus", this.showTooltip, false); this.handle2.removeEventListener("focus", this.showTooltip, false); @@ -970,7 +1072,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win var eventNames = Object.keys(this.eventToCallbackMap); for (var i = 0; i < eventNames.length; i++) { var eventName = eventNames[i]; - this.eventToCallbackMap[eventName] = null; + delete this.eventToCallbackMap[eventName]; } }, _showTooltip: function _showTooltip() { @@ -993,6 +1095,49 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win } this._state.over = false; }, + _setToolTipOnMouseOver: function _setToolTipOnMouseOver(tempState) { + var formattedTooltipVal = this.options.formatter(!tempState ? this._state.value[0] : tempState.value[0]); + var positionPercentages = !tempState ? getPositionPercentages(this._state, this.options.reversed) : getPositionPercentages(tempState, this.options.reversed); + this._setText(this.tooltipInner, formattedTooltipVal); + + this.tooltip.style[this.stylePos] = positionPercentages[0] + "%"; + if (this.options.orientation === 'vertical') { + this._css(this.tooltip, "margin-" + this.stylePos, -this.tooltip.offsetHeight / 2 + "px"); + } else { + this._css(this.tooltip, "margin-" + this.stylePos, -this.tooltip.offsetWidth / 2 + "px"); + } + + function getPositionPercentages(state, reversed) { + if (reversed) { + return [100 - state.percentage[0], this.options.range ? 100 - state.percentage[1] : state.percentage[1]]; + } + return [state.percentage[0], state.percentage[1]]; + } + }, + _addTickListener: function _addTickListener() { + return { + addMouseEnter: function addMouseEnter(reference, tick, index) { + var enter = function enter() { + var tempState = reference._state; + var idString = index >= 0 ? index : this.attributes['aria-valuenow'].value; + var hoverIndex = parseInt(idString, 10); + tempState.value[0] = hoverIndex; + tempState.percentage[0] = reference.options.ticks_positions[hoverIndex]; + reference._setToolTipOnMouseOver(tempState); + reference._showTooltip(); + }; + tick.addEventListener("mouseenter", enter, false); + return enter; + }, + addMouseLeave: function addMouseLeave(reference, tick) { + var leave = function leave() { + reference._hideTooltip(); + }; + tick.addEventListener("mouseleave", leave, false); + return leave; + } + }; + }, _layout: function _layout() { var positionPercentages; @@ -1002,24 +1147,71 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win positionPercentages = [this._state.percentage[0], this._state.percentage[1]]; } - this.handle1.style[this.stylePos] = positionPercentages[0] + '%'; + this.handle1.style[this.stylePos] = positionPercentages[0] + "%"; this.handle1.setAttribute('aria-valuenow', this._state.value[0]); + if (isNaN(this.options.formatter(this._state.value[0]))) { + this.handle1.setAttribute('aria-valuetext', this.options.formatter(this._state.value[0])); + } - this.handle2.style[this.stylePos] = positionPercentages[1] + '%'; + this.handle2.style[this.stylePos] = positionPercentages[1] + "%"; this.handle2.setAttribute('aria-valuenow', this._state.value[1]); + if (isNaN(this.options.formatter(this._state.value[1]))) { + this.handle2.setAttribute('aria-valuetext', this.options.formatter(this._state.value[1])); + } + + /* Position highlight range elements */ + if (this.rangeHighlightElements.length > 0 && Array.isArray(this.options.rangeHighlights) && this.options.rangeHighlights.length > 0) { + for (var _i = 0; _i < this.options.rangeHighlights.length; _i++) { + var startPercent = this._toPercentage(this.options.rangeHighlights[_i].start); + var endPercent = this._toPercentage(this.options.rangeHighlights[_i].end); + + if (this.options.reversed) { + var sp = 100 - endPercent; + endPercent = 100 - startPercent; + startPercent = sp; + } + + var currentRange = this._createHighlightRange(startPercent, endPercent); + + if (currentRange) { + if (this.options.orientation === 'vertical') { + this.rangeHighlightElements[_i].style.top = currentRange.start + "%"; + this.rangeHighlightElements[_i].style.height = currentRange.size + "%"; + } else { + if (this.options.rtl) { + this.rangeHighlightElements[_i].style.right = currentRange.start + "%"; + } else { + this.rangeHighlightElements[_i].style.left = currentRange.start + "%"; + } + this.rangeHighlightElements[_i].style.width = currentRange.size + "%"; + } + } else { + this.rangeHighlightElements[_i].style.display = "none"; + } + } + } /* Position ticks and labels */ if (Array.isArray(this.options.ticks) && this.options.ticks.length > 0) { var styleSize = this.options.orientation === 'vertical' ? 'height' : 'width'; - var styleMargin = this.options.orientation === 'vertical' ? 'marginTop' : 'marginLeft'; + var styleMargin; + if (this.options.orientation === 'vertical') { + styleMargin = 'marginTop'; + } else { + if (this.options.rtl) { + styleMargin = 'marginRight'; + } else { + styleMargin = 'marginLeft'; + } + } var labelSize = this._state.size / (this.options.ticks.length - 1); if (this.tickLabelContainer) { var extraMargin = 0; if (this.options.ticks_positions.length === 0) { if (this.options.orientation !== 'vertical') { - this.tickLabelContainer.style[styleMargin] = -labelSize / 2 + 'px'; + this.tickLabelContainer.style[styleMargin] = -labelSize / 2 + "px"; } extraMargin = this.tickLabelContainer.offsetHeight; @@ -1032,7 +1224,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win } } if (this.options.orientation === 'horizontal') { - this.sliderElem.style.marginBottom = extraMargin + 'px'; + this.sliderElem.style.marginBottom = extraMargin + "px"; } } for (var i = 0; i < this.options.ticks.length; i++) { @@ -1043,7 +1235,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win percentage = 100 - percentage; } - this.ticks[i].style[this.stylePos] = percentage + '%'; + this.ticks[i].style[this.stylePos] = percentage + "%"; /* Set class labels to denote whether ticks are in the selection */ this._removeClass(this.ticks[i], 'in-selection'); @@ -1058,15 +1250,19 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win } if (this.tickLabels[i]) { - this.tickLabels[i].style[styleSize] = labelSize + 'px'; + this.tickLabels[i].style[styleSize] = labelSize + "px"; if (this.options.orientation !== 'vertical' && this.options.ticks_positions[i] !== undefined) { this.tickLabels[i].style.position = 'absolute'; - this.tickLabels[i].style[this.stylePos] = percentage + '%'; + this.tickLabels[i].style[this.stylePos] = percentage + "%"; this.tickLabels[i].style[styleMargin] = -labelSize / 2 + 'px'; } else if (this.options.orientation === 'vertical') { - this.tickLabels[i].style['marginLeft'] = this.sliderElem.offsetWidth + 'px'; - this.tickLabelContainer.style['marginTop'] = this.sliderElem.offsetWidth / 2 * -1 + 'px'; + if (this.options.rtl) { + this.tickLabels[i].style['marginRight'] = this.sliderElem.offsetWidth + "px"; + } else { + this.tickLabels[i].style['marginLeft'] = this.sliderElem.offsetWidth + "px"; + } + this.tickLabelContainer.style[styleMargin] = this.sliderElem.offsetWidth / 2 * -1 + 'px'; } } } @@ -1077,18 +1273,12 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win if (this.options.range) { formattedTooltipVal = this.options.formatter(this._state.value); this._setText(this.tooltipInner, formattedTooltipVal); - this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0]) / 2 + '%'; + this.tooltip.style[this.stylePos] = (positionPercentages[1] + positionPercentages[0]) / 2 + "%"; if (this.options.orientation === 'vertical') { - this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px'); + this._css(this.tooltip, "margin-" + this.stylePos, -this.tooltip.offsetHeight / 2 + "px"); } else { - this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px'); - } - - if (this.options.orientation === 'vertical') { - this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px'); - } else { - this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px'); + this._css(this.tooltip, "margin-" + this.stylePos, -this.tooltip.offsetWidth / 2 + "px"); } var innerTooltipMinText = this.options.formatter(this._state.value[0]); @@ -1097,30 +1287,30 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win var innerTooltipMaxText = this.options.formatter(this._state.value[1]); this._setText(this.tooltipInner_max, innerTooltipMaxText); - this.tooltip_min.style[this.stylePos] = positionPercentages[0] + '%'; + this.tooltip_min.style[this.stylePos] = positionPercentages[0] + "%"; if (this.options.orientation === 'vertical') { - this._css(this.tooltip_min, 'margin-top', -this.tooltip_min.offsetHeight / 2 + 'px'); + this._css(this.tooltip_min, "margin-" + this.stylePos, -this.tooltip_min.offsetHeight / 2 + "px"); } else { - this._css(this.tooltip_min, 'margin-left', -this.tooltip_min.offsetWidth / 2 + 'px'); + this._css(this.tooltip_min, "margin-" + this.stylePos, -this.tooltip_min.offsetWidth / 2 + "px"); } - this.tooltip_max.style[this.stylePos] = positionPercentages[1] + '%'; + this.tooltip_max.style[this.stylePos] = positionPercentages[1] + "%"; if (this.options.orientation === 'vertical') { - this._css(this.tooltip_max, 'margin-top', -this.tooltip_max.offsetHeight / 2 + 'px'); + this._css(this.tooltip_max, "margin-" + this.stylePos, -this.tooltip_max.offsetHeight / 2 + "px"); } else { - this._css(this.tooltip_max, 'margin-left', -this.tooltip_max.offsetWidth / 2 + 'px'); + this._css(this.tooltip_max, "margin-" + this.stylePos, -this.tooltip_max.offsetWidth / 2 + "px"); } } else { formattedTooltipVal = this.options.formatter(this._state.value[0]); this._setText(this.tooltipInner, formattedTooltipVal); - this.tooltip.style[this.stylePos] = positionPercentages[0] + '%'; + this.tooltip.style[this.stylePos] = positionPercentages[0] + "%"; if (this.options.orientation === 'vertical') { - this._css(this.tooltip, 'margin-top', -this.tooltip.offsetHeight / 2 + 'px'); + this._css(this.tooltip, "margin-" + this.stylePos, -this.tooltip.offsetHeight / 2 + "px"); } else { - this._css(this.tooltip, 'margin-left', -this.tooltip.offsetWidth / 2 + 'px'); + this._css(this.tooltip, "margin-" + this.stylePos, -this.tooltip.offsetWidth / 2 + "px"); } } @@ -1134,13 +1324,25 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win this.trackHigh.style.bottom = '0'; this.trackHigh.style.height = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + '%'; } else { - this.trackLow.style.left = '0'; + if (this.stylePos === 'right') { + this.trackLow.style.right = '0'; + } else { + this.trackLow.style.left = '0'; + } this.trackLow.style.width = Math.min(positionPercentages[0], positionPercentages[1]) + '%'; - this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) + '%'; + if (this.stylePos === 'right') { + this.trackSelection.style.right = Math.min(positionPercentages[0], positionPercentages[1]) + '%'; + } else { + this.trackSelection.style.left = Math.min(positionPercentages[0], positionPercentages[1]) + '%'; + } this.trackSelection.style.width = Math.abs(positionPercentages[0] - positionPercentages[1]) + '%'; - this.trackHigh.style.right = '0'; + if (this.stylePos === 'right') { + this.trackHigh.style.left = '0'; + } else { + this.trackHigh.style.right = '0'; + } this.trackHigh.style.width = 100 - Math.min(positionPercentages[0], positionPercentages[1]) - Math.abs(positionPercentages[0] - positionPercentages[1]) + '%'; var offset_min = this.tooltip_min.getBoundingClientRect(); @@ -1171,6 +1373,22 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win } } }, + _createHighlightRange: function _createHighlightRange(start, end) { + if (this._isHighlightRange(start, end)) { + if (start > end) { + return { 'start': end, 'size': start - end }; + } + return { 'start': start, 'size': end - start }; + } + return null; + }, + _isHighlightRange: function _isHighlightRange(start, end) { + if (0 <= start && start <= 100 && 0 <= end && end <= 100) { + return true; + } else { + return false; + } + }, _resize: function _resize(ev) { /*jshint unused:false*/ this._state.offset = this._offset(this.sliderElem); @@ -1238,7 +1456,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win this._setDataVal(newValue); this.setValue(newValue, false, true); - this._pauseEvent(ev); + ev.returnValue = false; if (this.options.focus) { this._triggerFocusOnHandle(this._state.dragged); @@ -1289,16 +1507,13 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win // use natural arrow keys instead of from min to max if (this.options.natural_arrow_keys) { var ifVerticalAndNotReversed = this.options.orientation === 'vertical' && !this.options.reversed; - var ifHorizontalAndReversed = this.options.orientation === 'horizontal' && this.options.reversed; + var ifHorizontalAndReversed = this.options.orientation === 'horizontal' && this.options.reversed; // @todo control with rtl if (ifVerticalAndNotReversed || ifHorizontalAndReversed) { dir = -dir; } } - if (this._state.value === null) { - this._state.value[0] = this._state.min; - this._state.value[1] = this._state.max; - } + var val = this._state.value[handleIdx] + dir * this.options.step; if (this.options.range) { val = [!handleIdx ? val : this._state.value[0], handleIdx ? val : this._state.value[1]]; @@ -1446,9 +1661,6 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0)); }, _applyToFixedAndParseFloat: function _applyToFixedAndParseFloat(num, toFixedInput) { - if (num === null) { - return null; - } var truncatedNum = num.toFixed(toFixedInput); return parseFloat(truncatedNum); }, @@ -1464,6 +1676,9 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win var eventPosition = ev[this.mousePos]; var sliderOffset = this._state.offset[this.stylePos]; var distanceToSlide = eventPosition - sliderOffset; + if (this.stylePos === 'right') { + distanceToSlide = -distanceToSlide; + } // Calculate what percent of the length the slider handle has slid var percentage = distanceToSlide / this._state.size * 100; percentage = Math.round(percentage / this._state.percentage[2]) * this._state.percentage[2]; @@ -1477,13 +1692,11 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win return Math.max(0, Math.min(100, percentage)); }, _validateInputValue: function _validateInputValue(val) { - if (typeof val === 'number') { - return val; + if (!isNaN(+val)) { + return +val; } else if (Array.isArray(val)) { this._validateArray(val); return val; - } else if (val === null) { - return null; } else { throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(val)); } @@ -1491,7 +1704,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win _validateArray: function _validateArray(val) { for (var i = 0; i < val.length; i++) { var input = val[i]; - if (typeof input !== 'number' && input !== null) { + if (typeof input !== 'number') { throw new Error(ErrorMsgs.formatInvalidInputErrorMsg(input)); } } @@ -1567,6 +1780,9 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win _offsetLeft: function _offsetLeft(obj) { return obj.getBoundingClientRect().left; }, + _offsetRight: function _offsetRight(obj) { + return obj.getBoundingClientRect().right; + }, _offsetTop: function _offsetTop(obj) { var offsetTop = obj.offsetTop; while ((obj = obj.offsetParent) && !isNaN(obj.offsetTop)) { @@ -1580,6 +1796,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win _offset: function _offset(obj) { return { left: this._offsetLeft(obj), + right: this._offsetRight(obj), top: this._offsetTop(obj) }; }, @@ -1602,7 +1819,16 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win _setTooltipPosition: function _setTooltipPosition() { var tooltips = [this.tooltip, this.tooltip_min, this.tooltip_max]; if (this.options.orientation === 'vertical') { - var tooltipPos = this.options.tooltip_position || 'right'; + var tooltipPos; + if (this.options.tooltip_position) { + tooltipPos = this.options.tooltip_position; + } else { + if (this.options.rtl) { + tooltipPos = 'left'; + } else { + tooltipPos = 'right'; + } + } var oppositeSide = tooltipPos === 'left' ? 'right' : 'left'; tooltips.forEach(function (tooltip) { this._addClass(tooltip, tooltipPos); @@ -1634,7 +1860,7 @@ var windowIsDefined = (typeof window === "undefined" ? "undefined" : _typeof(win autoRegisterNamespace = NAMESPACE_MAIN; } else { if (windowIsDefined) { - //window.console.warn("bootstrap-slider.js - WARNING: $.fn.slider namespace is already bound. Use the $.fn.bootstrapSlider namespace instead."); + window.console.warn("bootstrap-slider.js - WARNING: $.fn.slider namespace is already bound. Use the $.fn.bootstrapSlider namespace instead."); } autoRegisterNamespace = NAMESPACE_ALTERNATE; } diff --git a/third_party/bootstrap-slider/bootstrap-slider.min.js b/third_party/bootstrap-slider/bootstrap-slider.min.js index 3fadff9ea11..abe13ab6344 100644 --- a/third_party/bootstrap-slider/bootstrap-slider.min.js +++ b/third_party/bootstrap-slider/bootstrap-slider.min.js @@ -1,4 +1,5 @@ /*! ======================================================= - VERSION 9.1.3 + VERSION 9.6.0 ========================================================= */ -"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol?"symbol":typeof a},windowIsDefined="object"===("undefined"==typeof window?"undefined":_typeof(window));!function(a){if("function"==typeof define&&define.amd)define(["jquery"],a);else if("object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports){var b;try{b=require("jquery")}catch(c){b=null}module.exports=a(b)}else window&&(window.Slider=a(window.jQuery))}(function(a){var b="slider",c="bootstrapSlider";windowIsDefined&&!window.console&&(window.console={}),windowIsDefined&&!window.console.log&&(window.console.log=function(){}),windowIsDefined&&!window.console.warn&&(window.console.warn=function(){});var d;return function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l&&l!==k)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}var m=this.map(function(){var d=a.data(this,b);return d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d)),a(this)});return!m||m.length>1?m:m[0]}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;c(a)}(a),function(a){function e(b,c){function d(a,b){var c="data-slider-"+b.replace(/_/g,"-"),d=a.getAttribute(c);try{return JSON.parse(d)}catch(e){return d}}this._state={value:null,enabled:null,offset:null,size:null,percentage:null,inDrag:!1,over:!1},"string"==typeof b?this.element=document.querySelector(b):b instanceof HTMLElement&&(this.element=b),c=c?c:{};for(var e=Object.keys(this.defaultOptions),f=0;f0){for(this.ticksContainer=document.createElement("div"),this.ticksContainer.className="slider-tick-container",f=0;f0)for(this.tickLabelContainer=document.createElement("div"),this.tickLabelContainer.className="slider-tick-label-container",f=0;f0&&(this.options.max=Math.max.apply(Math,this.options.ticks),this.options.min=Math.min.apply(Math,this.options.ticks)),Array.isArray(this.options.value)?(this.options.range=!0,this._state.value=this.options.value):this.options.range?this._state.value=[this.options.value,this.options.max]:this._state.value=this.options.value,this.trackLow=k||this.trackLow,this.trackSelection=j||this.trackSelection,this.trackHigh=l||this.trackHigh,"none"===this.options.selection&&(this._addClass(this.trackLow,"hide"),this._addClass(this.trackSelection,"hide"),this._addClass(this.trackHigh,"hide")),this.handle1=m||this.handle1,this.handle2=n||this.handle2,p===!0)for(this._removeClass(this.handle1,"round triangle"),this._removeClass(this.handle2,"round triangle hide"),f=0;f0){for(var d,e,f,g=0,h=1;hthis.options.max?this.options.max:k},toPercentage:function(a){if(this.options.max===this.options.min)return 0;if(this.options.ticks_positions.length>0){for(var b,c,d,e=0,f=0;f0?this.options.ticks[f-1]:0,d=f>0?this.options.ticks_positions[f-1]:0,c=this.options.ticks[f],e=this.options.ticks_positions[f];break}if(f>0){var g=(a-b)/(c-b);return d+g*(e-d)}}return 100*(a-this.options.min)/(this.options.max-this.options.min)}},logarithmic:{toValue:function(a){var b=0===this.options.min?0:Math.log(this.options.min),c=Math.log(this.options.max),d=Math.exp(b+(c-b)*a/100);return d=this.options.min+Math.round((d-this.options.min)/this.options.step)*this.options.step,dthis.options.max?this.options.max:d},toPercentage:function(a){if(this.options.max===this.options.min)return 0;var b=Math.log(this.options.max),c=0===this.options.min?0:Math.log(this.options.min),d=0===a?0:Math.log(a);return 100*(d-c)/(b-c)}}};d=function(a,b){return e.call(this,a,b),this},d.prototype={_init:function(){},constructor:d,defaultOptions:{id:"",min:0,max:10,step:1,precision:0,orientation:"horizontal",value:null,range:!1,selection:"before",tooltip:"show",tooltip_split:!1,handle:"round",reversed:!1,enabled:!0,formatter:function(a){return Array.isArray(a)?a[0]+" : "+a[1]:a},natural_arrow_keys:!1,ticks:[],ticks_positions:[],ticks_labels:[],ticks_snap_bounds:0,scale:"linear",focus:!1,tooltip_position:null,labelledby:null},getElement:function(){return this.sliderElem},getValue:function(){return this.options.range||null===this._state.value?this._state.value:this._state.value[0]},setValue:function(a,b,c){a||(a=null);var d=this.getValue();this._state.value=this._validateInputValue(a);var e=this._applyPrecision.bind(this);this.options.range?(this._state.value[0]=e(this._state.value[0]),this._state.value[1]=e(this._state.value[1]),this._state.value[0]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[0])),this._state.value[1]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[1]))):(this._state.value=e(this._state.value),this._state.value=[Math.max(this.options.min,Math.min(this.options.max,this._state.value))],this._addClass(this.handle2,"hide"),"after"===this.options.selection?this._state.value[1]=this.options.max:this._state.value[1]=this.options.min),this.options.max>this.options.min?this._state.percentage=[this._toPercentage(this._state.value[0]),this._toPercentage(this._state.value[1]),100*this.options.step/(this.options.max-this.options.min)]:this._state.percentage=[0,0,100],this._layout();var f=this.options.range?this._state.value:this._state.value[0];return this._setDataVal(f),b===!0&&this._trigger("slide",f),d!==f&&c===!0&&this._trigger("change",{oldValue:d,newValue:f}),this},destroy:function(){this._removeSliderEventHandlers(),this.sliderElem.parentNode.removeChild(this.sliderElem),this.element.style.display="",this._cleanUpEventCallbacksMap(),this.element.removeAttribute("data"),a&&(this._unbindJQueryEventHandlers(),this.$element.removeData("slider"))},disable:function(){return this._state.enabled=!1,this.handle1.removeAttribute("tabindex"),this.handle2.removeAttribute("tabindex"),this._addClass(this.sliderElem,"slider-disabled"),this._trigger("slideDisabled"),this},enable:function(){return this._state.enabled=!0,this.handle1.setAttribute("tabindex",0),this.handle2.setAttribute("tabindex",0),this._removeClass(this.sliderElem,"slider-disabled"),this._trigger("slideEnabled"),this},toggle:function(){return this._state.enabled?this.disable():this.enable(),this},isEnabled:function(){return this._state.enabled},on:function(a,b){return this._bindNonQueryEventHandler(a,b),this},off:function(b,c){a?(this.$element.off(b,c),this.$sliderElem.off(b,c)):this._unbindNonQueryEventHandler(b,c)},getAttribute:function(a){return a?this.options[a]:this.options},setAttribute:function(a,b){return this.options[a]=b,this},refresh:function(){return this._removeSliderEventHandlers(),e.call(this,this.element,this.options),a&&a.data(this.element,"slider",this),this},relayout:function(){return this._resize(),this._layout(),this},_removeSliderEventHandlers:function(){this.handle1.removeEventListener("keydown",this.handle1Keydown,!1),this.handle2.removeEventListener("keydown",this.handle2Keydown,!1),this.showTooltip&&(this.handle1.removeEventListener("focus",this.showTooltip,!1),this.handle2.removeEventListener("focus",this.showTooltip,!1)),this.hideTooltip&&(this.handle1.removeEventListener("blur",this.hideTooltip,!1),this.handle2.removeEventListener("blur",this.hideTooltip,!1)),this.showTooltip&&this.sliderElem.removeEventListener("mouseenter",this.showTooltip,!1),this.hideTooltip&&this.sliderElem.removeEventListener("mouseleave",this.hideTooltip,!1),this.sliderElem.removeEventListener("touchstart",this.touchstart,!1),this.sliderElem.removeEventListener("touchmove",this.touchmove,!1),this.sliderElem.removeEventListener("mousedown",this.mousedown,!1),window.removeEventListener("resize",this.resize,!1)},_bindNonQueryEventHandler:function(a,b){void 0===this.eventToCallbackMap[a]&&(this.eventToCallbackMap[a]=[]),this.eventToCallbackMap[a].push(b)},_unbindNonQueryEventHandler:function(a,b){var c=this.eventToCallbackMap[a];if(void 0!==c)for(var d=0;d0){var b="vertical"===this.options.orientation?"height":"width",c="vertical"===this.options.orientation?"marginTop":"marginLeft",d=this._state.size/(this.options.ticks.length-1);if(this.tickLabelContainer){var e=0;if(0===this.options.ticks_positions.length)"vertical"!==this.options.orientation&&(this.tickLabelContainer.style[c]=-d/2+"px"),e=this.tickLabelContainer.offsetHeight;else for(f=0;fe&&(e=this.tickLabelContainer.childNodes[f].offsetHeight);"horizontal"===this.options.orientation&&(this.sliderElem.style.marginBottom=e+"px")}for(var f=0;f=a[0]&&g<=a[1]&&this._addClass(this.ticks[f],"in-selection"):"after"===this.options.selection&&g>=a[0]?this._addClass(this.ticks[f],"in-selection"):"before"===this.options.selection&&g<=a[0]&&this._addClass(this.ticks[f],"in-selection"),this.tickLabels[f]&&(this.tickLabels[f].style[b]=d+"px","vertical"!==this.options.orientation&&void 0!==this.options.ticks_positions[f]?(this.tickLabels[f].style.position="absolute",this.tickLabels[f].style[this.stylePos]=g+"%",this.tickLabels[f].style[c]=-d/2+"px"):"vertical"===this.options.orientation&&(this.tickLabels[f].style.marginLeft=this.sliderElem.offsetWidth+"px",this.tickLabelContainer.style.marginTop=this.sliderElem.offsetWidth/2*-1+"px"))}}var h;if(this.options.range){h=this.options.formatter(this._state.value),this._setText(this.tooltipInner,h),this.tooltip.style[this.stylePos]=(a[1]+a[0])/2+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-top",-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-left",-this.tooltip.offsetWidth/2+"px"),"vertical"===this.options.orientation?this._css(this.tooltip,"margin-top",-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-left",-this.tooltip.offsetWidth/2+"px");var i=this.options.formatter(this._state.value[0]);this._setText(this.tooltipInner_min,i);var j=this.options.formatter(this._state.value[1]);this._setText(this.tooltipInner_max,j),this.tooltip_min.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip_min,"margin-top",-this.tooltip_min.offsetHeight/2+"px"):this._css(this.tooltip_min,"margin-left",-this.tooltip_min.offsetWidth/2+"px"),this.tooltip_max.style[this.stylePos]=a[1]+"%","vertical"===this.options.orientation?this._css(this.tooltip_max,"margin-top",-this.tooltip_max.offsetHeight/2+"px"):this._css(this.tooltip_max,"margin-left",-this.tooltip_max.offsetWidth/2+"px")}else h=this.options.formatter(this._state.value[0]),this._setText(this.tooltipInner,h),this.tooltip.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-top",-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-left",-this.tooltip.offsetWidth/2+"px");if("vertical"===this.options.orientation)this.trackLow.style.top="0",this.trackLow.style.height=Math.min(a[0],a[1])+"%",this.trackSelection.style.top=Math.min(a[0],a[1])+"%",this.trackSelection.style.height=Math.abs(a[0]-a[1])+"%",this.trackHigh.style.bottom="0",this.trackHigh.style.height=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";else{this.trackLow.style.left="0",this.trackLow.style.width=Math.min(a[0],a[1])+"%",this.trackSelection.style.left=Math.min(a[0],a[1])+"%",this.trackSelection.style.width=Math.abs(a[0]-a[1])+"%",this.trackHigh.style.right="0",this.trackHigh.style.width=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";var k=this.tooltip_min.getBoundingClientRect(),l=this.tooltip_max.getBoundingClientRect();"bottom"===this.options.tooltip_position?k.right>l.left?(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top="",this.tooltip_max.style.bottom="22px"):(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top=this.tooltip_min.style.top,this.tooltip_max.style.bottom=""):k.right>l.left?(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top="18px"):(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top=this.tooltip_min.style.top)}},_resize:function(a){this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos],this._layout()},_removeProperty:function(a,b){a.style.removeProperty?a.style.removeProperty(b):a.style.removeAttribute(b)},_mousedown:function(a){if(!this._state.enabled)return!1;this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos];var b=this._getPercentage(a);if(this.options.range){var c=Math.abs(this._state.percentage[0]-b),d=Math.abs(this._state.percentage[1]-b);this._state.dragged=d>c?0:1,this._adjustPercentageForRangeSliders(b)}else this._state.dragged=0;this._state.percentage[this._state.dragged]=b,this._layout(),this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),this.mousemove&&document.removeEventListener("mousemove",this.mousemove,!1),this.mouseup&&document.removeEventListener("mouseup",this.mouseup,!1),this.mousemove=this._mousemove.bind(this),this.mouseup=this._mouseup.bind(this),this.touchCapable&&(document.addEventListener("touchmove",this.mousemove,!1),document.addEventListener("touchend",this.mouseup,!1)),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!0;var e=this._calculateValue();return this._trigger("slideStart",e),this._setDataVal(e),this.setValue(e,!1,!0),this._pauseEvent(a),this.options.focus&&this._triggerFocusOnHandle(this._state.dragged),!0},_touchstart:function(a){if(void 0===a.changedTouches)return void this._mousedown(a);var b=a.changedTouches[0];this.touchX=b.pageX,this.touchY=b.pageY},_triggerFocusOnHandle:function(a){0===a&&this.handle1.focus(),1===a&&this.handle2.focus()},_keydown:function(a,b){if(!this._state.enabled)return!1;var c;switch(b.keyCode){case 37:case 40:c=-1;break;case 39:case 38:c=1}if(c){if(this.options.natural_arrow_keys){var d="vertical"===this.options.orientation&&!this.options.reversed,e="horizontal"===this.options.orientation&&this.options.reversed;(d||e)&&(c=-c)}null===this._state.value&&(this._state.value[0]=this._state.min,this._state.value[1]=this._state.max);var f=this._state.value[a]+c*this.options.step;return this.options.range&&(f=[a?this._state.value[0]:f,a?f:this._state.value[1]]),this._trigger("slideStart",f),this._setDataVal(f),this.setValue(f,!0,!0),this._setDataVal(f),this._trigger("slideStop",f),this._layout(),this._pauseEvent(b),!1}},_pauseEvent:function(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.cancelBubble=!0,a.returnValue=!1},_mousemove:function(a){if(!this._state.enabled)return!1;var b=this._getPercentage(a);this._adjustPercentageForRangeSliders(b),this._state.percentage[this._state.dragged]=b,this._layout();var c=this._calculateValue(!0);return this.setValue(c,!0,!0),!1},_touchmove:function(a){if(void 0!==a.changedTouches){var b=a.changedTouches[0],c=b.pageX-this.touchX,d=b.pageY-this.touchY;this._state.inDrag||("vertical"===this.options.orientation&&5>=c&&c>=-5&&(d>=15||-15>=d)?this._mousedown(a):5>=d&&d>=-5&&(c>=15||-15>=c)&&this._mousedown(a))}},_adjustPercentageForRangeSliders:function(a){if(this.options.range){var b=this._getNumDigitsAfterDecimalPlace(a);b=b?b-1:0;var c=this._applyToFixedAndParseFloat(a,b);0===this._state.dragged&&this._applyToFixedAndParseFloat(this._state.percentage[1],b)c&&(this._state.percentage[1]=this._state.percentage[0],this._state.dragged=0)}},_mouseup:function(){if(!this._state.enabled)return!1;this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!1,this._state.over===!1&&this._hideTooltip();var a=this._calculateValue(!0);return this._layout(),this._setDataVal(a),this._trigger("slideStop",a),!1},_calculateValue:function(a){var b;if(this.options.range?(b=[this.options.min,this.options.max],0!==this._state.percentage[0]&&(b[0]=this._toValue(this._state.percentage[0]),b[0]=this._applyPrecision(b[0])),100!==this._state.percentage[1]&&(b[1]=this._toValue(this._state.percentage[1]),b[1]=this._applyPrecision(b[1]))):(b=this._toValue(this._state.percentage[0]),b=parseFloat(b),b=this._applyPrecision(b)),a){for(var c=[b,1/0],d=0;dh;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l&&l!==k)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}var m=this.map(function(){var d=a.data(this,b);return d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d)),a(this)});return!m||m.length>1?m:m[0]}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;c(a)}(a),function(a){function e(b,c){function d(a,b){var c="data-slider-"+b.replace(/_/g,"-"),d=a.getAttribute(c);try{return JSON.parse(d)}catch(e){return d}}this._state={value:null,enabled:null,offset:null,size:null,percentage:null,inDrag:!1,over:!1},this.ticksCallbackMap={},this.handleCallbackMap={},"string"==typeof b?this.element=document.querySelector(b):b instanceof HTMLElement&&(this.element=b),c=c?c:{};for(var e=Object.keys(this.defaultOptions),f=0;f0)for(var s=0;s0){for(this.ticksContainer=document.createElement("div"),this.ticksContainer.className="slider-tick-container",f=0;f0)for(this.tickLabelContainer=document.createElement("div"),this.tickLabelContainer.className="slider-tick-label-container",f=0;f0&&(this.options.max=Math.max.apply(Math,this.options.ticks),this.options.min=Math.min.apply(Math,this.options.ticks)),Array.isArray(this.options.value)?(this.options.range=!0,this._state.value=this.options.value):this.options.range?this._state.value=[this.options.value,this.options.max]:this._state.value=this.options.value,this.trackLow=k||this.trackLow,this.trackSelection=j||this.trackSelection,this.trackHigh=l||this.trackHigh,"none"===this.options.selection?(this._addClass(this.trackLow,"hide"),this._addClass(this.trackSelection,"hide"),this._addClass(this.trackHigh,"hide")):("after"===this.options.selection||"before"===this.options.selection)&&(this._removeClass(this.trackLow,"hide"),this._removeClass(this.trackSelection,"hide"),this._removeClass(this.trackHigh,"hide")),this.handle1=m||this.handle1,this.handle2=n||this.handle2,p===!0)for(this._removeClass(this.handle1,"round triangle"),this._removeClass(this.handle2,"round triangle hide"),f=0;f0){for(var d,e,f,g=0,h=1;hthis.options.max?this.options.max:k},toPercentage:function(a){if(this.options.max===this.options.min)return 0;if(this.options.ticks_positions.length>0){for(var b,c,d,e=0,f=0;f0?this.options.ticks[f-1]:0,d=f>0?this.options.ticks_positions[f-1]:0,c=this.options.ticks[f],e=this.options.ticks_positions[f];break}if(f>0){var g=(a-b)/(c-b);return d+g*(e-d)}}return 100*(a-this.options.min)/(this.options.max-this.options.min)}},logarithmic:{toValue:function(a){var b=0===this.options.min?0:Math.log(this.options.min),c=Math.log(this.options.max),d=Math.exp(b+(c-b)*a/100);return d=this.options.min+Math.round((d-this.options.min)/this.options.step)*this.options.step,dthis.options.max?this.options.max:d},toPercentage:function(a){if(this.options.max===this.options.min)return 0;var b=Math.log(this.options.max),c=0===this.options.min?0:Math.log(this.options.min),d=0===a?0:Math.log(a);return 100*(d-c)/(b-c)}}};d=function(a,b){return e.call(this,a,b),this},d.prototype={_init:function(){},constructor:d,defaultOptions:{id:"",min:0,max:10,step:1,precision:0,orientation:"horizontal",value:5,range:!1,selection:"before",tooltip:"show",tooltip_split:!1,handle:"round",reversed:!1,rtl:"auto",enabled:!0,formatter:function(a){return Array.isArray(a)?a[0]+" : "+a[1]:a},natural_arrow_keys:!1,ticks:[],ticks_positions:[],ticks_labels:[],ticks_snap_bounds:0,ticks_tooltip:!1,scale:"linear",focus:!1,tooltip_position:null,labelledby:null,rangeHighlights:[]},getElement:function(){return this.sliderElem},getValue:function(){return this.options.range?this._state.value:this._state.value[0]},setValue:function(a,b,c){a||(a=0);var d=this.getValue();this._state.value=this._validateInputValue(a);var e=this._applyPrecision.bind(this);this.options.range?(this._state.value[0]=e(this._state.value[0]),this._state.value[1]=e(this._state.value[1]),this._state.value[0]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[0])),this._state.value[1]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[1]))):(this._state.value=e(this._state.value),this._state.value=[Math.max(this.options.min,Math.min(this.options.max,this._state.value))],this._addClass(this.handle2,"hide"),"after"===this.options.selection?this._state.value[1]=this.options.max:this._state.value[1]=this.options.min),this.options.max>this.options.min?this._state.percentage=[this._toPercentage(this._state.value[0]),this._toPercentage(this._state.value[1]),100*this.options.step/(this.options.max-this.options.min)]:this._state.percentage=[0,0,100],this._layout();var f=this.options.range?this._state.value:this._state.value[0];return this._setDataVal(f),b===!0&&this._trigger("slide",f),d!==f&&c===!0&&this._trigger("change",{oldValue:d,newValue:f}),this},destroy:function(){this._removeSliderEventHandlers(),this.sliderElem.parentNode.removeChild(this.sliderElem),this.element.style.display="",this._cleanUpEventCallbacksMap(),this.element.removeAttribute("data"),a&&(this._unbindJQueryEventHandlers(),this.$element.removeData("slider"))},disable:function(){return this._state.enabled=!1,this.handle1.removeAttribute("tabindex"),this.handle2.removeAttribute("tabindex"),this._addClass(this.sliderElem,"slider-disabled"),this._trigger("slideDisabled"),this},enable:function(){return this._state.enabled=!0,this.handle1.setAttribute("tabindex",0),this.handle2.setAttribute("tabindex",0),this._removeClass(this.sliderElem,"slider-disabled"),this._trigger("slideEnabled"),this},toggle:function(){return this._state.enabled?this.disable():this.enable(),this},isEnabled:function(){return this._state.enabled},on:function(a,b){return this._bindNonQueryEventHandler(a,b),this},off:function(b,c){a?(this.$element.off(b,c),this.$sliderElem.off(b,c)):this._unbindNonQueryEventHandler(b,c)},getAttribute:function(a){return a?this.options[a]:this.options},setAttribute:function(a,b){return this.options[a]=b,this},refresh:function(){return this._removeSliderEventHandlers(),e.call(this,this.element,this.options),a&&a.data(this.element,"slider",this),this},relayout:function(){return this._resize(),this._layout(),this},_removeSliderEventHandlers:function(){if(this.handle1.removeEventListener("keydown",this.handle1Keydown,!1),this.handle2.removeEventListener("keydown",this.handle2Keydown,!1),this.options.ticks_tooltip){for(var a=this.ticksContainer.getElementsByClassName("slider-tick"),b=0;b=0?c:this.attributes["aria-valuenow"].value,e=parseInt(d,10);b.value[0]=e,b.percentage[0]=a.options.ticks_positions[e],a._setToolTipOnMouseOver(b),a._showTooltip()};return b.addEventListener("mouseenter",d,!1),d},addMouseLeave:function(a,b){var c=function(){a._hideTooltip()};return b.addEventListener("mouseleave",c,!1),c}}},_layout:function(){var a;if(a=this.options.reversed?[100-this._state.percentage[0],this.options.range?100-this._state.percentage[1]:this._state.percentage[1]]:[this._state.percentage[0],this._state.percentage[1]],this.handle1.style[this.stylePos]=a[0]+"%",this.handle1.setAttribute("aria-valuenow",this._state.value[0]),isNaN(this.options.formatter(this._state.value[0]))&&this.handle1.setAttribute("aria-valuetext",this.options.formatter(this._state.value[0])),this.handle2.style[this.stylePos]=a[1]+"%",this.handle2.setAttribute("aria-valuenow",this._state.value[1]),isNaN(this.options.formatter(this._state.value[1]))&&this.handle2.setAttribute("aria-valuetext",this.options.formatter(this._state.value[1])),this.rangeHighlightElements.length>0&&Array.isArray(this.options.rangeHighlights)&&this.options.rangeHighlights.length>0)for(var b=0;b0){var g,h="vertical"===this.options.orientation?"height":"width";g="vertical"===this.options.orientation?"marginTop":this.options.rtl?"marginRight":"marginLeft";var i=this._state.size/(this.options.ticks.length-1);if(this.tickLabelContainer){var j=0;if(0===this.options.ticks_positions.length)"vertical"!==this.options.orientation&&(this.tickLabelContainer.style[g]=-i/2+"px"),j=this.tickLabelContainer.offsetHeight;else for(k=0;kj&&(j=this.tickLabelContainer.childNodes[k].offsetHeight);"horizontal"===this.options.orientation&&(this.sliderElem.style.marginBottom=j+"px")}for(var k=0;k=a[0]&&l<=a[1]&&this._addClass(this.ticks[k],"in-selection"):"after"===this.options.selection&&l>=a[0]?this._addClass(this.ticks[k],"in-selection"):"before"===this.options.selection&&l<=a[0]&&this._addClass(this.ticks[k],"in-selection"),this.tickLabels[k]&&(this.tickLabels[k].style[h]=i+"px","vertical"!==this.options.orientation&&void 0!==this.options.ticks_positions[k]?(this.tickLabels[k].style.position="absolute",this.tickLabels[k].style[this.stylePos]=l+"%",this.tickLabels[k].style[g]=-i/2+"px"):"vertical"===this.options.orientation&&(this.options.rtl?this.tickLabels[k].style.marginRight=this.sliderElem.offsetWidth+"px":this.tickLabels[k].style.marginLeft=this.sliderElem.offsetWidth+"px",this.tickLabelContainer.style[g]=this.sliderElem.offsetWidth/2*-1+"px"))}}var m;if(this.options.range){m=this.options.formatter(this._state.value),this._setText(this.tooltipInner,m),this.tooltip.style[this.stylePos]=(a[1]+a[0])/2+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetWidth/2+"px");var n=this.options.formatter(this._state.value[0]);this._setText(this.tooltipInner_min,n);var o=this.options.formatter(this._state.value[1]);this._setText(this.tooltipInner_max,o),this.tooltip_min.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip_min,"margin-"+this.stylePos,-this.tooltip_min.offsetHeight/2+"px"):this._css(this.tooltip_min,"margin-"+this.stylePos,-this.tooltip_min.offsetWidth/2+"px"),this.tooltip_max.style[this.stylePos]=a[1]+"%","vertical"===this.options.orientation?this._css(this.tooltip_max,"margin-"+this.stylePos,-this.tooltip_max.offsetHeight/2+"px"):this._css(this.tooltip_max,"margin-"+this.stylePos,-this.tooltip_max.offsetWidth/2+"px")}else m=this.options.formatter(this._state.value[0]),this._setText(this.tooltipInner,m),this.tooltip.style[this.stylePos]=a[0]+"%","vertical"===this.options.orientation?this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetHeight/2+"px"):this._css(this.tooltip,"margin-"+this.stylePos,-this.tooltip.offsetWidth/2+"px");if("vertical"===this.options.orientation)this.trackLow.style.top="0",this.trackLow.style.height=Math.min(a[0],a[1])+"%",this.trackSelection.style.top=Math.min(a[0],a[1])+"%",this.trackSelection.style.height=Math.abs(a[0]-a[1])+"%",this.trackHigh.style.bottom="0",this.trackHigh.style.height=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";else{"right"===this.stylePos?this.trackLow.style.right="0":this.trackLow.style.left="0",this.trackLow.style.width=Math.min(a[0],a[1])+"%","right"===this.stylePos?this.trackSelection.style.right=Math.min(a[0],a[1])+"%":this.trackSelection.style.left=Math.min(a[0],a[1])+"%",this.trackSelection.style.width=Math.abs(a[0]-a[1])+"%","right"===this.stylePos?this.trackHigh.style.left="0":this.trackHigh.style.right="0",this.trackHigh.style.width=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";var p=this.tooltip_min.getBoundingClientRect(),q=this.tooltip_max.getBoundingClientRect();"bottom"===this.options.tooltip_position?p.right>q.left?(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top="",this.tooltip_max.style.bottom="22px"):(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top=this.tooltip_min.style.top,this.tooltip_max.style.bottom=""):p.right>q.left?(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top="18px"):(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top=this.tooltip_min.style.top)}},_createHighlightRange:function(a,b){return this._isHighlightRange(a,b)?a>b?{start:b,size:a-b}:{start:a,size:b-a}:null},_isHighlightRange:function(a,b){return a>=0&&100>=a&&b>=0&&100>=b?!0:!1},_resize:function(a){this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos],this._layout()},_removeProperty:function(a,b){a.style.removeProperty?a.style.removeProperty(b):a.style.removeAttribute(b)},_mousedown:function(a){if(!this._state.enabled)return!1;this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos];var b=this._getPercentage(a);if(this.options.range){var c=Math.abs(this._state.percentage[0]-b),d=Math.abs(this._state.percentage[1]-b);this._state.dragged=d>c?0:1,this._adjustPercentageForRangeSliders(b)}else this._state.dragged=0;this._state.percentage[this._state.dragged]=b,this._layout(),this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),this.mousemove&&document.removeEventListener("mousemove",this.mousemove,!1),this.mouseup&&document.removeEventListener("mouseup",this.mouseup,!1),this.mousemove=this._mousemove.bind(this),this.mouseup=this._mouseup.bind(this),this.touchCapable&&(document.addEventListener("touchmove",this.mousemove,!1),document.addEventListener("touchend",this.mouseup,!1)),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!0;var e=this._calculateValue();return this._trigger("slideStart",e),this._setDataVal(e),this.setValue(e,!1,!0),a.returnValue=!1,this.options.focus&&this._triggerFocusOnHandle(this._state.dragged),!0},_touchstart:function(a){if(void 0===a.changedTouches)return void this._mousedown(a);var b=a.changedTouches[0];this.touchX=b.pageX,this.touchY=b.pageY},_triggerFocusOnHandle:function(a){0===a&&this.handle1.focus(),1===a&&this.handle2.focus()},_keydown:function(a,b){if(!this._state.enabled)return!1;var c;switch(b.keyCode){case 37:case 40:c=-1;break;case 39:case 38:c=1}if(c){if(this.options.natural_arrow_keys){var d="vertical"===this.options.orientation&&!this.options.reversed,e="horizontal"===this.options.orientation&&this.options.reversed;(d||e)&&(c=-c)}var f=this._state.value[a]+c*this.options.step;return this.options.range&&(f=[a?this._state.value[0]:f,a?f:this._state.value[1]]),this._trigger("slideStart",f),this._setDataVal(f),this.setValue(f,!0,!0),this._setDataVal(f),this._trigger("slideStop",f),this._layout(),this._pauseEvent(b),!1}},_pauseEvent:function(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.cancelBubble=!0,a.returnValue=!1},_mousemove:function(a){if(!this._state.enabled)return!1;var b=this._getPercentage(a);this._adjustPercentageForRangeSliders(b),this._state.percentage[this._state.dragged]=b,this._layout();var c=this._calculateValue(!0);return this.setValue(c,!0,!0),!1},_touchmove:function(a){if(void 0!==a.changedTouches){var b=a.changedTouches[0],c=b.pageX-this.touchX,d=b.pageY-this.touchY;this._state.inDrag||("vertical"===this.options.orientation&&5>=c&&c>=-5&&(d>=15||-15>=d)?this._mousedown(a):5>=d&&d>=-5&&(c>=15||-15>=c)&&this._mousedown(a))}},_adjustPercentageForRangeSliders:function(a){if(this.options.range){var b=this._getNumDigitsAfterDecimalPlace(a);b=b?b-1:0;var c=this._applyToFixedAndParseFloat(a,b);0===this._state.dragged&&this._applyToFixedAndParseFloat(this._state.percentage[1],b)c&&(this._state.percentage[1]=this._state.percentage[0],this._state.dragged=0)}},_mouseup:function(){if(!this._state.enabled)return!1;this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!1,this._state.over===!1&&this._hideTooltip();var a=this._calculateValue(!0);return this._layout(),this._setDataVal(a),this._trigger("slideStop",a),!1},_calculateValue:function(a){var b;if(this.options.range?(b=[this.options.min,this.options.max],0!==this._state.percentage[0]&&(b[0]=this._toValue(this._state.percentage[0]),b[0]=this._applyPrecision(b[0])),100!==this._state.percentage[1]&&(b[1]=this._toValue(this._state.percentage[1]),b[1]=this._applyPrecision(b[1]))):(b=this._toValue(this._state.percentage[0]),b=parseFloat(b),b=this._applyPrecision(b)),a){for(var c=[b,1/0],d=0;d