praiadeseselle/wire/modules/Process/ProcessPageEditImageSelect/cropper/cropper.min.js

8 lines
18 KiB
JavaScript
Raw Permalink Normal View History

2022-03-08 15:55:41 +01:00
/*!
* Cropper v0.7.8
* https://github.com/fengyuanchen/cropper
*
* Copyright 2014-2015 Fengyuan Chen
* Released under the MIT license
*/
(function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof exports==="object"){a(require("jquery"))}else{a(jQuery)}}})(function(B){var J=B(window),r=B(document),n=window.location,v=true,L=false,x=null,N=NaN,k=Infinity,u="undefined",j="directive",e=".cropper",R=/^(e|n|w|s|ne|nw|sw|se|all|crop|move|zoom)$/,m=/^(x|y|width|height)$/,C=/^(naturalWidth|naturalHeight|width|height|aspectRatio|ratio|rotate)$/,O="cropper-modal",F="cropper-hidden",H="cropper-invisible",c="cropper-move",G="cropper-crop",E="cropper-disabled",l="mousedown touchstart",p="mousemove touchmove",K="mouseup mouseleave touchend touchleave touchcancel",d="wheel mousewheel DOMMouseScroll",a="resize"+e,f="dblclick",A="build"+e,o="built"+e,z="dragstart"+e,y="dragmove"+e,h="dragend"+e,Q=function(S){return typeof S==="number"},s=function(T,U){var S=[];if(Q(U)){S.push(U)}return S.slice.apply(T,S)},I=function(U,T){var S=s(arguments,2);return function(){return U.apply(T,S.concat(s(arguments)))}},g=function(S){var T="timestamp="+(new Date()).getTime();return(S+(S.indexOf("?")===-1?"?":"&")+T)},t=function(T,S){this.element=T;this.$element=B(T);this.defaults=B.extend({},t.DEFAULTS,B.isPlainObject(S)?S:{});this.$original=x;this.ready=L;this.built=L;this.cropped=L;this.rotated=L;this.disabled=L;this.replaced=L;this.init()},D=Math.sqrt,P=Math.min,q=Math.max,w=Math.abs,i=Math.sin,b=Math.cos,M=parseFloat;t.prototype={constructor:t,support:{canvas:B.isFunction(B("<canvas>")[0].getContext)},init:function(){var S=this.defaults;B.each(S,function(T,U){switch(T){case"aspectRatio":S[T]=w(M(U))||N;break;case"autoCropArea":S[T]=w(M(U))||0.8;break;case"minWidth":case"minHeight":S[T]=w(M(U))||0;break;case"maxWidth":case"maxHeight":S[T]=w(M(U))||k;break}});this.image={rotate:0};this.load()},load:function(){var Y=this,X=this.$element,U=this.element,W=this.image,S="",V,T;if(X.is("img")){T=X.prop("src")}else{if(X.is("canvas")&&this.support.canvas){T=U.toDataURL()}}if(!T){return}if(this.replaced){W.rotate=0}if(this.defaults.checkImageOrigin&&this.isCrossOriginURL(T)){S=" crossOrigin";T=g(T)}this.$clone=(V=B("<img"+S+' src="'+T+'">'));V.one("load",function(){W.naturalWidth=this.naturalWidth||V.width();W.naturalHeight=this.naturalHeight||V.height();W.aspectRatio=W.naturalWidth/W.naturalHeight;Y.url=T;Y.ready=v;Y.build()});V.addClass(H).prependTo("body")},isCrossOriginURL:function(S){var T=S.match(/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i);if((T&&(T[1]!==n.protocol||T[2]!==n.hostname||T[3]!==n.port))){return v}return L},build:function(){var V=this.$element,U=this.defaults,T,S;if(!this.ready){return}if(this.built){this.unbuild()}V.one(A,U.build);T=B.Event(A);V.trigger(T);if(T.isDefaultPrevented()){return}this.$cropper=(S=B(t.TEMPLATE));V.addClass(F);this.$clone.removeClass(H).prependTo(S);if(!this.rotated){this.$original=this.$clone.clone();this.$original.addClass(F).prependTo(this.$cropper);this.originalImage=B.extend({},this.image)}this.$container=V.parent();this.$container.append(S);this.$canvas=S.find(".cropper-canvas");this.$dragger=S.find(".cropper-dragger");this.$viewer=S.find(".cropper-viewer");U.autoCrop?(this.cropped=v):this.$dragger.addClass(F);U.modal&&this.$canvas.addClass(O);!U.dashed&&this.$dragger.find(".cropper-dashed").addClass(F);!U.movable&&this.$dragger.find(".cropper-face").data(j,"move");!U.resizable&&this.$dragger.find(".cropper-line, .cropper-point").addClass(F);this.addListeners();this.initPreview();this.built=v;U.dragCrop&&this.setDragMode("crop");this.update();this.replaced=L;V.one(o,U.built);V.trigger(o)},unbuild:function(){if(!this.built){return}this.built=L;this.removeListeners();this.$preview.empty();this.$preview=x;this.$dragger=x;this.$canvas=x;this.$container=x;this.$cropper.remove();this.$cropper=x},update:function(S){this.initContainer();this.initCropper();this.initImage();this.initDragger();if(S){this.setData(S,v);this.setDragMode("crop")}else{this.setData(this.defaults.data)}},resize:function(){clearTimeout(this.resizing);this.resizing=setTimeout(B.proxy(this.update,this,this.getData()),200)},preview:function(){var X=this.imag