index.js
function Slidy(target, options) {
	//force constructor
	if (!(this instanceof Slidy)) return new Slidy(target, options);

	var self = this;

	//ensure target & options
	if (!options) {
		if (target instanceof Element) {
			options = {};
		}
		else {
			options = target;
			target = doc.createElement('div');
		}
	}


	//get preferred element
	self.element = target;

	//adopt options
	extend(self, options);

	//calculate value & step
	//detect step automatically based on min/max range (1/100 by default)
	//native behaviour is always 1, so ignore it
	if (options.step === undefined) {
		self.step = detectStep(self.min, self.max);
	}

	//calc undefined valuea as a middle of range
	if (options.value === undefined) {
		self.value = detectValue(self.min, self.max);
	}

	//bind passed callbacks, if any
	if (options.created) on(self, 'created', options.created);

	//save refrence
	instancesCache.set(self.element, self);

	//generate id
	self.id = getUid();
	self.ns = 'slidy-' + self.id;
	if (!self.element.id) self.element.id = self.ns;

	//init instance
	self.element.classList.add('slidy');


	//create pickers, if passed a list
	self.pickers = [];
	if (isArray(options.pickers) && options.pickers.length) {
		options.pickers.forEach(function (opts) {
			self.addPicker(opts);
		});
	}
	//ensure at least one picker exists, if not passed in options separately
	else if (!options.hasOwnProperty('pickers')) {
		self.addPicker(options.pickers);
	}

	// Define value as active picker value getter
	//FIXME: case of multiple pickers
	Object.defineProperty(self, 'value', {
		set: function (value) {
			var picker = this.getActivePicker();
			picker && (picker.value = value);
		},
		get: function () {
			var picker = this.getActivePicker();
			return picker && picker.value;
		}
	});

	if (self.aria) {
		//a11y
		//@ref http://www.w3.org/TR/wai-aria/roles#slider
		self.element.setAttribute('role', 'slider');
		target.setAttribute('aria-valuemax', self.max);
		target.setAttribute('aria-valuemin', self.min);
		target.setAttribute('aria-orientation', self.orientation);
		target.setAttribute('aria-atomic', true);

		//update controls
		target.setAttribute('aria-controls', self.pickers.map(
			function (item) {
				return item.element.id;
			}).join(' '));
	}

	//turn on events etc
	if (!self.element.hasAttribute('disabled')) self.enable();

	//emit callback
	self.emit('created');
}
function Slidy(target, options) {
	//force constructor
	if (!(this instanceof Slidy)) return new Slidy(target, options);

	var self = this;

	//ensure target & options
	if (!options) {
		if (target instanceof Element) {
			options = {};
		}
		else {
			options = target;
			target = doc.createElement('div');
		}
	}


	//get preferred element
	self.element = target;

	//adopt options
	extend(self, options);

	//calculate value & step
	//detect step automatically based on min/max range (1/100 by default)
	//native behaviour is always 1, so ignore it
	if (options.step === undefined) {
		self.step = detectStep(self.min, self.max);
	}

	//calc undefined valuea as a middle of range
	if (options.value === undefined) {
		self.value = detectValue(self.min, self.max);
	}

	//bind passed callbacks, if any
	if (options.created) on(self, 'created', options.created);

	//save refrence
	instancesCache.set(self.element, self);

	//generate id
	self.id = getUid();
	self.ns = 'slidy-' + self.id;
	if (!self.element.id) self.element.id = self.ns;

	//init instance
	self.element.classList.add('slidy');


	//create pickers, if passed a list
	self.pickers = [];
	if (isArray(options.pickers) && options.pickers.length) {
		options.pickers.forEach(function (opts) {
			self.addPicker(opts);
		});
	}
	//ensure at least one picker exists, if not passed in options separately
	else if (!options.hasOwnProperty('pickers')) {
		self.addPicker(options.pickers);
	}

	// Define value as active picker value getter
	//FIXME: case of multiple pickers
	Object.defineProperty(self, 'value', {
		set: function (value) {
			var picker = this.getActivePicker();
			picker && (picker.value = value);
		},
		get: function () {
			var picker = this.getActivePicker();
			return picker && picker.value;
		}
	});

	if (self.aria) {
		//a11y
		//@ref http://www.w3.org/TR/wai-aria/roles#slider
		self.element.setAttribute('role', 'slider');
		target.setAttribute('aria-valuemax', self.max);
		target.setAttribute('aria-valuemin', self.min);
		target.setAttribute('aria-orientation', self.orientation);
		target.setAttribute('aria-atomic', true);

		//update controls
		target.setAttribute('aria-controls', self.pickers.map(
			function (item) {
				return item.element.id;
			}).join(' '));
	}

	//turn on events etc
	if (!self.element.hasAttribute('disabled')) self.enable();

	//emit callback
	self.emit('created');
}
function Slidy ( target , options ) { //force constructor if ( ! ( this instanceof Slidy ) ) return new Slidy ( target , options ) ; var self = this ; //ensure target & options if ( ! options ) { if ( target instanceof Element ) { options = { } ; } else { options = target ; target = doc . createElement ( 'div' ) ; } } //get preferred element self . element = target ; //adopt options extend ( self , options ) ; //calculate value & step //detect step automatically based on min/max range (1/100 by default) //native behaviour is always 1, so ignore it if ( options . step === undefined ) { self . step = detectStep ( self . min , self . max ) ; } //calc undefined valuea as a middle of range if ( options . value === undefined ) { self . value = detectValue ( self . min , self . max ) ; } //bind passed callbacks, if any if ( options . created ) on ( self , 'created' , options . created ) ; //save refrence instancesCache . set ( self . element , self ) ; //generate id self . id = getUid ( ) ; self . ns = 'slidy-' + self . id ; if ( ! self . element . id ) self . element . id = self . ns ; //init instance self . element . classList . add ( 'slidy' ) ; //create pickers, if passed a list self . pickers = [ ] ; if ( isArray ( options . pickers ) && options . pickers . length ) { options . pickers . forEach ( function ( opts ) { self . addPicker ( opts ) ; } ) ; } //ensure at least one picker exists, if not passed in options separately else if ( ! options . hasOwnProperty ( 'pickers' ) ) { self . addPicker ( options . pickers ) ; } // Define value as active picker value getter //FIXME: case of multiple pickers Object . defineProperty ( self , 'value' , { set : function ( value ) { var picker = this . getActivePicker ( ) ; picker && ( picker . value = value ) ; } , get : function ( ) { var picker = this . getActivePicker ( ) ; return picker && picker . value ; } } ) ; if ( self . aria ) { //a11y //@ref http://www.w3.org/TR/wai-aria/roles#slider self . element . setAttribute ( 'role' , 'slider' ) ; target . setAttribute ( 'aria-valuemax' , self . max ) ; target . setAttribute ( 'aria-valuemin' , self . min ) ; target . setAttribute ( 'aria-orientation' , self . orientation ) ; target . setAttribute ( 'aria-atomic' , true ) ; //update controls target . setAttribute ( 'aria-controls' , self . pickers . map ( function ( item ) { return item . element . id ; } ) . join ( ' ' ) ) ; } //turn on events etc if ( ! self . element . hasAttribute ( 'disabled' ) ) self . enable ( ) ; //emit callback self . emit ( 'created' ) ; }
Create slider over a target
@constructor
Create slider over a target