diff --git a/CHANGELOG.md b/CHANGELOG.md index c786b00..c95a1a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Prism Library Changelog ### v1.20 * Upgraded [VueJS](https://vuejs.org/) to v2.4.2. +* Upgraded [jQuery Cropper](https://fengyuanchen.github.io/cropper/) to v3.0.0. * Upgraded [jQuery AutoComplete](https://github.com/devbridge/jQuery-Autocomplete) to v1.4.1. * Upgraded [jQuery File Upload](https://github.com/blueimp/jQuery-File-Upload) to v9.18.0. * Upgraded [SweetAlert2](https://limonte.github.io/sweetalert2/) to v6.6.5. @@ -16,6 +17,7 @@ Prism Library Changelog * Renamed folder __libs__ to __vendor__. * The antbuilder reworked. Now, it builds Joomla! package from current source. * Published to Packagist. The library can be installed to any framework via Composer. +* It was decreased minimum image size to 25 when resize or crop. ### v1.19.6 * Improved Log class. diff --git a/build/build.xml b/build/build.xml index 5f48df1..98d5ac3 100644 --- a/build/build.xml +++ b/build/build.xml @@ -21,20 +21,21 @@ - + + + - - - + + @@ -69,7 +70,7 @@ - + @@ -96,8 +97,13 @@ - + + + + + + diff --git a/src/Database/Condition/Condition.php b/src/Database/Condition/Condition.php index 0210908..acfac37 100644 --- a/src/Database/Condition/Condition.php +++ b/src/Database/Condition/Condition.php @@ -55,8 +55,8 @@ public function __construct(array $data = array()) $this->raw = array_key_exists('raw', $data) ? (string)$data['raw'] : ''; $this->column = array_key_exists('column', $data) ? (string)$data['column'] : ''; $this->value = array_key_exists('value', $data) ? $data['value'] : ''; - $this->table = array_key_exists('table', $data) ? (string)$data['table'] : ''; - $this->operator = array_key_exists('operator', $data) ? (string)$data['operator'] : ''; + $this->table = array_key_exists('table', $data) ? (string)$data['table'] : 'a'; + $this->operator = array_key_exists('operator', $data) ? (string)$data['operator'] : '='; } /** diff --git a/src/Database/JoomlaDatabaseGateway.php b/src/Database/JoomlaDatabaseGateway.php index ec643b8..d8eeffd 100644 --- a/src/Database/JoomlaDatabaseGateway.php +++ b/src/Database/JoomlaDatabaseGateway.php @@ -126,10 +126,11 @@ protected function limit(\JDatabaseQuery $query, Request $request) * * @param Request $request * @param array $defaultFields + * @param array $aliasFields * * @return array */ - protected function prepareFields($request, array $defaultFields) + protected function prepareFields($request, array $defaultFields, array $aliasFields = array()) { $fields = array(); @@ -140,16 +141,20 @@ protected function prepareFields($request, array $defaultFields) if (count($requiredFields) > 0) { /** @var Field $field */ foreach ($requiredFields as $field) { - $requireField = $field->getTable() ? $field->getTable() . '.' . $field->getColumn() : 'a.' . $field->getColumn(); - if (!in_array($requireField, $defaultFields, true)) { - continue; + if ($field->isAlias() && array_key_exists($field->getColumn(), $aliasFields)) { + $fields[] = $aliasFields[$field->getColumn()]; + } else { + $requireField = $field->getTable() ? $field->getTable() . '.' . $field->getColumn() : 'a.' . $field->getColumn(); + if (!in_array($requireField, $defaultFields, true)) { + continue; + } + + if ($field->getAlias()) { + $requireField .= ' AS ' . $field->getAlias(); + } + + $fields[] = $requireField; } - - if ($field->getAlias()) { - $requireField .= ' AS ' . $field->getAlias(); - } - - $fields[] = $requireField; } } } diff --git a/src/Database/Request/Field.php b/src/Database/Request/Field.php index 21d23d9..076293e 100644 --- a/src/Database/Request/Field.php +++ b/src/Database/Request/Field.php @@ -45,12 +45,20 @@ class Field */ protected $raw; + /** + * It shows us the column name is an alias of expression. + * + * @var string + */ + protected $is_alias = false; + public function __construct(array $data) { - $this->raw = array_key_exists('raw', $data) ? (string)$data['raw'] : ''; - $this->alias = array_key_exists('alias', $data) ? (string)$data['alias'] : ''; - $this->column = array_key_exists('column', $data) ? (string)$data['column'] : ''; - $this->table = array_key_exists('table', $data) ? (string)$data['table'] : ''; + $this->raw = array_key_exists('raw', $data) ? (string)$data['raw'] : ''; + $this->alias = array_key_exists('alias', $data) ? (string)$data['alias'] : ''; + $this->column = array_key_exists('column', $data) ? (string)$data['column'] : ''; + $this->table = array_key_exists('table', $data) ? (string)$data['table'] : ''; + $this->is_alias = array_key_exists('is_alias', $data) ? (bool)$data['is_alias'] : false; } /** @@ -116,4 +124,14 @@ public function setRaw($raw) { $this->raw = $raw; } + + /** + * Check if the filed is an alias of expression. + * + * @return bool + */ + public function isAlias() + { + return (bool)$this->is_alias; + } } diff --git a/src/Database/Request/Request.php b/src/Database/Request/Request.php index b836507..49793d7 100644 --- a/src/Database/Request/Request.php +++ b/src/Database/Request/Request.php @@ -9,6 +9,7 @@ namespace Prism\Database\Request; +use Prism\Database\Condition\Condition; use Prism\Database\Condition\Conditions; use Prism\Database\Condition\Order; use Prism\Database\Condition\Ordering; @@ -50,10 +51,10 @@ class Request public function __construct() { - $this->fields = new Fields(); - $this->conditions = new Conditions(); - $this->ordering = new Ordering(); - $this->limit = new Limit(); + $this->fields = new Fields; + $this->conditions = new Conditions; + $this->ordering = new Ordering; + $this->limit = new Limit; } /** @@ -135,4 +136,40 @@ public function getLimit() { return $this->limit; } + + /** + * @param Condition $condition + * + * @return self + */ + public function addCondition(Condition $condition) + { + $this->conditions->addCondition($condition); + + return $this; + } + + /** + * @param Field $field + * + * @return self + */ + public function requestField(Field $field) + { + $this->fields->addField($field); + + return $this; + } + + /** + * @param Order $condition + * + * @return self + */ + public function addOrderCondition(Order $condition) + { + $this->ordering->addCondition($condition); + + return $this; + } } diff --git a/src/Domain/PropertiesMethods.php b/src/Domain/PropertiesMethods.php index 87841da..c99efda 100644 --- a/src/Domain/PropertiesMethods.php +++ b/src/Domain/PropertiesMethods.php @@ -18,7 +18,7 @@ trait PropertiesMethods { /** - * Returns object properties as associative array; + * Returns object properties as associative array. * * @return array */ diff --git a/src/Domain/ToOptionsMethod.php b/src/Domain/ToOptionsMethod.php index 9a86546..b7b5c22 100644 --- a/src/Domain/ToOptionsMethod.php +++ b/src/Domain/ToOptionsMethod.php @@ -35,7 +35,7 @@ public function toOptions($key, $text, $suffix = '') $properties = is_object($item) ? $item->getProperties() : $item; if ($suffix !== '' && (array_key_exists($suffix, $properties) && (string)$properties[$suffix] !== '')) { - $options[] = array('value' => $properties[$key], 'text' => $properties[$text] . ' ['.(string)$properties[$suffix].']'); + $options[] = array('value' => $properties[$key], 'text' => $properties[$text] . ', '.(string)$properties[$suffix]); } else { $options[] = array('value' => $properties[$key], 'text' => $properties[$text]); } diff --git a/src/File/Image.php b/src/File/Image.php index c362792..f377083 100644 --- a/src/File/Image.php +++ b/src/File/Image.php @@ -94,9 +94,9 @@ public function resize($destinationFolder, Registry $options) // Resize to general size. $width = $options->get('width', 640); - $width = ($width < 50) ? 50 : $width; + $width = ($width < 25) ? 25 : $width; $height = $options->get('height', 480); - $height = ($height < 50) ? 50 : $height; + $height = ($height < 25) ? 25 : $height; $scale = $options->get('scale', \JImage::SCALE_INSIDE); $createNew = (bool)$options->get('create_new', Constants::NO); @@ -157,9 +157,9 @@ public function crop($destinationFolder, Registry $options) // Resize to general size. $width = $options->get('width', 200); - $width = ($width < 50) ? 50 : $width; + $width = ($width < 25) ? 25 : $width; $height = $options->get('height', 200); - $height = ($height < 50) ? 50 : $height; + $height = ($height < 25) ? 25 : $height; $left = (int)abs($options->get('x', 0)); $top = (int)abs($options->get('y', 0)); $createNew = (bool)$options->get('create_new', Constants::NO); diff --git a/src/Version.php b/src/Version.php index 9dfd389..a5841be 100644 --- a/src/Version.php +++ b/src/Version.php @@ -57,7 +57,7 @@ class Version * * @var string */ - public $releaseDate = '10 September, 2017'; + public $releaseDate = '08 September, 2017'; /** * License diff --git a/src/lib_prism.xml b/src/lib_prism.xml index e7b94ce..8f871f4 100644 --- a/src/lib_prism.xml +++ b/src/lib_prism.xml @@ -10,7 +10,7 @@ ITPrism http://itprism.com 1.20 - 10 September, 2017 + 08 September, 2017 Prism Library is a collection of PHP classes used in many ITPrism extensions.

Subscribe for the newsletter to receive information about updates and new ITPrism extensions.

diff --git a/src/ui/cropper/cropper.min.css b/src/ui/cropper/cropper.min.css index 9426dac..cc4fa28 100644 --- a/src/ui/cropper/cropper.min.css +++ b/src/ui/cropper/cropper.min.css @@ -1,9 +1,11 @@ /*! - * Cropper v2.3.4 + * Cropper v3.0.0 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2016 Fengyuan Chen and contributors + * Copyright (c) 2017 Fengyuan Chen * Released under the MIT license * - * Date: 2016-09-03T05:50:45.412Z - */.cropper-container{font-size:0;line-height:0;position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;direction:ltr!important}.cropper-container img{display:block;width:100%;min-width:0!important;max-width:none!important;height:100%;min-height:0!important;max-height:none!important;image-orientation:0deg!important}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{position:absolute;top:0;right:0;bottom:0;left:0}.cropper-wrap-box{overflow:hidden}.cropper-drag-box{opacity:0;background-color:#fff;filter:alpha(opacity=0)}.cropper-dashed,.cropper-modal{opacity:.5;filter:alpha(opacity=50)}.cropper-modal{background-color:#000}.cropper-view-box{display:block;overflow:hidden;width:100%;height:100%;outline:#39f solid 1px;outline-color:rgba(51,153,255,.75)}.cropper-dashed{position:absolute;display:block;border:0 dashed #eee}.cropper-dashed.dashed-h{top:33.33333%;left:0;width:100%;height:33.33333%;border-top-width:1px;border-bottom-width:1px}.cropper-dashed.dashed-v{top:0;left:33.33333%;width:33.33333%;height:100%;border-right-width:1px;border-left-width:1px}.cropper-center{position:absolute;top:50%;left:50%;display:block;width:0;height:0;opacity:.75;filter:alpha(opacity=75)}.cropper-center:after,.cropper-center:before{position:absolute;display:block;content:' ';background-color:#eee}.cropper-center:before{top:0;left:-3px;width:7px;height:1px}.cropper-center:after{top:-3px;left:0;width:1px;height:7px}.cropper-face,.cropper-line,.cropper-point{position:absolute;display:block;width:100%;height:100%;opacity:.1;filter:alpha(opacity=10)}.cropper-face{top:0;left:0;background-color:#fff}.cropper-line,.cropper-point{background-color:#39f}.cropper-line.line-e{top:0;right:-3px;width:5px;cursor:e-resize}.cropper-line.line-n{top:-3px;left:0;height:5px;cursor:n-resize}.cropper-line.line-w{top:0;left:-3px;width:5px;cursor:w-resize}.cropper-line.line-s{bottom:-3px;left:0;height:5px;cursor:s-resize}.cropper-point{width:5px;height:5px;opacity:.75;filter:alpha(opacity=75)}.cropper-point.point-e{top:50%;right:-3px;margin-top:-3px;cursor:e-resize}.cropper-point.point-n{top:-3px;left:50%;margin-left:-3px;cursor:n-resize}.cropper-point.point-w{top:50%;left:-3px;margin-top:-3px;cursor:w-resize}.cropper-point.point-s{bottom:-3px;left:50%;margin-left:-3px;cursor:s-resize}.cropper-point.point-ne{top:-3px;right:-3px;cursor:ne-resize}.cropper-point.point-nw{top:-3px;left:-3px;cursor:nw-resize}.cropper-point.point-sw{bottom:-3px;left:-3px;cursor:sw-resize}.cropper-point.point-se{right:-3px;bottom:-3px;width:20px;height:20px;cursor:se-resize;opacity:1;filter:alpha(opacity=100)}.cropper-point.point-se:before{position:absolute;right:-50%;bottom:-50%;display:block;width:200%;height:200%;content:' ';opacity:0;background-color:#39f;filter:alpha(opacity=0)}@media (min-width:768px){.cropper-point.point-se{width:15px;height:15px}}@media (min-width:992px){.cropper-point.point-se{width:10px;height:10px}}@media (min-width:1200px){.cropper-point.point-se{width:5px;height:5px;opacity:.75;filter:alpha(opacity=75)}}.cropper-invisible{opacity:0;filter:alpha(opacity=0)}.cropper-bg{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC)}.cropper-hide{position:absolute;display:block;width:0;height:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed} \ No newline at end of file + * Date: 2017-09-03T13:13:53.439Z + */ + +.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-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} \ No newline at end of file diff --git a/src/ui/cropper/cropper.min.js b/src/ui/cropper/cropper.min.js index d285e2c..58b32b7 100644 --- a/src/ui/cropper/cropper.min.js +++ b/src/ui/cropper/cropper.min.js @@ -1,10 +1,11 @@ /*! - * Cropper v2.3.4 + * Cropper v3.0.0 * https://github.com/fengyuanchen/cropper * - * Copyright (c) 2014-2016 Fengyuan Chen and contributors + * Copyright (c) 2017 Fengyuan Chen * Released under the MIT license * - * Date: 2016-09-03T05:50:45.412Z + * Date: 2017-09-03T13:13:53.439Z */ -!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){"use strict";function i(t){return"number"==typeof t&&!isNaN(t)}function e(t){return"undefined"==typeof t}function s(t,e){var s=[];return i(e)&&s.push(e),s.slice.apply(t,s)}function a(t,i){var e=s(arguments,2);return function(){return t.apply(i,e.concat(s(arguments)))}}function o(t){var i=t.match(/^(https?:)\/\/([^\:\/\?#]+):?(\d*)/i);return i&&(i[1]!==C.protocol||i[2]!==C.hostname||i[3]!==C.port)}function h(t){var i="timestamp="+(new Date).getTime();return t+(t.indexOf("?")===-1?"?":"&")+i}function n(t){return t?' crossOrigin="'+t+'"':""}function r(t,i){var e;return t.naturalWidth&&!mt?i(t.naturalWidth,t.naturalHeight):(e=document.createElement("img"),e.onload=function(){i(this.width,this.height)},void(e.src=t.src))}function p(t){var e=[],s=t.rotate,a=t.scaleX,o=t.scaleY;return i(s)&&0!==s&&e.push("rotate("+s+"deg)"),i(a)&&1!==a&&e.push("scaleX("+a+")"),i(o)&&1!==o&&e.push("scaleY("+o+")"),e.length?e.join(" "):"none"}function l(t,i){var e,s,a=Ct(t.degree)%180,o=(a>90?180-a:a)*Math.PI/180,h=bt(o),n=Bt(o),r=t.width,p=t.height,l=t.aspectRatio;return i?(e=r/(n+h/l),s=e/l):(e=r*n+p*h,s=r*h+p*n),{width:e,height:s}}function c(e,s){var a,o,h,n=t("")[0],r=n.getContext("2d"),p=0,c=0,d=s.naturalWidth,g=s.naturalHeight,u=s.rotate,f=s.scaleX,m=s.scaleY,v=i(f)&&i(m)&&(1!==f||1!==m),w=i(u)&&0!==u,x=w||v,C=d*Ct(f||1),b=g*Ct(m||1);return v&&(a=C/2,o=b/2),w&&(h=l({width:C,height:b,degree:u}),C=h.width,b=h.height,a=C/2,o=b/2),n.width=C,n.height=b,x&&(p=-d/2,c=-g/2,r.save(),r.translate(a,o)),w&&r.rotate(u*Math.PI/180),v&&r.scale(f,m),r.drawImage(e,$t(p),$t(c),$t(d),$t(g)),x&&r.restore(),n}function d(i){var e=i.length,s=0,a=0;return e&&(t.each(i,function(t,i){s+=i.pageX,a+=i.pageY}),s/=e,a/=e),{pageX:s,pageY:a}}function g(t,i,e){var s,a="";for(s=i,e+=i;s=8&&(r=s+a)))),r)for(d=c.getUint16(r,o),l=0;l")[0].getContext),mt=b&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(b.userAgent),vt=Number,wt=Math.min,xt=Math.max,Ct=Math.abs,bt=Math.sin,Bt=Math.cos,yt=Math.sqrt,Dt=Math.round,$t=Math.floor,Lt=String.fromCharCode;v.prototype={constructor:v,init:function(){var t,i=this.$element;if(i.is("img")){if(this.isImg=!0,this.originalUrl=t=i.attr("src"),!t)return;t=i.prop("src")}else i.is("canvas")&&ft&&(t=i[0].toDataURL());this.load(t)},trigger:function(i,e){var s=t.Event(i,e);return this.$element.trigger(s),s},load:function(i){var e,s,a=this.options,n=this.$element;if(i&&(n.one(A,a.build),!this.trigger(A).isDefaultPrevented())){if(this.url=i,this.image={},!a.checkOrientation||!B)return this.clone();if(e=t.proxy(this.read,this),V.test(i))return J.test(i)?e(f(i)):this.clone();s=new XMLHttpRequest,s.onerror=s.onabort=t.proxy(function(){this.clone()},this),s.onload=function(){e(this.response)},a.checkCrossOrigin&&o(i)&&n.prop("crossOrigin")&&(i=h(i)),s.open("get",i),s.responseType="arraybuffer",s.send()}},read:function(t){var i=this.options,e=u(t),s=this.image,a=0,o=1,h=1;if(e>1)switch(this.url=m(t),e){case 2:o=-1;break;case 3:a=-180;break;case 4:h=-1;break;case 5:a=90,h=-1;break;case 6:a=90;break;case 7:a=90,o=-1;break;case 8:a=-90}i.rotatable&&(s.rotate=a),i.scalable&&(s.scaleX=o,s.scaleY=h),this.clone()},clone:function(){var i,e,s=this.options,a=this.$element,r=this.url,p="";s.checkCrossOrigin&&o(r)&&(p=a.prop("crossOrigin"),p?i=r:(p="anonymous",i=h(r))),this.crossOrigin=p,this.crossOriginUrl=i,this.$clone=e=t("'),this.isImg?a[0].complete?this.start():a.one(I,t.proxy(this.start,this)):e.one(I,t.proxy(this.start,this)).one(F,t.proxy(this.stop,this)).addClass(X).insertAfter(a)},start:function(){var i=this.$element,e=this.$clone;this.isImg||(e.off(F,this.stop),i=e),r(i[0],t.proxy(function(i,e){t.extend(this.image,{naturalWidth:i,naturalHeight:e,aspectRatio:i/e}),this.isLoaded=!0,this.build()},this))},stop:function(){this.$clone.remove(),this.$clone=null},build:function(){var i,e,s,a=this.options,o=this.$element,h=this.$clone;this.isLoaded&&(this.isBuilt&&this.unbuild(),this.$container=o.parent(),this.$cropper=i=t(v.TEMPLATE),this.$canvas=i.find(".cropper-canvas").append(h),this.$dragBox=i.find(".cropper-drag-box"),this.$cropBox=e=i.find(".cropper-crop-box"),this.$viewBox=i.find(".cropper-view-box"),this.$face=s=e.find(".cropper-face"),o.addClass(Y).after(i),this.isImg||h.removeClass(X),this.initPreview(),this.bind(),a.aspectRatio=xt(0,a.aspectRatio)||NaN,a.viewMode=xt(0,wt(3,Dt(a.viewMode)))||0,a.autoCrop?(this.isCropped=!0,a.modal&&this.$dragBox.addClass(T)):e.addClass(Y),a.guides||e.find(".cropper-dashed").addClass(Y),a.center||e.find(".cropper-center").addClass(Y),a.cropBoxMovable&&s.addClass(M).data(it,lt),a.highlight||s.addClass(k),a.background&&i.addClass(R),a.cropBoxResizable||e.find(".cropper-line, .cropper-point").addClass(Y),this.setDragMode(a.dragMode),this.render(),this.isBuilt=!0,this.setData(a.data),o.one(S,a.built),this.completing=setTimeout(t.proxy(function(){this.trigger(S),this.trigger(K,this.getData()),this.isCompleted=!0},this),0))},unbuild:function(){this.isBuilt&&(this.isCompleted||clearTimeout(this.completing),this.isBuilt=!1,this.isCompleted=!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)},render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.isCropped&&this.renderCropBox()},initContainer:function(){var t=this.options,i=this.$element,e=this.$container,s=this.$cropper;s.addClass(Y),i.removeClass(Y),s.css(this.container={width:xt(e.width(),vt(t.minContainerWidth)||200),height:xt(e.height(),vt(t.minContainerHeight)||100)}),i.addClass(Y),s.removeClass(Y)},initCanvas:function(){var i,e=this.options.viewMode,s=this.container,a=s.width,o=s.height,h=this.image,n=h.naturalWidth,r=h.naturalHeight,p=90===Ct(h.rotate),l=p?r:n,c=p?n:r,d=l/c,g=a,u=o;o*d>a?3===e?g=o*d:u=a/d:3===e?u=a/d:g=o*d,i={naturalWidth:l,naturalHeight:c,aspectRatio:d,width:g,height:u},i.oldLeft=i.left=(a-g)/2,i.oldTop=i.top=(o-u)/2,this.canvas=i,this.isLimited=1===e||2===e,this.limitCanvas(!0,!0),this.initialImage=t.extend({},h),this.initialCanvas=t.extend({},i)},limitCanvas:function(t,i){var e,s,a,o,h=this.options,n=h.viewMode,r=this.container,p=r.width,l=r.height,c=this.canvas,d=c.aspectRatio,g=this.cropBox,u=this.isCropped&&g;t&&(e=vt(h.minCanvasWidth)||0,s=vt(h.minCanvasHeight)||0,n&&(n>1?(e=xt(e,p),s=xt(s,l),3===n&&(s*d>e?e=s*d:s=e/d)):e?e=xt(e,u?g.width:0):s?s=xt(s,u?g.height:0):u&&(e=g.width,s=g.height,s*d>e?e=s*d:s=e/d)),e&&s?s*d>e?s=e/d:e=s*d:e?s=e/d:s&&(e=s*d),c.minWidth=e,c.minHeight=s,c.maxWidth=1/0,c.maxHeight=1/0),i&&(n?(a=p-c.width,o=l-c.height,c.minLeft=wt(0,a),c.minTop=wt(0,o),c.maxLeft=xt(0,a),c.maxTop=xt(0,o),u&&this.isLimited&&(c.minLeft=wt(g.left,g.left+g.width-c.width),c.minTop=wt(g.top,g.top+g.height-c.height),c.maxLeft=g.left,c.maxTop=g.top,2===n&&(c.width>=p&&(c.minLeft=wt(0,a),c.maxLeft=xt(0,a)),c.height>=l&&(c.minTop=wt(0,o),c.maxTop=xt(0,o))))):(c.minLeft=-c.width,c.minTop=-c.height,c.maxLeft=p,c.maxTop=l))},renderCanvas:function(t){var i,e,s=this.canvas,a=this.image,o=a.rotate,h=a.naturalWidth,n=a.naturalHeight;this.isRotated&&(this.isRotated=!1,e=l({width:a.width,height:a.height,degree:o}),i=e.width/e.height,i!==s.aspectRatio&&(s.left-=(e.width-s.width)/2,s.top-=(e.height-s.height)/2,s.width=e.width,s.height=e.height,s.aspectRatio=i,s.naturalWidth=h,s.naturalHeight=n,o%180&&(e=l({width:h,height:n,degree:o}),s.naturalWidth=e.width,s.naturalHeight=e.height),this.limitCanvas(!0,!1))),(s.width>s.maxWidth||s.widths.maxHeight||s.heighte.width?o.height=o.width/s:o.width=o.height*s),this.cropBox=o,this.limitCropBox(!0,!0),o.width=wt(xt(o.width,o.minWidth),o.maxWidth),o.height=wt(xt(o.height,o.minHeight),o.maxHeight),o.width=xt(o.minWidth,o.width*a),o.height=xt(o.minHeight,o.height*a),o.oldLeft=o.left=e.left+(e.width-o.width)/2,o.oldTop=o.top=e.top+(e.height-o.height)/2,this.initialCropBox=t.extend({},o)},limitCropBox:function(t,i){var e,s,a,o,h=this.options,n=h.aspectRatio,r=this.container,p=r.width,l=r.height,c=this.canvas,d=this.cropBox,g=this.isLimited;t&&(e=vt(h.minCropBoxWidth)||0,s=vt(h.minCropBoxHeight)||0,e=wt(e,p),s=wt(s,l),a=wt(p,g?c.width:p),o=wt(l,g?c.height:l),n&&(e&&s?s*n>e?s=e/n:e=s*n:e?s=e/n:s&&(e=s*n),o*n>a?o=a/n:a=o*n),d.minWidth=wt(e,a),d.minHeight=wt(s,o),d.maxWidth=a,d.maxHeight=o),i&&(g?(d.minLeft=xt(0,c.left),d.minTop=xt(0,c.top),d.maxLeft=wt(p,c.left+c.width)-d.width,d.maxTop=wt(l,c.top+c.height)-d.height):(d.minLeft=0,d.minTop=0,d.maxLeft=p-d.width,d.maxTop=l-d.height))},renderCropBox:function(){var t=this.options,i=this.container,e=i.width,s=i.height,a=this.cropBox;(a.width>a.maxWidth||a.widtha.maxHeight||a.height'),this.$viewBox.html(i),this.$preview.each(function(){var i=t(this);i.data(tt,{width:i.width(),height:i.height(),html:i.html()}),i.html("')})},resetPreview:function(){this.$preview.each(function(){var i=t(this),e=i.data(tt);i.css({width:e.width,height:e.height}).html(e.html).removeData(tt)})},preview:function(){var i=this.image,e=this.canvas,s=this.cropBox,a=s.width,o=s.height,h=i.width,n=i.height,r=s.left-e.left-i.left,l=s.top-e.top-i.top;this.isCropped&&!this.isDisabled&&(this.$clone2.css({width:h,height:n,marginLeft:-r,marginTop:-l,transform:p(i)}),this.$preview.each(function(){var e=t(this),s=e.data(tt),c=s.width,d=s.height,g=c,u=d,f=1;a&&(f=c/a,u=o*f),o&&u>d&&(f=d/o,g=a*f,u=d),e.css({width:g,height:u}).find("img").css({width:h*f,height:n*f,marginLeft:-r*f,marginTop:-l*f,transform:p(i)})}))},bind:function(){var i=this.options,e=this.$element,s=this.$cropper;t.isFunction(i.cropstart)&&e.on(N,i.cropstart),t.isFunction(i.cropmove)&&e.on(_,i.cropmove),t.isFunction(i.cropend)&&e.on(q,i.cropend),t.isFunction(i.crop)&&e.on(K,i.crop),t.isFunction(i.zoom)&&e.on(Z,i.zoom),s.on(z,t.proxy(this.cropStart,this)),i.zoomable&&i.zoomOnWheel&&s.on(E,t.proxy(this.wheel,this)),i.toggleDragModeOnDblclick&&s.on(U,t.proxy(this.dblclick,this)),x.on(O,this._cropMove=a(this.cropMove,this)).on(P,this._cropEnd=a(this.cropEnd,this)),i.responsive&&w.on(j,this._resize=a(this.resize,this))},unbind:function(){var i=this.options,e=this.$element,s=this.$cropper;t.isFunction(i.cropstart)&&e.off(N,i.cropstart),t.isFunction(i.cropmove)&&e.off(_,i.cropmove),t.isFunction(i.cropend)&&e.off(q,i.cropend),t.isFunction(i.crop)&&e.off(K,i.crop),t.isFunction(i.zoom)&&e.off(Z,i.zoom),s.off(z,this.cropStart),i.zoomable&&i.zoomOnWheel&&s.off(E,this.wheel),i.toggleDragModeOnDblclick&&s.off(U,this.dblclick),x.off(O,this._cropMove).off(P,this._cropEnd),i.responsive&&w.off(j,this._resize)},resize:function(){var i,e,s,a=this.options.restore,o=this.$container,h=this.container;!this.isDisabled&&h&&(s=o.width()/h.width,1===s&&o.height()===h.height||(a&&(i=this.getCanvasData(),e=this.getCropBoxData()),this.render(),a&&(this.setCanvasData(t.each(i,function(t,e){i[t]=e*s})),this.setCropBoxData(t.each(e,function(t,i){e[t]=i*s})))))},dblclick:function(){this.isDisabled||(this.$dragBox.hasClass(W)?this.setDragMode(dt):this.setDragMode(ct))},wheel:function(i){var e=i.originalEvent||i,s=vt(this.options.wheelZoomRatio)||.1,a=1;this.isDisabled||(i.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(t.proxy(function(){this.wheeling=!1},this),50),e.deltaY?a=e.deltaY>0?1:-1:e.wheelDelta?a=-e.wheelDelta/120:e.detail&&(a=e.detail>0?1:-1),this.zoom(-a*s,i)))},cropStart:function(i){var e,s,a=this.options,o=i.originalEvent,h=o&&o.touches,n=i;if(!this.isDisabled){if(h){if(e=h.length,e>1){if(!a.zoomable||!a.zoomOnTouch||2!==e)return;n=h[1],this.startX2=n.pageX,this.startY2=n.pageY,s=gt}n=h[0]}if(s=s||t(n.target).data(it),Q.test(s)){if(this.trigger(N,{originalEvent:o,action:s}).isDefaultPrevented())return;i.preventDefault(),this.action=s,this.cropping=!1,this.startX=n.pageX||o&&o.pageX,this.startY=n.pageY||o&&o.pageY,s===ct&&(this.cropping=!0,this.$dragBox.addClass(T))}}},cropMove:function(t){var i,e=this.options,s=t.originalEvent,a=s&&s.touches,o=t,h=this.action;if(!this.isDisabled){if(a){if(i=a.length,i>1){if(!e.zoomable||!e.zoomOnTouch||2!==i)return;o=a[1],this.endX2=o.pageX,this.endY2=o.pageY}o=a[0]}if(h){if(this.trigger(_,{originalEvent:s,action:h}).isDefaultPrevented())return;t.preventDefault(),this.endX=o.pageX||s&&s.pageX,this.endY=o.pageY||s&&s.pageY,this.change(o.shiftKey,h===gt?t:null)}}},cropEnd:function(t){var i=t.originalEvent,e=this.action;this.isDisabled||e&&(t.preventDefault(),this.cropping&&(this.cropping=!1,this.$dragBox.toggleClass(T,this.isCropped&&this.options.modal)),this.action="",this.trigger(q,{originalEvent:i,action:e}))},change:function(t,i){var e,s,a=this.options,o=a.aspectRatio,h=this.action,n=this.container,r=this.canvas,p=this.cropBox,l=p.width,c=p.height,d=p.left,g=p.top,u=d+l,f=g+c,m=0,v=0,w=n.width,x=n.height,C=!0;switch(!o&&t&&(o=l&&c?l/c:1),this.isLimited&&(m=p.minLeft,v=p.minTop,w=m+wt(n.width,r.width,r.left+r.width),x=v+wt(n.height,r.height,r.top+r.height)),s={x:this.endX-this.startX,y:this.endY-this.startY},o&&(s.X=s.y*o,s.Y=s.x/o),h){case lt:d+=s.x,g+=s.y;break;case et:if(s.x>=0&&(u>=w||o&&(g<=v||f>=x))){C=!1;break}l+=s.x,o&&(c=l/o,g-=s.Y/2),l<0&&(h=st,l=0);break;case ot:if(s.y<=0&&(g<=v||o&&(d<=m||u>=w))){C=!1;break}c-=s.y,g+=s.y,o&&(l=c*o,d+=s.X/2),c<0&&(h=at,c=0);break;case st:if(s.x<=0&&(d<=m||o&&(g<=v||f>=x))){C=!1;break}l-=s.x,d+=s.x,o&&(c=l/o,g+=s.Y/2),l<0&&(h=et,l=0);break;case at:if(s.y>=0&&(f>=x||o&&(d<=m||u>=w))){C=!1;break}c+=s.y,o&&(l=c*o,d-=s.X/2),c<0&&(h=ot,c=0);break;case rt:if(o){if(s.y<=0&&(g<=v||u>=w)){C=!1;break}c-=s.y,g+=s.y,l=c*o}else s.x>=0?uv&&(c-=s.y,g+=s.y):(c-=s.y,g+=s.y);l<0&&c<0?(h=nt,c=0,l=0):l<0?(h=pt,l=0):c<0&&(h=ht,c=0);break;case pt:if(o){if(s.y<=0&&(g<=v||d<=m)){C=!1;break}c-=s.y,g+=s.y,l=c*o,d+=s.X}else s.x<=0?d>m?(l-=s.x,d+=s.x):s.y<=0&&g<=v&&(C=!1):(l-=s.x,d+=s.x),s.y<=0?g>v&&(c-=s.y,g+=s.y):(c-=s.y,g+=s.y);l<0&&c<0?(h=ht,c=0,l=0):l<0?(h=rt,l=0):c<0&&(h=nt,c=0);break;case nt:if(o){if(s.x<=0&&(d<=m||f>=x)){C=!1;break}l-=s.x,d+=s.x,c=l/o}else s.x<=0?d>m?(l-=s.x,d+=s.x):s.y>=0&&f>=x&&(C=!1):(l-=s.x,d+=s.x),s.y>=0?f=0&&(u>=w||f>=x)){C=!1;break}l+=s.x,c=l/o}else s.x>=0?u=0&&f>=x&&(C=!1):l+=s.x,s.y>=0?f0?h=s.y>0?ht:rt:s.x<0&&(d-=l,h=s.y>0?nt:pt),s.y<0&&(g-=c),this.isCropped||(this.$cropBox.removeClass(Y),this.isCropped=!0,this.isLimited&&this.limitCropBox(!0,!0))}C&&(p.width=l,p.height=c,p.left=d,p.top=g,this.action=h,this.renderCropBox()),this.startX=this.endX,this.startY=this.endY},crop:function(){this.isBuilt&&!this.isDisabled&&(this.isCropped||(this.isCropped=!0,this.limitCropBox(!0,!0),this.options.modal&&this.$dragBox.addClass(T),this.$cropBox.removeClass(Y)),this.setCropBoxData(this.initialCropBox))},reset:function(){this.isBuilt&&!this.isDisabled&&(this.image=t.extend({},this.initialImage),this.canvas=t.extend({},this.initialCanvas),this.cropBox=t.extend({},this.initialCropBox),this.renderCanvas(),this.isCropped&&this.renderCropBox())},clear:function(){this.isCropped&&!this.isDisabled&&(t.extend(this.cropBox,{left:0,top:0,width:0,height:0}),this.isCropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),this.$dragBox.removeClass(T),this.$cropBox.addClass(Y))},replace:function(t,i){!this.isDisabled&&t&&(this.isImg&&this.$element.attr("src",t),i?(this.url=t,this.$clone.attr("src",t),this.isBuilt&&this.$preview.find("img").add(this.$clone2).attr("src",t)):(this.isImg&&(this.isReplaced=!0),this.options.data=null,this.load(t)))},enable:function(){this.isBuilt&&(this.isDisabled=!1,this.$cropper.removeClass(H))},disable:function(){this.isBuilt&&(this.isDisabled=!0,this.$cropper.addClass(H))},destroy:function(){var t=this.$element;this.isLoaded?(this.isImg&&this.isReplaced&&t.attr("src",this.originalUrl),this.unbuild(),t.removeClass(Y)):this.isImg?t.off(I,this.start):this.$clone&&this.$clone.remove(),t.removeData(L)},move:function(t,i){var s=this.canvas;this.moveTo(e(t)?t:s.left+vt(t),e(i)?i:s.top+vt(i))},moveTo:function(t,s){var a=this.canvas,o=!1;e(s)&&(s=t),t=vt(t),s=vt(s),this.isBuilt&&!this.isDisabled&&this.options.movable&&(i(t)&&(a.left=t,o=!0),i(s)&&(a.top=s,o=!0),o&&this.renderCanvas(!0))},zoom:function(t,i){var e=this.canvas;t=vt(t),t=t<0?1/(1-t):1+t,this.zoomTo(e.width*t/e.naturalWidth,i)},zoomTo:function(t,i){var e,s,a,o,h,n=this.options,r=this.canvas,p=r.width,l=r.height,c=r.naturalWidth,g=r.naturalHeight;if(t=vt(t),t>=0&&this.isBuilt&&!this.isDisabled&&n.zoomable){if(s=c*t,a=g*t,i&&(e=i.originalEvent),this.trigger(Z,{originalEvent:e,oldRatio:p/c,ratio:s/c}).isDefaultPrevented())return;e?(o=this.$cropper.offset(),h=e.touches?d(e.touches):{pageX:i.pageX||e.pageX||0,pageY:i.pageY||e.pageY||0},r.left-=(s-p)*((h.pageX-o.left-r.left)/p),r.top-=(a-l)*((h.pageY-o.top-r.top)/l)):(r.left-=(s-p)/2,r.top-=(a-l)/2),r.width=s,r.height=a,this.renderCanvas(!0)}},rotate:function(t){this.rotateTo((this.image.rotate||0)+vt(t))},rotateTo:function(t){t=vt(t),i(t)&&this.isBuilt&&!this.isDisabled&&this.options.rotatable&&(this.image.rotate=t%360,this.isRotated=!0,this.renderCanvas(!0))},scale:function(t,s){var a=this.image,o=!1;e(s)&&(s=t),t=vt(t),s=vt(s),this.isBuilt&&!this.isDisabled&&this.options.scalable&&(i(t)&&(a.scaleX=t,o=!0),i(s)&&(a.scaleY=s,o=!0),o&&this.renderImage(!0))},scaleX:function(t){var e=this.image.scaleY;this.scale(t,i(e)?e:1)},scaleY:function(t){var e=this.image.scaleX;this.scale(i(e)?e:1,t)},getData:function(i){var e,s,a=this.options,o=this.image,h=this.canvas,n=this.cropBox;return this.isBuilt&&this.isCropped?(s={x:n.left-h.left,y:n.top-h.top,width:n.width,height:n.height},e=o.width/o.naturalWidth,t.each(s,function(t,a){a/=e,s[t]=i?Dt(a):a})):s={x:0,y:0,width:0,height:0},a.rotatable&&(s.rotate=o.rotate||0),a.scalable&&(s.scaleX=o.scaleX||1,s.scaleY=o.scaleY||1),s},setData:function(e){var s,a,o,h=this.options,n=this.image,r=this.canvas,p={};t.isFunction(e)&&(e=e.call(this.element)),this.isBuilt&&!this.isDisabled&&t.isPlainObject(e)&&(h.rotatable&&i(e.rotate)&&e.rotate!==n.rotate&&(n.rotate=e.rotate,this.isRotated=s=!0),h.scalable&&(i(e.scaleX)&&e.scaleX!==n.scaleX&&(n.scaleX=e.scaleX,a=!0),i(e.scaleY)&&e.scaleY!==n.scaleY&&(n.scaleY=e.scaleY,a=!0)),s?this.renderCanvas():a&&this.renderImage(),o=n.width/n.naturalWidth,i(e.x)&&(p.left=e.x*o+r.left),i(e.y)&&(p.top=e.y*o+r.top),i(e.width)&&(p.width=e.width*o),i(e.height)&&(p.height=e.height*o),this.setCropBoxData(p))},getContainerData:function(){return this.isBuilt?this.container:{}},getImageData:function(){return this.isLoaded?this.image:{}},getCanvasData:function(){var i=this.canvas,e={};return this.isBuilt&&t.each(["left","top","width","height","naturalWidth","naturalHeight"],function(t,s){e[s]=i[s]}),e},setCanvasData:function(e){var s=this.canvas,a=s.aspectRatio;t.isFunction(e)&&(e=e.call(this.$element)),this.isBuilt&&!this.isDisabled&&t.isPlainObject(e)&&(i(e.left)&&(s.left=e.left),i(e.top)&&(s.top=e.top),i(e.width)?(s.width=e.width,s.height=e.width/a):i(e.height)&&(s.height=e.height,s.width=e.height*a),this.renderCanvas(!0))},getCropBoxData:function(){var t,i=this.cropBox;return this.isBuilt&&this.isCropped&&(t={left:i.left,top:i.top,width:i.width,height:i.height}),t||{}},setCropBoxData:function(e){var s,a,o=this.cropBox,h=this.options.aspectRatio;t.isFunction(e)&&(e=e.call(this.$element)),this.isBuilt&&this.isCropped&&!this.isDisabled&&t.isPlainObject(e)&&(i(e.left)&&(o.left=e.left),i(e.top)&&(o.top=e.top),i(e.width)&&(s=!0,o.width=e.width),i(e.height)&&(a=!0,o.height=e.height),h&&(s?o.height=o.width/h:a&&(o.width=o.height*h)),this.renderCropBox())},getCroppedCanvas:function(i){var e,s,a,o,h,n,r,p,l,d,g;if(this.isBuilt&&ft)return this.isCropped?(t.isPlainObject(i)||(i={}),g=this.getData(),e=g.width,s=g.height,p=e/s,t.isPlainObject(i)&&(h=i.width,n=i.height,h?(n=h/p,r=h/e):n&&(h=n*p,r=n/s)),a=$t(h||e),o=$t(n||s),l=t("")[0],l.width=a,l.height=o,d=l.getContext("2d"),i.fillColor&&(d.fillStyle=i.fillColor,d.fillRect(0,0,a,o)),d.drawImage.apply(d,function(){var t,i,a,o,h,n,p=c(this.$clone[0],this.image),l=p.width,d=p.height,u=this.canvas,f=[p],m=g.x+u.naturalWidth*(Ct(g.scaleX||1)-1)/2,v=g.y+u.naturalHeight*(Ct(g.scaleY||1)-1)/2;return m<=-e||m>l?m=t=a=h=0:m<=0?(a=-m,m=0,t=h=wt(l,e+m)):m<=l&&(a=0,t=h=wt(e,l-m)),t<=0||v<=-s||v>d?v=i=o=n=0:v<=0?(o=-v,v=0,i=n=wt(d,s+v)):v<=d&&(o=0,i=n=wt(s,d-v)),f.push($t(m),$t(v),$t(t),$t(i)),r&&(a*=r,o*=r,h*=r,n*=r),h>0&&n>0&&f.push($t(a),$t(o),$t(h),$t(n)),f}.call(this)),l):c(this.$clone[0],this.image)},setAspectRatio:function(t){var i=this.options;this.isDisabled||e(t)||(i.aspectRatio=xt(0,t)||NaN,this.isBuilt&&(this.initCropBox(),this.isCropped&&this.renderCropBox()))},setDragMode:function(t){var i,e,s=this.options;this.isLoaded&&!this.isDisabled&&(i=t===ct,e=s.movable&&t===dt,t=i||e?t:ut,this.$dragBox.data(it,t).toggleClass(W,i).toggleClass(M,e),s.cropBoxMovable||this.$face.data(it,t).toggleClass(W,i).toggleClass(M,e))}},v.DEFAULTS={viewMode:0,dragMode:"crop",aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,build:null,built:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},v.setDefaults=function(i){t.extend(v.DEFAULTS,i)},v.TEMPLATE='
',v.other=t.fn.cropper,t.fn.cropper=function(i){var a,o=s(arguments,1);return this.each(function(){var e,s,h=t(this),n=h.data(L);if(!n){if(/destroy/.test(i))return;e=t.extend({},h.data(),t.isPlainObject(i)&&i),h.data(L,n=new v(this,e))}"string"==typeof i&&t.isFunction(s=n[i])&&(a=s.apply(n,o))}),e(a)?this:a},t.fn.cropper.Constructor=v,t.fn.cropper.setDefaults=v.setDefaults,t.fn.cropper.noConflict=function(){return t.fn.cropper=v.other,this}}); \ No newline at end of file + +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):e(t.jQuery)}(this,function(t){"use strict";function e(t){return"number"==typeof t&&!isNaN(t)}function i(t){return void 0===t}function a(t,i){var a=[];return e(i)&&a.push(i),a.slice.apply(t,a)}function o(t,e){for(var i=arguments.length,o=Array(i>2?i-2:0),n=2;n90?180-i:i)*Math.PI/180,o=Math.sin(a),n=Math.cos(a),r=t.width,h=t.height,s=t.aspectRatio,d=void 0,c=void 0;return e?c=(d=r/(n+o/s))/s:(d=r*n+h*o,c=r*o+h*n),{width:d,height:c}}function l(i,a,o){var n=t("")[0],r=n.getContext("2d"),h=0,s=0,d=a.naturalWidth,l=a.naturalHeight,p=a.rotate,m=a.scaleX,g=a.scaleY,f=e(m)&&e(g)&&(1!==m||1!==g),u=e(p)&&0!==p,v=u||f,w=d*Math.abs(m||1),x=l*Math.abs(g||1),b=void 0,y=void 0,C=void 0;return f&&(b=w/2,y=x/2),u&&(b=(w=(C=c({width:w,height:x,degree:p})).width)/2,y=(x=C.height)/2),n.width=w,n.height=x,o.fillColor&&(r.fillStyle=o.fillColor,r.fillRect(0,0,w,x)),v&&(h=-d/2,s=-l/2,r.save(),r.translate(b,y)),u&&r.rotate(p*Math.PI/180),f&&r.scale(m,g),r.imageSmoothingEnabled=!!o.imageSmoothingEnabled,o.imageSmoothingQuality&&(r.imageSmoothingQuality=o.imageSmoothingQuality),r.drawImage(i,Math.floor(h),Math.floor(s),Math.floor(d),Math.floor(l)),v&&r.restore(),n}function p(t,e,i){var a="",o=void 0;for(o=e,i+=e;o=8&&(d=o+n)),d)for(i=e.getUint16(d,r),l=0;lo?3===i?m=n*p:g=o/p:3===i?g=o/p:m=n*p;var f={naturalWidth:c,naturalHeight:l,aspectRatio:p,width:m,height:g};f.left=(o-m)/2,f.top=(n-g)/2,f.oldLeft=f.left,f.oldTop=f.top,e.canvas=f,e.limited=1===i||2===i,e.limitCanvas(!0,!0),e.initialImage=t.extend({},r),e.initialCanvas=t.extend({},f)},limitCanvas:function(t,e){var i=this,a=i.options,o=a.viewMode,n=i.container,r=n.width,h=n.height,s=i.canvas,d=s.aspectRatio,c=i.cropBox,l=i.cropped&&c;if(t){var p=Number(a.minCanvasWidth)||0,m=Number(a.minCanvasHeight)||0;o&&(o>1?(p=Math.max(p,r),m=Math.max(m,h),3===o&&(m*d>p?p=m*d:m=p/d)):p?p=Math.max(p,l?c.width:0):m?m=Math.max(m,l?c.height:0):l&&(p=c.width,(m=c.height)*d>p?p=m*d:m=p/d)),p&&m?m*d>p?m=p/d:p=m*d:p?m=p/d:m&&(p=m*d),s.minWidth=p,s.minHeight=m,s.maxWidth=1/0,s.maxHeight=1/0}if(e)if(o){var g=r-s.width,f=h-s.height;s.minLeft=Math.min(0,g),s.minTop=Math.min(0,f),s.maxLeft=Math.max(0,g),s.maxTop=Math.max(0,f),l&&i.limited&&(s.minLeft=Math.min(c.left,c.left+c.width-s.width),s.minTop=Math.min(c.top,c.top+c.height-s.height),s.maxLeft=c.left,s.maxTop=c.top,2===o&&(s.width>=r&&(s.minLeft=Math.min(0,g),s.maxLeft=Math.max(0,g)),s.height>=h&&(s.minTop=Math.min(0,f),s.maxTop=Math.max(0,f))))}else s.minLeft=-s.width,s.minTop=-s.height,s.maxLeft=r,s.maxTop=h},renderCanvas:function(t){var e=this,i=e.canvas,a=e.image,o=a.rotate,n=a.naturalWidth,r=a.naturalHeight;if(e.rotated){e.rotated=!1;var h=c({width:a.width,height:a.height,degree:o}),s=h.width/h.height,l=1===a.aspectRatio;if(l||s!==i.aspectRatio){if(i.left-=(h.width-i.width)/2,i.top-=(h.height-i.height)/2,i.width=h.width,i.height=h.height,i.aspectRatio=s,i.naturalWidth=n,i.naturalHeight=r,l&&o%90||o%180){var p=c({width:n,height:r,degree:o});i.naturalWidth=p.width,i.naturalHeight=p.height}e.limitCanvas(!0,!1)}}(i.width>i.maxWidth||i.widthi.maxHeight||i.heighta.width?r.height=r.width/o:r.width=r.height*o),e.cropBox=r,e.limitCropBox(!0,!0),r.width=Math.min(Math.max(r.width,r.minWidth),r.maxWidth),r.height=Math.min(Math.max(r.height,r.minHeight),r.maxHeight),r.width=Math.max(r.minWidth,r.width*n),r.height=Math.max(r.minHeight,r.height*n),r.left=a.left+(a.width-r.width)/2,r.top=a.top+(a.height-r.height)/2,r.oldLeft=r.left,r.oldTop=r.top,e.initialCropBox=t.extend({},r)},limitCropBox:function(t,e){var i=this,a=i.options,o=a.aspectRatio,n=i.container,r=n.width,h=n.height,s=i.canvas,d=i.cropBox,c=i.limited;if(t){var l=Number(a.minCropBoxWidth)||0,p=Number(a.minCropBoxHeight)||0,m=Math.min(r,c?s.width:r),g=Math.min(h,c?s.height:h);l=Math.min(l,r),p=Math.min(p,h),o&&(l&&p?p*o>l?p=l/o:l=p*o:l?p=l/o:p&&(l=p*o),g*o>m?g=m/o:m=g*o),d.minWidth=Math.min(l,m),d.minHeight=Math.min(p,g),d.maxWidth=m,d.maxHeight=g}e&&(c?(d.minLeft=Math.max(0,s.left),d.minTop=Math.max(0,s.top),d.maxLeft=Math.min(r,s.left+s.width)-d.width,d.maxTop=Math.min(h,s.top+s.height)-d.height):(d.minLeft=0,d.minTop=0,d.maxLeft=r-d.width,d.maxTop=h-d.height))},renderCropBox:function(){var t=this,e=t.options,i=t.container,a=i.width,o=i.height,n=t.cropBox;(n.width>n.maxWidth||n.widthn.maxHeight||n.heightg&&(f=n*(v=g/r),u=g),o.css({width:f,height:u}).find("img").css({width:h*v,height:s*v,transform:d(t.extend({translateX:-c*v,translateY:-l*v},i))})}))}},W="undefined"!=typeof window?window.PointerEvent:null,Y=W?"pointerdown":"touchstart mousedown",X=W?"pointermove":"touchmove mousemove",H=W?" pointerup pointercancel":"touchend touchcancel mouseup",O={bind:function(){var e=this,i=e.options,a=e.$element,n=e.$cropper;t.isFunction(i.cropstart)&&a.on("cropstart",i.cropstart),t.isFunction(i.cropmove)&&a.on("cropmove",i.cropmove),t.isFunction(i.cropend)&&a.on("cropend",i.cropend),t.isFunction(i.crop)&&a.on("crop",i.crop),t.isFunction(i.zoom)&&a.on("zoom",i.zoom),n.on(Y,o(e.cropStart,this)),i.zoomable&&i.zoomOnWheel&&n.on("wheel mousewheel DOMMouseScroll",o(e.wheel,this)),i.toggleDragModeOnDblclick&&n.on("dblclick",o(e.dblclick,this)),t(document).on(X,e.onCropMove=o(e.cropMove,this)).on(H,e.onCropEnd=o(e.cropEnd,this)),i.responsive&&t(window).on("resize",e.onResize=o(e.resize,this))},unbind:function(){var e=this,i=e.options,a=e.$element,o=e.$cropper;t.isFunction(i.cropstart)&&a.off("cropstart",i.cropstart),t.isFunction(i.cropmove)&&a.off("cropmove",i.cropmove),t.isFunction(i.cropend)&&a.off("cropend",i.cropend),t.isFunction(i.crop)&&a.off("crop",i.crop),t.isFunction(i.zoom)&&a.off("zoom",i.zoom),o.off(Y,e.cropStart),i.zoomable&&i.zoomOnWheel&&o.off("wheel mousewheel DOMMouseScroll",e.wheel),i.toggleDragModeOnDblclick&&o.off("dblclick",e.dblclick),t(document).off(X,e.onCropMove).off(H,e.onCropEnd),i.responsive&&t(window).off("resize",e.onResize)}},z=/^(e|w|s|n|se|sw|ne|nw|all|crop|move|zoom)$/,R={resize:function(){var e=this,i=e.options,a=e.$container,o=e.container,n=Number(i.minContainerWidth)||200,r=Number(i.minContainerHeight)||100;if(!e.disabled&&o.width!==n&&o.height!==r){var h=a.width()/o.width;if(1!==h||a.height()!==o.height){var s=void 0,d=void 0;i.restore&&(s=e.getCanvasData(),d=e.getCropBoxData()),e.render(),i.restore&&(e.setCanvasData(t.each(s,function(t,e){s[t]=e*h})),e.setCropBoxData(t.each(d,function(t,e){d[t]=e*h})))}}},dblclick:function(){var t=this;t.disabled||"none"===t.options.dragMode||t.setDragMode(t.$dragBox.hasClass("cropper-crop")?"move":"crop")},wheel:function(t){var e=this,i=t.originalEvent||t,a=Number(e.options.wheelZoomRatio)||.1;if(!e.disabled&&(t.preventDefault(),!e.wheeling)){e.wheeling=!0,setTimeout(function(){e.wheeling=!1},50);var o=1;i.deltaY?o=i.deltaY>0?1:-1:i.wheelDelta?o=-i.wheelDelta/120:i.detail&&(o=i.detail>0?1:-1),e.zoom(-o*a,t)}},cropStart:function(e){var i=this;if(!i.disabled){var a=i.options,o=i.pointers,r=e.originalEvent,h=void 0;r&&r.changedTouches?t.each(r.changedTouches,function(t,e){o[e.identifier]=u(e)}):o[r&&r.pointerId||0]=u(r||e),h=n(o).length>1&&a.zoomable&&a.zoomOnTouch?"zoom":t(e.target).data("action"),z.test(h)&&(i.trigger("cropstart",{originalEvent:r,action:h}).isDefaultPrevented()||(e.preventDefault(),i.action=h,i.cropping=!1,"crop"===h&&(i.cropping=!0,i.$dragBox.addClass("cropper-modal"))))}},cropMove:function(e){var i=this,a=i.action;if(!i.disabled&&a){var o=i.pointers,n=e.originalEvent;e.preventDefault(),i.trigger("cropmove",{originalEvent:n,action:a}).isDefaultPrevented()||(n&&n.changedTouches?t.each(n.changedTouches,function(e,i){t.extend(o[i.identifier],u(i,!0))}):t.extend(o[n&&n.pointerId||0],u(n||e,!0)),i.change(e))}},cropEnd:function(e){var i=this;if(!i.disabled){var a=i.action,o=i.pointers,r=e.originalEvent;r&&r.changedTouches?t.each(r.changedTouches,function(t,e){delete o[e.identifier]}):delete o[r&&r.pointerId||0],a&&(e.preventDefault(),n(o).length||(i.action=""),i.cropping&&(i.cropping=!1,i.$dragBox.toggleClass("cropper-modal",i.cropped&&i.options.modal)),i.trigger("cropend",{originalEvent:r,action:a}))}}},E={change:function(e){var i=this,a=i.options,o=i.pointers,r=o[n(o)[0]],h=i.container,s=i.canvas,d=i.cropBox,c=i.action,l=a.aspectRatio,p=d.width,m=d.height,g=d.left,f=d.top,u=g+p,w=f+m,x=0,b=0,y=h.width,C=h.height,M=!0,$=void 0;!l&&e.shiftKey&&(l=p&&m?p/m:1),i.limited&&(x=d.minLeft,b=d.minTop,y=x+Math.min(h.width,s.width,s.left+s.width),C=b+Math.min(h.height,s.height,s.top+s.height));var B={x:r.endX-r.startX,y:r.endY-r.startY};switch(c){case"all":g+=B.x,f+=B.y;break;case"e":if(B.x>=0&&(u>=y||l&&(f<=b||w>=C))){M=!1;break}u+B.x>y&&(B.x=y-u),p+=B.x,l&&(m=p/l,f-=B.x/l/2),p<0&&(c="w",p=0);break;case"n":if(B.y<=0&&(f<=b||l&&(g<=x||u>=y))){M=!1;break}f+B.y=C))){M=!1;break}g+B.x=0&&(w>=C||l&&(g<=x||u>=y))){M=!1;break}w+B.y>C&&(B.y=C-w),m+=B.y,l&&(p=m*l,g-=B.y*l/2),m<0&&(c="n",m=0);break;case"ne":if(l){if(B.y<=0&&(f<=b||u>=y)){M=!1;break}m-=B.y,f+=B.y,p=m*l}else B.x>=0?ub&&(m-=B.y,f+=B.y):(m-=B.y,f+=B.y);p<0&&m<0?(c="sw",m=0,p=0):p<0?(c="nw",p=0):m<0&&(c="se",m=0);break;case"nw":if(l){if(B.y<=0&&(f<=b||g<=x)){M=!1;break}m-=B.y,f+=B.y,p=m*l,g+=B.y*l}else B.x<=0?g>x?(p-=B.x,g+=B.x):B.y<=0&&f<=b&&(M=!1):(p-=B.x,g+=B.x),B.y<=0?f>b&&(m-=B.y,f+=B.y):(m-=B.y,f+=B.y);p<0&&m<0?(c="se",m=0,p=0):p<0?(c="ne",p=0):m<0&&(c="sw",m=0);break;case"sw":if(l){if(B.x<=0&&(g<=x||w>=C)){M=!1;break}p-=B.x,g+=B.x,m=p/l}else B.x<=0?g>x?(p-=B.x,g+=B.x):B.y>=0&&w>=C&&(M=!1):(p-=B.x,g+=B.x),B.y>=0?w=0&&(u>=y||w>=C)){M=!1;break}m=(p+=B.x)/l}else B.x>=0?u=0&&w>=C&&(M=!1):p+=B.x,B.y>=0?w0?c=B.y>0?"se":"ne":B.x<0&&(g-=p,c=B.y>0?"sw":"nw"),B.y<0&&(f-=m),i.cropped||(i.$cropBox.removeClass("cropper-hidden"),i.cropped=!0,i.limited&&i.limitCropBox(!0,!0))}M&&(d.width=p,d.height=m,d.left=g,d.top=f,i.action=c,i.renderCropBox()),t.each(o,function(t,e){e.startX=e.endX,e.startY=e.endY})}},L={crop:function(){var t=this;t.ready&&!t.disabled&&(t.cropped||(t.cropped=!0,t.limitCropBox(!0,!0),t.options.modal&&t.$dragBox.addClass("cropper-modal"),t.$cropBox.removeClass("cropper-hidden")),t.setCropBoxData(t.initialCropBox))},reset:function(){var e=this;e.ready&&!e.disabled&&(e.image=t.extend({},e.initialImage),e.canvas=t.extend({},e.initialCanvas),e.cropBox=t.extend({},e.initialCropBox),e.renderCanvas(),e.cropped&&e.renderCropBox())},clear:function(){var e=this;e.cropped&&!e.disabled&&(t.extend(e.cropBox,{left:0,top:0,width:0,height:0}),e.cropped=!1,e.renderCropBox(),e.limitCanvas(!0,!0),e.renderCanvas(),e.$dragBox.removeClass("cropper-modal"),e.$cropBox.addClass("cropper-hidden"))},replace:function(t,e){var i=this;!i.disabled&&t&&(i.isImg&&i.$element.attr("src",t),e?(i.url=t,i.$clone.attr("src",t),i.ready&&i.$preview.find("img").add(i.$clone2).attr("src",t)):(i.isImg&&(i.replaced=!0),i.options.data=null,i.load(t)))},enable:function(){var t=this;t.ready&&(t.disabled=!1,t.$cropper.removeClass("cropper-disabled"))},disable:function(){var t=this;t.ready&&(t.disabled=!0,t.$cropper.addClass("cropper-disabled"))},destroy:function(){var t=this,e=t.$element;t.loaded?(t.isImg&&t.replaced&&e.attr("src",t.originalUrl),t.unbuild(),e.removeClass("cropper-hidden")):t.isImg?e.off("load",t.start):t.$clone&&t.$clone.remove(),e.removeData("cropper")},move:function(t,e){var a=this,o=a.canvas;a.moveTo(i(t)?t:o.left+Number(t),i(e)?e:o.top+Number(e))},moveTo:function(t,a){var o=this,n=o.canvas,r=!1;i(a)&&(a=t),t=Number(t),a=Number(a),o.ready&&!o.disabled&&o.options.movable&&(e(t)&&(n.left=t,r=!0),e(a)&&(n.top=a,r=!0),r&&o.renderCanvas(!0))},zoom:function(t,e){var i=this,a=i.canvas;t=(t=Number(t))<0?1/(1-t):1+t,i.zoomTo(a.width*t/a.naturalWidth,e)},zoomTo:function(t,e){var i=this,a=i.options,o=i.pointers,r=i.canvas,h=r.width,s=r.height,d=r.naturalWidth,c=r.naturalHeight;if((t=Number(t))>=0&&i.ready&&!i.disabled&&a.zoomable){var l=d*t,p=c*t,m=void 0;if(e&&(m=e.originalEvent),i.trigger("zoom",{originalEvent:m,oldRatio:h/d,ratio:l/d}).isDefaultPrevented())return;if(m){var g=i.$cropper.offset(),f=o&&n(o).length?x(o):{pageX:e.pageX||m.pageX||0,pageY:e.pageY||m.pageY||0};r.left-=(l-h)*((f.pageX-g.left-r.left)/h),r.top-=(p-s)*((f.pageY-g.top-r.top)/s)}else r.left-=(l-h)/2,r.top-=(p-s)/2;r.width=l,r.height=p,i.renderCanvas(!0)}},rotate:function(t){var e=this;e.rotateTo((e.image.rotate||0)+Number(t))},rotateTo:function(t){var i=this;e(t=Number(t))&&i.ready&&!i.disabled&&i.options.rotatable&&(i.image.rotate=t%360,i.rotated=!0,i.renderCanvas(!0))},scale:function(t,a){var o=this,n=o.image,r=!1;i(a)&&(a=t),t=Number(t),a=Number(a),o.ready&&!o.disabled&&o.options.scalable&&(e(t)&&(n.scaleX=t,r=!0),e(a)&&(n.scaleY=a,r=!0),r&&o.renderImage(!0))},scaleX:function(t){var i=this,a=i.image.scaleY;i.scale(t,e(a)?a:1)},scaleY:function(t){var i=this,a=i.image.scaleX;i.scale(e(a)?a:1,t)},getData:function(e){var i=this,a=i.options,o=i.image,n=i.canvas,r=i.cropBox,h=void 0,s=void 0;return i.ready&&i.cropped?(s={x:r.left-n.left,y:r.top-n.top,width:r.width,height:r.height},h=o.width/o.naturalWidth,t.each(s,function(t,i){i/=h,s[t]=e?Math.round(i):i})):s={x:0,y:0,width:0,height:0},a.rotatable&&(s.rotate=o.rotate||0),a.scalable&&(s.scaleX=o.scaleX||1,s.scaleY=o.scaleY||1),s},setData:function(i){var a=this,o=a.options,n=a.image,r=a.canvas,h={},s=void 0,d=void 0,c=void 0;t.isFunction(i)&&(i=i.call(a.element)),a.ready&&!a.disabled&&t.isPlainObject(i)&&(o.rotatable&&e(i.rotate)&&i.rotate!==n.rotate&&(n.rotate=i.rotate,s=!0,a.rotated=s),o.scalable&&(e(i.scaleX)&&i.scaleX!==n.scaleX&&(n.scaleX=i.scaleX,d=!0),e(i.scaleY)&&i.scaleY!==n.scaleY&&(n.scaleY=i.scaleY,d=!0)),s?a.renderCanvas():d&&a.renderImage(),c=n.width/n.naturalWidth,e(i.x)&&(h.left=i.x*c+r.left),e(i.y)&&(h.top=i.y*c+r.top),e(i.width)&&(h.width=i.width*c),e(i.height)&&(h.height=i.height*c),a.setCropBoxData(h))},getContainerData:function(){return this.ready?this.container:{}},getImageData:function(){return this.loaded?this.image:{}},getCanvasData:function(){var e=this,i=e.canvas,a={};return e.ready&&t.each(["left","top","width","height","naturalWidth","naturalHeight"],function(t,e){a[e]=i[e]}),a},setCanvasData:function(i){var a=this,o=a.canvas,n=o.aspectRatio;t.isFunction(i)&&(i=i.call(a.$element)),a.ready&&!a.disabled&&t.isPlainObject(i)&&(e(i.left)&&(o.left=i.left),e(i.top)&&(o.top=i.top),e(i.width)?(o.width=i.width,o.height=i.width/n):e(i.height)&&(o.height=i.height,o.width=i.height*n),a.renderCanvas(!0))},getCropBoxData:function(){var t=this,e=t.cropBox;return t.ready&&t.cropped?{left:e.left,top:e.top,width:e.width,height:e.height}:{}},setCropBoxData:function(i){var a=this,o=a.cropBox,n=a.options.aspectRatio,r=void 0,h=void 0;t.isFunction(i)&&(i=i.call(a.$element)),a.ready&&a.cropped&&!a.disabled&&t.isPlainObject(i)&&(e(i.left)&&(o.left=i.left),e(i.top)&&(o.top=i.top),e(i.width)&&i.width!==o.width&&(r=!0,o.width=i.width),e(i.height)&&i.height!==o.height&&(h=!0,o.height=i.height),n&&(r?o.height=o.width/n:h&&(o.width=o.height*n)),a.renderCropBox())},getCroppedCanvas:function(e){var i=this;if(!i.ready||!window.HTMLCanvasElement)return null;if(t.isPlainObject(e)||(e={}),!i.cropped)return l(i.$clone[0],i.image,e);var a=i.getData(),o=a.width,n=a.height,r=o/n,h=void 0,s=void 0,d=void 0;t.isPlainObject(e)&&(h=e.width,s=e.height,h?(s=h/r,d=h/o):s&&(h=s*r,d=s/n));var c=Math.floor(h||o),p=Math.floor(s||n),m=t("")[0],g=m.getContext("2d");m.width=c,m.height=p,e.fillColor&&(g.fillStyle=e.fillColor,g.fillRect(0,0,c,p));var f=function(){var t=l(i.$clone[0],i.image,e),r=t.width,h=t.height,s=i.canvas,c=[t],p=a.x+s.naturalWidth*(Math.abs(a.scaleX||1)-1)/2,m=a.y+s.naturalHeight*(Math.abs(a.scaleY||1)-1)/2,g=void 0,f=void 0,u=void 0,v=void 0,w=void 0,x=void 0;return p<=-o||p>r?(p=0,g=0,u=0,w=0):p<=0?(u=-p,p=0,g=w=Math.min(r,o+p)):p<=r&&(u=0,g=w=Math.min(o,r-p)),g<=0||m<=-n||m>h?(m=0,f=0,v=0,x=0):m<=0?(v=-m,m=0,f=x=Math.min(h,n+m)):m<=h&&(v=0,f=x=Math.min(n,h-m)),c.push(Math.floor(p),Math.floor(m),Math.floor(g),Math.floor(f)),d&&(u*=d,v*=d,w*=d,x*=d),w>0&&x>0&&c.push(Math.floor(u),Math.floor(v),Math.floor(w),Math.floor(x)),c}();return g.imageSmoothingEnabled=!!e.imageSmoothingEnabled,e.imageSmoothingQuality&&(g.imageSmoothingQuality=e.imageSmoothingQuality),g.drawImage.apply(g,w(f)),m},setAspectRatio:function(t){var e=this,a=e.options;e.disabled||i(t)||(a.aspectRatio=Math.max(0,t)||NaN,e.ready&&(e.initCropBox(),e.cropped&&e.renderCropBox()))},setDragMode:function(t){var e=this,i=e.options,a=void 0,o=void 0;e.loaded&&!e.disabled&&(a="crop"===t,o=i.movable&&"move"===t,t=a||o?t:"none",e.$dragBox.data("action",t).toggleClass("cropper-crop",a).toggleClass("cropper-move",o),i.cropBoxMovable||e.$face.data("action",t).toggleClass("cropper-crop",a).toggleClass("cropper-move",o))}},N=function(){function t(t,e){for(var i=0;i1)switch(e.url=f(t),a){case 2:r=-1;break;case 3:n=-180;break;case 4:h=-1;break;case 5:n=90,h=-1;break;case 6:n=90;break;case 7:n=90,r=-1;break;case 8:n=-90}i.rotatable&&(o.rotate=n),i.scalable&&(o.scaleX=r,o.scaleY=h),e.clone()}},{key:"clone",value:function(){var e=this,i=e.options,a=e.$element,o=e.url,n="",s=void 0;i.checkCrossOrigin&&r(o)&&((n=a.prop("crossOrigin"))?s=o:(n="anonymous",s=h(o))),e.crossOrigin=n,e.crossOriginUrl=s;var d=document.createElement("img");n&&(d.crossOrigin=n),d.src=s||o;var c=t(d);e.$clone=c,e.isImg?a[0].complete?e.start():a.one("load",t.proxy(e.start,this)):c.one("load",t.proxy(e.start,this)).one("error",t.proxy(e.stop,this)).addClass("cropper-hide").insertAfter(a)}},{key:"start",value:function(){var e=this,i=e.$clone,a=e.$element;e.isImg||(i.off("error",e.stop),a=i),s(a[0],function(i,a){t.extend(e.image,{naturalWidth:i,naturalHeight:a,aspectRatio:i/a}),e.loaded=!0,e.build()})}},{key:"stop",value:function(){var t=this;t.$clone.remove(),t.$clone=null}},{key:"build",value:function(){var e=this,i=e.options,a=e.$element,o=e.$clone;if(e.loaded){e.ready&&e.unbuild();var n=t('
'),r=n.find(".cropper-crop-box"),h=r.find(".cropper-face");e.$container=a.parent(),e.$cropper=n,e.$canvas=n.find(".cropper-canvas").append(o),e.$dragBox=n.find(".cropper-drag-box"),e.$cropBox=r,e.$viewBox=n.find(".cropper-view-box"),e.$face=h,a.addClass("cropper-hidden").after(n),e.isImg||o.removeClass("cropper-hide"),e.initPreview(),e.bind(),i.aspectRatio=Math.max(0,i.aspectRatio)||NaN,i.viewMode=Math.max(0,Math.min(3,Math.round(i.viewMode)))||0,e.cropped=i.autoCrop,i.autoCrop?i.modal&&e.$dragBox.addClass("cropper-modal"):r.addClass("cropper-hidden"),i.guides||r.find(".cropper-dashed").addClass("cropper-hidden"),i.center||r.find(".cropper-center").addClass("cropper-hidden"),i.cropBoxMovable&&h.addClass("cropper-move").data("action","all"),i.highlight||h.addClass("cropper-invisible"),i.background&&n.addClass("cropper-bg"),i.cropBoxResizable||r.find(".cropper-line, .cropper-point").addClass("cropper-hidden"),e.setDragMode(i.dragMode),e.render(),e.ready=!0,e.setData(i.data),e.completing=setTimeout(function(){t.isFunction(i.ready)&&a.one("ready",i.ready),e.trigger("ready"),e.trigger("crop",e.getData()),e.completed=!0},0)}}},{key:"unbuild",value:function(){var t=this;t.ready&&(t.completed||clearTimeout(t.completing),t.ready=!1,t.completed=!1,t.initialImage=null,t.initialCanvas=null,t.initialCropBox=null,t.container=null,t.canvas=null,t.cropBox=null,t.unbind(),t.resetPreview(),t.$preview=null,t.$viewBox=null,t.$cropBox=null,t.$dragBox=null,t.$canvas=null,t.$container=null,t.$cropper.remove(),t.$cropper=null)}}],[{key:"setDefaults",value:function(e){t.extend(y,t.isPlainObject(e)&&e)}}]),e}();t.extend(U.prototype,D),t.extend(U.prototype,T),t.extend(U.prototype,O),t.extend(U.prototype,R),t.extend(U.prototype,E),t.extend(U.prototype,L);var A=t.fn.cropper;t.fn.cropper=function(e){for(var i=arguments.length,a=Array(i>1?i-1:0),o=1;o