Viewing File: /home/ubuntu/allinonecluster-landing/blog/wp-content/plugins/web-stories/assets/js/imgareaselect.js
(()=>{"use strict";!function(e){var t=Math.abs,o=Math.max,i=Math.ceil,n=Math.min,s=Math.round;function r(){return e("<div/>")}e.imgAreaSelect=function(c,d){var a,u,l,h,f,m,p,y,g,v,b,x,w,S,z,k,C,A,W,I,K,P,M,N,H,E,O,T,L,j,D,R=e(c),X=r(),Y=r(),$=r().add(r()).add(r()).add(r()),q=r().add(r()).add(r()).add(r()),B=e([]),Q={left:0,top:0},F={left:0,top:0},G=0,J="absolute",U={x1:0,y1:0,x2:0,y2:0,width:0,height:0},V=document.documentElement,Z=navigator.userAgent;function _(e){return e+Q.left-F.left}function ee(e){return e+Q.top-F.top}function te(e){return e-Q.left+F.left}function oe(e){return e-Q.top+F.top}function ie(e){return o(e.pageX||0,se(e).x)-F.left}function ne(e){return o(e.pageY||0,se(e).y)-F.top}function se(e){var t=e.originalEvent||{};return t.touches&&t.touches.length?{x:t.touches[0].pageX,y:t.touches[0].pageY}:{x:0,y:0}}function re(e){var t=e||x,o=e||w;return{x1:s(U.x1*t),y1:s(U.y1*o),x2:s(U.x2*t),y2:s(U.y2*o),width:s(U.x2*t)-s(U.x1*t),height:s(U.y2*o)-s(U.y1*o)}}function ce(e,t,o,i,n){var r=n||x,c=n||w;(U={x1:s(e/r||0),y1:s(t/c||0),x2:s(o/r||0),y2:s(i/c||0)}).width=U.x2-U.x1,U.height=U.y2-U.y1}function de(){a&&R.width()&&(Q={left:s(R.offset().left),top:s(R.offset().top)},f=i(R.innerWidth()),m=i(R.innerHeight()),p=i(R.innerWidth()),y=i(R.innerHeight()),Q.top+=y-m>>1,Q.left+=p-f>>1,z=s(d.minWidth/x)||0,k=s(d.minHeight/w)||0,C=s(n(d.maxWidth/x||1<<24,f)),A=s(n(d.maxHeight/w||1<<24,m)),"1.3.2"!=e().jquery||"fixed"!=J||V.getBoundingClientRect||(Q.top+=o(document.body.scrollTop,V.scrollTop),Q.left+=o(document.body.scrollLeft,V.scrollLeft)),F=/absolute|relative/.test(g.css("position"))?{left:s(g.offset().left)-g.scrollLeft(),top:s(g.offset().top)-g.scrollTop()}:"fixed"==J?{left:e(document).scrollLeft(),top:e(document).scrollTop()}:{left:0,top:0},l=_(0),h=ee(0),(U.x2>f||U.y2>m)&&ye())}function ae(t){if(I){switch(X.css({left:_(U.x1),top:ee(U.y1)}).add(Y).width(L=U.width).height(j=U.height),Y.add($).add(B).css({left:0,top:0}),$.width(o(L-$.outerWidth()+$.innerWidth(),0)).height(o(j-$.outerHeight()+$.innerHeight(),0)),e(q[0]).css({left:l,top:h,width:U.x1,height:m}),e(q[1]).css({left:l+U.x1,top:h,width:L,height:U.y1}),e(q[2]).css({left:l+U.x2,top:h,width:f-U.x2,height:m}),e(q[3]).css({left:l+U.x1,top:h+U.y2,width:L,height:m-U.y2}),L-=B.outerWidth(),j-=B.outerHeight(),B.length){case 8:e(B[4]).css({left:L>>1}),e(B[5]).css({left:L,top:j>>1}),e(B[6]).css({left:L>>1,top:j}),e(B[7]).css({top:j>>1});case 4:B.slice(1,3).css({left:L}),B.slice(2,4).css({top:j})}!1!==t&&(e.imgAreaSelect.onKeyPress!=Ce&&e(document).off(e.imgAreaSelect.keyPress,e.imgAreaSelect.onKeyPress),d.keys&&e(document).on(e.imgAreaSelect.keyPress,(function(){e.imgAreaSelect.onKeyPress=Ce}))),Ie&&$.outerWidth()-$.innerWidth()==2&&($.css("margin",0),setTimeout((function(){$.css("margin","auto")}),0))}}function ue(e){de(),ae(e),K=_(U.x1),P=ee(U.y1),M=_(U.x2),N=ee(U.y2)}function le(e,t){d.fadeSpeed?e.fadeOut(d.fadeSpeed,t):e.hide()}function he(e){var t=te(ie(e))-U.x1,o=oe(ne(e))-U.y1;D||(de(),D=!0,X.one("mouseout",(function(){D=!1}))),S="",d.resizable&&(o<=d.resizeMargin?S="n":o>=U.height-d.resizeMargin&&(S="s"),t<=d.resizeMargin?S+="w":t>=U.width-d.resizeMargin&&(S+="e")),X.css("cursor",S?S+"-resize":d.movable?"move":""),u&&u.toggle()}function fe(t){e("body").css("cursor",""),(d.autoHide||U.width*U.height==0)&&le(X.add(q),(function(){e(this).hide()})),e(document).off("mousemove touchmove",ge),X.on("mousemove touchmove",he),d.onSelectEnd(c,re())}function me(t){return"mousedown"==t.type&&1!=t.which||(he(t),de(),S?(e("body").css("cursor",S+"-resize"),K=_(U[/w/.test(S)?"x2":"x1"]),P=ee(U[/n/.test(S)?"y2":"y1"]),e(document).on("mousemove touchmove",ge).one("mouseup touchend",fe),X.off("mousemove touchmove",he)):d.movable?(v=l+U.x1-ie(t),b=h+U.y1-ne(t),X.off("mousemove touchmove",he),e(document).on("mousemove touchmove",be).one("mouseup touchend",(function(){d.onSelectEnd(c,re()),e(document).off("mousemove touchmove",be),X.on("mousemove touchmove",he)}))):R.mousedown(t)),!1}function pe(e){W&&(e?(M=o(l,n(l+f,K+t(N-P)*W*(M>K||-1))),N=s(o(h,n(h+m,P+t(M-K)/W*(N>P||-1)))),M=s(M)):(N=o(h,n(h+m,P+t(M-K)/W*(N>P||-1))),M=s(o(l,n(l+f,K+t(N-P)*W*(M>K||-1)))),N=s(N)))}function ye(){K=n(K,l+f),P=n(P,h+m),t(M-K)<z&&((M=K-z*(M<K||-1))<l?K=l+z:M>l+f&&(K=l+f-z)),t(N-P)<k&&((N=P-k*(N<P||-1))<h?P=h+k:N>h+m&&(P=h+m-k)),M=o(l,n(M,l+f)),N=o(h,n(N,h+m)),pe(t(M-K)<t(N-P)*W),t(M-K)>C&&(M=K-C*(M<K||-1),pe()),t(N-P)>A&&(N=P-A*(N<P||-1),pe(!0)),U={x1:te(n(K,M)),x2:te(o(K,M)),y1:oe(n(P,N)),y2:oe(o(P,N)),width:t(M-K),height:t(N-P)},ae(),d.onSelectChange(c,re())}function ge(e){return M=/w|e|^$/.test(S)||W?ie(e):_(U.x2),N=/n|s|^$/.test(S)||W?ne(e):ee(U.y2),ye(),!1}function ve(t,o){M=(K=t)+U.width,N=(P=o)+U.height,e.extend(U,{x1:te(K),y1:oe(P),x2:te(M),y2:oe(N)}),ae(),d.onSelectChange(c,re())}function be(e){return K=o(l,n(v+ie(e),l+f-U.width)),P=o(h,n(b+ne(e),h+m-U.height)),ve(K,P),e.preventDefault(),!1}function xe(){e(document).off("mousemove touchmove",xe),de(),M=K,N=P,ye(),S="",q.is(":visible")||X.add(q).hide().fadeIn(d.fadeSpeed||0),I=!0,e(document).off("mouseup touchend",we).on("mousemove touchmove",ge).one("mouseup touchend",fe),X.off("mousemove touchmove",he),d.onSelectStart(c,re())}function we(){e(document).off("mousemove touchmove",xe).off("mouseup touchend",we),le(X.add(q)),ce(te(K),oe(P),te(K),oe(P)),this instanceof e.imgAreaSelect||(d.onSelectChange(c,re()),d.onSelectEnd(c,re()))}function Se(t){return t.which>1||q.is(":animated")||(de(),v=K=ie(t),b=P=ne(t),e(document).on({"mousemove touchmove":xe,"mouseup touchend":we})),!1}function ze(){ue(!1)}function ke(){a=!0,We(d=e.extend({classPrefix:"imgareaselect",movable:!0,parent:"body",resizable:!0,resizeMargin:10,onInit:function(){},onSelectStart:function(){},onSelectChange:function(){},onSelectEnd:function(){}},d)),X.add(q).css({visibility:""}),d.show&&(I=!0,de(),ae(),X.add(q).hide().fadeIn(d.fadeSpeed||0)),setTimeout((function(){d.onInit(c,re())}),0)}var Ce=function(e){var t,i,s=d.keys,r=e.keyCode;if(t=isNaN(s.alt)||!e.altKey&&!e.originalEvent.altKey?!isNaN(s.ctrl)&&e.ctrlKey?s.ctrl:!isNaN(s.shift)&&e.shiftKey?s.shift:isNaN(s.arrows)?10:s.arrows:s.alt,"resize"==s.arrows||"resize"==s.shift&&e.shiftKey||"resize"==s.ctrl&&e.ctrlKey||"resize"==s.alt&&(e.altKey||e.originalEvent.altKey)){switch(r){case 37:t=-t;case 39:i=o(K,M),K=n(K,M),M=o(i+t,K),pe();break;case 38:t=-t;case 40:i=o(P,N),P=n(P,N),N=o(i+t,P),pe(!0);break;default:return}ye()}else switch(K=n(K,M),P=n(P,N),r){case 37:ve(o(K-t,l),P);break;case 38:ve(K,o(P-t,h));break;case 39:ve(K+n(t,f-te(M)),P);break;case 40:ve(K,P+n(t,m-oe(N)));break;default:return}return!1};function Ae(e,t){for(var o in t)void 0!==d[o]&&e.css(t[o],d[o])}function We(t){if(t.parent&&(g=t.parent.append(X.add(q))),e.extend(d,t),de(),null!=t.handles){for(B.remove(),B=e([]),O=t.handles?"corners"==t.handles?4:8:0;O--;)B=B.add(r());B.addClass(d.classPrefix+"-handle").css({position:"absolute",fontSize:"0",zIndex:G+1||1}),!parseInt(B.css("width"))>=0&&B.width(5).height(5),(T=d.borderWidth)&&B.css({borderWidth:T,borderStyle:"solid"}),Ae(B,{borderColor1:"border-color",borderColor2:"background-color",borderOpacity:"opacity"})}for(x=d.imageWidth/f||1,w=d.imageHeight/m||1,null!=t.x1&&(ce(t.x1,t.y1,t.x2,t.y2),t.show=!t.hide),t.keys&&(d.keys=e.extend({shift:1,ctrl:"resize"},t.keys)),q.addClass(d.classPrefix+"-outer"),Y.addClass(d.classPrefix+"-selection"),O=0;O++<4;)e($[O-1]).addClass(d.classPrefix+"-border"+O);Ae(Y,{selectionColor:"background-color",selectionOpacity:"opacity"}),Ae($,{borderOpacity:"opacity",borderWidth:"border-width"}),Ae(q,{outerColor:"background-color",outerOpacity:"opacity"}),(T=d.borderColor1)&&e($[0]).css({borderStyle:"solid",borderColor:T}),(T=d.borderColor2)&&e($[1]).css({borderStyle:"dashed",borderColor:T}),X.append(Y.add($).add(u)).append(B),Ie&&((T=(q.css("filter")||"").match(/opacity=(\d+)/))&&q.css("opacity",T[1]/100),(T=($.css("filter")||"").match(/opacity=(\d+)/))&&$.css("opacity",T[1]/100)),t.hide?le(X.add(q)):t.show&&a&&(I=!0,X.add(q).fadeIn(d.fadeSpeed||0),ue()),W=(E=(d.aspectRatio||"").split(/:/))[0]/E[1],R.add(q).off("mousedown",Se),d.disable||!1===d.enable?(X.off({"mousemove touchmove":he,"mousedown touchstart":me}),e(window).off("resize",ze)):((d.enable||!1===d.disable)&&((d.resizable||d.movable)&&X.on({"mousemove touchmove":he,"mousedown touchstart":me}),e(window).on("resize",ze)),d.persistent||R.add(q).on("mousedown touchstart",Se)),d.enable=d.disable=void 0}this.remove=function(){We({disable:!0}),X.add(q).remove()},this.getOptions=function(){return d},this.setOptions=We,this.getSelection=re,this.setSelection=ce,this.cancelSelection=we,this.update=ue;var Ie=(/msie ([\w.]+)/i.exec(Z)||[])[1],Ke=/opera/i.test(Z),Pe=/webkit/i.test(Z)&&!/chrome/i.test(Z);for(H=R;H.length;)G=o(G,isNaN(H.css("z-index"))?G:H.css("z-index")),"fixed"==H.css("position")&&(J="fixed"),H=H.parent(":not(body)");G=d.zIndex||G,Ie&&R.attr("unselectable","on"),e.imgAreaSelect.keyPress=Ie||Pe?"keydown":"keypress",Ke&&(u=r().css({width:"100%",height:"100%",position:"absolute",zIndex:G+2||2})),X.add(q).css({visibility:"hidden",position:J,overflow:"hidden",zIndex:G||"0"}),X.css({zIndex:G+2||2}),Y.add($).css({position:"absolute",fontSize:"0"}),c.complete||"complete"==c.readyState||!R.is("img")?ke():R.one("load",ke),!a&&Ie&&Ie>=7&&(c.src=c.src)},e.fn.imgAreaSelect=function(t){return t=t||{},this.each((function(){e(this).data("imgAreaSelect")?t.remove?(e(this).data("imgAreaSelect").remove(),e(this).removeData("imgAreaSelect")):e(this).data("imgAreaSelect").setOptions(t):t.remove||(void 0===t.enable&&void 0===t.disable&&(t.enable=!0),e(this).data("imgAreaSelect",new e.imgAreaSelect(this,t)))})),t.instance?e(this).data("imgAreaSelect"):this}}(jQuery)})();
Back to Directory
File Manager