js/nouislider.js
// Test all developer settings and parse to assumption-safe values.
Test all developer settings and parse to assumption-safe values.
Test all developer settings and parse to assumption - safe values .
function testOptions ( options ) {
		var parsed = {
			margin: 0,
			limit: 0,
			padding: 0,
			animate: true,
			animationDuration: 300,
			ariaFormat: defaultFormatter,
			format: defaultFormatter
		};
		var tests = {
			'step': { r: false, t: testStep },
			'start': { r: true, t: testStart },
			'connect': { r: true, t: testConnect },
			'direction': { r: true, t: testDirection },
			'snap': { r: false, t: testSnap },
			'animate': { r: false, t: testAnimate },
			'animationDuration': { r: false, t: testAnimationDuration },
			'range': { r: true, t: testRange },
			'orientation': { r: false, t: testOrientation },
			'margin': { r: false, t: testMargin },
			'limit': { r: false, t: testLimit },
			'padding': { r: false, t: testPadding },
			'behaviour': { r: true, t: testBehaviour },
			'ariaFormat': { r: false, t: testAriaFormat },
			'format': { r: false, t: testFormat },
			'tooltips': { r: false, t: testTooltips },
			'cssPrefix': { r: true, t: testCssPrefix },
			'cssClasses': { r: true, t: testCssClasses }
		};
		var defaults = {
			'connect': false,
			'direction': 'ltr',
			'behaviour': 'tap',
			'orientation': 'horizontal',
			'cssPrefix' : 'noUi-',
			'cssClasses': {
				target: 'target',
				base: 'base',
				origin: 'origin',
				handle: 'handle',
				handleLower: 'handle-lower',
				handleUpper: 'handle-upper',
				horizontal: 'horizontal',
				vertical: 'vertical',
				background: 'background',
				connect: 'connect',
				connects: 'connects',
				ltr: 'ltr',
				rtl: 'rtl',
				draggable: 'draggable',
				drag: 'state-drag',
				tap: 'state-tap',
				active: 'active',
				tooltip: 'tooltip',
				pips: 'pips',
				pipsHorizontal: 'pips-horizontal',
				pipsVertical: 'pips-vertical',
				marker: 'marker',
				markerHorizontal: 'marker-horizontal',
				markerVertical: 'marker-vertical',
				markerNormal: 'marker-normal',
				markerLarge: 'marker-large',
				markerSub: 'marker-sub',
				value: 'value',
				valueHorizontal: 'value-horizontal',
				valueVertical: 'value-vertical',
				valueNormal: 'value-normal',
				valueLarge: 'value-large',
				valueSub: 'value-sub'
			}
		};
		if ( options.format && !options.ariaFormat ) {
			options.ariaFormat = options.format;
		}
		Object.keys(tests).forEach(function( name ){
			if ( !isSet(options[name]) && defaults[name] === undefined ) {
				if ( tests[name].r ) {
					throw new Error("noUiSlider (" + VERSION + "): '" + name + "' is required.");
				}
				return true;
			}
			tests[name].t( parsed, !isSet(options[name]) ? defaults[name] : options[name] );
		});
		parsed.pips = options.pips;
		var d = document.createElement("div");
		var msPrefix = d.style.msTransform !== undefined;
		var noPrefix = d.style.transform !== undefined;
		parsed.transformRule = noPrefix ? 'transform' : (msPrefix ? 'msTransform' : 'webkitTransform');
		var styles = [['left', 'top'], ['right', 'bottom']];
		parsed.style = styles[parsed.dir][parsed.ort];
		return parsed;
	}
function testOptions ( options ) { var parsed = { margin : 0 , limit : 0 , padding : 0 , animate : true , animationDuration : 300 , ariaFormat : defaultFormatter , format : defaultFormatter } ; var tests = { 'step' : { r : false , t : testStep } , 'start' : { r : true , t : testStart } , 'connect' : { r : true , t : testConnect } , 'direction' : { r : true , t : testDirection } , 'snap' : { r : false , t : testSnap } , 'animate' : { r : false , t : testAnimate } , 'animationDuration' : { r : false , t : testAnimationDuration } , 'range' : { r : true , t : testRange } , 'orientation' : { r : false , t : testOrientation } , 'margin' : { r : false , t : testMargin } , 'limit' : { r : false , t : testLimit } , 'padding' : { r : false , t : testPadding } , 'behaviour' : { r : true , t : testBehaviour } , 'ariaFormat' : { r : false , t : testAriaFormat } , 'format' : { r : false , t : testFormat } , 'tooltips' : { r : false , t : testTooltips } , 'cssPrefix' : { r : true , t : testCssPrefix } , 'cssClasses' : { r : true , t : testCssClasses } } ; var defaults = { 'connect' : false , 'direction' : 'ltr' , 'behaviour' : 'tap' , 'orientation' : 'horizontal' , 'cssPrefix' : 'noUi-' , 'cssClasses' : { target : 'target' , base : 'base' , origin : 'origin' , handle : 'handle' , handleLower : 'handle-lower' , handleUpper : 'handle-upper' , horizontal : 'horizontal' , vertical : 'vertical' , background : 'background' , connect : 'connect' , connects : 'connects' , ltr : 'ltr' , rtl : 'rtl' , draggable : 'draggable' , drag : 'state-drag' , tap : 'state-tap' , active : 'active' , tooltip : 'tooltip' , pips : 'pips' , pipsHorizontal : 'pips-horizontal' , pipsVertical : 'pips-vertical' , marker : 'marker' , markerHorizontal : 'marker-horizontal' , markerVertical : 'marker-vertical' , markerNormal : 'marker-normal' , markerLarge : 'marker-large' , markerSub : 'marker-sub' , value : 'value' , valueHorizontal : 'value-horizontal' , valueVertical : 'value-vertical' , valueNormal : 'value-normal' , valueLarge : 'value-large' , valueSub : 'value-sub' } } ; if ( options . format && ! options . ariaFormat ) { options . ariaFormat = options . format ; } Object . keys ( tests ) . forEach ( function ( name ) { if ( ! isSet ( options [ name ] ) && defaults [ name ] === undefined ) { if ( tests [ name ] . r ) { throw new Error ( "noUiSlider (" + VERSION + "): '" + name + "' is required." ) ; } return true ; } tests [ name ] . t ( parsed , ! isSet ( options [ name ] ) ? defaults [ name ] : options [ name ] ) ; } ) ; parsed . pips = options . pips ; var d = document . createElement ( "div" ) ; var msPrefix = d . style . msTransform !== undefined ; var noPrefix = d . style . transform !== undefined ; parsed . transformRule = noPrefix ? 'transform' : ( msPrefix ? 'msTransform' : 'webkitTransform' ) ; var styles = [ [ 'left' , 'top' ] , [ 'right' , 'bottom' ] ] ; parsed . style = styles [ parsed . dir ] [ parsed . ort ] ; return parsed ; }
Test all developer settings and parse to assumption-safe values.
Test all developer settings and parse to assumption - safe values .
// To prove a fix for #537, freeze options here. // If the object is modified, an error will be thrown. // Object.freeze(options); // Tests are executed in the order they are presented here. // AriaFormat defaults to regular format, if any. // Run all options through a testing mechanism to ensure correct // input. It should be noted that options might get modified to // be handled properly. E.g. wrapping integers in arrays. // If the option isn't set, but it is required, throw an error. // Forward pips options // All recent browsers accept unprefixed transform. // We need -ms- for IE9 and -webkit- for older Android; // Assume use of -webkit- if unprefixed and -ms- are not supported. // https://caniuse.com/#feat=transforms2d // Pips don't move, so we can place them using left/top.