diff --git a/CHANGELOG.md b/CHANGELOG.md index 37517f9d..e3ca7663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.1.4 (Jan 13, 2018) + +- Fixed a bug of rotation (#938). + ## 3.1.3 (Oct 21, 2017) - Fixed a bug of render when disable one of `rotatable` and `scalable` options. diff --git a/dist/cropper.common.js b/dist/cropper.common.js index 85d17dd7..ed15d61a 100644 --- a/dist/cropper.common.js +++ b/dist/cropper.common.js @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.3 + * Cropper v3.1.4 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2017 Chen Fengyuan + * Copyright (c) 2014-2018 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-21T10:04:29.734Z + * Date: 2018-01-13T09:37:52.890Z */ 'use strict'; @@ -59,7 +59,7 @@ var EVENT_ERROR = 'error'; var EVENT_LOAD = 'load'; var EVENT_POINTER_DOWN = WINDOW.PointerEvent ? 'pointerdown' : 'touchstart mousedown'; var EVENT_POINTER_MOVE = WINDOW.PointerEvent ? 'pointermove' : 'touchmove mousemove'; -var EVENT_POINTER_UP = WINDOW.PointerEvent ? ' pointerup pointercancel' : 'touchend touchcancel mouseup'; +var EVENT_POINTER_UP = WINDOW.PointerEvent ? 'pointerup pointercancel' : 'touchend touchcancel mouseup'; var EVENT_READY = 'ready'; var EVENT_RESIZE = 'resize'; var EVENT_WHEEL = 'wheel mousewheel DOMMouseScroll'; @@ -169,7 +169,79 @@ 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); } } +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +var toConsumableArray = function (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. @@ -475,9 +547,9 @@ function getRotatedSizes(_ref5) { height = _ref5.height, degree = _ref5.degree; - degree = Math.abs(degree); + degree = Math.abs(degree) % 180; - if (degree % 180 === 90) { + if (degree === 90) { return { width: height, height: width @@ -487,10 +559,15 @@ function getRotatedSizes(_ref5) { var arc = degree % 90 * Math.PI / 180; var sinArc = Math.sin(arc); var cosArc = Math.cos(arc); - - return { - width: width * cosArc + height * sinArc, - height: width * sinArc + height * cosArc + var newWidth = width * cosArc + height * sinArc; + var newHeight = width * sinArc + height * cosArc; + + return degree > 90 ? { + width: newHeight, + height: newWidth + } : { + width: newWidth, + height: newHeight }; } @@ -555,7 +632,7 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + context.drawImage.apply(context, [image].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); context.restore(); @@ -1315,7 +1392,7 @@ var events = { $cropper.on(EVENT_DBLCLICK, proxy(this.dblclick, this)); } - $(document).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); + $(this.element.ownerDocument).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); if (options.responsive) { $(window).on(EVENT_RESIZE, this.onResize = proxy(this.resize, this)); @@ -1357,7 +1434,7 @@ var events = { $cropper.off(EVENT_DBLCLICK, this.dblclick); } - $(document).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); + $(this.element.ownerDocument).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); if (options.responsive) { $(window).off(EVENT_RESIZE, this.onResize); @@ -2000,8 +2077,6 @@ 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() { @@ -2722,7 +2797,7 @@ var methods = { params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + context.drawImage.apply(context, [source].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); return canvas; @@ -2777,10 +2852,6 @@ var methods = { } }; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var Cropper = function () { /** * Create a new Cropper. @@ -2789,8 +2860,7 @@ var Cropper = function () { */ function Cropper(element) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Cropper); + classCallCheck(this, Cropper); if (!element || !REGEXP_TAG_NAME.test(element.tagName)) { throw new Error('The first argument is required and must be an or element.'); @@ -2815,7 +2885,7 @@ var Cropper = function () { this.init(); } - _createClass(Cropper, [{ + createClass(Cropper, [{ key: 'init', value: function init() { var $element = this.$element; @@ -2896,7 +2966,8 @@ var Cropper = function () { _this.read(xhr.response); }; - if (options.checkCrossOrigin && isCrossOriginURL(url) && $element.prop('crossOrigin')) { + // Bust cache when there is a "crossOrigin" property + if (options.checkCrossOrigin && isCrossOriginURL(url) && !$element.prop('crossOrigin')) { url = addTimestamp(url); } @@ -3160,7 +3231,6 @@ var Cropper = function () { $.extend(DEFAULTS, $.isPlainObject(options) && options); } }]); - return Cropper; }(); diff --git a/dist/cropper.css b/dist/cropper.css index 1bc28298..f97ab37e 100644 --- a/dist/cropper.css +++ b/dist/cropper.css @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.3 + * Cropper v3.1.4 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2017 Chen Fengyuan + * Copyright (c) 2014-2018 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-21T10:03:37.133Z + * Date: 2018-01-13T09:37:21.486Z */ .cropper-container { @@ -147,21 +147,21 @@ } .cropper-line.line-e { - cursor: e-resize; + cursor: ew-resize; right: -3px; top: 0; width: 5px; } .cropper-line.line-n { - cursor: n-resize; + cursor: ns-resize; height: 5px; left: 0; top: -3px; } .cropper-line.line-w { - cursor: w-resize; + cursor: ew-resize; left: -3px; top: 0; width: 5px; @@ -169,7 +169,7 @@ .cropper-line.line-s { bottom: -3px; - cursor: s-resize; + cursor: ns-resize; height: 5px; left: 0; } @@ -182,21 +182,21 @@ } .cropper-point.point-e { - cursor: e-resize; + cursor: ew-resize; margin-top: -3px; right: -3px; top: 50%; } .cropper-point.point-n { - cursor: n-resize; + cursor: ns-resize; left: 50%; margin-left: -3px; top: -3px; } .cropper-point.point-w { - cursor: w-resize; + cursor: ew-resize; left: -3px; margin-top: -3px; top: 50%; @@ -210,26 +210,26 @@ } .cropper-point.point-ne { - cursor: ne-resize; + cursor: nesw-resize; right: -3px; top: -3px; } .cropper-point.point-nw { - cursor: nw-resize; + cursor: nwse-resize; left: -3px; top: -3px; } .cropper-point.point-sw { bottom: -3px; - cursor: sw-resize; + cursor: nesw-resize; left: -3px; } .cropper-point.point-se { bottom: -3px; - cursor: se-resize; + cursor: nwse-resize; height: 20px; opacity: 1; right: -3px; diff --git a/dist/cropper.esm.js b/dist/cropper.esm.js index 281433c0..ed0e7104 100644 --- a/dist/cropper.esm.js +++ b/dist/cropper.esm.js @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.3 + * Cropper v3.1.4 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2017 Chen Fengyuan + * Copyright (c) 2014-2018 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-21T10:04:29.734Z + * Date: 2018-01-13T09:37:52.890Z */ import $ from 'jquery'; @@ -55,7 +55,7 @@ var EVENT_ERROR = 'error'; var EVENT_LOAD = 'load'; var EVENT_POINTER_DOWN = WINDOW.PointerEvent ? 'pointerdown' : 'touchstart mousedown'; var EVENT_POINTER_MOVE = WINDOW.PointerEvent ? 'pointermove' : 'touchmove mousemove'; -var EVENT_POINTER_UP = WINDOW.PointerEvent ? ' pointerup pointercancel' : 'touchend touchcancel mouseup'; +var EVENT_POINTER_UP = WINDOW.PointerEvent ? 'pointerup pointercancel' : 'touchend touchcancel mouseup'; var EVENT_READY = 'ready'; var EVENT_RESIZE = 'resize'; var EVENT_WHEEL = 'wheel mousewheel DOMMouseScroll'; @@ -165,7 +165,79 @@ 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); } } +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +var toConsumableArray = function (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. @@ -471,9 +543,9 @@ function getRotatedSizes(_ref5) { height = _ref5.height, degree = _ref5.degree; - degree = Math.abs(degree); + degree = Math.abs(degree) % 180; - if (degree % 180 === 90) { + if (degree === 90) { return { width: height, height: width @@ -483,10 +555,15 @@ function getRotatedSizes(_ref5) { var arc = degree % 90 * Math.PI / 180; var sinArc = Math.sin(arc); var cosArc = Math.cos(arc); - - return { - width: width * cosArc + height * sinArc, - height: width * sinArc + height * cosArc + var newWidth = width * cosArc + height * sinArc; + var newHeight = width * sinArc + height * cosArc; + + return degree > 90 ? { + width: newHeight, + height: newWidth + } : { + width: newWidth, + height: newHeight }; } @@ -551,7 +628,7 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + context.drawImage.apply(context, [image].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); context.restore(); @@ -1311,7 +1388,7 @@ var events = { $cropper.on(EVENT_DBLCLICK, proxy(this.dblclick, this)); } - $(document).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); + $(this.element.ownerDocument).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); if (options.responsive) { $(window).on(EVENT_RESIZE, this.onResize = proxy(this.resize, this)); @@ -1353,7 +1430,7 @@ var events = { $cropper.off(EVENT_DBLCLICK, this.dblclick); } - $(document).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); + $(this.element.ownerDocument).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); if (options.responsive) { $(window).off(EVENT_RESIZE, this.onResize); @@ -1996,8 +2073,6 @@ 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() { @@ -2718,7 +2793,7 @@ var methods = { params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + context.drawImage.apply(context, [source].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); return canvas; @@ -2773,10 +2848,6 @@ var methods = { } }; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var Cropper = function () { /** * Create a new Cropper. @@ -2785,8 +2856,7 @@ var Cropper = function () { */ function Cropper(element) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Cropper); + classCallCheck(this, Cropper); if (!element || !REGEXP_TAG_NAME.test(element.tagName)) { throw new Error('The first argument is required and must be an or element.'); @@ -2811,7 +2881,7 @@ var Cropper = function () { this.init(); } - _createClass(Cropper, [{ + createClass(Cropper, [{ key: 'init', value: function init() { var $element = this.$element; @@ -2892,7 +2962,8 @@ var Cropper = function () { _this.read(xhr.response); }; - if (options.checkCrossOrigin && isCrossOriginURL(url) && $element.prop('crossOrigin')) { + // Bust cache when there is a "crossOrigin" property + if (options.checkCrossOrigin && isCrossOriginURL(url) && !$element.prop('crossOrigin')) { url = addTimestamp(url); } @@ -3156,7 +3227,6 @@ var Cropper = function () { $.extend(DEFAULTS, $.isPlainObject(options) && options); } }]); - return Cropper; }(); diff --git a/dist/cropper.js b/dist/cropper.js index ea988649..2db396e2 100644 --- a/dist/cropper.js +++ b/dist/cropper.js @@ -1,11 +1,11 @@ /*! - * Cropper v3.1.3 + * Cropper v3.1.4 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2017 Chen Fengyuan + * Copyright (c) 2014-2018 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-21T10:04:29.734Z + * Date: 2018-01-13T09:37:52.890Z */ (function (global, factory) { @@ -61,7 +61,7 @@ var EVENT_ERROR = 'error'; var EVENT_LOAD = 'load'; var EVENT_POINTER_DOWN = WINDOW.PointerEvent ? 'pointerdown' : 'touchstart mousedown'; var EVENT_POINTER_MOVE = WINDOW.PointerEvent ? 'pointermove' : 'touchmove mousemove'; -var EVENT_POINTER_UP = WINDOW.PointerEvent ? ' pointerup pointercancel' : 'touchend touchcancel mouseup'; +var EVENT_POINTER_UP = WINDOW.PointerEvent ? 'pointerup pointercancel' : 'touchend touchcancel mouseup'; var EVENT_READY = 'ready'; var EVENT_RESIZE = 'resize'; var EVENT_WHEEL = 'wheel mousewheel DOMMouseScroll'; @@ -171,7 +171,79 @@ 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); } } +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +var toConsumableArray = function (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. @@ -477,9 +549,9 @@ function getRotatedSizes(_ref5) { height = _ref5.height, degree = _ref5.degree; - degree = Math.abs(degree); + degree = Math.abs(degree) % 180; - if (degree % 180 === 90) { + if (degree === 90) { return { width: height, height: width @@ -489,10 +561,15 @@ function getRotatedSizes(_ref5) { var arc = degree % 90 * Math.PI / 180; var sinArc = Math.sin(arc); var cosArc = Math.cos(arc); - - return { - width: width * cosArc + height * sinArc, - height: width * sinArc + height * cosArc + var newWidth = width * cosArc + height * sinArc; + var newHeight = width * sinArc + height * cosArc; + + return degree > 90 ? { + width: newHeight, + height: newWidth + } : { + width: newWidth, + height: newHeight }; } @@ -557,7 +634,7 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + context.drawImage.apply(context, [image].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); context.restore(); @@ -1317,7 +1394,7 @@ var events = { $cropper.on(EVENT_DBLCLICK, proxy(this.dblclick, this)); } - $(document).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); + $(this.element.ownerDocument).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); if (options.responsive) { $(window).on(EVENT_RESIZE, this.onResize = proxy(this.resize, this)); @@ -1359,7 +1436,7 @@ var events = { $cropper.off(EVENT_DBLCLICK, this.dblclick); } - $(document).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); + $(this.element.ownerDocument).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); if (options.responsive) { $(window).off(EVENT_RESIZE, this.onResize); @@ -2002,8 +2079,6 @@ 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() { @@ -2724,7 +2799,7 @@ var methods = { params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + context.drawImage.apply(context, [source].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); return canvas; @@ -2779,10 +2854,6 @@ var methods = { } }; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var Cropper = function () { /** * Create a new Cropper. @@ -2791,8 +2862,7 @@ var Cropper = function () { */ function Cropper(element) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Cropper); + classCallCheck(this, Cropper); if (!element || !REGEXP_TAG_NAME.test(element.tagName)) { throw new Error('The first argument is required and must be an or element.'); @@ -2817,7 +2887,7 @@ var Cropper = function () { this.init(); } - _createClass(Cropper, [{ + createClass(Cropper, [{ key: 'init', value: function init() { var $element = this.$element; @@ -2898,7 +2968,8 @@ var Cropper = function () { _this.read(xhr.response); }; - if (options.checkCrossOrigin && isCrossOriginURL(url) && $element.prop('crossOrigin')) { + // Bust cache when there is a "crossOrigin" property + if (options.checkCrossOrigin && isCrossOriginURL(url) && !$element.prop('crossOrigin')) { url = addTimestamp(url); } @@ -3162,7 +3233,6 @@ var Cropper = function () { $.extend(DEFAULTS, $.isPlainObject(options) && options); } }]); - return Cropper; }(); diff --git a/dist/cropper.min.css b/dist/cropper.min.css index 6f148971..e7735eee 100644 --- a/dist/cropper.min.css +++ b/dist/cropper.min.css @@ -1,10 +1,9 @@ /*! - * Cropper v3.1.3 + * Cropper v3.1.4 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2017 Chen Fengyuan + * Copyright (c) 2014-2018 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-21T10:03:37.133Z - */.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 + * Date: 2018-01-13T09:37:21.486Z + */.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:ew-resize;right:-3px;top:0;width:5px}.cropper-line.line-n{cursor:ns-resize;height:5px;left:0;top:-3px}.cropper-line.line-w{cursor:ew-resize;left:-3px;top:0;width:5px}.cropper-line.line-s{bottom:-3px;cursor:ns-resize;height:5px;left:0}.cropper-point{background-color:#39f;height:5px;opacity:.75;width:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;right:-3px;top:50%}.cropper-point.point-n{cursor:ns-resize;left:50%;margin-left:-3px;top:-3px}.cropper-point.point-w{cursor:ew-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:nesw-resize;right:-3px;top:-3px}.cropper-point.point-nw{cursor:nwse-resize;left:-3px;top:-3px}.cropper-point.point-sw{bottom:-3px;cursor:nesw-resize;left:-3px}.cropper-point.point-se{bottom:-3px;cursor:nwse-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} \ No newline at end of file diff --git a/dist/cropper.min.js b/dist/cropper.min.js index fa407a60..b4ed9908 100644 --- a/dist/cropper.min.js +++ b/dist/cropper.min.js @@ -1,10 +1,10 @@ /*! - * Cropper v3.1.3 + * Cropper v3.1.4 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2017 Chen Fengyuan + * Copyright (c) 2014-2018 Chen Fengyuan * Released under the MIT license * - * Date: 2017-10-21T10:04:29.734Z + * Date: 2018-01-13T09:37:52.890Z */ -!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){if(Array.isArray(t)){for(var i=0,e=Array(t.length);i2?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=void 0===c?0:c,l=a.scaleX,p=void 0===l?1:l,m=a.scaleY,u=void 0===m?1:m,f=n.aspectRatio,v=n.naturalWidth,w=n.naturalHeight,x=o.fillColor,b=void 0===x?"transparent":x,y=o.imageSmoothingEnabled,C=void 0===y||y,M=o.imageSmoothingQuality,$=void 0===M?"low":M,B=o.maxWidth,k=void 0===B?1/0:B,W=o.maxHeight,T=void 0===W?1/0:W,D=o.minWidth,H=void 0===D?0:D,Y=o.minHeight,X=void 0===Y?0:Y,O=g({aspectRatio:f,width:k,height:T}),z=g({aspectRatio:f,width:H,height:X}),E=Math.min(O.width,Math.max(z.width,v)),N=Math.min(O.height,Math.max(z.height,w)),R=document.createElement("canvas"),L=R.getContext("2d"),P=[-r/2,-s/2,r,s];return R.width=h(E),R.height=h(N),L.fillStyle=b,L.fillRect(0,0,E,N),L.save(),L.translate(E/2,N/2),L.rotate(d*Math.PI/180),L.scale(p,u),L.imageSmoothingEnabled=!!C,L.imageSmoothingQuality=$,L.drawImage.apply(L,[e].concat(i(t.map(P,function(t){return Math.floor(h(t))})))),L.restore(),R}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||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),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(window).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(window).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||!window.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 $=a.width,B=a.height,k=o,W=r,T=void 0,D=void 0,H=void 0,Y=void 0,X=void 0,O=void 0;k<=-s||k>$?(k=0,T=0,H=0,X=0):k<=0?(H=-k,k=0,X=T=Math.min($,s+k)):k<=$&&(H=0,X=T=Math.min(s,$-k)),T<=0||W<=-c||W>B?(W=0,D=0,Y=0,O=0):W<=0?(Y=-W,W=0,O=D=Math.min(B,c+W)):W<=B&&(Y=0,O=D=Math.min(c,B-W));var z=[k,W,T,D];if(X>0&&O>0){var E=u/s;z.push(H*E,Y*E,X*E,O*E)}return x.drawImage.apply(x,[a].concat(C(t.map(z,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")&&window.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&&window.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;h2?e-2:0),n=2;n1&&void 0!==arguments[1]?arguments[1]:1e11;return X.test(t)?Math.round(t*i)/i:t}var O=i.location,E=/^(https?:)\/\/([^:/?#]+):?(\d*)/i;function N(t){var i=t.match(E);return i&&(i[1]!==O.protocol||i[2]!==O.hostname||i[3]!==O.port)}function R(t){var i="timestamp="+(new Date).getTime();return t+(-1===t.indexOf("?")?"?":"&")+i}function L(t){var i=t.rotate,e=t.scaleX,a=t.scaleY,n=t.translateX,o=t.translateY,h=[];return D(n)&&0!==n&&h.push("translateX("+n+"px)"),D(o)&&0!==o&&h.push("translateY("+o+"px)"),D(i)&&0!==i&&h.push("rotate("+i+"deg)"),D(e)&&1!==e&&h.push("scaleX("+e+")"),D(a)&&1!==a&&h.push("scaleY("+a+")"),h.length?h.join(" "):"none"}var P=i.navigator,I=P&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(P.userAgent);function U(i,e){var a=i.pageX,n=i.pageY,o={endX:a,endY:n};return e?o:t.extend({startX:a,startY:n},o)}var A=Number.isFinite||i.isFinite;function F(t){var i=t.aspectRatio,e=t.height,a=t.width,n=function(t){return A(t)&&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}}var j=String.fromCharCode;var S=/^data:.*,/;function q(t){var i=new DataView(t),e=void 0,a=void 0,n=void 0,o=void 0;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var h=i.byteLength,s=2;s=8&&(o=r+l)}}}if(o){var c=i.getUint16(o,a),p=void 0,m=void 0;for(m=0;mi.width?3===a?r=i.height*s:d=i.width/s:3===a?d=i.width/s:r=i.height*s;var l={aspectRatio:s,naturalWidth:o,naturalHeight:h,width:r,height:d};l.left=(i.width-r)/2,l.top=(i.height-d)/2,l.oldLeft=l.left,l.oldTop=l.top,this.canvas=l,this.limited=1===a||2===a,this.limitCanvas(!0,!0),this.initialImage=t.extend({},e),this.initialCanvas=t.extend({},l)},limitCanvas:function(t,i){var e=this.options,a=this.container,n=this.canvas,o=this.cropBox,h=e.viewMode,s=n.aspectRatio,r=this.cropped&&o;if(t){var d=Number(e.minCanvasWidth)||0,l=Number(e.minCanvasHeight)||0;h>0&&(h>1?(d=Math.max(d,a.width),l=Math.max(l,a.height),3===h&&(l*s>d?d=l*s:l=d/s)):d?d=Math.max(d,r?o.width:0):l?l=Math.max(l,r?o.height:0):r&&(d=o.width,(l=o.height)*s>d?d=l*s:l=d/s));var c=F({aspectRatio:s,width:d,height:l});d=c.width,l=c.height,n.minWidth=d,n.minHeight=l,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),r&&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=function(t){var i=t.width,e=t.height,a=t.degree;if(90==(a=Math.abs(a)%180))return{width:e,height:i};var n=a%90*Math.PI/180,o=Math.sin(n),h=Math.cos(n),s=i*h+e*o,r=i*o+e*h;return a>90?{width:r,height:s}:{width:s,height:r}}({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,h=n.height,s=e.width*(o/e.naturalWidth),r=e.height*(h/e.naturalHeight);e.left-=(s-e.width)/2,e.top-=(r-e.height)/2,e.width=s,e.height=r,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,s=e.aspectRatio;if(t){var r=Number(e.minCropBoxWidth)||0,d=Number(e.minCropBoxHeight)||0,l=Math.min(a.width,h?n.width:a.width),c=Math.min(a.height,h?n.height:a.height);r=Math.min(r,a.width),d=Math.min(d,a.height),s&&(r&&d?d*s>r?d=r/s:r=d*s:r?d=r/s:d&&(r=d*s),c*s>l?c=l/s:l=c*s),o.minWidth=Math.min(r,l),o.minHeight=Math.min(d,c),o.maxWidth=l,o.maxHeight=c}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:L({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(c,this.getData())}},K={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(l,{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(l);a.css({width:n.width,height:n.height}).html(n.html).removeData(l)})},preview:function(){var i=this.image,e=this.canvas,a=this.cropBox,n=a.width,o=a.height,h=i.width,s=i.height,r=a.left-e.left-i.left,d=a.top-e.top-i.top;this.cropped&&!this.disabled&&(this.$clone2.css({width:h,height:s,transform:L(t.extend({translateX:-r,translateY:-d},i))}),this.$preview.each(function(e,a){var c=t(a),p=c.data(l),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),c.css({width:u,height:f}).find("img").css({width:h*v,height:s*v,transform:L(t.extend({translateX:-r*v,translateY:-d*v},i))})}))}},Z={bind:function(){var i=this.$element,e=this.options,a=this.$cropper;t.isFunction(e.cropstart)&&i.on(g,e.cropstart),t.isFunction(e.cropmove)&&i.on(m,e.cropmove),t.isFunction(e.cropend)&&i.on(p,e.cropend),t.isFunction(e.crop)&&i.on(c,e.crop),t.isFunction(e.zoom)&&i.on("zoom",e.zoom),a.on(u,H(this.cropStart,this)),e.zoomable&&e.zoomOnWheel&&a.on(w,H(this.wheel,this)),e.toggleDragModeOnDblclick&&a.on("dblclick",H(this.dblclick,this)),t(this.element.ownerDocument).on(f,this.onCropMove=H(this.cropMove,this)).on(v,this.onCropEnd=H(this.cropEnd,this)),e.responsive&&t(window).on("resize",this.onResize=H(this.resize,this))},unbind:function(){var i=this.$element,e=this.options,a=this.$cropper;t.isFunction(e.cropstart)&&i.off(g,e.cropstart),t.isFunction(e.cropmove)&&i.off(m,e.cropmove),t.isFunction(e.cropend)&&i.off(p,e.cropend),t.isFunction(e.crop)&&i.off(c,e.crop),t.isFunction(e.zoom)&&i.off("zoom",e.zoom),a.off(u,this.cropStart),e.zoomable&&e.zoomOnWheel&&a.off(w,this.wheel),e.toggleDragModeOnDblclick&&a.off("dblclick",this.dblclick),t(this.element.ownerDocument).off(f,this.onCropMove).off(v,this.onCropEnd),e.responsive&&t(window).off("resize",this.onResize)}},V={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 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(a)?"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]=U(i)}):a[n&&n.pointerId||0]=U(n||i),o=Y(a).length>1&&e.zoomable&&e.zoomOnTouch?"zoom":t(i.target).data(d),x.test(o)&&(this.trigger(g,{originalEvent:n,action:o}).isDefaultPrevented()||(i.preventDefault(),this.action=o,this.cropping=!1,"crop"===o&&(this.cropping=!0,this.$dragBox.addClass(s))))}},cropMove:function(i){var e=this.action;if(!this.disabled&&e){var a=this.pointers,n=i.originalEvent;i.preventDefault(),this.trigger(m,{originalEvent:n,action:e}).isDefaultPrevented()||(n&&n.changedTouches?t.each(n.changedTouches,function(i,e){t.extend(a[e.identifier],U(e,!0))}):t.extend(a[n&&n.pointerId||0],U(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(),Y(a).length||(this.action=""),this.cropping&&(this.cropping=!1,this.$dragBox.toggleClass(s,this.cropped&&this.options.modal)),this.trigger(p,{originalEvent:n,action:e}))}}},G={change:function(i){var e=this.options,a=this.pointers,n=this.container,h=this.canvas,s=this.cropBox,r=this.action,d=e.aspectRatio,l=s.left,c=s.top,p=s.width,m=s.height,g=l+p,u=c+m,f=0,v=0,w=n.width,x=n.height,b=!0,y=void 0;!d&&i.shiftKey&&(d=p&&m?p/m:1),this.limited&&(f=s.minLeft,v=s.minTop,w=f+Math.min(n.width,h.width,h.left+h.width),x=v+Math.min(n.height,h.height,h.top+h.height));var C,M,$,B=a[Y(a)[0]],k={x:B.endX-B.startX,y:B.endY-B.startY},W=function(t){switch(t){case"e":g+k.x>w&&(k.x=w-g);break;case"w":l+k.xx&&(k.y=x-u)}};switch(r){case"all":l+=k.x,c+=k.y;break;case"e":if(k.x>=0&&(g>=w||d&&(c<=v||u>=x))){b=!1;break}W("e"),p+=k.x,d&&(m=p/d,c-=k.x/d/2),p<0&&(r="w",p=0);break;case"n":if(k.y<=0&&(c<=v||d&&(l<=f||g>=w))){b=!1;break}W("n"),m-=k.y,c+=k.y,d&&(p=m*d,l+=k.y*d/2),m<0&&(r="s",m=0);break;case"w":if(k.x<=0&&(l<=f||d&&(c<=v||u>=x))){b=!1;break}W("w"),p-=k.x,l+=k.x,d&&(m=p/d,c+=k.x/d/2),p<0&&(r="e",p=0);break;case"s":if(k.y>=0&&(u>=x||d&&(l<=f||g>=w))){b=!1;break}W("s"),m+=k.y,d&&(p=m*d,l-=k.y*d/2),m<0&&(r="n",m=0);break;case"ne":if(d){if(k.y<=0&&(c<=v||g>=w)){b=!1;break}W("n"),m-=k.y,c+=k.y,p=m*d}else W("n"),W("e"),k.x>=0?gv&&(m-=k.y,c+=k.y):(m-=k.y,c+=k.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(d){if(k.y<=0&&(c<=v||l<=f)){b=!1;break}W("n"),m-=k.y,c+=k.y,p=m*d,l+=k.y*d}else W("n"),W("w"),k.x<=0?l>f?(p-=k.x,l+=k.x):k.y<=0&&c<=v&&(b=!1):(p-=k.x,l+=k.x),k.y<=0?c>v&&(m-=k.y,c+=k.y):(m-=k.y,c+=k.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(d){if(k.x<=0&&(l<=f||u>=x)){b=!1;break}W("w"),p-=k.x,l+=k.x,m=p/d}else W("s"),W("w"),k.x<=0?l>f?(p-=k.x,l+=k.x):k.y>=0&&u>=x&&(b=!1):(p-=k.x,l+=k.x),k.y>=0?u=0&&(g>=w||u>=x)){b=!1;break}W("e"),m=(p+=k.x)/d}else W("s"),W("e"),k.x>=0?g=0&&u>=x&&(b=!1):p+=k.x,k.y>=0?u0?r=k.y>0?"se":"ne":k.x<0&&(l-=p,r=k.y>0?"sw":"nw"),k.y<0&&(c-=m),this.cropped||(this.$cropBox.removeClass(o),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}b&&(s.width=p,s.height=m,s.left=l,s.top=c,this.action=r,this.renderCropBox()),t.each(a,function(t,i){i.startX=i.endX,i.startY=i.endY})}},J={crop:function(){this.ready&&!this.disabled&&(this.cropped||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&this.$dragBox.addClass(s),this.$cropBox.removeClass(o)),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(s),this.$cropBox.addClass(o))},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(n))},disable:function(){this.ready&&(this.disabled=!0,this.$cropper.addClass(n))},destroy:function(){var t=this.$element;this.loaded?(this.isImg&&this.replaced&&t.attr("src",this.originalUrl),this.unbuild(),t.removeClass(o)):this.isImg?t.off("load",this.start):this.$clone&&this.$clone.remove(),t.removeData(e)},move:function(t,i){var e=this.canvas,a=e.left,n=e.top;this.moveTo(T(t)?t:a+Number(t),T(i)?i:n+Number(i))},moveTo:function(t,i){var e=this.canvas,a=!1;T(i)&&(i=t),t=Number(t),i=Number(i),this.ready&&!this.disabled&&this.options.movable&&(D(t)&&(e.left=t,a=!0),D(i)&&(e.top=i,a=!0),a&&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(i,e){var a,n,o,h,s=this.options,r=this.pointers,d=this.canvas,l=d.width,c=d.height,p=d.naturalWidth,m=d.naturalHeight;if((i=Number(i))>=0&&this.ready&&!this.disabled&&s.zoomable){var g=p*i,u=m*i,f=void 0;if(e&&(f=e.originalEvent),this.trigger("zoom",{originalEvent:f,oldRatio:l/p,ratio:g/p}).isDefaultPrevented())return;if(f){var v=this.$cropper.offset(),w=r&&Y(r).length?(a=r,n=0,o=0,h=0,t.each(a,function(t,i){var e=i.startX,a=i.startY;n+=e,o+=a,h+=1}),{pageX:n/=h,pageY:o/=h}):{pageX:e.pageX||f.pageX||0,pageY:e.pageY||f.pageY||0};d.left-=(g-l)*((w.pageX-v.left-d.left)/l),d.top-=(u-c)*((w.pageY-v.top-d.top)/c)}else d.left-=(g-l)/2,d.top-=(u-c)/2;d.width=g,d.height=u,this.renderCanvas(!0)}},rotate:function(t){this.rotateTo((this.image.rotate||0)+Number(t))},rotateTo:function(t){D(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,D(i)?i:1)},scaleY:function(t){var i=this.image.scaleX;this.scale(D(i)?i:1,t)},scale:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,e=this.image,a=!1;t=Number(t),i=Number(i),this.ready&&!this.disabled&&this.options.scalable&&(D(t)&&(e.scaleX=t,a=!0),D(i)&&(e.scaleY=i,a=!0),a&&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 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 e=this.options,a=this.image,n=this.canvas,o={};if(t.isFunction(i)&&(i=i.call(this.element)),this.ready&&!this.disabled&&t.isPlainObject(i)){var h=!1;e.rotatable&&D(i.rotate)&&i.rotate!==a.rotate&&(a.rotate=i.rotate,h=!0),e.scalable&&(D(i.scaleX)&&i.scaleX!==a.scaleX&&(a.scaleX=i.scaleX,h=!0),D(i.scaleY)&&i.scaleY!==a.scaleY&&(a.scaleY=i.scaleY,h=!0)),h&&this.renderCanvas(!0,!0);var s=a.width/a.naturalWidth;D(i.x)&&(o.left=i.x*s+n.left),D(i.y)&&(o.top=i.y*s+n.top),D(i.width)&&(o.width=i.width*s),D(i.height)&&(o.height=i.height*s),this.setCropBoxData(o)}},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,a=e.aspectRatio;t.isFunction(i)&&(i=i.call(this.$element)),this.ready&&!this.disabled&&t.isPlainObject(i)&&(D(i.left)&&(e.left=i.left),D(i.top)&&(e.top=i.top),D(i.width)?(e.width=i.width,e.height=i.width/a):D(i.height)&&(e.height=i.height,e.width=i.height*a),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,a=this.options.aspectRatio,n=void 0,o=void 0;t.isFunction(i)&&(i=i.call(this.$element)),this.ready&&this.cropped&&!this.disabled&&t.isPlainObject(i)&&(D(i.left)&&(e.left=i.left),D(i.top)&&(e.top=i.top),D(i.width)&&i.width!==e.width&&(n=!0,e.width=i.width),D(i.height)&&i.height!==e.height&&(o=!0,e.height=i.height),a&&(n?e.height=e.width/a:o&&(e.width=e.height*a)),this.renderCropBox())},getCroppedCanvas:function(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e,a,n,o,h,s,r,d,l,c,p,m,g,u,f,v,w,x,b,y,C,M,$,B,W,D,T,H,Y,X,O,E,N,R,L,P,I=this.canvas,U=(e=this.$clone[0],a=this.image,n=I,o=i,h=a.naturalWidth,s=a.naturalHeight,r=a.rotate,d=void 0===r?0:r,l=a.scaleX,c=void 0===l?1:l,p=a.scaleY,m=void 0===p?1:p,g=n.aspectRatio,u=n.naturalWidth,f=n.naturalHeight,v=o.fillColor,w=void 0===v?"transparent":v,x=o.imageSmoothingEnabled,b=void 0===x||x,y=o.imageSmoothingQuality,C=void 0===y?"low":y,M=o.maxWidth,$=void 0===M?1/0:M,B=o.maxHeight,W=void 0===B?1/0:B,D=o.minWidth,T=void 0===D?0:D,H=o.minHeight,Y=void 0===H?0:H,X=F({aspectRatio:g,width:$,height:W}),O=F({aspectRatio:g,width:T,height:Y}),E=Math.min(X.width,Math.max(O.width,u)),N=Math.min(X.height,Math.max(O.height,f)),R=document.createElement("canvas"),L=R.getContext("2d"),P=[-h/2,-s/2,h,s],R.width=z(E),R.height=z(N),L.fillStyle=w,L.fillRect(0,0,E,N),L.save(),L.translate(E/2,N/2),L.rotate(d*Math.PI/180),L.scale(c,m),L.imageSmoothingEnabled=!!b,L.imageSmoothingQuality=C,L.drawImage.apply(L,[e].concat(k(t.map(P,function(t){return Math.floor(z(t))})))),L.restore(),R);if(!this.cropped)return U;var A=this.getData(),j=A.x,S=A.y,q=A.width,Q=A.height,K=q/Q,Z=F({aspectRatio:K,width:i.maxWidth||1/0,height:i.maxHeight||1/0}),V=F({aspectRatio:K,width:i.minWidth||0,height:i.minHeight||0}),G=F({aspectRatio:K,width:i.width||q,height:i.height||Q}),J=G.width,_=G.height;J=Math.min(Z.width,Math.max(V.width,J)),_=Math.min(Z.height,Math.max(V.height,_));var tt=document.createElement("canvas"),it=tt.getContext("2d");tt.width=z(J),tt.height=z(_),it.fillStyle=i.fillColor||"transparent",it.fillRect(0,0,J,_);var et=i.imageSmoothingEnabled,at=void 0===et||et,nt=i.imageSmoothingQuality;it.imageSmoothingEnabled=at,nt&&(it.imageSmoothingQuality=nt);var ot=U.width,ht=U.height,st=j,rt=S,dt=void 0,lt=void 0,ct=void 0,pt=void 0,mt=void 0,gt=void 0;st<=-q||st>ot?(st=0,dt=0,ct=0,mt=0):st<=0?(ct=-st,st=0,mt=dt=Math.min(ot,q+st)):st<=ot&&(ct=0,mt=dt=Math.min(q,ot-st)),dt<=0||rt<=-Q||rt>ht?(rt=0,lt=0,pt=0,gt=0):rt<=0?(pt=-rt,rt=0,gt=lt=Math.min(ht,Q+rt)):rt<=ht&&(pt=0,gt=lt=Math.min(Q,ht-rt));var ut=[st,rt,dt,lt];if(mt>0&>>0){var ft=J/q;ut.push(ct*ft,pt*ft,mt*ft,gt*ft)}return it.drawImage.apply(it,[U].concat(k(t.map(ut,function(t){return Math.floor(z(t))})))),tt},setAspectRatio:function(t){var i=this.options;this.disabled||T(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,n=void 0;this.loaded&&!this.disabled&&(e="crop"===t,n=i.movable&&"move"===t,t=e||n?t:"none",this.$dragBox.data(d,t).toggleClass(a,e).toggleClass(r,n),i.cropBoxMovable||this.$face.data(d,t).toggleClass(a,e).toggleClass(r,n))}},_=function(){function i(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if($(this,i),!e||!C.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({},M,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 B(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")&&window.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(i){var e=this;if(i){this.url=i,this.image={};var a=this.$element,n=this.options;if(n.checkOrientation&&window.ArrayBuffer)if(b.test(i))y.test(i)?this.read((o=i.replace(S,""),h=atob(o),s=new ArrayBuffer(h.length),r=new Uint8Array(s),t.each(r,function(t){r[t]=h.charCodeAt(t)}),s)):this.clone();else{var o,h,s,r,d=new XMLHttpRequest;d.onerror=function(){e.clone()},d.onload=function(){e.read(d.response)},n.checkCrossOrigin&&N(i)&&!a.prop("crossOrigin")&&(i=R(i)),d.open("get",i),d.responseType="arraybuffer",d.withCredentials="use-credentials"===a.prop("crossOrigin"),d.send()}else this.clone()}}},{key:"read",value:function(i){var e,a,n,o=this.options,h=this.image,s=q(i),r=0,d=1,l=1;if(s>1){this.url=(e="image/jpeg",a=new Uint8Array(i),n="",t.each(a,function(t,i){n+=j(i)}),"data:"+e+";base64,"+btoa(n));var c=function(t){var i=0,e=1,a=1;switch(t){case 2:e=-1;break;case 3:i=-180;break;case 4:a=-1;break;case 5:i=90,a=-1;break;case 6:i=90;break;case 7:i=90,e=-1;break;case 8:i=-90}return{rotate:i,scaleX:e,scaleY:a}}(s);r=c.rotate,d=c.scaleX,l=c.scaleY}o.rotatable&&(h.rotate=r),o.scalable&&(h.scaleX=d,h.scaleY=l),this.clone()}},{key:"clone",value:function(){var i=this.$element,e=this.options,a=this.url,n="",o=void 0;e.checkCrossOrigin&&N(a)&&((n=i.prop("crossOrigin"))?o=a:(n="anonymous",o=R(a))),this.crossOrigin=n,this.crossOriginUrl=o;var s=document.createElement("img");n&&(s.crossOrigin=n),s.src=o||a;var r=t(s);this.$clone=r,this.isImg?this.element.complete?this.start():i.one("load",t.proxy(this.start,this)):r.one("load",t.proxy(this.start,this)).one("error",t.proxy(this.stop,this)).addClass(h).insertAfter(i)}},{key:"start",value:function(){var i=this,e=this.$clone,a=this.$element;this.isImg||(e.off("error",this.stop),a=e),function(t,i){if(!t.naturalWidth||I){var e=document.createElement("img");e.onload=function(){i(e.width,e.height)},e.src=t.src}else i(t.naturalWidth,t.naturalHeight)}(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 a=this.$element,n=this.options,l=this.$clone,p=t('
'),m=p.find("."+e+"-crop-box"),g=m.find("."+e+"-face");this.$container=a.parent(),this.$cropper=p,this.$canvas=p.find("."+e+"-canvas").append(l),this.$dragBox=p.find("."+e+"-drag-box"),this.$cropBox=m,this.$viewBox=p.find("."+e+"-view-box"),this.$face=g,a.addClass(o).after(p),this.isImg||l.removeClass(h),this.initPreview(),this.bind(),n.aspectRatio=Math.max(0,n.aspectRatio)||NaN,n.viewMode=Math.max(0,Math.min(3,Math.round(n.viewMode)))||0,this.cropped=n.autoCrop,n.autoCrop?n.modal&&this.$dragBox.addClass(s):m.addClass(o),n.guides||m.find("."+e+"-dashed").addClass(o),n.center||m.find("."+e+"-center").addClass(o),n.cropBoxMovable&&g.addClass(r).data(d,"all"),n.highlight||g.addClass("cropper-invisible"),n.background&&p.addClass(e+"-bg"),n.cropBoxResizable||m.find("."+e+"-line,."+e+"-point").addClass(o),this.setDragMode(n.dragMode),this.render(),this.ready=!0,this.setData(n.data),this.completing=setTimeout(function(){t.isFunction(n.ready)&&a.one("ready",n.ready),i.trigger("ready"),i.trigger(c,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(M,t.isPlainObject(i)&&i)}}]),i}();if(t.extend&&t.extend(_.prototype,Q,K,Z,V,G,J),t.fn){var tt=t.fn.cropper;t.fn.cropper=function(i){for(var a=arguments.length,n=Array(a>1?a-1:0),o=1;o' + '
' + '' + '
' + '
' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' + ''; -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); } } +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +var toConsumableArray = function (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. @@ -477,9 +549,9 @@ function getRotatedSizes(_ref5) { height = _ref5.height, degree = _ref5.degree; - degree = Math.abs(degree); + degree = Math.abs(degree) % 180; - if (degree % 180 === 90) { + if (degree === 90) { return { width: height, height: width @@ -489,10 +561,15 @@ function getRotatedSizes(_ref5) { var arc = degree % 90 * Math.PI / 180; var sinArc = Math.sin(arc); var cosArc = Math.cos(arc); - - return { - width: width * cosArc + height * sinArc, - height: width * sinArc + height * cosArc + var newWidth = width * cosArc + height * sinArc; + var newHeight = width * sinArc + height * cosArc; + + return degree > 90 ? { + width: newHeight, + height: newWidth + } : { + width: newWidth, + height: newHeight }; } @@ -557,7 +634,7 @@ function getSourceCanvas(image, _ref6, _ref7, _ref8) { context.scale(scaleX, scaleY); context.imageSmoothingEnabled = !!imageSmoothingEnabled; context.imageSmoothingQuality = imageSmoothingQuality; - context.drawImage.apply(context, [image].concat(_toConsumableArray($.map(params, function (param) { + context.drawImage.apply(context, [image].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); context.restore(); @@ -1317,7 +1394,7 @@ var events = { $cropper.on(EVENT_DBLCLICK, proxy(this.dblclick, this)); } - $(document).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); + $(this.element.ownerDocument).on(EVENT_POINTER_MOVE, this.onCropMove = proxy(this.cropMove, this)).on(EVENT_POINTER_UP, this.onCropEnd = proxy(this.cropEnd, this)); if (options.responsive) { $(window).on(EVENT_RESIZE, this.onResize = proxy(this.resize, this)); @@ -1359,7 +1436,7 @@ var events = { $cropper.off(EVENT_DBLCLICK, this.dblclick); } - $(document).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); + $(this.element.ownerDocument).off(EVENT_POINTER_MOVE, this.onCropMove).off(EVENT_POINTER_UP, this.onCropEnd); if (options.responsive) { $(window).off(EVENT_RESIZE, this.onResize); @@ -2002,8 +2079,6 @@ 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() { @@ -2724,7 +2799,7 @@ var methods = { params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale); } - context.drawImage.apply(context, [source].concat(_toConsumableArray$1($.map(params, function (param) { + context.drawImage.apply(context, [source].concat(toConsumableArray($.map(params, function (param) { return Math.floor(normalizeDecimalNumber(param)); })))); return canvas; @@ -2779,10 +2854,6 @@ var methods = { } }; -var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var Cropper = function () { /** * Create a new Cropper. @@ -2791,8 +2862,7 @@ var Cropper = function () { */ function Cropper(element) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - - _classCallCheck(this, Cropper); + classCallCheck(this, Cropper); if (!element || !REGEXP_TAG_NAME.test(element.tagName)) { throw new Error('The first argument is required and must be an or element.'); @@ -2817,7 +2887,7 @@ var Cropper = function () { this.init(); } - _createClass(Cropper, [{ + createClass(Cropper, [{ key: 'init', value: function init() { var $element = this.$element; @@ -2898,7 +2968,8 @@ var Cropper = function () { _this.read(xhr.response); }; - if (options.checkCrossOrigin && isCrossOriginURL(url) && $element.prop('crossOrigin')) { + // Bust cache when there is a "crossOrigin" property + if (options.checkCrossOrigin && isCrossOriginURL(url) && !$element.prop('crossOrigin')) { url = addTimestamp(url); } @@ -3162,7 +3233,6 @@ var Cropper = function () { $.extend(DEFAULTS, $.isPlainObject(options) && options); } }]); - return Cropper; }(); diff --git a/package-lock.json b/package-lock.json index 62470885..62ee4ebc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cropper", - "version": "3.1.3", + "version": "3.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -456,6 +456,15 @@ "babel-runtime": "6.26.0" } }, + "babel-plugin-external-helpers": { + "version": "6.22.0", + "resolved": "https://registry.npmjs.org/babel-plugin-external-helpers/-/babel-plugin-external-helpers-6.22.0.tgz", + "integrity": "sha1-IoX0iwK9Xe3oUXXK+MYuhq3M76E=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, "babel-plugin-syntax-async-functions": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz", @@ -976,23 +985,6 @@ "repeat-element": "1.1.2" } }, - "browser-resolve": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", - "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", - "dev": true, - "requires": { - "resolve": "1.1.7" - }, - "dependencies": { - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", - "dev": true - } - } - }, "browserslist": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-2.5.0.tgz", @@ -1101,6 +1093,12 @@ "supports-color": "2.0.0" } }, + "chardet": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", + "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", + "dev": true + }, "chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -1867,13 +1865,12 @@ "dev": true }, "doctrine": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.0.tgz", - "integrity": "sha1-xz2NKQnSIpHhoAejlYBNqLZl/mM=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { - "esutils": "2.0.2", - "isarray": "1.0.0" + "esutils": "2.0.2" } }, "doiuse": { @@ -2091,9 +2088,9 @@ } }, "es6-promise": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.1.1.tgz", - "integrity": "sha512-OaU1hHjgJf+b0NzsxCg7NdIYERD6Hy/PEmFLTjw+b65scuisG3Kt4QoTvJ66BBkPZ581gr0kpoVzKnxniM8nng==", + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz", + "integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==", "dev": true }, "escape-string-regexp": { @@ -2103,31 +2100,31 @@ "dev": true }, "eslint": { - "version": "4.11.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.11.0.tgz", - "integrity": "sha512-UWbhQpaKlm8h5x/VLwm0S1kheMrDj8jPwhnBMjr/Dlo3qqT7MvcN/UfKAR3E1N4lr4YNtOvS4m3hwsrVc/ky7g==", + "version": "4.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.15.0.tgz", + "integrity": "sha512-zEO/Z1ZUxIQ+MhDVKkVTUYpIPDTEJLXGMrkID+5v1NeQHtCz6FZikWuFRgxE1Q/RV2V4zVl1u3xmpPADHhMZ6A==", "dev": true, "requires": { - "ajv": "5.3.0", + "ajv": "5.5.2", "babel-code-frame": "6.26.0", "chalk": "2.3.0", "concat-stream": "1.6.0", "cross-spawn": "5.1.0", "debug": "3.1.0", - "doctrine": "2.0.0", + "doctrine": "2.1.0", "eslint-scope": "3.7.1", + "eslint-visitor-keys": "1.0.0", "espree": "3.5.2", "esquery": "1.0.0", - "estraverse": "4.2.0", "esutils": "2.0.2", "file-entry-cache": "2.0.0", "functional-red-black-tree": "1.0.1", "glob": "7.1.2", - "globals": "9.18.0", + "globals": "11.1.0", "ignore": "3.3.5", "imurmurhash": "0.1.4", "inquirer": "3.3.0", - "is-resolvable": "1.0.0", + "is-resolvable": "1.0.1", "js-yaml": "3.10.0", "json-stable-stringify-without-jsonify": "1.0.1", "levn": "0.3.0", @@ -2148,9 +2145,9 @@ }, "dependencies": { "ajv": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.3.0.tgz", - "integrity": "sha1-RBT/dKUIecII7l/cgm4ywwNUnto=", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", "dev": true, "requires": { "co": "4.6.0", @@ -2214,6 +2211,12 @@ "path-is-absolute": "1.0.1" } }, + "globals": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.1.0.tgz", + "integrity": "sha512-uEuWt9mqTlPDwSqi+sHjD4nWU/1N+q0fiWI9T1mZpD2UENqX20CFD5T/ziLZvztPaBKl7ZylUi1q6Qfm7E2CiQ==", + "dev": true + }, "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", @@ -2382,6 +2385,12 @@ "estraverse": "4.2.0" } }, + "eslint-visitor-keys": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", + "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", + "dev": true + }, "espree": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.2.tgz", @@ -2499,13 +2508,13 @@ "dev": true }, "external-editor": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.0.5.tgz", - "integrity": "sha512-Msjo64WT5W+NhOpQXh0nOHm+n0RfU1QUwDnKYvJ8dEJ8zlwLrqXNTv5mSUTJpepf41PDJGyhueTw2vNZW+Fr/w==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", + "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", "dev": true, "requires": { + "chardet": "0.4.2", "iconv-lite": "0.4.19", - "jschardet": "1.6.0", "tmp": "0.0.33" } }, @@ -3016,7 +3025,7 @@ "chalk": "2.3.0", "cli-cursor": "2.1.0", "cli-width": "2.2.0", - "external-editor": "2.0.5", + "external-editor": "2.1.0", "figures": "2.0.0", "lodash": "4.17.4", "mute-stream": "0.0.7", @@ -3313,13 +3322,10 @@ "dev": true }, "is-resolvable": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.0.tgz", - "integrity": "sha1-jfV8YeouPFAUCNEA+wE8+NbgzGI=", - "dev": true, - "requires": { - "tryit": "1.0.3" - } + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.0.1.tgz", + "integrity": "sha512-y5CXYbzvB3jTnWAZH1Nl7ykUWb6T3BcTs56HUruwBf8MhF56n1HWqhDWnVFo8GHrUPDgvUUNVhrc2U8W7iqz5g==", + "dev": true }, "is-retry-allowed": { "version": "1.1.0", @@ -3434,12 +3440,6 @@ "dev": true, "optional": true }, - "jschardet": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/jschardet/-/jschardet-1.6.0.tgz", - "integrity": "sha512-xYuhvQ7I9PDJIGBWev9xm0+SMSed3ZDBAmvVjbFR1ZRLAF+vlXcQu6cRI9uAlj81rzikElRVteehwV7DuX2ZmQ==", - "dev": true - }, "jsesc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-1.3.0.tgz", @@ -3865,9 +3865,9 @@ } }, "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", "dev": true }, "mime-db": { @@ -3955,15 +3955,15 @@ } }, "node-qunit-phantomjs": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/node-qunit-phantomjs/-/node-qunit-phantomjs-1.6.0.tgz", - "integrity": "sha512-biPV9v2CSuDT6CxQyPOZj4baFdPftxbklcJREXmzxVdpngmI2VqZvAgnkKx5LAJXmJvrct078Al+vHHVBAn1kQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/node-qunit-phantomjs/-/node-qunit-phantomjs-2.0.0.tgz", + "integrity": "sha512-xZV0J8fBbe8h04IkBxLtwvGVbP0ViUhkJzjFx/tb7uWT02w6iMt5X6HDmdTZuQXBMsgahyaIGjW30l3HSlj2yA==", "dev": true, "requires": { "chalk": "2.3.0", "minimist": "1.2.0", "phantomjs-prebuilt": "2.1.16", - "qunit-phantomjs-runner": "2.3.0" + "qunit-phantomjs-runner": "2.3.1" }, "dependencies": { "ansi-styles": { @@ -4415,7 +4415,7 @@ "integrity": "sha1-79ISpKOWbTZHaE6ouniFSb4q7+8=", "dev": true, "requires": { - "es6-promise": "4.1.1", + "es6-promise": "4.2.2", "extract-zip": "1.6.6", "fs-extra": "1.0.0", "hasha": "2.2.0", @@ -7074,15 +7074,15 @@ } }, "postcss-url": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/postcss-url/-/postcss-url-7.1.2.tgz", - "integrity": "sha1-4Erjhq9+pu9d9RxbRJ1rlQLNmbI=", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/postcss-url/-/postcss-url-7.3.0.tgz", + "integrity": "sha512-VBP6uf6iL3AZra23nkPkOEkS/5azj1xf/toRrjfkolfFEgg9Gyzg9UhJZeIsz12EGKZTNVeGbPa2XtaZm/iZvg==", "dev": true, "requires": { - "mime": "1.4.1", + "mime": "1.6.0", "minimatch": "3.0.4", "mkdirp": "0.5.1", - "postcss": "6.0.13", + "postcss": "6.0.16", "xxhashjs": "0.2.1" }, "dependencies": { @@ -7096,14 +7096,25 @@ } }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" + "supports-color": "4.5.0" + }, + "dependencies": { + "supports-color": { + "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" + } + } } }, "has-flag": { @@ -7113,14 +7124,14 @@ "dev": true }, "postcss": { - "version": "6.0.13", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.13.tgz", - "integrity": "sha512-nHsrD1PPTMSJDfU+osVsLtPkSP9YGeoOz4FDLN4r1DW4N5vqL1J+gACzTQHsfwIiWG/0/nV4yCzjTMo1zD8U1g==", + "version": "6.0.16", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.16.tgz", + "integrity": "sha512-m758RWPmSjFH/2MyyG3UOW1fgYbR9rtdzz5UNJnlm7OLtu4B2h9C6gi+bE4qFKghsBRFfZT8NzoQBs6JhLotoA==", "dev": true, "requires": { - "chalk": "2.1.0", + "chalk": "2.3.0", "source-map": "0.6.1", - "supports-color": "4.4.0" + "supports-color": "5.1.0" } }, "source-map": { @@ -7130,9 +7141,9 @@ "dev": true }, "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": "5.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.1.0.tgz", + "integrity": "sha512-Ry0AwkoKjDpVKK4sV4h6o3UJmNRbjYm2uXhwfj3J56lMVdvnUNqzQVRztOOMGQ++w1K/TjNDFvpJk0F/LoeBCQ==", "dev": true, "requires": { "has-flag": "2.0.0" @@ -7243,9 +7254,9 @@ } }, "qunit-phantomjs-runner": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/qunit-phantomjs-runner/-/qunit-phantomjs-runner-2.3.0.tgz", - "integrity": "sha1-JwrLGXwPL8qvBmdqsKSP1aymapk=", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/qunit-phantomjs-runner/-/qunit-phantomjs-runner-2.3.1.tgz", + "integrity": "sha512-RLg51606zm6/HwZi29NciAMAqifyJE1oGg77tEuk05vEa7kuqEaI0Mkjw976Ynnq7GXurATnbFd+471c024tBQ==", "dev": true, "requires": { "qunit-reporter-junit": "1.1.1" @@ -7678,15 +7689,15 @@ } }, "rollup": { - "version": "0.51.5", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.51.5.tgz", - "integrity": "sha512-nvwUduO53TvWigOaOv7t+rNoEUW53sTUeqMAjlxp7ekeHirPECnWXSwiPwiqvGNdbJTQbOdHFPAZZfjo61BtVQ==", + "version": "0.54.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.54.0.tgz", + "integrity": "sha512-lgW/RpP8e8HdkrgJtFeBwzuWfvj+eo7yWfJ8AXRfi6a3d0DeYxysr4CwvqnTxJbtvcQ19L0L2bLDQkVK1Db4JA==", "dev": true }, "rollup-plugin-babel": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-3.0.2.tgz", - "integrity": "sha512-ALGPBFtwJZcYHsNPM6RGJlEncTzAARPvZOGjNPZgDe5hS5t6sJGjiOWibEFVEz5LQN7S7spvCBILaS4N1Cql2w==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-3.0.3.tgz", + "integrity": "sha512-5kzM/Rr4jQSRPLc2eN5NuD+CI/6AAy7S1O18Ogu4U3nq1Q42VJn0C9EMtqnvxtfwf1XrezOtdA9ro1VZI5B0mA==", "dev": true, "requires": { "rollup-pluginutils": "1.5.2" @@ -7732,12 +7743,11 @@ } }, "rollup-plugin-node-resolve": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.0.tgz", - "integrity": "sha1-i4l8TDAw1QASd7BRSyXSygloPuA=", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.0.2.tgz", + "integrity": "sha512-ZwmMip/yqw6cmDQJuCQJ1G7gw2z11iGUtQNFYrFZHmqadRHU+OZGC3nOXwXu+UTvcm5lzDspB1EYWrkTgPWybw==", "dev": true, "requires": { - "browser-resolve": "1.11.2", "builtin-modules": "1.1.1", "is-module": "1.0.0", "resolve": "1.4.0" @@ -8691,12 +8701,6 @@ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, - "tryit": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", - "integrity": "sha1-OTvnMKlEb9Hq1tpZoBQwjzbCics=", - "dev": true - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -8729,15 +8733,21 @@ "dev": true }, "uglify-js": { - "version": "3.1.9", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.9.tgz", - "integrity": "sha512-ari2E89bD7f+fMU173NgF12JBcOhgoxeyuCs97h5K58IBENrnG9eVj2lFadrOPdqf0KifsxVmUQfzA2cHNxCZQ==", + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.3.5.tgz", + "integrity": "sha512-ZebM2kgBL/UI9rKeAbsS2J0UPPv7SBy5hJNZml/YxB1zC6JK8IztcPs+cxilE4pu0li6vadVSFqiO7xFTKuSrg==", "dev": true, "requires": { - "commander": "2.11.0", + "commander": "2.12.2", "source-map": "0.6.1" }, "dependencies": { + "commander": { + "version": "2.12.2", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.12.2.tgz", + "integrity": "sha512-BFnaq5ZOGcDN7FlrtBT4xxkgIToalIIxwjxLWVJ8bGTpe1LroqMiqQXdA7ygc7CRvaYS+9zfPGFnJqFSayx+AA==", + "dev": true + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", diff --git a/package.json b/package.json index 924c6913..09d8593c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cropper", "description": "A simple jQuery image cropping plugin.", - "version": "3.1.3", + "version": "3.1.4", "main": "dist/cropper.common.js", "module": "dist/cropper.esm.js", "browser": "dist/cropper.js", @@ -53,27 +53,28 @@ }, "devDependencies": { "babel-core": "^6.26.0", + "babel-plugin-external-helpers": "^6.22.0", "babel-preset-env": "^1.6.1", "cpy-cli": "^1.0.1", "cssnano": "^3.10.0", "del-cli": "^1.1.0", - "eslint": "^4.11.0", + "eslint": "^4.15.0", "eslint-config-airbnb-base": "^12.1.0", "eslint-plugin-import": "^2.8.0", "jquery": "^3.2.1", - "node-qunit-phantomjs": "^1.6.0", + "node-qunit-phantomjs": "^2.0.0", "npm-run-all": "^4.1.2", "postcss-cli": "^4.1.1", "postcss-cssnext": "^3.0.2", "postcss-header": "^1.0.0", - "postcss-url": "^7.1.2", - "rollup": "^0.51.5", - "rollup-plugin-babel": "^3.0.2", + "postcss-url": "^7.3.0", + "rollup": "^0.54.0", + "rollup-plugin-babel": "^3.0.3", "rollup-plugin-commonjs": "^8.2.6", - "rollup-plugin-node-resolve": "^3.0.0", + "rollup-plugin-node-resolve": "^3.0.2", "rollup-watch": "^4.3.1", "stylefmt": "^6.0.0", - "uglify-js": "^3.1.9" + "uglify-js": "^3.3.5" }, "peerDependencies": { "jquery": ">= 1.9.1"