text: (function(e,f){function n(a){var b=a.originalEvent;return b.touches&&b.touches.length?b.touches[0].pageX:b.changedTouches&&b.changedTouches.length?b.changedTouches[0].pageX:a.pageX}function l(a,b,d){return(a=a.attr(d)||a.data("quinn-"+d))?parseFloat(a):b.options[d]}function c(a,b){var d;f.bindAll(this,"clickBar","startDrag","drag","endDrag","handleKeyboardEvent","enableKeyboardEvents","disableKeyboardEvents");this.wrapper=a;this.options=d=f.extend({},c.defaults,b);this.callbacks={};this.disabled=
  !1;this.previousValue=this.activeHandle=null;a.is("input")&&this.enhance(a);var h=d.drawTo,g=d.min,e=d.max,h=h||{};this.drawTo={left:f.has(h,"left")?h.left:g,right:f.has(h,"right")?h.right:e};this.model=new m(this,this.options.strict);this.renderer=new this.options.renderer(this);this.keyFloodTimer=null;this.wrapperOffset=this.wrapperWidth=0;this.on("setup",d.setup);this.on("begin",d.begin);this.on("drag",d.drag);this.on("change",d.change);this.on("abort",d.abort);f.isFunction(this.renderer.render)&&
  this.renderer.render();!0===d.disable&&this.disable();this.trigger("setup",this.model.value)}function m(a,b){var d,h,c;this.options=d=a.options;this.step=d.step;this.only=d.only;this.values=[];this.minimum=this.roundToStep(d.min);this.maximum=this.roundToStep(d.max);this.minimum<d.min&&(this.minimum+=this.step);this.maximum>d.max&&(this.maximum-=this.step);d=void 0===d.value||null===d.value?this.minimum:f.isArray(d.value)?d.value:[d.value];c=0;for(h=d.length;c<h;c++)this.values[c]=null;this.setValue(d,
  b)}var p="mousemove",q="mousedown",r="mouseup",s=!1;"ontouchstart"in document.documentElement&&(p="touchmove",q="touchstart",r="touchend",s=!0);c.VERSION="1.1.0";c.prototype.on=function(a,b){f.isString(a)&&f.isFunction(b)&&(this.callbacks[a]||(this.callbacks[a]=[]),this.callbacks[a].push(b));return this};c.prototype.trigger=function(a,b){var d=this.callbacks[a]||[],h=0,c;void 0===b&&(b=this.value);for(;c=d[h++];)if(!1===c(b,this))return!1;return!0};c.prototype.enable=function(){this.disabled&&(this.disabled=
  !1,this.trigger("enabled"))};c.prototype.disable=function(){this.disabled||(this.disabled=!0,this.trigger("disabled"))};c.prototype.setValue=function(a,b,d){this.start()&&(!1!==this.setTentativeValue(a,b,d)?this.resolve():this.reject());return this.model.value};c.prototype.setTentativeValue=function(a,b,d){var c=this.model.value,g=null,e=null,k;if(void 0===a||null===a)return!1;if(1<this.model.values.length&&f.isNumber(a)){if(null===this.activeHandle)return!1;k=this.model.sanitizeValue(a);a=f.clone(this.model.values);
  g=a[this.activeHandle-1];e=a[this.activeHandle+1];null!==g&&k<=g&&(k=g+this.options.step);null!==e&&k>=e&&(k=e-this.options.step);a[this.activeHandle]=k}a=this.model.setValue(a);if(!1===a||!d&&!this.trigger("drag",a))return this.model.setValue(c),!1!==a&&this.trigger("drag",c),!1;this.trigger("redraw",b);return a};c.prototype.stepUp=function(a,b,d){return 1<this.model.values.length?this.model.value:f.bind(d?this.setTentativeValue:this.setValue,this)(this.model.value+this.model.step*(a||1),b)};c.prototype.stepDown=
  function(a,b,d){return this.stepUp(-(a||1),b,d)};c.prototype.start=function(){if(!0===this.disabled||!this.trigger("begin"))return!1;this.previousValue=this.model.value;this.wrapperWidth=this.wrapper.width();this.wrapperOffset=this.wrapper.offset().left;return!0};c.prototype.resolve=function(){this.deactivateActiveHandle();if(f.isEqual(this.previousValue,this.model.value))return this.reject(),!1;if(!this.trigger("change",this.model.value))return this.setTentativeValue(this.previousValue),this.reject(),
  !1;this.previousValue=null};c.prototype.reject=function(){this.previousValue=null;this.deactivateActiveHandle();return this.trigger("abort")};c.prototype.valueFromMouse=function(a){a=this.positionFromMouse(a);return this.drawTo.left+(this.drawTo.right-this.drawTo.left)*a};c.prototype.positionFromMouse=function(a){var b=this.wrapperOffset+this.wrapperWidth;return(a<this.wrapperOffset?0:a>b?this.wrapperWidth:a-this.wrapperOffset)/this.wrapperWidth};c.prototype.startDrag=function(a,b){if(!s&&1!==a.which)return!0;
  if(!b&&!this.start())return!1;this.activateHandleWithEvent(a);e(document).on(r+".quinn",this.endDrag).on(p+".quinn",this.drag).on("mouseenter.quinn",this.endDrag);return!1};c.prototype.drag=function(a){this.setTentativeValue(this.valueFromMouse(n(a)),!1);return a.preventDefault()};c.prototype.endDrag=function(a){e(document).off(r+".quinn").off(p+".quinn").off("mouseenter.quinn");this.resolve();return a.preventDefault()};c.prototype.clickBar=function(a){if(!s&&1!==a.which)return!0;this.start()&&(this.activateHandleWithEvent(a),
  this.setTentativeValue(this.valueFromMouse(n(a))),this.startDrag(a,!0));return a.preventDefault()};c.prototype.activateHandleWithEvent=function(a){var b;if(this.activeHandle)return!1;b=this.valueFromMouse(n(a));a=f.min(this.model.values,function(a){return Math.abs(a-b)});a=f.indexOf(this.model.values,a);-1!==a&&(this.activeHandle=a,this.trigger("handleOn",this.activeHandle))};c.prototype.deactivateActiveHandle=function(){null!==this.activeHandle&&-1!==this.activeHandle&&(this.trigger("handleOff",
  this.activeHandle),this.activeHandle=null)};c.prototype.enableKeyboardEvents=function(a){e(a.target).on("keydown",this.handleKeyboardEvent);e(a.target).on("keyup",this.handleKeyboardEvent)};c.prototype.disableKeyboardEvents=function(a){e(a.target).off("keydown",this.handleKeyboardEvent);e(a.target).off("keyup",this.handleKeyboardEvent)};c.prototype.handleKeyboardEvent=function(a){if("keydown"===a.type){if(this.keyFloodTimer&&(window.clearTimeout(this.keyFloodTimer),this.keyFloodTimer=null),null==
  this.previousValue&&!this.start())return!1}else if("keyup"===a.type)return null!=this.previousValue&&(this.options.keyFloodWait?this.keyFloodTimer=window.setTimeout(f.bind(this.resolve,this),this.options.keyFloodWait):this.resolve()),!0;switch(a.which){case 33:this.stepUp(10,!1,!0);break;case 34:this.stepDown(10,!1,!0);break;case 37:case 40:a.metaKey?this.setTentativeValue(this.model.minimum,!1):this.stepDown(a.altKey?10:1,!1,!0);break;case 39:case 38:a.metaKey?this.setTentativeValue(this.model.maximum,
  !1):this.stepUp(a.altKey?10:1,!1,!0);break;default:return!0}a.preventDefault()};c.prototype.enhance=function(a){this.options.disabled=a.attr("disabled");this.options.step=l(a,this,"step");this.options.value=l(a,this,"value");this.options.min=l(a,this,"min");this.options.max=l(a,this,"max");this.wrapper=e("<div />").css({width:a.outerWidth(),margin:a.css("margin"),display:"inline-block"}).insertAfter(a.hide());this.on("change",function(b){a.val(b)});a.on("change",f.bind(function(){this.setValue(a.val())},
  this))};m.prototype.setValue=function(a,b){var d=this.values,c,g;a=f.isArray(a)?f.clone(a):[a];g=0;for(c=a.length;g<c;g++)a[g]=this.sanitizeValue(a[g],b);if(f.isEqual(a,d))return!1;this.value=this.values=a;1===this.values.length&&(this.value=a[0]);return this.value};m.prototype.roundToStep=function(a){var b=1/this.step,b=Math.round(a*b)/b;f.isArray(this.only)&&(b=f.min(this.only,function(b){return Math.abs(b-a)}));return b>this.maximum?b-this.step:b<this.minimum?b+this.step:b};m.prototype.sanitizeValue=
  function(a,b){!1!==b&&(a=this.roundToStep(a));return a>this.maximum?this.maximum:a<this.minimum?this.minimum:a};c.Renderer=function(a){f.bindAll(this,"render","redraw");var b=this;this.quinn=a;this.model=a.model;this.wrapper=a.wrapper;this.options=a.options;this.handles=[];this.lastDraw=[];a.on("redraw",this.redraw);a.on("handleOn",function(a){b.handles[a].addClass("active")});a.on("handleOff",function(a){b.handles[a].removeClass("active")});a.on("enabled",function(){b.wrapper.removeClass("disabled");
  1!==b.options.disabledOpacity&&b.wrapper.css("opacity",1)});a.on("disabled",function(){b.wrapper.addClass("disabled");1!==b.options.disabledOpacity&&b.wrapper.css("opacity",b.options.disabledOpacity)})};c.Renderer.prototype.render=function(){function a(a){a.append(e('<div class="left" />'));a.append(e('<div class="main" />'));a.append(e('<div class="right" />'))}var b,d;this.width=this.wrapper.width();this.bar=e('<div class="bar" />');this.deltaBar=e('<div class="delta-bar" />');1<this.model.values.length&&
  this.wrapper.addClass("multiple");a(this.bar);2>=this.model.values.length&&(a(this.deltaBar),this.bar.append(this.deltaBar));this.wrapper.html(this.bar);this.wrapper.addClass("quinn");b=0;for(d=this.model.values.length;b<d;b++)this.handles[b]=e('<span class="handle" tabindex="0"></span>'),this.handles[b].on(q,this.quinn.startDrag),2>this.quinn.model.values.length&&(this.handles[b].on("focus",this.quinn.enableKeyboardEvents),this.handles[b].on("blur",this.quinn.disableKeyboardEvents)),this.bar.append(this.handles[b]);
  this.wrapper.on(q,this.quinn.clickBar);this.barHeight=this.bar.height();this.handleOverhang=parseInt(this.handles[0].css("margin-left"),10)+parseInt(this.handles[0].css("margin-right"),10);this.redraw(!1)};c.Renderer.prototype.redraw=function(a){var b=this;!1!==a&&(a=!0);f.each(this.model.values,function(d,c){var g,e;if(d===b.lastDraw[c])return!0;g=b.handles[c].stop();e=b.position(d)+"px";a&&b.options.effects?g.animate({left:e},{duration:b.options.effectSpeed,step:b.redrawDeltaBarInStep(g)}):(g.css("left",
  e),b.redrawDeltaBar(d,g))});this.lastDraw=f.clone(this.model.values)};c.Renderer.prototype.redrawDeltaBar=function(a,b){var d=null,c=null,e=parseInt(b.position().left,10)+this.barHeight;this.deltaBar.stop(!0);1<this.model.values.length?b?b===this.handles[0]?d=e:c=e:(d=a[0],c=a[1]):0>a?(d=e,c=this.position(0,!0)):(c=e,d=this.position(0,!0));null!==d&&this.deltaBar.css("left",d);null!==c&&(c=this.width-c,this.deltaBar.css("right",c))};c.Renderer.prototype.redrawDeltaBarInStep=function(a){if(!this.deltaBar)return function(){};
  var b=this.quinn.drawTo.left,d=this.quinn.drawTo.right,c=Math.ceil(this.deltaBar.height()/2),e=this;return function(f){f=(f+c)/e.width;e.redrawDeltaBar(f*(d-b)+b,a);return!0}};c.Renderer.prototype.position=function(a,b){var d=this.quinn.drawTo.right-this.quinn.drawTo.left,c=this.width;b||(c-=this.handles[0].width()+this.handleOverhang);d=(a-this.quinn.drawTo.left)/d*c;return 0>d?0:d>c?c:Math.round(d)};c.defaults={min:0,max:100,drawTo:null,step:1,value:null,strict:!0,only:null,disable:!1,disabledOpacity:0.5,
  width:null,handleWidth:null,drag:null,change:null,setup:null,renderer:c.Renderer,keyFloodWait:!1,effectSpeed:"fast",effects:!0};e.fn.quinn=function(a){return e.each(this,function(){new c(e(this),a)})};e.Quinn=c})(jQuery,_);
  