KOTH_wordpress/wp_data/wp-includes/js/imgareaselect/jquery.imgareaselect.min.js

1 line
9.5 KiB
JavaScript
Raw Normal View History

2023-02-19 18:03:46 -05:00
!function(we){var Se=Math.abs,ze=Math.max,ke=Math.min,Ce=Math.round;function Ae(){return we("<div/>")}we.imgAreaSelect=function(o,n){var T,L,r,c,d,a,t,j,D,R,X,i,Y,$,q,B,s,Q,u,l,h,f,F,m,p,y,g,G,v=we(o),b=Ae(),x=Ae(),w=Ae().add(Ae()).add(Ae()).add(Ae()),S=Ae().add(Ae()).add(Ae()).add(Ae()),z=we([]),k={left:0,top:0},C={left:0,top:0},A=0,J="absolute",W={x1:0,y1:0,x2:0,y2:0,width:0,height:0},U=document.documentElement,V=navigator.userAgent;function I(e){return e+k.left-C.left}function K(e){return e+k.top-C.top}function P(e){return e-k.left+C.left}function N(e){return e-k.top+C.top}function Z(e){return ze(e.pageX||0,ee(e).x)-C.left}function _(e){return ze(e.pageY||0,ee(e).y)-C.top}function ee(e){e=e.originalEvent||{};return e.touches&&e.touches.length?{x:e.touches[0].pageX,y:e.touches[0].pageY}:{x:0,y:0}}function H(e){var t=e||R,e=e||X;return{x1:Ce(W.x1*t),y1:Ce(W.y1*e),x2:Ce(W.x2*t),y2:Ce(W.y2*e),width:Ce(W.x2*t)-Ce(W.x1*t),height:Ce(W.y2*e)-Ce(W.y1*e)}}function te(e,t,o,i,s){var n=s||R,s=s||X;(W={x1:Ce(e/n||0),y1:Ce(t/s||0),x2:Ce(o/n||0),y2:Ce(i/s||0)}).width=W.x2-W.x1,W.height=W.y2-W.y1}function M(){T&&v.width()&&(k={left:Ce(v.offset().left),top:Ce(v.offset().top)},d=v.innerWidth(),a=v.innerHeight(),k.top+=v.outerHeight()-a>>1,k.left+=v.outerWidth()-d>>1,Y=Ce(n.minWidth/R)||0,$=Ce(n.minHeight/X)||0,q=Ce(ke(n.maxWidth/R||1<<24,d)),B=Ce(ke(n.maxHeight/X||1<<24,a)),"1.3.2"!=we().jquery||"fixed"!=J||U.getBoundingClientRect||(k.top+=ze(document.body.scrollTop,U.scrollTop),k.left+=ze(document.body.scrollLeft,U.scrollLeft)),C=/absolute|relative/.test(t.css("position"))?{left:Ce(t.offset().left)-t.scrollLeft(),top:Ce(t.offset().top)-t.scrollTop()}:"fixed"==J?{left:we(document).scrollLeft(),top:we(document).scrollTop()}:{left:0,top:0},r=I(0),c=K(0),(W.x2>d||W.y2>a)&&de())}function oe(e){if(Q){switch(b.css({left:I(W.x1),top:K(W.y1)}).add(x).width(y=W.width).height(g=W.height),x.add(w).add(z).css({left:0,top:0}),w.width(ze(y-w.outerWidth()+w.innerWidth(),0)).height(ze(g-w.outerHeight()+w.innerHeight(),0)),we(S[0]).css({left:r,top:c,width:W.x1,height:a}),we(S[1]).css({left:r+W.x1,top:c,width:y,height:W.y1}),we(S[2]).css({left:r+W.x2,top:c,width:d-W.x2,height:a}),we(S[3]).css({left:r+W.x1,top:c+W.y2,width:y,height:a-W.y2}),y-=z.outerWidth(),g-=z.outerHeight(),z.length){case 8:we(z[4]).css({left:y>>1}),we(z[5]).css({left:y,top:g>>1}),we(z[6]).css({left:y>>1,top:g}),we(z[7]).css({top:g>>1});case 4:z.slice(1,3).css({left:y}),z.slice(2,4).css({top:g})}!1!==e&&(we.imgAreaSelect.onKeyPress!=ge&&we(document).off(we.imgAreaSelect.keyPress,we.imgAreaSelect.onKeyPress),n.keys&&we(document).on(we.imgAreaSelect.keyPress,function(){we.imgAreaSelect.onKeyPress=ge})),O&&w.outerWidth()-w.innerWidth()==2&&(w.css("margin",0),setTimeout(function(){w.css("margin","auto")},0))}}function ie(e){M(),oe(e),u=I(W.x1),l=K(W.y1),h=I(W.x2),f=K(W.y2)}function se(e,t){n.fadeSpeed?e.fadeOut(n.fadeSpeed,t):e.hide()}function E(e){var t=P(Z(e))-W.x1,e=N(_(e))-W.y1;G||(M(),G=!0,b.one("mouseout",function(){G=!1})),i="",n.resizable&&(e<=n.resizeMargin?i="n":e>=W.height-n.resizeMargin&&(i="s"),t<=n.resizeMargin?i+="w":t>=W.width-n.resizeMargin&&(i+="e")),b.css("cursor",i?i+"-resize":n.movable?"move":""),L&&L.toggle()}function ne(e){we("body").css("cursor",""),!n.autoHide&&W.width*W.height!=0||se(b.add(S),function(){we(this).hide()}),we(document).off("mousemove touchmove",ae),b.on("mousemove touchmove",E),n.onSelectEnd(o,H())}function re(e){return"mousedown"==e.type&&1!=e.which||(E(e),M(),i?(we("body").css("cursor",i+"-resize"),u=I(W[/w/.test(i)?"x2":"x1"]),l=K(W[/n/.test(i)?"y2":"y1"]),we(document).on("mousemove touchmove",ae).one("mouseup touchend",ne),b.off("mousemove touchmove",E)):n.movable?(j=r+W.x1-Z(e),D=c+W.y1-_(e),b.off("mousemove touchmove",E),we(document).on("mousemove touchmove",le).one("mouseup touchend",function(){n.onSelectEnd(o,H()),we(document).off("mousemove touchmove",le),b.on("mousemove touchmove",E)})):v.mousedown(e)),!1}function ce(e){s&&(e?(h=ze(r,ke(r+d,u+Se(f-l)*s*(u<h||-1))),f=Ce(ze(c,ke(c+a,l+Se(h-u)/s*(l<f||-1)))),h=Ce(h)):(f=ze(c,ke(c+a,l+Se(h-u