nouislider
Advanced tools
Comparing version 8.3.0 to 8.4.0
@@ -1,9 +0,8 @@ | ||
You want to help out or ask a question? Great!!! | ||
# Issues | ||
Please, only use the issue tracker for **problems, bugs and feature requests**. For help with implementing this slider, ask your question on [stackoverflow](http://stackoverflow.com/questions/tagged/nouislider). I look a questions posted there daily, and you will get you an answer much faster. | ||
Minor things that make my life easier: | ||
## Issues: | ||
If you have a support question, asking it on [stackoverflow](http://stackoverflow.com/questions/tagged/nouislider) will get you an answer much faster. | ||
## Pull requests: | ||
- Please don't commit `/distribute/*` files, I'll do that upon release. | ||
# Pull requests | ||
- Detail (in the pull request comment) what your changes do. | ||
- When applicable, include new unit tests. I **can't** and **won't** merge any untested changes. | ||
- If you are introducing a new feature, update the **documentation**. | ||
- **Do NOT** commit `/distribute/*` files, I'll do that upon release. |
@@ -1,2 +0,2 @@ | ||
/*! nouislider - 8.3.0 - 2016-02-14 17:37:19 */ | ||
/*! nouislider - 8.4.0 - 2016-04-16 16:46:07 */ | ||
@@ -64,8 +64,2 @@ (function (factory) { | ||
// Rounds a number to 7 supported decimals. | ||
function accurateNumber( number ) { | ||
var p = Math.pow(10, 7); | ||
return Number((Math.round(number*p)/p).toFixed(7)); | ||
} | ||
// Sets a class and removes it after [duration] ms. | ||
@@ -145,22 +139,27 @@ function addClassFor ( element, className, duration ) { | ||
var | ||
// Determine the events to bind. IE11 implements pointerEvents without | ||
// a prefix, which breaks compatibility with the IE10 implementation. | ||
/** @const */ | ||
actions = window.navigator.pointerEnabled ? { | ||
start: 'pointerdown', | ||
move: 'pointermove', | ||
end: 'pointerup' | ||
} : window.navigator.msPointerEnabled ? { | ||
start: 'MSPointerDown', | ||
move: 'MSPointerMove', | ||
end: 'MSPointerUp' | ||
} : { | ||
start: 'mousedown touchstart', | ||
move: 'mousemove touchmove', | ||
end: 'mouseup touchend' | ||
}, | ||
defaultCssPrefix = 'noUi-'; | ||
var defaultCssPrefix = 'noUi-'; | ||
// we provide a function to compute constants instead | ||
// of accessing window.* as soon as the module needs it | ||
// so that we do not compute anything if not needed | ||
function getActions ( ) { | ||
// Determine the events to bind. IE11 implements pointerEvents without | ||
// a prefix, which breaks compatibility with the IE10 implementation. | ||
return window.navigator.pointerEnabled ? { | ||
start: 'pointerdown', | ||
move: 'pointermove', | ||
end: 'pointerup' | ||
} : window.navigator.msPointerEnabled ? { | ||
start: 'MSPointerDown', | ||
move: 'MSPointerMove', | ||
end: 'MSPointerUp' | ||
} : { | ||
start: 'mousedown touchstart', | ||
move: 'mousemove touchmove', | ||
end: 'mouseup touchend' | ||
}; | ||
} | ||
// Value calculation | ||
@@ -406,3 +405,3 @@ | ||
return accurateNumber(fromStepping( this.xVal, this.xPct, value )); | ||
return fromStepping( this.xVal, this.xPct, value ); | ||
}; | ||
@@ -525,2 +524,11 @@ | ||
function testAnimationDuration ( parsed, entry ) { | ||
parsed.animationDuration = entry; | ||
if ( typeof entry !== 'number' ){ | ||
throw new Error("noUiSlider: 'animationDuration' option must be a number."); | ||
} | ||
} | ||
function testConnect ( parsed, entry ) { | ||
@@ -697,2 +705,3 @@ | ||
animate: true, | ||
animationDuration: 300, | ||
format: defaultFormatter | ||
@@ -709,2 +718,3 @@ }, tests; | ||
'animate': { r: false, t: testAnimate }, | ||
'animationDuration': { r: false, t: testAnimationDuration }, | ||
'range': { r: true, t: testRange }, | ||
@@ -755,6 +765,7 @@ 'orientation': { r: false, t: testOrientation }, | ||
function closure ( target, options ){ | ||
// All variables local to 'closure' are prefixed with 'scope_' | ||
var scope_Target = target, | ||
function closure ( target, options, originalOptions ){ | ||
var | ||
actions = getActions( ), | ||
// All variables local to 'closure' are prefixed with 'scope_' | ||
scope_Target = target, | ||
scope_Locations = [-1, -1], | ||
@@ -1201,2 +1212,11 @@ scope_Base, | ||
var i; | ||
// During initialization, do not fire events. | ||
for ( i = 0; i < options.handles; i++ ) { | ||
if ( scope_Locations[i] === -1 ) { | ||
return; | ||
} | ||
} | ||
if ( handleNumber !== undefined && options.handles !== 1 ) { | ||
@@ -1381,4 +1401,2 @@ handleNumber = Math.abs(handleNumber - options.dir); | ||
if ( data.handles.length === 1 ) { | ||
addClass(data.handles[0].children[0], cssClasses[15]); | ||
// Support 'disabled' handles | ||
@@ -1388,2 +1406,4 @@ if ( data.handles[0].hasAttribute('disabled') ) { | ||
} | ||
addClass(data.handles[0].children[0], cssClasses[15]); | ||
} | ||
@@ -1463,3 +1483,3 @@ | ||
handleNumber = ( location < total/2 || scope_Handles.length === 1 ) ? 0 : 1; | ||
// Check if handler is not disablet if yes set number to the next handler | ||
@@ -1477,4 +1497,4 @@ if (scope_Handles[handleNumber].hasAttribute('disabled')) { | ||
// Flag the slider as it is now in a transitional state. | ||
// Transition takes 300 ms, so re-enable the slider afterwards. | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
// Transition takes a configurable amount of ms (default 300). Re-enable the slider after that. | ||
addClassFor( scope_Target, cssClasses[14], options.animationDuration ); | ||
} | ||
@@ -1603,5 +1623,4 @@ | ||
// Limit to 0/100 for .val input, trim anything beyond 7 digits, as | ||
// JavaScript has some issues in its floating point implementation. | ||
to = limit(parseFloat(to.toFixed(7))); | ||
// Limit percentage to the 0 - 100 range | ||
to = limit(to); | ||
@@ -1685,6 +1704,9 @@ // Return false if handle can't move | ||
// Set the slider value. | ||
function valueSet ( input ) { | ||
function valueSet ( input, fireSetEvent ) { | ||
var count, values = asArray( input ), i; | ||
// Event fires by default | ||
fireSetEvent = (fireSetEvent === undefined ? true : !!fireSetEvent); | ||
// The RTL settings is implemented by reversing the front-end, | ||
@@ -1699,3 +1721,3 @@ // internal mechanisms are the same. | ||
if ( options.animate && scope_Locations[0] !== -1 ) { | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
addClassFor( scope_Target, cssClasses[14], options.animationDuration ); | ||
} | ||
@@ -1716,3 +1738,3 @@ | ||
// Fire the event only for handles that received a new value, as per #579 | ||
if ( values[i] !== null ) { | ||
if ( values[i] !== null && fireSetEvent ) { | ||
fireEvent('set', i); | ||
@@ -1802,4 +1824,4 @@ } | ||
var event = namespacedEvent.split('.')[0], | ||
namespace = namespacedEvent.substring(event.length); | ||
var event = namespacedEvent && namespacedEvent.split('.')[0], | ||
namespace = event && namespacedEvent.substring(event.length); | ||
@@ -1818,9 +1840,12 @@ Object.keys(scope_Events).forEach(function( bind ){ | ||
// Updateable: margin, limit, step, range, animate, snap | ||
function updateOptions ( optionsToUpdate ) { | ||
function updateOptions ( optionsToUpdate, fireSetEvent ) { | ||
var v = valueGet(), i, newOptions = testOptions({ | ||
// Spectrum is created using the range, snap, direction and step options. | ||
// 'snap' and 'step' can be updated, 'direction' cannot, due to event binding. | ||
// If 'snap' and 'step' are not passed, they should remain unchanged. | ||
var v = valueGet(), newOptions = testOptions({ | ||
start: [0, 0], | ||
margin: optionsToUpdate.margin, | ||
limit: optionsToUpdate.limit, | ||
step: optionsToUpdate.step, | ||
step: optionsToUpdate.step === undefined ? options.singleStep : optionsToUpdate.step, | ||
range: optionsToUpdate.range, | ||
@@ -1831,3 +1856,5 @@ animate: optionsToUpdate.animate, | ||
['margin', 'limit', 'step', 'range', 'animate'].forEach(function(name){ | ||
['margin', 'limit', 'range', 'animate'].forEach(function(name){ | ||
// Only change options that we're actually passed to update. | ||
if ( optionsToUpdate[name] !== undefined ) { | ||
@@ -1845,7 +1872,3 @@ options[name] = optionsToUpdate[name]; | ||
scope_Locations = [-1, -1]; | ||
valueSet(v); | ||
for ( i = 0; i < scope_Handles.length; i++ ) { | ||
fireEvent('update', i); | ||
} | ||
valueSet(optionsToUpdate.start || v, fireSetEvent); | ||
} | ||
@@ -1883,3 +1906,3 @@ | ||
updateOptions: updateOptions, | ||
options: options, // Issue #600 | ||
options: originalOptions, // Issue #600 | ||
target: scope_Target, // Issue #597 | ||
@@ -1906,3 +1929,3 @@ pips: pips // Issue #594 | ||
var options = testOptions( originalOptions, target ), | ||
slider = closure( target, options ); | ||
slider = closure( target, options, originalOptions ); | ||
@@ -1909,0 +1932,0 @@ // Use the public value method to set the start values. |
@@ -1,3 +0,3 @@ | ||
/*! nouislider - 8.3.0 - 2016-02-14 17:37:19 */ | ||
/*! nouislider - 8.4.0 - 2016-04-16 16:46:07 */ | ||
!function(a){"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?module.exports=a():window.noUiSlider=a()}(function(){"use strict";function a(a){return a.filter(function(a){return this[a]?!1:this[a]=!0},{})}function b(a,b){return Math.round(a/b)*b}function c(a){var b=a.getBoundingClientRect(),c=a.ownerDocument,d=c.documentElement,e=m();return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(e.x=0),{top:b.top+e.y-d.clientTop,left:b.left+e.x-d.clientLeft}}function d(a){return"number"==typeof a&&!isNaN(a)&&isFinite(a)}function e(a){var b=Math.pow(10,7);return Number((Math.round(a*b)/b).toFixed(7))}function f(a,b,c){j(a,b),setTimeout(function(){k(a,b)},c)}function g(a){return Math.max(Math.min(a,100),0)}function h(a){return Array.isArray(a)?a:[a]}function i(a){var b=a.split(".");return b.length>1?b[1].length:0}function j(a,b){a.classList?a.classList.add(b):a.className+=" "+b}function k(a,b){a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp("(^|\\b)"+b.split(" ").join("|")+"(\\b|$)","gi")," ")}function l(a,b){return a.classList?a.classList.contains(b):new RegExp("\\b"+b+"\\b").test(a.className)}function m(){var a=void 0!==window.pageXOffset,b="CSS1Compat"===(document.compatMode||""),c=a?window.pageXOffset:b?document.documentElement.scrollLeft:document.body.scrollLeft,d=a?window.pageYOffset:b?document.documentElement.scrollTop:document.body.scrollTop;return{x:c,y:d}}function n(a){a.stopPropagation()}function o(a){return function(b){return a+b}}function p(a,b){return 100/(b-a)}function q(a,b){return 100*b/(a[1]-a[0])}function r(a,b){return q(a,a[0]<0?b+Math.abs(a[0]):b-a[0])}function s(a,b){return b*(a[1]-a[0])/100+a[0]}function t(a,b){for(var c=1;a>=b[c];)c+=1;return c}function u(a,b,c){if(c>=a.slice(-1)[0])return 100;var d,e,f,g,h=t(c,a);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],f+r([d,e],c)/p(f,g)}function v(a,b,c){if(c>=100)return a.slice(-1)[0];var d,e,f,g,h=t(c,b);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],s([d,e],(c-f)*p(f,g))}function w(a,c,d,e){if(100===e)return e;var f,g,h=t(e,a);return d?(f=a[h-1],g=a[h],e-f>(g-f)/2?g:f):c[h-1]?a[h-1]+b(e-a[h-1],c[h-1]):e}function x(a,b,c){var e;if("number"==typeof b&&(b=[b]),"[object Array]"!==Object.prototype.toString.call(b))throw new Error("noUiSlider: 'range' contains invalid value.");if(e="min"===a?0:"max"===a?100:parseFloat(a),!d(e)||!d(b[0]))throw new Error("noUiSlider: 'range' value isn't numeric.");c.xPct.push(e),c.xVal.push(b[0]),e?c.xSteps.push(isNaN(b[1])?!1:b[1]):isNaN(b[1])||(c.xSteps[0]=b[1])}function y(a,b,c){return b?void(c.xSteps[a]=q([c.xVal[a],c.xVal[a+1]],b)/p(c.xPct[a],c.xPct[a+1])):!0}function z(a,b,c,d){this.xPct=[],this.xVal=[],this.xSteps=[d||!1],this.xNumSteps=[!1],this.snap=b,this.direction=c;var e,f=[];for(e in a)a.hasOwnProperty(e)&&f.push([a[e],e]);for(f.length&&"object"==typeof f[0][0]?f.sort(function(a,b){return a[0][0]-b[0][0]}):f.sort(function(a,b){return a[0]-b[0]}),e=0;e<f.length;e++)x(f[e][1],f[e][0],this);for(this.xNumSteps=this.xSteps.slice(0),e=0;e<this.xNumSteps.length;e++)y(e,this.xNumSteps[e],this)}function A(a,b){if(!d(b))throw new Error("noUiSlider: 'step' is not numeric.");a.singleStep=b}function B(a,b){if("object"!=typeof b||Array.isArray(b))throw new Error("noUiSlider: 'range' is not an object.");if(void 0===b.min||void 0===b.max)throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");if(b.min===b.max)throw new Error("noUiSlider: 'range' 'min' and 'max' cannot be equal.");a.spectrum=new z(b,a.snap,a.dir,a.singleStep)}function C(a,b){if(b=h(b),!Array.isArray(b)||!b.length||b.length>2)throw new Error("noUiSlider: 'start' option is incorrect.");a.handles=b.length,a.start=b}function D(a,b){if(a.snap=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'snap' option must be a boolean.")}function E(a,b){if(a.animate=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'animate' option must be a boolean.")}function F(a,b){if("lower"===b&&1===a.handles)a.connect=1;else if("upper"===b&&1===a.handles)a.connect=2;else if(b===!0&&2===a.handles)a.connect=3;else{if(b!==!1)throw new Error("noUiSlider: 'connect' option doesn't match handle count.");a.connect=0}}function G(a,b){switch(b){case"horizontal":a.ort=0;break;case"vertical":a.ort=1;break;default:throw new Error("noUiSlider: 'orientation' option is invalid.")}}function H(a,b){if(!d(b))throw new Error("noUiSlider: 'margin' option must be numeric.");if(0!==b&&(a.margin=a.spectrum.getMargin(b),!a.margin))throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.")}function I(a,b){if(!d(b))throw new Error("noUiSlider: 'limit' option must be numeric.");if(a.limit=a.spectrum.getMargin(b),!a.limit)throw new Error("noUiSlider: 'limit' option is only supported on linear sliders.")}function J(a,b){switch(b){case"ltr":a.dir=0;break;case"rtl":a.dir=1,a.connect=[0,2,1,3][a.connect];break;default:throw new Error("noUiSlider: 'direction' option was not recognized.")}}function K(a,b){if("string"!=typeof b)throw new Error("noUiSlider: 'behaviour' must be a string containing options.");var c=b.indexOf("tap")>=0,d=b.indexOf("drag")>=0,e=b.indexOf("fixed")>=0,f=b.indexOf("snap")>=0,g=b.indexOf("hover")>=0;if(d&&!a.connect)throw new Error("noUiSlider: 'drag' behaviour must be used with 'connect': true.");a.events={tap:c||f,drag:d,fixed:e,snap:f,hover:g}}function L(a,b){var c;if(b!==!1)if(b===!0)for(a.tooltips=[],c=0;c<a.handles;c++)a.tooltips.push(!0);else{if(a.tooltips=h(b),a.tooltips.length!==a.handles)throw new Error("noUiSlider: must pass a formatter for all handles.");a.tooltips.forEach(function(a){if("boolean"!=typeof a&&("object"!=typeof a||"function"!=typeof a.to))throw new Error("noUiSlider: 'tooltips' must be passed a formatter or 'false'.")})}}function M(a,b){if(a.format=b,"function"==typeof b.to&&"function"==typeof b.from)return!0;throw new Error("noUiSlider: 'format' requires 'to' and 'from' methods.")}function N(a,b){if(void 0!==b&&"string"!=typeof b)throw new Error("noUiSlider: 'cssPrefix' must be a string.");a.cssPrefix=b}function O(a){var b,c={margin:0,limit:0,animate:!0,format:T};b={step:{r:!1,t:A},start:{r:!0,t:C},connect:{r:!0,t:F},direction:{r:!0,t:J},snap:{r:!1,t:D},animate:{r:!1,t:E},range:{r:!0,t:B},orientation:{r:!1,t:G},margin:{r:!1,t:H},limit:{r:!1,t:I},behaviour:{r:!0,t:K},format:{r:!1,t:M},tooltips:{r:!1,t:L},cssPrefix:{r:!1,t:N}};var d={connect:!1,direction:"ltr",behaviour:"tap",orientation:"horizontal"};return Object.keys(b).forEach(function(e){if(void 0===a[e]&&void 0===d[e]){if(b[e].r)throw new Error("noUiSlider: '"+e+"' is required.");return!0}b[e].t(c,void 0===a[e]?d[e]:a[e])}),c.pips=a.pips,c.style=c.ort?"top":"left",c}function P(b,d){function e(a,b,c){var d=a+b[0],e=a+b[1];return c?(0>d&&(e+=Math.abs(d)),e>100&&(d-=e-100),[g(d),g(e)]):[d,e]}function p(a,b){a.preventDefault();var c,d,e=0===a.type.indexOf("touch"),f=0===a.type.indexOf("mouse"),g=0===a.type.indexOf("pointer"),h=a;return 0===a.type.indexOf("MSPointer")&&(g=!0),e&&(c=a.changedTouches[0].pageX,d=a.changedTouches[0].pageY),b=b||m(),(f||g)&&(c=a.clientX+b.x,d=a.clientY+b.y),h.pageOffset=b,h.points=[c,d],h.cursor=f||g,h}function q(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=["-lower","-upper"];return a&&e.reverse(),j(d,da[3]),j(d,da[3]+e[b]),j(c,da[2]),c.appendChild(d),c}function r(a,b,c){switch(a){case 1:j(b,da[7]),j(c[0],da[6]);break;case 3:j(c[1],da[6]);case 2:j(c[0],da[7]);case 0:j(b,da[6])}}function s(a,b,c){var d,e=[];for(d=0;a>d;d+=1)e.push(c.appendChild(q(b,d)));return e}function t(a,b,c){j(c,da[0]),j(c,da[8+a]),j(c,da[4+b]);var d=document.createElement("div");return j(d,da[1]),c.appendChild(d),d}function u(a,b){if(!d.tooltips[b])return!1;var c=document.createElement("div");return c.className=da[18],a.firstChild.appendChild(c)}function v(){d.dir&&d.tooltips.reverse();var a=Y.map(u);d.dir&&(a.reverse(),d.tooltips.reverse()),U("update",function(b,c,e){a[c]&&(a[c].innerHTML=d.tooltips[c]===!0?b[c]:d.tooltips[c].to(e[c]))})}function w(a,b,c){if("range"===a||"steps"===a)return aa.xVal;if("count"===a){var d,e=100/(b-1),f=0;for(b=[];(d=f++*e)<=100;)b.push(d);a="positions"}return"positions"===a?b.map(function(a){return aa.fromStepping(c?aa.getStep(a):a)}):"values"===a?c?b.map(function(a){return aa.fromStepping(aa.getStep(aa.toStepping(a)))}):b:void 0}function x(b,c,d){function e(a,b){return(a+b).toFixed(7)/1}var f=aa.direction,g={},h=aa.xVal[0],i=aa.xVal[aa.xVal.length-1],j=!1,k=!1,l=0;return aa.direction=0,d=a(d.slice().sort(function(a,b){return a-b})),d[0]!==h&&(d.unshift(h),j=!0),d[d.length-1]!==i&&(d.push(i),k=!0),d.forEach(function(a,f){var h,i,m,n,o,p,q,r,s,t,u=a,v=d[f+1];if("steps"===c&&(h=aa.xNumSteps[f]),h||(h=v-u),u!==!1&&void 0!==v)for(i=u;v>=i;i=e(i,h)){for(n=aa.toStepping(i),o=n-l,r=o/b,s=Math.round(r),t=o/s,m=1;s>=m;m+=1)p=l+m*t,g[p.toFixed(5)]=["x",0];q=d.indexOf(i)>-1?1:"steps"===c?2:0,!f&&j&&(q=0),i===v&&k||(g[n.toFixed(5)]=[i,q]),l=n}}),aa.direction=f,g}function y(a,b,c){function e(a){return["-normal","-large","-sub"][a]}function f(a,b,c){return'class="'+b+" "+b+"-"+h+" "+b+e(c[1])+'" style="'+d.style+": "+a+'%"'}function g(a,d){aa.direction&&(a=100-a),d[1]=d[1]&&b?b(d[0],d[1]):d[1],k+="<div "+f(a,da[21],d)+"></div>",d[1]&&(k+="<div "+f(a,da[22],d)+">"+c.to(d[0])+"</div>")}var h=["horizontal","vertical"][d.ort],i=document.createElement("div"),k="";return j(i,da[20]),j(i,da[20]+"-"+h),Object.keys(a).forEach(function(b){g(b,a[b])}),i.innerHTML=k,i}function z(a){var b=a.mode,c=a.density||1,d=a.filter||!1,e=a.values||!1,f=a.stepped||!1,g=w(b,e,f),h=x(c,b,g),i=a.format||{to:Math.round};return $.appendChild(y(h,d,i))}function A(){var a=X.getBoundingClientRect(),b="offset"+["Width","Height"][d.ort];return 0===d.ort?a.width||X[b]:a.height||X[b]}function B(a,b,c){void 0!==b&&1!==d.handles&&(b=Math.abs(b-d.dir)),Object.keys(ca).forEach(function(d){var e=d.split(".")[0];a===e&&ca[d].forEach(function(a){a.call(Z,h(P()),b,h(C(Array.prototype.slice.call(ba))),c||!1,_)})})}function C(a){return 1===a.length?a[0]:d.dir?a.reverse():a}function D(a,b,c,e){var f=function(b){return $.hasAttribute("disabled")?!1:l($,da[14])?!1:(b=p(b,e.pageOffset),a===R.start&&void 0!==b.buttons&&b.buttons>1?!1:e.hover&&b.buttons?!1:(b.calcPoint=b.points[d.ort],void c(b,e)))},g=[];return a.split(" ").forEach(function(a){b.addEventListener(a,f,!1),g.push([a,f])}),g}function E(a,b){if(-1===navigator.appVersion.indexOf("MSIE 9")&&0===a.buttons&&0!==b.buttonsProperty)return F(a,b);var c,d,f=b.handles||Y,g=!1,h=100*(a.calcPoint-b.start)/b.baseSize,i=f[0]===Y[0]?0:1;if(c=e(h,b.positions,f.length>1),g=L(f[0],c[i],1===f.length),f.length>1){if(g=L(f[1],c[i?0:1],!1)||g)for(d=0;d<b.handles.length;d++)B("slide",d)}else g&&B("slide",i)}function F(a,b){var c=X.querySelector("."+da[15]),d=b.handles[0]===Y[0]?0:1;null!==c&&k(c,da[15]),a.cursor&&(document.body.style.cursor="",document.body.removeEventListener("selectstart",document.body.noUiListener));var e=document.documentElement;e.noUiListeners.forEach(function(a){e.removeEventListener(a[0],a[1])}),k($,da[12]),B("set",d),B("change",d),void 0!==b.handleNumber&&B("end",b.handleNumber)}function G(a,b){"mouseout"===a.type&&"HTML"===a.target.nodeName&&null===a.relatedTarget&&F(a,b)}function H(a,b){var c=document.documentElement;if(1===b.handles.length&&(j(b.handles[0].children[0],da[15]),b.handles[0].hasAttribute("disabled")))return!1;a.preventDefault(),a.stopPropagation();var d=D(R.move,c,E,{start:a.calcPoint,baseSize:A(),pageOffset:a.pageOffset,handles:b.handles,handleNumber:b.handleNumber,buttonsProperty:a.buttons,positions:[_[0],_[Y.length-1]]}),e=D(R.end,c,F,{handles:b.handles,handleNumber:b.handleNumber}),f=D("mouseout",c,G,{handles:b.handles,handleNumber:b.handleNumber});if(c.noUiListeners=d.concat(e,f),a.cursor){document.body.style.cursor=getComputedStyle(a.target).cursor,Y.length>1&&j($,da[12]);var g=function(){return!1};document.body.noUiListener=g,document.body.addEventListener("selectstart",g,!1)}void 0!==b.handleNumber&&B("start",b.handleNumber)}function I(a){var b,e,g=a.calcPoint,h=0;return a.stopPropagation(),Y.forEach(function(a){h+=c(a)[d.style]}),b=h/2>g||1===Y.length?0:1,Y[b].hasAttribute("disabled")&&(b=b?0:1),g-=c(X)[d.style],e=100*g/A(),d.events.snap||f($,da[14],300),Y[b].hasAttribute("disabled")?!1:(L(Y[b],e),B("slide",b,!0),B("set",b,!0),B("change",b,!0),void(d.events.snap&&H(a,{handles:[Y[b]]})))}function J(a){var b=a.calcPoint-c(X)[d.style],e=aa.getStep(100*b/A()),f=aa.fromStepping(e);Object.keys(ca).forEach(function(a){"hover"===a.split(".")[0]&&ca[a].forEach(function(a){a.call(Z,f)})})}function K(a){var b,c;if(!a.fixed)for(b=0;b<Y.length;b+=1)D(R.start,Y[b].children[0],H,{handles:[Y[b]],handleNumber:b});if(a.tap&&D(R.start,X,I,{handles:Y}),a.hover)for(D(R.move,X,J,{hover:!0}),b=0;b<Y.length;b+=1)["mousemove MSPointerMove pointermove"].forEach(function(a){Y[b].children[0].addEventListener(a,n,!1)});a.drag&&(c=[X.querySelector("."+da[7])],j(c[0],da[10]),a.fixed&&c.push(Y[c[0]===Y[0]?1:0].children[0]),c.forEach(function(a){D(R.start,a,H,{handles:Y})}))}function L(a,b,c){var e=a!==Y[0]?1:0,f=_[0]+d.margin,h=_[1]-d.margin,i=_[0]+d.limit,l=_[1]-d.limit;return Y.length>1&&(b=e?Math.max(b,f):Math.min(b,h)),c!==!1&&d.limit&&Y.length>1&&(b=e?Math.min(b,i):Math.max(b,l)),b=aa.getStep(b),b=g(parseFloat(b.toFixed(7))),b===_[e]?!1:(window.requestAnimationFrame?window.requestAnimationFrame(function(){a.style[d.style]=b+"%"}):a.style[d.style]=b+"%",a.previousSibling||(k(a,da[17]),b>50&&j(a,da[17])),_[e]=b,ba[e]=aa.fromStepping(b),B("update",e),!0)}function M(a,b){var c,e,f;for(d.limit&&(a+=1),c=0;a>c;c+=1)e=c%2,f=b[e],null!==f&&f!==!1&&("number"==typeof f&&(f=String(f)),f=d.format.from(f),(f===!1||isNaN(f)||L(Y[e],aa.toStepping(f),c===3-d.dir)===!1)&&B("update",e))}function N(a){var b,c,e=h(a);for(d.dir&&d.handles>1&&e.reverse(),d.animate&&-1!==_[0]&&f($,da[14],300),b=Y.length>1?3:1,1===e.length&&(b=1),M(b,e),c=0;c<Y.length;c++)null!==e[c]&&B("set",c)}function P(){var a,b=[];for(a=0;a<d.handles;a+=1)b[a]=d.format.to(ba[a]);return C(b)}function Q(){for(da.forEach(function(a){a&&k($,a)});$.firstChild;)$.removeChild($.firstChild);delete $.noUiSlider}function T(){var a=_.map(function(a,b){var c=aa.getApplicableStep(a),d=i(String(c[2])),e=ba[b],f=100===a?null:c[2],g=Number((e-c[2]).toFixed(d)),h=0===a?null:g>=c[1]?c[2]:c[0]||!1;return[h,f]});return C(a)}function U(a,b){ca[a]=ca[a]||[],ca[a].push(b),"update"===a.split(".")[0]&&Y.forEach(function(a,b){B("update",b)})}function V(a){var b=a.split(".")[0],c=a.substring(b.length);Object.keys(ca).forEach(function(a){var d=a.split(".")[0],e=a.substring(d.length);b&&b!==d||c&&c!==e||delete ca[a]})}function W(a){var b,c=P(),e=O({start:[0,0],margin:a.margin,limit:a.limit,step:a.step,range:a.range,animate:a.animate,snap:void 0===a.snap?d.snap:a.snap});for(["margin","limit","step","range","animate"].forEach(function(b){void 0!==a[b]&&(d[b]=a[b])}),e.spectrum.direction=aa.direction,aa=e.spectrum,_=[-1,-1],N(c),b=0;b<Y.length;b++)B("update",b)}var X,Y,Z,$=b,_=[-1,-1],aa=d.spectrum,ba=[],ca={},da=["target","base","origin","handle","horizontal","vertical","background","connect","ltr","rtl","draggable","","state-drag","","state-tap","active","","stacking","tooltip","","pips","marker","value"].map(o(d.cssPrefix||S));if($.noUiSlider)throw new Error("Slider was already initialized.");return X=t(d.dir,d.ort,$),Y=s(d.handles,d.dir,X),r(d.connect,$,Y),d.pips&&z(d.pips),d.tooltips&&v(),Z={destroy:Q,steps:T,on:U,off:V,get:P,set:N,updateOptions:W,options:d,target:$,pips:z},K(d.events),Z}function Q(a,b){if(!a.nodeName)throw new Error("noUiSlider.create requires a single element.");var c=O(b,a),d=P(a,c);return d.set(c.start),a.noUiSlider=d,d}var R=window.navigator.pointerEnabled?{start:"pointerdown",move:"pointermove",end:"pointerup"}:window.navigator.msPointerEnabled?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:{start:"mousedown touchstart",move:"mousemove touchmove",end:"mouseup touchend"},S="noUi-";z.prototype.getMargin=function(a){return 2===this.xPct.length?q(this.xVal,a):!1},z.prototype.toStepping=function(a){return a=u(this.xVal,this.xPct,a),this.direction&&(a=100-a),a},z.prototype.fromStepping=function(a){return this.direction&&(a=100-a),e(v(this.xVal,this.xPct,a))},z.prototype.getStep=function(a){return this.direction&&(a=100-a),a=w(this.xPct,this.xSteps,this.snap,a),this.direction&&(a=100-a),a},z.prototype.getApplicableStep=function(a){var b=t(a,this.xPct),c=100===a?2:1;return[this.xNumSteps[b-2],this.xVal[b-c],this.xNumSteps[b-c]]},z.prototype.convert=function(a){return this.getStep(this.toStepping(a))};var T={to:function(a){return void 0!==a&&a.toFixed(2)},from:Number};return{create:Q}}); | ||
!function(a){"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?module.exports=a():window.noUiSlider=a()}(function(){"use strict";function a(a){return a.filter(function(a){return this[a]?!1:this[a]=!0},{})}function b(a,b){return Math.round(a/b)*b}function c(a){var b=a.getBoundingClientRect(),c=a.ownerDocument,d=c.documentElement,e=l();return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(e.x=0),{top:b.top+e.y-d.clientTop,left:b.left+e.x-d.clientLeft}}function d(a){return"number"==typeof a&&!isNaN(a)&&isFinite(a)}function e(a,b,c){i(a,b),setTimeout(function(){j(a,b)},c)}function f(a){return Math.max(Math.min(a,100),0)}function g(a){return Array.isArray(a)?a:[a]}function h(a){var b=a.split(".");return b.length>1?b[1].length:0}function i(a,b){a.classList?a.classList.add(b):a.className+=" "+b}function j(a,b){a.classList?a.classList.remove(b):a.className=a.className.replace(new RegExp("(^|\\b)"+b.split(" ").join("|")+"(\\b|$)","gi")," ")}function k(a,b){return a.classList?a.classList.contains(b):new RegExp("\\b"+b+"\\b").test(a.className)}function l(){var a=void 0!==window.pageXOffset,b="CSS1Compat"===(document.compatMode||""),c=a?window.pageXOffset:b?document.documentElement.scrollLeft:document.body.scrollLeft,d=a?window.pageYOffset:b?document.documentElement.scrollTop:document.body.scrollTop;return{x:c,y:d}}function m(a){a.stopPropagation()}function n(a){return function(b){return a+b}}function o(){return window.navigator.pointerEnabled?{start:"pointerdown",move:"pointermove",end:"pointerup"}:window.navigator.msPointerEnabled?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:{start:"mousedown touchstart",move:"mousemove touchmove",end:"mouseup touchend"}}function p(a,b){return 100/(b-a)}function q(a,b){return 100*b/(a[1]-a[0])}function r(a,b){return q(a,a[0]<0?b+Math.abs(a[0]):b-a[0])}function s(a,b){return b*(a[1]-a[0])/100+a[0]}function t(a,b){for(var c=1;a>=b[c];)c+=1;return c}function u(a,b,c){if(c>=a.slice(-1)[0])return 100;var d,e,f,g,h=t(c,a);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],f+r([d,e],c)/p(f,g)}function v(a,b,c){if(c>=100)return a.slice(-1)[0];var d,e,f,g,h=t(c,b);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],s([d,e],(c-f)*p(f,g))}function w(a,c,d,e){if(100===e)return e;var f,g,h=t(e,a);return d?(f=a[h-1],g=a[h],e-f>(g-f)/2?g:f):c[h-1]?a[h-1]+b(e-a[h-1],c[h-1]):e}function x(a,b,c){var e;if("number"==typeof b&&(b=[b]),"[object Array]"!==Object.prototype.toString.call(b))throw new Error("noUiSlider: 'range' contains invalid value.");if(e="min"===a?0:"max"===a?100:parseFloat(a),!d(e)||!d(b[0]))throw new Error("noUiSlider: 'range' value isn't numeric.");c.xPct.push(e),c.xVal.push(b[0]),e?c.xSteps.push(isNaN(b[1])?!1:b[1]):isNaN(b[1])||(c.xSteps[0]=b[1])}function y(a,b,c){return b?void(c.xSteps[a]=q([c.xVal[a],c.xVal[a+1]],b)/p(c.xPct[a],c.xPct[a+1])):!0}function z(a,b,c,d){this.xPct=[],this.xVal=[],this.xSteps=[d||!1],this.xNumSteps=[!1],this.snap=b,this.direction=c;var e,f=[];for(e in a)a.hasOwnProperty(e)&&f.push([a[e],e]);for(f.length&&"object"==typeof f[0][0]?f.sort(function(a,b){return a[0][0]-b[0][0]}):f.sort(function(a,b){return a[0]-b[0]}),e=0;e<f.length;e++)x(f[e][1],f[e][0],this);for(this.xNumSteps=this.xSteps.slice(0),e=0;e<this.xNumSteps.length;e++)y(e,this.xNumSteps[e],this)}function A(a,b){if(!d(b))throw new Error("noUiSlider: 'step' is not numeric.");a.singleStep=b}function B(a,b){if("object"!=typeof b||Array.isArray(b))throw new Error("noUiSlider: 'range' is not an object.");if(void 0===b.min||void 0===b.max)throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");if(b.min===b.max)throw new Error("noUiSlider: 'range' 'min' and 'max' cannot be equal.");a.spectrum=new z(b,a.snap,a.dir,a.singleStep)}function C(a,b){if(b=g(b),!Array.isArray(b)||!b.length||b.length>2)throw new Error("noUiSlider: 'start' option is incorrect.");a.handles=b.length,a.start=b}function D(a,b){if(a.snap=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'snap' option must be a boolean.")}function E(a,b){if(a.animate=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'animate' option must be a boolean.")}function F(a,b){if(a.animationDuration=b,"number"!=typeof b)throw new Error("noUiSlider: 'animationDuration' option must be a number.")}function G(a,b){if("lower"===b&&1===a.handles)a.connect=1;else if("upper"===b&&1===a.handles)a.connect=2;else if(b===!0&&2===a.handles)a.connect=3;else{if(b!==!1)throw new Error("noUiSlider: 'connect' option doesn't match handle count.");a.connect=0}}function H(a,b){switch(b){case"horizontal":a.ort=0;break;case"vertical":a.ort=1;break;default:throw new Error("noUiSlider: 'orientation' option is invalid.")}}function I(a,b){if(!d(b))throw new Error("noUiSlider: 'margin' option must be numeric.");if(0!==b&&(a.margin=a.spectrum.getMargin(b),!a.margin))throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.")}function J(a,b){if(!d(b))throw new Error("noUiSlider: 'limit' option must be numeric.");if(a.limit=a.spectrum.getMargin(b),!a.limit)throw new Error("noUiSlider: 'limit' option is only supported on linear sliders.")}function K(a,b){switch(b){case"ltr":a.dir=0;break;case"rtl":a.dir=1,a.connect=[0,2,1,3][a.connect];break;default:throw new Error("noUiSlider: 'direction' option was not recognized.")}}function L(a,b){if("string"!=typeof b)throw new Error("noUiSlider: 'behaviour' must be a string containing options.");var c=b.indexOf("tap")>=0,d=b.indexOf("drag")>=0,e=b.indexOf("fixed")>=0,f=b.indexOf("snap")>=0,g=b.indexOf("hover")>=0;if(d&&!a.connect)throw new Error("noUiSlider: 'drag' behaviour must be used with 'connect': true.");a.events={tap:c||f,drag:d,fixed:e,snap:f,hover:g}}function M(a,b){var c;if(b!==!1)if(b===!0)for(a.tooltips=[],c=0;c<a.handles;c++)a.tooltips.push(!0);else{if(a.tooltips=g(b),a.tooltips.length!==a.handles)throw new Error("noUiSlider: must pass a formatter for all handles.");a.tooltips.forEach(function(a){if("boolean"!=typeof a&&("object"!=typeof a||"function"!=typeof a.to))throw new Error("noUiSlider: 'tooltips' must be passed a formatter or 'false'.")})}}function N(a,b){if(a.format=b,"function"==typeof b.to&&"function"==typeof b.from)return!0;throw new Error("noUiSlider: 'format' requires 'to' and 'from' methods.")}function O(a,b){if(void 0!==b&&"string"!=typeof b)throw new Error("noUiSlider: 'cssPrefix' must be a string.");a.cssPrefix=b}function P(a){var b,c={margin:0,limit:0,animate:!0,animationDuration:300,format:T};b={step:{r:!1,t:A},start:{r:!0,t:C},connect:{r:!0,t:G},direction:{r:!0,t:K},snap:{r:!1,t:D},animate:{r:!1,t:E},animationDuration:{r:!1,t:F},range:{r:!0,t:B},orientation:{r:!1,t:H},margin:{r:!1,t:I},limit:{r:!1,t:J},behaviour:{r:!0,t:L},format:{r:!1,t:N},tooltips:{r:!1,t:M},cssPrefix:{r:!1,t:O}};var d={connect:!1,direction:"ltr",behaviour:"tap",orientation:"horizontal"};return Object.keys(b).forEach(function(e){if(void 0===a[e]&&void 0===d[e]){if(b[e].r)throw new Error("noUiSlider: '"+e+"' is required.");return!0}b[e].t(c,void 0===a[e]?d[e]:a[e])}),c.pips=a.pips,c.style=c.ort?"top":"left",c}function Q(b,d,p){function q(a,b,c){var d=a+b[0],e=a+b[1];return c?(0>d&&(e+=Math.abs(d)),e>100&&(d-=e-100),[f(d),f(e)]):[d,e]}function r(a,b){a.preventDefault();var c,d,e=0===a.type.indexOf("touch"),f=0===a.type.indexOf("mouse"),g=0===a.type.indexOf("pointer"),h=a;return 0===a.type.indexOf("MSPointer")&&(g=!0),e&&(c=a.changedTouches[0].pageX,d=a.changedTouches[0].pageY),b=b||l(),(f||g)&&(c=a.clientX+b.x,d=a.clientY+b.y),h.pageOffset=b,h.points=[c,d],h.cursor=f||g,h}function s(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=["-lower","-upper"];return a&&e.reverse(),i(d,fa[3]),i(d,fa[3]+e[b]),i(c,fa[2]),c.appendChild(d),c}function t(a,b,c){switch(a){case 1:i(b,fa[7]),i(c[0],fa[6]);break;case 3:i(c[1],fa[6]);case 2:i(c[0],fa[7]);case 0:i(b,fa[6])}}function u(a,b,c){var d,e=[];for(d=0;a>d;d+=1)e.push(c.appendChild(s(b,d)));return e}function v(a,b,c){i(c,fa[0]),i(c,fa[8+a]),i(c,fa[4+b]);var d=document.createElement("div");return i(d,fa[1]),c.appendChild(d),d}function w(a,b){if(!d.tooltips[b])return!1;var c=document.createElement("div");return c.className=fa[18],a.firstChild.appendChild(c)}function x(){d.dir&&d.tooltips.reverse();var a=Z.map(w);d.dir&&(a.reverse(),d.tooltips.reverse()),V("update",function(b,c,e){a[c]&&(a[c].innerHTML=d.tooltips[c]===!0?b[c]:d.tooltips[c].to(e[c]))})}function y(a,b,c){if("range"===a||"steps"===a)return ca.xVal;if("count"===a){var d,e=100/(b-1),f=0;for(b=[];(d=f++*e)<=100;)b.push(d);a="positions"}return"positions"===a?b.map(function(a){return ca.fromStepping(c?ca.getStep(a):a)}):"values"===a?c?b.map(function(a){return ca.fromStepping(ca.getStep(ca.toStepping(a)))}):b:void 0}function z(b,c,d){function e(a,b){return(a+b).toFixed(7)/1}var f=ca.direction,g={},h=ca.xVal[0],i=ca.xVal[ca.xVal.length-1],j=!1,k=!1,l=0;return ca.direction=0,d=a(d.slice().sort(function(a,b){return a-b})),d[0]!==h&&(d.unshift(h),j=!0),d[d.length-1]!==i&&(d.push(i),k=!0),d.forEach(function(a,f){var h,i,m,n,o,p,q,r,s,t,u=a,v=d[f+1];if("steps"===c&&(h=ca.xNumSteps[f]),h||(h=v-u),u!==!1&&void 0!==v)for(i=u;v>=i;i=e(i,h)){for(n=ca.toStepping(i),o=n-l,r=o/b,s=Math.round(r),t=o/s,m=1;s>=m;m+=1)p=l+m*t,g[p.toFixed(5)]=["x",0];q=d.indexOf(i)>-1?1:"steps"===c?2:0,!f&&j&&(q=0),i===v&&k||(g[n.toFixed(5)]=[i,q]),l=n}}),ca.direction=f,g}function A(a,b,c){function e(a){return["-normal","-large","-sub"][a]}function f(a,b,c){return'class="'+b+" "+b+"-"+h+" "+b+e(c[1])+'" style="'+d.style+": "+a+'%"'}function g(a,d){ca.direction&&(a=100-a),d[1]=d[1]&&b?b(d[0],d[1]):d[1],k+="<div "+f(a,fa[21],d)+"></div>",d[1]&&(k+="<div "+f(a,fa[22],d)+">"+c.to(d[0])+"</div>")}var h=["horizontal","vertical"][d.ort],j=document.createElement("div"),k="";return i(j,fa[20]),i(j,fa[20]+"-"+h),Object.keys(a).forEach(function(b){g(b,a[b])}),j.innerHTML=k,j}function B(a){var b=a.mode,c=a.density||1,d=a.filter||!1,e=a.values||!1,f=a.stepped||!1,g=y(b,e,f),h=z(c,b,g),i=a.format||{to:Math.round};return aa.appendChild(A(h,d,i))}function C(){var a=Y.getBoundingClientRect(),b="offset"+["Width","Height"][d.ort];return 0===d.ort?a.width||Y[b]:a.height||Y[b]}function D(a,b,c){var e;for(e=0;e<d.handles;e++)if(-1===ba[e])return;void 0!==b&&1!==d.handles&&(b=Math.abs(b-d.dir)),Object.keys(ea).forEach(function(d){var e=d.split(".")[0];a===e&&ea[d].forEach(function(a){a.call($,g(R()),b,g(E(Array.prototype.slice.call(da))),c||!1,ba)})})}function E(a){return 1===a.length?a[0]:d.dir?a.reverse():a}function F(a,b,c,e){var f=function(b){return aa.hasAttribute("disabled")?!1:k(aa,fa[14])?!1:(b=r(b,e.pageOffset),a===_.start&&void 0!==b.buttons&&b.buttons>1?!1:e.hover&&b.buttons?!1:(b.calcPoint=b.points[d.ort],void c(b,e)))},g=[];return a.split(" ").forEach(function(a){b.addEventListener(a,f,!1),g.push([a,f])}),g}function G(a,b){if(-1===navigator.appVersion.indexOf("MSIE 9")&&0===a.buttons&&0!==b.buttonsProperty)return H(a,b);var c,d,e=b.handles||Z,f=!1,g=100*(a.calcPoint-b.start)/b.baseSize,h=e[0]===Z[0]?0:1;if(c=q(g,b.positions,e.length>1),f=N(e[0],c[h],1===e.length),e.length>1){if(f=N(e[1],c[h?0:1],!1)||f)for(d=0;d<b.handles.length;d++)D("slide",d)}else f&&D("slide",h)}function H(a,b){var c=Y.querySelector("."+fa[15]),d=b.handles[0]===Z[0]?0:1;null!==c&&j(c,fa[15]),a.cursor&&(document.body.style.cursor="",document.body.removeEventListener("selectstart",document.body.noUiListener));var e=document.documentElement;e.noUiListeners.forEach(function(a){e.removeEventListener(a[0],a[1])}),j(aa,fa[12]),D("set",d),D("change",d),void 0!==b.handleNumber&&D("end",b.handleNumber)}function I(a,b){"mouseout"===a.type&&"HTML"===a.target.nodeName&&null===a.relatedTarget&&H(a,b)}function J(a,b){var c=document.documentElement;if(1===b.handles.length){if(b.handles[0].hasAttribute("disabled"))return!1;i(b.handles[0].children[0],fa[15])}a.preventDefault(),a.stopPropagation();var d=F(_.move,c,G,{start:a.calcPoint,baseSize:C(),pageOffset:a.pageOffset,handles:b.handles,handleNumber:b.handleNumber,buttonsProperty:a.buttons,positions:[ba[0],ba[Z.length-1]]}),e=F(_.end,c,H,{handles:b.handles,handleNumber:b.handleNumber}),f=F("mouseout",c,I,{handles:b.handles,handleNumber:b.handleNumber});if(c.noUiListeners=d.concat(e,f),a.cursor){document.body.style.cursor=getComputedStyle(a.target).cursor,Z.length>1&&i(aa,fa[12]);var g=function(){return!1};document.body.noUiListener=g,document.body.addEventListener("selectstart",g,!1)}void 0!==b.handleNumber&&D("start",b.handleNumber)}function K(a){var b,f,g=a.calcPoint,h=0;return a.stopPropagation(),Z.forEach(function(a){h+=c(a)[d.style]}),b=h/2>g||1===Z.length?0:1,Z[b].hasAttribute("disabled")&&(b=b?0:1),g-=c(Y)[d.style],f=100*g/C(),d.events.snap||e(aa,fa[14],d.animationDuration),Z[b].hasAttribute("disabled")?!1:(N(Z[b],f),D("slide",b,!0),D("set",b,!0),D("change",b,!0),void(d.events.snap&&J(a,{handles:[Z[b]]})))}function L(a){var b=a.calcPoint-c(Y)[d.style],e=ca.getStep(100*b/C()),f=ca.fromStepping(e);Object.keys(ea).forEach(function(a){"hover"===a.split(".")[0]&&ea[a].forEach(function(a){a.call($,f)})})}function M(a){var b,c;if(!a.fixed)for(b=0;b<Z.length;b+=1)F(_.start,Z[b].children[0],J,{handles:[Z[b]],handleNumber:b});if(a.tap&&F(_.start,Y,K,{handles:Z}),a.hover)for(F(_.move,Y,L,{hover:!0}),b=0;b<Z.length;b+=1)["mousemove MSPointerMove pointermove"].forEach(function(a){Z[b].children[0].addEventListener(a,m,!1)});a.drag&&(c=[Y.querySelector("."+fa[7])],i(c[0],fa[10]),a.fixed&&c.push(Z[c[0]===Z[0]?1:0].children[0]),c.forEach(function(a){F(_.start,a,J,{handles:Z})}))}function N(a,b,c){var e=a!==Z[0]?1:0,g=ba[0]+d.margin,h=ba[1]-d.margin,k=ba[0]+d.limit,l=ba[1]-d.limit;return Z.length>1&&(b=e?Math.max(b,g):Math.min(b,h)),c!==!1&&d.limit&&Z.length>1&&(b=e?Math.min(b,k):Math.max(b,l)),b=ca.getStep(b),b=f(b),b===ba[e]?!1:(window.requestAnimationFrame?window.requestAnimationFrame(function(){a.style[d.style]=b+"%"}):a.style[d.style]=b+"%",a.previousSibling||(j(a,fa[17]),b>50&&i(a,fa[17])),ba[e]=b,da[e]=ca.fromStepping(b),D("update",e),!0)}function O(a,b){var c,e,f;for(d.limit&&(a+=1),c=0;a>c;c+=1)e=c%2,f=b[e],null!==f&&f!==!1&&("number"==typeof f&&(f=String(f)),f=d.format.from(f),(f===!1||isNaN(f)||N(Z[e],ca.toStepping(f),c===3-d.dir)===!1)&&D("update",e))}function Q(a,b){var c,f,h=g(a);for(b=void 0===b?!0:!!b,d.dir&&d.handles>1&&h.reverse(),d.animate&&-1!==ba[0]&&e(aa,fa[14],d.animationDuration),c=Z.length>1?3:1,1===h.length&&(c=1),O(c,h),f=0;f<Z.length;f++)null!==h[f]&&b&&D("set",f)}function R(){var a,b=[];for(a=0;a<d.handles;a+=1)b[a]=d.format.to(da[a]);return E(b)}function T(){for(fa.forEach(function(a){a&&j(aa,a)});aa.firstChild;)aa.removeChild(aa.firstChild);delete aa.noUiSlider}function U(){var a=ba.map(function(a,b){var c=ca.getApplicableStep(a),d=h(String(c[2])),e=da[b],f=100===a?null:c[2],g=Number((e-c[2]).toFixed(d)),i=0===a?null:g>=c[1]?c[2]:c[0]||!1;return[i,f]});return E(a)}function V(a,b){ea[a]=ea[a]||[],ea[a].push(b),"update"===a.split(".")[0]&&Z.forEach(function(a,b){D("update",b)})}function W(a){var b=a&&a.split(".")[0],c=b&&a.substring(b.length);Object.keys(ea).forEach(function(a){var d=a.split(".")[0],e=a.substring(d.length);b&&b!==d||c&&c!==e||delete ea[a]})}function X(a,b){var c=R(),e=P({start:[0,0],margin:a.margin,limit:a.limit,step:void 0===a.step?d.singleStep:a.step,range:a.range,animate:a.animate,snap:void 0===a.snap?d.snap:a.snap});["margin","limit","range","animate"].forEach(function(b){void 0!==a[b]&&(d[b]=a[b])}),e.spectrum.direction=ca.direction,ca=e.spectrum,ba=[-1,-1],Q(a.start||c,b)}var Y,Z,$,_=o(),aa=b,ba=[-1,-1],ca=d.spectrum,da=[],ea={},fa=["target","base","origin","handle","horizontal","vertical","background","connect","ltr","rtl","draggable","","state-drag","","state-tap","active","","stacking","tooltip","","pips","marker","value"].map(n(d.cssPrefix||S));if(aa.noUiSlider)throw new Error("Slider was already initialized.");return Y=v(d.dir,d.ort,aa),Z=u(d.handles,d.dir,Y),t(d.connect,aa,Z),d.pips&&B(d.pips),d.tooltips&&x(),$={destroy:T,steps:U,on:V,off:W,get:R,set:Q,updateOptions:X,options:p,target:aa,pips:B},M(d.events),$}function R(a,b){if(!a.nodeName)throw new Error("noUiSlider.create requires a single element.");var c=P(b,a),d=Q(a,c,b);return d.set(c.start),a.noUiSlider=d,d}var S="noUi-";z.prototype.getMargin=function(a){return 2===this.xPct.length?q(this.xVal,a):!1},z.prototype.toStepping=function(a){return a=u(this.xVal,this.xPct,a),this.direction&&(a=100-a),a},z.prototype.fromStepping=function(a){return this.direction&&(a=100-a),v(this.xVal,this.xPct,a)},z.prototype.getStep=function(a){return this.direction&&(a=100-a),a=w(this.xPct,this.xSteps,this.snap,a),this.direction&&(a=100-a),a},z.prototype.getApplicableStep=function(a){var b=t(a,this.xPct),c=100===a?2:1;return[this.xNumSteps[b-2],this.xVal[b-c],this.xNumSteps[b-c]]},z.prototype.convert=function(a){return this.getStep(this.toStepping(a))};var T={to:function(a){return void 0!==a&&a.toFixed(2)},from:Number};return{create:R}}); |
@@ -33,4 +33,4 @@ module.exports = function(grunt) { | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
concat: { | ||
@@ -45,3 +45,3 @@ options: { | ||
} | ||
}, | ||
}, | ||
cssmin: { | ||
@@ -90,6 +90,6 @@ all: { | ||
} | ||
}); | ||
}); | ||
// https://github.com/gruntjs/grunt-contrib-concat | ||
grunt.loadNpmTasks('grunt-contrib-concat'); | ||
grunt.loadNpmTasks('grunt-contrib-concat'); | ||
@@ -96,0 +96,0 @@ // https://github.com/gruntjs/grunt-contrib-uglify |
{ | ||
"name": "nouislider", | ||
"version": "8.3.0", | ||
"version": "8.4.0", | ||
"main": "distribute/nouislider", | ||
@@ -5,0 +5,0 @@ "style": "distribute/nouislider.min.css", |
@@ -19,3 +19,12 @@ # noUiSlider | ||
--------- | ||
### 8.3.0 (latest) | ||
### 8.4.0 (latest) | ||
- Fix: don't assume `window` exists. #503, #533, #617 and #628 | ||
- Fix: `:focus` style applied to wrong element. #631 | ||
- Fix: `step` option is lost on updating. #619 | ||
- Fix: exposed `options` should be the original options, not the parsed set. #607 | ||
- Added: handle animation time configurable. #629 | ||
- Added: slider values can be updated without firing `set`. #602 | ||
- Change: internal value calculations no longer limited to 7 decimals. #614 | ||
### 8.3.0 | ||
- Expose several internal features, including `options` and `pips`. | ||
@@ -22,0 +31,0 @@ - Add a fifth argument to all events, containing the handle offsets. |
var | ||
// Determine the events to bind. IE11 implements pointerEvents without | ||
// a prefix, which breaks compatibility with the IE10 implementation. | ||
/** @const */ | ||
actions = window.navigator.pointerEnabled ? { | ||
start: 'pointerdown', | ||
move: 'pointermove', | ||
end: 'pointerup' | ||
} : window.navigator.msPointerEnabled ? { | ||
start: 'MSPointerDown', | ||
move: 'MSPointerMove', | ||
end: 'MSPointerUp' | ||
} : { | ||
start: 'mousedown touchstart', | ||
move: 'mousemove touchmove', | ||
end: 'mouseup touchend' | ||
}, | ||
defaultCssPrefix = 'noUi-'; | ||
var defaultCssPrefix = 'noUi-'; | ||
// we provide a function to compute constants instead | ||
// of accessing window.* as soon as the module needs it | ||
// so that we do not compute anything if not needed | ||
function getActions ( ) { | ||
// Determine the events to bind. IE11 implements pointerEvents without | ||
// a prefix, which breaks compatibility with the IE10 implementation. | ||
return window.navigator.pointerEnabled ? { | ||
start: 'pointerdown', | ||
move: 'pointermove', | ||
end: 'pointerup' | ||
} : window.navigator.msPointerEnabled ? { | ||
start: 'MSPointerDown', | ||
move: 'MSPointerMove', | ||
end: 'MSPointerUp' | ||
} : { | ||
start: 'mousedown touchstart', | ||
move: 'mousemove touchmove', | ||
end: 'mouseup touchend' | ||
}; | ||
} |
@@ -40,8 +40,2 @@ | ||
// Rounds a number to 7 supported decimals. | ||
function accurateNumber( number ) { | ||
var p = Math.pow(10, 7); | ||
return Number((Math.round(number*p)/p).toFixed(7)); | ||
} | ||
// Sets a class and removes it after [duration] ms. | ||
@@ -48,0 +42,0 @@ function addClassFor ( element, className, duration ) { |
@@ -11,3 +11,3 @@ | ||
var options = testOptions( originalOptions, target ), | ||
slider = closure( target, options ); | ||
slider = closure( target, options, originalOptions ); | ||
@@ -14,0 +14,0 @@ // Use the public value method to set the start values. |
@@ -87,2 +87,11 @@ /* Every input option is tested and parsed. This'll prevent | ||
function testAnimationDuration ( parsed, entry ) { | ||
parsed.animationDuration = entry; | ||
if ( typeof entry !== 'number' ){ | ||
throw new Error("noUiSlider: 'animationDuration' option must be a number."); | ||
} | ||
} | ||
function testConnect ( parsed, entry ) { | ||
@@ -259,2 +268,3 @@ | ||
animate: true, | ||
animationDuration: 300, | ||
format: defaultFormatter | ||
@@ -271,2 +281,3 @@ }, tests; | ||
'animate': { r: false, t: testAnimate }, | ||
'animationDuration': { r: false, t: testAnimationDuration }, | ||
'range': { r: true, t: testRange }, | ||
@@ -273,0 +284,0 @@ 'orientation': { r: false, t: testOrientation }, |
@@ -242,3 +242,3 @@ | ||
return accurateNumber(fromStepping( this.xVal, this.xPct, value )); | ||
return fromStepping( this.xVal, this.xPct, value ); | ||
}; | ||
@@ -245,0 +245,0 @@ |
@@ -135,4 +135,2 @@ | ||
if ( data.handles.length === 1 ) { | ||
addClass(data.handles[0].children[0], cssClasses[15]); | ||
// Support 'disabled' handles | ||
@@ -142,2 +140,4 @@ if ( data.handles[0].hasAttribute('disabled') ) { | ||
} | ||
addClass(data.handles[0].children[0], cssClasses[15]); | ||
} | ||
@@ -217,3 +217,3 @@ | ||
handleNumber = ( location < total/2 || scope_Handles.length === 1 ) ? 0 : 1; | ||
// Check if handler is not disablet if yes set number to the next handler | ||
@@ -231,4 +231,4 @@ if (scope_Handles[handleNumber].hasAttribute('disabled')) { | ||
// Flag the slider as it is now in a transitional state. | ||
// Transition takes 300 ms, so re-enable the slider afterwards. | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
// Transition takes a configurable amount of ms (default 300). Re-enable the slider after that. | ||
addClassFor( scope_Target, cssClasses[14], options.animationDuration ); | ||
} | ||
@@ -235,0 +235,0 @@ |
@@ -11,2 +11,11 @@ | ||
var i; | ||
// During initialization, do not fire events. | ||
for ( i = 0; i < options.handles; i++ ) { | ||
if ( scope_Locations[i] === -1 ) { | ||
return; | ||
} | ||
} | ||
if ( handleNumber !== undefined && options.handles !== 1 ) { | ||
@@ -13,0 +22,0 @@ handleNumber = Math.abs(handleNumber - options.dir); |
function closure ( target, options ){ | ||
// All variables local to 'closure' are prefixed with 'scope_' | ||
var scope_Target = target, | ||
function closure ( target, options, originalOptions ){ | ||
var | ||
actions = getActions( ), | ||
// All variables local to 'closure' are prefixed with 'scope_' | ||
scope_Target = target, | ||
scope_Locations = [-1, -1], | ||
@@ -7,0 +8,0 @@ scope_Base, |
@@ -29,5 +29,4 @@ | ||
// Limit to 0/100 for .val input, trim anything beyond 7 digits, as | ||
// JavaScript has some issues in its floating point implementation. | ||
to = limit(parseFloat(to.toFixed(7))); | ||
// Limit percentage to the 0 - 100 range | ||
to = limit(to); | ||
@@ -111,6 +110,9 @@ // Return false if handle can't move | ||
// Set the slider value. | ||
function valueSet ( input ) { | ||
function valueSet ( input, fireSetEvent ) { | ||
var count, values = asArray( input ), i; | ||
// Event fires by default | ||
fireSetEvent = (fireSetEvent === undefined ? true : !!fireSetEvent); | ||
// The RTL settings is implemented by reversing the front-end, | ||
@@ -125,3 +127,3 @@ // internal mechanisms are the same. | ||
if ( options.animate && scope_Locations[0] !== -1 ) { | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
addClassFor( scope_Target, cssClasses[14], options.animationDuration ); | ||
} | ||
@@ -142,3 +144,3 @@ | ||
// Fire the event only for handles that received a new value, as per #579 | ||
if ( values[i] !== null ) { | ||
if ( values[i] !== null && fireSetEvent ) { | ||
fireEvent('set', i); | ||
@@ -228,4 +230,4 @@ } | ||
var event = namespacedEvent.split('.')[0], | ||
namespace = namespacedEvent.substring(event.length); | ||
var event = namespacedEvent && namespacedEvent.split('.')[0], | ||
namespace = event && namespacedEvent.substring(event.length); | ||
@@ -244,9 +246,12 @@ Object.keys(scope_Events).forEach(function( bind ){ | ||
// Updateable: margin, limit, step, range, animate, snap | ||
function updateOptions ( optionsToUpdate ) { | ||
function updateOptions ( optionsToUpdate, fireSetEvent ) { | ||
var v = valueGet(), i, newOptions = testOptions({ | ||
// Spectrum is created using the range, snap, direction and step options. | ||
// 'snap' and 'step' can be updated, 'direction' cannot, due to event binding. | ||
// If 'snap' and 'step' are not passed, they should remain unchanged. | ||
var v = valueGet(), newOptions = testOptions({ | ||
start: [0, 0], | ||
margin: optionsToUpdate.margin, | ||
limit: optionsToUpdate.limit, | ||
step: optionsToUpdate.step, | ||
step: optionsToUpdate.step === undefined ? options.singleStep : optionsToUpdate.step, | ||
range: optionsToUpdate.range, | ||
@@ -257,3 +262,5 @@ animate: optionsToUpdate.animate, | ||
['margin', 'limit', 'step', 'range', 'animate'].forEach(function(name){ | ||
['margin', 'limit', 'range', 'animate'].forEach(function(name){ | ||
// Only change options that we're actually passed to update. | ||
if ( optionsToUpdate[name] !== undefined ) { | ||
@@ -271,7 +278,3 @@ options[name] = optionsToUpdate[name]; | ||
scope_Locations = [-1, -1]; | ||
valueSet(v); | ||
for ( i = 0; i < scope_Handles.length; i++ ) { | ||
fireEvent('update', i); | ||
} | ||
valueSet(optionsToUpdate.start || v, fireSetEvent); | ||
} | ||
@@ -309,3 +312,3 @@ | ||
updateOptions: updateOptions, | ||
options: options, // Issue #600 | ||
options: originalOptions, // Issue #600 | ||
target: scope_Target, // Issue #597 | ||
@@ -312,0 +315,0 @@ pips: pips // Issue #594 |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169813
4067
111