-
Notifications
You must be signed in to change notification settings - Fork 9
/
nativemultiple.jquery.min.js
1 lines (1 loc) · 1.71 KB
/
nativemultiple.jquery.min.js
1
(function(d){var t={stylesheet:"",tooltip:!1,onCreate:{},onChange:{},vertical:!1},e=!0,f=0,g={init:function(a){a=d.extend(!0,{},t,a);d(this).each(function(){var b=d(this),c=b.attr("value"),m=0,n=0,c=void 0!=c?c.split(","):["0",b.attr("max")];void 0==c[1]&&(c[1]=c[0]);var m=c[0],n=c[1],h=d("<div></div>").addClass(a.stylesheet).addClass("nativeMultiple");d("<div class='nativeMultiple-one'><div></div></div>").appendTo(h);b.wrap(h);var h=b.parents(".nativeMultiple"),p=b.parents(".nativeMultiple-one"), q=d("<div class='nativeMultiple-two'></div>").appendTo(h),k=b.clone().removeAttr("id").removeAttr("name").appendTo(q).wrap("<div></div>"),q=h.width(),l=(q-60)/parseFloat(b.attr("max")),g=0,r=0;h.find("div > div").width(q);b.on("touchstart mousedown",function(){e=!0}).on("touchmove mousemove",function(b){e&&(f=this.value*l,r=k.val(),parseFloat(this.value)>parseFloat(r)&&(k.val(this.value),p.width(f),n=this.value),m!=this.value&&(m=this.value,a.onSlide(this.value,r)))}).on("touchend mouseup",function(){f= this.value*l;e=!1;m=this.value;a.onChange(this.value,k.val())});k.on("touchstart mousedown",function(){console.log("strt");e=!0}).on("touchmove mousemove",function(c){e&&(f=this.value*l,g=b.val(),p.width(f),parseFloat(this.value)<parseFloat(g)&&b.val(this.value),n!=this.value&&(n=this.value,a.onSlide(g,this.value)))}).on("touchend mouseup",function(){f=this.value*l;e=!1;p.width(f);a.onChange(b.val(),this.value)});k.val(c[1]);b.val(c[0]);p.width(c[1]*l);e=!1});a.onCreate();return this}};d.fn.nativeMultiple= function(a){if(g[a])return g[a].apply(this,Array.prototype.slice.call(arguments,1));if("object"!==typeof a&&a)d.error("Method "+a+" does not exist on jQuery.nativeMultiple");else return g.init.apply(this,arguments)}})(jQuery);