-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathinputcircleslider-0.1.min.js
More file actions
1 lines (1 loc) · 2.19 KB
/
inputcircleslider-0.1.min.js
File metadata and controls
1 lines (1 loc) · 2.19 KB
1
(function(a){a.fn.iCircleSlider=function(p){var c=jQuery.extend({id:"",dialwidth:50,degbound:45},p);return this.each(function(){c.id="#"+this.id;var f=a(c.id).val(),m=a(c.id).offset(),n=a(c.id).outerHeight(),g=0,h=0,j=!1,e=!1,k=g,l=h,b=0;a(c.id).on("click",function(){if(!1==e){f=a(c.id).val();f=c.degbound*Math.round(f/c.degbound);m=a(c.id).offset();n=a(c.id).outerHeight();var d=a("<div class='circlecontainer' ></div>").css({top:m.top+n,left:m.left,position:"absolute"}).append("<div id='dial_0'>0</div><div id='dial_90'>90</div><div id='dial_180'>180</div><div id='dial_270'>270</div><div id='r_pt'></div><div id='dial'><div id='dial_l' > </div></div>"); a("body").append(d);d.attr("unselectable","on").css("UserSelect","none").css("MozUserSelect","none");calct=180-f;a("#dial").css({transform:"rotate("+calct+"deg)","-ms-transform":"rotate("+calct+"deg)","-webkit-transform":"rotate("+calct+"deg)","-o-transform":"rotate("+calct+"deg)","-moz-transform":"rotate("+calct+"deg)"});d.mousedown(function(d){var e=a("#r_pt").offset();k=e.left-g;l=e.top-h;b=Math.round(Math.atan2(l,k)*(180/Math.PI));a("#dial").css({transform:"rotate("+b+"deg)","-ms-transform":"rotate("+ b+"deg)","-webkit-transform":"rotate("+b+"deg)","-o-transform":"rotate("+b+"deg)","-moz-transform":"rotate("+b+"deg)"});b=c.degbound*Math.round(b/c.degbound);calct=180-b;a(c.id).val(calct).change();j=!0;d.preventDefault()}).mouseup(function(a){a.stopPropagation();j=!1});e=!0}return!1}).on("keyup",function(){!0==e&&(calct=180-a(c.id).val(),a("#dial").css({transform:"rotate("+calct+"deg)","-ms-transform":"rotate("+calct+"deg)","-webkit-transform":"rotate("+calct+"deg)","-o-transform":"rotate("+calct+ "deg)","-moz-transform":"rotate("+calct+"deg)"}));return!1});a(document).mousemove(function(d){!0==e&&(g=d.pageX,h=d.pageY,j&&(d=a("#r_pt").offset(),k=d.left-g,l=d.top-h,b=Math.round(Math.atan2(l,k)*(180/Math.PI)),a("#dial").css({transform:"rotate("+b+"deg)","-ms-transform":"rotate("+b+"deg)","-webkit-transform":"rotate("+b+"deg)","-o-transform":"rotate("+b+"deg)","-moz-transform":"rotate("+b+"deg)"}),b=c.degbound*Math.round(b/c.degbound),calct=180-b,a(c.id).val(calct).change()))}).mouseup(function(){j= !1;e&&(e=!1,a(".circlecontainer").remove())})})}})(jQuery);