View file aio-radio-station-player-1.14/assets/js/jquery.imagecrop.min.js

File size: 1.31Kb
!function(t){t.fn.extend({imagearea:function(e,i){t(this).unbind("mousemove"),t(this).unbind("mousedown"),t(this).unbind("mouseup"),defaults={width:120,height:120};var i=t.extend(defaults,i),h=t('<img src="'+e+'" style="cursor: move;">');t(this).html(h).css({width:i.width,height:i.height});var n=h.width()/(h.height()/i.height);h.attr(n>i.width?{width:"auto",height:i.height}:{height:"auto",width:i.width});var e={width:h.width(),height:h.height()},o=!1,a=0,s=0,f=0,u=0,d=t(this),r=t('[name="cropX"]'),c=t('[name="cropY"]'),g={left:e.width-i.width,top:e.height-i.height};t(d).on("mousedown",function(t){s=f+(d.offset().left+t.pageX),a=u+(d.offset().top+t.pageY),t.originalEvent.preventDefault(),o=!0}),t(document).on("mousemove",function(e){if(o){var i=s-(d.offset().left+e.pageX),h=a-(d.offset().top+e.pageY);i<=g.left&&i>=0&&(t(d).find("img").css("left",-1*i),f=i),h<=g.top&&h>=0&&(t(d).find("img").css("top",-1*h),u=h),c.val(u),r.val(f)}}),t(document).mouseup(function(){o&&(t(d).unbind("mousemove"),o=!1)}),t(document).on("keydown",function(e){switch(e.which){case 37:var i=f-1;break;case 39:var i=f+1;break;case 38:var h=u-1;break;case 40:var h=u+1;break;default:return}i<=g.left&&i>=0&&(t(d).find("img").css("left",-1*i),f=i),h<=g.top&&h>=0&&(t(d).find("img").css("top",-1*h),u=h),c.val(u),r.val(f),e.preventDefault()})}})}(jQuery);