nouislider
Advanced tools
Comparing version 8.0.2 to 8.1.0
@@ -0,0 +0,0 @@ { |
@@ -1,6 +0,3 @@ | ||
/*! nouislider - 8.0.2 - 2015-07-06 13:22:09 */ | ||
/*! nouislider - 8.1.0 - 2015-10-25 16:05:43 */ | ||
/*jslint browser: true */ | ||
/*jslint white: true */ | ||
(function (factory) { | ||
@@ -15,9 +12,4 @@ | ||
var fs = require('fs'); | ||
// Node/CommonJS | ||
module.exports = factory(); | ||
module.exports.css = function () { | ||
return fs.readFileSync(__dirname + '/nouislider.min.css', 'utf8'); | ||
}; | ||
@@ -52,5 +44,4 @@ } else { | ||
doc = elem.ownerDocument, | ||
win = doc.defaultView || doc.parentWindow, | ||
docElem = doc.documentElement, | ||
xOff = win.pageXOffset; | ||
pageOffset = getPageOffset(); | ||
@@ -61,8 +52,8 @@ // getBoundingClientRect contains left scroll in Chrome on Android. | ||
if ( /webkit.*Chrome.*Mobile/i.test(navigator.userAgent) ) { | ||
xOff = 0; | ||
pageOffset.x = 0; | ||
} | ||
return { | ||
top: rect.top + win.pageYOffset - docElem.clientTop, | ||
left: rect.left + xOff - docElem.clientLeft | ||
top: rect.top + pageOffset.y - docElem.clientTop, | ||
left: rect.left + pageOffset.x - docElem.clientLeft | ||
}; | ||
@@ -133,3 +124,24 @@ } | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY#Notes | ||
function getPageOffset ( ) { | ||
var supportPageOffset = window.pageXOffset !== undefined, | ||
isCSS1Compat = ((document.compatMode || "") === "CSS1Compat"), | ||
x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft, | ||
y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop; | ||
return { | ||
x: x, | ||
y: y | ||
}; | ||
} | ||
// todo | ||
function addCssPrefix(cssPrefix) { | ||
return function(className) { | ||
return cssPrefix + className; | ||
}; | ||
} | ||
var | ||
@@ -152,24 +164,3 @@ // Determine the events to bind. IE11 implements pointerEvents without | ||
}, | ||
// Re-usable list of classes; | ||
/** @const */ | ||
Classes = [ | ||
/* 0 */ 'noUi-target' | ||
/* 1 */ ,'noUi-base' | ||
/* 2 */ ,'noUi-origin' | ||
/* 3 */ ,'noUi-handle' | ||
/* 4 */ ,'noUi-horizontal' | ||
/* 5 */ ,'noUi-vertical' | ||
/* 6 */ ,'noUi-background' | ||
/* 7 */ ,'noUi-connect' | ||
/* 8 */ ,'noUi-ltr' | ||
/* 9 */ ,'noUi-rtl' | ||
/* 10 */ ,'noUi-dragable' | ||
/* 11 */ ,'' | ||
/* 12 */ ,'noUi-state-drag' | ||
/* 13 */ ,'' | ||
/* 14 */ ,'noUi-state-tap' | ||
/* 15 */ ,'noUi-active' | ||
/* 16 */ ,'' | ||
/* 17 */ ,'noUi-stacking' | ||
]; | ||
defaultCssPrefix = 'noUi-'; | ||
@@ -372,4 +363,9 @@ | ||
// Sort all entries by value (numeric sort). | ||
ordered.sort(function(a, b) { return a[0] - b[0]; }); | ||
if ( ordered.length && typeof ordered[0][0] === "object" ) { | ||
ordered.sort(function(a, b) { return a[0][0] - b[0][0]; }); | ||
} else { | ||
ordered.sort(function(a, b) { return a[0] - b[0]; }); | ||
} | ||
// Convert all entries to subranges. | ||
@@ -459,3 +455,3 @@ for ( index = 0; index < ordered.length; index++ ) { | ||
var defaultFormatter = { 'to': function( value ){ | ||
return value.toFixed(2); | ||
return value !== undefined && value.toFixed(2); | ||
}, 'from': Number }; | ||
@@ -616,2 +612,7 @@ | ||
// Fix #472 | ||
if ( drag && !parsed.connect ) { | ||
throw new Error("noUiSlider: 'drag' behaviour must be used with 'connect': true."); | ||
} | ||
parsed.events = { | ||
@@ -625,2 +626,20 @@ tap: tap || snap, | ||
function testTooltips ( parsed, entry ) { | ||
if ( entry === true ) { | ||
parsed.tooltips = true; | ||
} | ||
if ( entry && entry.format ) { | ||
if ( typeof entry.format !== 'function' ) { | ||
throw new Error("noUiSlider: 'tooltips.format' must be an object."); | ||
} | ||
parsed.tooltips = { | ||
format: entry.format | ||
}; | ||
} | ||
} | ||
function testFormat ( parsed, entry ) { | ||
@@ -638,2 +657,11 @@ | ||
function testCssPrefix ( parsed, entry ) { | ||
if ( entry !== undefined && typeof entry !== 'string' ) { | ||
throw new Error( "noUiSlider: 'cssPrefix' must be a string."); | ||
} | ||
parsed.cssPrefix = entry; | ||
} | ||
// Test all developer settings and parse to assumption-safe values. | ||
@@ -662,3 +690,5 @@ function testOptions ( options ) { | ||
'behaviour': { r: true, t: testBehaviour }, | ||
'format': { r: false, t: testFormat } | ||
'format': { r: false, t: testFormat }, | ||
'tooltips': { r: false, t: testTooltips }, | ||
'cssPrefix': { r: false, t: testCssPrefix } | ||
}; | ||
@@ -710,2 +740,36 @@ | ||
function closure ( target, options ){ | ||
// All variables local to 'closure' are prefixed with 'scope_' | ||
var scope_Target = target, | ||
scope_Locations = [-1, -1], | ||
scope_Base, | ||
scope_Handles, | ||
scope_Spectrum = options.spectrum, | ||
scope_Values = [], | ||
scope_Events = {}; | ||
var cssClasses = [ | ||
/* 0 */ 'target' | ||
/* 1 */ ,'base' | ||
/* 2 */ ,'origin' | ||
/* 3 */ ,'handle' | ||
/* 4 */ ,'horizontal' | ||
/* 5 */ ,'vertical' | ||
/* 6 */ ,'background' | ||
/* 7 */ ,'connect' | ||
/* 8 */ ,'ltr' | ||
/* 9 */ ,'rtl' | ||
/* 10 */ ,'draggable' | ||
/* 11 */ ,'' | ||
/* 12 */ ,'state-drag' | ||
/* 13 */ ,'' | ||
/* 14 */ ,'state-tap' | ||
/* 15 */ ,'active' | ||
/* 16 */ ,'' | ||
/* 17 */ ,'stacking' | ||
/* 18 */ ,'tooltip' | ||
].map(addCssPrefix(options.cssPrefix || defaultCssPrefix)); | ||
// Delimit proposed values for handle positions. | ||
@@ -735,3 +799,3 @@ function getPositions ( a, b, delimit ) { | ||
// Provide a clean event with standardized offset values. | ||
function fixEvent ( e ) { | ||
function fixEvent ( e, pageOffset ) { | ||
@@ -762,7 +826,10 @@ // Prevent scrolling and panning on touch events, while | ||
pageOffset = pageOffset || getPageOffset(); | ||
if ( mouse || pointer ) { | ||
x = e.clientX + window.pageXOffset; | ||
y = e.clientY + window.pageYOffset; | ||
x = e.clientX + pageOffset.x; | ||
y = e.clientY + pageOffset.y; | ||
} | ||
event.pageOffset = pageOffset; | ||
event.points = [x, y]; | ||
@@ -785,6 +852,6 @@ event.cursor = mouse || pointer; // Fix #435 | ||
addClass(handle, Classes[3]); | ||
addClass(handle, Classes[3] + additions[index]); | ||
addClass(handle, cssClasses[3]); | ||
addClass(handle, cssClasses[3] + additions[index]); | ||
addClass(origin, Classes[2]); | ||
addClass(origin, cssClasses[2]); | ||
origin.appendChild(handle); | ||
@@ -803,10 +870,10 @@ | ||
switch ( connect ) { | ||
case 1: addClass(target, Classes[7]); | ||
addClass(handles[0], Classes[6]); | ||
case 1: addClass(target, cssClasses[7]); | ||
addClass(handles[0], cssClasses[6]); | ||
break; | ||
case 3: addClass(handles[1], Classes[6]); | ||
case 3: addClass(handles[1], cssClasses[6]); | ||
/* falls through */ | ||
case 2: addClass(handles[0], Classes[7]); | ||
case 2: addClass(handles[0], cssClasses[7]); | ||
/* falls through */ | ||
case 0: addClass(target, Classes[6]); | ||
case 0: addClass(target, cssClasses[6]); | ||
break; | ||
@@ -835,8 +902,8 @@ } | ||
// Apply classes and data to the target. | ||
addClass(target, Classes[0]); | ||
addClass(target, Classes[8 + direction]); | ||
addClass(target, Classes[4 + orientation]); | ||
addClass(target, cssClasses[0]); | ||
addClass(target, cssClasses[8 + direction]); | ||
addClass(target, cssClasses[4 + orientation]); | ||
var div = document.createElement('div'); | ||
addClass(div, Classes[1]); | ||
addClass(div, cssClasses[1]); | ||
target.appendChild(div); | ||
@@ -847,14 +914,24 @@ return div; | ||
function closure ( target, options ){ | ||
function defaultFormatTooltipValue ( formattedValue ) { | ||
return formattedValue; | ||
} | ||
// All variables local to 'closure' are prefixed with 'scope_' | ||
var scope_Target = target, | ||
scope_Locations = [-1, -1], | ||
scope_Base, | ||
scope_Handles, | ||
scope_Spectrum = options.spectrum, | ||
scope_Values = [], | ||
scope_Events = {}; | ||
function addTooltip ( handle ) { | ||
var element = document.createElement('div'); | ||
element.className = cssClasses[18]; | ||
return handle.firstChild.appendChild(element); | ||
} | ||
// The tooltips option is a shorthand for using the 'update' event. | ||
function tooltips ( tooltipsOptions ) { | ||
var formatTooltipValue = tooltipsOptions.format ? tooltipsOptions.format : defaultFormatTooltipValue, | ||
tips = scope_Handles.map(addTooltip); | ||
bindEvent('update', function(formattedValues, handleId, rawValues) { | ||
tips[handleId].innerHTML = formatTooltipValue(formattedValues[handleId], rawValues[handleId]); | ||
}); | ||
} | ||
function getGroup ( mode, values, stepped ) { | ||
@@ -909,2 +986,7 @@ | ||
function safeIncrement(value, increment) { | ||
// Avoid floating point variance by dropping the smallest decimal places. | ||
return (value + increment).toFixed(7) / 1; | ||
} | ||
var originalSpectrumDirection = scope_Spectrum.direction, | ||
@@ -965,3 +1047,3 @@ indexes = {}, | ||
// Find all steps in the subrange. | ||
for ( i = low; i <= high; i += step ) { | ||
for ( i = low; i <= high; i = safeIncrement(i, step) ) { | ||
@@ -1092,3 +1174,3 @@ // Get the percentage value for the current step, | ||
if ( handleNumber !== undefined ) { | ||
if ( handleNumber !== undefined && options.handles !== 1 ) { | ||
handleNumber = Math.abs(handleNumber - options.dir); | ||
@@ -1140,7 +1222,7 @@ } | ||
// Stop if an active 'tap' transition is taking place. | ||
if ( hasClass(scope_Target, Classes[14]) ) { | ||
if ( hasClass(scope_Target, cssClasses[14]) ) { | ||
return false; | ||
} | ||
e = fixEvent(e); | ||
e = fixEvent(e, data.pageOffset); | ||
@@ -1171,4 +1253,12 @@ // Ignore right or middle clicks on start #454 | ||
// Fix #498 | ||
// Check value of .buttons in 'start' to work around a bug in IE10 mobile. | ||
// https://connect.microsoft.com/IE/feedback/details/927005/mobile-ie10-windows-phone-buttons-property-of-pointermove-event-always-zero | ||
// IE9 has .buttons zero on mousemove. | ||
if ( event.buttons === 0 && event.which === 0 && data.buttonsProperty !== 0 ) { | ||
return end(event, data); | ||
} | ||
var handles = data.handles || scope_Handles, positions, state = false, | ||
proposal = ((event.calcPoint - data.start) * 100) / baseSize(), | ||
proposal = ((event.calcPoint - data.start) * 100) / data.baseSize, | ||
handleNumber = handles[0] === scope_Handles[0] ? 0 : 1, i; | ||
@@ -1201,7 +1291,7 @@ | ||
// The handle is no longer active, so remove the class. | ||
var active = scope_Base.getElementsByClassName(Classes[15]), | ||
var active = scope_Base.querySelector( '.' + cssClasses[15] ), | ||
handleNumber = data.handles[0] === scope_Handles[0] ? 0 : 1; | ||
if ( active.length ) { | ||
removeClass(active[0], Classes[15]); | ||
if ( active !== null ) { | ||
removeClass(active, cssClasses[15]); | ||
} | ||
@@ -1223,3 +1313,3 @@ | ||
// Remove dragging class. | ||
removeClass(scope_Target, Classes[12]); | ||
removeClass(scope_Target, cssClasses[12]); | ||
@@ -1238,3 +1328,3 @@ // Fire the change and set events. | ||
if ( data.handles.length === 1 ) { | ||
addClass(data.handles[0].children[0], Classes[15]); | ||
addClass(data.handles[0].children[0], cssClasses[15]); | ||
@@ -1253,3 +1343,6 @@ // Support 'disabled' handles | ||
start: event.calcPoint, | ||
baseSize: baseSize(), | ||
pageOffset: event.pageOffset, | ||
handles: data.handles, | ||
buttonsProperty: event.buttons, | ||
positions: [ | ||
@@ -1274,3 +1367,3 @@ scope_Locations[0], | ||
if ( scope_Handles.length > 1 ) { | ||
addClass(scope_Target, Classes[12]); | ||
addClass(scope_Target, cssClasses[12]); | ||
} | ||
@@ -1313,3 +1406,3 @@ | ||
// Transition takes 300 ms, so re-enable the slider afterwards. | ||
addClassFor( scope_Target, Classes[14], 300 ); | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
} | ||
@@ -1331,3 +1424,3 @@ | ||
if ( options.events.snap ) { | ||
start(event, { handles: [scope_Handles[total]] }); | ||
start(event, { handles: [scope_Handles[handleNumber]] }); | ||
} | ||
@@ -1362,7 +1455,7 @@ } | ||
// Make the range dragable. | ||
// Make the range draggable. | ||
if ( behaviour.drag ){ | ||
drag = [scope_Base.getElementsByClassName( Classes[7] )[0]]; | ||
addClass(drag[0], Classes[10]); | ||
drag = [scope_Base.querySelector( '.' + cssClasses[7] )]; | ||
addClass(drag[0], cssClasses[10]); | ||
@@ -1393,3 +1486,4 @@ // When the range is fixed, the entire range can | ||
lowerLimit = scope_Locations[0] + options.limit, | ||
upperLimit = scope_Locations[1] - options.limit; | ||
upperLimit = scope_Locations[1] - options.limit, | ||
newScopeValue = scope_Spectrum.fromStepping( to ); | ||
@@ -1418,4 +1512,4 @@ // For sliders with multiple handles, | ||
// Return false if handle can't move. | ||
if ( to === scope_Locations[trigger] ) { | ||
// Return false if handle can't move and ranges were not updated | ||
if ( to === scope_Locations[trigger] && newScopeValue === scope_Values[trigger]) { | ||
return false; | ||
@@ -1425,9 +1519,18 @@ } | ||
// Set the handle to the new position. | ||
handle.style[options.style] = to + '%'; | ||
// Use requestAnimationFrame for efficient painting. | ||
// No significant effect in Chrome, Edge sees dramatic | ||
// performace improvements. | ||
if ( window.requestAnimationFrame ) { | ||
window.requestAnimationFrame(function(){ | ||
handle.style[options.style] = to + '%'; | ||
}); | ||
} else { | ||
handle.style[options.style] = to + '%'; | ||
} | ||
// Force proper handle stacking | ||
if ( !handle.previousSibling ) { | ||
removeClass(handle, Classes[17]); | ||
removeClass(handle, cssClasses[17]); | ||
if ( to > 50 ) { | ||
addClass(handle, Classes[17]); | ||
addClass(handle, cssClasses[17]); | ||
} | ||
@@ -1501,3 +1604,3 @@ } | ||
if ( options.animate && scope_Locations[0] !== -1 ) { | ||
addClassFor( scope_Target, Classes[14], 300 ); | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
} | ||
@@ -1535,3 +1638,3 @@ | ||
function destroy ( ) { | ||
Classes.forEach(function(cls){ | ||
cssClasses.forEach(function(cls){ | ||
if ( !cls ) { return; } // Ignore empty classes | ||
@@ -1631,2 +1734,32 @@ removeClass(scope_Target, cls); | ||
if ( options.tooltips ) { | ||
tooltips(options.tooltips); | ||
} | ||
// can be updated: | ||
// margin | ||
// limit | ||
// step | ||
// range | ||
// animate | ||
function updateOptions ( optionsToUpdate ) { | ||
var newOptions = testOptions({ | ||
start: [0, 0], | ||
margin: optionsToUpdate.margin, | ||
limit: optionsToUpdate.limit, | ||
step: optionsToUpdate.step, | ||
range: optionsToUpdate.range, | ||
animate: optionsToUpdate.animate | ||
}); | ||
options.margin = newOptions.margin; | ||
options.limit = newOptions.limit; | ||
options.step = newOptions.step; | ||
options.range = newOptions.range; | ||
options.animate = newOptions.animate; | ||
scope_Spectrum = newOptions.spectrum; | ||
} | ||
return { | ||
@@ -1638,3 +1771,4 @@ destroy: destroy, | ||
get: valueGet, | ||
set: valueSet | ||
set: valueSet, | ||
updateOptions: updateOptions | ||
}; | ||
@@ -1660,2 +1794,3 @@ | ||
target.noUiSlider = slider; | ||
return slider; | ||
} | ||
@@ -1662,0 +1797,0 @@ |
@@ -1,3 +0,3 @@ | ||
/*! nouislider - 8.0.2 - 2015-07-06 13:22:09 */ | ||
/*! nouislider - 8.1.0 - 2015-10-25 16:05:43 */ | ||
!function(a){if("function"==typeof define&&define.amd)define([],a);else if("object"==typeof exports){var b=require("fs");module.exports=a(),module.exports.css=function(){return b.readFileSync(__dirname+"/nouislider.min.css","utf8")}}else 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.defaultView||c.parentWindow,e=c.documentElement,f=d.pageXOffset;return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(f=0),{top:b.top+d.pageYOffset-e.clientTop,left:b.left+f-e.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){a.classList?a.classList.contains(b):new RegExp("(^| )"+b+"( |$)","gi").test(a.className)}function m(a,b){return 100/(b-a)}function n(a,b){return 100*b/(a[1]-a[0])}function o(a,b){return n(a,a[0]<0?b+Math.abs(a[0]):b-a[0])}function p(a,b){return b*(a[1]-a[0])/100+a[0]}function q(a,b){for(var c=1;a>=b[c];)c+=1;return c}function r(a,b,c){if(c>=a.slice(-1)[0])return 100;var d,e,f,g,h=q(c,a);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],f+o([d,e],c)/m(f,g)}function s(a,b,c){if(c>=100)return a.slice(-1)[0];var d,e,f,g,h=q(c,b);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],p([d,e],(c-f)*m(f,g))}function t(a,c,d,e){if(100===e)return e;var f,g,h=q(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 u(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 v(a,b,c){return b?void(c.xSteps[a]=n([c.xVal[a],c.xVal[a+1]],b)/m(c.xPct[a],c.xPct[a+1])):!0}function w(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.sort(function(a,b){return a[0]-b[0]}),e=0;e<f.length;e++)u(f[e][1],f[e][0],this);for(this.xNumSteps=this.xSteps.slice(0),e=0;e<this.xNumSteps.length;e++)v(e,this.xNumSteps[e],this)}function x(a,b){if(!d(b))throw new Error("noUiSlider: 'step' is not numeric.");a.singleStep=b}function y(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'.");a.spectrum=new w(b,a.snap,a.dir,a.singleStep)}function z(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 A(a,b){if(a.snap=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'snap' option must be a boolean.")}function B(a,b){if(a.animate=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'animate' option must be a boolean.")}function C(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 D(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 E(a,b){if(!d(b))throw new Error("noUiSlider: 'margin' option must be numeric.");if(a.margin=a.spectrum.getMargin(b),!a.margin)throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.")}function F(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 G(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 H(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;a.events={tap:c||f,drag:d,fixed:e,snap:f}}function I(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 J(a){var b,c={margin:0,limit:0,animate:!0,format:U};b={step:{r:!1,t:x},start:{r:!0,t:z},connect:{r:!0,t:C},direction:{r:!0,t:G},snap:{r:!1,t:A},animate:{r:!1,t:B},range:{r:!0,t:y},orientation:{r:!1,t:D},margin:{r:!1,t:E},limit:{r:!1,t:F},behaviour:{r:!0,t:H},format:{r:!1,t:I}};var d={connect:!1,direction:"ltr",behaviour:"tap",orientation:"horizontal"};return Object.keys(d).forEach(function(b){void 0===a[b]&&(a[b]=d[b])}),Object.keys(b).forEach(function(d){var e=b[d];if(void 0===a[d]){if(e.r)throw new Error("noUiSlider: '"+d+"' is required.");return!0}e.t(c,a[d])}),c.pips=a.pips,c.style=c.ort?"top":"left",c}function K(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 L(a){a.preventDefault();var b,c,d=0===a.type.indexOf("touch"),e=0===a.type.indexOf("mouse"),f=0===a.type.indexOf("pointer"),g=a;return 0===a.type.indexOf("MSPointer")&&(f=!0),d&&(b=a.changedTouches[0].pageX,c=a.changedTouches[0].pageY),(e||f)&&(b=a.clientX+window.pageXOffset,c=a.clientY+window.pageYOffset),g.points=[b,c],g.cursor=e||f,g}function M(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=["-lower","-upper"];return a&&e.reverse(),j(d,T[3]),j(d,T[3]+e[b]),j(c,T[2]),c.appendChild(d),c}function N(a,b,c){switch(a){case 1:j(b,T[7]),j(c[0],T[6]);break;case 3:j(c[1],T[6]);case 2:j(c[0],T[7]);case 0:j(b,T[6])}}function O(a,b,c){var d,e=[];for(d=0;a>d;d+=1)e.push(c.appendChild(M(b,d)));return e}function P(a,b,c){j(c,T[0]),j(c,T[8+a]),j(c,T[4+b]);var d=document.createElement("div");return j(d,T[1]),c.appendChild(d),d}function Q(b,d){function e(a,b,c){if("range"===a||"steps"===a)return M.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 M.fromStepping(c?M.getStep(a):a)}):"values"===a?c?b.map(function(a){return M.fromStepping(M.getStep(M.toStepping(a)))}):b:void 0}function m(b,c,d){var e=M.direction,f={},g=M.xVal[0],h=M.xVal[M.xVal.length-1],i=!1,j=!1,k=0;return M.direction=0,d=a(d.slice().sort(function(a,b){return a-b})),d[0]!==g&&(d.unshift(g),i=!0),d[d.length-1]!==h&&(d.push(h),j=!0),d.forEach(function(a,e){var g,h,l,m,n,o,p,q,r,s,t=a,u=d[e+1];if("steps"===c&&(g=M.xNumSteps[e]),g||(g=u-t),t!==!1&&void 0!==u)for(h=t;u>=h;h+=g){for(m=M.toStepping(h),n=m-k,q=n/b,r=Math.round(q),s=n/r,l=1;r>=l;l+=1)o=k+l*s,f[o.toFixed(5)]=["x",0];p=d.indexOf(h)>-1?1:"steps"===c?2:0,!e&&i&&(p=0),h===u&&j||(f[m.toFixed(5)]=[h,p]),k=m}}),M.direction=e,f}function n(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){M.direction&&(a=100-a),d[1]=d[1]&&b?b(d[0],d[1]):d[1],i.innerHTML+="<div "+f(a,"noUi-marker",d)+"></div>",d[1]&&(i.innerHTML+="<div "+f(a,"noUi-value",d)+">"+c.to(d[0])+"</div>")}var h=["horizontal","vertical"][d.ort],i=document.createElement("div");return j(i,"noUi-pips"),j(i,"noUi-pips-"+h),Object.keys(a).forEach(function(b){g(b,a[b])}),i}function o(a){var b=a.mode,c=a.density||1,d=a.filter||!1,f=a.values||!1,g=a.stepped||!1,h=e(b,f,g),i=m(c,b,h),j=a.format||{to:Math.round};return I.appendChild(n(i,d,j))}function p(){return G["offset"+["Width","Height"][d.ort]]}function q(a,b){void 0!==b&&(b=Math.abs(b-d.dir)),Object.keys(R).forEach(function(c){var d=c.split(".")[0];a===d&&R[c].forEach(function(a){a(h(B()),b,r(Array.prototype.slice.call(Q)))})})}function r(a){return 1===a.length?a[0]:d.dir?a.reverse():a}function s(a,b,c,e){var f=function(b){return I.hasAttribute("disabled")?!1:l(I,T[14])?!1:(b=L(b),a===S.start&&void 0!==b.buttons&&b.buttons>1?!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 t(a,b){var c,d,e=b.handles||H,f=!1,g=100*(a.calcPoint-b.start)/p(),h=e[0]===H[0]?0:1;if(c=K(g,b.positions,e.length>1),f=y(e[0],c[h],1===e.length),e.length>1){if(f=y(e[1],c[h?0:1],!1)||f)for(d=0;d<b.handles.length;d++)q("slide",d)}else f&&q("slide",h)}function u(a,b){var c=G.getElementsByClassName(T[15]),d=b.handles[0]===H[0]?0:1;c.length&&k(c[0],T[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(I,T[12]),q("set",d),q("change",d)}function v(a,b){var c=document.documentElement;if(1===b.handles.length&&(j(b.handles[0].children[0],T[15]),b.handles[0].hasAttribute("disabled")))return!1;a.stopPropagation();var d=s(S.move,c,t,{start:a.calcPoint,handles:b.handles,positions:[J[0],J[H.length-1]]}),e=s(S.end,c,u,{handles:b.handles});if(c.noUiListeners=d.concat(e),a.cursor){document.body.style.cursor=getComputedStyle(a.target).cursor,H.length>1&&j(I,T[12]);var f=function(){return!1};document.body.noUiListener=f,document.body.addEventListener("selectstart",f,!1)}}function w(a){var b,e,g=a.calcPoint,h=0;return a.stopPropagation(),H.forEach(function(a){h+=c(a)[d.style]}),b=h/2>g||1===H.length?0:1,g-=c(G)[d.style],e=100*g/p(),d.events.snap||f(I,T[14],300),H[b].hasAttribute("disabled")?!1:(y(H[b],e),q("slide",b),q("set",b),q("change",b),void(d.events.snap&&v(a,{handles:[H[h]]})))}function x(a){var b,c;if(!a.fixed)for(b=0;b<H.length;b+=1)s(S.start,H[b].children[0],v,{handles:[H[b]]});a.tap&&s(S.start,G,w,{handles:H}),a.drag&&(c=[G.getElementsByClassName(T[7])[0]],j(c[0],T[10]),a.fixed&&c.push(H[c[0]===H[0]?1:0].children[0]),c.forEach(function(a){s(S.start,a,v,{handles:H})}))}function y(a,b,c){var e=a!==H[0]?1:0,f=J[0]+d.margin,h=J[1]-d.margin,i=J[0]+d.limit,l=J[1]-d.limit;return H.length>1&&(b=e?Math.max(b,f):Math.min(b,h)),c!==!1&&d.limit&&H.length>1&&(b=e?Math.min(b,i):Math.max(b,l)),b=M.getStep(b),b=g(parseFloat(b.toFixed(7))),b===J[e]?!1:(a.style[d.style]=b+"%",a.previousSibling||(k(a,T[17]),b>50&&j(a,T[17])),J[e]=b,Q[e]=M.fromStepping(b),q("update",e),!0)}function z(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)||y(H[e],M.toStepping(f),c===3-d.dir)===!1)&&q("update",e))}function A(a){var b,c,e=h(a);for(d.dir&&d.handles>1&&e.reverse(),d.animate&&-1!==J[0]&&f(I,T[14],300),b=H.length>1?3:1,1===e.length&&(b=1),z(b,e),c=0;c<H.length;c++)q("set",c)}function B(){var a,b=[];for(a=0;a<d.handles;a+=1)b[a]=d.format.to(Q[a]);return r(b)}function C(){T.forEach(function(a){a&&k(I,a)}),I.innerHTML="",delete I.noUiSlider}function D(){var a=J.map(function(a,b){var c=M.getApplicableStep(a),d=i(String(c[2])),e=Q[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 r(a)}function E(a,b){R[a]=R[a]||[],R[a].push(b),"update"===a.split(".")[0]&&H.forEach(function(a,b){q("update",b)})}function F(a){var b=a.split(".")[0],c=a.substring(b.length);Object.keys(R).forEach(function(a){var d=a.split(".")[0],e=a.substring(d.length);b&&b!==d||c&&c!==e||delete R[a]})}var G,H,I=b,J=[-1,-1],M=d.spectrum,Q=[],R={};if(I.noUiSlider)throw new Error("Slider was already initialized.");return G=P(d.dir,d.ort,I),H=O(d.handles,d.dir,G),N(d.connect,I,H),x(d.events),d.pips&&o(d.pips),{destroy:C,steps:D,on:E,off:F,get:B,set:A}}function R(a,b){if(!a.nodeName)throw new Error("noUiSlider.create requires a single element.");var c=J(b,a),d=Q(a,c);d.set(c.start),a.noUiSlider=d}var S=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"},T=["noUi-target","noUi-base","noUi-origin","noUi-handle","noUi-horizontal","noUi-vertical","noUi-background","noUi-connect","noUi-ltr","noUi-rtl","noUi-dragable","","noUi-state-drag","","noUi-state-tap","noUi-active","","noUi-stacking"];w.prototype.getMargin=function(a){return 2===this.xPct.length?n(this.xVal,a):!1},w.prototype.toStepping=function(a){return a=r(this.xVal,this.xPct,a),this.direction&&(a=100-a),a},w.prototype.fromStepping=function(a){return this.direction&&(a=100-a),e(s(this.xVal,this.xPct,a))},w.prototype.getStep=function(a){return this.direction&&(a=100-a),a=t(this.xPct,this.xSteps,this.snap,a),this.direction&&(a=100-a),a},w.prototype.getApplicableStep=function(a){var b=q(a,this.xPct),c=100===a?2:1;return[this.xNumSteps[b-2],this.xVal[b-c],this.xNumSteps[b-c]]},w.prototype.convert=function(a){return this.getStep(this.toStepping(a))};var U={to:function(a){return a.toFixed(2)},from:Number};return{create:R}}); | ||
!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){a.classList?a.classList.contains(b):new RegExp("(^| )"+b+"( |$)","gi").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){return function(b){return a+b}}function o(a,b){return 100/(b-a)}function p(a,b){return 100*b/(a[1]-a[0])}function q(a,b){return p(a,a[0]<0?b+Math.abs(a[0]):b-a[0])}function r(a,b){return b*(a[1]-a[0])/100+a[0]}function s(a,b){for(var c=1;a>=b[c];)c+=1;return c}function t(a,b,c){if(c>=a.slice(-1)[0])return 100;var d,e,f,g,h=s(c,a);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],f+q([d,e],c)/o(f,g)}function u(a,b,c){if(c>=100)return a.slice(-1)[0];var d,e,f,g,h=s(c,b);return d=a[h-1],e=a[h],f=b[h-1],g=b[h],r([d,e],(c-f)*o(f,g))}function v(a,c,d,e){if(100===e)return e;var f,g,h=s(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 w(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 x(a,b,c){return b?void(c.xSteps[a]=p([c.xVal[a],c.xVal[a+1]],b)/o(c.xPct[a],c.xPct[a+1])):!0}function y(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++)w(f[e][1],f[e][0],this);for(this.xNumSteps=this.xSteps.slice(0),e=0;e<this.xNumSteps.length;e++)x(e,this.xNumSteps[e],this)}function z(a,b){if(!d(b))throw new Error("noUiSlider: 'step' is not numeric.");a.singleStep=b}function A(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'.");a.spectrum=new y(b,a.snap,a.dir,a.singleStep)}function B(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 C(a,b){if(a.snap=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'snap' option must be a boolean.")}function D(a,b){if(a.animate=b,"boolean"!=typeof b)throw new Error("noUiSlider: 'animate' option must be a boolean.")}function E(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 F(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 G(a,b){if(!d(b))throw new Error("noUiSlider: 'margin' option must be numeric.");if(a.margin=a.spectrum.getMargin(b),!a.margin)throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.")}function H(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 I(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 J(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;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}}function K(a,b){if(b===!0&&(a.tooltips=!0),b&&b.format){if("function"!=typeof b.format)throw new Error("noUiSlider: 'tooltips.format' must be an object.");a.tooltips={format:b.format}}}function L(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 M(a,b){if(void 0!==b&&"string"!=typeof b)throw new Error("noUiSlider: 'cssPrefix' must be a string.");a.cssPrefix=b}function N(a){var b,c={margin:0,limit:0,animate:!0,format:S};b={step:{r:!1,t:z},start:{r:!0,t:B},connect:{r:!0,t:E},direction:{r:!0,t:I},snap:{r:!1,t:C},animate:{r:!1,t:D},range:{r:!0,t:A},orientation:{r:!1,t:F},margin:{r:!1,t:G},limit:{r:!1,t:H},behaviour:{r:!0,t:J},format:{r:!1,t:L},tooltips:{r:!1,t:K},cssPrefix:{r:!1,t:M}};var d={connect:!1,direction:"ltr",behaviour:"tap",orientation:"horizontal"};return Object.keys(d).forEach(function(b){void 0===a[b]&&(a[b]=d[b])}),Object.keys(b).forEach(function(d){var e=b[d];if(void 0===a[d]){if(e.r)throw new Error("noUiSlider: '"+d+"' is required.");return!0}e.t(c,a[d])}),c.pips=a.pips,c.style=c.ort?"top":"left",c}function O(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 o(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 p(a,b){var c=document.createElement("div"),d=document.createElement("div"),e=["-lower","-upper"];return a&&e.reverse(),j(d,aa[3]),j(d,aa[3]+e[b]),j(c,aa[2]),c.appendChild(d),c}function q(a,b,c){switch(a){case 1:j(b,aa[7]),j(c[0],aa[6]);break;case 3:j(c[1],aa[6]);case 2:j(c[0],aa[7]);case 0:j(b,aa[6])}}function r(a,b,c){var d,e=[];for(d=0;a>d;d+=1)e.push(c.appendChild(p(b,d)));return e}function s(a,b,c){j(c,aa[0]),j(c,aa[8+a]),j(c,aa[4+b]);var d=document.createElement("div");return j(d,aa[1]),c.appendChild(d),d}function t(a){return a}function u(a){var b=document.createElement("div");return b.className=aa[18],a.firstChild.appendChild(b)}function v(a){var b=a.format?a.format:t,c=W.map(u);S("update",function(a,d,e){c[d].innerHTML=b(a[d],e[d])})}function w(a,b,c){if("range"===a||"steps"===a)return Z.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 Z.fromStepping(c?Z.getStep(a):a)}):"values"===a?c?b.map(function(a){return Z.fromStepping(Z.getStep(Z.toStepping(a)))}):b:void 0}function x(b,c,d){function e(a,b){return(a+b).toFixed(7)/1}var f=Z.direction,g={},h=Z.xVal[0],i=Z.xVal[Z.xVal.length-1],j=!1,k=!1,l=0;return Z.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=Z.xNumSteps[f]),h||(h=v-u),u!==!1&&void 0!==v)for(i=u;v>=i;i=e(i,h)){for(n=Z.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}}),Z.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){Z.direction&&(a=100-a),d[1]=d[1]&&b?b(d[0],d[1]):d[1],i.innerHTML+="<div "+f(a,"noUi-marker",d)+"></div>",d[1]&&(i.innerHTML+="<div "+f(a,"noUi-value",d)+">"+c.to(d[0])+"</div>")}var h=["horizontal","vertical"][d.ort],i=document.createElement("div");return j(i,"noUi-pips"),j(i,"noUi-pips-"+h),Object.keys(a).forEach(function(b){g(b,a[b])}),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 X.appendChild(y(h,d,i))}function A(){return V["offset"+["Width","Height"][d.ort]]}function B(a,b){void 0!==b&&1!==d.handles&&(b=Math.abs(b-d.dir)),Object.keys(_).forEach(function(c){var d=c.split(".")[0];a===d&&_[c].forEach(function(a){a(h(M()),b,C(Array.prototype.slice.call($)))})})}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 X.hasAttribute("disabled")?!1:l(X,aa[14])?!1:(b=o(b,e.pageOffset),a===Q.start&&void 0!==b.buttons&&b.buttons>1?!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(0===a.buttons&&0===a.which&&0!==b.buttonsProperty)return F(a,b);var c,d,f=b.handles||W,g=!1,h=100*(a.calcPoint-b.start)/b.baseSize,i=f[0]===W[0]?0:1;if(c=e(h,b.positions,f.length>1),g=J(f[0],c[i],1===f.length),f.length>1){if(g=J(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=V.querySelector("."+aa[15]),d=b.handles[0]===W[0]?0:1;null!==c&&k(c,aa[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(X,aa[12]),B("set",d),B("change",d)}function G(a,b){var c=document.documentElement;if(1===b.handles.length&&(j(b.handles[0].children[0],aa[15]),b.handles[0].hasAttribute("disabled")))return!1;a.stopPropagation();var d=D(Q.move,c,E,{start:a.calcPoint,baseSize:A(),pageOffset:a.pageOffset,handles:b.handles,buttonsProperty:a.buttons,positions:[Y[0],Y[W.length-1]]}),e=D(Q.end,c,F,{handles:b.handles});if(c.noUiListeners=d.concat(e),a.cursor){document.body.style.cursor=getComputedStyle(a.target).cursor,W.length>1&&j(X,aa[12]);var f=function(){return!1};document.body.noUiListener=f,document.body.addEventListener("selectstart",f,!1)}}function H(a){var b,e,g=a.calcPoint,h=0;return a.stopPropagation(),W.forEach(function(a){h+=c(a)[d.style]}),b=h/2>g||1===W.length?0:1,g-=c(V)[d.style],e=100*g/A(),d.events.snap||f(X,aa[14],300),W[b].hasAttribute("disabled")?!1:(J(W[b],e),B("slide",b),B("set",b),B("change",b),void(d.events.snap&&G(a,{handles:[W[b]]})))}function I(a){var b,c;if(!a.fixed)for(b=0;b<W.length;b+=1)D(Q.start,W[b].children[0],G,{handles:[W[b]]});a.tap&&D(Q.start,V,H,{handles:W}),a.drag&&(c=[V.querySelector("."+aa[7])],j(c[0],aa[10]),a.fixed&&c.push(W[c[0]===W[0]?1:0].children[0]),c.forEach(function(a){D(Q.start,a,G,{handles:W})}))}function J(a,b,c){var e=a!==W[0]?1:0,f=Y[0]+d.margin,h=Y[1]-d.margin,i=Y[0]+d.limit,l=Y[1]-d.limit,m=Z.fromStepping(b);return W.length>1&&(b=e?Math.max(b,f):Math.min(b,h)),c!==!1&&d.limit&&W.length>1&&(b=e?Math.min(b,i):Math.max(b,l)),b=Z.getStep(b),b=g(parseFloat(b.toFixed(7))),b===Y[e]&&m===$[e]?!1:(window.requestAnimationFrame?window.requestAnimationFrame(function(){a.style[d.style]=b+"%"}):a.style[d.style]=b+"%",a.previousSibling||(k(a,aa[17]),b>50&&j(a,aa[17])),Y[e]=b,$[e]=Z.fromStepping(b),B("update",e),!0)}function K(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)||J(W[e],Z.toStepping(f),c===3-d.dir)===!1)&&B("update",e))}function L(a){var b,c,e=h(a);for(d.dir&&d.handles>1&&e.reverse(),d.animate&&-1!==Y[0]&&f(X,aa[14],300),b=W.length>1?3:1,1===e.length&&(b=1),K(b,e),c=0;c<W.length;c++)B("set",c)}function M(){var a,b=[];for(a=0;a<d.handles;a+=1)b[a]=d.format.to($[a]);return C(b)}function O(){aa.forEach(function(a){a&&k(X,a)}),X.innerHTML="",delete X.noUiSlider}function P(){var a=Y.map(function(a,b){var c=Z.getApplicableStep(a),d=i(String(c[2])),e=$[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 S(a,b){_[a]=_[a]||[],_[a].push(b),"update"===a.split(".")[0]&&W.forEach(function(a,b){B("update",b)})}function T(a){var b=a.split(".")[0],c=a.substring(b.length);Object.keys(_).forEach(function(a){var d=a.split(".")[0],e=a.substring(d.length);b&&b!==d||c&&c!==e||delete _[a]})}function U(a){var b=N({start:[0,0],margin:a.margin,limit:a.limit,step:a.step,range:a.range,animate:a.animate});d.margin=b.margin,d.limit=b.limit,d.step=b.step,d.range=b.range,d.animate=b.animate,Z=b.spectrum}var V,W,X=b,Y=[-1,-1],Z=d.spectrum,$=[],_={},aa=["target","base","origin","handle","horizontal","vertical","background","connect","ltr","rtl","draggable","","state-drag","","state-tap","active","","stacking","tooltip"].map(n(d.cssPrefix||R));if(X.noUiSlider)throw new Error("Slider was already initialized.");return V=s(d.dir,d.ort,X),W=r(d.handles,d.dir,V),q(d.connect,X,W),I(d.events),d.pips&&z(d.pips),d.tooltips&&v(d.tooltips),{destroy:O,steps:P,on:S,off:T,get:M,set:L,updateOptions:U}}function P(a,b){if(!a.nodeName)throw new Error("noUiSlider.create requires a single element.");var c=N(b,a),d=O(a,c);return d.set(c.start),a.noUiSlider=d,d}var Q=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"},R="noUi-";y.prototype.getMargin=function(a){return 2===this.xPct.length?p(this.xVal,a):!1},y.prototype.toStepping=function(a){return a=t(this.xVal,this.xPct,a),this.direction&&(a=100-a),a},y.prototype.fromStepping=function(a){return this.direction&&(a=100-a),e(u(this.xVal,this.xPct,a))},y.prototype.getStep=function(a){return this.direction&&(a=100-a),a=v(this.xPct,this.xSteps,this.snap,a),this.direction&&(a=100-a),a},y.prototype.getApplicableStep=function(a){var b=s(a,this.xPct),c=100===a?2:1;return[this.xNumSteps[b-2],this.xVal[b-c],this.xNumSteps[b-c]]},y.prototype.convert=function(a){return this.getStep(this.toStepping(a))};var S={to:function(a){return void 0!==a&&a.toFixed(2)},from:Number};return{create:P}}); |
@@ -15,4 +15,5 @@ module.exports = function(grunt) { | ||
'src/js/options.js', | ||
'src/js/scope_start.js', | ||
'src/js/structure.js', | ||
'src/js/scope_start.js', | ||
'src/js/tooltips.js', | ||
'src/js/pips.js', | ||
@@ -51,3 +52,3 @@ 'src/js/scope_helpers.js', | ||
files: { | ||
'distribute/nouislider.min.css': ['src/nouislider.css', 'src/nouislider.pips.css'] | ||
'distribute/nouislider.min.css': ['src/nouislider.css', 'src/nouislider.pips.css', 'src/nouislider.tooltips.css'] | ||
} | ||
@@ -106,5 +107,6 @@ } | ||
grunt.registerTask('default', ['concat', 'jshint']); | ||
grunt.registerTask('create', ['concat', 'jshint', 'uglify', 'cssmin']); | ||
grunt.registerTask('release', ['compress']); | ||
grunt.registerTask('default', ['concat', 'jshint']); | ||
grunt.registerTask('create', ['concat', 'uglify', 'cssmin']); | ||
grunt.registerTask('lint', ['jshint']); | ||
grunt.registerTask('release', ['jshint', 'compress']); | ||
}; |
{ | ||
"name": "nouislider", | ||
"version": "8.0.2", | ||
"version": "8.1.0", | ||
"main": "distribute/nouislider", | ||
"style": "distribute/nouislider.min.css", | ||
"license": "WTFPL", | ||
"scripts": { | ||
"build": "grunt create", | ||
"watch:js": "npm run build && onchange 'src/js/*.js' 'src/*.css' -- npm run build", | ||
"serve-tests": "browser-sync start --server . --startPath tests/slider.html --files 'distribute/, tests/*.js'", | ||
"test": "grunt lint", | ||
"dev": "./scripts/dev.sh" | ||
}, | ||
"devDependencies": { | ||
"blanket": "1.1.7", | ||
"browser-sync": "2.9.3", | ||
"grunt": "~0.4.1", | ||
"grunt-cli": "0.1.13", | ||
"grunt-contrib-compress": "^0.11.0", | ||
@@ -13,3 +24,5 @@ "grunt-contrib-concat": "^0.5.0", | ||
"grunt-contrib-jshint": "^0.10.0", | ||
"grunt-contrib-uglify": "^0.5.1" | ||
"grunt-contrib-uglify": "^0.5.1", | ||
"onchange": "2.0.0", | ||
"simulant": "0.1.5" | ||
}, | ||
@@ -19,8 +32,3 @@ "repository": { | ||
"url": "git://github.com/leongersen/noUiSlider.git" | ||
}, | ||
"browserify": { | ||
"transform": [ | ||
"brfs" | ||
] | ||
} | ||
} |
# noUiSlider | ||
noUiSlider is lightweight JavaScript range slider, originally developed to be a jQuery UI alternative. It features cross-browser support, a wide range of options and support for a bunch of touch devices. It has been tested on Android phones, iPhone & iPad, Windows phone and touch-screen laptops and tablets and desktops; All modern browsers and IE9+ are supported. The end result? A lean, extendible and bloat-less plugin that'll just do its job. | ||
noUiSlider is lightweight JavaScript range slider, originally developed to be a jQuery UI alternative. | ||
The best part? noUiSlider has no dependencies! As of version 8, **Query is no longer required!** | ||
It features cross-browser support, a wide range of options and support for a bunch of touch devices. It has been tested on Android phones, iPhone & iPad, Windows phone and touch-screen laptops and tablets and desktops. | ||
Oh, and the licensing terms are simple: [just do what you want](http://www.wtfpl.net/about/). | ||
All modern browsers and [IE8+](#browser-support) are supported. The end result? A lean, extendible and bloat-less plugin that'll just do its job. | ||
------------------------------------- | ||
The best part? noUiSlider has no dependencies! As of version 8, **jQuery is no longer required!** | ||
**Quick note (July 10, 2015):** I'll be on vacation for the next three months, so support on this library will be very limited. I'm sorry for any inconvenience caused. I'll get back to you *asap*. | ||
Oh, and the licensing terms are simple: [just Do What the Fuck You Want](http://www.wtfpl.net/about/) with it. | ||
------------------------------------- | ||
Documentation | ||
@@ -21,11 +19,29 @@ ------- | ||
--------- | ||
###8.0.2 | ||
Fix #464, added NPM information; | ||
### 8.1.0 (latest) | ||
- Fixed Microsoft Edge support | ||
- Merged several pull requests containing bug fixes | ||
- Fixed an issue where a slider handle could get 'stuck' to a mouse cursor after moving out of a window. | ||
- Combed through code using a profiler, fixed some performance issues. | ||
- Added support for basic tooltips. | ||
###8.0.1 | ||
Fixed an issue with IE11 on touch devices. | ||
###8.0.0 | ||
### 8.0.0 | ||
Removed jQuery dependency! For more info and other changes, see [the release information](http://refreshless.com/nouislider/new-version). | ||
Devices | ||
------- | ||
Devices/browsers tested: | ||
- Surface Pro 3 (Windows 10) | ||
- iPad Air 2 (iOS 9.0) | ||
- iPad 3 (iOS 8.4) | ||
- Moto E (Android 5.1, Chrome) | ||
- Lumia 930 (WP10 mobile) | ||
- Asus S400C (Windows 10, Touch + mouse) | ||
+ Chrome | ||
+ Firefox | ||
+ Edge | ||
+ IE11 | ||
+ IE10 (Emulated) | ||
+ IE9 (Emulated) | ||
Bower | ||
@@ -59,2 +75,16 @@ ----- | ||
Browser support | ||
--------------- | ||
All major browsers are supported. **To support IE8** you'll need to shim several ES5 features. | ||
You can use [polyfill.io](https://cdn.polyfill.io/v2/docs/) to easily do so: | ||
```html | ||
<meta http-equiv="X-UA-Compatible" content="IE=Edge"> | ||
<!--[if lte IE 8]> | ||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script> | ||
<![endif]--> | ||
``` | ||
Version numbering | ||
@@ -61,0 +91,0 @@ ------------------------------ |
@@ -19,23 +19,2 @@ | ||
}, | ||
// Re-usable list of classes; | ||
/** @const */ | ||
Classes = [ | ||
/* 0 */ 'noUi-target' | ||
/* 1 */ ,'noUi-base' | ||
/* 2 */ ,'noUi-origin' | ||
/* 3 */ ,'noUi-handle' | ||
/* 4 */ ,'noUi-horizontal' | ||
/* 5 */ ,'noUi-vertical' | ||
/* 6 */ ,'noUi-background' | ||
/* 7 */ ,'noUi-connect' | ||
/* 8 */ ,'noUi-ltr' | ||
/* 9 */ ,'noUi-rtl' | ||
/* 10 */ ,'noUi-dragable' | ||
/* 11 */ ,'' | ||
/* 12 */ ,'noUi-state-drag' | ||
/* 13 */ ,'' | ||
/* 14 */ ,'noUi-state-tap' | ||
/* 15 */ ,'noUi-active' | ||
/* 16 */ ,'' | ||
/* 17 */ ,'noUi-stacking' | ||
]; | ||
defaultCssPrefix = 'noUi-'; |
@@ -19,5 +19,4 @@ | ||
doc = elem.ownerDocument, | ||
win = doc.defaultView || doc.parentWindow, | ||
docElem = doc.documentElement, | ||
xOff = win.pageXOffset; | ||
pageOffset = getPageOffset(); | ||
@@ -28,8 +27,8 @@ // getBoundingClientRect contains left scroll in Chrome on Android. | ||
if ( /webkit.*Chrome.*Mobile/i.test(navigator.userAgent) ) { | ||
xOff = 0; | ||
pageOffset.x = 0; | ||
} | ||
return { | ||
top: rect.top + win.pageYOffset - docElem.clientTop, | ||
left: rect.left + xOff - docElem.clientLeft | ||
top: rect.top + pageOffset.y - docElem.clientTop, | ||
left: rect.left + pageOffset.x - docElem.clientLeft | ||
}; | ||
@@ -99,1 +98,22 @@ } | ||
} | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY#Notes | ||
function getPageOffset ( ) { | ||
var supportPageOffset = window.pageXOffset !== undefined, | ||
isCSS1Compat = ((document.compatMode || "") === "CSS1Compat"), | ||
x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft, | ||
y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop; | ||
return { | ||
x: x, | ||
y: y | ||
}; | ||
} | ||
// todo | ||
function addCssPrefix(cssPrefix) { | ||
return function(className) { | ||
return cssPrefix + className; | ||
}; | ||
} |
@@ -17,2 +17,3 @@ | ||
target.noUiSlider = slider; | ||
return slider; | ||
} | ||
@@ -19,0 +20,0 @@ |
@@ -1,4 +0,1 @@ | ||
/*jslint browser: true */ | ||
/*jslint white: true */ | ||
(function (factory) { | ||
@@ -13,9 +10,4 @@ | ||
var fs = require('fs'); | ||
// Node/CommonJS | ||
module.exports = factory(); | ||
module.exports.css = function () { | ||
return fs.readFileSync(__dirname + '/nouislider.min.css', 'utf8'); | ||
}; | ||
@@ -22,0 +14,0 @@ } else { |
@@ -15,3 +15,3 @@ /* Every input option is tested and parsed. This'll prevent | ||
var defaultFormatter = { 'to': function( value ){ | ||
return value.toFixed(2); | ||
return value !== undefined && value.toFixed(2); | ||
}, 'from': Number }; | ||
@@ -172,2 +172,7 @@ | ||
// Fix #472 | ||
if ( drag && !parsed.connect ) { | ||
throw new Error("noUiSlider: 'drag' behaviour must be used with 'connect': true."); | ||
} | ||
parsed.events = { | ||
@@ -181,2 +186,20 @@ tap: tap || snap, | ||
function testTooltips ( parsed, entry ) { | ||
if ( entry === true ) { | ||
parsed.tooltips = true; | ||
} | ||
if ( entry && entry.format ) { | ||
if ( typeof entry.format !== 'function' ) { | ||
throw new Error("noUiSlider: 'tooltips.format' must be an object."); | ||
} | ||
parsed.tooltips = { | ||
format: entry.format | ||
}; | ||
} | ||
} | ||
function testFormat ( parsed, entry ) { | ||
@@ -194,2 +217,11 @@ | ||
function testCssPrefix ( parsed, entry ) { | ||
if ( entry !== undefined && typeof entry !== 'string' ) { | ||
throw new Error( "noUiSlider: 'cssPrefix' must be a string."); | ||
} | ||
parsed.cssPrefix = entry; | ||
} | ||
// Test all developer settings and parse to assumption-safe values. | ||
@@ -218,3 +250,5 @@ function testOptions ( options ) { | ||
'behaviour': { r: true, t: testBehaviour }, | ||
'format': { r: false, t: testFormat } | ||
'format': { r: false, t: testFormat }, | ||
'tooltips': { r: false, t: testTooltips }, | ||
'cssPrefix': { r: false, t: testCssPrefix } | ||
}; | ||
@@ -221,0 +255,0 @@ |
@@ -51,2 +51,7 @@ | ||
function safeIncrement(value, increment) { | ||
// Avoid floating point variance by dropping the smallest decimal places. | ||
return (value + increment).toFixed(7) / 1; | ||
} | ||
var originalSpectrumDirection = scope_Spectrum.direction, | ||
@@ -107,3 +112,3 @@ indexes = {}, | ||
// Find all steps in the subrange. | ||
for ( i = low; i <= high; i += step ) { | ||
for ( i = low; i <= high; i = safeIncrement(i, step) ) { | ||
@@ -110,0 +115,0 @@ // Get the percentage value for the current step, |
@@ -197,4 +197,9 @@ | ||
// Sort all entries by value (numeric sort). | ||
ordered.sort(function(a, b) { return a[0] - b[0]; }); | ||
if ( ordered.length && typeof ordered[0][0] === "object" ) { | ||
ordered.sort(function(a, b) { return a[0][0] - b[0][0]; }); | ||
} else { | ||
ordered.sort(function(a, b) { return a[0] - b[0]; }); | ||
} | ||
// Convert all entries to subranges. | ||
@@ -201,0 +206,0 @@ for ( index = 0; index < ordered.length; index++ ) { |
@@ -15,7 +15,7 @@ | ||
// Stop if an active 'tap' transition is taking place. | ||
if ( hasClass(scope_Target, Classes[14]) ) { | ||
if ( hasClass(scope_Target, cssClasses[14]) ) { | ||
return false; | ||
} | ||
e = fixEvent(e); | ||
e = fixEvent(e, data.pageOffset); | ||
@@ -46,4 +46,12 @@ // Ignore right or middle clicks on start #454 | ||
// Fix #498 | ||
// Check value of .buttons in 'start' to work around a bug in IE10 mobile. | ||
// https://connect.microsoft.com/IE/feedback/details/927005/mobile-ie10-windows-phone-buttons-property-of-pointermove-event-always-zero | ||
// IE9 has .buttons zero on mousemove. | ||
if ( event.buttons === 0 && event.which === 0 && data.buttonsProperty !== 0 ) { | ||
return end(event, data); | ||
} | ||
var handles = data.handles || scope_Handles, positions, state = false, | ||
proposal = ((event.calcPoint - data.start) * 100) / baseSize(), | ||
proposal = ((event.calcPoint - data.start) * 100) / data.baseSize, | ||
handleNumber = handles[0] === scope_Handles[0] ? 0 : 1, i; | ||
@@ -76,7 +84,7 @@ | ||
// The handle is no longer active, so remove the class. | ||
var active = scope_Base.getElementsByClassName(Classes[15]), | ||
var active = scope_Base.querySelector( '.' + cssClasses[15] ), | ||
handleNumber = data.handles[0] === scope_Handles[0] ? 0 : 1; | ||
if ( active.length ) { | ||
removeClass(active[0], Classes[15]); | ||
if ( active !== null ) { | ||
removeClass(active, cssClasses[15]); | ||
} | ||
@@ -98,3 +106,3 @@ | ||
// Remove dragging class. | ||
removeClass(scope_Target, Classes[12]); | ||
removeClass(scope_Target, cssClasses[12]); | ||
@@ -113,3 +121,3 @@ // Fire the change and set events. | ||
if ( data.handles.length === 1 ) { | ||
addClass(data.handles[0].children[0], Classes[15]); | ||
addClass(data.handles[0].children[0], cssClasses[15]); | ||
@@ -128,3 +136,6 @@ // Support 'disabled' handles | ||
start: event.calcPoint, | ||
baseSize: baseSize(), | ||
pageOffset: event.pageOffset, | ||
handles: data.handles, | ||
buttonsProperty: event.buttons, | ||
positions: [ | ||
@@ -149,3 +160,3 @@ scope_Locations[0], | ||
if ( scope_Handles.length > 1 ) { | ||
addClass(scope_Target, Classes[12]); | ||
addClass(scope_Target, cssClasses[12]); | ||
} | ||
@@ -188,3 +199,3 @@ | ||
// Transition takes 300 ms, so re-enable the slider afterwards. | ||
addClassFor( scope_Target, Classes[14], 300 ); | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
} | ||
@@ -206,3 +217,3 @@ | ||
if ( options.events.snap ) { | ||
start(event, { handles: [scope_Handles[total]] }); | ||
start(event, { handles: [scope_Handles[handleNumber]] }); | ||
} | ||
@@ -237,7 +248,7 @@ } | ||
// Make the range dragable. | ||
// Make the range draggable. | ||
if ( behaviour.drag ){ | ||
drag = [scope_Base.getElementsByClassName( Classes[7] )[0]]; | ||
addClass(drag[0], Classes[10]); | ||
drag = [scope_Base.querySelector( '.' + cssClasses[7] )]; | ||
addClass(drag[0], cssClasses[10]); | ||
@@ -244,0 +255,0 @@ // When the range is fixed, the entire range can |
@@ -10,3 +10,3 @@ | ||
if ( handleNumber !== undefined ) { | ||
if ( handleNumber !== undefined && options.handles !== 1 ) { | ||
handleNumber = Math.abs(handleNumber - options.dir); | ||
@@ -13,0 +13,0 @@ } |
@@ -12,1 +12,23 @@ | ||
scope_Events = {}; | ||
var cssClasses = [ | ||
/* 0 */ 'target' | ||
/* 1 */ ,'base' | ||
/* 2 */ ,'origin' | ||
/* 3 */ ,'handle' | ||
/* 4 */ ,'horizontal' | ||
/* 5 */ ,'vertical' | ||
/* 6 */ ,'background' | ||
/* 7 */ ,'connect' | ||
/* 8 */ ,'ltr' | ||
/* 9 */ ,'rtl' | ||
/* 10 */ ,'draggable' | ||
/* 11 */ ,'' | ||
/* 12 */ ,'state-drag' | ||
/* 13 */ ,'' | ||
/* 14 */ ,'state-tap' | ||
/* 15 */ ,'active' | ||
/* 16 */ ,'' | ||
/* 17 */ ,'stacking' | ||
/* 18 */ ,'tooltip' | ||
].map(addCssPrefix(options.cssPrefix || defaultCssPrefix)); |
@@ -9,3 +9,4 @@ | ||
lowerLimit = scope_Locations[0] + options.limit, | ||
upperLimit = scope_Locations[1] - options.limit; | ||
upperLimit = scope_Locations[1] - options.limit, | ||
newScopeValue = scope_Spectrum.fromStepping( to ); | ||
@@ -34,4 +35,4 @@ // For sliders with multiple handles, | ||
// Return false if handle can't move. | ||
if ( to === scope_Locations[trigger] ) { | ||
// Return false if handle can't move and ranges were not updated | ||
if ( to === scope_Locations[trigger] && newScopeValue === scope_Values[trigger]) { | ||
return false; | ||
@@ -41,9 +42,18 @@ } | ||
// Set the handle to the new position. | ||
handle.style[options.style] = to + '%'; | ||
// Use requestAnimationFrame for efficient painting. | ||
// No significant effect in Chrome, Edge sees dramatic | ||
// performace improvements. | ||
if ( window.requestAnimationFrame ) { | ||
window.requestAnimationFrame(function(){ | ||
handle.style[options.style] = to + '%'; | ||
}); | ||
} else { | ||
handle.style[options.style] = to + '%'; | ||
} | ||
// Force proper handle stacking | ||
if ( !handle.previousSibling ) { | ||
removeClass(handle, Classes[17]); | ||
removeClass(handle, cssClasses[17]); | ||
if ( to > 50 ) { | ||
addClass(handle, Classes[17]); | ||
addClass(handle, cssClasses[17]); | ||
} | ||
@@ -117,3 +127,3 @@ } | ||
if ( options.animate && scope_Locations[0] !== -1 ) { | ||
addClassFor( scope_Target, Classes[14], 300 ); | ||
addClassFor( scope_Target, cssClasses[14], 300 ); | ||
} | ||
@@ -151,3 +161,3 @@ | ||
function destroy ( ) { | ||
Classes.forEach(function(cls){ | ||
cssClasses.forEach(function(cls){ | ||
if ( !cls ) { return; } // Ignore empty classes | ||
@@ -247,2 +257,32 @@ removeClass(scope_Target, cls); | ||
if ( options.tooltips ) { | ||
tooltips(options.tooltips); | ||
} | ||
// can be updated: | ||
// margin | ||
// limit | ||
// step | ||
// range | ||
// animate | ||
function updateOptions ( optionsToUpdate ) { | ||
var newOptions = testOptions({ | ||
start: [0, 0], | ||
margin: optionsToUpdate.margin, | ||
limit: optionsToUpdate.limit, | ||
step: optionsToUpdate.step, | ||
range: optionsToUpdate.range, | ||
animate: optionsToUpdate.animate | ||
}); | ||
options.margin = newOptions.margin; | ||
options.limit = newOptions.limit; | ||
options.step = newOptions.step; | ||
options.range = newOptions.range; | ||
options.animate = newOptions.animate; | ||
scope_Spectrum = newOptions.spectrum; | ||
} | ||
return { | ||
@@ -254,3 +294,4 @@ destroy: destroy, | ||
get: valueGet, | ||
set: valueSet | ||
set: valueSet, | ||
updateOptions: updateOptions | ||
}; |
@@ -26,3 +26,3 @@ | ||
// Provide a clean event with standardized offset values. | ||
function fixEvent ( e ) { | ||
function fixEvent ( e, pageOffset ) { | ||
@@ -53,7 +53,10 @@ // Prevent scrolling and panning on touch events, while | ||
pageOffset = pageOffset || getPageOffset(); | ||
if ( mouse || pointer ) { | ||
x = e.clientX + window.pageXOffset; | ||
y = e.clientY + window.pageYOffset; | ||
x = e.clientX + pageOffset.x; | ||
y = e.clientY + pageOffset.y; | ||
} | ||
event.pageOffset = pageOffset; | ||
event.points = [x, y]; | ||
@@ -76,6 +79,6 @@ event.cursor = mouse || pointer; // Fix #435 | ||
addClass(handle, Classes[3]); | ||
addClass(handle, Classes[3] + additions[index]); | ||
addClass(handle, cssClasses[3]); | ||
addClass(handle, cssClasses[3] + additions[index]); | ||
addClass(origin, Classes[2]); | ||
addClass(origin, cssClasses[2]); | ||
origin.appendChild(handle); | ||
@@ -94,10 +97,10 @@ | ||
switch ( connect ) { | ||
case 1: addClass(target, Classes[7]); | ||
addClass(handles[0], Classes[6]); | ||
case 1: addClass(target, cssClasses[7]); | ||
addClass(handles[0], cssClasses[6]); | ||
break; | ||
case 3: addClass(handles[1], Classes[6]); | ||
case 3: addClass(handles[1], cssClasses[6]); | ||
/* falls through */ | ||
case 2: addClass(handles[0], Classes[7]); | ||
case 2: addClass(handles[0], cssClasses[7]); | ||
/* falls through */ | ||
case 0: addClass(target, Classes[6]); | ||
case 0: addClass(target, cssClasses[6]); | ||
break; | ||
@@ -126,10 +129,10 @@ } | ||
// Apply classes and data to the target. | ||
addClass(target, Classes[0]); | ||
addClass(target, Classes[8 + direction]); | ||
addClass(target, Classes[4 + orientation]); | ||
addClass(target, cssClasses[0]); | ||
addClass(target, cssClasses[8 + direction]); | ||
addClass(target, cssClasses[4 + orientation]); | ||
var div = document.createElement('div'); | ||
addClass(div, Classes[1]); | ||
addClass(div, cssClasses[1]); | ||
target.appendChild(div); | ||
return div; | ||
} |
@@ -9,3 +9,3 @@ | ||
Q.innerHTML = '<div class="slider"></div>'; | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -40,9 +40,9 @@ noUiSlider.create(slider, { | ||
assert.ok( Q.getElementsByClassName('noUi-pips').length, 'Pips where created' ); | ||
assert.ok( Q.querySelectorAll('.noUi-pips').length, 'Pips where created' ); | ||
var markers = Q.getElementsByClassName('noUi-marker'); | ||
var markers = Q.querySelectorAll('.noUi-marker'); | ||
assert.ok( markers.length >= 32 && markers.length <= 34, 'Density of 1/3 was applied' ); | ||
// Test formatter | ||
assert.equal( Q.getElementsByClassName('noUi-value')[0].innerHTML, '0.00' ); | ||
assert.equal( Q.querySelector('.noUi-value').innerHTML, '0.00' ); | ||
}); | ||
@@ -60,3 +60,3 @@ | ||
var markers = Q.getElementsByClassName('noUi-marker').length; | ||
var markers = Q.querySelectorAll('.noUi-marker').length; | ||
assert.ok( markers >= 49 && markers <= 51, 'Density of 1/2 was applied' ); | ||
@@ -75,7 +75,7 @@ | ||
assert.equal( Q.getElementsByClassName('noUi-marker-large').length, 5, 'Large markers added for all values' ); | ||
assert.equal( Q.getElementsByClassName('noUi-value').length, 5 ); | ||
assert.equal( Q.querySelectorAll('.noUi-marker-large').length, 5, 'Large markers added for all values' ); | ||
assert.equal( Q.querySelectorAll('.noUi-value').length, 5 ); | ||
var pos = []; | ||
Array.prototype.forEach.call(Q.getElementsByClassName('noUi-value'), function( el ){ | ||
Array.prototype.forEach.call(Q.querySelectorAll('.noUi-value'), function( el ){ | ||
pos.push(parseInt(el.style.left)); | ||
@@ -110,6 +110,6 @@ }); | ||
assert.equal( Q.getElementsByClassName('noUi-value').length, 8, 'Placed requested number of values' ); | ||
assert.equal( Q.querySelectorAll('.noUi-value').length, 8, 'Placed requested number of values' ); | ||
var pos2 = []; | ||
Array.prototype.forEach.call(Q.getElementsByClassName('noUi-value'), function( el ){ | ||
Array.prototype.forEach.call(Q.querySelectorAll('.noUi-value'), function( el ){ | ||
pos2.push(parseInt(el.style.left)); | ||
@@ -143,3 +143,3 @@ }); | ||
assert.equal( Q.getElementsByClassName('noUi-value').length, 7, 'Placed requested number of values' ); | ||
assert.equal( Q.querySelectorAll('.noUi-value').length, 7, 'Placed requested number of values' ); | ||
}); | ||
@@ -157,3 +157,27 @@ | ||
assert.equal( Q.getElementsByClassName('noUi-value').length, 6, 'Removed duplicate in step' ); | ||
assert.equal( Q.querySelectorAll('.noUi-value').length, 6, 'Removed duplicate in step' ); | ||
}); | ||
// #528, #532 | ||
QUnit.test( "Values, stepped", function( assert ){ | ||
Q.innerHTML = '<div class="slider"></div>'; | ||
var slider = Q.querySelector('.slider'); | ||
noUiSlider.create(slider, { | ||
start: -12, | ||
range: { | ||
min: -15, | ||
max: 0.23 | ||
}, | ||
pips: { | ||
mode: 'positions', | ||
values: [0, 50, 100] | ||
} | ||
}); | ||
var pips = Q.querySelectorAll('.noUi-value'); | ||
assert.ok( pips[pips.length - 1].getAttribute('style').indexOf('left: 100') === 0, 'Last pip is on the right.' ); | ||
}); |
@@ -8,3 +8,3 @@ | ||
var sliders = Q.getElementsByClassName('slider'), | ||
var sliders = Q.querySelectorAll('.slider'), | ||
slider = sliders[0]; | ||
@@ -68,15 +68,8 @@ | ||
var origin = slider.getElementsByClassName('noUi-origin')[1], | ||
clickEvent = new MouseEvent('mousedown', { | ||
bubbles: true, | ||
cancelable: true, | ||
view: window, | ||
buttons: 1, | ||
clientX: offset(slider).left + 100, | ||
clientY: offset(slider).top + 8 | ||
}); | ||
simulant.fire( slider.querySelectorAll('.noUi-origin')[1], 'mousedown', { | ||
button: 1, // middle-click | ||
clientX: offset(slider).left + 100, | ||
clientY: offset(slider).top + 8 | ||
}); | ||
console.log(offset(slider)); | ||
origin.dispatchEvent(clickEvent); | ||
slider.noUiSlider.off('.namespace'); | ||
@@ -83,0 +76,0 @@ |
@@ -6,3 +6,3 @@ | ||
var sliders = Q.getElementsByClassName('slider'), | ||
var sliders = Q.querySelectorAll('.slider'), | ||
slider = sliders[0]; | ||
@@ -89,2 +89,14 @@ | ||
assert.throws(function(){ | ||
noUiSlider.create(slider, { | ||
start: 10, | ||
connect: false, | ||
behaviour: 'drag', | ||
range: { | ||
'min': 0, | ||
'max': 10 | ||
} | ||
}); | ||
}); | ||
noUiSlider.create(slider, { | ||
@@ -91,0 +103,0 @@ start: 1, |
@@ -0,0 +0,0 @@ |
@@ -15,3 +15,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -18,0 +18,0 @@ noUiSlider.create(slider, settings); |
@@ -9,4 +9,4 @@ | ||
var sliderRTL = Q.getElementsByClassName('sliderRTL')[0]; | ||
var sliderLTR = Q.getElementsByClassName('sliderLTR')[0]; | ||
var sliderRTL = Q.querySelector('.sliderRTL'); | ||
var sliderLTR = Q.querySelector('.sliderLTR'); | ||
@@ -13,0 +13,0 @@ noUiSlider.create(sliderRTL, { |
@@ -6,3 +6,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -9,0 +9,0 @@ noUiSlider.create(slider, { |
@@ -6,3 +6,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -9,0 +9,0 @@ noUiSlider.create(slider, { |
@@ -6,3 +6,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -9,0 +9,0 @@ noUiSlider.create(slider, { |
@@ -6,3 +6,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -9,0 +9,0 @@ noUiSlider.create(slider, { |
@@ -6,3 +6,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -22,11 +22,8 @@ noUiSlider.create(slider, { | ||
equal(slider.noUiSlider.get(), 11); | ||
equal(slider.getElementsByClassName('noUi-origin')[0].style.left, '0%'); | ||
slider.noUiSlider.set(12); | ||
equal(slider.noUiSlider.get(), 12); | ||
equal(slider.getElementsByClassName('noUi-origin')[0].style.left, '10%'); | ||
slider.noUiSlider.set(16); | ||
equal(slider.noUiSlider.get(), 16); | ||
equal(slider.getElementsByClassName('noUi-origin')[0].style.left, '50%'); | ||
}); |
@@ -8,3 +8,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -39,3 +39,3 @@ noUiSlider.create(slider, { | ||
equal ( slider.getElementsByClassName('noUi-connect').length, 0, 'Slider uses no connection' ); | ||
equal ( slider.querySelectorAll('.noUi-connect').length, 0, 'Slider uses no connection' ); | ||
@@ -47,3 +47,3 @@ settings.connect = true; | ||
equal ( slider.getElementsByClassName('noUi-connect').length, 1, 'Slider now connects' ); | ||
equal ( slider.querySelectorAll('.noUi-connect').length, 1, 'Slider now connects' ); | ||
@@ -50,0 +50,0 @@ assert.deepEqual(slider.noUiSlider.get(), ['30', '60'], 'Value was unchanged'); |
@@ -6,3 +6,3 @@ | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
var slider = Q.querySelector('.slider'); | ||
@@ -26,1 +26,46 @@ noUiSlider.create(slider, { | ||
}); | ||
/* The two tests show some problems with enormous numbers in JavaScript. | ||
I've decided not the attempt to work around these issues, instead documenting | ||
them and providing a work-around. | ||
QUnit.test( "Values, Accuracy With Large Numbers 1", function( assert ){ | ||
Q.innerHTML = '<div class="slider"></div>'; | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
noUiSlider.create(slider, { | ||
start: [ 1, 8301034833169290000 ], | ||
connect: true, | ||
format: TEST_ROUND_FORMAT, | ||
range: { | ||
'min': 1, | ||
'max': 8301034833169290000 | ||
} | ||
}); | ||
assert.deepEqual( slider.noUiSlider.get(), ['1', '8301034833169290000'], 'Values were accurate' ); | ||
}); | ||
QUnit.test( "Values, Accuracy With Large Numbers 2", function( assert ){ | ||
Q.innerHTML = '<div class="slider"></div>'; | ||
var slider = Q.getElementsByClassName('slider')[0]; | ||
noUiSlider.create(slider, { | ||
start: [ 1, 10000000000000005 ], | ||
connect: true, | ||
format: TEST_ROUND_FORMAT, | ||
range: { | ||
'min': 1, | ||
'max': 10000000000000005 | ||
} | ||
}); | ||
assert.deepEqual( slider.noUiSlider.get(), ['1', '10000000000000005'], 'Values were accurate' ); | ||
}); | ||
*/ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
High entropy strings
Supply chain riskContains high entropy strings. This could be a sign of encrypted data, leaked secrets or obfuscated code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
92
0
153021
12
44
3774