/*! Jcrop.js v2.0.4 - build: 20151117 * @copyright 2008-2015 Tapmodo Interactive LLC * @license Free software under MIT License * @website http://jcrop.org/ **/ !function(a){"use strict";var b=function(c,d){var e=navigator.userAgent.toLowerCase();this.opt=a.extend({},b.defaults,d||{}),this.container=a(c),this.opt.is_msie=/msie/.test(e),this.opt.is_ie_lt9=/msie [1-8]\./.test(e),this.container.addClass(this.opt.css_container),this.ui={},this.state=null,this.ui.multi=[],this.ui.selection=null,this.filter={},this.init(),this.setOptions(d),this.applySizeConstraints(),this.container.trigger("cropinit",this),this.opt.is_ie_lt9&&(this.opt.dragEventTarget=document.body)};a.extend(b,{"component":{},"filter":{},"stage":{},"registerComponent":function(a,c){b.component[a]=c},"registerFilter":function(a,c){b.filter[a]=c},"registerStageType":function(a,c){b.stage[a]=c},"attach":function(b,c){var d=new a.Jcrop(b,c);return d},"imgCopy":function(a){var b=new Image;return b.src=a.src,b},"imageClone":function(c){return a.Jcrop.supportsCanvas?b.canvasClone(c):b.imgCopy(c)},"canvasClone":function(b){var c=document.createElement("canvas"),d=c.getContext("2d");return a(c).width(b.width).height(b.height),c.width=b.naturalWidth,c.height=b.naturalHeight,d.drawImage(b,0,0,b.naturalWidth,b.naturalHeight),c},"propagate":function(a,b,c){for(var d=0,e=a.length;e>d;d++)b.hasOwnProperty(a[d])&&(c[a[d]]=b[a[d]])},"getLargestBox":function(a,b,c){return b/c>a?[c*a,c]:[b,b/a]},"stageConstructor":function(c,d,e){var f=[];a.each(b.stage,function(a,b){f.push(b)}),f.sort(function(a,b){return a.priority-b.priority});for(var g=0,h=f.length;h>g;g++)if(f[g].isSupported(c,d)){f[g].create(c,d,function(a,b){"function"==typeof e&&e(a,b)});break}},"supportsColorFade":function(){return a.fx.step.hasOwnProperty("backgroundColor")},"wrapFromXywh":function(a){var b={"x":a[0],"y":a[1],"w":a[2],"h":a[3]};return b.x2=b.x+b.w,b.y2=b.y+b.h,b}});var c=function(){};a.extend(c,{"isSupported":function(a,b){return!0},"priority":100,"create":function(a,b,d){var e=new c;e.element=a,d.call(this,e,b)},"prototype":{"attach":function(a){this.init(a),a.ui.stage=this},"triggerEvent":function(b){return a(this.element).trigger(b),this},"getElement":function(){return this.element}}}),b.registerStageType("Block",c);var d=function(){};d.prototype=new c,a.extend(d,{"isSupported":function(a,b){return"IMG"==a.tagName?!0:void 0},"priority":90,"create":function(b,c,e){a.Jcrop.component.ImageLoader.attach(b,function(f,g){var h=new d;h.element=a(b).wrap("
").parent(),h.element.width(f).height(g),h.imgsrc=b,"function"==typeof e&&e.call(this,h,c)})}}),b.registerStageType("Image",d);var e=function(){this.angle=0,this.scale=1,this.scaleMin=.2,this.scaleMax=1.25,this.offset=[0,0]};e.prototype=new d,a.extend(e,{"isSupported":function(b,c){return a.Jcrop.supportsCanvas&&"IMG"==b.tagName?!0:void 0},"priority":60,"create":function(b,c,d){var f=a(b),g=a.extend({},c);a.Jcrop.component.ImageLoader.attach(b,function(a,c){var h=new e;f.hide(),h.createCanvas(b,a,c),f.before(h.element),h.imgsrc=b,g.imgsrc=b,"function"==typeof d&&(d(h,g),h.redraw())})}}),a.extend(e.prototype,{"init":function(a){this.core=a},"setOffset":function(a,b){return this.offset=[a,b],this},"setAngle":function(a){return this.angle=a,this},"setScale":function(a){return this.scale=this.boundScale(a),this},"boundScale":function(a){return athis.scaleMax&&(a=this.scaleMax),a},"createCanvas":function(b,c,d){this.width=c,this.height=d,this.canvas=document.createElement("canvas"),this.canvas.width=c,this.canvas.height=d,this.$canvas=a(this.canvas).width("100%").height("100%"),this.context=this.canvas.getContext("2d"),this.fillstyle="rgb(0,0,0)",this.element=this.$canvas.wrap("
").parent().width(c).height(d)},"triggerEvent":function(a){return this.$canvas.trigger(a),this},"clear":function(){return this.context.fillStyle=this.fillstyle,this.context.fillRect(0,0,this.canvas.width,this.canvas.height),this},"redraw":function(){return this.context.save(),this.clear(),this.context.translate(parseInt(.5*this.width),parseInt(.5*this.height)),this.context.translate(this.offset[0]/this.core.opt.xscale,this.offset[1]/this.core.opt.yscale),this.context.rotate(this.angle*(Math.PI/180)),this.context.scale(this.scale,this.scale),this.context.translate(-parseInt(.5*this.width),-parseInt(.5*this.height)),this.context.drawImage(this.imgsrc,0,0,this.width,this.height),this.context.restore(),this.$canvas.trigger("cropredraw"),this},"setFillStyle":function(a){return this.fillstyle=a,this}}),b.registerStageType("Canvas",e);var f=function(){this.minw=40,this.minh=40,this.maxw=0,this.maxh=0,this.core=null};a.extend(f.prototype,{"tag":"backoff","priority":22,"filter":function(a){var b=this.bound;return a.xb.maxx&&(a.x2=b.maxx,a.x=a.x2-a.w),a.y2>b.maxy&&(a.y2=b.maxy,a.y=a.y2-a.h),a},"refresh":function(a){this.elw=a.core.container.width(),this.elh=a.core.container.height(),this.bound={"minx":0+a.edge.w,"miny":0+a.edge.n,"maxx":this.elw+a.edge.e,"maxy":this.elh+a.edge.s}}}),b.registerFilter("backoff",f);var g=function(){this.core=null};a.extend(g.prototype,{"tag":"constrain","priority":5,"filter":function(a,b){return"move"==b?(a.xthis.maxx&&(a.x2=this.maxx,a.x=a.x2-a.w),a.y2>this.maxy&&(a.y2=this.maxy,a.y=a.y2-a.h)):(a.xthis.maxx&&(a.x2=this.maxx),a.y2>this.maxy&&(a.y2=this.maxy)),a.w=a.x2-a.x,a.h=a.y2-a.y,a},"refresh":function(a){this.elw=a.core.container.width(),this.elh=a.core.container.height(),this.minx=0+a.edge.w,this.miny=0+a.edge.n,this.maxx=this.elw+a.edge.e,this.maxy=this.elh+a.edge.s}}),b.registerFilter("constrain",g);var h=function(){this.core=null};a.extend(h.prototype,{"tag":"extent","priority":12,"offsetFromCorner":function(a,b,c){var d=b[0],e=b[1];switch(a){case"bl":return[c.x2-d,c.y,d,e];case"tl":return[c.x2-d,c.y2-e,d,e];case"br":return[c.x,c.y,d,e];case"tr":return[c.x,c.y2-e,d,e]}},"getQuadrant":function(a){var b=a.opposite[0]-a.offsetx,c=a.opposite[1]-a.offsety;return 0>b&&0>c?"br":b>=0&&c>=0?"tl":0>b&&c>=0?"tr":"bl"},"filter":function(a,c,d){if("move"==c)return a;var e=a.w,f=a.h,g=d.state,h=this.limits,i=g?this.getQuadrant(g):"br";return h.minw&&eh.maxw&&(e=h.maxw),h.maxh&&f>h.maxh&&(f=h.maxh),e==a.w&&f==a.h?a:b.wrapFromXywh(this.offsetFromCorner(i,[e,f],a))},"refresh":function(a){this.elw=a.core.container.width(),this.elh=a.core.container.height(),this.limits={"minw":a.minSize[0],"minh":a.minSize[1],"maxw":a.maxSize[0],"maxh":a.maxSize[1]}}}),b.registerFilter("extent",h);var i=function(){this.stepx=1,this.stepy=1,this.core=null};a.extend(i.prototype,{"tag":"grid","priority":19,"filter":function(a){var b={"x":Math.round(a.x/this.stepx)*this.stepx,"y":Math.round(a.y/this.stepy)*this.stepy,"x2":Math.round(a.x2/this.stepx)*this.stepx,"y2":Math.round(a.y2/this.stepy)*this.stepy};return b.w=b.x2-b.x,b.h=b.y2-b.y,b}}),b.registerFilter("grid",i);var j=function(){this.ratio=0,this.core=null};a.extend(j.prototype,{"tag":"ratio","priority":15,"offsetFromCorner":function(a,b,c){var d=b[0],e=b[1];switch(a){case"bl":return[c.x2-d,c.y,d,e];case"tl":return[c.x2-d,c.y2-e,d,e];case"br":return[c.x,c.y,d,e];case"tr":return[c.x,c.y2-e,d,e]}},"getBoundRatio":function(a,c){var d=b.getLargestBox(this.ratio,a.w,a.h);return b.wrapFromXywh(this.offsetFromCorner(c,d,a))},"getQuadrant":function(a){var b=a.opposite[0]-a.offsetx,c=a.opposite[1]-a.offsety;return 0>b&&0>c?"br":b>=0&&c>=0?"tl":0>b&&c>=0?"tr":"bl"},"filter":function(a,b,c){if(!this.ratio)return a;var d=(a.w/a.h,c.state),e=d?this.getQuadrant(d):"br";if(b=b||"se","move"==b)return a;switch(b){case"n":a.x2=this.elw,a.w=a.x2-a.x,e="tr";break;case"s":a.x2=this.elw,a.w=a.x2-a.x,e="br";break;case"e":a.y2=this.elh,a.h=a.y2-a.y,e="br";break;case"w":a.y2=this.elh,a.h=a.y2-a.y,e="bl"}return this.getBoundRatio(a,e)},"refresh":function(a){this.ratio=a.aspectRatio,this.elw=a.core.container.width(),this.elh=a.core.container.height()}}),b.registerFilter("ratio",j);var k=function(){this.core=null};a.extend(k.prototype,{"tag":"round","priority":90,"filter":function(a){var b={"x":Math.round(a.x),"y":Math.round(a.y),"x2":Math.round(a.x2),"y2":Math.round(a.y2)};return b.w=b.x2-b.x,b.h=b.y2-b.y,b}}),b.registerFilter("round",k);var l=function(a,b){this.color=b||"black",this.opacity=a||.5,this.core=null,this.shades={}};a.extend(l.prototype,{"tag":"shader","fade":!0,"fadeEasing":"swing","fadeSpeed":320,"priority":95,"init":function(){var b=this;b.attached||(b.visible=!1,b.container=a("
").addClass(b.core.opt.css_shades).prependTo(this.core.container).hide(),b.elh=this.core.container.height(),b.elw=this.core.container.width(),b.shades={"top":b.createShade(),"right":b.createShade(),"left":b.createShade(),"bottom":b.createShade()},b.attached=!0)},"destroy":function(){this.container.remove()},"setColor":function(c,d){var e=this;if(c==e.color)return e;this.color=c;var f=b.supportsColorFade();return a.each(e.shades,function(a,b){e.fade&&!d&&f?b.animate({"backgroundColor":c},{"queue":!1,"duration":e.fadeSpeed,"easing":e.fadeEasing}):b.css("backgroundColor",c)}),e},"setOpacity":function(b,c){var d=this;return b==d.opacity?d:(d.opacity=b,a.each(d.shades,function(a,e){!d.fade||c?e.css({"opacity":b}):e.animate({"opacity":b},{"queue":!1,"duration":d.fadeSpeed,"easing":d.fadeEasing})}),d)},"createShade":function(){return a("
").css({"position":"absolute","backgroundColor":this.color,"opacity":this.opacity}).appendTo(this.container)},"refresh":function(a){var b=this.core,c=this.shades;this.setColor(a.bgColor?a.bgColor:this.core.opt.bgColor),this.setOpacity(a.bgOpacity?a.bgOpacity:this.core.opt.bgOpacity),this.elh=b.container.height(),this.elw=b.container.width(),c.right.css("height",this.elh+"px"),c.left.css("height",this.elh+"px")},"filter":function(a,b,c){if(!c.active)return a;var d=this,e=d.shades;return e.top.css({"left":Math.round(a.x)+"px","width":Math.round(a.w)+"px","height":Math.round(a.y)+"px"}),e.bottom.css({"top":Math.round(a.y2)+"px","left":Math.round(a.x)+"px","width":Math.round(a.w)+"px","height":d.elh-Math.round(a.y2)+"px"}),e.right.css({"left":Math.round(a.x2)+"px","width":d.elw-Math.round(a.x2)+"px"}),e.left.css({"width":Math.round(a.x)+"px"}),d.visible||(d.container.show(),d.visible=!0),a}}),b.registerFilter("shader",l);var m=function(a){this.stage=a,this.core=a.core,this.cloneStagePosition()};m.prototype={"cloneStagePosition":function(){var a=this.stage;this.angle=a.angle,this.scale=a.scale,this.offset=a.offset},"getElement":function(){var b=this.stage;return a("
").css({"position":"absolute","top":b.offset[0]+"px","left":b.offset[1]+"px","width":b.angle+"px","height":b.scale+"px"})},"animate":function(a){var b=this;this.scale=this.stage.boundScale(this.scale),b.stage.triggerEvent("croprotstart"),b.getElement().animate({"top":b.offset[0]+"px","left":b.offset[1]+"px","width":b.angle+"px","height":b.scale+"px"},{"easing":b.core.opt.animEasing,"duration":b.core.opt.animDuration,"complete":function(){b.stage.triggerEvent("croprotend"),"function"==typeof a&&a.call(this)},"progress":function(a){var c,d={},e=a.tweens;for(c=0;c").css({"position":"absolute","top":b.y+"px","left":b.x+"px","width":b.w+"px","height":b.h+"px"})},"animate":function(a,b,c,d,e){var f=this;f.selection.allowResize(!1),f.getElement().animate({"top":b+"px","left":a+"px","width":c+"px","height":d+"px"},{"easing":f.core.opt.animEasing,"duration":f.core.opt.animDuration,"complete":function(){f.selection.allowResize(!0),e&&e.call(this)},"progress":function(a){var b,c={},d=a.tweens;for(b=0;b=0)return!0;switch(d.keyCode){case 37:c.nudge(-e,0);break;case 38:c.nudge(0,-e);break;case 39:c.nudge(e,0);break;case 40:c.nudge(0,e);break;case 46:case 8:return c.requestDelete(),!1;default:b.debug&&console.log("keycode: "+d.keyCode)}d.metaKey||d.ctrlKey||d.preventDefault()})}}}),b.registerComponent("Keyboard",t);var u=function(){};a.extend(u,{"defaults":{"minSize":[8,8],"maxSize":[0,0],"aspectRatio":0,"edge":{"n":0,"s":0,"e":0,"w":0},"bgColor":null,"bgOpacity":null,"last":null,"state":null,"active":!0,"linked":!0,"canDelete":!0,"canDrag":!0,"canResize":!0,"canSelect":!0},"prototype":{"init":function(a){this.core=a,this.startup(),this.linked=this.core.opt.linked,this.attach(),this.setOptions(this.core.opt),a.container.trigger("cropcreate",[this])},"attach":function(){},"startup":function(){var b=this,c=b.core.opt;a.extend(b,u.defaults),b.filter=b.core.getDefaultFilters(),b.element=a("
").addClass(c.css_selection).data({"selection":b}),b.frame=a("