gumga-avatar-ng
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,1 +0,1 @@ | ||
!function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="dist",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(1);window.angular.module("gumga.avatar",[]).component("gumgaAvatar",i.a)},function(e,t,n){"use strict";var i=n(2),o=(n.n(i),n(3)),r={bindings:{height:"@?",width:"@?",ngModel:"=",pickerText:"@?",cropTitle:"@?",defaultAvatar:"@?",type:"@?",useGumgaImage:"=?"},template:n(10),controller:["$timeout","$attrs","$element","$uibModal",function(e,t,i,r){var a=this;a.$onInit=function(){e(function(){a.width=a.width||170,a.height=a.height||170,a.useGumgaImage=a.useGumgaImage||!1,a.type=a.type||"square",a.input=i.find('input[type="file"]'),a.input.change(function(e){return a.changeImage(e)}),a.ngModel&&a.useGumgaImage&&(a.image="data:"+a.ngModel.mimeType+";base64,"+a.ngModel.bytes),a.ngModel&&!a.useGumgaImage&&(a.image=a.ngModel)})},a.chooseImage=function(){a.input&&a.input[0]?a.input.click():(a.input=i.find('input[type="file"]'),a.input.click())},a.changeImage=function(e){if(a.input[0].files&&a.input[0].files[0]){var t=a.input[0].files[0],n=new FileReader;n.readAsDataURL(t),n.onload=function(e){a.input[0].value="",a.openModalCropImage(e.target.result)}}},a.setPicture=function(e){if(e&&a.useGumgaImage){a.image=e;var t=e.substring(e.indexOf(":")+1,e.indexOf(";")),n={mimeType:t,name:"picture."+t.substring(t.lastIndexOf("/")+1,t.length),bytes:e.substring(e.indexOf(",")+1,e.length),size:Math.round(6*e.length/8)};a.ngModel=n}e&&!a.useGumgaImage&&(a.image=e,a.ngModel=e)},a.openModalCropImage=function(e){r.open({template:n(11),controller:o.a,controllerAs:"$ctrl",backdrop:"static",openedClass:"gumga-avatar",size:"md",resolve:{image:function(){return e},cropTitle:function(){return a.cropTitle},width:function(){return a.width},height:function(){return a.height},type:function(){return a.type}}}).result.then(function(e){e&&a.setPicture(e)})}}]};t.a=r},function(e,t){},function(e,t,n){"use strict";var i=n(4),o=(n.n(i),n(5)),r=n.n(o),a=["image","$uibModalInstance","cropTitle","width","height","type",function(e,t,n,i,o,a){var s=this;s.$onInit=function(){s.cropTitle=n},s.close=function(){t.close()},s.createCrop=function(){s.crop=new r.a(document.getElementById("cropElem"),{viewport:{width:i,height:o,type:a},showZoomer:!0,enableOrientation:!0}),s.crop.bind({url:e})},s.save=function(){s.crop.result().then(function(e){t.close(e)})}}];t.a=a},function(e,t){},function(e,t,n){(function(n){var i,o,r;!function(n,a){o=[t],void 0===(r="function"==typeof(i=a)?i.apply(t,o):i)||(e.exports=r)}(0,function(t){function i(e){if(e in B)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=R.length;n--;)if((e=R[n]+t)in B)return e}function o(e,t){e=e||{};for(var n in t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},o(e[n],t[n])):e[n]=t[n];return e}function r(e){if("createEvent"in document){var t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0),e.dispatchEvent(t)}else e.fireEvent("onchange")}function a(e,t,n){if("string"==typeof t){var i=t;(t={})[i]=n}for(var o in t)e.style[o]=t[o]}function s(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function l(e,t){for(var n in t)e.setAttribute(n,t[n])}function c(e){return parseInt(e,10)}function u(e,t,n){var i=t.width,o=t.height,r=e.getContext("2d");switch(e.width=t.width,e.height=t.height,r.save(),n){case 2:r.translate(i,0),r.scale(-1,1);break;case 3:r.translate(i,o),r.rotate(180*Math.PI/180);break;case 4:r.translate(0,o),r.scale(1,-1);break;case 5:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.scale(1,-1);break;case 6:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.translate(0,-o);break;case 7:e.width=o,e.height=i,r.rotate(-90*Math.PI/180),r.translate(-i,o),r.scale(1,-1);break;case 8:e.width=o,e.height=i,r.translate(0,i),r.rotate(-90*Math.PI/180)}r.drawImage(t,0,0,i,o),r.restore()}function h(){var e,t,n,i,o,c=this.options.viewport.type?"cr-vp-"+this.options.viewport.type:null;this.options.useCanvas=this.options.enableOrientation||p.call(this),this.data={},this.elements={},e=this.elements.boundary=document.createElement("div"),t=this.elements.viewport=document.createElement("div"),this.elements.img=document.createElement("img"),n=this.elements.overlay=document.createElement("div"),this.options.useCanvas?(this.elements.canvas=document.createElement("canvas"),this.elements.preview=this.elements.canvas):this.elements.preview=this.elements.img,s(e,"cr-boundary"),e.setAttribute("aria-dropeffect","none"),i=this.options.boundary.width,o=this.options.boundary.height,a(e,{width:i+(isNaN(i)?"":"px"),height:o+(isNaN(o)?"":"px")}),s(t,"cr-viewport"),c&&s(t,c),a(t,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),t.setAttribute("tabindex",0),s(this.elements.preview,"cr-image"),l(this.elements.preview,{alt:"preview","aria-grabbed":"false"}),s(n,"cr-overlay"),this.element.appendChild(e),e.appendChild(this.elements.preview),e.appendChild(t),e.appendChild(n),s(this.element,"croppie-container"),this.options.customClass&&s(this.element,this.options.customClass),function(){function e(e,t){var n=p.elements.preview.getBoundingClientRect(),i=h.y+t,o=h.x+e;p.options.enforceBoundary?(u.top>n.top+t&&u.bottom<n.bottom+t&&(h.y=i),u.left>n.left+e&&u.right<n.right+e&&(h.x=o)):(h.y=i,h.x=o)}function t(e){p.elements.preview.setAttribute("aria-grabbed",e),p.elements.boundary.setAttribute("aria-dropeffect",e?"move":"none")}function n(e){if((void 0===e.button||0===e.button)&&(e.preventDefault(),!m)){if(m=!0,s=e.pageX,l=e.pageY,e.touches){var n=e.touches[0];s=n.pageX,l=n.pageY}t(m),h=O.parse(p.elements.preview),window.addEventListener("mousemove",i),window.addEventListener("touchmove",i),window.addEventListener("mouseup",o),window.addEventListener("touchend",o),document.body.style[k]="none",u=p.elements.viewport.getBoundingClientRect()}}function i(t){t.preventDefault();var n=t.pageX,i=t.pageY;if(t.touches){var o=t.touches[0];n=o.pageX,i=o.pageY}var u=n-s,m=i-l,f={};if("touchmove"==t.type&&t.touches.length>1){var v=t.touches[0],w=t.touches[1],y=Math.sqrt((v.pageX-w.pageX)*(v.pageX-w.pageX)+(v.pageY-w.pageY)*(v.pageY-w.pageY));c||(c=y/p._currentZoom);var b=y/c;return d.call(p,b),void r(p.elements.zoomer)}e(u,m),f[L]=h.toString(),a(p.elements.preview,f),g.call(p),l=i,s=n}function o(){t(m=!1),window.removeEventListener("mousemove",i),window.removeEventListener("touchmove",i),window.removeEventListener("mouseup",o),window.removeEventListener("touchend",o),document.body.style[k]="",f.call(p),v.call(p),c=0}var s,l,c,u,h,p=this,m=!1;p.elements.overlay.addEventListener("mousedown",n),p.elements.viewport.addEventListener("keydown",function(t){var n=37,i=38,o=39,r=40;if(!t.shiftKey||t.keyCode!=i&&t.keyCode!=r){if(p.options.enableKeyMovement&&t.keyCode>=37&&t.keyCode<=40){t.preventDefault();var s=function(e){switch(e){case n:return[1,0];case i:return[0,1];case o:return[-1,0];case r:return[0,-1]}}(t.keyCode);h=O.parse(p.elements.preview),document.body.style[k]="none",u=p.elements.viewport.getBoundingClientRect(),function(t){var n=t[0],i=t[1],o={};e(n,i),o[L]=h.toString(),a(p.elements.preview,o),g.call(p),document.body.style[k]="",f.call(p),v.call(p),c=0}(s)}}else{var l=0;l=t.keyCode==i?parseFloat(p.elements.zoomer.value,10)+parseFloat(p.elements.zoomer.step,10):parseFloat(p.elements.zoomer.value,10)-parseFloat(p.elements.zoomer.step,10),p.setZoom(l)}}),p.elements.overlay.addEventListener("touchstart",n)}.call(this),this.options.enableZoom&&function(){function e(){m.call(n,{value:parseFloat(o.value),origin:new z(n.elements.preview),viewportRect:n.elements.viewport.getBoundingClientRect(),transform:O.parse(n.elements.preview)})}function t(t){var i,o;i=t.wheelDelta?t.wheelDelta/1200:t.deltaY?t.deltaY/1060:t.detail?t.detail/-60:0,o=n._currentZoom+i*n._currentZoom,t.preventDefault(),d.call(n,o),e.call(n)}var n=this,i=n.elements.zoomerWrap=document.createElement("div"),o=n.elements.zoomer=document.createElement("input");s(i,"cr-slider-wrap"),s(o,"cr-slider"),o.type="range",o.step="0.0001",o.value=1,o.style.display=n.options.showZoomer?"":"none",o.setAttribute("aria-label","zoom"),n.element.appendChild(i),i.appendChild(o),n._currentZoom=1;n.elements.zoomer.addEventListener("input",e),n.elements.zoomer.addEventListener("change",e),n.options.mouseWheelZoom&&(n.elements.boundary.addEventListener("mousewheel",t),n.elements.boundary.addEventListener("DOMMouseScroll",t))}.call(this),this.options.enableResize&&function(){function e(e){if((void 0===e.button||0===e.button)&&(e.preventDefault(),!m)){var a=p.elements.overlay.getBoundingClientRect();if(m=!0,o=e.pageX,r=e.pageY,i=-1!==e.currentTarget.className.indexOf("vertical")?"v":"h",l=a.width,c=a.height,e.touches){var s=e.touches[0];o=s.pageX,r=s.pageY}window.addEventListener("mousemove",t),window.addEventListener("touchmove",t),window.addEventListener("mouseup",n),window.addEventListener("touchend",n),document.body.style[k]="none"}}function t(e){var t=e.pageX,n=e.pageY;if(e.preventDefault(),e.touches){var s=e.touches[0];t=s.pageX,n=s.pageY}var u=t-o,h=n-r,m=p.options.viewport.height+h,y=p.options.viewport.width+u;"v"===i&&m>=w&&m<=c?(a(d,{height:m+"px"}),p.options.boundary.height+=h,a(p.elements.boundary,{height:p.options.boundary.height+"px"}),p.options.viewport.height+=h,a(p.elements.viewport,{height:p.options.viewport.height+"px"})):"h"===i&&y>=w&&y<=l&&(a(d,{width:y+"px"}),p.options.boundary.width+=u,a(p.elements.boundary,{width:p.options.boundary.width+"px"}),p.options.viewport.width+=u,a(p.elements.viewport,{width:p.options.viewport.width+"px"})),g.call(p),b.call(p),f.call(p),v.call(p),r=n,o=t}function n(){m=!1,window.removeEventListener("mousemove",t),window.removeEventListener("touchmove",t),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),document.body.style[k]=""}var i,o,r,l,c,u,h,p=this,d=document.createElement("div"),m=!1,w=50;s(d,"cr-resizer"),a(d,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),this.options.resizeControls.height&&(s(u=document.createElement("div"),"cr-resizer-vertical"),d.appendChild(u));this.options.resizeControls.width&&(s(h=document.createElement("div"),"cr-resizer-horisontal"),d.appendChild(h));u&&u.addEventListener("mousedown",e);h&&h.addEventListener("mousedown",e);this.elements.boundary.appendChild(d)}.call(this)}function p(){return this.options.enableExif&&window.EXIF}function d(e){if(this.options.enableZoom){var t=this.elements.zoomer,n=E(e,4);t.value=Math.max(t.min,Math.min(t.max,n))}}function m(e){function t(){var e={};e[L]=i.toString(),e[M]=r.toString(),a(n.elements.preview,e)}var n=this,i=e?e.transform:O.parse(n.elements.preview),o=e?e.viewportRect:n.elements.viewport.getBoundingClientRect(),r=e?e.origin:new z(n.elements.preview);if(n._currentZoom=e?e.value:n._currentZoom,i.scale=n._currentZoom,n.elements.zoomer.setAttribute("aria-valuenow",n._currentZoom),t(),n.options.enforceBoundary){var s=function(e){var t=this._currentZoom,n=e.width,i=e.height,o=this.elements.boundary.clientWidth/2,r=this.elements.boundary.clientHeight/2,a=this.elements.preview.getBoundingClientRect(),s=a.width,l=a.height,c=n/2,u=i/2,h=-1*(c/t-o),p=-1*(u/t-r),d=1/t*c,m=1/t*u;return{translate:{maxX:h,minX:h-(s*(1/t)-n*(1/t)),maxY:p,minY:p-(l*(1/t)-i*(1/t))},origin:{maxX:s*(1/t)-d,minX:d,maxY:l*(1/t)-m,minY:m}}}.call(n,o),l=s.translate,c=s.origin;i.x>=l.maxX&&(r.x=c.minX,i.x=l.maxX),i.x<=l.minX&&(r.x=c.maxX,i.x=l.minX),i.y>=l.maxY&&(r.y=c.minY,i.y=l.maxY),i.y<=l.minY&&(r.y=c.maxY,i.y=l.minY)}t(),A.call(n),v.call(n)}function f(){var e=this._currentZoom,t=this.elements.preview.getBoundingClientRect(),n=this.elements.viewport.getBoundingClientRect(),i=O.parse(this.elements.preview.style[L]),o=new z(this.elements.preview),r=n.top-t.top+n.height/2,s=n.left-t.left+n.width/2,l={},c={};l.y=r/e,l.x=s/e,c.y=(l.y-o.y)*(1-e),c.x=(l.x-o.x)*(1-e),i.x-=c.x,i.y-=c.y;var u={};u[M]=l.x+"px "+l.y+"px",u[L]=i.toString(),a(this.elements.preview,u)}function g(){var e=this.elements.boundary.getBoundingClientRect(),t=this.elements.preview.getBoundingClientRect();a(this.elements.overlay,{width:t.width+"px",height:t.height+"px",top:t.top-e.top+"px",left:t.left-e.left+"px"})}function v(){var e=this.get();if(w.call(this))if(this.options.update.call(this,e),this.$&&"undefined"==typeof Prototype)this.$(this.element).trigger("update",e);else{var t;window.CustomEvent?t=new CustomEvent("update",{detail:e}):(t=document.createEvent("CustomEvent")).initCustomEvent("update",!0,!0,e),this.element.dispatchEvent(t)}}function w(){return this.elements.preview.offsetHeight>0&&this.elements.preview.offsetWidth>0}function y(){var e={},t=this.elements.preview,n=this.elements.preview.getBoundingClientRect(),i=new O(0,0,1),o=new z;w.call(this)&&!this.data.bound&&(this.data.bound=!0,e[L]=i.toString(),e[M]=o.toString(),e.opacity=1,a(t,e),this._originalImageWidth=n.width,this._originalImageHeight=n.height,this.options.enableZoom?b.call(this,!0):this._currentZoom=1,i.scale=this._currentZoom,e[L]=i.toString(),a(t,e),this.data.points.length?function(e){if(4!=e.length)throw"Croppie - Invalid number of points supplied: "+e;var t=e[2]-e[0],n=this.elements.viewport.getBoundingClientRect(),i=this.elements.boundary.getBoundingClientRect(),o={left:n.left-i.left,top:n.top-i.top},r=n.width/t,s=e[1],l=e[0],c=-1*e[1]+o.top,u=-1*e[0]+o.left,h={};h[M]=l+"px "+s+"px",h[L]=new O(u,c,r).toString(),a(this.elements.preview,h),d.call(this,r),this._currentZoom=r}.call(this,this.data.points):function(){var e=this.elements.preview.getBoundingClientRect(),t=this.elements.viewport.getBoundingClientRect(),n=this.elements.boundary.getBoundingClientRect(),i=t.left-n.left,o=t.top-n.top,r=i-(e.width-t.width)/2,s=o-(e.height-t.height)/2,l=new O(r,s,this._currentZoom);a(this.elements.preview,L,l.toString())}.call(this),f.call(this),g.call(this))}function b(e){var t,n,i,o,a=0,s=1.5,l=this.elements.zoomer,c=parseFloat(l.value),u=this.elements.boundary.getBoundingClientRect(),h=this.elements.preview.getBoundingClientRect(),p=this.elements.viewport.getBoundingClientRect();this.options.enforceBoundary&&(i=p.width/(e?h.width:h.width/c),o=p.height/(e?h.height:h.height/c),a=Math.max(i,o)),a>=s&&(s=a+1),l.min=E(a,4),l.max=E(s,4),e&&(n=Math.max(u.width/h.width,u.height/h.height),t=null!==this.data.boundZoom?this.data.boundZoom:n,d.call(this,t)),r(l)}function x(e){var t=e.points,n=c(t[0]),i=c(t[1]),o=c(t[2]),r=c(t[3]),a=o-n,s=r-i,l=e.circle,u=document.createElement("canvas"),h=u.getContext("2d"),p=a,d=s,m=0,f=0,g=p,v=d,w=1;return e.outputWidth&&e.outputHeight&&(g=e.outputWidth,v=e.outputHeight,w=g/p),u.width=g,u.height=v,e.backgroundColor&&(h.fillStyle=e.backgroundColor,h.fillRect(0,0,p,d)),this.options.enforceBoundary||(n<0&&(m=Math.abs(n),n=0),i<0&&(f=Math.abs(i),i=0),o>this._originalImageWidth&&(p=a=this._originalImageWidth-n),r>this._originalImageHeight&&(d=s=this._originalImageHeight-i)),1!==w&&(m*=w,f*=w,p*=w,d*=w),h.drawImage(this.elements.preview,n,i,Math.min(a,this._originalImageWidth),Math.min(s,this._originalImageHeight),m,f,p,d),l&&(h.fillStyle="#fff",h.globalCompositeOperation="destination-in",h.beginPath(),h.arc(p/2,d/2,p/2,0,2*Math.PI,!0),h.closePath(),h.fill()),u}function C(e,t){var n,i=this,o=[],r=null,a=p.call(i);if("string"==typeof e)n=e,e={};else if(Array.isArray(e))o=e.slice();else{if(void 0===e&&i.data.url)return y.call(i),v.call(i),null;n=e.url,o=e.points||[],r=void 0===e.zoom?null:e.zoom}return i.data.bound=!1,i.data.url=n||i.data.url,i.data.boundZoom=r,function(e,t,n){var i=t||new Image;return i.style.opacity=0,new Promise(function(t){function o(){setTimeout(function(){t(i)},1)}i.src!==e?(i.exifdata=null,i.removeAttribute("crossOrigin"),e.match(/^https?:\/\/|^\/\//)&&i.setAttribute("crossOrigin","anonymous"),i.onload=function(){n?EXIF.getData(i,function(){o()}):o()},i.src=e):o()})}(n,i.elements.img,a).then(function(n){if(o.length)i.options.relative&&(o=[o[0]*n.naturalWidth/100,o[1]*n.naturalHeight/100,o[2]*n.naturalWidth/100,o[3]*n.naturalHeight/100]);else{var r,a,s=function(e){var t=e.naturalWidth,n=e.naturalHeight;if(e.exifdata&&e.exifdata.Orientation>=5){var i=t;t=n,n=i}return{width:t,height:n}}(n),l=i.elements.viewport.getBoundingClientRect(),h=l.width/l.height;s.width/s.height>h?r=(a=s.height)*h:a=(r=s.width)/h;var d=(s.width-r)/2,m=(s.height-a)/2,f=d+r,g=m+a;i.data.points=[d,m,f,g]}i.data.points=o.map(function(e){return parseFloat(e)}),i.options.useCanvas&&function(e){var t=this.elements.canvas,n=this.elements.img,i=t.getContext("2d"),o=p.call(this);e=this.options.enableOrientation&&e,i.clearRect(0,0,t.width,t.height),t.width=n.width,t.height=n.height,o&&!e?u(t,n,c(function(e){return e.exifdata.Orientation}(n)||0)):e&&u(t,n,e)}.call(i,e.orientation||1),y.call(i),v.call(i),t&&t()})}function E(e,t){return parseFloat(e).toFixed(t||0)}function T(){var e=this.elements.preview.getBoundingClientRect(),t=this.elements.viewport.getBoundingClientRect(),n=t.left-e.left,i=t.top-e.top,o=(t.width-this.elements.viewport.offsetWidth)/2,r=(t.height-this.elements.viewport.offsetHeight)/2,a=n+this.elements.viewport.offsetWidth+o,s=i+this.elements.viewport.offsetHeight+r,l=this._currentZoom;(l===1/0||isNaN(l))&&(l=1);var c=this.options.enforceBoundary?0:Number.NEGATIVE_INFINITY;return n=Math.max(c,n/l),i=Math.max(c,i/l),a=Math.max(c,a/l),s=Math.max(c,s/l),{points:[E(n),E(i),E(a),E(s)],zoom:l}}function I(e){var t=this,n=T.call(t),i=o(Z,o({},e)),r="string"==typeof e?e:i.type||"base64",l=i.size||"viewport",c=i.format,u=i.quality,h=i.backgroundColor,p="boolean"==typeof i.circle?i.circle:"circle"===t.options.viewport.type,d=t.elements.viewport.getBoundingClientRect(),m=d.width/d.height;return"viewport"===l?(n.outputWidth=d.width,n.outputHeight=d.height):"object"==typeof l&&(l.width&&l.height?(n.outputWidth=l.width,n.outputHeight=l.height):l.width?(n.outputWidth=l.width,n.outputHeight=l.width/m):l.height&&(n.outputWidth=l.height*m,n.outputHeight=l.height)),F.indexOf(c)>-1&&(n.format="image/"+c,n.quality=u),n.circle=p,n.url=t.data.url,n.backgroundColor=h,new Promise(function(e,i){switch(r.toLowerCase()){case"rawcanvas":e(x.call(t,n));break;case"canvas":case"base64":e(function(e){return x.call(this,e).toDataURL(e.format,e.quality)}.call(t,n));break;case"blob":(function(e){var t=this;return new Promise(function(n,i){x.call(t,e).toBlob(function(e){n(e)},e.format,e.quality)})}).call(t,n).then(e);break;default:e(function(e){var t=e.points,n=document.createElement("div"),i=document.createElement("img"),o=t[2]-t[0],r=t[3]-t[1];return s(n,"croppie-result"),n.appendChild(i),a(i,{left:-1*t[0]+"px",top:-1*t[1]+"px"}),i.src=e.url,a(n,{width:o+"px",height:r+"px"}),n}.call(t,n))}})}function _(e,t){if(this.element=e,this.options=o(o({},_.defaults),t),"img"===this.element.tagName.toLowerCase()){var n=this.element;s(n,"cr-original-image"),l(n,{"aria-hidden":"true",alt:""});var i=document.createElement("div");this.element.parentNode.appendChild(i),i.appendChild(n),this.element=i,this.options.url=this.options.url||n.src}if(h.call(this),this.options.url){var r={url:this.options.url,points:this.options.points};delete this.options.url,delete this.options.points,C.call(this,r)}}"function"!=typeof Promise&&function(t){function i(e,t){return function(){e.apply(t,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],c(e,i(a,this),i(s,this))}function r(e){var t=this;return null===this._state?void this._deferreds.push(e):void h(function(){var n=t._state?e.onFulfilled:e.onRejected;if(null!==n){var i;try{i=n(t._value)}catch(t){return void e.reject(t)}e.resolve(i)}else(t._state?e.resolve:e.reject)(t._value)})}function a(e){try{if(e===this)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if("function"==typeof t)return void c(i(t,e),i(a,this),i(s,this))}this._state=!0,this._value=e,l.call(this)}catch(e){s.call(this,e)}}function s(e){this._state=!1,this._value=e,l.call(this)}function l(){for(var e=0,t=this._deferreds.length;t>e;e++)r.call(this,this._deferreds[e]);this._deferreds=null}function c(e,t,n){var i=!1;try{e(function(e){i||(i=!0,t(e))},function(e){i||(i=!0,n(e))})}catch(e){if(i)return;i=!0,n(e)}}var u=setTimeout,h="function"==typeof n&&n||function(e){u(e,1)},p=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var n=this;return new o(function(i,o){r.call(n,new function(e,t,n,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=i}(e,t,i,o))})},o.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&p(arguments[0])?arguments[0]:arguments);return new o(function(t,n){function i(r,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){i(r,e)},n)}e[r]=a,0==--o&&t(e)}catch(e){n(e)}}if(0===e.length)return t([]);for(var o=e.length,r=0;r<e.length;r++)i(r,e[r])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(t){t(e)})},o.reject=function(e){return new o(function(t,n){n(e)})},o.race=function(e){return new o(function(t,n){for(var i=0,o=e.length;o>i;i++)e[i].then(t,n)})},o._setImmediateFn=function(e){h=e},void 0!==e&&e.exports?e.exports=o:t.Promise||(t.Promise=o)}(this),"function"!=typeof window.CustomEvent&&function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,n){for(var i=atob(this.toDataURL(t,n).split(",")[1]),o=i.length,r=new Uint8Array(o),a=0;a<o;a++)r[a]=i.charCodeAt(a);e(new Blob([r],{type:t||"image/png"}))}});var M,L,k,R=["Webkit","Moz","ms"],B=document.createElement("div").style;L=i("transform"),M=i("transformOrigin"),k=i("userSelect");var $={translate3d:{suffix:", 0px"},translate:{suffix:""}},O=function(e,t,n){this.x=parseFloat(e),this.y=parseFloat(t),this.scale=parseFloat(n)};O.parse=function(e){return e.style?O.parse(e.style[L]):e.indexOf("matrix")>-1||e.indexOf("none")>-1?O.fromMatrix(e):O.fromString(e)},O.fromMatrix=function(e){var t=e.substring(7).split(",");return t.length&&"none"!==e||(t=[1,0,0,1,0,0]),new O(c(t[4]),c(t[5]),parseFloat(t[0]))},O.fromString=function(e){var t=e.split(") "),n=t[0].substring(_.globals.translate.length+1).split(","),i=t.length>1?t[1].substring(6):1,o=n.length>1?n[0]:0,r=n.length>1?n[1]:0;return new O(o,r,i)},O.prototype.toString=function(){var e=$[_.globals.translate].suffix||"";return _.globals.translate+"("+this.x+"px, "+this.y+"px"+e+") scale("+this.scale+")"};var z=function(e){if(!e||!e.style[M])return this.x=0,void(this.y=0);var t=e.style[M].split(" ");this.x=parseFloat(t[0]),this.y=parseFloat(t[1])};z.prototype.toString=function(){return this.x+"px "+this.y+"px"};var A=function(e,t,n){var i;return function(){var o=this,r=arguments,a=n&&!i;clearTimeout(i),i=setTimeout(function(){i=null,n||e.apply(o,r)},t),a&&e.apply(o,r)}}(g,500),Z={type:"canvas",format:"png",quality:1},F=["jpeg","webp","png"];if(window.jQuery){var j=window.jQuery;j.fn.croppie=function(e){if("string"===typeof e){var t=Array.prototype.slice.call(arguments,1),n=j(this).data("croppie");return"get"===e?n.get():"result"===e?n.result.apply(n,t):"bind"===e?n.bind.apply(n,t):this.each(function(){var n=j(this).data("croppie");if(n){var i=n[e];if(!j.isFunction(i))throw"Croppie "+e+" method not found";i.apply(n,t),"destroy"===e&&j(this).removeData("croppie")}})}return this.each(function(){var t=new _(this,e);t.$=j,j(this).data("croppie",t)})}}_.defaults={viewport:{width:100,height:100,type:"square"},boundary:{},orientationControls:{enabled:!0,leftClass:"",rightClass:""},resizeControls:{width:!0,height:!0},customClass:"",showZoomer:!0,enableZoom:!0,enableResize:!1,mouseWheelZoom:!0,enableExif:!1,enforceBoundary:!0,enableOrientation:!1,enableKeyMovement:!0,update:function(){}},_.globals={translate:"translate3d"},o(_.prototype,{bind:function(e,t){return C.call(this,e,t)},get:function(){var e=T.call(this),t=e.points;return this.options.relative&&(t[0]/=this.elements.img.naturalWidth/100,t[1]/=this.elements.img.naturalHeight/100,t[2]/=this.elements.img.naturalWidth/100,t[3]/=this.elements.img.naturalHeight/100),e},result:function(e){return I.call(this,e)},refresh:function(){return function(){y.call(this)}.call(this)},setZoom:function(e){d.call(this,e),r(this.elements.zoomer)},rotate:function(e){(function(e){if(!this.options.useCanvas)throw"Croppie: Cannot rotate without enableOrientation";var t=this.elements.canvas,n=document.createElement("canvas"),i=1;n.width=t.width,n.height=t.height,n.getContext("2d").drawImage(t,0,0),90!==e&&-270!==e||(i=6),-90!==e&&270!==e||(i=8),180!==e&&-180!==e||(i=3),u(t,n,i),m.call(this),n=null}).call(this,e)},destroy:function(){return function(){this.element.removeChild(this.elements.boundary),function(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(t,"")}(this.element,"croppie-container"),this.options.enableZoom&&this.element.removeChild(this.elements.zoomerWrap),delete this.elements}.call(this)}}),t.Croppie=window.Croppie=_,"object"==typeof e&&e.exports&&(e.exports=_)})}).call(t,n(6).setImmediate)},function(e,t,n){function i(e,t){this._id=e,this._clearFn=t}var o=Function.prototype.apply;t.setTimeout=function(){return new i(o.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new i(o.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(7),t.setImmediate=setImmediate,t.clearImmediate=clearImmediate},function(e,t,n){(function(e,t){!function(e,n){"use strict";function i(e){delete s[e]}function o(e){if(l)setTimeout(o,0,e);else{var t=s[e];if(t){l=!0;try{!function(e){var t=e.callback,i=e.args;switch(i.length){case 0:t();break;case 1:t(i[0]);break;case 2:t(i[0],i[1]);break;case 3:t(i[0],i[1],i[2]);break;default:t.apply(n,i)}}(t)}finally{i(e),l=!1}}}}if(!e.setImmediate){var r,a=1,s={},l=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){o(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?function(){var t="setImmediate$"+Math.random()+"$",n=function(n){n.source===e&&"string"==typeof n.data&&0===n.data.indexOf(t)&&o(+n.data.slice(t.length))};e.addEventListener?e.addEventListener("message",n,!1):e.attachEvent("onmessage",n),r=function(n){e.postMessage(t+n,"*")}}():e.MessageChannel?function(){var e=new MessageChannel;e.port1.onmessage=function(e){o(e.data)},r=function(t){e.port2.postMessage(t)}}():c&&"onreadystatechange"in c.createElement("script")?function(){var e=c.documentElement;r=function(t){var n=c.createElement("script");n.onreadystatechange=function(){o(t),n.onreadystatechange=null,e.removeChild(n),n=null},e.appendChild(n)}}():r=function(e){setTimeout(o,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return s[a]=i,r(a),a++},u.clearImmediate=i}}("undefined"==typeof self?void 0===e?this:e:self)}).call(t,n(8),n(9))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function r(){m&&p&&(m=!1,p.length?d=p.concat(d):f=-1,d.length&&a())}function a(){if(!m){var e=o(r);m=!0;for(var t=d.length;t;){for(p=d,d=[];++f<t;)p&&p[f].run();f=-1,t=d.length}p=null,m=!1,function(e){if(u===clearTimeout)return clearTimeout(e);if((u===i||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{u(e)}catch(t){try{return u.call(null,e)}catch(t){return u.call(this,e)}}}(e)}}function s(e,t){this.fun=e,this.array=t}function l(){}var c,u,h=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:n}catch(e){c=n}try{u="function"==typeof clearTimeout?clearTimeout:i}catch(e){u=i}}();var p,d=[],m=!1,f=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];d.push(new s(e,t)),1!==d.length||m||o(a)},s.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(e,t){e.exports='<div class="photoContainer"\n ng-class="{\'photoCircle\': $ctrl.type == \'circle\'}"\n ng-style="{ width: $ctrl.width + \'px\', height: $ctrl.height + \'px\' }">\n\n <img data-action="zoom" \n ng-src="{{$ctrl.image ? $ctrl.image : $ctrl.defaultAvatar}}"\n ng-class="{\'photoCircle\': $ctrl.type == \'circle\'}"\n ng-style="{ width: ($ctrl.width - 10) + \'px\', height: ($ctrl.height - 10) + \'px\' }"/>\n\n <input type="file" \n name="picker" \n accept="image/x-png,image/gif,image/jpeg"/>\n\n <div class="photoPicker" \n ng-style="{ width: $ctrl.type == \'circle\' ? ($ctrl.width - 30) + \'px\' : ($ctrl.width - 10) + \'px\' }" \n ng-class="{\'circle\' : $ctrl.type == \'circle\'}"\n data-ng-click="$ctrl.chooseImage()">\n <i class="fa fa-camera" aria-hidden="true"></i>\n {{$ctrl.pickerText ? $ctrl.pickerText : \'Atualizar foto\'}}\n </div>\n\n</div>'},function(e,t){e.exports='<div class="modal-heading">\n\n <label>{{$ctrl.cropTitle ? $ctrl.cropTitle : \'Criar novo recorte\'}}</label>\n\n</div>\n\n<div class="modal-footer">\n <div class="row">\n <div class="col-md-12">\n\n <button class="cancel" data-ng-click="$ctrl.close()">Cancelar</button>\n <button class="crop-btn" data-ng-click="$ctrl.save()">Salvar</button>\n\n </div>\n </div>\n</div>\n\n<div class="modal-body">\n\n <div id="cropElem" ng-init="$ctrl.createCrop()"></div>\n\n\n <div class="footer">\n\n </div>\n\n</div>'}]); | ||
!function(e){function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="dist",t(t.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=n(1);window.angular.module("gumga.avatar",[]).component("gumgaAvatar",i.a)},function(e,t,n){"use strict";var i=n(2),o=(n.n(i),n(3)),r={bindings:{height:"@?",width:"@?",ngModel:"=",pickerText:"@?",cropTitle:"@?",defaultAvatar:"@?",type:"@?",useGumgaImage:"=?"},template:n(10),controller:["$timeout","$attrs","$element","$uibModal","$scope",function(e,t,i,r,a){var s=this;s.$onInit=function(){e(function(){s.width=s.width||170,s.height=s.height||170,s.useGumgaImage=s.useGumgaImage||!1,s.type=s.type||"square",s.input=i.find('input[type="file"]'),s.input.change(function(e){return s.changeImage(e)}),s.initImage(),a.$watch("$ctrl.ngModel",function(){s.initImage()});var e=i.find("img");e.bind("error",function(){return e.css({display:"none"})}),e.bind("load",function(){return e.css({display:"block"})})})},s.initImage=function(){s.ngModel&&s.useGumgaImage&&(s.image="data:"+s.ngModel.mimeType+";base64,"+s.ngModel.bytes),s.ngModel&&!s.useGumgaImage&&(s.image=s.ngModel)},s.chooseImage=function(){s.input&&s.input[0]?s.input.click():(s.input=i.find('input[type="file"]'),s.input.click())},s.changeImage=function(e){if(s.input[0].files&&s.input[0].files[0]){var t=s.input[0].files[0],n=new FileReader;n.readAsDataURL(t),n.onload=function(e){s.input[0].value="",s.openModalCropImage(e.target.result)}}},s.setPicture=function(e){if(e&&s.useGumgaImage){s.image=e;var t=e.substring(e.indexOf(":")+1,e.indexOf(";")),n={mimeType:t,name:"picture."+t.substring(t.lastIndexOf("/")+1,t.length),bytes:e.substring(e.indexOf(",")+1,e.length),size:Math.round(6*e.length/8)};s.ngModel=n}e&&!s.useGumgaImage&&(s.image=e,s.ngModel=e)},s.openModalCropImage=function(e){r.open({template:n(11),controller:o.a,controllerAs:"$ctrl",backdrop:"static",openedClass:"gumga-avatar",size:"md",resolve:{image:function(){return e},cropTitle:function(){return s.cropTitle},width:function(){return s.width},height:function(){return s.height},type:function(){return s.type}}}).result.then(function(e){e&&s.setPicture(e)})}}]};t.a=r},function(e,t){},function(e,t,n){"use strict";var i=n(4),o=(n.n(i),n(5)),r=n.n(o),a=["image","$uibModalInstance","cropTitle","width","height","type",function(e,t,n,i,o,a){var s=this;s.$onInit=function(){s.cropTitle=n},s.close=function(){t.close()},s.createCrop=function(){s.crop=new r.a(document.getElementById("cropElem"),{viewport:{width:i,height:o,type:a},showZoomer:!0,enableOrientation:!0}),s.crop.bind({url:e})},s.save=function(){s.crop.result().then(function(e){t.close(e)})}}];t.a=a},function(e,t){},function(e,t,n){(function(n){var i,o,r;!function(n,a){o=[t],void 0===(r="function"==typeof(i=a)?i.apply(t,o):i)||(e.exports=r)}(0,function(t){function i(e){if(e in R)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=$.length;n--;)if((e=$[n]+t)in R)return e}function o(e,t){e=e||{};for(var n in t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},o(e[n],t[n])):e[n]=t[n];return e}function r(e){if("createEvent"in document){var t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0),e.dispatchEvent(t)}else e.fireEvent("onchange")}function a(e,t,n){if("string"==typeof t){var i=t;(t={})[i]=n}for(var o in t)e.style[o]=t[o]}function s(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function l(e,t){for(var n in t)e.setAttribute(n,t[n])}function c(e){return parseInt(e,10)}function u(e,t,n){var i=t.width,o=t.height,r=e.getContext("2d");switch(e.width=t.width,e.height=t.height,r.save(),n){case 2:r.translate(i,0),r.scale(-1,1);break;case 3:r.translate(i,o),r.rotate(180*Math.PI/180);break;case 4:r.translate(0,o),r.scale(1,-1);break;case 5:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.scale(1,-1);break;case 6:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.translate(0,-o);break;case 7:e.width=o,e.height=i,r.rotate(-90*Math.PI/180),r.translate(-i,o),r.scale(1,-1);break;case 8:e.width=o,e.height=i,r.translate(0,i),r.rotate(-90*Math.PI/180)}r.drawImage(t,0,0,i,o),r.restore()}function h(){var e,t,n,i,o,c=this.options.viewport.type?"cr-vp-"+this.options.viewport.type:null;this.options.useCanvas=this.options.enableOrientation||p.call(this),this.data={},this.elements={},e=this.elements.boundary=document.createElement("div"),t=this.elements.viewport=document.createElement("div"),this.elements.img=document.createElement("img"),n=this.elements.overlay=document.createElement("div"),this.options.useCanvas?(this.elements.canvas=document.createElement("canvas"),this.elements.preview=this.elements.canvas):this.elements.preview=this.elements.img,s(e,"cr-boundary"),e.setAttribute("aria-dropeffect","none"),i=this.options.boundary.width,o=this.options.boundary.height,a(e,{width:i+(isNaN(i)?"":"px"),height:o+(isNaN(o)?"":"px")}),s(t,"cr-viewport"),c&&s(t,c),a(t,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),t.setAttribute("tabindex",0),s(this.elements.preview,"cr-image"),l(this.elements.preview,{alt:"preview","aria-grabbed":"false"}),s(n,"cr-overlay"),this.element.appendChild(e),e.appendChild(this.elements.preview),e.appendChild(t),e.appendChild(n),s(this.element,"croppie-container"),this.options.customClass&&s(this.element,this.options.customClass),function(){function e(e,t){var n=p.elements.preview.getBoundingClientRect(),i=h.y+t,o=h.x+e;p.options.enforceBoundary?(u.top>n.top+t&&u.bottom<n.bottom+t&&(h.y=i),u.left>n.left+e&&u.right<n.right+e&&(h.x=o)):(h.y=i,h.x=o)}function t(e){p.elements.preview.setAttribute("aria-grabbed",e),p.elements.boundary.setAttribute("aria-dropeffect",e?"move":"none")}function n(e){if((void 0===e.button||0===e.button)&&(e.preventDefault(),!m)){if(m=!0,s=e.pageX,l=e.pageY,e.touches){var n=e.touches[0];s=n.pageX,l=n.pageY}t(m),h=O.parse(p.elements.preview),window.addEventListener("mousemove",i),window.addEventListener("touchmove",i),window.addEventListener("mouseup",o),window.addEventListener("touchend",o),document.body.style[k]="none",u=p.elements.viewport.getBoundingClientRect()}}function i(t){t.preventDefault();var n=t.pageX,i=t.pageY;if(t.touches){var o=t.touches[0];n=o.pageX,i=o.pageY}var u=n-s,m=i-l,f={};if("touchmove"==t.type&&t.touches.length>1){var v=t.touches[0],w=t.touches[1],y=Math.sqrt((v.pageX-w.pageX)*(v.pageX-w.pageX)+(v.pageY-w.pageY)*(v.pageY-w.pageY));c||(c=y/p._currentZoom);var b=y/c;return d.call(p,b),void r(p.elements.zoomer)}e(u,m),f[L]=h.toString(),a(p.elements.preview,f),g.call(p),l=i,s=n}function o(){t(m=!1),window.removeEventListener("mousemove",i),window.removeEventListener("touchmove",i),window.removeEventListener("mouseup",o),window.removeEventListener("touchend",o),document.body.style[k]="",f.call(p),v.call(p),c=0}var s,l,c,u,h,p=this,m=!1;p.elements.overlay.addEventListener("mousedown",n),p.elements.viewport.addEventListener("keydown",function(t){var n=37,i=38,o=39,r=40;if(!t.shiftKey||t.keyCode!=i&&t.keyCode!=r){if(p.options.enableKeyMovement&&t.keyCode>=37&&t.keyCode<=40){t.preventDefault();var s=function(e){switch(e){case n:return[1,0];case i:return[0,1];case o:return[-1,0];case r:return[0,-1]}}(t.keyCode);h=O.parse(p.elements.preview),document.body.style[k]="none",u=p.elements.viewport.getBoundingClientRect(),function(t){var n=t[0],i=t[1],o={};e(n,i),o[L]=h.toString(),a(p.elements.preview,o),g.call(p),document.body.style[k]="",f.call(p),v.call(p),c=0}(s)}}else{var l=0;l=t.keyCode==i?parseFloat(p.elements.zoomer.value,10)+parseFloat(p.elements.zoomer.step,10):parseFloat(p.elements.zoomer.value,10)-parseFloat(p.elements.zoomer.step,10),p.setZoom(l)}}),p.elements.overlay.addEventListener("touchstart",n)}.call(this),this.options.enableZoom&&function(){function e(){m.call(n,{value:parseFloat(o.value),origin:new z(n.elements.preview),viewportRect:n.elements.viewport.getBoundingClientRect(),transform:O.parse(n.elements.preview)})}function t(t){var i,o;i=t.wheelDelta?t.wheelDelta/1200:t.deltaY?t.deltaY/1060:t.detail?t.detail/-60:0,o=n._currentZoom+i*n._currentZoom,t.preventDefault(),d.call(n,o),e.call(n)}var n=this,i=n.elements.zoomerWrap=document.createElement("div"),o=n.elements.zoomer=document.createElement("input");s(i,"cr-slider-wrap"),s(o,"cr-slider"),o.type="range",o.step="0.0001",o.value=1,o.style.display=n.options.showZoomer?"":"none",o.setAttribute("aria-label","zoom"),n.element.appendChild(i),i.appendChild(o),n._currentZoom=1;n.elements.zoomer.addEventListener("input",e),n.elements.zoomer.addEventListener("change",e),n.options.mouseWheelZoom&&(n.elements.boundary.addEventListener("mousewheel",t),n.elements.boundary.addEventListener("DOMMouseScroll",t))}.call(this),this.options.enableResize&&function(){function e(e){if((void 0===e.button||0===e.button)&&(e.preventDefault(),!m)){var a=p.elements.overlay.getBoundingClientRect();if(m=!0,o=e.pageX,r=e.pageY,i=-1!==e.currentTarget.className.indexOf("vertical")?"v":"h",l=a.width,c=a.height,e.touches){var s=e.touches[0];o=s.pageX,r=s.pageY}window.addEventListener("mousemove",t),window.addEventListener("touchmove",t),window.addEventListener("mouseup",n),window.addEventListener("touchend",n),document.body.style[k]="none"}}function t(e){var t=e.pageX,n=e.pageY;if(e.preventDefault(),e.touches){var s=e.touches[0];t=s.pageX,n=s.pageY}var u=t-o,h=n-r,m=p.options.viewport.height+h,y=p.options.viewport.width+u;"v"===i&&m>=w&&m<=c?(a(d,{height:m+"px"}),p.options.boundary.height+=h,a(p.elements.boundary,{height:p.options.boundary.height+"px"}),p.options.viewport.height+=h,a(p.elements.viewport,{height:p.options.viewport.height+"px"})):"h"===i&&y>=w&&y<=l&&(a(d,{width:y+"px"}),p.options.boundary.width+=u,a(p.elements.boundary,{width:p.options.boundary.width+"px"}),p.options.viewport.width+=u,a(p.elements.viewport,{width:p.options.viewport.width+"px"})),g.call(p),b.call(p),f.call(p),v.call(p),r=n,o=t}function n(){m=!1,window.removeEventListener("mousemove",t),window.removeEventListener("touchmove",t),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),document.body.style[k]=""}var i,o,r,l,c,u,h,p=this,d=document.createElement("div"),m=!1,w=50;s(d,"cr-resizer"),a(d,{width:this.options.viewport.width+"px",height:this.options.viewport.height+"px"}),this.options.resizeControls.height&&(s(u=document.createElement("div"),"cr-resizer-vertical"),d.appendChild(u));this.options.resizeControls.width&&(s(h=document.createElement("div"),"cr-resizer-horisontal"),d.appendChild(h));u&&u.addEventListener("mousedown",e);h&&h.addEventListener("mousedown",e);this.elements.boundary.appendChild(d)}.call(this)}function p(){return this.options.enableExif&&window.EXIF}function d(e){if(this.options.enableZoom){var t=this.elements.zoomer,n=E(e,4);t.value=Math.max(t.min,Math.min(t.max,n))}}function m(e){function t(){var e={};e[L]=i.toString(),e[M]=r.toString(),a(n.elements.preview,e)}var n=this,i=e?e.transform:O.parse(n.elements.preview),o=e?e.viewportRect:n.elements.viewport.getBoundingClientRect(),r=e?e.origin:new z(n.elements.preview);if(n._currentZoom=e?e.value:n._currentZoom,i.scale=n._currentZoom,n.elements.zoomer.setAttribute("aria-valuenow",n._currentZoom),t(),n.options.enforceBoundary){var s=function(e){var t=this._currentZoom,n=e.width,i=e.height,o=this.elements.boundary.clientWidth/2,r=this.elements.boundary.clientHeight/2,a=this.elements.preview.getBoundingClientRect(),s=a.width,l=a.height,c=n/2,u=i/2,h=-1*(c/t-o),p=-1*(u/t-r),d=1/t*c,m=1/t*u;return{translate:{maxX:h,minX:h-(s*(1/t)-n*(1/t)),maxY:p,minY:p-(l*(1/t)-i*(1/t))},origin:{maxX:s*(1/t)-d,minX:d,maxY:l*(1/t)-m,minY:m}}}.call(n,o),l=s.translate,c=s.origin;i.x>=l.maxX&&(r.x=c.minX,i.x=l.maxX),i.x<=l.minX&&(r.x=c.maxX,i.x=l.minX),i.y>=l.maxY&&(r.y=c.minY,i.y=l.maxY),i.y<=l.minY&&(r.y=c.maxY,i.y=l.minY)}t(),A.call(n),v.call(n)}function f(){var e=this._currentZoom,t=this.elements.preview.getBoundingClientRect(),n=this.elements.viewport.getBoundingClientRect(),i=O.parse(this.elements.preview.style[L]),o=new z(this.elements.preview),r=n.top-t.top+n.height/2,s=n.left-t.left+n.width/2,l={},c={};l.y=r/e,l.x=s/e,c.y=(l.y-o.y)*(1-e),c.x=(l.x-o.x)*(1-e),i.x-=c.x,i.y-=c.y;var u={};u[M]=l.x+"px "+l.y+"px",u[L]=i.toString(),a(this.elements.preview,u)}function g(){var e=this.elements.boundary.getBoundingClientRect(),t=this.elements.preview.getBoundingClientRect();a(this.elements.overlay,{width:t.width+"px",height:t.height+"px",top:t.top-e.top+"px",left:t.left-e.left+"px"})}function v(){var e=this.get();if(w.call(this))if(this.options.update.call(this,e),this.$&&"undefined"==typeof Prototype)this.$(this.element).trigger("update",e);else{var t;window.CustomEvent?t=new CustomEvent("update",{detail:e}):(t=document.createEvent("CustomEvent")).initCustomEvent("update",!0,!0,e),this.element.dispatchEvent(t)}}function w(){return this.elements.preview.offsetHeight>0&&this.elements.preview.offsetWidth>0}function y(){var e={},t=this.elements.preview,n=this.elements.preview.getBoundingClientRect(),i=new O(0,0,1),o=new z;w.call(this)&&!this.data.bound&&(this.data.bound=!0,e[L]=i.toString(),e[M]=o.toString(),e.opacity=1,a(t,e),this._originalImageWidth=n.width,this._originalImageHeight=n.height,this.options.enableZoom?b.call(this,!0):this._currentZoom=1,i.scale=this._currentZoom,e[L]=i.toString(),a(t,e),this.data.points.length?function(e){if(4!=e.length)throw"Croppie - Invalid number of points supplied: "+e;var t=e[2]-e[0],n=this.elements.viewport.getBoundingClientRect(),i=this.elements.boundary.getBoundingClientRect(),o={left:n.left-i.left,top:n.top-i.top},r=n.width/t,s=e[1],l=e[0],c=-1*e[1]+o.top,u=-1*e[0]+o.left,h={};h[M]=l+"px "+s+"px",h[L]=new O(u,c,r).toString(),a(this.elements.preview,h),d.call(this,r),this._currentZoom=r}.call(this,this.data.points):function(){var e=this.elements.preview.getBoundingClientRect(),t=this.elements.viewport.getBoundingClientRect(),n=this.elements.boundary.getBoundingClientRect(),i=t.left-n.left,o=t.top-n.top,r=i-(e.width-t.width)/2,s=o-(e.height-t.height)/2,l=new O(r,s,this._currentZoom);a(this.elements.preview,L,l.toString())}.call(this),f.call(this),g.call(this))}function b(e){var t,n,i,o,a=0,s=1.5,l=this.elements.zoomer,c=parseFloat(l.value),u=this.elements.boundary.getBoundingClientRect(),h=this.elements.preview.getBoundingClientRect(),p=this.elements.viewport.getBoundingClientRect();this.options.enforceBoundary&&(i=p.width/(e?h.width:h.width/c),o=p.height/(e?h.height:h.height/c),a=Math.max(i,o)),a>=s&&(s=a+1),l.min=E(a,4),l.max=E(s,4),e&&(n=Math.max(u.width/h.width,u.height/h.height),t=null!==this.data.boundZoom?this.data.boundZoom:n,d.call(this,t)),r(l)}function x(e){var t=e.points,n=c(t[0]),i=c(t[1]),o=c(t[2]),r=c(t[3]),a=o-n,s=r-i,l=e.circle,u=document.createElement("canvas"),h=u.getContext("2d"),p=a,d=s,m=0,f=0,g=p,v=d,w=1;return e.outputWidth&&e.outputHeight&&(g=e.outputWidth,v=e.outputHeight,w=g/p),u.width=g,u.height=v,e.backgroundColor&&(h.fillStyle=e.backgroundColor,h.fillRect(0,0,p,d)),this.options.enforceBoundary||(n<0&&(m=Math.abs(n),n=0),i<0&&(f=Math.abs(i),i=0),o>this._originalImageWidth&&(p=a=this._originalImageWidth-n),r>this._originalImageHeight&&(d=s=this._originalImageHeight-i)),1!==w&&(m*=w,f*=w,p*=w,d*=w),h.drawImage(this.elements.preview,n,i,Math.min(a,this._originalImageWidth),Math.min(s,this._originalImageHeight),m,f,p,d),l&&(h.fillStyle="#fff",h.globalCompositeOperation="destination-in",h.beginPath(),h.arc(p/2,d/2,p/2,0,2*Math.PI,!0),h.closePath(),h.fill()),u}function C(e,t){var n,i=this,o=[],r=null,a=p.call(i);if("string"==typeof e)n=e,e={};else if(Array.isArray(e))o=e.slice();else{if(void 0===e&&i.data.url)return y.call(i),v.call(i),null;n=e.url,o=e.points||[],r=void 0===e.zoom?null:e.zoom}return i.data.bound=!1,i.data.url=n||i.data.url,i.data.boundZoom=r,function(e,t,n){var i=t||new Image;return i.style.opacity=0,new Promise(function(t){function o(){setTimeout(function(){t(i)},1)}i.src!==e?(i.exifdata=null,i.removeAttribute("crossOrigin"),e.match(/^https?:\/\/|^\/\//)&&i.setAttribute("crossOrigin","anonymous"),i.onload=function(){n?EXIF.getData(i,function(){o()}):o()},i.src=e):o()})}(n,i.elements.img,a).then(function(n){if(o.length)i.options.relative&&(o=[o[0]*n.naturalWidth/100,o[1]*n.naturalHeight/100,o[2]*n.naturalWidth/100,o[3]*n.naturalHeight/100]);else{var r,a,s=function(e){var t=e.naturalWidth,n=e.naturalHeight;if(e.exifdata&&e.exifdata.Orientation>=5){var i=t;t=n,n=i}return{width:t,height:n}}(n),l=i.elements.viewport.getBoundingClientRect(),h=l.width/l.height;s.width/s.height>h?r=(a=s.height)*h:a=(r=s.width)/h;var d=(s.width-r)/2,m=(s.height-a)/2,f=d+r,g=m+a;i.data.points=[d,m,f,g]}i.data.points=o.map(function(e){return parseFloat(e)}),i.options.useCanvas&&function(e){var t=this.elements.canvas,n=this.elements.img,i=t.getContext("2d"),o=p.call(this);e=this.options.enableOrientation&&e,i.clearRect(0,0,t.width,t.height),t.width=n.width,t.height=n.height,o&&!e?u(t,n,c(function(e){return e.exifdata.Orientation}(n)||0)):e&&u(t,n,e)}.call(i,e.orientation||1),y.call(i),v.call(i),t&&t()})}function E(e,t){return parseFloat(e).toFixed(t||0)}function I(){var e=this.elements.preview.getBoundingClientRect(),t=this.elements.viewport.getBoundingClientRect(),n=t.left-e.left,i=t.top-e.top,o=(t.width-this.elements.viewport.offsetWidth)/2,r=(t.height-this.elements.viewport.offsetHeight)/2,a=n+this.elements.viewport.offsetWidth+o,s=i+this.elements.viewport.offsetHeight+r,l=this._currentZoom;(l===1/0||isNaN(l))&&(l=1);var c=this.options.enforceBoundary?0:Number.NEGATIVE_INFINITY;return n=Math.max(c,n/l),i=Math.max(c,i/l),a=Math.max(c,a/l),s=Math.max(c,s/l),{points:[E(n),E(i),E(a),E(s)],zoom:l}}function T(e){var t=this,n=I.call(t),i=o(Z,o({},e)),r="string"==typeof e?e:i.type||"base64",l=i.size||"viewport",c=i.format,u=i.quality,h=i.backgroundColor,p="boolean"==typeof i.circle?i.circle:"circle"===t.options.viewport.type,d=t.elements.viewport.getBoundingClientRect(),m=d.width/d.height;return"viewport"===l?(n.outputWidth=d.width,n.outputHeight=d.height):"object"==typeof l&&(l.width&&l.height?(n.outputWidth=l.width,n.outputHeight=l.height):l.width?(n.outputWidth=l.width,n.outputHeight=l.width/m):l.height&&(n.outputWidth=l.height*m,n.outputHeight=l.height)),F.indexOf(c)>-1&&(n.format="image/"+c,n.quality=u),n.circle=p,n.url=t.data.url,n.backgroundColor=h,new Promise(function(e,i){switch(r.toLowerCase()){case"rawcanvas":e(x.call(t,n));break;case"canvas":case"base64":e(function(e){return x.call(this,e).toDataURL(e.format,e.quality)}.call(t,n));break;case"blob":(function(e){var t=this;return new Promise(function(n,i){x.call(t,e).toBlob(function(e){n(e)},e.format,e.quality)})}).call(t,n).then(e);break;default:e(function(e){var t=e.points,n=document.createElement("div"),i=document.createElement("img"),o=t[2]-t[0],r=t[3]-t[1];return s(n,"croppie-result"),n.appendChild(i),a(i,{left:-1*t[0]+"px",top:-1*t[1]+"px"}),i.src=e.url,a(n,{width:o+"px",height:r+"px"}),n}.call(t,n))}})}function _(e,t){if(this.element=e,this.options=o(o({},_.defaults),t),"img"===this.element.tagName.toLowerCase()){var n=this.element;s(n,"cr-original-image"),l(n,{"aria-hidden":"true",alt:""});var i=document.createElement("div");this.element.parentNode.appendChild(i),i.appendChild(n),this.element=i,this.options.url=this.options.url||n.src}if(h.call(this),this.options.url){var r={url:this.options.url,points:this.options.points};delete this.options.url,delete this.options.points,C.call(this,r)}}"function"!=typeof Promise&&function(t){function i(e,t){return function(){e.apply(t,arguments)}}function o(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],c(e,i(a,this),i(s,this))}function r(e){var t=this;return null===this._state?void this._deferreds.push(e):void h(function(){var n=t._state?e.onFulfilled:e.onRejected;if(null!==n){var i;try{i=n(t._value)}catch(t){return void e.reject(t)}e.resolve(i)}else(t._state?e.resolve:e.reject)(t._value)})}function a(e){try{if(e===this)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if("function"==typeof t)return void c(i(t,e),i(a,this),i(s,this))}this._state=!0,this._value=e,l.call(this)}catch(e){s.call(this,e)}}function s(e){this._state=!1,this._value=e,l.call(this)}function l(){for(var e=0,t=this._deferreds.length;t>e;e++)r.call(this,this._deferreds[e]);this._deferreds=null}function c(e,t,n){var i=!1;try{e(function(e){i||(i=!0,t(e))},function(e){i||(i=!0,n(e))})}catch(e){if(i)return;i=!0,n(e)}}var u=setTimeout,h="function"==typeof n&&n||function(e){u(e,1)},p=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){var n=this;return new o(function(i,o){r.call(n,new function(e,t,n,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=i}(e,t,i,o))})},o.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&p(arguments[0])?arguments[0]:arguments);return new o(function(t,n){function i(r,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){i(r,e)},n)}e[r]=a,0==--o&&t(e)}catch(e){n(e)}}if(0===e.length)return t([]);for(var o=e.length,r=0;r<e.length;r++)i(r,e[r])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(t){t(e)})},o.reject=function(e){return new o(function(t,n){n(e)})},o.race=function(e){return new o(function(t,n){for(var i=0,o=e.length;o>i;i++)e[i].then(t,n)})},o._setImmediateFn=function(e){h=e},void 0!==e&&e.exports?e.exports=o:t.Promise||(t.Promise=o)}(this),"function"!=typeof window.CustomEvent&&function(){function e(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}e.prototype=window.Event.prototype,window.CustomEvent=e}(),HTMLCanvasElement.prototype.toBlob||Object.defineProperty(HTMLCanvasElement.prototype,"toBlob",{value:function(e,t,n){for(var i=atob(this.toDataURL(t,n).split(",")[1]),o=i.length,r=new Uint8Array(o),a=0;a<o;a++)r[a]=i.charCodeAt(a);e(new Blob([r],{type:t||"image/png"}))}});var M,L,k,$=["Webkit","Moz","ms"],R=document.createElement("div").style;L=i("transform"),M=i("transformOrigin"),k=i("userSelect");var B={translate3d:{suffix:", 0px"},translate:{suffix:""}},O=function(e,t,n){this.x=parseFloat(e),this.y=parseFloat(t),this.scale=parseFloat(n)};O.parse=function(e){return e.style?O.parse(e.style[L]):e.indexOf("matrix")>-1||e.indexOf("none")>-1?O.fromMatrix(e):O.fromString(e)},O.fromMatrix=function(e){var t=e.substring(7).split(",");return t.length&&"none"!==e||(t=[1,0,0,1,0,0]),new O(c(t[4]),c(t[5]),parseFloat(t[0]))},O.fromString=function(e){var t=e.split(") "),n=t[0].substring(_.globals.translate.length+1).split(","),i=t.length>1?t[1].substring(6):1,o=n.length>1?n[0]:0,r=n.length>1?n[1]:0;return new O(o,r,i)},O.prototype.toString=function(){var e=B[_.globals.translate].suffix||"";return _.globals.translate+"("+this.x+"px, "+this.y+"px"+e+") scale("+this.scale+")"};var z=function(e){if(!e||!e.style[M])return this.x=0,void(this.y=0);var t=e.style[M].split(" ");this.x=parseFloat(t[0]),this.y=parseFloat(t[1])};z.prototype.toString=function(){return this.x+"px "+this.y+"px"};var A=function(e,t,n){var i;return function(){var o=this,r=arguments,a=n&&!i;clearTimeout(i),i=setTimeout(function(){i=null,n||e.apply(o,r)},t),a&&e.apply(o,r)}}(g,500),Z={type:"canvas",format:"png",quality:1},F=["jpeg","webp","png"];if(window.jQuery){var j=window.jQuery;j.fn.croppie=function(e){if("string"===typeof e){var t=Array.prototype.slice.call(arguments,1),n=j(this).data("croppie");return"get"===e?n.get():"result"===e?n.result.apply(n,t):"bind"===e?n.bind.apply(n,t):this.each(function(){var n=j(this).data("croppie");if(n){var i=n[e];if(!j.isFunction(i))throw"Croppie "+e+" method not found";i.apply(n,t),"destroy"===e&&j(this).removeData("croppie")}})}return this.each(function(){var t=new _(this,e);t.$=j,j(this).data("croppie",t)})}}_.defaults={viewport:{width:100,height:100,type:"square"},boundary:{},orientationControls:{enabled:!0,leftClass:"",rightClass:""},resizeControls:{width:!0,height:!0},customClass:"",showZoomer:!0,enableZoom:!0,enableResize:!1,mouseWheelZoom:!0,enableExif:!1,enforceBoundary:!0,enableOrientation:!1,enableKeyMovement:!0,update:function(){}},_.globals={translate:"translate3d"},o(_.prototype,{bind:function(e,t){return C.call(this,e,t)},get:function(){var e=I.call(this),t=e.points;return this.options.relative&&(t[0]/=this.elements.img.naturalWidth/100,t[1]/=this.elements.img.naturalHeight/100,t[2]/=this.elements.img.naturalWidth/100,t[3]/=this.elements.img.naturalHeight/100),e},result:function(e){return T.call(this,e)},refresh:function(){return function(){y.call(this)}.call(this)},setZoom:function(e){d.call(this,e),r(this.elements.zoomer)},rotate:function(e){(function(e){if(!this.options.useCanvas)throw"Croppie: Cannot rotate without enableOrientation";var t=this.elements.canvas,n=document.createElement("canvas"),i=1;n.width=t.width,n.height=t.height,n.getContext("2d").drawImage(t,0,0),90!==e&&-270!==e||(i=6),-90!==e&&270!==e||(i=8),180!==e&&-180!==e||(i=3),u(t,n,i),m.call(this),n=null}).call(this,e)},destroy:function(){return function(){this.element.removeChild(this.elements.boundary),function(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(t,"")}(this.element,"croppie-container"),this.options.enableZoom&&this.element.removeChild(this.elements.zoomerWrap),delete this.elements}.call(this)}}),t.Croppie=window.Croppie=_,"object"==typeof e&&e.exports&&(e.exports=_)})}).call(t,n(6).setImmediate)},function(e,t,n){function i(e,t){this._id=e,this._clearFn=t}var o=Function.prototype.apply;t.setTimeout=function(){return new i(o.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new i(o.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n(7),t.setImmediate=setImmediate,t.clearImmediate=clearImmediate},function(e,t,n){(function(e,t){!function(e,n){"use strict";function i(e){delete s[e]}function o(e){if(l)setTimeout(o,0,e);else{var t=s[e];if(t){l=!0;try{!function(e){var t=e.callback,i=e.args;switch(i.length){case 0:t();break;case 1:t(i[0]);break;case 2:t(i[0],i[1]);break;case 3:t(i[0],i[1],i[2]);break;default:t.apply(n,i)}}(t)}finally{i(e),l=!1}}}}if(!e.setImmediate){var r,a=1,s={},l=!1,c=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,"[object process]"==={}.toString.call(e.process)?r=function(e){t.nextTick(function(){o(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=n,t}}()?function(){var t="setImmediate$"+Math.random()+"$",n=function(n){n.source===e&&"string"==typeof n.data&&0===n.data.indexOf(t)&&o(+n.data.slice(t.length))};e.addEventListener?e.addEventListener("message",n,!1):e.attachEvent("onmessage",n),r=function(n){e.postMessage(t+n,"*")}}():e.MessageChannel?function(){var e=new MessageChannel;e.port1.onmessage=function(e){o(e.data)},r=function(t){e.port2.postMessage(t)}}():c&&"onreadystatechange"in c.createElement("script")?function(){var e=c.documentElement;r=function(t){var n=c.createElement("script");n.onreadystatechange=function(){o(t),n.onreadystatechange=null,e.removeChild(n),n=null},e.appendChild(n)}}():r=function(e){setTimeout(o,0,e)},u.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),n=0;n<t.length;n++)t[n]=arguments[n+1];var i={callback:e,args:t};return s[a]=i,r(a),a++},u.clearImmediate=i}}("undefined"==typeof self?void 0===e?this:e:self)}).call(t,n(8),n(9))},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function r(){m&&p&&(m=!1,p.length?d=p.concat(d):f=-1,d.length&&a())}function a(){if(!m){var e=o(r);m=!0;for(var t=d.length;t;){for(p=d,d=[];++f<t;)p&&p[f].run();f=-1,t=d.length}p=null,m=!1,function(e){if(u===clearTimeout)return clearTimeout(e);if((u===i||!u)&&clearTimeout)return u=clearTimeout,clearTimeout(e);try{u(e)}catch(t){try{return u.call(null,e)}catch(t){return u.call(this,e)}}}(e)}}function s(e,t){this.fun=e,this.array=t}function l(){}var c,u,h=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:n}catch(e){c=n}try{u="function"==typeof clearTimeout?clearTimeout:i}catch(e){u=i}}();var p,d=[],m=!1,f=-1;h.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];d.push(new s(e,t)),1!==d.length||m||o(a)},s.prototype.run=function(){this.fun.apply(null,this.array)},h.title="browser",h.browser=!0,h.env={},h.argv=[],h.version="",h.versions={},h.on=l,h.addListener=l,h.once=l,h.off=l,h.removeListener=l,h.removeAllListeners=l,h.emit=l,h.prependListener=l,h.prependOnceListener=l,h.listeners=function(e){return[]},h.binding=function(e){throw new Error("process.binding is not supported")},h.cwd=function(){return"/"},h.chdir=function(e){throw new Error("process.chdir is not supported")},h.umask=function(){return 0}},function(e,t){e.exports='<div class="photoContainer"\n ng-class="{\'photoCircle\': $ctrl.type == \'circle\'}"\n ng-style="{ width: $ctrl.width + \'px\', height: $ctrl.height + \'px\' }">\n\n <img data-action="zoom" \n ng-src="{{$ctrl.image ? $ctrl.image : $ctrl.defaultAvatar}}"\n ng-class="{\'photoCircle\': $ctrl.type == \'circle\'}"\n ng-style="{ width: ($ctrl.width - 10) + \'px\', height: ($ctrl.height - 10) + \'px\' }"/>\n\n <input type="file" \n name="picker" \n accept="image/x-png,image/gif,image/jpeg"/>\n\n <div class="photoPicker" \n ng-style="{ width: $ctrl.type == \'circle\' ? ($ctrl.width - 30) + \'px\' : ($ctrl.width - 10) + \'px\' }" \n ng-class="{\'circle\' : $ctrl.type == \'circle\'}"\n data-ng-click="$ctrl.chooseImage()">\n <i class="fa fa-camera" aria-hidden="true"></i>\n {{$ctrl.pickerText ? $ctrl.pickerText : \'Atualizar foto\'}}\n </div>\n\n</div>'},function(e,t){e.exports='<div class="modal-heading">\n\n <label>{{$ctrl.cropTitle ? $ctrl.cropTitle : \'Criar novo recorte\'}}</label>\n\n</div>\n\n<div class="modal-footer">\n <div class="row">\n <div class="col-md-12">\n\n <button class="cancel" data-ng-click="$ctrl.close()">Cancelar</button>\n <button class="crop-btn" data-ng-click="$ctrl.save()">Salvar</button>\n\n </div>\n </div>\n</div>\n\n<div class="modal-body">\n\n <div id="cropElem" ng-init="$ctrl.createCrop()"></div>\n\n\n <div class="footer">\n\n </div>\n\n</div>'}]); |
{ | ||
"name": "gumga-avatar-ng", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "webpack.config.js", |
@@ -18,3 +18,3 @@ declare function require(name: string); | ||
template: require('./component.html'), | ||
controller: ['$timeout', '$attrs', '$element', '$uibModal', function ($timeout, $attrs, $element, $uibModal) { | ||
controller: ['$timeout', '$attrs', '$element', '$uibModal', '$scope', function ($timeout, $attrs, $element, $uibModal, $scope) { | ||
let ctrl = this; | ||
@@ -30,11 +30,25 @@ | ||
ctrl.input.change((evt) => ctrl.changeImage(evt)); | ||
if(ctrl.ngModel && ctrl.useGumgaImage){ | ||
ctrl.image = 'data:' + ctrl.ngModel.mimeType + ';base64,' + ctrl.ngModel.bytes; | ||
} | ||
if(ctrl.ngModel && !ctrl.useGumgaImage){ | ||
ctrl.image = ctrl.ngModel; | ||
} | ||
ctrl.initImage(); | ||
$scope.$watch('$ctrl.ngModel', () => { | ||
ctrl.initImage(); | ||
}) | ||
let img = $element.find('img'); | ||
img.bind('error', () => img.css({'display' : 'none'})); | ||
img.bind('load', () => img.css({'display' : 'block'})); | ||
}); | ||
} | ||
ctrl.initImage = () => { | ||
if(ctrl.ngModel && ctrl.useGumgaImage){ | ||
ctrl.image = 'data:' + ctrl.ngModel.mimeType + ';base64,' + ctrl.ngModel.bytes; | ||
} | ||
if(ctrl.ngModel && !ctrl.useGumgaImage){ | ||
ctrl.image = ctrl.ngModel; | ||
} | ||
} | ||
ctrl.chooseImage = () => { | ||
@@ -41,0 +55,0 @@ if(ctrl.input && ctrl.input[0]){ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
230718
883