diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7469732..1128c8509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog +## 0.5.5 (Jan 1, 2016) + +- Fixed a dimension bug in the "getCroppedCanvas" method. +- Added an example for cropping round image. + + ## 0.5.4 (Dec 28, 2015) - Supports to zoom from event triggering point. diff --git a/README.md b/README.md index 6c2ccc231..68c2444e6 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ dist/ ├── cropper.css ( 5 KB) ├── cropper.min.css ( 4 KB) -├── cropper.js (87 KB) +├── cropper.js (88 KB) └── cropper.min.js (28 KB) ``` @@ -1023,4 +1023,5 @@ Maintained under the [Semantic Versioning guidelines](http://semver.org/). - [react-cropperjs](https://github.com/TAPP-TV/react-cropperjs) by @pbojinov + [⬆ back to top](#table-of-contents) diff --git a/dist/cropper.css b/dist/cropper.css index 09f9e9c74..37c3251e4 100644 --- a/dist/cropper.css +++ b/dist/cropper.css @@ -1,11 +1,11 @@ /*! - * Cropper v0.5.4 + * Cropper.js v0.5.5 * https://github.com/fengyuanchen/cropperjs * - * Copyright (c) 2015 Fengyuan Chen + * Copyright (c) 2015-2016 Fengyuan Chen * Released under the MIT license * - * Date: 2015-12-28T03:39:33.053Z + * Date: 2016-01-01T08:10:03.671Z */ .cropper-container { font-size: 0; diff --git a/dist/cropper.js b/dist/cropper.js index 5724de66e..954c1f7c2 100644 --- a/dist/cropper.js +++ b/dist/cropper.js @@ -1,11 +1,11 @@ /*! - * Cropper v0.5.4 + * Cropper.js v0.5.5 * https://github.com/fengyuanchen/cropperjs * - * Copyright (c) 2015 Fengyuan Chen + * Copyright (c) 2015-2016 Fengyuan Chen * Released under the MIT license * - * Date: 2015-12-28T03:39:49.283Z + * Date: 2016-01-01T08:10:31.084Z */ (function (global, factory) { @@ -226,7 +226,7 @@ var style = element.style; each(styles, function (value, property) { - if (REGEXP_SUFFIX.test(property)) { + if (REGEXP_SUFFIX.test(property) && isNumber(value)) { value += 'px'; } @@ -410,18 +410,14 @@ }; } - function getByTag(element, tagName, index) { - var elements = element.getElementsByTagName(tagName); - - return isNumber(index) ? elements[index] : elements; + function getByTag(element, tagName) { + return element.getElementsByTagName(tagName); } - function getByClass(element, className, index) { - var elements = element.getElementsByClassName ? + function getByClass(element, className) { + return element.getElementsByClassName ? element.getElementsByClassName(className) : element.querySelectorAll('.' + className); - - return isNumber(index) ? elements[index] : elements; } function createElement(tagName) { @@ -969,12 +965,12 @@ // Create cropper elements _this.container = container = element.parentNode; - _this.cropper = cropper = getByClass(template, 'cropper-container', 0); - _this.canvas = canvas = getByClass(cropper, 'cropper-canvas', 0); - _this.dragBox = dragBox = getByClass(cropper, 'cropper-drag-box', 0); - _this.cropBox = cropBox = getByClass(cropper, 'cropper-crop-box', 0); - _this.viewBox = getByClass(cropper, 'cropper-view-box', 0); - _this.face = face = getByClass(cropBox, 'cropper-face', 0); + _this.cropper = cropper = getByClass(template, 'cropper-container')[0]; + _this.canvas = canvas = getByClass(cropper, 'cropper-canvas')[0]; + _this.dragBox = dragBox = getByClass(cropper, 'cropper-drag-box')[0]; + _this.cropBox = cropBox = getByClass(cropper, 'cropper-crop-box')[0]; + _this.viewBox = getByClass(cropper, 'cropper-view-box')[0]; + _this.face = face = getByClass(cropBox, 'cropper-face')[0]; appendChild(canvas, image); @@ -1010,7 +1006,7 @@ } if (!options.center) { - addClass(getByClass(cropBox, 'cropper-center', 0), CLASS_HIDDEN); + addClass(getByClass(cropBox, 'cropper-center'), CLASS_HIDDEN); } if (options.background) { @@ -1728,7 +1724,7 @@ return; } - setStyle(getByTag(_this.viewBox, 'img', 0), extend({ + setStyle(getByTag(_this.viewBox, 'img')[0], extend({ width: width, height: height, marginLeft: -left, @@ -1759,7 +1755,7 @@ height: newHeight }); - setStyle(getByTag(element, 'img', 0), extend({ + setStyle(getByTag(element, 'img')[0], extend({ width: width * ratio, height: height * ratio, marginLeft: -left * ratio, @@ -3122,9 +3118,9 @@ } } - // The canvas element will use `Math.floor` on a float number, so round first - canvasWidth = round(scaledWidth || originalWidth); - canvasHeight = round(scaledHeight || originalHeight); + // The canvas element will use `Math.floor` on a float number, so floor first + canvasWidth = floor(scaledWidth || originalWidth); + canvasHeight = floor(scaledHeight || originalHeight); canvas = createElement('canvas'); canvas.width = canvasWidth; diff --git a/dist/cropper.min.css b/dist/cropper.min.css index 7bdcca7e2..0bea9dbf9 100644 --- a/dist/cropper.min.css +++ b/dist/cropper.min.css @@ -1,9 +1,9 @@ /*! - * Cropper v0.5.4 + * Cropper.js v0.5.5 * https://github.com/fengyuanchen/cropperjs * - * Copyright (c) 2015 Fengyuan Chen + * Copyright (c) 2015-2016 Fengyuan Chen * Released under the MIT license * - * Date: 2015-12-28T03:39:33.053Z + * Date: 2016-01-01T08:10:03.671Z */.cropper-container{font-size:0;line-height:0;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;direction:ltr!important;-ms-touch-action:none;touch-action:none;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none}.cropper-container img{display:block;width:100%;min-width:0!important;max-width:none!important;height:100%;min-height:0!important;max-height:none!important;image-orientation:0deg!important}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{position:absolute;top:0;right:0;bottom:0;left:0}.cropper-wrap-box{overflow:hidden}.cropper-drag-box{opacity:0;background-color:#fff;filter:alpha(opacity=0)}.cropper-dashed,.cropper-modal{opacity:.5;filter:alpha(opacity=50)}.cropper-modal{background-color:#000}.cropper-view-box{display:block;overflow:hidden;width:100%;height:100%;outline:#39f solid 1px;outline-color:rgba(51,153,255,.75)}.cropper-dashed{position:absolute;display:block;border:0 dashed #eee}.cropper-dashed.dashed-h{top:33.33333%;left:0;width:100%;height:33.33333%;border-top-width:1px;border-bottom-width:1px}.cropper-dashed.dashed-v{top:0;left:33.33333%;width:33.33333%;height:100%;border-right-width:1px;border-left-width:1px}.cropper-center{position:absolute;top:50%;left:50%;display:block;width:0;height:0;opacity:.75;filter:alpha(opacity=75)}.cropper-center:after,.cropper-center:before{position:absolute;display:block;content:' ';background-color:#eee}.cropper-center:before{top:0;left:-3px;width:7px;height:1px}.cropper-center:after{top:-3px;left:0;width:1px;height:7px}.cropper-face,.cropper-line,.cropper-point{position:absolute;display:block;width:100%;height:100%;opacity:.1;filter:alpha(opacity=10)}.cropper-face{top:0;left:0;background-color:#fff}.cropper-line,.cropper-point{background-color:#39f}.cropper-line.line-e{top:0;right:-3px;width:5px;cursor:e-resize}.cropper-line.line-n{top:-3px;left:0;height:5px;cursor:n-resize}.cropper-line.line-w{top:0;left:-3px;width:5px;cursor:w-resize}.cropper-line.line-s{bottom:-3px;left:0;height:5px;cursor:s-resize}.cropper-point{width:5px;height:5px;opacity:.75;filter:alpha(opacity=75)}.cropper-point.point-e{top:50%;right:-3px;margin-top:-3px;cursor:e-resize}.cropper-point.point-n{top:-3px;left:50%;margin-left:-3px;cursor:n-resize}.cropper-point.point-w{top:50%;left:-3px;margin-top:-3px;cursor:w-resize}.cropper-point.point-s{bottom:-3px;left:50%;margin-left:-3px;cursor:s-resize}.cropper-point.point-ne{top:-3px;right:-3px;cursor:ne-resize}.cropper-point.point-nw{top:-3px;left:-3px;cursor:nw-resize}.cropper-point.point-sw{bottom:-3px;left:-3px;cursor:sw-resize}.cropper-point.point-se{right:-3px;bottom:-3px;width:20px;height:20px;cursor:se-resize;opacity:1;filter:alpha(opacity=100)}.cropper-point.point-se:before{position:absolute;right:-50%;bottom:-50%;display:block;width:200%;height:200%;content:' ';opacity:0;background-color:#39f;filter:alpha(opacity=0)}@media (min-width:768px){.cropper-point.point-se{width:15px;height:15px}}@media (min-width:992px){.cropper-point.point-se{width:10px;height:10px}}@media (min-width:1200px){.cropper-point.point-se{width:5px;height:5px;opacity:.75;filter:alpha(opacity=75)}}.cropper-invisible{opacity:0;filter:alpha(opacity=0)}.cropper-bg{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC)}.cropper-hide{position:absolute;display:block;width:0;height:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed} \ No newline at end of file diff --git a/dist/cropper.min.js b/dist/cropper.min.js index 6fe53c868..a9f240ddf 100644 --- a/dist/cropper.min.js +++ b/dist/cropper.min.js @@ -1,10 +1,10 @@ /*! - * Cropper v0.5.4 + * Cropper.js v0.5.5 * https://github.com/fengyuanchen/cropperjs * - * Copyright (c) 2015 Fengyuan Chen + * Copyright (c) 2015-2016 Fengyuan Chen * Released under the MIT license * - * Date: 2015-12-28T03:39:49.283Z + * Date: 2016-01-01T08:10:31.084Z */ -!function(t,e){"object"==typeof module&&"object"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error("Cropper requires a window with a document");return e(t)}:e(t)}("undefined"!=typeof window?window:this,function(t,e){"use strict";function i(t){return Kt.call(t).slice(8,-1).toLowerCase()}function a(t){return"number"==typeof t&&!isNaN(t)}function n(t){return"undefined"==typeof t}function o(t){return"object"==typeof t&&null!==t}function r(t){var e,i;if(!o(t))return!1;try{return e=t.constructor,i=e.prototype,e&&i&&Gt.call(i,"isPrototypeOf")}catch(a){return!1}}function h(t){return"function"===i(t)}function l(t){return $.isArray?$.isArray(t):"array"===i(t)}function c(t,e){return e=e>=0?e:0,$.from?$.from(t).slice(e):Jt.call(t,e)}function s(t){return"string"==typeof t&&(t=t.trim?t.trim():t.replace(bt,"$1")),t}function d(t,e){var i,n;if(t&&h(e))if(l(t)||a(t.length))for(n=0,i=t.length;i>n&&e.call(t,t[n],n,t)!==!1;n++);else if(o(t))for(n in t)if(t.hasOwnProperty(n)&&e.call(t,t[n],n,t)===!1)break;return t}function p(t){var e;if(arguments.length>1){if(e=c(arguments),Z.assign)return Z.assign.apply(Z,e);e.shift(),d(e,function(e){d(e,function(e,i){t[i]=e})})}return t}function u(t,e){var i=c(arguments,2);return function(){return t.apply(e,i.concat(c(arguments)))}}function g(t,e){var i=t.style;d(e,function(t,e){vt.test(e)&&(t+="px"),i[e]=t})}function f(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}function m(t,e){var i;return a(t.length)?d(t,function(t){m(t,e)}):t.classList?t.classList.add(e):(i=s(t.className),void(i?i.indexOf(e)<0&&(t.className=i+" "+e):t.className=e))}function v(t,e){return a(t.length)?d(t,function(t){v(t,e)}):t.classList?t.classList.remove(e):void(t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function w(t,e,i){return a(t.length)?d(t,function(t){w(t,e,i)}):void(i?m(t,e):v(t,e))}function b(t,e){return o(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-"+e)}function x(t,e,i){o(i)&&n(t[e])?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-"+e,i)}function D(t,e){o(t[e])?delete t[e]:t.dataset?delete t.dataset[e]:t.removeAttribute("data-"+e)}function C(t,e,i){var a=s(e).split(xt);return a.length>1?d(a,function(e){C(t,e,i)}):void(t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent&&t.attachEvent("on"+e,i))}function y(t,e,i){var a=s(e).split(xt);return a.length>1?d(a,function(e){y(t,e,i)}):void(t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent&&t.detachEvent("on"+e,i))}function B(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function T(e){var i,n=e||t.event;return n.target||(n.target=n.srcElement||q),a(n.pageX)||(i=q.documentElement,n.pageX=n.clientX+(t.scrollX||i&&i.scrollLeft||0)-(i&&i.clientLeft||0),n.pageY=n.clientY+(t.scrollY||i&&i.scrollTop||0)-(i&&i.clientTop||0)),n}function L(e){var i=q.documentElement,a=e.getBoundingClientRect();return{left:a.left+(t.scrollX||i&&i.scrollLeft||0)-(i&&i.clientLeft||0),top:a.top+(t.scrollY||i&&i.scrollTop||0)-(i&&i.clientTop||0)}}function X(t){var e=t.length,i=0,a=0;return e&&(d(t,function(t){i+=t.pageX,a+=t.pageY}),i/=e,a/=e),{pageX:i,pageY:a}}function Y(t,e,i){var n=t.getElementsByTagName(e);return a(i)?n[i]:n}function k(t,e,i){var n=t.getElementsByClassName?t.getElementsByClassName(e):t.querySelectorAll("."+e);return a(i)?n[i]:n}function W(t){return q.createElement(t)}function H(t,e){t.appendChild(e)}function M(t){t.parentNode&&t.parentNode.removeChild(t)}function E(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function O(t){var e=t.match(wt);return e&&(e[1]!==F.protocol||e[2]!==F.hostname||e[3]!==F.port)}function z(t){var e="timestamp="+(new Date).getTime();return t+(-1===t.indexOf("?")?"?":"&")+e}function R(t,e){var i;return t.naturalWidth?e(t.naturalWidth,t.naturalHeight):(i=W("img"),i.onload=function(){e(this.width,this.height)},void(i.src=t.src))}function N(t){var e=[],i=t.rotate,n=t.scaleX,o=t.scaleY;return a(i)&&e.push("rotate("+i+"deg)"),a(n)&&a(o)&&e.push("scale("+n+","+o+")"),e.length?e.join(" "):"none"}function U(t,e){var i,a,n=_t(t.degree)%180,o=(n>90?180-n:n)*Zt/180,r=Pt(o),h=jt(o),l=t.width,c=t.height,s=t.aspectRatio;return e?(i=l/(h+r/s),a=i/s):(i=l*h+c*r,a=l*r+c*h),{width:i,height:a}}function A(t,e){var i,n,o,r=W("canvas"),h=r.getContext("2d"),l=0,c=0,s=e.naturalWidth,d=e.naturalHeight,p=e.rotate,u=e.scaleX,g=e.scaleY,f=a(u)&&a(g)&&(1!==u||1!==g),m=a(p)&&0!==p,v=m||f,w=s,b=d;return f&&(i=s/2,n=d/2),m&&(o=U({width:s,height:d,degree:p}),w=o.width,b=o.height,i=o.width/2,n=o.height/2),r.width=w,r.height=b,v&&(l=-s/2,c=-d/2,h.save(),h.translate(i,n)),m&&h.rotate(p*Zt/180),f&&h.scale(u,g),h.drawImage(t,Vt(l),Vt(c),Vt(s),Vt(d)),v&&h.restore(),r}function I(t,e,i){var a="",n=e;for(i+=e;i>n;n++)a+=Qt(t.getUint8(n));return a}function S(t){var e,i,a,n,o,r,h,l,c,s,d=new DataView(t),p=d.byteLength;if(255===d.getUint8(0)&&216===d.getUint8(1))for(c=2;p>c;){if(255===d.getUint8(c)&&225===d.getUint8(c+1)){h=c;break}c++}if(h&&(i=h+4,a=h+10,"Exif"===I(d,i,4)&&(r=d.getUint16(a),o=18761===r,(o||19789===r)&&42===d.getUint16(a+2,o)&&(n=d.getUint32(a+4,o),n>=8&&(l=a+n)))),l)for(p=d.getUint16(l,o),s=0;p>s;s++)if(c=l+12*s+2,274===d.getUint16(c,o)){c+=8,e=d.getUint16(c,o),d.setUint16(c,1,o);break}return e}function _(t){var e,i=t.replace(Ct,""),a=atob(i),n=a.length,o=new V(n),r=new Uint8Array(o);for(e=0;n>e;e++)r[e]=a.charCodeAt(e);return o}function P(t){var e,i=new Uint8Array(t),a=i.length,n="";for(e=0;a>e;e++)n+=Qt(i[e]);return"data:image/jpeg;base64,"+btoa(n)}function j(t,e){var i=this;i.element=t,i.options=p({},j.DEFAULTS,r(e)&&e),i.ready=!1,i.built=!1,i.complete=!1,i.rotated=!1,i.cropped=!1,i.disabled=!1,i.replaced=!1,i.limited=!1,i.wheeling=!1,i.isImg=!1,i.originalUrl="",i.canvasData=null,i.cropBoxData=null,i.previews=null,i.init()}var q=t.document,F=t.location,V=t.ArrayBuffer,Z=t.Object,$=t.Array,K=t.String,G=t.Number,J=t.Math,Q="cropper",tt=Q+"-modal",et=Q+"-hide",it=Q+"-hidden",at=Q+"-invisible",nt=Q+"-move",ot=Q+"-crop",rt=Q+"-disabled",ht=Q+"-bg",lt="mousedown touchstart pointerdown MSPointerDown",ct="mousemove touchmove pointermove MSPointerMove",st="mouseup touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",dt="wheel mousewheel DOMMouseScroll",pt="dblclick",ut="resize",gt="error",ft="load",mt=/e|w|s|n|se|sw|ne|nw|all|crop|move|zoom/,vt=/width|height|left|top|marginLeft|marginTop/,wt=/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i,bt=/^\s+(.*)\s+$/,xt=/\s+/,Dt=/^data\:/,Ct=/^data\:([^\;]+)\;base64,/,yt=/^data\:image\/jpeg.*;base64,/,Bt="preview",Tt="action",Lt="e",Xt="w",Yt="s",kt="n",Wt="se",Ht="sw",Mt="ne",Et="nw",Ot="all",zt="crop",Rt="move",Nt="zoom",Ut="none",At=!!q.createElement("canvas").getContext,It=J.min,St=J.max,_t=J.abs,Pt=J.sin,jt=J.cos,qt=J.sqrt,Ft=J.round,Vt=J.floor,Zt=J.PI,$t=Z.prototype,Kt=$t.toString,Gt=$t.hasOwnProperty,Jt=$.prototype.slice,Qt=K.fromCharCode;j.prototype={constructor:j,init:function(){var t,e=this,i=e.element,a=i.tagName.toLowerCase();if(!b(i,Q)){if(x(i,Q,e),"img"===a){if(e.isImg=!0,e.originalUrl=t=i.getAttribute("src"),!t)return;t=i.src}else"canvas"===a&&At&&(t=i.toDataURL());e.load(t)}},load:function(t){var e,i=this,a=i.options;if(t&&(!h(a.build)||a.build.call(i.element)!==!1)){if(i.url=t,i.imageData={},!a.checkOrientation||!V)return i.clone();if(Dt.test(t))return yt.test(t)?i.read(_(t)):i.clone();e=new XMLHttpRequest,e.onerror=e.onabort=function(){i.clone()},e.onload=function(){i.read(this.response)},e.open("get",t),e.responseType="arraybuffer",e.send()}},read:function(t){var e,i,a,n=this,o=n.options,r=S(t),h=n.imageData;if(r>1)switch(n.url=P(t),r){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}o.rotatable&&(h.rotate=e),o.scalable&&(h.scaleX=i,h.scaleY=a),n.clone()},clone:function(){var t,e,i,a,n,o=this,r=o.element,h=o.url;o.options.checkCrossOrigin&&O(h)&&(t=r.crossOrigin,t||(t="anonymous",e=z(h))),o.crossOrigin=t,o.crossOriginUrl=e,i=W("img"),t&&(i.crossOrigin=t),i.src=e||h,o.image=i,o._start=a=u(o.start,o),o._stop=n=u(o.stop,o),o.isImg?r.complete?o.start():C(r,ft,a):(C(i,ft,a),C(i,gt,n),m(i,et),r.parentNode.insertBefore(i,r.nextSibling))},start:function(t){var e=this,i=e.isImg?e.element:e.image;t&&(y(i,ft,e._start),y(i,gt,e._stop)),R(i,function(t,i){p(e.imageData,{naturalWidth:t,naturalHeight:i,aspectRatio:t/i}),e.ready=!0,e.build()})},stop:function(){var t=this,e=t.image;y(e,ft,t._start),y(e,gt,t._stop),M(e),t.image=null},build:function(){var t,e,i,a,n,o,r,l=this,c=l.options,s=l.element,d=l.image;l.ready&&(l.built&&l.unbuild(),e=W("div"),e.innerHTML=j.TEMPLATE,l.container=t=s.parentNode,l.cropper=i=k(e,"cropper-container",0),l.canvas=a=k(i,"cropper-canvas",0),l.dragBox=n=k(i,"cropper-drag-box",0),l.cropBox=o=k(i,"cropper-crop-box",0),l.viewBox=k(i,"cropper-view-box",0),l.face=r=k(o,"cropper-face",0),H(a,d),m(s,it),t.insertBefore(i,s.nextSibling),l.isImg||v(d,et),l.initPreview(),l.bind(),c.aspectRatio=St(0,c.aspectRatio)||NaN,c.viewMode=St(0,It(3,Ft(c.viewMode)))||0,c.autoCrop?(l.cropped=!0,c.modal&&m(n,tt)):m(o,it),c.guides||m(k(o,"cropper-dashed"),it),c.center||m(k(o,"cropper-center",0),it),c.background&&m(i,ht),c.highlight||m(r,at),c.cropBoxMovable&&(m(r,nt),x(r,Tt,Ot)),c.cropBoxResizable||(m(k(o,"cropper-line"),it),m(k(o,"cropper-point"),it)),l.setDragMode(c.dragMode),l.render(),l.built=!0,l.setData(c.data),setTimeout(function(){h(c.built)&&c.built.call(s),h(c.crop)&&c.crop.call(s,l.getData()),l.complete=!0},0))},unbuild:function(){var t=this;t.built&&(t.built=!1,t.complete=!1,t.initialImageData=null,t.initialCanvasData=null,t.initialCropBoxData=null,t.containerData=null,t.canvasData=null,t.cropBoxData=null,t.unbind(),t.resetPreview(),t.previews=null,t.viewBox=null,t.cropBox=null,t.dragBox=null,t.canvas=null,t.container=null,M(t.cropper),t.cropper=null)},render:function(){var t=this;t.initContainer(),t.initCanvas(),t.initCropBox(),t.renderCanvas(),t.cropped&&t.renderCropBox()},initContainer:function(){var t,e=this,i=e.options,a=e.element,n=e.container,o=e.cropper;m(o,it),v(a,it),e.containerData=t={width:St(n.offsetWidth,G(i.minContainerWidth)||200),height:St(n.offsetHeight,G(i.minContainerHeight)||100)},g(o,{width:t.width,height:t.height}),m(a,it),v(o,it)},initCanvas:function(){var t,e=this,i=e.options.viewMode,a=e.containerData,n=e.imageData,o=90===_t(n.rotate),r=o?n.naturalHeight:n.naturalWidth,h=o?n.naturalWidth:n.naturalHeight,l=r/h,c=a.width,s=a.height;a.height*l>a.width?3===i?c=a.height*l:s=a.width/l:3===i?s=a.width/l:c=a.height*l,t={naturalWidth:r,naturalHeight:h,aspectRatio:l,width:c,height:s},t.oldLeft=t.left=(a.width-c)/2,t.oldTop=t.top=(a.height-s)/2,e.canvasData=t,e.limited=1===i||2===i,e.limitCanvas(!0,!0),e.initialImageData=p({},n),e.initialCanvasData=p({},t)},limitCanvas:function(t,e){var i,a,n,o,r=this,h=r.options,l=h.viewMode,c=r.containerData,s=r.canvasData,d=s.aspectRatio,p=r.cropBoxData,u=r.cropped&&p;t&&(i=G(h.minCanvasWidth)||0,a=G(h.minCanvasHeight)||0,l>1?(i=St(i,c.width),a=St(a,c.height),3===l&&(a*d>i?i=a*d:a=i/d)):l>0&&(i?i=St(i,u?p.width:0):a?a=St(a,u?p.height:0):u&&(i=p.width,a=p.height,a*d>i?i=a*d:a=i/d)),i&&a?a*d>i?a=i/d:i=a*d:i?a=i/d:a&&(i=a*d),s.minWidth=i,s.minHeight=a,s.maxWidth=1/0,s.maxHeight=1/0),e&&(l?(n=c.width-s.width,o=c.height-s.height,s.minLeft=It(0,n),s.minTop=It(0,o),s.maxLeft=St(0,n),s.maxTop=St(0,o),u&&r.limited&&(s.minLeft=It(p.left,p.left+p.width-s.width),s.minTop=It(p.top,p.top+p.height-s.height),s.maxLeft=p.left,s.maxTop=p.top,2===l&&(s.width>=c.width&&(s.minLeft=It(0,n),s.maxLeft=St(0,n)),s.height>=c.height&&(s.minTop=It(0,o),s.maxTop=St(0,o))))):(s.minLeft=-s.width,s.minTop=-s.height,s.maxLeft=c.width,s.maxTop=c.height))},renderCanvas:function(t){var e,i,a=this,n=a.canvasData,o=a.imageData,r=o.rotate;a.rotated&&(a.rotated=!1,i=U({width:o.width,height:o.height,degree:r}),e=i.width/i.height,e!==n.aspectRatio&&(n.left-=(i.width-n.width)/2,n.top-=(i.height-n.height)/2,n.width=i.width,n.height=i.height,n.aspectRatio=e,n.naturalWidth=o.naturalWidth,n.naturalHeight=o.naturalHeight,r%180&&(i=U({width:o.naturalWidth,height:o.naturalHeight,degree:r}),n.naturalWidth=i.width,n.naturalHeight=i.height),a.limitCanvas(!0,!1))),(n.width>n.maxWidth||n.widthn.maxHeight||n.heightn.width?o.height=o.width/i:o.width=o.height*i),t.cropBoxData=o,t.limitCropBox(!0,!0),o.width=It(St(o.width,o.minWidth),o.maxWidth),o.height=It(St(o.height,o.minHeight),o.maxHeight),o.width=St(o.minWidth,o.width*a),o.height=St(o.minHeight,o.height*a),o.oldLeft=o.left=n.left+(n.width-o.width)/2,o.oldTop=o.top=n.top+(n.height-o.height)/2,t.initialCropBoxData=p({},o)},limitCropBox:function(t,e){var i,a,n,o,r=this,h=r.options,l=h.aspectRatio,c=r.containerData,s=r.canvasData,d=r.cropBoxData,p=r.limited;t&&(i=G(h.minCropBoxWidth)||0,a=G(h.minCropBoxHeight)||0,i=It(i,c.width),a=It(a,c.height),n=It(c.width,p?s.width:c.width),o=It(c.height,p?s.height:c.height),l&&(i&&a?a*l>i?a=i/l:i=a*l:i?a=i/l:a&&(i=a*l),o*l>n?o=n/l:n=o*l),d.minWidth=It(i,n),d.minHeight=It(a,o),d.maxWidth=n,d.maxHeight=o),e&&(p?(d.minLeft=St(0,s.left),d.minTop=St(0,s.top),d.maxLeft=It(c.width,s.left+s.width)-d.width,d.maxTop=It(c.height,s.top+s.height)-d.height):(d.minLeft=0,d.minTop=0,d.maxLeft=c.width-d.width,d.maxTop=c.height-d.height))},renderCropBox:function(){var t=this,e=t.options,i=t.containerData,a=t.cropBoxData;(a.width>a.maxWidth||a.widtha.maxHeight||a.heighta&&(f=a/o,s=n*f,d=a),g(t,{width:s,height:d}),g(Y(t,"img",0),p({width:r*f,height:h*f,marginLeft:-l*f,marginTop:-c*f},u))}))},bind:function(){var e=this,i=e.options,a=e.cropper;C(a,lt,e._cropStart=u(e.cropStart,e)),i.zoomable&&i.zoomOnWheel&&C(a,dt,e._wheel=u(e.wheel,e)),i.toggleDragModeOnDblclick&&C(a,pt,e._dblclick=u(e.dblclick,e)),C(q,ct,e._cropMove=u(e.cropMove,e)),C(q,st,e._cropEnd=u(e.cropEnd,e)),i.responsive&&C(t,ut,e._resize=u(e.resize,e))},unbind:function(){var e=this,i=e.options,a=e.cropper;y(a,lt,e._cropStart),i.zoomable&&i.zoomOnWheel&&y(a,dt,e._wheel),i.toggleDragModeOnDblclick&&y(a,pt,e._dblclick),y(q,ct,e._cropMove),y(q,st,e._cropEnd),i.responsive&&y(t,ut,e._resize)},resize:function(){var t,e,i,a=this,n=a.options.restore,o=a.container,r=a.containerData;!a.disabled&&r&&(i=o.offsetWidth/r.width,(1!==i||o.offsetHeight!==r.height)&&(n&&(t=a.getCanvasData(),e=a.getCropBoxData()),a.render(),n&&(a.setCanvasData(d(t,function(e,a){t[a]=e*i})),a.setCropBoxData(d(e,function(t,a){e[a]=t*i})))))},dblclick:function(){var t=this;t.disabled||t.setDragMode(f(t.dragBox,ot)?Rt:zt)},wheel:function(t){var e=this,i=T(t),a=G(e.options.wheelZoomRatio)||.1,n=1;e.disabled||(B(i),e.wheeling||(e.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),i.deltaY?n=i.deltaY>0?1:-1:i.wheelDelta?n=-i.wheelDelta/120:i.detail&&(n=i.detail>0?1:-1),e.zoom(-n*a,i)))},cropStart:function(t){var e,i,a,n=this,o=n.options,r=T(t),l=r.touches;if(!n.disabled){if(l){if(e=l.length,e>1){if(!o.zoomable||!o.zoomOnTouch||2!==e)return;i=l[1],n.startX2=i.pageX,n.startY2=i.pageY,a=Nt}i=l[0]}if(a=a||b(r.target,Tt),mt.test(a)){if(h(o.cropstart)&&o.cropstart.call(n.element,{originalEvent:r,action:a})===!1)return;B(r),n.action=a,n.cropping=!1,n.startX=i?i.pageX:r.pageX,n.startY=i?i.pageY:r.pageY,a===zt&&(n.cropping=!0,m(n.dragBox,tt))}}},cropMove:function(t){var e,i,a=this,n=a.options,o=T(t),r=o.touches,l=a.action;if(!a.disabled){if(r){if(e=r.length,e>1){if(!n.zoomable||!n.zoomOnTouch||2!==e)return;i=r[1],a.endX2=i.pageX,a.endY2=i.pageY}i=r[0]}if(l){if(h(n.cropmove)&&n.cropmove.call(a.element,{originalEvent:o,action:l})===!1)return;B(o),a.endX=i?i.pageX:o.pageX,a.endY=i?i.pageY:o.pageY,a.change(o.shiftKey,l===Nt?o:null)}}},cropEnd:function(t){var e=this,i=e.options,a=T(t),n=e.action;e.disabled||n&&(B(a),e.cropping&&(e.cropping=!1,w(e.dragBox,tt,e.cropped&&i.modal)),e.action="",h(i.cropend)&&i.cropend.call(e.element,{originalEvent:a,action:n}))},change:function(t,e){var i,a,n=this,o=n.options,r=o.aspectRatio,h=n.action,l=n.containerData,c=n.canvasData,s=n.cropBoxData,d=s.width,p=s.height,u=s.left,g=s.top,f=u+d,m=g+p,w=0,b=0,x=l.width,D=l.height,C=!0;switch(!r&&t&&(r=d&&p?d/p:1),n.limited&&(w=s.minLeft,b=s.minTop,x=w+It(l.width,c.width),D=b+It(l.height,c.height)),a={x:n.endX-n.startX,y:n.endY-n.startY},r&&(a.X=a.y*r,a.Y=a.x/r),h){case Ot:u+=a.x,g+=a.y;break;case Lt:if(a.x>=0&&(f>=x||r&&(b>=g||m>=D))){C=!1;break}d+=a.x,r&&(p=d/r,g-=a.Y/2),0>d&&(h=Xt,d=0);break;case kt:if(a.y<=0&&(b>=g||r&&(w>=u||f>=x))){C=!1;break}p-=a.y,g+=a.y,r&&(d=p*r,u+=a.X/2),0>p&&(h=Yt,p=0);break;case Xt:if(a.x<=0&&(w>=u||r&&(b>=g||m>=D))){C=!1;break}d-=a.x,u+=a.x,r&&(p=d/r,g+=a.Y/2),0>d&&(h=Lt,d=0);break;case Yt:if(a.y>=0&&(m>=D||r&&(w>=u||f>=x))){C=!1;break}p+=a.y,r&&(d=p*r,u-=a.X/2),0>p&&(h=kt,p=0);break;case Mt:if(r){if(a.y<=0&&(b>=g||f>=x)){C=!1;break}p-=a.y,g+=a.y,d=p*r}else a.x>=0?x>f?d+=a.x:a.y<=0&&b>=g&&(C=!1):d+=a.x,a.y<=0?g>b&&(p-=a.y,g+=a.y):(p-=a.y,g+=a.y);0>d&&0>p?(h=Ht,p=0,d=0):0>d?(h=Et,d=0):0>p&&(h=Wt,p=0);break;case Et:if(r){if(a.y<=0&&(b>=g||w>=u)){C=!1;break}p-=a.y,g+=a.y,d=p*r,u+=a.X}else a.x<=0?u>w?(d-=a.x,u+=a.x):a.y<=0&&b>=g&&(C=!1):(d-=a.x,u+=a.x),a.y<=0?g>b&&(p-=a.y,g+=a.y):(p-=a.y,g+=a.y);0>d&&0>p?(h=Wt,p=0,d=0):0>d?(h=Mt,d=0):0>p&&(h=Ht,p=0);break;case Ht:if(r){if(a.x<=0&&(w>=u||m>=D)){C=!1;break}d-=a.x,u+=a.x,p=d/r}else a.x<=0?u>w?(d-=a.x,u+=a.x):a.y>=0&&m>=D&&(C=!1):(d-=a.x,u+=a.x),a.y>=0?D>m&&(p+=a.y):p+=a.y;0>d&&0>p?(h=Mt,p=0,d=0):0>d?(h=Wt,d=0):0>p&&(h=Et,p=0);break;case Wt:if(r){if(a.x>=0&&(f>=x||m>=D)){C=!1;break}d+=a.x,p=d/r}else a.x>=0?x>f?d+=a.x:a.y>=0&&m>=D&&(C=!1):d+=a.x,a.y>=0?D>m&&(p+=a.y):p+=a.y;0>d&&0>p?(h=Et,p=0,d=0):0>d?(h=Ht,d=0):0>p&&(h=Mt,p=0);break;case Rt:n.move(a.x,a.y),C=!1;break;case Nt:n.zoom(function(t,e,i,a){var n=qt(t*t+e*e),o=qt(i*i+a*a);return(o-n)/n}(_t(n.startX-n.startX2),_t(n.startY-n.startY2),_t(n.endX-n.endX2),_t(n.endY-n.endY2)),e),n.startX2=n.endX2,n.startY2=n.endY2,C=!1;break;case zt:if(!a.x||!a.y){C=!1;break}i=L(n.cropper),u=n.startX-i.left,g=n.startY-i.top,d=s.minWidth,p=s.minHeight,a.x>0?h=a.y>0?Wt:Mt:a.x<0&&(u-=d,h=a.y>0?Ht:Et),a.y<0&&(g-=p),n.cropped||(v(n.cropBox,it),n.cropped=!0,n.limited&&n.limitCropBox(!0,!0))}C&&(s.width=d,s.height=p,s.left=u,s.top=g,n.action=h,n.renderCropBox()),n.startX=n.endX,n.startY=n.endY},crop:function(){var t=this;return t.built&&!t.disabled&&(t.cropped||(t.cropped=!0,t.limitCropBox(!0,!0),t.options.modal&&m(t.dragBox,tt),v(t.cropBox,it)),t.setCropBoxData(t.initialCropBoxData)),t},reset:function(){var t=this;return t.built&&!t.disabled&&(t.imageData=p({},t.initialImageData),t.canvasData=p({},t.initialCanvasData),t.cropBoxData=p({},t.initialCropBoxData),t.renderCanvas(),t.cropped&&t.renderCropBox()),t},clear:function(){var t=this;return t.cropped&&!t.disabled&&(p(t.cropBoxData,{left:0,top:0,width:0,height:0}),t.cropped=!1,t.renderCropBox(),t.limitCanvas(),t.renderCanvas(),v(t.dragBox,tt),m(t.cropBox,it)),t},replace:function(t){var e=this;return!e.disabled&&t&&(e.isImg&&(e.replaced=!0,e.element.src=t),e.options.data=null,e.load(t)),e},enable:function(){var t=this;return t.built&&(t.disabled=!1,v(t.cropper,rt)),t},disable:function(){var t=this;return t.built&&(t.disabled=!0,m(t.cropper,rt)),t},destroy:function(){var t=this,e=t.element,i=t.image;return t.ready?(t.isImg&&t.replaced&&(e.src=t.originalUrl),t.unbuild(),v(e,it)):t.isImg?e.off(ft,t.start):i&&M(i),D(e,Q),t},move:function(t,e){var i=this,a=i.canvasData;return i.moveTo(n(t)?t:a.left+G(t),n(e)?e:a.top+G(e))},moveTo:function(t,e){var i=this,o=i.canvasData,r=!1;return n(e)&&(e=t),t=G(t),e=G(e),i.built&&!i.disabled&&i.options.movable&&(a(t)&&(o.left=t,r=!0),a(e)&&(o.top=e,r=!0),r&&i.renderCanvas(!0)),i},zoom:function(t,e){var i=this,a=i.canvasData;return t=G(t),t=0>t?1/(1-t):1+t,i.zoomTo(a.width*t/a.naturalWidth,e)},zoomTo:function(t,e){var i,a,n,o,r=this,l=r.options,c=r.canvasData,s=c.width,d=c.height,p=c.naturalWidth,u=c.naturalHeight;if(t=G(t),t>=0&&r.built&&!r.disabled&&l.zoomable){if(i=p*t,a=u*t,h(l.zoom)&&l.zoom.call(r.element,{originalEvent:e,oldRatio:s/p,ratio:i/p})===!1)return r;e?(n=L(r.cropper),o=e.touches?X(e.touches):{pageX:e.pageX,pageY:e.pageY},c.left-=(i-s)*((o.pageX-n.left-c.left)/s),c.top-=(a-d)*((o.pageY-n.top-c.top)/d)):(c.left-=(i-s)/2,c.top-=(a-d)/2),c.width=i,c.height=a,r.renderCanvas(!0)}return r},rotate:function(t){var e=this;return e.rotateTo((e.imageData.rotate||0)+G(t))},rotateTo:function(t){var e=this;return t=G(t),a(t)&&e.built&&!e.disabled&&e.options.rotatable&&(e.imageData.rotate=t%360,e.rotated=!0,e.renderCanvas(!0)),e},scale:function(t,e){var i=this,o=i.imageData,r=!1;return n(e)&&(e=t),t=G(t),e=G(e),i.built&&!i.disabled&&i.options.scalable&&(a(t)&&(o.scaleX=t,r=!0),a(e)&&(o.scaleY=e,r=!0),r&&i.renderImage(!0)),i},scaleX:function(t){var e=this,i=e.imageData.scaleY;return e.scale(t,a(i)?i:1)},scaleY:function(t){var e=this,i=e.imageData.scaleX;return e.scale(a(i)?i:1,t)},getData:function(t){var e,i,a=this,n=a.options,o=a.imageData,r=a.canvasData,h=a.cropBoxData;return a.built&&a.cropped?(i={x:h.left-r.left,y:h.top-r.top,width:h.width,height:h.height},e=o.width/o.naturalWidth,d(i,function(a,n){a/=e,i[n]=t?Ft(a):a})):i={x:0,y:0,width:0,height:0},n.rotatable&&(i.rotate=o.rotate||0),n.scalable&&(i.scaleX=o.scaleX||1,i.scaleY=o.scaleY||1),i},setData:function(t){var e,i,n,o=this,l=o.options,c=o.imageData,s=o.canvasData,d={};return h(t)&&(t=t.call(o.element)),o.built&&!o.disabled&&r(t)&&(l.rotatable&&a(t.rotate)&&t.rotate!==c.rotate&&(c.rotate=t.rotate,o.rotated=e=!0),l.scalable&&(a(t.scaleX)&&t.scaleX!==c.scaleX&&(c.scaleX=t.scaleX,i=!0),a(t.scaleY)&&t.scaleY!==c.scaleY&&(c.scaleY=t.scaleY,i=!0)),e?o.renderCanvas():i&&o.renderImage(),n=c.width/c.naturalWidth,a(t.x)&&(d.left=t.x*n+s.left),a(t.y)&&(d.top=t.y*n+s.top),a(t.width)&&(d.width=t.width*n),a(t.height)&&(d.height=t.height*n),o.setCropBoxData(d)),o},getContainerData:function(){var t=this;return t.built?t.containerData:{}},getImageData:function(){var t=this;return t.ready?t.imageData:{}},getCanvasData:function(){var t=this,e=t.canvasData,i={};return t.built&&d(["left","top","width","height","naturalWidth","naturalHeight"],function(t){i[t]=e[t]}),i},setCanvasData:function(t){var e=this,i=e.canvasData,n=i.aspectRatio;return h(t)&&(t=t.call(e.element)),e.built&&!e.disabled&&r(t)&&(a(t.left)&&(i.left=t.left),a(t.top)&&(i.top=t.top),a(t.width)?(i.width=t.width,i.height=t.width/n):a(t.height)&&(i.height=t.height,i.width=t.height*n),e.renderCanvas(!0)),e},getCropBoxData:function(){var t,e=this,i=e.cropBoxData;return e.built&&e.cropped&&(t={left:i.left,top:i.top,width:i.width,height:i.height}),t||{}},setCropBoxData:function(t){var e,i,n=this,o=n.cropBoxData,l=n.options.aspectRatio;return h(t)&&(t=t.call(n.element)),n.built&&n.cropped&&!n.disabled&&r(t)&&(a(t.left)&&(o.left=t.left),a(t.top)&&(o.top=t.top),a(t.width)&&(e=!0,o.width=t.width),a(t.height)&&(i=!0,o.height=t.height),l&&(e?o.height=o.width/l:i&&(o.width=o.height*l)),n.renderCropBox()),n},getCroppedCanvas:function(t){var e,i,a,n,o,h,l,c,s,d,p,u=this;return u.built&&u.cropped&&At?(r(t)||(t={}),p=u.getData(),e=p.width,i=p.height,c=e/i,r(t)&&(o=t.width,h=t.height,o?(h=o/c,l=o/e):h&&(o=h*c,l=h/i)),a=Ft(o||e),n=Ft(h||i),s=W("canvas"),s.width=a,s.height=n,d=s.getContext("2d"),t.fillColor&&(d.fillStyle=t.fillColor,d.fillRect(0,0,a,n)),d.drawImage.apply(d,function(){var t,a,n,o,r,h,c=A(u.image,u.imageData),s=c.width,d=c.height,g=[c],f=p.x,m=p.y;return-e>=f||f>s?f=t=n=r=0:0>=f?(n=-f,f=0,t=r=It(s,e+f)):s>=f&&(n=0,t=r=It(e,s-f)),0>=t||-i>=m||m>d?m=a=o=h=0:0>=m?(o=-m,m=0,a=h=It(d,i+m)):d>=m&&(o=0,a=h=It(i,d-m)),g.push(Vt(f),Vt(m),Vt(t),Vt(a)),l&&(n*=l,o*=l,r*=l,h*=l),r>0&&h>0&&g.push(Vt(n),Vt(o),Vt(r),Vt(h)),g}.call(u)),s):void 0},setAspectRatio:function(t){var e=this,i=e.options;return e.disabled||n(t)||(i.aspectRatio=St(0,t)||NaN,e.built&&(e.initCropBox(),e.cropped&&e.renderCropBox())),e},setDragMode:function(t){var e,i,a=this,n=a.options,o=a.dragBox,r=a.face;return a.ready&&!a.disabled&&(e=t===zt,i=n.movable&&t===Rt,t=e||i?t:Ut,x(o,Tt,t),w(o,ot,e),w(o,nt,i),n.cropBoxMovable||(x(r,Tt,t),w(r,ot,e),w(r,nt,i))),a}},j.DEFAULTS={viewMode:0,dragMode:"crop",aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,build:null,built:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},j.TEMPLATE=function(t,e){return e=e.split(","),t.replace(/\d+/g,function(t){return e[t]})}('<0 6="5-container"><0 6="5-wrap-9"><0 6="5-canvas"><0 6="5-drag-9"><0 6="5-crop-9"><1 6="5-view-9"><1 6="5-8 8-h"><1 6="5-8 8-v"><1 6="5-center"><1 6="5-face"><1 6="5-7 7-e" 3-2="e"><1 6="5-7 7-n" 3-2="n"><1 6="5-7 7-w" 3-2="w"><1 6="5-7 7-s" 3-2="s"><1 6="5-4 4-e" 3-2="e"><1 6="5-4 4-n" 3-2="n"><1 6="5-4 4-w" 3-2="w"><1 6="5-4 4-s" 3-2="s"><1 6="5-4 4-ne" 3-2="ne"><1 6="5-4 4-nw" 3-2="nw"><1 6="5-4 4-sw" 3-2="sw"><1 6="5-4 4-se" 3-2="se">',"div,span,action,data,point,cropper,class,line,dashed,box");var te=t.Cropper;return j.noConflict=function(){return t.Cropper=te,j},j.setDefaults=function(t){p(j.DEFAULTS,t)},"function"==typeof define&&define.amd&&define("cropper",[],function(){return j}),e||(t.Cropper=j),j}); \ No newline at end of file +!function(t,e){"object"==typeof module&&"object"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error("Cropper requires a window with a document");return e(t)}:e(t)}("undefined"!=typeof window?window:this,function(t,e){"use strict";function i(t){return Kt.call(t).slice(8,-1).toLowerCase()}function a(t){return"number"==typeof t&&!isNaN(t)}function n(t){return"undefined"==typeof t}function o(t){return"object"==typeof t&&null!==t}function r(t){var e,i;if(!o(t))return!1;try{return e=t.constructor,i=e.prototype,e&&i&&Gt.call(i,"isPrototypeOf")}catch(a){return!1}}function h(t){return"function"===i(t)}function l(t){return $.isArray?$.isArray(t):"array"===i(t)}function c(t,e){return e=e>=0?e:0,$.from?$.from(t).slice(e):Jt.call(t,e)}function s(t){return"string"==typeof t&&(t=t.trim?t.trim():t.replace(bt,"$1")),t}function d(t,e){var i,n;if(t&&h(e))if(l(t)||a(t.length))for(n=0,i=t.length;i>n&&e.call(t,t[n],n,t)!==!1;n++);else if(o(t))for(n in t)if(t.hasOwnProperty(n)&&e.call(t,t[n],n,t)===!1)break;return t}function p(t){var e;if(arguments.length>1){if(e=c(arguments),Z.assign)return Z.assign.apply(Z,e);e.shift(),d(e,function(e){d(e,function(e,i){t[i]=e})})}return t}function u(t,e){var i=c(arguments,2);return function(){return t.apply(e,i.concat(c(arguments)))}}function g(t,e){var i=t.style;d(e,function(t,e){vt.test(e)&&a(t)&&(t+="px"),i[e]=t})}function f(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}function m(t,e){var i;return a(t.length)?d(t,function(t){m(t,e)}):t.classList?t.classList.add(e):(i=s(t.className),void(i?i.indexOf(e)<0&&(t.className=i+" "+e):t.className=e))}function v(t,e){return a(t.length)?d(t,function(t){v(t,e)}):t.classList?t.classList.remove(e):void(t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function w(t,e,i){return a(t.length)?d(t,function(t){w(t,e,i)}):void(i?m(t,e):v(t,e))}function b(t,e){return o(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-"+e)}function x(t,e,i){o(i)&&n(t[e])?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-"+e,i)}function D(t,e){o(t[e])?delete t[e]:t.dataset?delete t.dataset[e]:t.removeAttribute("data-"+e)}function C(t,e,i){var a=s(e).split(xt);return a.length>1?d(a,function(e){C(t,e,i)}):void(t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent&&t.attachEvent("on"+e,i))}function y(t,e,i){var a=s(e).split(xt);return a.length>1?d(a,function(e){y(t,e,i)}):void(t.removeEventListener?t.removeEventListener(e,i,!1):t.detachEvent&&t.detachEvent("on"+e,i))}function B(t){t.preventDefault?t.preventDefault():t.returnValue=!1}function T(e){var i,n=e||t.event;return n.target||(n.target=n.srcElement||q),a(n.pageX)||(i=q.documentElement,n.pageX=n.clientX+(t.scrollX||i&&i.scrollLeft||0)-(i&&i.clientLeft||0),n.pageY=n.clientY+(t.scrollY||i&&i.scrollTop||0)-(i&&i.clientTop||0)),n}function L(e){var i=q.documentElement,a=e.getBoundingClientRect();return{left:a.left+(t.scrollX||i&&i.scrollLeft||0)-(i&&i.clientLeft||0),top:a.top+(t.scrollY||i&&i.scrollTop||0)-(i&&i.clientTop||0)}}function X(t){var e=t.length,i=0,a=0;return e&&(d(t,function(t){i+=t.pageX,a+=t.pageY}),i/=e,a/=e),{pageX:i,pageY:a}}function Y(t,e){return t.getElementsByTagName(e)}function k(t,e){return t.getElementsByClassName?t.getElementsByClassName(e):t.querySelectorAll("."+e)}function W(t){return q.createElement(t)}function H(t,e){t.appendChild(e)}function M(t){t.parentNode&&t.parentNode.removeChild(t)}function E(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function O(t){var e=t.match(wt);return e&&(e[1]!==F.protocol||e[2]!==F.hostname||e[3]!==F.port)}function z(t){var e="timestamp="+(new Date).getTime();return t+(-1===t.indexOf("?")?"?":"&")+e}function R(t,e){var i;return t.naturalWidth?e(t.naturalWidth,t.naturalHeight):(i=W("img"),i.onload=function(){e(this.width,this.height)},void(i.src=t.src))}function N(t){var e=[],i=t.rotate,n=t.scaleX,o=t.scaleY;return a(i)&&e.push("rotate("+i+"deg)"),a(n)&&a(o)&&e.push("scale("+n+","+o+")"),e.length?e.join(" "):"none"}function U(t,e){var i,a,n=_t(t.degree)%180,o=(n>90?180-n:n)*Zt/180,r=Pt(o),h=jt(o),l=t.width,c=t.height,s=t.aspectRatio;return e?(i=l/(h+r/s),a=i/s):(i=l*h+c*r,a=l*r+c*h),{width:i,height:a}}function A(t,e){var i,n,o,r=W("canvas"),h=r.getContext("2d"),l=0,c=0,s=e.naturalWidth,d=e.naturalHeight,p=e.rotate,u=e.scaleX,g=e.scaleY,f=a(u)&&a(g)&&(1!==u||1!==g),m=a(p)&&0!==p,v=m||f,w=s,b=d;return f&&(i=s/2,n=d/2),m&&(o=U({width:s,height:d,degree:p}),w=o.width,b=o.height,i=o.width/2,n=o.height/2),r.width=w,r.height=b,v&&(l=-s/2,c=-d/2,h.save(),h.translate(i,n)),m&&h.rotate(p*Zt/180),f&&h.scale(u,g),h.drawImage(t,Vt(l),Vt(c),Vt(s),Vt(d)),v&&h.restore(),r}function I(t,e,i){var a="",n=e;for(i+=e;i>n;n++)a+=Qt(t.getUint8(n));return a}function S(t){var e,i,a,n,o,r,h,l,c,s,d=new DataView(t),p=d.byteLength;if(255===d.getUint8(0)&&216===d.getUint8(1))for(c=2;p>c;){if(255===d.getUint8(c)&&225===d.getUint8(c+1)){h=c;break}c++}if(h&&(i=h+4,a=h+10,"Exif"===I(d,i,4)&&(r=d.getUint16(a),o=18761===r,(o||19789===r)&&42===d.getUint16(a+2,o)&&(n=d.getUint32(a+4,o),n>=8&&(l=a+n)))),l)for(p=d.getUint16(l,o),s=0;p>s;s++)if(c=l+12*s+2,274===d.getUint16(c,o)){c+=8,e=d.getUint16(c,o),d.setUint16(c,1,o);break}return e}function _(t){var e,i=t.replace(Ct,""),a=atob(i),n=a.length,o=new V(n),r=new Uint8Array(o);for(e=0;n>e;e++)r[e]=a.charCodeAt(e);return o}function P(t){var e,i=new Uint8Array(t),a=i.length,n="";for(e=0;a>e;e++)n+=Qt(i[e]);return"data:image/jpeg;base64,"+btoa(n)}function j(t,e){var i=this;i.element=t,i.options=p({},j.DEFAULTS,r(e)&&e),i.ready=!1,i.built=!1,i.complete=!1,i.rotated=!1,i.cropped=!1,i.disabled=!1,i.replaced=!1,i.limited=!1,i.wheeling=!1,i.isImg=!1,i.originalUrl="",i.canvasData=null,i.cropBoxData=null,i.previews=null,i.init()}var q=t.document,F=t.location,V=t.ArrayBuffer,Z=t.Object,$=t.Array,K=t.String,G=t.Number,J=t.Math,Q="cropper",tt=Q+"-modal",et=Q+"-hide",it=Q+"-hidden",at=Q+"-invisible",nt=Q+"-move",ot=Q+"-crop",rt=Q+"-disabled",ht=Q+"-bg",lt="mousedown touchstart pointerdown MSPointerDown",ct="mousemove touchmove pointermove MSPointerMove",st="mouseup touchend touchcancel pointerup pointercancel MSPointerUp MSPointerCancel",dt="wheel mousewheel DOMMouseScroll",pt="dblclick",ut="resize",gt="error",ft="load",mt=/e|w|s|n|se|sw|ne|nw|all|crop|move|zoom/,vt=/width|height|left|top|marginLeft|marginTop/,wt=/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i,bt=/^\s+(.*)\s+$/,xt=/\s+/,Dt=/^data\:/,Ct=/^data\:([^\;]+)\;base64,/,yt=/^data\:image\/jpeg.*;base64,/,Bt="preview",Tt="action",Lt="e",Xt="w",Yt="s",kt="n",Wt="se",Ht="sw",Mt="ne",Et="nw",Ot="all",zt="crop",Rt="move",Nt="zoom",Ut="none",At=!!q.createElement("canvas").getContext,It=J.min,St=J.max,_t=J.abs,Pt=J.sin,jt=J.cos,qt=J.sqrt,Ft=J.round,Vt=J.floor,Zt=J.PI,$t=Z.prototype,Kt=$t.toString,Gt=$t.hasOwnProperty,Jt=$.prototype.slice,Qt=K.fromCharCode;j.prototype={constructor:j,init:function(){var t,e=this,i=e.element,a=i.tagName.toLowerCase();if(!b(i,Q)){if(x(i,Q,e),"img"===a){if(e.isImg=!0,e.originalUrl=t=i.getAttribute("src"),!t)return;t=i.src}else"canvas"===a&&At&&(t=i.toDataURL());e.load(t)}},load:function(t){var e,i=this,a=i.options;if(t&&(!h(a.build)||a.build.call(i.element)!==!1)){if(i.url=t,i.imageData={},!a.checkOrientation||!V)return i.clone();if(Dt.test(t))return yt.test(t)?i.read(_(t)):i.clone();e=new XMLHttpRequest,e.onerror=e.onabort=function(){i.clone()},e.onload=function(){i.read(this.response)},e.open("get",t),e.responseType="arraybuffer",e.send()}},read:function(t){var e,i,a,n=this,o=n.options,r=S(t),h=n.imageData;if(r>1)switch(n.url=P(t),r){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}o.rotatable&&(h.rotate=e),o.scalable&&(h.scaleX=i,h.scaleY=a),n.clone()},clone:function(){var t,e,i,a,n,o=this,r=o.element,h=o.url;o.options.checkCrossOrigin&&O(h)&&(t=r.crossOrigin,t||(t="anonymous",e=z(h))),o.crossOrigin=t,o.crossOriginUrl=e,i=W("img"),t&&(i.crossOrigin=t),i.src=e||h,o.image=i,o._start=a=u(o.start,o),o._stop=n=u(o.stop,o),o.isImg?r.complete?o.start():C(r,ft,a):(C(i,ft,a),C(i,gt,n),m(i,et),r.parentNode.insertBefore(i,r.nextSibling))},start:function(t){var e=this,i=e.isImg?e.element:e.image;t&&(y(i,ft,e._start),y(i,gt,e._stop)),R(i,function(t,i){p(e.imageData,{naturalWidth:t,naturalHeight:i,aspectRatio:t/i}),e.ready=!0,e.build()})},stop:function(){var t=this,e=t.image;y(e,ft,t._start),y(e,gt,t._stop),M(e),t.image=null},build:function(){var t,e,i,a,n,o,r,l=this,c=l.options,s=l.element,d=l.image;l.ready&&(l.built&&l.unbuild(),e=W("div"),e.innerHTML=j.TEMPLATE,l.container=t=s.parentNode,l.cropper=i=k(e,"cropper-container")[0],l.canvas=a=k(i,"cropper-canvas")[0],l.dragBox=n=k(i,"cropper-drag-box")[0],l.cropBox=o=k(i,"cropper-crop-box")[0],l.viewBox=k(i,"cropper-view-box")[0],l.face=r=k(o,"cropper-face")[0],H(a,d),m(s,it),t.insertBefore(i,s.nextSibling),l.isImg||v(d,et),l.initPreview(),l.bind(),c.aspectRatio=St(0,c.aspectRatio)||NaN,c.viewMode=St(0,It(3,Ft(c.viewMode)))||0,c.autoCrop?(l.cropped=!0,c.modal&&m(n,tt)):m(o,it),c.guides||m(k(o,"cropper-dashed"),it),c.center||m(k(o,"cropper-center"),it),c.background&&m(i,ht),c.highlight||m(r,at),c.cropBoxMovable&&(m(r,nt),x(r,Tt,Ot)),c.cropBoxResizable||(m(k(o,"cropper-line"),it),m(k(o,"cropper-point"),it)),l.setDragMode(c.dragMode),l.render(),l.built=!0,l.setData(c.data),setTimeout(function(){h(c.built)&&c.built.call(s),h(c.crop)&&c.crop.call(s,l.getData()),l.complete=!0},0))},unbuild:function(){var t=this;t.built&&(t.built=!1,t.complete=!1,t.initialImageData=null,t.initialCanvasData=null,t.initialCropBoxData=null,t.containerData=null,t.canvasData=null,t.cropBoxData=null,t.unbind(),t.resetPreview(),t.previews=null,t.viewBox=null,t.cropBox=null,t.dragBox=null,t.canvas=null,t.container=null,M(t.cropper),t.cropper=null)},render:function(){var t=this;t.initContainer(),t.initCanvas(),t.initCropBox(),t.renderCanvas(),t.cropped&&t.renderCropBox()},initContainer:function(){var t,e=this,i=e.options,a=e.element,n=e.container,o=e.cropper;m(o,it),v(a,it),e.containerData=t={width:St(n.offsetWidth,G(i.minContainerWidth)||200),height:St(n.offsetHeight,G(i.minContainerHeight)||100)},g(o,{width:t.width,height:t.height}),m(a,it),v(o,it)},initCanvas:function(){var t,e=this,i=e.options.viewMode,a=e.containerData,n=e.imageData,o=90===_t(n.rotate),r=o?n.naturalHeight:n.naturalWidth,h=o?n.naturalWidth:n.naturalHeight,l=r/h,c=a.width,s=a.height;a.height*l>a.width?3===i?c=a.height*l:s=a.width/l:3===i?s=a.width/l:c=a.height*l,t={naturalWidth:r,naturalHeight:h,aspectRatio:l,width:c,height:s},t.oldLeft=t.left=(a.width-c)/2,t.oldTop=t.top=(a.height-s)/2,e.canvasData=t,e.limited=1===i||2===i,e.limitCanvas(!0,!0),e.initialImageData=p({},n),e.initialCanvasData=p({},t)},limitCanvas:function(t,e){var i,a,n,o,r=this,h=r.options,l=h.viewMode,c=r.containerData,s=r.canvasData,d=s.aspectRatio,p=r.cropBoxData,u=r.cropped&&p;t&&(i=G(h.minCanvasWidth)||0,a=G(h.minCanvasHeight)||0,l>1?(i=St(i,c.width),a=St(a,c.height),3===l&&(a*d>i?i=a*d:a=i/d)):l>0&&(i?i=St(i,u?p.width:0):a?a=St(a,u?p.height:0):u&&(i=p.width,a=p.height,a*d>i?i=a*d:a=i/d)),i&&a?a*d>i?a=i/d:i=a*d:i?a=i/d:a&&(i=a*d),s.minWidth=i,s.minHeight=a,s.maxWidth=1/0,s.maxHeight=1/0),e&&(l?(n=c.width-s.width,o=c.height-s.height,s.minLeft=It(0,n),s.minTop=It(0,o),s.maxLeft=St(0,n),s.maxTop=St(0,o),u&&r.limited&&(s.minLeft=It(p.left,p.left+p.width-s.width),s.minTop=It(p.top,p.top+p.height-s.height),s.maxLeft=p.left,s.maxTop=p.top,2===l&&(s.width>=c.width&&(s.minLeft=It(0,n),s.maxLeft=St(0,n)),s.height>=c.height&&(s.minTop=It(0,o),s.maxTop=St(0,o))))):(s.minLeft=-s.width,s.minTop=-s.height,s.maxLeft=c.width,s.maxTop=c.height))},renderCanvas:function(t){var e,i,a=this,n=a.canvasData,o=a.imageData,r=o.rotate;a.rotated&&(a.rotated=!1,i=U({width:o.width,height:o.height,degree:r}),e=i.width/i.height,e!==n.aspectRatio&&(n.left-=(i.width-n.width)/2,n.top-=(i.height-n.height)/2,n.width=i.width,n.height=i.height,n.aspectRatio=e,n.naturalWidth=o.naturalWidth,n.naturalHeight=o.naturalHeight,r%180&&(i=U({width:o.naturalWidth,height:o.naturalHeight,degree:r}),n.naturalWidth=i.width,n.naturalHeight=i.height),a.limitCanvas(!0,!1))),(n.width>n.maxWidth||n.widthn.maxHeight||n.heightn.width?o.height=o.width/i:o.width=o.height*i),t.cropBoxData=o,t.limitCropBox(!0,!0),o.width=It(St(o.width,o.minWidth),o.maxWidth),o.height=It(St(o.height,o.minHeight),o.maxHeight),o.width=St(o.minWidth,o.width*a),o.height=St(o.minHeight,o.height*a),o.oldLeft=o.left=n.left+(n.width-o.width)/2,o.oldTop=o.top=n.top+(n.height-o.height)/2,t.initialCropBoxData=p({},o)},limitCropBox:function(t,e){var i,a,n,o,r=this,h=r.options,l=h.aspectRatio,c=r.containerData,s=r.canvasData,d=r.cropBoxData,p=r.limited;t&&(i=G(h.minCropBoxWidth)||0,a=G(h.minCropBoxHeight)||0,i=It(i,c.width),a=It(a,c.height),n=It(c.width,p?s.width:c.width),o=It(c.height,p?s.height:c.height),l&&(i&&a?a*l>i?a=i/l:i=a*l:i?a=i/l:a&&(i=a*l),o*l>n?o=n/l:n=o*l),d.minWidth=It(i,n),d.minHeight=It(a,o),d.maxWidth=n,d.maxHeight=o),e&&(p?(d.minLeft=St(0,s.left),d.minTop=St(0,s.top),d.maxLeft=It(c.width,s.left+s.width)-d.width,d.maxTop=It(c.height,s.top+s.height)-d.height):(d.minLeft=0,d.minTop=0,d.maxLeft=c.width-d.width,d.maxTop=c.height-d.height))},renderCropBox:function(){var t=this,e=t.options,i=t.containerData,a=t.cropBoxData;(a.width>a.maxWidth||a.widtha.maxHeight||a.heighta&&(f=a/o,s=n*f,d=a),g(t,{width:s,height:d}),g(Y(t,"img")[0],p({width:r*f,height:h*f,marginLeft:-l*f,marginTop:-c*f},u))}))},bind:function(){var e=this,i=e.options,a=e.cropper;C(a,lt,e._cropStart=u(e.cropStart,e)),i.zoomable&&i.zoomOnWheel&&C(a,dt,e._wheel=u(e.wheel,e)),i.toggleDragModeOnDblclick&&C(a,pt,e._dblclick=u(e.dblclick,e)),C(q,ct,e._cropMove=u(e.cropMove,e)),C(q,st,e._cropEnd=u(e.cropEnd,e)),i.responsive&&C(t,ut,e._resize=u(e.resize,e))},unbind:function(){var e=this,i=e.options,a=e.cropper;y(a,lt,e._cropStart),i.zoomable&&i.zoomOnWheel&&y(a,dt,e._wheel),i.toggleDragModeOnDblclick&&y(a,pt,e._dblclick),y(q,ct,e._cropMove),y(q,st,e._cropEnd),i.responsive&&y(t,ut,e._resize)},resize:function(){var t,e,i,a=this,n=a.options.restore,o=a.container,r=a.containerData;!a.disabled&&r&&(i=o.offsetWidth/r.width,(1!==i||o.offsetHeight!==r.height)&&(n&&(t=a.getCanvasData(),e=a.getCropBoxData()),a.render(),n&&(a.setCanvasData(d(t,function(e,a){t[a]=e*i})),a.setCropBoxData(d(e,function(t,a){e[a]=t*i})))))},dblclick:function(){var t=this;t.disabled||t.setDragMode(f(t.dragBox,ot)?Rt:zt)},wheel:function(t){var e=this,i=T(t),a=G(e.options.wheelZoomRatio)||.1,n=1;e.disabled||(B(i),e.wheeling||(e.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),i.deltaY?n=i.deltaY>0?1:-1:i.wheelDelta?n=-i.wheelDelta/120:i.detail&&(n=i.detail>0?1:-1),e.zoom(-n*a,i)))},cropStart:function(t){var e,i,a,n=this,o=n.options,r=T(t),l=r.touches;if(!n.disabled){if(l){if(e=l.length,e>1){if(!o.zoomable||!o.zoomOnTouch||2!==e)return;i=l[1],n.startX2=i.pageX,n.startY2=i.pageY,a=Nt}i=l[0]}if(a=a||b(r.target,Tt),mt.test(a)){if(h(o.cropstart)&&o.cropstart.call(n.element,{originalEvent:r,action:a})===!1)return;B(r),n.action=a,n.cropping=!1,n.startX=i?i.pageX:r.pageX,n.startY=i?i.pageY:r.pageY,a===zt&&(n.cropping=!0,m(n.dragBox,tt))}}},cropMove:function(t){var e,i,a=this,n=a.options,o=T(t),r=o.touches,l=a.action;if(!a.disabled){if(r){if(e=r.length,e>1){if(!n.zoomable||!n.zoomOnTouch||2!==e)return;i=r[1],a.endX2=i.pageX,a.endY2=i.pageY}i=r[0]}if(l){if(h(n.cropmove)&&n.cropmove.call(a.element,{originalEvent:o,action:l})===!1)return;B(o),a.endX=i?i.pageX:o.pageX,a.endY=i?i.pageY:o.pageY,a.change(o.shiftKey,l===Nt?o:null)}}},cropEnd:function(t){var e=this,i=e.options,a=T(t),n=e.action;e.disabled||n&&(B(a),e.cropping&&(e.cropping=!1,w(e.dragBox,tt,e.cropped&&i.modal)),e.action="",h(i.cropend)&&i.cropend.call(e.element,{originalEvent:a,action:n}))},change:function(t,e){var i,a,n=this,o=n.options,r=o.aspectRatio,h=n.action,l=n.containerData,c=n.canvasData,s=n.cropBoxData,d=s.width,p=s.height,u=s.left,g=s.top,f=u+d,m=g+p,w=0,b=0,x=l.width,D=l.height,C=!0;switch(!r&&t&&(r=d&&p?d/p:1),n.limited&&(w=s.minLeft,b=s.minTop,x=w+It(l.width,c.width),D=b+It(l.height,c.height)),a={x:n.endX-n.startX,y:n.endY-n.startY},r&&(a.X=a.y*r,a.Y=a.x/r),h){case Ot:u+=a.x,g+=a.y;break;case Lt:if(a.x>=0&&(f>=x||r&&(b>=g||m>=D))){C=!1;break}d+=a.x,r&&(p=d/r,g-=a.Y/2),0>d&&(h=Xt,d=0);break;case kt:if(a.y<=0&&(b>=g||r&&(w>=u||f>=x))){C=!1;break}p-=a.y,g+=a.y,r&&(d=p*r,u+=a.X/2),0>p&&(h=Yt,p=0);break;case Xt:if(a.x<=0&&(w>=u||r&&(b>=g||m>=D))){C=!1;break}d-=a.x,u+=a.x,r&&(p=d/r,g+=a.Y/2),0>d&&(h=Lt,d=0);break;case Yt:if(a.y>=0&&(m>=D||r&&(w>=u||f>=x))){C=!1;break}p+=a.y,r&&(d=p*r,u-=a.X/2),0>p&&(h=kt,p=0);break;case Mt:if(r){if(a.y<=0&&(b>=g||f>=x)){C=!1;break}p-=a.y,g+=a.y,d=p*r}else a.x>=0?x>f?d+=a.x:a.y<=0&&b>=g&&(C=!1):d+=a.x,a.y<=0?g>b&&(p-=a.y,g+=a.y):(p-=a.y,g+=a.y);0>d&&0>p?(h=Ht,p=0,d=0):0>d?(h=Et,d=0):0>p&&(h=Wt,p=0);break;case Et:if(r){if(a.y<=0&&(b>=g||w>=u)){C=!1;break}p-=a.y,g+=a.y,d=p*r,u+=a.X}else a.x<=0?u>w?(d-=a.x,u+=a.x):a.y<=0&&b>=g&&(C=!1):(d-=a.x,u+=a.x),a.y<=0?g>b&&(p-=a.y,g+=a.y):(p-=a.y,g+=a.y);0>d&&0>p?(h=Wt,p=0,d=0):0>d?(h=Mt,d=0):0>p&&(h=Ht,p=0);break;case Ht:if(r){if(a.x<=0&&(w>=u||m>=D)){C=!1;break}d-=a.x,u+=a.x,p=d/r}else a.x<=0?u>w?(d-=a.x,u+=a.x):a.y>=0&&m>=D&&(C=!1):(d-=a.x,u+=a.x),a.y>=0?D>m&&(p+=a.y):p+=a.y;0>d&&0>p?(h=Mt,p=0,d=0):0>d?(h=Wt,d=0):0>p&&(h=Et,p=0);break;case Wt:if(r){if(a.x>=0&&(f>=x||m>=D)){C=!1;break}d+=a.x,p=d/r}else a.x>=0?x>f?d+=a.x:a.y>=0&&m>=D&&(C=!1):d+=a.x,a.y>=0?D>m&&(p+=a.y):p+=a.y;0>d&&0>p?(h=Et,p=0,d=0):0>d?(h=Ht,d=0):0>p&&(h=Mt,p=0);break;case Rt:n.move(a.x,a.y),C=!1;break;case Nt:n.zoom(function(t,e,i,a){var n=qt(t*t+e*e),o=qt(i*i+a*a);return(o-n)/n}(_t(n.startX-n.startX2),_t(n.startY-n.startY2),_t(n.endX-n.endX2),_t(n.endY-n.endY2)),e),n.startX2=n.endX2,n.startY2=n.endY2,C=!1;break;case zt:if(!a.x||!a.y){C=!1;break}i=L(n.cropper),u=n.startX-i.left,g=n.startY-i.top,d=s.minWidth,p=s.minHeight,a.x>0?h=a.y>0?Wt:Mt:a.x<0&&(u-=d,h=a.y>0?Ht:Et),a.y<0&&(g-=p),n.cropped||(v(n.cropBox,it),n.cropped=!0,n.limited&&n.limitCropBox(!0,!0))}C&&(s.width=d,s.height=p,s.left=u,s.top=g,n.action=h,n.renderCropBox()),n.startX=n.endX,n.startY=n.endY},crop:function(){var t=this;return t.built&&!t.disabled&&(t.cropped||(t.cropped=!0,t.limitCropBox(!0,!0),t.options.modal&&m(t.dragBox,tt),v(t.cropBox,it)),t.setCropBoxData(t.initialCropBoxData)),t},reset:function(){var t=this;return t.built&&!t.disabled&&(t.imageData=p({},t.initialImageData),t.canvasData=p({},t.initialCanvasData),t.cropBoxData=p({},t.initialCropBoxData),t.renderCanvas(),t.cropped&&t.renderCropBox()),t},clear:function(){var t=this;return t.cropped&&!t.disabled&&(p(t.cropBoxData,{left:0,top:0,width:0,height:0}),t.cropped=!1,t.renderCropBox(),t.limitCanvas(),t.renderCanvas(),v(t.dragBox,tt),m(t.cropBox,it)),t},replace:function(t){var e=this;return!e.disabled&&t&&(e.isImg&&(e.replaced=!0,e.element.src=t),e.options.data=null,e.load(t)),e},enable:function(){var t=this;return t.built&&(t.disabled=!1,v(t.cropper,rt)),t},disable:function(){var t=this;return t.built&&(t.disabled=!0,m(t.cropper,rt)),t},destroy:function(){var t=this,e=t.element,i=t.image;return t.ready?(t.isImg&&t.replaced&&(e.src=t.originalUrl),t.unbuild(),v(e,it)):t.isImg?e.off(ft,t.start):i&&M(i),D(e,Q),t},move:function(t,e){var i=this,a=i.canvasData;return i.moveTo(n(t)?t:a.left+G(t),n(e)?e:a.top+G(e))},moveTo:function(t,e){var i=this,o=i.canvasData,r=!1;return n(e)&&(e=t),t=G(t),e=G(e),i.built&&!i.disabled&&i.options.movable&&(a(t)&&(o.left=t,r=!0),a(e)&&(o.top=e,r=!0),r&&i.renderCanvas(!0)),i},zoom:function(t,e){var i=this,a=i.canvasData;return t=G(t),t=0>t?1/(1-t):1+t,i.zoomTo(a.width*t/a.naturalWidth,e)},zoomTo:function(t,e){var i,a,n,o,r=this,l=r.options,c=r.canvasData,s=c.width,d=c.height,p=c.naturalWidth,u=c.naturalHeight;if(t=G(t),t>=0&&r.built&&!r.disabled&&l.zoomable){if(i=p*t,a=u*t,h(l.zoom)&&l.zoom.call(r.element,{originalEvent:e,oldRatio:s/p,ratio:i/p})===!1)return r;e?(n=L(r.cropper),o=e.touches?X(e.touches):{pageX:e.pageX,pageY:e.pageY},c.left-=(i-s)*((o.pageX-n.left-c.left)/s),c.top-=(a-d)*((o.pageY-n.top-c.top)/d)):(c.left-=(i-s)/2,c.top-=(a-d)/2),c.width=i,c.height=a,r.renderCanvas(!0)}return r},rotate:function(t){var e=this;return e.rotateTo((e.imageData.rotate||0)+G(t))},rotateTo:function(t){var e=this;return t=G(t),a(t)&&e.built&&!e.disabled&&e.options.rotatable&&(e.imageData.rotate=t%360,e.rotated=!0,e.renderCanvas(!0)),e},scale:function(t,e){var i=this,o=i.imageData,r=!1;return n(e)&&(e=t),t=G(t),e=G(e),i.built&&!i.disabled&&i.options.scalable&&(a(t)&&(o.scaleX=t,r=!0),a(e)&&(o.scaleY=e,r=!0),r&&i.renderImage(!0)),i},scaleX:function(t){var e=this,i=e.imageData.scaleY;return e.scale(t,a(i)?i:1)},scaleY:function(t){var e=this,i=e.imageData.scaleX;return e.scale(a(i)?i:1,t)},getData:function(t){var e,i,a=this,n=a.options,o=a.imageData,r=a.canvasData,h=a.cropBoxData;return a.built&&a.cropped?(i={x:h.left-r.left,y:h.top-r.top,width:h.width,height:h.height},e=o.width/o.naturalWidth,d(i,function(a,n){a/=e,i[n]=t?Ft(a):a})):i={x:0,y:0,width:0,height:0},n.rotatable&&(i.rotate=o.rotate||0),n.scalable&&(i.scaleX=o.scaleX||1,i.scaleY=o.scaleY||1),i},setData:function(t){var e,i,n,o=this,l=o.options,c=o.imageData,s=o.canvasData,d={};return h(t)&&(t=t.call(o.element)),o.built&&!o.disabled&&r(t)&&(l.rotatable&&a(t.rotate)&&t.rotate!==c.rotate&&(c.rotate=t.rotate,o.rotated=e=!0),l.scalable&&(a(t.scaleX)&&t.scaleX!==c.scaleX&&(c.scaleX=t.scaleX,i=!0),a(t.scaleY)&&t.scaleY!==c.scaleY&&(c.scaleY=t.scaleY,i=!0)),e?o.renderCanvas():i&&o.renderImage(),n=c.width/c.naturalWidth,a(t.x)&&(d.left=t.x*n+s.left),a(t.y)&&(d.top=t.y*n+s.top),a(t.width)&&(d.width=t.width*n),a(t.height)&&(d.height=t.height*n),o.setCropBoxData(d)),o},getContainerData:function(){var t=this;return t.built?t.containerData:{}},getImageData:function(){var t=this;return t.ready?t.imageData:{}},getCanvasData:function(){var t=this,e=t.canvasData,i={};return t.built&&d(["left","top","width","height","naturalWidth","naturalHeight"],function(t){i[t]=e[t]}),i},setCanvasData:function(t){var e=this,i=e.canvasData,n=i.aspectRatio;return h(t)&&(t=t.call(e.element)),e.built&&!e.disabled&&r(t)&&(a(t.left)&&(i.left=t.left),a(t.top)&&(i.top=t.top),a(t.width)?(i.width=t.width,i.height=t.width/n):a(t.height)&&(i.height=t.height,i.width=t.height*n),e.renderCanvas(!0)),e},getCropBoxData:function(){var t,e=this,i=e.cropBoxData;return e.built&&e.cropped&&(t={left:i.left,top:i.top,width:i.width,height:i.height}),t||{}},setCropBoxData:function(t){var e,i,n=this,o=n.cropBoxData,l=n.options.aspectRatio;return h(t)&&(t=t.call(n.element)),n.built&&n.cropped&&!n.disabled&&r(t)&&(a(t.left)&&(o.left=t.left),a(t.top)&&(o.top=t.top),a(t.width)&&(e=!0,o.width=t.width),a(t.height)&&(i=!0,o.height=t.height),l&&(e?o.height=o.width/l:i&&(o.width=o.height*l)),n.renderCropBox()),n},getCroppedCanvas:function(t){var e,i,a,n,o,h,l,c,s,d,p,u=this;return u.built&&u.cropped&&At?(r(t)||(t={}),p=u.getData(),e=p.width,i=p.height,c=e/i,r(t)&&(o=t.width,h=t.height,o?(h=o/c,l=o/e):h&&(o=h*c,l=h/i)),a=Vt(o||e),n=Vt(h||i),s=W("canvas"),s.width=a,s.height=n,d=s.getContext("2d"),t.fillColor&&(d.fillStyle=t.fillColor,d.fillRect(0,0,a,n)),d.drawImage.apply(d,function(){var t,a,n,o,r,h,c=A(u.image,u.imageData),s=c.width,d=c.height,g=[c],f=p.x,m=p.y;return-e>=f||f>s?f=t=n=r=0:0>=f?(n=-f,f=0,t=r=It(s,e+f)):s>=f&&(n=0,t=r=It(e,s-f)),0>=t||-i>=m||m>d?m=a=o=h=0:0>=m?(o=-m,m=0,a=h=It(d,i+m)):d>=m&&(o=0,a=h=It(i,d-m)),g.push(Vt(f),Vt(m),Vt(t),Vt(a)),l&&(n*=l,o*=l,r*=l,h*=l),r>0&&h>0&&g.push(Vt(n),Vt(o),Vt(r),Vt(h)),g}.call(u)),s):void 0},setAspectRatio:function(t){var e=this,i=e.options;return e.disabled||n(t)||(i.aspectRatio=St(0,t)||NaN,e.built&&(e.initCropBox(),e.cropped&&e.renderCropBox())),e},setDragMode:function(t){var e,i,a=this,n=a.options,o=a.dragBox,r=a.face;return a.ready&&!a.disabled&&(e=t===zt,i=n.movable&&t===Rt,t=e||i?t:Ut,x(o,Tt,t),w(o,ot,e),w(o,nt,i),n.cropBoxMovable||(x(r,Tt,t),w(r,ot,e),w(r,nt,i))),a}},j.DEFAULTS={viewMode:0,dragMode:"crop",aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,build:null,built:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},j.TEMPLATE=function(t,e){return e=e.split(","),t.replace(/\d+/g,function(t){return e[t]})}('<0 6="5-container"><0 6="5-wrap-9"><0 6="5-canvas"><0 6="5-drag-9"><0 6="5-crop-9"><1 6="5-view-9"><1 6="5-8 8-h"><1 6="5-8 8-v"><1 6="5-center"><1 6="5-face"><1 6="5-7 7-e" 3-2="e"><1 6="5-7 7-n" 3-2="n"><1 6="5-7 7-w" 3-2="w"><1 6="5-7 7-s" 3-2="s"><1 6="5-4 4-e" 3-2="e"><1 6="5-4 4-n" 3-2="n"><1 6="5-4 4-w" 3-2="w"><1 6="5-4 4-s" 3-2="s"><1 6="5-4 4-ne" 3-2="ne"><1 6="5-4 4-nw" 3-2="nw"><1 6="5-4 4-sw" 3-2="sw"><1 6="5-4 4-se" 3-2="se">',"div,span,action,data,point,cropper,class,line,dashed,box");var te=t.Cropper;return j.noConflict=function(){return t.Cropper=te,j},j.setDefaults=function(t){p(j.DEFAULTS,t)},"function"==typeof define&&define.amd&&define("cropper",[],function(){return j}),e||(t.Cropper=j),j}); \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 0477c9fbb..e310bc5f6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -41,7 +41,7 @@