From 54d7f0ee1fb44dd133aaeee3103d7a7e5fec9063 Mon Sep 17 00:00:00 2001 From: Fengyuan Chen Date: Wed, 18 Oct 2017 21:26:31 +0800 Subject: [PATCH] build: release 3.1.2 --- CHANGELOG.md | 5 +++ dist/cropper.common.js | 46 +++++++++++++++++++------- dist/cropper.css | 4 +-- dist/cropper.esm.js | 46 +++++++++++++++++++------- dist/cropper.js | 46 +++++++++++++++++++------- dist/cropper.min.css | 4 +-- dist/cropper.min.js | 6 ++-- docs/css/cropper.css | 4 +-- docs/index.html | 2 +- docs/js/cropper.js | 46 +++++++++++++++++++------- package-lock.json | 74 +++++++++++++++++++++++------------------- package.json | 12 +++---- 12 files changed, 198 insertions(+), 97 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79a92ebe..d52f02d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.1.2 (Oct 18, 2017) + +- Normalize related decimal numbers when crop an image with canvas (#918). +- Ignore unnecessary files when publish to NPM (#928). + ## 3.1.1 (Oct 11, 2017) - Supports to load in node environment. diff --git a/dist/cropper.common.js b/dist/cropper.common.js index 42d59940..73490079 100644 --- a/dist/cropper.common.js +++ b/dist/cropper.common.js @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.1 + * Cropper v3.1.2 * https://github.com/fengyuanchen/cropper * * Copyright (c) 2014-2017 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-11T13:34:24.201Z + * Date: 2017-10-18T13:23:24.651Z */ 'use strict'; @@ -170,6 +170,8 @@ var DEFAULTS = { var TEMPLATE = '
' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '
'; +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + /** * Check if the given value is a string. * @param {*} value - The value to check. @@ -238,6 +240,21 @@ var objectKeys = Object.keys || function objectKeys(obj) { return keys; }; +var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/i; + +/** + * Normalize decimal number. + * Check out {@link http://0.30000000000000004.com/ } + * @param {number} value - The value to normalize. + * @param {number} [times=100000000000] - The times for normalizing. + * @returns {number} Returns the normalized number. + */ +function normalizeDecimalNumber(value) { + var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100000000000; + + return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value; +} + var location = global.location; var REGEXP_ORIGINS = /^(https?:)\/\/([^:/?#]+):?(\d*)/i; @@ -524,9 +541,10 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight)); var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); + var params = [-imageNaturalWidth / 2, -imageNaturalHeight / 2, imageNaturalWidth, imageNaturalHeight]; - canvas.width = width; - canvas.height = height; + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = fillColor; context.fillRect(0, 0, width, height); context.save(); @@ -535,7 +553,9 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage(image, Math.floor(-imageNaturalWidth / 2), Math.floor(-imageNaturalHeight / 2), Math.floor(imageNaturalWidth), Math.floor(imageNaturalHeight)); + context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); context.restore(); return canvas; } @@ -1978,6 +1998,8 @@ var change = { } }; +function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + var methods = { // Show the crop box manually crop: function crop() { @@ -2623,9 +2645,8 @@ var methods = { var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); - canvas.width = width; - canvas.height = height; - + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = options.fillColor || 'transparent'; context.fillRect(0, 0, width, height); @@ -2690,17 +2711,18 @@ var methods = { // All the numerical parameters should be integer for `drawImage` // https://github.com/fengyuanchen/cropper/issues/476 - var params = [Math.floor(srcX), Math.floor(srcY), Math.floor(srcWidth), Math.floor(srcHeight)]; + var params = [srcX, srcY, srcWidth, srcHeight]; // Avoid "IndexSizeError" if (dstWidth > 0 && dstHeight > 0) { var scale = width / initialWidth; - params.push(Math.floor(dstX * scale), Math.floor(dstY * scale), Math.floor(dstWidth * scale), Math.floor(dstHeight * scale)); + params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(params)); - + context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); return canvas; }, diff --git a/dist/cropper.css b/dist/cropper.css index 31257dc7..9b9716c3 100644 --- a/dist/cropper.css +++ b/dist/cropper.css @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.1 + * Cropper v3.1.2 * https://github.com/fengyuanchen/cropper * * Copyright (c) 2014-2017 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-11T13:34:16.708Z + * Date: 2017-10-18T13:22:12.595Z */ .cropper-container { diff --git a/dist/cropper.esm.js b/dist/cropper.esm.js index a4d1074b..1778bf78 100644 --- a/dist/cropper.esm.js +++ b/dist/cropper.esm.js @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.1 + * Cropper v3.1.2 * https://github.com/fengyuanchen/cropper * * Copyright (c) 2014-2017 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-11T13:34:24.201Z + * Date: 2017-10-18T13:23:24.651Z */ import $ from 'jquery'; @@ -166,6 +166,8 @@ var DEFAULTS = { var TEMPLATE = '
' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '
'; +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + /** * Check if the given value is a string. * @param {*} value - The value to check. @@ -234,6 +236,21 @@ var objectKeys = Object.keys || function objectKeys(obj) { return keys; }; +var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/i; + +/** + * Normalize decimal number. + * Check out {@link http://0.30000000000000004.com/ } + * @param {number} value - The value to normalize. + * @param {number} [times=100000000000] - The times for normalizing. + * @returns {number} Returns the normalized number. + */ +function normalizeDecimalNumber(value) { + var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100000000000; + + return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value; +} + var location = global.location; var REGEXP_ORIGINS = /^(https?:)\/\/([^:/?#]+):?(\d*)/i; @@ -520,9 +537,10 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight)); var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); + var params = [-imageNaturalWidth / 2, -imageNaturalHeight / 2, imageNaturalWidth, imageNaturalHeight]; - canvas.width = width; - canvas.height = height; + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = fillColor; context.fillRect(0, 0, width, height); context.save(); @@ -531,7 +549,9 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage(image, Math.floor(-imageNaturalWidth / 2), Math.floor(-imageNaturalHeight / 2), Math.floor(imageNaturalWidth), Math.floor(imageNaturalHeight)); + context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); context.restore(); return canvas; } @@ -1974,6 +1994,8 @@ var change = { } }; +function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + var methods = { // Show the crop box manually crop: function crop() { @@ -2619,9 +2641,8 @@ var methods = { var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); - canvas.width = width; - canvas.height = height; - + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = options.fillColor || 'transparent'; context.fillRect(0, 0, width, height); @@ -2686,17 +2707,18 @@ var methods = { // All the numerical parameters should be integer for `drawImage` // https://github.com/fengyuanchen/cropper/issues/476 - var params = [Math.floor(srcX), Math.floor(srcY), Math.floor(srcWidth), Math.floor(srcHeight)]; + var params = [srcX, srcY, srcWidth, srcHeight]; // Avoid "IndexSizeError" if (dstWidth > 0 && dstHeight > 0) { var scale = width / initialWidth; - params.push(Math.floor(dstX * scale), Math.floor(dstY * scale), Math.floor(dstWidth * scale), Math.floor(dstHeight * scale)); + params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(params)); - + context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); return canvas; }, diff --git a/dist/cropper.js b/dist/cropper.js index 86e7c826..0669958b 100644 --- a/dist/cropper.js +++ b/dist/cropper.js @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.1 + * Cropper v3.1.2 * https://github.com/fengyuanchen/cropper * * Copyright (c) 2014-2017 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-11T13:34:24.201Z + * Date: 2017-10-18T13:23:24.651Z */ (function (global, factory) { @@ -172,6 +172,8 @@ var DEFAULTS = { var TEMPLATE = '
' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '
'; +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + /** * Check if the given value is a string. * @param {*} value - The value to check. @@ -240,6 +242,21 @@ var objectKeys = Object.keys || function objectKeys(obj) { return keys; }; +var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/i; + +/** + * Normalize decimal number. + * Check out {@link http://0.30000000000000004.com/ } + * @param {number} value - The value to normalize. + * @param {number} [times=100000000000] - The times for normalizing. + * @returns {number} Returns the normalized number. + */ +function normalizeDecimalNumber(value) { + var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100000000000; + + return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value; +} + var location = global.location; var REGEXP_ORIGINS = /^(https?:)\/\/([^:/?#]+):?(\d*)/i; @@ -526,9 +543,10 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight)); var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); + var params = [-imageNaturalWidth / 2, -imageNaturalHeight / 2, imageNaturalWidth, imageNaturalHeight]; - canvas.width = width; - canvas.height = height; + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = fillColor; context.fillRect(0, 0, width, height); context.save(); @@ -537,7 +555,9 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage(image, Math.floor(-imageNaturalWidth / 2), Math.floor(-imageNaturalHeight / 2), Math.floor(imageNaturalWidth), Math.floor(imageNaturalHeight)); + context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); context.restore(); return canvas; } @@ -1980,6 +2000,8 @@ var change = { } }; +function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + var methods = { // Show the crop box manually crop: function crop() { @@ -2625,9 +2647,8 @@ var methods = { var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); - canvas.width = width; - canvas.height = height; - + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = options.fillColor || 'transparent'; context.fillRect(0, 0, width, height); @@ -2692,17 +2713,18 @@ var methods = { // All the numerical parameters should be integer for `drawImage` // https://github.com/fengyuanchen/cropper/issues/476 - var params = [Math.floor(srcX), Math.floor(srcY), Math.floor(srcWidth), Math.floor(srcHeight)]; + var params = [srcX, srcY, srcWidth, srcHeight]; // Avoid "IndexSizeError" if (dstWidth > 0 && dstHeight > 0) { var scale = width / initialWidth; - params.push(Math.floor(dstX * scale), Math.floor(dstY * scale), Math.floor(dstWidth * scale), Math.floor(dstHeight * scale)); + params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(params)); - + context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); return canvas; }, diff --git a/dist/cropper.min.css b/dist/cropper.min.css index 86806461..3ea9d70a 100644 --- a/dist/cropper.min.css +++ b/dist/cropper.min.css @@ -1,10 +1,10 @@ /*! - * Cropper v3.1.1 + * Cropper v3.1.2 * https://github.com/fengyuanchen/cropper * * Copyright (c) 2014-2017 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-11T13:34:16.708Z + * Date: 2017-10-18T13:22:12.595Z */.cropper-container{direction:ltr;font-size:0;line-height:0;position:relative;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.cropper-container img{display:block;height:100%;image-orientation:0deg;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{bottom:0;left:0;position:absolute;right:0;top:0}.cropper-canvas,.cropper-wrap-box{overflow:hidden}.cropper-drag-box{background-color:#fff;opacity:0}.cropper-modal{background-color:#000;opacity:.5}.cropper-view-box{display:block;height:100%;outline-color:rgba(51,153,255,.75);outline:1px solid #39f;overflow:hidden;width:100%}.cropper-dashed{border:0 dashed #eee;display:block;opacity:.5;position:absolute}.cropper-dashed.dashed-h{border-bottom-width:1px;border-top-width:1px;height:33.33333%;left:0;top:33.33333%;width:100%}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;height:100%;left:33.33333%;top:0;width:33.33333%}.cropper-center{display:block;height:0;left:50%;opacity:.75;position:absolute;top:50%;width:0}.cropper-center:after,.cropper-center:before{background-color:#eee;content:" ";display:block;position:absolute}.cropper-center:before{height:1px;left:-3px;top:0;width:7px}.cropper-center:after{height:7px;left:0;top:-3px;width:1px}.cropper-face,.cropper-line,.cropper-point{display:block;height:100%;opacity:.1;position:absolute;width:100%}.cropper-face{background-color:#fff;left:0;top:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:e-resize;right:-3px;top:0;width:5px}.cropper-line.line-n{cursor:n-resize;height:5px;left:0;top:-3px}.cropper-line.line-w{cursor:w-resize;left:-3px;top:0;width:5px}.cropper-line.line-s{bottom:-3px;cursor:s-resize;height:5px;left:0}.cropper-point{background-color:#39f;height:5px;opacity:.75;width:5px}.cropper-point.point-e{cursor:e-resize;margin-top:-3px;right:-3px;top:50%}.cropper-point.point-n{cursor:n-resize;left:50%;margin-left:-3px;top:-3px}.cropper-point.point-w{cursor:w-resize;left:-3px;margin-top:-3px;top:50%}.cropper-point.point-s{bottom:-3px;cursor:s-resize;left:50%;margin-left:-3px}.cropper-point.point-ne{cursor:ne-resize;right:-3px;top:-3px}.cropper-point.point-nw{cursor:nw-resize;left:-3px;top:-3px}.cropper-point.point-sw{bottom:-3px;cursor:sw-resize;left:-3px}.cropper-point.point-se{bottom:-3px;cursor:se-resize;height:20px;opacity:1;right:-3px;width:20px}@media (min-width:768px){.cropper-point.point-se{height:15px;width:15px}}@media (min-width:992px){.cropper-point.point-se{height:10px;width:10px}}@media (min-width:1200px){.cropper-point.point-se{height:5px;opacity:.75;width:5px}}.cropper-point.point-se:before{background-color:#39f;bottom:-50%;content:" ";display:block;height:200%;opacity:0;position:absolute;right:-50%;width:200%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC")}.cropper-hide{display:block;height:0;position:absolute;width: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} /*# sourceMappingURL=cropper.min.css.map */ \ No newline at end of file diff --git a/dist/cropper.min.js b/dist/cropper.min.js index 84094a8b..cdc4c7bc 100644 --- a/dist/cropper.min.js +++ b/dist/cropper.min.js @@ -1,10 +1,10 @@ /*! - * Cropper v3.1.1 + * Cropper v3.1.2 * https://github.com/fengyuanchen/cropper * * Copyright (c) 2014-2017 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-11T13:34:24.201Z + * Date: 2017-10-18T13:23:24.651Z */ -!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],i):i(t.jQuery)}(this,function(t){"use strict";function i(t){return"string"==typeof t}function e(t){return"number"==typeof t&&!Y(t)}function a(t){return void 0===t}function o(t,i){for(var e=arguments.length,a=Array(e>2?e-2:0),o=2;o0};return o(a)&&o(e)?e*i>a?e=a/i:a=e*i:o(a)?e=a/i:o(e)&&(a=e*i),{width:a,height:e}}function m(t){var i=t.width,e=t.height,a=t.degree;if((a=Math.abs(a))%180==90)return{width:e,height:i};var o=a%90*Math.PI/180,n=Math.sin(o),h=Math.cos(o);return{width:i*h+e*n,height:i*n+e*h}}function g(t,i,e,a){var o=i.naturalWidth,n=i.naturalHeight,h=i.rotate,s=i.scaleX,r=i.scaleY,c=e.aspectRatio,d=e.naturalWidth,l=e.naturalHeight,m=a.fillColor,g=void 0===m?"transparent":m,u=a.imageSmoothingEnabled,f=void 0===u||u,v=a.imageSmoothingQuality,w=void 0===v?"low":v,x=a.maxWidth,b=void 0===x?1/0:x,y=a.maxHeight,M=void 0===y?1/0:y,C=a.minWidth,$=void 0===C?0:C,B=a.minHeight,k=void 0===B?0:B,W=p({aspectRatio:c,width:b,height:M}),T=p({aspectRatio:c,width:$,height:k}),D=Math.min(W.width,Math.max(T.width,d)),H=Math.min(W.height,Math.max(T.height,l)),Y=document.createElement("canvas"),X=Y.getContext("2d");return Y.width=D,Y.height=H,X.fillStyle=g,X.fillRect(0,0,D,H),X.save(),X.translate(D/2,H/2),X.rotate(h*Math.PI/180),X.scale(s,r),X.imageSmoothingEnabled=!!f,X.imageSmoothingQuality=w,X.drawImage(t,Math.floor(-o/2),Math.floor(-n/2),Math.floor(o),Math.floor(n)),X.restore(),Y}function u(t,i,e){var a="",o=void 0;for(e+=i,o=i;o=8&&(n=r+d)}}}if(n){var l=i.getUint16(n,a),p=void 0,m=void 0;for(m=0;mi.width?3===a?r=i.height*s:c=i.width/s:3===a?c=i.width/s:r=i.height*s;var d={aspectRatio:s,naturalWidth:n,naturalHeight:h,width:r,height:c};d.left=(i.width-r)/2,d.top=(i.height-c)/2,d.oldLeft=d.left,d.oldTop=d.top,this.canvas=d,this.limited=1===a||2===a,this.limitCanvas(!0,!0),this.initialImage=t.extend({},e),this.initialCanvas=t.extend({},d)},limitCanvas:function(t,i){var e=this.options,a=this.container,o=this.canvas,n=this.cropBox,h=e.viewMode,s=o.aspectRatio,r=this.cropped&&n;if(t){var c=Number(e.minCanvasWidth)||0,d=Number(e.minCanvasHeight)||0;h>0&&(h>1?(c=Math.max(c,a.width),d=Math.max(d,a.height),3===h&&(d*s>c?c=d*s:d=c/s)):c?c=Math.max(c,r?n.width:0):d?d=Math.max(d,r?n.height:0):r&&(c=n.width,(d=n.height)*s>c?c=d*s:d=c/s));var l=p({aspectRatio:s,width:c,height:d});c=l.width,d=l.height,o.minWidth=c,o.minHeight=d,o.maxWidth=1/0,o.maxHeight=1/0}if(i)if(h>0){var m=a.width-o.width,g=a.height-o.height;o.minLeft=Math.min(0,m),o.minTop=Math.min(0,g),o.maxLeft=Math.max(0,m),o.maxTop=Math.max(0,g),r&&this.limited&&(o.minLeft=Math.min(n.left,n.left+n.width-o.width),o.minTop=Math.min(n.top,n.top+n.height-o.height),o.maxLeft=n.left,o.maxTop=n.top,2===h&&(o.width>=a.width&&(o.minLeft=Math.min(0,m),o.maxLeft=Math.max(0,m)),o.height>=a.height&&(o.minTop=Math.min(0,g),o.maxTop=Math.max(0,g))))}else o.minLeft=-o.width,o.minTop=-o.height,o.maxLeft=a.width,o.maxTop=a.height},renderCanvas:function(t,i){var e=this.canvas,a=this.image;if(i){var o=m({width:a.naturalWidth*Math.abs(a.scaleX),height:a.naturalHeight*Math.abs(a.scaleY),degree:a.rotate}),n=o.width,h=o.height,r=e.width*(n/e.naturalWidth),c=e.height*(h/e.naturalHeight);e.left-=(r-e.width)/2,e.top-=(c-e.height)/2,e.width=r,e.height=c,e.aspectRatio=n/h,e.naturalWidth=n,e.naturalHeight=h,this.limitCanvas(!0,!1)}(e.width>e.maxWidth||e.widthe.maxHeight||e.heighte.width?n.height=n.width/a:n.width=n.height*a),this.cropBox=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*o),n.height=Math.max(n.minHeight,n.height*o),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBox=t.extend({},n)},limitCropBox:function(t,i){var e=this.options,a=this.container,o=this.canvas,n=this.cropBox,h=this.limited,s=e.aspectRatio;if(t){var r=Number(e.minCropBoxWidth)||0,c=Number(e.minCropBoxHeight)||0,d=Math.min(a.width,h?o.width:a.width),l=Math.min(a.height,h?o.height:a.height);r=Math.min(r,a.width),c=Math.min(c,a.height),s&&(r&&c?c*s>r?c=r/s:r=c*s:r?c=r/s:c&&(r=c*s),l*s>d?l=d/s:d=l*s),n.minWidth=Math.min(r,d),n.minHeight=Math.min(c,l),n.maxWidth=d,n.maxHeight=l}i&&(h?(n.minLeft=Math.max(0,o.left),n.minTop=Math.max(0,o.top),n.maxLeft=Math.min(a.width,o.left+o.width)-n.width,n.maxTop=Math.min(a.height,o.top+o.height)-n.height):(n.minLeft=0,n.minTop=0,n.maxLeft=a.width-n.width,n.maxTop=a.height-n.height))},renderCropBox:function(){var t=this.options,i=this.container,e=this.cropBox;(e.width>e.maxWidth||e.widthe.maxHeight||e.height=i.width&&e.height>=i.height?"move":"all"),this.$cropBox.css({width:e.width,height:e.height,transform:s({translateX:e.left,translateY:e.top})}),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),this.completed&&this.trigger("crop",this.getData())}},U={initPreview:function(){var i=this.crossOrigin,e=i?this.crossOriginUrl:this.url,a=document.createElement("img");i&&(a.crossOrigin=i),a.src=e;var o=t(a);this.$preview=t(this.options.preview),this.$clone2=o,this.$viewBox.html(o),this.$preview.each(function(a,o){var n=t(o),h=document.createElement("img");n.data("preview",{width:n.width(),height:n.height(),html:n.html()}),i&&(h.crossOrigin=i),h.src=e,h.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',n.html(h)})},resetPreview:function(){this.$preview.each(function(i,e){var a=t(e),o=a.data("preview");a.css({width:o.width,height:o.height}).html(o.html).removeData("preview")})},preview:function(){var i=this.image,e=this.canvas,a=this.cropBox,o=a.width,n=a.height,h=i.width,r=i.height,c=a.left-e.left-i.left,d=a.top-e.top-i.top;this.cropped&&!this.disabled&&(this.$clone2.css({width:h,height:r,transform:s(t.extend({translateX:-c,translateY:-d},i))}),this.$preview.each(function(e,a){var l=t(a),p=l.data("preview"),m=p.width,g=p.height,u=m,f=g,v=1;o&&(f=n*(v=m/o)),n&&f>g&&(u=o*(v=g/n),f=g),l.css({width:u,height:f}).find("img").css({width:h*v,height:r*v,transform:s(t.extend({translateX:-c*v,translateY:-d*v},i))})}))}},F={bind:function(){var i=this.$element,e=this.options,a=this.$cropper;t.isFunction(e.cropstart)&&i.on("cropstart",e.cropstart),t.isFunction(e.cropmove)&&i.on("cropmove",e.cropmove),t.isFunction(e.cropend)&&i.on("cropend",e.cropend),t.isFunction(e.crop)&&i.on("crop",e.crop),t.isFunction(e.zoom)&&i.on("zoom",e.zoom),a.on(C,o(this.cropStart,this)),e.zoomable&&e.zoomOnWheel&&a.on("wheel mousewheel DOMMouseScroll",o(this.wheel,this)),e.toggleDragModeOnDblclick&&a.on("dblclick",o(this.dblclick,this)),t(document).on($,this.onCropMove=o(this.cropMove,this)).on(B,this.onCropEnd=o(this.cropEnd,this)),e.responsive&&t(y).on("resize",this.onResize=o(this.resize,this))},unbind:function(){var i=this.$element,e=this.options,a=this.$cropper;t.isFunction(e.cropstart)&&i.off("cropstart",e.cropstart),t.isFunction(e.cropmove)&&i.off("cropmove",e.cropmove),t.isFunction(e.cropend)&&i.off("cropend",e.cropend),t.isFunction(e.crop)&&i.off("crop",e.crop),t.isFunction(e.zoom)&&i.off("zoom",e.zoom),a.off(C,this.cropStart),e.zoomable&&e.zoomOnWheel&&a.off("wheel mousewheel DOMMouseScroll",this.wheel),e.toggleDragModeOnDblclick&&a.off("dblclick",this.dblclick),t(document).off($,this.onCropMove).off(B,this.onCropEnd),e.responsive&&t(y).off("resize",this.onResize)}},S={resize:function(){var i=this.options,e=this.$container,a=this.container,o=Number(i.minContainerWidth)||200,n=Number(i.minContainerHeight)||100;if(!(this.disabled||a.width<=o||a.height<=n)){var h=e.width()/a.width;if(1!==h||e.height()!==a.height){var s=void 0,r=void 0;i.restore&&(s=this.getCanvasData(),r=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(t.each(s,function(t,i){s[t]=i*h})),this.setCropBoxData(t.each(r,function(t,i){r[t]=i*h})))}}},dblclick:function(){this.disabled||"none"===this.options.dragMode||this.setDragMode(this.$dragBox.hasClass("cropper-crop")?"move":"crop")},wheel:function(t){var i=this,e=t.originalEvent||t,a=Number(this.options.wheelZoomRatio)||.1;if(!this.disabled&&(t.preventDefault(),!this.wheeling)){this.wheeling=!0,setTimeout(function(){i.wheeling=!1},50);var o=1;e.deltaY?o=e.deltaY>0?1:-1:e.wheelDelta?o=-e.wheelDelta/120:e.detail&&(o=e.detail>0?1:-1),this.zoom(-o*a,t)}},cropStart:function(i){if(!this.disabled){var e=this.options,a=this.pointers,o=i.originalEvent,n=void 0;o&&o.changedTouches?t.each(o.changedTouches,function(t,i){a[i.identifier]=d(i)}):a[o&&o.pointerId||0]=d(o||i),n=X(a).length>1&&e.zoomable&&e.zoomOnTouch?"zoom":t(i.target).data("action"),k.test(n)&&(this.trigger("cropstart",{originalEvent:o,action:n}).isDefaultPrevented()||(i.preventDefault(),this.action=n,this.cropping=!1,"crop"===n&&(this.cropping=!0,this.$dragBox.addClass("cropper-modal"))))}},cropMove:function(i){var e=this.action;if(!this.disabled&&e){var a=this.pointers,o=i.originalEvent;i.preventDefault(),this.trigger("cropmove",{originalEvent:o,action:e}).isDefaultPrevented()||(o&&o.changedTouches?t.each(o.changedTouches,function(i,e){t.extend(a[e.identifier],d(e,!0))}):t.extend(a[o&&o.pointerId||0],d(o||i,!0)),this.change(i))}},cropEnd:function(i){if(!this.disabled){var e=this.action,a=this.pointers,o=i.originalEvent;o&&o.changedTouches?t.each(o.changedTouches,function(t,i){delete a[i.identifier]}):delete a[o&&o.pointerId||0],e&&(i.preventDefault(),X(a).length||(this.action=""),this.cropping&&(this.cropping=!1,this.$dragBox.toggleClass("cropper-modal",this.cropped&&this.options.modal)),this.trigger("cropend",{originalEvent:o,action:e}))}}},j={change:function(i){var e=this.options,a=this.pointers,o=this.container,n=this.canvas,h=this.cropBox,s=this.action,r=e.aspectRatio,d=h.left,l=h.top,p=h.width,m=h.height,g=d+p,u=l+m,f=0,v=0,w=o.width,x=o.height,b=!0,y=void 0;!r&&i.shiftKey&&(r=p&&m?p/m:1),this.limited&&(f=h.minLeft,v=h.minTop,w=f+Math.min(o.width,n.width,n.left+n.width),x=v+Math.min(o.height,n.height,n.top+n.height));var C=a[X(a)[0]],$={x:C.endX-C.startX,y:C.endY-C.startY},B=function(t){switch(t){case"e":g+$.x>w&&($.x=w-g);break;case"w":d+$.xx&&($.y=x-u)}};switch(s){case"all":d+=$.x,l+=$.y;break;case"e":if($.x>=0&&(g>=w||r&&(l<=v||u>=x))){b=!1;break}B("e"),p+=$.x,r&&(m=p/r,l-=$.x/r/2),p<0&&(s="w",p=0);break;case"n":if($.y<=0&&(l<=v||r&&(d<=f||g>=w))){b=!1;break}B("n"),m-=$.y,l+=$.y,r&&(p=m*r,d+=$.y*r/2),m<0&&(s="s",m=0);break;case"w":if($.x<=0&&(d<=f||r&&(l<=v||u>=x))){b=!1;break}B("w"),p-=$.x,d+=$.x,r&&(m=p/r,l+=$.x/r/2),p<0&&(s="e",p=0);break;case"s":if($.y>=0&&(u>=x||r&&(d<=f||g>=w))){b=!1;break}B("s"),m+=$.y,r&&(p=m*r,d-=$.y*r/2),m<0&&(s="n",m=0);break;case"ne":if(r){if($.y<=0&&(l<=v||g>=w)){b=!1;break}B("n"),m-=$.y,l+=$.y,p=m*r}else B("n"),B("e"),$.x>=0?gv&&(m-=$.y,l+=$.y):(m-=$.y,l+=$.y);p<0&&m<0?(s="sw",m=0,p=0):p<0?(s="nw",p=0):m<0&&(s="se",m=0);break;case"nw":if(r){if($.y<=0&&(l<=v||d<=f)){b=!1;break}B("n"),m-=$.y,l+=$.y,p=m*r,d+=$.y*r}else B("n"),B("w"),$.x<=0?d>f?(p-=$.x,d+=$.x):$.y<=0&&l<=v&&(b=!1):(p-=$.x,d+=$.x),$.y<=0?l>v&&(m-=$.y,l+=$.y):(m-=$.y,l+=$.y);p<0&&m<0?(s="se",m=0,p=0):p<0?(s="ne",p=0):m<0&&(s="sw",m=0);break;case"sw":if(r){if($.x<=0&&(d<=f||u>=x)){b=!1;break}B("w"),p-=$.x,d+=$.x,m=p/r}else B("s"),B("w"),$.x<=0?d>f?(p-=$.x,d+=$.x):$.y>=0&&u>=x&&(b=!1):(p-=$.x,d+=$.x),$.y>=0?u=0&&(g>=w||u>=x)){b=!1;break}B("e"),m=(p+=$.x)/r}else B("s"),B("e"),$.x>=0?g=0&&u>=x&&(b=!1):p+=$.x,$.y>=0?u0?s=$.y>0?"se":"ne":$.x<0&&(d-=p,s=$.y>0?"sw":"nw"),$.y<0&&(l-=m),this.cropped||(this.$cropBox.removeClass(M),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}b&&(h.width=p,h.height=m,h.left=d,h.top=l,this.action=s,this.renderCropBox()),t.each(a,function(t,i){i.startX=i.endX,i.startY=i.endY})}},A={crop:function(){this.ready&&!this.disabled&&(this.cropped||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&this.$dragBox.addClass("cropper-modal"),this.$cropBox.removeClass(M)),this.setCropBoxData(this.initialCropBox))},reset:function(){this.ready&&!this.disabled&&(this.image=t.extend({},this.initialImage),this.canvas=t.extend({},this.initialCanvas),this.cropBox=t.extend({},this.initialCropBox),this.renderCanvas(),this.cropped&&this.renderCropBox())},clear:function(){this.cropped&&!this.disabled&&(t.extend(this.cropBox,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),this.$dragBox.removeClass("cropper-modal"),this.$cropBox.addClass(M))},replace:function(t,i){!this.disabled&&t&&(this.isImg&&this.$element.attr("src",t),i?(this.url=t,this.$clone.attr("src",t),this.ready&&this.$preview.find("img").add(this.$clone2).attr("src",t)):(this.isImg&&(this.replaced=!0),this.options.data=null,this.load(t)))},enable:function(){this.ready&&(this.disabled=!1,this.$cropper.removeClass("cropper-disabled"))},disable:function(){this.ready&&(this.disabled=!0,this.$cropper.addClass("cropper-disabled"))},destroy:function(){var t=this.$element;this.loaded?(this.isImg&&this.replaced&&t.attr("src",this.originalUrl),this.unbuild(),t.removeClass(M)):this.isImg?t.off("load",this.start):this.$clone&&this.$clone.remove(),t.removeData("cropper")},move:function(t,i){var e=this.canvas,o=e.left,n=e.top;this.moveTo(a(t)?t:o+Number(t),a(i)?i:n+Number(i))},moveTo:function(t,i){var o=this.canvas,n=!1;a(i)&&(i=t),t=Number(t),i=Number(i),this.ready&&!this.disabled&&this.options.movable&&(e(t)&&(o.left=t,n=!0),e(i)&&(o.top=i,n=!0),n&&this.renderCanvas(!0))},zoom:function(t,i){var e=this.canvas;t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(e.width*t/e.naturalWidth,i)},zoomTo:function(t,i){var e=this.options,a=this.pointers,o=this.canvas,n=o.width,h=o.height,s=o.naturalWidth,r=o.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&e.zoomable){var c=s*t,d=r*t,p=void 0;if(i&&(p=i.originalEvent),this.trigger("zoom",{originalEvent:p,oldRatio:n/s,ratio:c/s}).isDefaultPrevented())return;if(p){var m=this.$cropper.offset(),g=a&&X(a).length?l(a):{pageX:i.pageX||p.pageX||0,pageY:i.pageY||p.pageY||0};o.left-=(c-n)*((g.pageX-m.left-o.left)/n),o.top-=(d-h)*((g.pageY-m.top-o.top)/h)}else o.left-=(c-n)/2,o.top-=(d-h)/2;o.width=c,o.height=d,this.renderCanvas(!0)}},rotate:function(t){this.rotateTo((this.image.rotate||0)+Number(t))},rotateTo:function(t){e(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.image.rotate=t%360,this.renderCanvas(!0,!0))},scaleX:function(t){var i=this.image.scaleY;this.scale(t,e(i)?i:1)},scaleY:function(t){var i=this.image.scaleX;this.scale(e(i)?i:1,t)},scale:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,a=this.image,o=!1;t=Number(t),i=Number(i),this.ready&&!this.disabled&&this.options.scalable&&(e(t)&&(a.scaleX=t,o=!0),e(i)&&(a.scaleY=i,o=!0),o&&this.renderCanvas(!0,!0))},getData:function(){var i=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.options,a=this.image,o=this.canvas,n=this.cropBox,h=void 0;if(this.ready&&this.cropped){h={x:n.left-o.left,y:n.top-o.top,width:n.width,height:n.height};var s=a.width/a.naturalWidth;t.each(h,function(t,e){e/=s,h[t]=i?Math.round(e):e})}else h={x:0,y:0,width:0,height:0};return e.rotatable&&(h.rotate=a.rotate||0),e.scalable&&(h.scaleX=a.scaleX||1,h.scaleY=a.scaleY||1),h},setData:function(i){var a=this.options,o=this.image,n=this.canvas,h={};if(t.isFunction(i)&&(i=i.call(this.element)),this.ready&&!this.disabled&&t.isPlainObject(i)){var s=!1;a.rotatable&&e(i.rotate)&&i.rotate!==o.rotate&&(o.rotate=i.rotate,s=!0),a.scalable&&(e(i.scaleX)&&i.scaleX!==o.scaleX&&(o.scaleX=i.scaleX,s=!0),e(i.scaleY)&&i.scaleY!==o.scaleY&&(o.scaleY=i.scaleY,s=!0)),s&&this.renderCanvas(!0,!0);var r=o.width/o.naturalWidth;e(i.x)&&(h.left=i.x*r+n.left),e(i.y)&&(h.top=i.y*r+n.top),e(i.width)&&(h.width=i.width*r),e(i.height)&&(h.height=i.height*r),this.setCropBoxData(h)}},getContainerData:function(){return this.ready?t.extend({},this.container):{}},getImageData:function(){return this.loaded?t.extend({},this.image):{}},getCanvasData:function(){var i=this.canvas,e={};return this.ready&&t.each(["left","top","width","height","naturalWidth","naturalHeight"],function(t,a){e[a]=i[a]}),e},setCanvasData:function(i){var a=this.canvas,o=a.aspectRatio;t.isFunction(i)&&(i=i.call(this.$element)),this.ready&&!this.disabled&&t.isPlainObject(i)&&(e(i.left)&&(a.left=i.left),e(i.top)&&(a.top=i.top),e(i.width)?(a.width=i.width,a.height=i.width/o):e(i.height)&&(a.height=i.height,a.width=i.height*o),this.renderCanvas(!0))},getCropBoxData:function(){var t=this.cropBox;return this.ready&&this.cropped?{left:t.left,top:t.top,width:t.width,height:t.height}:{}},setCropBoxData:function(i){var a=this.cropBox,o=this.options.aspectRatio,n=void 0,h=void 0;t.isFunction(i)&&(i=i.call(this.$element)),this.ready&&this.cropped&&!this.disabled&&t.isPlainObject(i)&&(e(i.left)&&(a.left=i.left),e(i.top)&&(a.top=i.top),e(i.width)&&i.width!==a.width&&(n=!0,a.width=i.width),e(i.height)&&i.height!==a.height&&(h=!0,a.height=i.height),o&&(n?a.height=a.width/o:h&&(a.width=a.height*o)),this.renderCropBox())},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!y.HTMLCanvasElement)return null;var i=this.canvas,e=g(this.$clone[0],this.image,i,t);if(!this.cropped)return e;var a=this.getData(),o=a.x,n=a.y,h=a.width,s=a.height,r=h/s,c=p({aspectRatio:r,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),d=p({aspectRatio:r,width:t.minWidth||0,height:t.minHeight||0}),l=p({aspectRatio:r,width:t.width||h,height:t.height||s}),m=l.width,u=l.height;m=Math.min(c.width,Math.max(d.width,m)),u=Math.min(c.height,Math.max(d.height,u));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=m,f.height=u,v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,m,u);var w=t.imageSmoothingEnabled,x=void 0===w||w,b=t.imageSmoothingQuality;v.imageSmoothingEnabled=x,b&&(v.imageSmoothingQuality=b);var M=e.width,C=e.height,$=o,B=n,k=void 0,W=void 0,T=void 0,D=void 0,H=void 0,Y=void 0;$<=-h||$>M?($=0,k=0,T=0,H=0):$<=0?(T=-$,$=0,H=k=Math.min(M,h+$)):$<=M&&(T=0,H=k=Math.min(h,M-$)),k<=0||B<=-s||B>C?(B=0,W=0,D=0,Y=0):B<=0?(D=-B,B=0,Y=W=Math.min(C,s+B)):B<=C&&(D=0,Y=W=Math.min(s,C-B));var X=[Math.floor($),Math.floor(B),Math.floor(k),Math.floor(W)];if(H>0&&Y>0){var O=m/h;X.push(Math.floor(T*O),Math.floor(D*O),Math.floor(H*O),Math.floor(Y*O))}return v.drawImage.apply(v,[e].concat(X)),f},setAspectRatio:function(t){var i=this.options;this.disabled||a(t)||(i.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox()))},setDragMode:function(t){var i=this.options,e=void 0,a=void 0;this.loaded&&!this.disabled&&(e="crop"===t,a=i.movable&&"move"===t,t=e||a?t:"none",this.$dragBox.data("action",t).toggleClass("cropper-crop",e).toggleClass("cropper-move",a),i.cropBoxMovable||this.$face.data("action",t).toggleClass("cropper-crop",e).toggleClass("cropper-move",a))}},q=function(){function t(t,i){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:{};if(b(this,i),!e||!D.test(e.tagName))throw new Error("The first argument is required and must be an or element.");this.element=e,this.$element=t(e),this.options=t.extend({},H,t.isPlainObject(a)&&a),this.completed=!1,this.cropped=!1,this.disabled=!1,this.isImg=!1,this.limited=!1,this.loaded=!1,this.ready=!1,this.replaced=!1,this.wheeling=!1,this.originalUrl="",this.canvas=null,this.cropBox=null,this.pointers={},this.init()}return q(i,[{key:"init",value:function(){var t=this.$element,i=void 0;if(t.is("img")){if(this.isImg=!0,i=t.attr("src")||"",this.originalUrl=i,!i)return;i=t.prop("src")}else t.is("canvas")&&y.HTMLCanvasElement&&(i=t[0].toDataURL());this.load(i)}},{key:"trigger",value:function(i,e){var a=t.Event(i,e);return this.$element.trigger(a),a}},{key:"load",value:function(t){var i=this;if(t){this.url=t,this.image={};var e=this.$element,a=this.options;if(a.checkOrientation&&y.ArrayBuffer)if(W.test(t))T.test(t)?this.read(f(t)):this.clone();else{var o=new XMLHttpRequest;o.onerror=function(){i.clone()},o.onload=function(){i.read(o.response)},a.checkCrossOrigin&&n(t)&&e.prop("crossOrigin")&&(t=h(t)),o.open("get",t),o.responseType="arraybuffer",o.withCredentials="use-credentials"===e.prop("crossOrigin"),o.send()}else this.clone()}}},{key:"read",value:function(t){var i=this.options,e=this.image,a=w(t),o=0,n=1,h=1;if(a>1){this.url=v(t,"image/jpeg");var s=x(a);o=s.rotate,n=s.scaleX,h=s.scaleY}i.rotatable&&(e.rotate=o),i.scalable&&(e.scaleX=n,e.scaleY=h),this.clone()}},{key:"clone",value:function(){var i=this.$element,e=this.options,a=this.url,o="",s=void 0;e.checkCrossOrigin&&n(a)&&((o=i.prop("crossOrigin"))?s=a:(o="anonymous",s=h(a))),this.crossOrigin=o,this.crossOriginUrl=s;var r=document.createElement("img");o&&(r.crossOrigin=o),r.src=s||a;var c=t(r);this.$clone=c,this.isImg?this.element.complete?this.start():i.one("load",t.proxy(this.start,this)):c.one("load",t.proxy(this.start,this)).one("error",t.proxy(this.stop,this)).addClass("cropper-hide").insertAfter(i)}},{key:"start",value:function(){var i=this,e=this.$clone,a=this.$element;this.isImg||(e.off("error",this.stop),a=e),r(a[0],function(e,a){t.extend(i.image,{naturalWidth:e,naturalHeight:a,aspectRatio:e/a}),i.loaded=!0,i.build()})}},{key:"stop",value:function(){this.$clone.remove(),this.$clone=null}},{key:"build",value:function(){var i=this;if(this.loaded){this.ready&&this.unbuild();var e=this.$element,a=this.options,o=this.$clone,n=t('
'),h=n.find(".cropper-crop-box"),s=h.find(".cropper-face");this.$container=e.parent(),this.$cropper=n,this.$canvas=n.find(".cropper-canvas").append(o),this.$dragBox=n.find(".cropper-drag-box"),this.$cropBox=h,this.$viewBox=n.find(".cropper-view-box"),this.$face=s,e.addClass(M).after(n),this.isImg||o.removeClass("cropper-hide"),this.initPreview(),this.bind(),a.aspectRatio=Math.max(0,a.aspectRatio)||NaN,a.viewMode=Math.max(0,Math.min(3,Math.round(a.viewMode)))||0,this.cropped=a.autoCrop,a.autoCrop?a.modal&&this.$dragBox.addClass("cropper-modal"):h.addClass(M),a.guides||h.find(".cropper-dashed").addClass(M),a.center||h.find(".cropper-center").addClass(M),a.cropBoxMovable&&s.addClass("cropper-move").data("action","all"),a.highlight||s.addClass("cropper-invisible"),a.background&&n.addClass("cropper-bg"),a.cropBoxResizable||h.find(".cropper-line,.cropper-point").addClass(M),this.setDragMode(a.dragMode),this.render(),this.ready=!0,this.setData(a.data),this.completing=setTimeout(function(){t.isFunction(a.ready)&&e.one("ready",a.ready),i.trigger("ready"),i.trigger("crop",i.getData()),i.completed=!0},0)}}},{key:"unbuild",value:function(){this.ready&&(this.completed||clearTimeout(this.completing),this.ready=!1,this.completed=!1,this.initialImage=null,this.initialCanvas=null,this.initialCropBox=null,this.container=null,this.canvas=null,this.cropBox=null,this.unbind(),this.resetPreview(),this.$preview=null,this.$viewBox=null,this.$cropBox=null,this.$dragBox=null,this.$canvas=null,this.$container=null,this.$cropper.remove(),this.$cropper=null)}}],[{key:"setDefaults",value:function(i){t.extend(H,t.isPlainObject(i)&&i)}}]),i}();if(t.extend&&t.extend(Q.prototype,I,U,F,S,j,A),t.fn){var K=t.fn.cropper;t.fn.cropper=function(e){for(var o=arguments.length,n=Array(o>1?o-1:0),h=1;h2?e-2:0),n=2;n1&&void 0!==arguments[1]?arguments[1]:1e11;return N.test(t)?Math.round(t*i)/i:t}function r(t){var i=t.match(L);return i&&(i[1]!==R.protocol||i[2]!==R.hostname||i[3]!==R.port)}function s(t){var i="timestamp="+(new Date).getTime();return t+(-1===t.indexOf("?")?"?":"&")+i}function c(t){var i=t.rotate,e=t.scaleX,n=t.scaleY,o=t.translateX,h=t.translateY,r=[];return a(o)&&0!==o&&r.push("translateX("+o+"px)"),a(h)&&0!==h&&r.push("translateY("+h+"px)"),a(i)&&0!==i&&r.push("rotate("+i+"deg)"),a(e)&&1!==e&&r.push("scaleX("+e+")"),a(n)&&1!==n&&r.push("scaleY("+n+")"),r.length?r.join(" "):"none"}function d(t,i){if(!t.naturalWidth||A){var e=document.createElement("img");e.onload=function(){i(e.width,e.height)},e.src=t.src}else i(t.naturalWidth,t.naturalHeight)}function l(i){var e=t.extend({},i),a=[];return t.each(i,function(i,n){delete e[i],t.each(e,function(t,i){var e=Math.abs(n.startX-i.startX),o=Math.abs(n.startY-i.startY),h=Math.abs(n.endX-i.endX),r=Math.abs(n.endY-i.endY),s=Math.sqrt(e*e+o*o),c=(Math.sqrt(h*h+r*r)-s)/s;a.push(c)})}),a.sort(function(t,i){return Math.abs(t)0};return n(a)&&n(e)?e*i>a?e=a/i:a=e*i:n(a)?e=a/i:n(e)&&(a=e*i),{width:a,height:e}}function u(t){var i=t.width,e=t.height,a=t.degree;if((a=Math.abs(a))%180==90)return{width:e,height:i};var n=a%90*Math.PI/180,o=Math.sin(n),h=Math.cos(n);return{width:i*h+e*o,height:i*o+e*h}}function f(e,a,n,o){var r=a.naturalWidth,s=a.naturalHeight,c=a.rotate,d=a.scaleX,l=a.scaleY,p=n.aspectRatio,m=n.naturalWidth,u=n.naturalHeight,f=o.fillColor,v=void 0===f?"transparent":f,w=o.imageSmoothingEnabled,x=void 0===w||w,b=o.imageSmoothingQuality,y=void 0===b?"low":b,C=o.maxWidth,M=void 0===C?1/0:C,$=o.maxHeight,B=void 0===$?1/0:$,k=o.minWidth,W=void 0===k?0:k,T=o.minHeight,D=void 0===T?0:T,H=g({aspectRatio:p,width:M,height:B}),Y=g({aspectRatio:p,width:W,height:D}),X=Math.min(H.width,Math.max(Y.width,m)),O=Math.min(H.height,Math.max(Y.height,u)),z=document.createElement("canvas"),E=z.getContext("2d"),N=[-r/2,-s/2,r,s];return z.width=h(X),z.height=h(O),E.fillStyle=v,E.fillRect(0,0,X,O),E.save(),E.translate(X/2,O/2),E.rotate(c*Math.PI/180),E.scale(d,l),E.imageSmoothingEnabled=!!x,E.imageSmoothingQuality=y,E.drawImage.apply(E,[e].concat(i(t.map(N,function(t){return Math.floor(h(t))})))),E.restore(),z}function v(t,i,e){var a="",n=void 0;for(e+=i,n=i;n=8&&(o=s+d)}}}if(o){var l=i.getUint16(o,a),p=void 0,m=void 0;for(m=0;mi.width?3===a?s=i.height*r:c=i.width/r:3===a?c=i.width/r:s=i.height*r;var d={aspectRatio:r,naturalWidth:o,naturalHeight:h,width:s,height:c};d.left=(i.width-s)/2,d.top=(i.height-c)/2,d.oldLeft=d.left,d.oldTop=d.top,this.canvas=d,this.limited=1===a||2===a,this.limitCanvas(!0,!0),this.initialImage=t.extend({},e),this.initialCanvas=t.extend({},d)},limitCanvas:function(t,i){var e=this.options,a=this.container,n=this.canvas,o=this.cropBox,h=e.viewMode,r=n.aspectRatio,s=this.cropped&&o;if(t){var c=Number(e.minCanvasWidth)||0,d=Number(e.minCanvasHeight)||0;h>0&&(h>1?(c=Math.max(c,a.width),d=Math.max(d,a.height),3===h&&(d*r>c?c=d*r:d=c/r)):c?c=Math.max(c,s?o.width:0):d?d=Math.max(d,s?o.height:0):s&&(c=o.width,(d=o.height)*r>c?c=d*r:d=c/r));var l=g({aspectRatio:r,width:c,height:d});c=l.width,d=l.height,n.minWidth=c,n.minHeight=d,n.maxWidth=1/0,n.maxHeight=1/0}if(i)if(h>0){var p=a.width-n.width,m=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,m),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,m),s&&this.limited&&(n.minLeft=Math.min(o.left,o.left+o.width-n.width),n.minTop=Math.min(o.top,o.top+o.height-n.height),n.maxLeft=o.left,n.maxTop=o.top,2===h&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,m),n.maxTop=Math.max(0,m))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,i){var e=this.canvas,a=this.image;if(i){var n=u({width:a.naturalWidth*Math.abs(a.scaleX),height:a.naturalHeight*Math.abs(a.scaleY),degree:a.rotate}),o=n.width,h=n.height,r=e.width*(o/e.naturalWidth),s=e.height*(h/e.naturalHeight);e.left-=(r-e.width)/2,e.top-=(s-e.height)/2,e.width=r,e.height=s,e.aspectRatio=o/h,e.naturalWidth=o,e.naturalHeight=h,this.limitCanvas(!0,!1)}(e.width>e.maxWidth||e.widthe.maxHeight||e.heighte.width?o.height=o.width/a:o.width=o.height*a),this.cropBox=o,this.limitCropBox(!0,!0),o.width=Math.min(Math.max(o.width,o.minWidth),o.maxWidth),o.height=Math.min(Math.max(o.height,o.minHeight),o.maxHeight),o.width=Math.max(o.minWidth,o.width*n),o.height=Math.max(o.minHeight,o.height*n),o.left=e.left+(e.width-o.width)/2,o.top=e.top+(e.height-o.height)/2,o.oldLeft=o.left,o.oldTop=o.top,this.initialCropBox=t.extend({},o)},limitCropBox:function(t,i){var e=this.options,a=this.container,n=this.canvas,o=this.cropBox,h=this.limited,r=e.aspectRatio;if(t){var s=Number(e.minCropBoxWidth)||0,c=Number(e.minCropBoxHeight)||0,d=Math.min(a.width,h?n.width:a.width),l=Math.min(a.height,h?n.height:a.height);s=Math.min(s,a.width),c=Math.min(c,a.height),r&&(s&&c?c*r>s?c=s/r:s=c*r:s?c=s/r:c&&(s=c*r),l*r>d?l=d/r:d=l*r),o.minWidth=Math.min(s,d),o.minHeight=Math.min(c,l),o.maxWidth=d,o.maxHeight=l}i&&(h?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function(){var t=this.options,i=this.container,e=this.cropBox;(e.width>e.maxWidth||e.widthe.maxHeight||e.height=i.width&&e.height>=i.height?"move":"all"),this.$cropBox.css({width:e.width,height:e.height,transform:c({translateX:e.left,translateY:e.top})}),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),this.completed&&this.trigger("crop",this.getData())}},j={initPreview:function(){var i=this.crossOrigin,e=i?this.crossOriginUrl:this.url,a=document.createElement("img");i&&(a.crossOrigin=i),a.src=e;var n=t(a);this.$preview=t(this.options.preview),this.$clone2=n,this.$viewBox.html(n),this.$preview.each(function(a,n){var o=t(n),h=document.createElement("img");o.data("preview",{width:o.width(),height:o.height(),html:o.html()}),i&&(h.crossOrigin=i),h.src=e,h.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',o.html(h)})},resetPreview:function(){this.$preview.each(function(i,e){var a=t(e),n=a.data("preview");a.css({width:n.width,height:n.height}).html(n.html).removeData("preview")})},preview:function(){var i=this.image,e=this.canvas,a=this.cropBox,n=a.width,o=a.height,h=i.width,r=i.height,s=a.left-e.left-i.left,d=a.top-e.top-i.top;this.cropped&&!this.disabled&&(this.$clone2.css({width:h,height:r,transform:c(t.extend({translateX:-s,translateY:-d},i))}),this.$preview.each(function(e,a){var l=t(a),p=l.data("preview"),m=p.width,g=p.height,u=m,f=g,v=1;n&&(f=o*(v=m/n)),o&&f>g&&(u=n*(v=g/o),f=g),l.css({width:u,height:f}).find("img").css({width:h*v,height:r*v,transform:c(t.extend({translateX:-s*v,translateY:-d*v},i))})}))}},q={bind:function(){var i=this.$element,e=this.options,a=this.$cropper;t.isFunction(e.cropstart)&&i.on("cropstart",e.cropstart),t.isFunction(e.cropmove)&&i.on("cropmove",e.cropmove),t.isFunction(e.cropend)&&i.on("cropend",e.cropend),t.isFunction(e.crop)&&i.on("crop",e.crop),t.isFunction(e.zoom)&&i.on("zoom",e.zoom),a.on(k,o(this.cropStart,this)),e.zoomable&&e.zoomOnWheel&&a.on("wheel mousewheel DOMMouseScroll",o(this.wheel,this)),e.toggleDragModeOnDblclick&&a.on("dblclick",o(this.dblclick,this)),t(document).on(W,this.onCropMove=o(this.cropMove,this)).on(T,this.onCropEnd=o(this.cropEnd,this)),e.responsive&&t($).on("resize",this.onResize=o(this.resize,this))},unbind:function(){var i=this.$element,e=this.options,a=this.$cropper;t.isFunction(e.cropstart)&&i.off("cropstart",e.cropstart),t.isFunction(e.cropmove)&&i.off("cropmove",e.cropmove),t.isFunction(e.cropend)&&i.off("cropend",e.cropend),t.isFunction(e.crop)&&i.off("crop",e.crop),t.isFunction(e.zoom)&&i.off("zoom",e.zoom),a.off(k,this.cropStart),e.zoomable&&e.zoomOnWheel&&a.off("wheel mousewheel DOMMouseScroll",this.wheel),e.toggleDragModeOnDblclick&&a.off("dblclick",this.dblclick),t(document).off(W,this.onCropMove).off(T,this.onCropEnd),e.responsive&&t($).off("resize",this.onResize)}},Q={resize:function(){var i=this.options,e=this.$container,a=this.container,n=Number(i.minContainerWidth)||200,o=Number(i.minContainerHeight)||100;if(!(this.disabled||a.width<=n||a.height<=o)){var h=e.width()/a.width;if(1!==h||e.height()!==a.height){var r=void 0,s=void 0;i.restore&&(r=this.getCanvasData(),s=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(t.each(r,function(t,i){r[t]=i*h})),this.setCropBoxData(t.each(s,function(t,i){s[t]=i*h})))}}},dblclick:function(){this.disabled||"none"===this.options.dragMode||this.setDragMode(this.$dragBox.hasClass("cropper-crop")?"move":"crop")},wheel:function(t){var i=this,e=t.originalEvent||t,a=Number(this.options.wheelZoomRatio)||.1;if(!this.disabled&&(t.preventDefault(),!this.wheeling)){this.wheeling=!0,setTimeout(function(){i.wheeling=!1},50);var n=1;e.deltaY?n=e.deltaY>0?1:-1:e.wheelDelta?n=-e.wheelDelta/120:e.detail&&(n=e.detail>0?1:-1),this.zoom(-n*a,t)}},cropStart:function(i){if(!this.disabled){var e=this.options,a=this.pointers,n=i.originalEvent,o=void 0;n&&n.changedTouches?t.each(n.changedTouches,function(t,i){a[i.identifier]=p(i)}):a[n&&n.pointerId||0]=p(n||i),o=E(a).length>1&&e.zoomable&&e.zoomOnTouch?"zoom":t(i.target).data("action"),D.test(o)&&(this.trigger("cropstart",{originalEvent:n,action:o}).isDefaultPrevented()||(i.preventDefault(),this.action=o,this.cropping=!1,"crop"===o&&(this.cropping=!0,this.$dragBox.addClass("cropper-modal"))))}},cropMove:function(i){var e=this.action;if(!this.disabled&&e){var a=this.pointers,n=i.originalEvent;i.preventDefault(),this.trigger("cropmove",{originalEvent:n,action:e}).isDefaultPrevented()||(n&&n.changedTouches?t.each(n.changedTouches,function(i,e){t.extend(a[e.identifier],p(e,!0))}):t.extend(a[n&&n.pointerId||0],p(n||i,!0)),this.change(i))}},cropEnd:function(i){if(!this.disabled){var e=this.action,a=this.pointers,n=i.originalEvent;n&&n.changedTouches?t.each(n.changedTouches,function(t,i){delete a[i.identifier]}):delete a[n&&n.pointerId||0],e&&(i.preventDefault(),E(a).length||(this.action=""),this.cropping&&(this.cropping=!1,this.$dragBox.toggleClass("cropper-modal",this.cropped&&this.options.modal)),this.trigger("cropend",{originalEvent:n,action:e}))}}},K={change:function(i){var e=this.options,a=this.pointers,n=this.container,o=this.canvas,h=this.cropBox,r=this.action,s=e.aspectRatio,c=h.left,d=h.top,p=h.width,m=h.height,g=c+p,u=d+m,f=0,v=0,w=n.width,x=n.height,b=!0,y=void 0;!s&&i.shiftKey&&(s=p&&m?p/m:1),this.limited&&(f=h.minLeft,v=h.minTop,w=f+Math.min(n.width,o.width,o.left+o.width),x=v+Math.min(n.height,o.height,o.top+o.height));var C=a[E(a)[0]],M={x:C.endX-C.startX,y:C.endY-C.startY},$=function(t){switch(t){case"e":g+M.x>w&&(M.x=w-g);break;case"w":c+M.xx&&(M.y=x-u)}};switch(r){case"all":c+=M.x,d+=M.y;break;case"e":if(M.x>=0&&(g>=w||s&&(d<=v||u>=x))){b=!1;break}$("e"),p+=M.x,s&&(m=p/s,d-=M.x/s/2),p<0&&(r="w",p=0);break;case"n":if(M.y<=0&&(d<=v||s&&(c<=f||g>=w))){b=!1;break}$("n"),m-=M.y,d+=M.y,s&&(p=m*s,c+=M.y*s/2),m<0&&(r="s",m=0);break;case"w":if(M.x<=0&&(c<=f||s&&(d<=v||u>=x))){b=!1;break}$("w"),p-=M.x,c+=M.x,s&&(m=p/s,d+=M.x/s/2),p<0&&(r="e",p=0);break;case"s":if(M.y>=0&&(u>=x||s&&(c<=f||g>=w))){b=!1;break}$("s"),m+=M.y,s&&(p=m*s,c-=M.y*s/2),m<0&&(r="n",m=0);break;case"ne":if(s){if(M.y<=0&&(d<=v||g>=w)){b=!1;break}$("n"),m-=M.y,d+=M.y,p=m*s}else $("n"),$("e"),M.x>=0?gv&&(m-=M.y,d+=M.y):(m-=M.y,d+=M.y);p<0&&m<0?(r="sw",m=0,p=0):p<0?(r="nw",p=0):m<0&&(r="se",m=0);break;case"nw":if(s){if(M.y<=0&&(d<=v||c<=f)){b=!1;break}$("n"),m-=M.y,d+=M.y,p=m*s,c+=M.y*s}else $("n"),$("w"),M.x<=0?c>f?(p-=M.x,c+=M.x):M.y<=0&&d<=v&&(b=!1):(p-=M.x,c+=M.x),M.y<=0?d>v&&(m-=M.y,d+=M.y):(m-=M.y,d+=M.y);p<0&&m<0?(r="se",m=0,p=0):p<0?(r="ne",p=0):m<0&&(r="sw",m=0);break;case"sw":if(s){if(M.x<=0&&(c<=f||u>=x)){b=!1;break}$("w"),p-=M.x,c+=M.x,m=p/s}else $("s"),$("w"),M.x<=0?c>f?(p-=M.x,c+=M.x):M.y>=0&&u>=x&&(b=!1):(p-=M.x,c+=M.x),M.y>=0?u=0&&(g>=w||u>=x)){b=!1;break}$("e"),m=(p+=M.x)/s}else $("s"),$("e"),M.x>=0?g=0&&u>=x&&(b=!1):p+=M.x,M.y>=0?u0?r=M.y>0?"se":"ne":M.x<0&&(c-=p,r=M.y>0?"sw":"nw"),M.y<0&&(d-=m),this.cropped||(this.$cropBox.removeClass(B),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}b&&(h.width=p,h.height=m,h.left=c,h.top=d,this.action=r,this.renderCropBox()),t.each(a,function(t,i){i.startX=i.endX,i.startY=i.endY})}},Z={crop:function(){this.ready&&!this.disabled&&(this.cropped||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&this.$dragBox.addClass("cropper-modal"),this.$cropBox.removeClass(B)),this.setCropBoxData(this.initialCropBox))},reset:function(){this.ready&&!this.disabled&&(this.image=t.extend({},this.initialImage),this.canvas=t.extend({},this.initialCanvas),this.cropBox=t.extend({},this.initialCropBox),this.renderCanvas(),this.cropped&&this.renderCropBox())},clear:function(){this.cropped&&!this.disabled&&(t.extend(this.cropBox,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),this.$dragBox.removeClass("cropper-modal"),this.$cropBox.addClass(B))},replace:function(t,i){!this.disabled&&t&&(this.isImg&&this.$element.attr("src",t),i?(this.url=t,this.$clone.attr("src",t),this.ready&&this.$preview.find("img").add(this.$clone2).attr("src",t)):(this.isImg&&(this.replaced=!0),this.options.data=null,this.load(t)))},enable:function(){this.ready&&(this.disabled=!1,this.$cropper.removeClass("cropper-disabled"))},disable:function(){this.ready&&(this.disabled=!0,this.$cropper.addClass("cropper-disabled"))},destroy:function(){var t=this.$element;this.loaded?(this.isImg&&this.replaced&&t.attr("src",this.originalUrl),this.unbuild(),t.removeClass(B)):this.isImg?t.off("load",this.start):this.$clone&&this.$clone.remove(),t.removeData("cropper")},move:function(t,i){var e=this.canvas,a=e.left,o=e.top;this.moveTo(n(t)?t:a+Number(t),n(i)?i:o+Number(i))},moveTo:function(t,i){var e=this.canvas,o=!1;n(i)&&(i=t),t=Number(t),i=Number(i),this.ready&&!this.disabled&&this.options.movable&&(a(t)&&(e.left=t,o=!0),a(i)&&(e.top=i,o=!0),o&&this.renderCanvas(!0))},zoom:function(t,i){var e=this.canvas;t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(e.width*t/e.naturalWidth,i)},zoomTo:function(t,i){var e=this.options,a=this.pointers,n=this.canvas,o=n.width,h=n.height,r=n.naturalWidth,s=n.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&e.zoomable){var c=r*t,d=s*t,l=void 0;if(i&&(l=i.originalEvent),this.trigger("zoom",{originalEvent:l,oldRatio:o/r,ratio:c/r}).isDefaultPrevented())return;if(l){var p=this.$cropper.offset(),g=a&&E(a).length?m(a):{pageX:i.pageX||l.pageX||0,pageY:i.pageY||l.pageY||0};n.left-=(c-o)*((g.pageX-p.left-n.left)/o),n.top-=(d-h)*((g.pageY-p.top-n.top)/h)}else n.left-=(c-o)/2,n.top-=(d-h)/2;n.width=c,n.height=d,this.renderCanvas(!0)}},rotate:function(t){this.rotateTo((this.image.rotate||0)+Number(t))},rotateTo:function(t){a(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.image.rotate=t%360,this.renderCanvas(!0,!0))},scaleX:function(t){var i=this.image.scaleY;this.scale(t,a(i)?i:1)},scaleY:function(t){var i=this.image.scaleX;this.scale(a(i)?i:1,t)},scale:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,e=this.image,n=!1;t=Number(t),i=Number(i),this.ready&&!this.disabled&&this.options.scalable&&(a(t)&&(e.scaleX=t,n=!0),a(i)&&(e.scaleY=i,n=!0),n&&this.renderCanvas(!0,!0))},getData:function(){var i=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.options,a=this.image,n=this.canvas,o=this.cropBox,h=void 0;if(this.ready&&this.cropped){h={x:o.left-n.left,y:o.top-n.top,width:o.width,height:o.height};var r=a.width/a.naturalWidth;t.each(h,function(t,e){e/=r,h[t]=i?Math.round(e):e})}else h={x:0,y:0,width:0,height:0};return e.rotatable&&(h.rotate=a.rotate||0),e.scalable&&(h.scaleX=a.scaleX||1,h.scaleY=a.scaleY||1),h},setData:function(i){var e=this.options,n=this.image,o=this.canvas,h={};if(t.isFunction(i)&&(i=i.call(this.element)),this.ready&&!this.disabled&&t.isPlainObject(i)){var r=!1;e.rotatable&&a(i.rotate)&&i.rotate!==n.rotate&&(n.rotate=i.rotate,r=!0),e.scalable&&(a(i.scaleX)&&i.scaleX!==n.scaleX&&(n.scaleX=i.scaleX,r=!0),a(i.scaleY)&&i.scaleY!==n.scaleY&&(n.scaleY=i.scaleY,r=!0)),r&&this.renderCanvas(!0,!0);var s=n.width/n.naturalWidth;a(i.x)&&(h.left=i.x*s+o.left),a(i.y)&&(h.top=i.y*s+o.top),a(i.width)&&(h.width=i.width*s),a(i.height)&&(h.height=i.height*s),this.setCropBoxData(h)}},getContainerData:function(){return this.ready?t.extend({},this.container):{}},getImageData:function(){return this.loaded?t.extend({},this.image):{}},getCanvasData:function(){var i=this.canvas,e={};return this.ready&&t.each(["left","top","width","height","naturalWidth","naturalHeight"],function(t,a){e[a]=i[a]}),e},setCanvasData:function(i){var e=this.canvas,n=e.aspectRatio;t.isFunction(i)&&(i=i.call(this.$element)),this.ready&&!this.disabled&&t.isPlainObject(i)&&(a(i.left)&&(e.left=i.left),a(i.top)&&(e.top=i.top),a(i.width)?(e.width=i.width,e.height=i.width/n):a(i.height)&&(e.height=i.height,e.width=i.height*n),this.renderCanvas(!0))},getCropBoxData:function(){var t=this.cropBox;return this.ready&&this.cropped?{left:t.left,top:t.top,width:t.width,height:t.height}:{}},setCropBoxData:function(i){var e=this.cropBox,n=this.options.aspectRatio,o=void 0,h=void 0;t.isFunction(i)&&(i=i.call(this.$element)),this.ready&&this.cropped&&!this.disabled&&t.isPlainObject(i)&&(a(i.left)&&(e.left=i.left),a(i.top)&&(e.top=i.top),a(i.width)&&i.width!==e.width&&(o=!0,e.width=i.width),a(i.height)&&i.height!==e.height&&(h=!0,e.height=i.height),n&&(o?e.height=e.width/n:h&&(e.width=e.height*n)),this.renderCropBox())},getCroppedCanvas:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!$.HTMLCanvasElement)return null;var e=this.canvas,a=f(this.$clone[0],this.image,e,i);if(!this.cropped)return a;var n=this.getData(),o=n.x,r=n.y,s=n.width,c=n.height,d=s/c,l=g({aspectRatio:d,width:i.maxWidth||1/0,height:i.maxHeight||1/0}),p=g({aspectRatio:d,width:i.minWidth||0,height:i.minHeight||0}),m=g({aspectRatio:d,width:i.width||s,height:i.height||c}),u=m.width,v=m.height;u=Math.min(l.width,Math.max(p.width,u)),v=Math.min(l.height,Math.max(p.height,v));var w=document.createElement("canvas"),x=w.getContext("2d");w.width=h(u),w.height=h(v),x.fillStyle=i.fillColor||"transparent",x.fillRect(0,0,u,v);var b=i.imageSmoothingEnabled,y=void 0===b||b,M=i.imageSmoothingQuality;x.imageSmoothingEnabled=y,M&&(x.imageSmoothingQuality=M);var B=a.width,k=a.height,W=o,T=r,D=void 0,H=void 0,Y=void 0,X=void 0,O=void 0,z=void 0;W<=-s||W>B?(W=0,D=0,Y=0,O=0):W<=0?(Y=-W,W=0,O=D=Math.min(B,s+W)):W<=B&&(Y=0,O=D=Math.min(s,B-W)),D<=0||T<=-c||T>k?(T=0,H=0,X=0,z=0):T<=0?(X=-T,T=0,z=H=Math.min(k,c+T)):T<=k&&(X=0,z=H=Math.min(c,k-T));var E=[W,T,D,H];if(O>0&&z>0){var N=u/s;E.push(Y*N,X*N,O*N,z*N)}return x.drawImage.apply(x,[a].concat(C(t.map(E,function(t){return Math.floor(h(t))})))),w},setAspectRatio:function(t){var i=this.options;this.disabled||n(t)||(i.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox()))},setDragMode:function(t){var i=this.options,e=void 0,a=void 0;this.loaded&&!this.disabled&&(e="crop"===t,a=i.movable&&"move"===t,t=e||a?t:"none",this.$dragBox.data("action",t).toggleClass("cropper-crop",e).toggleClass("cropper-move",a),i.cropBoxMovable||this.$face.data("action",t).toggleClass("cropper-crop",e).toggleClass("cropper-move",a))}},V=function(){function t(t,i){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:{};if(M(this,i),!e||!X.test(e.tagName))throw new Error("The first argument is required and must be an or element.");this.element=e,this.$element=t(e),this.options=t.extend({},O,t.isPlainObject(a)&&a),this.completed=!1,this.cropped=!1,this.disabled=!1,this.isImg=!1,this.limited=!1,this.loaded=!1,this.ready=!1,this.replaced=!1,this.wheeling=!1,this.originalUrl="",this.canvas=null,this.cropBox=null,this.pointers={},this.init()}return V(i,[{key:"init",value:function(){var t=this.$element,i=void 0;if(t.is("img")){if(this.isImg=!0,i=t.attr("src")||"",this.originalUrl=i,!i)return;i=t.prop("src")}else t.is("canvas")&&$.HTMLCanvasElement&&(i=t[0].toDataURL());this.load(i)}},{key:"trigger",value:function(i,e){var a=t.Event(i,e);return this.$element.trigger(a),a}},{key:"load",value:function(t){var i=this;if(t){this.url=t,this.image={};var e=this.$element,a=this.options;if(a.checkOrientation&&$.ArrayBuffer)if(H.test(t))Y.test(t)?this.read(w(t)):this.clone();else{var n=new XMLHttpRequest;n.onerror=function(){i.clone()},n.onload=function(){i.read(n.response)},a.checkCrossOrigin&&r(t)&&e.prop("crossOrigin")&&(t=s(t)),n.open("get",t),n.responseType="arraybuffer",n.withCredentials="use-credentials"===e.prop("crossOrigin"),n.send()}else this.clone()}}},{key:"read",value:function(t){var i=this.options,e=this.image,a=b(t),n=0,o=1,h=1;if(a>1){this.url=x(t,"image/jpeg");var r=y(a);n=r.rotate,o=r.scaleX,h=r.scaleY}i.rotatable&&(e.rotate=n),i.scalable&&(e.scaleX=o,e.scaleY=h),this.clone()}},{key:"clone",value:function(){var i=this.$element,e=this.options,a=this.url,n="",o=void 0;e.checkCrossOrigin&&r(a)&&((n=i.prop("crossOrigin"))?o=a:(n="anonymous",o=s(a))),this.crossOrigin=n,this.crossOriginUrl=o;var h=document.createElement("img");n&&(h.crossOrigin=n),h.src=o||a;var c=t(h);this.$clone=c,this.isImg?this.element.complete?this.start():i.one("load",t.proxy(this.start,this)):c.one("load",t.proxy(this.start,this)).one("error",t.proxy(this.stop,this)).addClass("cropper-hide").insertAfter(i)}},{key:"start",value:function(){var i=this,e=this.$clone,a=this.$element;this.isImg||(e.off("error",this.stop),a=e),d(a[0],function(e,a){t.extend(i.image,{naturalWidth:e,naturalHeight:a,aspectRatio:e/a}),i.loaded=!0,i.build()})}},{key:"stop",value:function(){this.$clone.remove(),this.$clone=null}},{key:"build",value:function(){var i=this;if(this.loaded){this.ready&&this.unbuild();var e=this.$element,a=this.options,n=this.$clone,o=t('
'),h=o.find(".cropper-crop-box"),r=h.find(".cropper-face");this.$container=e.parent(),this.$cropper=o,this.$canvas=o.find(".cropper-canvas").append(n),this.$dragBox=o.find(".cropper-drag-box"),this.$cropBox=h,this.$viewBox=o.find(".cropper-view-box"),this.$face=r,e.addClass(B).after(o),this.isImg||n.removeClass("cropper-hide"),this.initPreview(),this.bind(),a.aspectRatio=Math.max(0,a.aspectRatio)||NaN,a.viewMode=Math.max(0,Math.min(3,Math.round(a.viewMode)))||0,this.cropped=a.autoCrop,a.autoCrop?a.modal&&this.$dragBox.addClass("cropper-modal"):h.addClass(B),a.guides||h.find(".cropper-dashed").addClass(B),a.center||h.find(".cropper-center").addClass(B),a.cropBoxMovable&&r.addClass("cropper-move").data("action","all"),a.highlight||r.addClass("cropper-invisible"),a.background&&o.addClass("cropper-bg"),a.cropBoxResizable||h.find(".cropper-line,.cropper-point").addClass(B),this.setDragMode(a.dragMode),this.render(),this.ready=!0,this.setData(a.data),this.completing=setTimeout(function(){t.isFunction(a.ready)&&e.one("ready",a.ready),i.trigger("ready"),i.trigger("crop",i.getData()),i.completed=!0},0)}}},{key:"unbuild",value:function(){this.ready&&(this.completed||clearTimeout(this.completing),this.ready=!1,this.completed=!1,this.initialImage=null,this.initialCanvas=null,this.initialCropBox=null,this.container=null,this.canvas=null,this.cropBox=null,this.unbind(),this.resetPreview(),this.$preview=null,this.$viewBox=null,this.$cropBox=null,this.$dragBox=null,this.$canvas=null,this.$container=null,this.$cropper.remove(),this.$cropper=null)}}],[{key:"setDefaults",value:function(i){t.extend(O,t.isPlainObject(i)&&i)}}]),i}();if(t.extend&&t.extend(G.prototype,S,j,q,Q,K,Z),t.fn){var J=t.fn.cropper;t.fn.cropper=function(i){for(var a=arguments.length,o=Array(a>1?a-1:0),h=1;h
-

Cropper v3.1.1

+

Cropper v3.1.2

A simple jQuery image cropping plugin.

diff --git a/docs/js/cropper.js b/docs/js/cropper.js index 86e7c826..0669958b 100644 --- a/docs/js/cropper.js +++ b/docs/js/cropper.js @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.1 + * Cropper v3.1.2 * https://github.com/fengyuanchen/cropper * * Copyright (c) 2014-2017 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-11T13:34:24.201Z + * Date: 2017-10-18T13:23:24.651Z */ (function (global, factory) { @@ -172,6 +172,8 @@ var DEFAULTS = { var TEMPLATE = '
' + '
' + '
' + '
' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + '
'; +function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + /** * Check if the given value is a string. * @param {*} value - The value to check. @@ -240,6 +242,21 @@ var objectKeys = Object.keys || function objectKeys(obj) { return keys; }; +var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/i; + +/** + * Normalize decimal number. + * Check out {@link http://0.30000000000000004.com/ } + * @param {number} value - The value to normalize. + * @param {number} [times=100000000000] - The times for normalizing. + * @returns {number} Returns the normalized number. + */ +function normalizeDecimalNumber(value) { + var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100000000000; + + return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value; +} + var location = global.location; var REGEXP_ORIGINS = /^(https?:)\/\/([^:/?#]+):?(\d*)/i; @@ -526,9 +543,10 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight)); var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); + var params = [-imageNaturalWidth / 2, -imageNaturalHeight / 2, imageNaturalWidth, imageNaturalHeight]; - canvas.width = width; - canvas.height = height; + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = fillColor; context.fillRect(0, 0, width, height); context.save(); @@ -537,7 +555,9 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage(image, Math.floor(-imageNaturalWidth / 2), Math.floor(-imageNaturalHeight / 2), Math.floor(imageNaturalWidth), Math.floor(imageNaturalHeight)); + context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); context.restore(); return canvas; } @@ -1980,6 +2000,8 @@ var change = { } }; +function _toConsumableArray$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } + var methods = { // Show the crop box manually crop: function crop() { @@ -2625,9 +2647,8 @@ var methods = { var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); - canvas.width = width; - canvas.height = height; - + canvas.width = normalizeDecimalNumber(width); + canvas.height = normalizeDecimalNumber(height); context.fillStyle = options.fillColor || 'transparent'; context.fillRect(0, 0, width, height); @@ -2692,17 +2713,18 @@ var methods = { // All the numerical parameters should be integer for `drawImage` // https://github.com/fengyuanchen/cropper/issues/476 - var params = [Math.floor(srcX), Math.floor(srcY), Math.floor(srcWidth), Math.floor(srcHeight)]; + var params = [srcX, srcY, srcWidth, srcHeight]; // Avoid "IndexSizeError" if (dstWidth > 0 && dstHeight > 0) { var scale = width / initialWidth; - params.push(Math.floor(dstX * scale), Math.floor(dstY * scale), Math.floor(dstWidth * scale), Math.floor(dstHeight * scale)); + params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(params)); - + context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + return Math.floor(normalizeDecimalNumber(param)); + })))); return canvas; }, diff --git a/package-lock.json b/package-lock.json index 933e8aeb..674c9642 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cropper", - "version": "3.1.1", + "version": "3.1.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -731,9 +731,9 @@ } }, "babel-preset-env": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.0.tgz", - "integrity": "sha512-OVgtQRuOZKckrILgMA5rvctvFZPv72Gua9Rt006AiPoB0DJKGN07UmaQA+qRrYgK71MVct8fFhT0EyNWYorVew==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.6.1.tgz", + "integrity": "sha512-W6VIyA6Ch9ePMI7VptNn2wBM6dbG0eSz25HEiL40nQXCsXGTGZSTZu1Iap+cj3Q0S5a7T9+529l/5Bkvd+afNA==", "dev": true, "requires": { "babel-plugin-check-es2015-constants": "6.22.0", @@ -1893,14 +1893,14 @@ "dev": true }, "eslint": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.8.0.tgz", - "integrity": "sha1-Ip7w41Tg5h2DfHqA/fuoJeGZgV4=", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.9.0.tgz", + "integrity": "sha1-doedJ0BoJhsZH+Dy9Wx0wvQgjos=", "dev": true, "requires": { "ajv": "5.2.3", "babel-code-frame": "6.26.0", - "chalk": "2.1.0", + "chalk": "2.2.0", "concat-stream": "1.6.0", "cross-spawn": "5.1.0", "debug": "3.1.0", @@ -1953,14 +1953,14 @@ } }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.2.0.tgz", + "integrity": "sha512-0BMM/2hG3ZaoPfR6F+h/oWpZtsh3b/s62TjSM6MGCJWEbJDN1acqCXvyhhZsDSVFklpebUoQ5O1kKC7lOzrn9g==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" + "supports-color": "4.5.0" } }, "debug": { @@ -2018,9 +2018,9 @@ } }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { "has-flag": "2.0.0" @@ -2029,9 +2029,9 @@ } }, "eslint-config-airbnb-base": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.0.2.tgz", - "integrity": "sha512-rQqOvAzrMC3BBCH6Dd/1RenDi+RW4vdgnh8xcPf6sgd324ad6aX7hSZ52L1SfDGe2VsZR2yB5uPvDfXYvxHZmA==", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.1.0.tgz", + "integrity": "sha512-/vjm0Px5ZCpmJqnjIzcFb9TKZrKWz0gnuG/7Gfkt0Db1ELJR51xkZth+t14rYdqWgX836XbuxtArbIHlVhbLBA==", "dev": true, "requires": { "eslint-restricted-globals": "0.1.1" @@ -2780,7 +2780,7 @@ "dev": true, "requires": { "ansi-escapes": "3.0.0", - "chalk": "2.1.0", + "chalk": "2.2.0", "cli-cursor": "2.1.0", "cli-width": "2.2.0", "external-editor": "2.0.5", @@ -2811,14 +2811,14 @@ } }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.2.0.tgz", + "integrity": "sha512-0BMM/2hG3ZaoPfR6F+h/oWpZtsh3b/s62TjSM6MGCJWEbJDN1acqCXvyhhZsDSVFklpebUoQ5O1kKC7lOzrn9g==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" + "supports-color": "4.5.0" } }, "has-flag": { @@ -2837,9 +2837,9 @@ } }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { "has-flag": "2.0.0" @@ -7330,9 +7330,9 @@ } }, "rollup-plugin-commonjs": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.1.tgz", - "integrity": "sha512-ZTwAetmKimCsuWost/+n4FaOpMoczBRTx+kuQaZCIKXTx/R1wNBezuX5NS0vnPKM3hBoErdpAqmNyVSCi5XKbg==", + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-8.2.3.tgz", + "integrity": "sha512-WFkITnsa3sNsWtBfBMnjXVUN/6tWKVOUTq/2VhQhDjytPhpZ/y+oTa2tyBdu9caC9Rp29ZtnH+qo4zYO7n8/Ww==", "dev": true, "requires": { "acorn": "5.1.2", @@ -8350,13 +8350,21 @@ "dev": true }, "uglify-js": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.3.tgz", - "integrity": "sha512-5ZUOgufCHjN2mBBLfz63UtWTP6va2sSzBpNCM+/iqI6RnPzEhANmB0EKiKBYdQbc3v7KeomXJ2DJx0Xq9gvUvA==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.4.tgz", + "integrity": "sha512-DcbkPg11Lw2lAWpwCmQDX+qoR4JiII6ypsQmF6tscZtlxGPFAmSRUGuMoVT3/0EHqypVik/TpkH4ITiMJeQqQA==", "dev": true, "requires": { "commander": "2.11.0", - "source-map": "0.5.7" + "source-map": "0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "uniq": { diff --git a/package.json b/package.json index f9cc5f55..a503cedc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cropper", "description": "A simple jQuery image cropping plugin.", - "version": "3.1.1", + "version": "3.1.2", "main": "dist/cropper.common.js", "module": "dist/cropper.esm.js", "browser": "dist/cropper.js", @@ -52,11 +52,11 @@ }, "devDependencies": { "babel-core": "^6.26.0", - "babel-preset-env": "^1.6.0", + "babel-preset-env": "^1.6.1", "cpy-cli": "^1.0.1", "cssnano": "^3.10.0", - "eslint": "^4.8.0", - "eslint-config-airbnb-base": "^12.0.2", + "eslint": "^4.9.0", + "eslint-config-airbnb-base": "^12.1.0", "eslint-plugin-import": "^2.7.0", "jquery": "^3.2.1", "node-qunit-phantomjs": "^1.5.0", @@ -67,11 +67,11 @@ "postcss-url": "^7.1.2", "rollup": "^0.50.0", "rollup-plugin-babel": "^3.0.2", - "rollup-plugin-commonjs": "^8.2.1", + "rollup-plugin-commonjs": "^8.2.3", "rollup-plugin-node-resolve": "^3.0.0", "rollup-watch": "^4.3.1", "stylefmt": "^6.0.0", - "uglify-js": "^3.1.3" + "uglify-js": "^3.1.4" }, "peerDependencies": { "jquery": ">= 1.9.1"