rumine-web/static/wagtailimages/js/vendor/jquery.Jcrop.min.js

1 line
15 KiB
JavaScript
Raw Normal View History

2024-03-13 07:49:06 +01:00
!function(e){e.Jcrop=function(t,n){function o(e){return Math.round(e)+"px"}function r(e){return M.baseClass+"-"+e}function a(){return e.fx.step.hasOwnProperty("backgroundColor")}function i(t){var n=e(t).offset();return[n.left,n.top]}function s(e){return[e.pageX-z[0],e.pageY-z[1]]}function c(t){"object"!=typeof t&&(t={}),M=e.extend(M,t),e.each(["onChange","onSelect","onRelease","onDblClick"],(function(e,t){"function"!=typeof M[t]&&(M[t]=function(){})}))}function u(e,t,n){if(z=i(P),re.setCursor("move"===e?e:e+"-resize"),"move"===e)return re.activateHandlers(function(e){var t=e;return ae.watchKeys(),function(e){te.moveOffset([e[0]-t[0],e[1]-t[1]]),t=e,oe.update()}}(t),g,n);var o=te.getFixed(),r=l(e),a=te.getCorner(l(r));te.setPressed(te.getCorner(r)),te.setCurrent(a),re.activateHandlers(d(e,o),g,n)}function d(e,t){return function(n){if(M.aspectRatio)switch(e){case"e":case"w":n[1]=t.y+1;break;case"n":case"s":n[0]=t.x+1}else switch(e){case"e":case"w":n[1]=t.y2;break;case"n":case"s":n[0]=t.x2}te.setCurrent(n),oe.update()}}function l(e){switch(e){case"n":case"ne":return"sw";case"s":case"e":case"se":return"nw";case"w":case"sw":return"ne";case"nw":return"se"}}function h(e){return function(t){return!(M.disabled||"move"===e&&!M.allowMove||(z=i(P),V=!0,u(e,s(t)),t.stopPropagation(),t.preventDefault(),1))}}function f(e,t,n){var o=e.width(),r=e.height();o>t&&t>0&&(o=t,r=t/e.width()*e.height()),r>n&&n>0&&(r=n,o=n/e.height()*e.width()),G=e.width()/o,N=e.height()/r,e.width(o).height(r)}function p(e){return{x:e.x*G,y:e.y*N,x2:e.x2*G,y2:e.y2*N,w:e.w*G,h:e.h*N}}function g(e){var t=te.getFixed();t.w>M.minSelect[0]&&t.h>M.minSelect[1]?(oe.enableHandles(),oe.done()):oe.release(),re.setCursor(M.allowSelect?"crosshair":"default")}function b(e){if(M.disabled)return!1;if(!M.allowSelect)return!1;V=!0,z=i(P),oe.disableHandles(),re.setCursor("crosshair");var t=s(e);return te.setPressed(t),oe.update(),re.activateHandlers(w,g,"touch"===e.type.substring(0,5)),ae.watchKeys(),e.stopPropagation(),e.preventDefault(),!1}function w(e){te.setCurrent(e),oe.update()}function v(){var t=e("<div></div>").addClass(r("tracker"));return j&&t.css({opacity:0,backgroundColor:"white"}),t}function y(e){m([e[0]/G,e[1]/N,e[2]/G,e[3]/N]),M.onSelect.call(ie,p(te.getFixed())),oe.enableHandles()}function m(e){te.setPressed([e[0],e[1]]),te.setCurrent([e[2],e[3]]),oe.update()}function C(){M.disabled=!0,oe.disableHandles(),oe.setCursor("default"),re.setCursor("default")}function x(){M.disabled=!1,k()}function S(e,t,n){var o=t||M.bgColor;M.bgFade&&a()&&M.fadeTime&&!n?e.animate({backgroundColor:o},{queue:!1,duration:M.fadeTime}):e.css("backgroundColor",o)}function k(e){M.allowResize?e?oe.enableOnly():oe.enableHandles():oe.disableHandles(),re.setCursor(M.allowSelect?"crosshair":"default"),oe.setCursor(M.allowMove?"move":"default"),M.hasOwnProperty("trueSize")&&(G=M.trueSize[0]/J,N=M.trueSize[1]/A),M.hasOwnProperty("setSelect")&&(y(M.setSelect),oe.done(),delete M.setSelect),ne.refresh(),M.bgColor!=$&&(S(M.shade?ne.getShades():R,M.shade&&M.shadeColor||M.bgColor),$=M.bgColor),_!=M.bgOpacity&&(_=M.bgOpacity,M.shade?ne.refresh():oe.setBgOpacity(_)),Y=M.maxSize[0]||0,q=M.maxSize[1]||0,L=M.minSize[0]||0,X=M.minSize[1]||0,M.hasOwnProperty("outerImage")&&(P.attr("src",M.outerImage),delete M.outerImage),oe.refresh()}var z,M=e.extend({},e.Jcrop.defaults),O=navigator.userAgent.toLowerCase(),j=/msie/.test(O),F=/msie [1-6]\./.test(O);"object"!=typeof t&&(t=e(t)[0]),"object"!=typeof n&&(n={}),c(n);var H={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},D=e(t),I=!0;if("IMG"==t.tagName){if(0!=D[0].width&&0!=D[0].height)D.width(D[0].width),D.height(D[0].height);else{var B=new Image;B.src=D[0].src,D.width(B.width),D.height(B.height)}var P=D.clone().removeAttr("id").css(H).show();P.width(D.width()),P.height(D.height()),D.after(P).hide()}else P=D.css(H).show(),I=!1,null===M.shade&&(M.shade=!0);f(P,M.boxWidth,M.boxHeight);var J=P.width(),A=P.height(),R=e("<div />").width(J).height(A).addClass(r("holder")).css({position:"relative",backgroundColor:M.bgColor}).insertAft