abchospitality/old/wp-includes/js/imgareaselect/jquery.imgareaselect.min.js

1 line
9.5 KiB
JavaScript
Raw Normal View History

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