Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

don't listen on window

  • Loading branch information...
commit 89b7c029c3a63abcaab59a30adbbba049a1a020f 1 parent 6167a0f
@caleb authored
Showing with 3 additions and 7 deletions.
  1. +1 −3 lib/stage.coffee
  2. +1 −3 rodeo-crop.js
  3. +1 −1  rodeo-crop.min.js
View
4 lib/stage.coffee
@@ -24,7 +24,6 @@ class Stage extends drawing.Drawable
attachListeners: () ->
window.addEventListener 'mouseup', (e) =>
return unless e.which == 1
- e.preventDefault()
pos = @windowToCanvas e
@@ -38,7 +37,7 @@ class Stage extends drawing.Drawable
@lastMouseMoveTarget = null
@dragTarget = null
- window.addEventListener 'mousedown', (e) =>
+ @canvas.addEventListener 'mousedown', (e) =>
return unless e.which == 1
e.preventDefault()
@@ -52,7 +51,6 @@ class Stage extends drawing.Drawable
@movedSinceMouseDown = false
window.addEventListener 'mousemove', (e) =>
- e.preventDefault()
pos = @windowToCanvas e
target = @findChildAtPoint(pos) || @
View
4 rodeo-crop.js
@@ -1425,7 +1425,6 @@ define("crop-box",
if (e.which !== 1) {
return;
}
- e.preventDefault();
pos = _this.windowToCanvas(e);
target = _this.findChildAtPoint(pos) || _this;
_this.bubbleMouseEvent(target, 'mouseup', e, pos);
@@ -1440,7 +1439,7 @@ define("crop-box",
return _this.dragTarget = null;
};
})(this));
- window.addEventListener('mousedown', (function(_this) {
+ this.canvas.addEventListener('mousedown', (function(_this) {
return function(e) {
var pos, target;
if (e.which !== 1) {
@@ -1458,7 +1457,6 @@ define("crop-box",
return window.addEventListener('mousemove', (function(_this) {
return function(e) {
var pos, target;
- e.preventDefault();
pos = _this.windowToCanvas(e);
target = _this.findChildAtPoint(pos) || _this;
_this.bubbleMouseEvent(target, 'mousemove', e, pos);
View
2  rodeo-crop.min.js
@@ -1 +1 @@
-var define,requireModule,require,requirejs;!function(){var t={},e={};define=function(e,r,i){t[e]={deps:r,callback:i}},requirejs=require=requireModule=function(r){function i(t){if("."!==t.charAt(0))return t;for(var e=t.split("/"),i=r.split("/").slice(0,-1),n=0,s=e.length;s>n;n++){var o=e[n];if(".."===o)i.pop();else{if("."===o)continue;i.push(o)}}return i.join("/")}if(requirejs._eak_seen=t,e.hasOwnProperty(r))return e[r];if(e[r]={},!t[r])throw new Error("Could not find module "+r);for(var n,s=t[r],o=s.deps,h=s.callback,a=[],c=0,u=o.length;u>c;c++)a.push("exports"===o[c]?n={}:requireModule(i(o[c])));var p=h.apply(this,a);return e[r]=n||p}}(),define("crop-box",["funderscore","drawing","exports"],function(t,e,r){"use strict";var i,n=t["default"],s=e["default"],o={}.hasOwnProperty,h=function(t,e){function r(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};i=function(t){function e(t){e.__super__.constructor.call(this,n.extend({dragable:!0},t)),this.image=t.image,this.handleSize=t.handleSize||10,this.screenStyle=t.screenStyle||"rgba(0, 0, 0, .75)",this.topScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.leftScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.rightScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.bottomScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.cropX=t.cropX||0,this.cropY=t.cropY||0,this.cropWidth=t.cropWidth||4*this.handleSize,this.cropHeight=t.cropHeight||4*this.handleSize,this.marchingAnts=t.marchingAnts||!0,this.dashOffset=0,this.dragging=null,this.mouseDown=!1,this.handles={},this.image.on("load",function(t){return function(){return t.setCropFrameAndUpdateFrame(t.cropFrame())}}(this)),this.image.on("crop",function(t){return function(e,r,i){return t.cropX=r.w>=i.w?0:r.x-i.x,t.cropY=r.h>=i.h?0:r.y-i.y,t.cropWidth=r.w>=i.w?i.w:r.w,t.cropHeight=r.h>=i.h?i.h:r.h,t.setCropFrameAndUpdateFrame(t.cropFrame())}}(this)),this.on("mouseout",this.onMouseOut),this.on("mousemove",this.onMouseMove),this.on("mousedown",this.onMouseDown),this.on("mouseup",this.onMouseUp),this.on("dragstart",this.onDragStart),this.on("dragend",this.onDragEnd),this.on("dragmove",this.onDragMove),this.setLooseTheAnts()}return h(e,t),e.prototype.frame=function(){return{x:this.w<0?this.x+this.w:this.x,y:this.h<0?this.y+this.h:this.y,w:Math.abs(this.w),h:Math.abs(this.h)}},e.prototype.cropFrame=function(){return{x:this.cropX,y:this.cropY,width:this.cropWidth,height:this.cropHeight}},e.prototype.updateCropFrameFromFrame=function(){var t,e,r;return t=this.frame(),r=this.image.naturalBounds(),e=this.image.bounds(),this.image.loaded&&(this.cropX=r.w*(t.x/e.w),this.cropY=r.h*(t.y/e.h),this.cropWidth=r.w*(t.w/e.w),this.cropHeight=r.h*(t.h/e.h)),this.trigger("change:cropFrame",this.cropFrame())},e.prototype.setFrameAndUpdateCropArea=function(t){return this.x=t.x,this.y=t.y,this.w=t.w,this.h=t.h,this.updateCropFrameFromFrame(),this.markDirty()},e.prototype.updateFrameFromCropFrame=function(){var t,e;return this.image.loaded?(e=this.image.naturalBounds(),t=this.image.bounds(),this.x=t.w*(this.cropX/e.w),this.y=t.h*(this.cropY/e.h),this.w=t.w*(this.cropWidth/e.w),this.h=t.h*(this.cropHeight/e.h),this.markDirty()):void 0},e.prototype.setCropFrameAndUpdateFrame=function(t){var e,r,i,n,s;return this.image.loaded?(e=this.image.naturalBounds(),n=(null!=t?t.x:void 0)||.125*e.w,s=(null!=t?t.y:void 0)||.125*e.h,i=(null!=t?t.width:void 0)||.75*e.w,r=(null!=t?t.height:void 0)||.75*e.h,this.cropX=Math.min(Math.max(n,0),e.w),this.cropY=Math.min(Math.max(s,0),e.h),this.cropWidth=Math.min(Math.max(i,0),e.w-this.cropX),this.cropHeight=Math.min(Math.max(r,0),e.h-this.cropY),this.updateFrameFromCropFrame()):(this.cropX=null!=t?t.x:void 0,this.cropY=null!=t?t.y:void 0,this.cropWidth=null!=t?t.width:void 0,this.cropHeight=null!=t?t.height:void 0)},e.prototype.bounds=function(){return{x:0,y:0,w:Math.abs(this.w),h:Math.abs(this.h)}},e.prototype.containsCanvasPoint=function(t){var e,r,i,n,s;if(n=this.convertFromCanvas(t),e=this.containsPoint(n))return e;s=this.handles;for(r in s)if(i=s[r],i.containsCanvasPoint(t))return!0;return!1},e.prototype.onMouseOut=function(){return this.canvas.style.cursor="default"},e.prototype.onMouseMove=function(t){var e,r,i,n;if(this.enabled){i=t.canvasPoint,n=this.handles;for(e in n)if(r=n[e],r.containsCanvasPoint(i)){switch(e){case"tl":this.canvas.style.cursor="nw-resize";break;case"tm":this.canvas.style.cursor="n-resize";break;case"tr":this.canvas.style.cursor="ne-resize";break;case"ml":this.canvas.style.cursor="w-resize";break;case"mr":this.canvas.style.cursor="e-resize";break;case"bl":this.canvas.style.cursor="sw-resize";break;case"bm":this.canvas.style.cursor="s-resize";break;case"br":this.canvas.style.cursor="se-resize"}return}return this.canvas.style.cursor="move"}},e.prototype.constrainPointInParent=function(t){return{x:Math.min(Math.max(t.x,0),this.parent.frame().w),y:Math.min(Math.max(t.y,0),this.parent.frame().h)}},e.prototype.onMouseUp=function(){return this.dragging=this.mouseDown=null},e.prototype.onDragStart=function(t){var e,r,i,n,s;n=t.canvasPoint,s=this.handles;for(e in s)if(r=s[e],r.containsCanvasPoint(n))return i=r.convertFromCanvas(n),void(this.dragging={resizeDirection:e,object:r,offsetX:i.x,offsetY:i.y});return i=this.convertFromCanvas(n),this.dragging={object:this,offsetX:i.x,offsetY:i.y}},e.prototype.onDragMove=function(t){var e,r,i,n,s;if(i=t.canvasPoint,(null!=(n=this.dragging)?n.object:void 0)===this)return e=this.convertFromCanvas(i),this.moveTo({x:e.x-this.dragging.offsetX,y:e.y-this.dragging.offsetY}),this.updateCropFrameFromFrame(),this.markDirty();if(null!=(s=this.dragging)?s.resizeDirection:void 0){switch(r=this.parent.convertFromCanvas(i),this.dragging.resizeDirection){case"tl":i=this.constrainPointInParent(r),this.w=this.w+(this.x-i.x),this.h=this.h+(this.y-i.y),this.x=i.x,this.y=i.y;break;case"tm":i=this.constrainPointInParent(r),this.w=this.w,this.h=this.h+(this.y-i.y),this.x=this.x,this.y=i.y;break;case"tr":i=this.constrainPointInParent(r),this.w=i.x-this.x,this.h=this.h+(this.y-i.y),this.x=this.x,this.y=i.y;break;case"ml":i=this.constrainPointInParent(r),this.w=this.w+(this.x-i.x),this.h=this.h,this.x=i.x,this.y=this.y;break;case"mr":i=this.constrainPointInParent(r),this.w=i.x-this.x,this.h=this.h,this.x=this.x,this.y=this.y;break;case"bl":i=this.constrainPointInParent(r),this.w=this.w+(this.x-i.x),this.h=i.y-this.y,this.x=i.x,this.y=this.y;break;case"bm":i=this.constrainPointInParent(r),this.w=this.w,this.h=i.y-this.y,this.x=this.x,this.y=this.y;break;case"br":i=this.constrainPointInParent(r),this.w=i.x-this.x,this.h=i.y-this.y,this.x=this.x,this.y=this.y}return this.updateCropFrameFromFrame(),this.markDirty()}},e.prototype.onDragEnd=function(t){var e,r;return r=t.canvasPoint,e=this.frame(),this.x=e.x,this.y=e.y,this.w=e.w,this.h=e.h,this.trigger("change",this.cropFrame())},e.prototype.onClick=function(){},e.prototype.moveTo=function(t){var e,r,i;return e=this.convertToParent(t),r=Math.max(0,e.x),i=Math.max(0,e.y),r=Math.min(this.parent.bounds().w-this.w,r),i=Math.min(this.parent.bounds().h-this.h,i),this.x=r,this.y=i},e.prototype.setLooseTheAnts=function(){var t;return t=function(e){return function(){return e.marchingAnts&&(e.dashOffset+=.15,e.markDirty()),window.requestAnimationFrame(t)}}(this),window.requestAnimationFrame(t)},e.prototype.drawScreen=function(t){var e;return e=this.frame(),e.x=Math.round(e.x),e.y=Math.round(e.y),e.w=Math.round(e.w),e.h=Math.round(e.h),this.topScreen.set({parent:this.parent,x:0,y:0,w:this.parent.w,h:e.y}),this.bottomScreen.set({parent:this.parent,x:0,y:e.y+e.h,w:this.parent.w,h:this.parent.h-(e.y+e.h)}),this.leftScreen.set({parent:this.parent,x:0,y:e.y,w:e.x,h:e.h}),this.rightScreen.set({parent:this.parent,x:e.x+e.w,y:e.y,w:this.parent.w-(e.x+e.w),h:e.h}),this.topScreen.render(t),this.leftScreen.render(t),this.rightScreen.render(t),this.bottomScreen.render(t)},e.prototype.drawHandles=function(t){var e,r,i,n,o,h;r=this.frame(),r.x=Math.round(r.x),r.y=Math.round(r.y),r.w=Math.round(r.w),r.h=Math.round(r.h),n=function(t){return function(e,r){return new s.Rectangle({parent:t,x:e-t.handleSize/2-.5,y:r-t.handleSize/2-.5,w:t.handleSize,h:t.handleSize,lineWidth:1,strokeStyle:"rgba(192, 192, 192, 1)",fillStyle:"rgba(64, 64, 64, 1)"})}}(this),this.handles.tl=n(0,0),this.handles.tm=n(r.w/2,0),this.handles.tr=n(r.w,0),this.handles.ml=n(0,r.h/2),this.handles.mr=n(r.w,r.h/2),this.handles.bl=n(0,r.h),this.handles.bm=n(r.w/2,r.h),this.handles.br=n(r.w,r.h),o=this.handles,h=[];for(e in o)i=o[e],h.push(i.render(t));return h},e.prototype.drawCropLines=function(t){var e,r,i;return e=this.frame(),e.x=Math.round(e.x),e.y=Math.round(e.y),e.w=Math.round(e.w),e.h=Math.round(e.h),i="0.5",r=4,t.save(),this.positionContext(t,function(t){return function(n){var s,o,h,a,c,u,p,l,d;for(n.lineDashOffset=t.dashOffset,n.beginPath(),n.strokeStyle="rgba(255,255,255,1)",n.rect(.5,.5,e.w,e.h),n.closePath(),n.stroke(),n.beginPath(),n.strokeStyle="rgba(0,0,0,1)",n.setLineDash([r]),n.rect(.5,.5,e.w,e.h),n.closePath(),n.stroke(),n.lineDashOffset=0,p=[e.w/3+.5,e.w/3*2+.5],h=0,c=p.length;c>h;h++)s=p[h],n.beginPath(),n.moveTo(s,0),n.strokeStyle="rgba(255,255,255,"+i+")",n.setLineDash([]),n.lineTo(s,e.h),n.stroke(),n.beginPath(),n.moveTo(s,0),n.strokeStyle="rgba(0,0,0,"+i+")",n.setLineDash([r]),n.lineTo(s,e.h),n.stroke();for(l=[e.h/3+.5,e.h/3*2+.5],d=[],a=0,u=l.length;u>a;a++)o=l[a],n.beginPath(),n.moveTo(0,o),n.strokeStyle="rgba(255,255,255,"+i+")",n.setLineDash([]),n.lineTo(e.w,o),n.stroke(),n.beginPath(),n.moveTo(0,o),n.strokeStyle="rgba(0,0,0,"+i+")",n.setLineDash([r]),n.lineTo(e.w,o),d.push(n.stroke());return d}}(this)),t.restore()},e.prototype.draw=function(t){return this.drawScreen(t),this.drawCropLines(t),this.drawHandles(t)},e}(s.Drawable),r["default"]=i}),define("funderscore",["exports"],function(t){"use strict";var e,r,i,n,s,o;for(r={},r.clone=function(t){return r.extend({},t)},r.extend=function(t,e){var r;if(e)for(r in e)t[r]=e[r];return t},o=["Arguments","Function","String","Number","Date","RegExp"],i=function(t){return r["is"+t]=function(e){return Object.prototype.toString.call(e)==="[object "+t+"]"}},n=0,s=o.length;s>n;n++)e=o[n],i(e);t["default"]=r}),define("drawing",["funderscore","events","exports"],function(t,e,r){"use strict";var i,n,s,o,h,a=t["default"],c=e["default"],u={}.hasOwnProperty,p=function(t,e){function r(){this.constructor=t}for(var i in e)u.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},l=[].slice;h={},n=function(t){function e(t){this.options=t,this.x=t.x,this.y=t.y,this.w=t.w,this.h=t.h,this.dirty=!0,this.scale=t.scale,this.parent=t.parent,this.canvas=t.canvas,this.children=t.children||[],this.dragable=t.dragable||!1,this.enabled=void 0!==t.enabled?!!t.enabled:!0}return p(e,t),e.prototype.set=function(t){var e,r,i;i=[];for(e in t)u.call(t,e)&&(r=t[e],i.push(this[e]=r));return i},e.prototype.enable=function(t){var e;return e=this.enabled,this.enabled=!!t,this.markDirty(),e!==this.enabled?this.enabled?this.trigger("enabled",this):this.trigger("disabled",this):void 0},e.prototype.markDirty=function(){return this.dirty=!0,this.parent?this.parent.markDirty():void 0},e.prototype.bubble=function(){var t,e,r,i,n;for(r=arguments[0],e=arguments[1],t=3<=arguments.length?l.call(arguments,2):[],e.currentTarget=this,this.trigger.apply(this,arguments),i=this.parent,n=[];i;)e=a.clone(e),e.currentTarget=i,i.trigger.apply(i,[r,e].concat(t)),n.push(i=i.parent);return n},e.prototype.findChildAtPoint=function(t){var e,r,i;for(i=this.children.length-1;i>=0;){if(e=this.children[i],r=e.findChildAtPoint(t))return r;if(e.containsCanvasPoint(t))return e;i--}},e.prototype.bounds=function(){return{x:0,y:0,w:this.w,h:this.h}},e.prototype.frame=function(){return{x:this.x,y:this.y,w:this.w,h:this.h}},e.prototype.convertToParent=function(t){var e;return e=this.frame(),{x:t.x+e.x,y:t.y+e.y}},e.prototype.convertFromParent=function(t){var e;return e=this.frame(),{x:t.x-e.x,y:t.y-e.y}},e.prototype.convertToCanvas=function(t){var e,r,i;for(e=this,r=t.x,i=t.y;e;)r+=e.frame().x,i+=e.frame().y,e=e.parent;return{x:r,y:i}},e.prototype.convertFromCanvas=function(t){var e,r,i;for(e=this,r=t.x,i=t.y;e;)r-=e.frame().x,i-=e.frame().y,e=e.parent;return{x:r,y:i}},e.prototype.positionContext=function(t,e){var r;return this.parent&&(r=this.convertToCanvas(this.parent.bounds()),t.translate(r.x,r.y)),e.call(this,t)},e.prototype.containsCanvasPoint=function(t){var e;return e=this.convertFromCanvas(t),this.containsPoint(e)},e.prototype.containsPoint=function(t){var e,r,i;return e=this.frame(),0<=(r=t.x)&&r<=e.w&&0<=(i=t.y)&&i<=e.h},e.prototype.addChild=function(t){return t.parent=this,this.children.push(t),this.markDirty()},e.prototype.removeChild=function(t){var e;return e=this.children.indexOf(t),e>=0?(t.parent=null,this.children.splice(e,1),this.markDirty()):void 0},e.prototype.renderChildren=function(t){var e,r,i,n,s;for(n=this.children,s=[],r=0,i=n.length;i>r;r++)e=n[r],s.push(e.enabled?e.render(t):void 0);return s},e.prototype.clear=function(t){var e;return e=this.frame(),this.parent?positionContext(t,function(){return function(t){return t.clearRect(e.x,e.y,e.w,e.h)}}(this)):t.clearRect(e.x,e.y,e.w,e.h)},e.prototype.render=function(t){return t.save(),this.draw(t),t.restore(),this.renderChildren(t),this.dirty=!1},e.prototype.draw=function(){},e}(c),h.Drawable=n,s=function(t){function e(t){null==t&&(t={}),e.__super__.constructor.call(this,t),this.padding=t.padding||10,this.fillParent=t.fillParent||!0}return p(e,t),e.prototype.frame=function(){var t;return this.fillParent?(t=this.parent.frame(),{x:this.padding,y:this.padding,w:t.w-2*this.padding,h:t.h-2*this.padding}):{x:this.x+this.padding,y:this.y+this.padding,w:this.w-2*this.padding,h:this.h-2*this.padding}},e.prototype.bounds=function(){var t;return this.fillParent?(t=this.parent.frame(),{x:0,y:0,w:t.w-2*this.padding,h:t.h-2*this.padding}):{x:0,y:0,w:this.w-2*this.padding,h:this.h-2*this.padding}},e}(n),h.PaddedContainer=s,i=function(t){function e(t){e.__super__.constructor.call(this,t),this.source=t.source,this.naturalWidth=t.naturalWidth,this.naturalHeight=t.naturalHeight,this.originalNaturalBounds=this.naturalBounds(),this.cropped=!1,this.cropStack=[],this.loaded=!1,this.cropX=0,this.cropY=0,this.cropWidth=this.naturalWidth,this.cropHeight=this.naturalHeight,this.loadImage()}return p(e,t),e.prototype.clearImage=function(){return this.loaded=!1,this.cropped=!1,this.w=null,this.h=null,this.naturalWidth=null,this.naturalHeight=null,this.cropStack=[],this.originalNaturalBounds=this.naturalBounds(),this.markDirty()},e.prototype.setSource=function(t){return this.clearImage(),this.source=t,this.loadImage()},e.prototype.naturalBounds=function(){return{x:0,y:0,w:this.naturalWidth,h:this.naturalHeight}},e.prototype.cropFrame=function(){return{x:this.cropX,y:this.cropY,w:this.cropWidth,h:this.cropHeight}},e.prototype.crop=function(t){return this.cropped||(this.cropped=!0,this.cropX=this.cropY=0),this.cropX=t.x+this.cropX,this.cropY=t.y+this.cropY,this.cropWidth=t.width,this.cropHeight=t.height,this.naturalWidth=this.cropWidth,this.naturalHeight=this.cropHeight,this.resizeToParent(),this.centerOnParent(),this.cropStack.push(this.cropFrame()),this.trigger("crop",this,this.cropStack[this.cropStack.length-2],this.cropFrame()),this.markDirty()},e.prototype.undoCrop=function(){var t,e;return this.cropStack.length>1?(e=this.cropStack.pop(),t=this.cropStack[this.cropStack.length-1],this.cropX=t.x,this.cropY=t.y,this.cropWidth=t.w,this.cropHeight=t.h,this.naturalWidth=t.w,this.naturalHeight=t.h,this.resizeToParent(),this.centerOnParent(),1===this.cropStack.length&&(this.cropped=!1),this.trigger("crop",this,e,this.cropFrame()),this.markDirty()):void 0},e.prototype.revertImage=function(){var t,e;return this.cropped=!1,this.cropStack.length>1?(e=this.cropStack[this.cropStack.length-1],t=this.cropStack[0],this.cropX=t.x,this.cropY=t.y,this.cropWidth=t.w,this.cropHeight=t.h,this.naturalWidth=t.w,this.naturalHeight=t.h,this.resizeToParent(),this.centerOnParent(),this.cropStack=[t],this.trigger("crop",this,e,t),this.markDirty()):void 0},e.prototype.resizeToParent=function(){var t,e,r,i;return e=this.parent.frame().w,t=this.parent.frame().h,r=1,i=1,this.naturalWidth>e&&(r=e/this.naturalWidth),this.naturalHeight>t&&(i=t/this.naturalHeight),this.scale=Math.min(r,i),this.w=this.naturalWidth*this.scale|0,this.h=this.naturalHeight*this.scale|0,this.trigger("resize",this.frame())},e.prototype.centerOnParent=function(){return this.x=this.parent.frame().w/2-this.w/2|0,this.y=this.parent.frame().h/2-this.h/2|0,this.trigger("reposition",this.frame())},e.prototype.toDataURL=function(t){var e,r;return null==t&&(t="image/png"),e=document.createElement("canvas"),e.width=this.cropWidth,e.height=this.cropHeight,r=e.getContext("2d"),this.cropped?r.drawImage(this.img,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight):r.drawImage(this.img,0,0,this.cropWidth,this.cropHeight),e.toDataURL(t)},e.prototype.draw=function(t){return this.positionContext(t,function(t){return this.cropped?t.drawImage(this.img,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.w,this.h):t.drawImage(this.img,0,0,this.w,this.h)})},e.prototype.loadImage=function(){return this.img=document.createElement("img"),this.img.onload=function(t){return function(){return t.loaded=!0,t.naturalWidth=t.img.naturalWidth,t.naturalHeight=t.img.naturalHeight,t.cropped=!1,t.cropStack=[],t.cropX=0,t.cropY=0,t.cropWidth=t.img.naturalWidth,t.cropHeight=t.img.naturalHeight,t.cropStack.push(t.cropFrame()),t.markDirty(),t.trigger("load",t)}}(this),this.img.src=this.source},e}(n),h.CanvasImage=i,o=function(t){function e(t){e.__super__.constructor.call(this,t),this.fillStyle=t.fillStyle||"rgba(0, 0, 0, 0)",this.strokeStyle=t.strokeStyle,this.lineWidth=t.lineWidth}return p(e,t),e.prototype.draw=function(t){return this.positionContext(t,function(t){return function(e){return t.fillStyle&&(e.fillStyle=t.fillStyle),t.strokeStyle&&(e.strokeStyle=t.strokeStyle),t.lineWidth&&(e.lineWidth=t.lineWidth),e.beginPath(),e.rect(0,0,t.w,t.h),e.closePath(),t.fillStyle&&e.fill(),t.lineWidth&&t.strokeStyle?e.stroke():void 0}}(this))},e}(n),h.Rectangle=o,r["default"]=h}),define("events",["funderscore","exports"],function(t,e){"use strict";var r,i,n=t["default"];i=function(){function t(){}return t.prototype.on=function(t,e,r){var i;return this.events||(this.events={}),(i=this.events)[t]||(i[t]=[]),n.isFunction(e)?this.events[t].push([e,r]):void 0},t.prototype.trigger=function(t){var e,r,i,n,s,o,h,a;for(s=Array.prototype.slice.call(arguments,1),i=this.events&&this.events[t]?this.events[t]:[],a=[],o=0,h=i.length;h>o;o++)r=i[o],e=r[0],n=r[1]||this,a.push(e.apply(n,s));return a},t}(),r=function(){function t(t){var e,r;for(e in t)r=t[e],this[e]=r}return t}(),e["default"]=i,e.Event=r}),define("rodeo-crop",["funderscore","drawing","events","crop-box","stage","exports"],function(t,e,r,i,n,s){"use strict";var o,h,a=t["default"],c=e["default"],u=r["default"],p=i["default"],l=n["default"],d={}.hasOwnProperty,g=function(t,e){function r(){this.constructor=t}for(var i in e)d.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};h={},o=function(t){function e(t,e){this.el=a.isString(t)?document.querySelector(t):t,this.options=a.extend({cropEnabled:!0,cropX:null,cropY:null,cropWidth:null,cropHeight:null,marchingAnts:!0,handleSize:10,width:100,height:100,imageSource:null},e),this.ctx=null,this.stage=null,this.imageSource=this.options.imageSource,this.initializeCanvas(),this.createStage(),this.createImage(),this.createCropBox(),this.runLoop()}return g(e,t),e.prototype.initializeCanvas=function(){return this.canvas=document.createElement("canvas"),this.canvas.width=this.options.width,this.canvas.height=this.options.height,this.canvas.style.display="block",this.el.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d")},e.prototype.createStage=function(){return this.stage=new l({canvas:this.canvas})},e.prototype.createImage=function(){return this.paddedContainer=new c.PaddedContainer({padding:this.options.handleSize/2+1}),this.image=new c.CanvasImage({canvas:this.canvas,source:this.imageSource}),this.image.on("load",function(t){return function(){return t.image.resizeToParent(),t.image.centerOnParent()}}(this)),this.stage.on("resize",function(t){return function(){return t.image.resizeToParent(),t.image.centerOnParent()}}(this)),this.paddedContainer.addChild(this.image),this.stage.addChild(this.paddedContainer)},e.prototype.createCropBox=function(){return this.cropBox=new p({enabled:this.options.cropEnabled,canvas:this.canvas,image:this.image,cropX:this.options.cropX,cropY:this.options.cropY,cropWidth:this.options.cropWidth,cropHeight:this.options.cropHeight,handleSize:this.options.handleSize,marchingAnts:this.options.marchingAnts}),this.cropBox.on("disabled",function(t){return function(e){return t.trigger("disabled",e)}}(this)),this.cropBox.on("enabled",function(t){return function(e){return t.trigger("enabled",e)}}(this)),this.cropBox.on("change",function(t){return function(e){return t.trigger("change",e)}}(this)),this.image.on("resize",function(t){return function(){return t.cropBox.updateFrameFromCropFrame()}}(this)),this.image.addChild(this.cropBox)},e.prototype.isCropped=function(){return this.image.cropped},e.prototype.setImageSource=function(t){return this.image.setSource(t)},e.prototype.setCropFrame=function(t){return this.cropBox.setCropFrameAndUpdateFrame(t),this.cropBox.cropFrame()},e.prototype.enableCrop=function(t){return this.cropBox.enable(t)},e.prototype.revertImage=function(){return this.image.revertImage()},e.prototype.undoCropImage=function(){return this.image.undoCrop()},e.prototype.cropImage=function(){return this.cropBox.enabled?this.image.crop(this.cropBox.cropFrame()):void 0},e.prototype.toDataURL=function(t){return null==t&&(t="image/png"),this.image.toDataURL(t)},e.prototype.updateCanvasSize=function(){var t,e;return e=window.getComputedStyle(this.canvas.parentNode).getPropertyValue("width"),t=window.getComputedStyle(this.canvas.parentNode).getPropertyValue("height"),e=parseInt(e,10),t=parseInt(t,10),this.canvas.width!==e||this.canvas.height!==t?(this.canvas.width=e,this.canvas.height=t,!0):!1},e.prototype.runLoop=function(){var t;return t=this.updateCanvasSize(),(t||this.stage.dirty)&&(this.stage.clear(this.ctx),t&&this.stage.trigger("resize"),this.stage.render(this.ctx)),window.requestAnimationFrame(function(t){return function(){return t.runLoop()}}(this))},e}(u),h.Cropper=o,s["default"]=h}),define("stage",["funderscore","drawing","events","exports"],function(t,e,r,i){"use strict";var n,s=(t["default"],e["default"]),o=r.Event,h={}.hasOwnProperty,a=function(t,e){function r(){this.constructor=t}for(var i in e)h.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};n=function(t){function e(t){e.__super__.constructor.call(this,t),this.canvas=t.canvas,this.lastMouseDownTarget=null,this.lastMouseMoveTarget=null,this.dragTarget=null,this.clickTarget=null,this.attachListeners()}return a(e,t),e.prototype.bubbleMouseEvent=function(t,e,r,i){var n;return n=new o({target:t,originalEvent:r,canvasPoint:i}),t.bubble(e,n)},e.prototype.attachListeners=function(){return window.addEventListener("mouseup",function(t){return function(e){var r,i;if(1===e.which)return e.preventDefault(),r=t.windowToCanvas(e),i=t.findChildAtPoint(r)||t,t.bubbleMouseEvent(i,"mouseup",e,r),t.clickTarget===i&&t.bubbleMouseEvent(t.clickTarget,"click",e,r),t.dragTarget&&t.bubbleMouseEvent(t.dragTarget,"dragend",e,r),t.lastMouseDownTarget=null,t.lastMouseMoveTarget=null,t.dragTarget=null}}(this)),window.addEventListener("mousedown",function(t){return function(e){var r,i;if(1===e.which)return e.preventDefault(),r=t.windowToCanvas(e),i=t.findChildAtPoint(r)||t,t.bubbleMouseEvent(i,"mousedown",e,r),t.lastMouseDownTarget=i,t.clickTarget=i,t.movedSinceMouseDown=!1}}(this)),window.addEventListener("mousemove",function(t){return function(e){var r,i;return e.preventDefault(),r=t.windowToCanvas(e),i=t.findChildAtPoint(r)||t,t.bubbleMouseEvent(i,"mousemove",e,r),t.lastMouseDownTarget&&(t.dragTarget||(t.bubbleMouseEvent(t.lastMouseDownTarget,"dragstart",e,r),t.dragTarget=t.lastMouseDownTarget),t.bubbleMouseEvent(t.dragTarget,"dragmove",e,r)),i!==t.lastMouseMoveTarget&&(t.lastMouseMoveTarget&&t.bubbleMouseEvent(t.lastMouseMoveTarget,"mouseout",e,r),t.bubbleMouseEvent(i,"mouseover",e,r)),t.lastMouseMoveTarget=i}}(this))},e.prototype.windowToCanvas=function(t){var e,r,i;return e=this.canvas.getBoundingClientRect(),r=t.clientX-e.left-parseInt(window.getComputedStyle(this.canvas).getPropertyValue("padding-left"),0),i=t.clientY-e.top-parseInt(window.getComputedStyle(this.canvas).getPropertyValue("padding-top"),0),{x:r,y:i}},e.prototype.frame=function(){return{x:0,y:0,w:this.canvas.width,h:this.canvas.height}},e.prototype.bounds=function(){return this.frame()},e}(s.Drawable),i["default"]=n}),define("vendor/loader",[],function(){"use strict";var t,e,r,i;!function(){var n={},s={};t=function(t,e,r){n[t]={deps:e,callback:r}},i=r=e=function(t){function r(e){if("."!==e.charAt(0))return e;for(var r=e.split("/"),i=t.split("/").slice(0,-1),n=0,s=r.length;s>n;n++){var o=r[n];if(".."===o)i.pop();else{if("."===o)continue;i.push(o)}}return i.join("/")}if(i._eak_seen=n,s.hasOwnProperty(t))return s[t];if(s[t]={},!n[t])throw new Error("Could not find module "+t);for(var o,h=n[t],a=h.deps,c=h.callback,u=[],p=0,l=a.length;l>p;p++)u.push("exports"===a[p]?o={}:e(r(a[p])));var d=c.apply(this,u);return s[t]=o||d}}()}),window.RodeoCrop=requireModule("rodeo-crop").default;
+var define,requireModule,require,requirejs;!function(){var t={},e={};define=function(e,r,i){t[e]={deps:r,callback:i}},requirejs=require=requireModule=function(r){function i(t){if("."!==t.charAt(0))return t;for(var e=t.split("/"),i=r.split("/").slice(0,-1),n=0,s=e.length;s>n;n++){var o=e[n];if(".."===o)i.pop();else{if("."===o)continue;i.push(o)}}return i.join("/")}if(requirejs._eak_seen=t,e.hasOwnProperty(r))return e[r];if(e[r]={},!t[r])throw new Error("Could not find module "+r);for(var n,s=t[r],o=s.deps,h=s.callback,a=[],c=0,u=o.length;u>c;c++)a.push("exports"===o[c]?n={}:requireModule(i(o[c])));var p=h.apply(this,a);return e[r]=n||p}}(),define("crop-box",["funderscore","drawing","exports"],function(t,e,r){"use strict";var i,n=t["default"],s=e["default"],o={}.hasOwnProperty,h=function(t,e){function r(){this.constructor=t}for(var i in e)o.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};i=function(t){function e(t){e.__super__.constructor.call(this,n.extend({dragable:!0},t)),this.image=t.image,this.handleSize=t.handleSize||10,this.screenStyle=t.screenStyle||"rgba(0, 0, 0, .75)",this.topScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.leftScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.rightScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.bottomScreen=new s.Rectangle({fillStyle:this.screenStyle}),this.cropX=t.cropX||0,this.cropY=t.cropY||0,this.cropWidth=t.cropWidth||4*this.handleSize,this.cropHeight=t.cropHeight||4*this.handleSize,this.marchingAnts=t.marchingAnts||!0,this.dashOffset=0,this.dragging=null,this.mouseDown=!1,this.handles={},this.image.on("load",function(t){return function(){return t.setCropFrameAndUpdateFrame(t.cropFrame())}}(this)),this.image.on("crop",function(t){return function(e,r,i){return t.cropX=r.w>=i.w?0:r.x-i.x,t.cropY=r.h>=i.h?0:r.y-i.y,t.cropWidth=r.w>=i.w?i.w:r.w,t.cropHeight=r.h>=i.h?i.h:r.h,t.setCropFrameAndUpdateFrame(t.cropFrame())}}(this)),this.on("mouseout",this.onMouseOut),this.on("mousemove",this.onMouseMove),this.on("mousedown",this.onMouseDown),this.on("mouseup",this.onMouseUp),this.on("dragstart",this.onDragStart),this.on("dragend",this.onDragEnd),this.on("dragmove",this.onDragMove),this.setLooseTheAnts()}return h(e,t),e.prototype.frame=function(){return{x:this.w<0?this.x+this.w:this.x,y:this.h<0?this.y+this.h:this.y,w:Math.abs(this.w),h:Math.abs(this.h)}},e.prototype.cropFrame=function(){return{x:this.cropX,y:this.cropY,width:this.cropWidth,height:this.cropHeight}},e.prototype.updateCropFrameFromFrame=function(){var t,e,r;return t=this.frame(),r=this.image.naturalBounds(),e=this.image.bounds(),this.image.loaded&&(this.cropX=r.w*(t.x/e.w),this.cropY=r.h*(t.y/e.h),this.cropWidth=r.w*(t.w/e.w),this.cropHeight=r.h*(t.h/e.h)),this.trigger("change:cropFrame",this.cropFrame())},e.prototype.setFrameAndUpdateCropArea=function(t){return this.x=t.x,this.y=t.y,this.w=t.w,this.h=t.h,this.updateCropFrameFromFrame(),this.markDirty()},e.prototype.updateFrameFromCropFrame=function(){var t,e;return this.image.loaded?(e=this.image.naturalBounds(),t=this.image.bounds(),this.x=t.w*(this.cropX/e.w),this.y=t.h*(this.cropY/e.h),this.w=t.w*(this.cropWidth/e.w),this.h=t.h*(this.cropHeight/e.h),this.markDirty()):void 0},e.prototype.setCropFrameAndUpdateFrame=function(t){var e,r,i,n,s;return this.image.loaded?(e=this.image.naturalBounds(),n=(null!=t?t.x:void 0)||.125*e.w,s=(null!=t?t.y:void 0)||.125*e.h,i=(null!=t?t.width:void 0)||.75*e.w,r=(null!=t?t.height:void 0)||.75*e.h,this.cropX=Math.min(Math.max(n,0),e.w),this.cropY=Math.min(Math.max(s,0),e.h),this.cropWidth=Math.min(Math.max(i,0),e.w-this.cropX),this.cropHeight=Math.min(Math.max(r,0),e.h-this.cropY),this.updateFrameFromCropFrame()):(this.cropX=null!=t?t.x:void 0,this.cropY=null!=t?t.y:void 0,this.cropWidth=null!=t?t.width:void 0,this.cropHeight=null!=t?t.height:void 0)},e.prototype.bounds=function(){return{x:0,y:0,w:Math.abs(this.w),h:Math.abs(this.h)}},e.prototype.containsCanvasPoint=function(t){var e,r,i,n,s;if(n=this.convertFromCanvas(t),e=this.containsPoint(n))return e;s=this.handles;for(r in s)if(i=s[r],i.containsCanvasPoint(t))return!0;return!1},e.prototype.onMouseOut=function(){return this.canvas.style.cursor="default"},e.prototype.onMouseMove=function(t){var e,r,i,n;if(this.enabled){i=t.canvasPoint,n=this.handles;for(e in n)if(r=n[e],r.containsCanvasPoint(i)){switch(e){case"tl":this.canvas.style.cursor="nw-resize";break;case"tm":this.canvas.style.cursor="n-resize";break;case"tr":this.canvas.style.cursor="ne-resize";break;case"ml":this.canvas.style.cursor="w-resize";break;case"mr":this.canvas.style.cursor="e-resize";break;case"bl":this.canvas.style.cursor="sw-resize";break;case"bm":this.canvas.style.cursor="s-resize";break;case"br":this.canvas.style.cursor="se-resize"}return}return this.canvas.style.cursor="move"}},e.prototype.constrainPointInParent=function(t){return{x:Math.min(Math.max(t.x,0),this.parent.frame().w),y:Math.min(Math.max(t.y,0),this.parent.frame().h)}},e.prototype.onMouseUp=function(){return this.dragging=this.mouseDown=null},e.prototype.onDragStart=function(t){var e,r,i,n,s;n=t.canvasPoint,s=this.handles;for(e in s)if(r=s[e],r.containsCanvasPoint(n))return i=r.convertFromCanvas(n),void(this.dragging={resizeDirection:e,object:r,offsetX:i.x,offsetY:i.y});return i=this.convertFromCanvas(n),this.dragging={object:this,offsetX:i.x,offsetY:i.y}},e.prototype.onDragMove=function(t){var e,r,i,n,s;if(i=t.canvasPoint,(null!=(n=this.dragging)?n.object:void 0)===this)return e=this.convertFromCanvas(i),this.moveTo({x:e.x-this.dragging.offsetX,y:e.y-this.dragging.offsetY}),this.updateCropFrameFromFrame(),this.markDirty();if(null!=(s=this.dragging)?s.resizeDirection:void 0){switch(r=this.parent.convertFromCanvas(i),this.dragging.resizeDirection){case"tl":i=this.constrainPointInParent(r),this.w=this.w+(this.x-i.x),this.h=this.h+(this.y-i.y),this.x=i.x,this.y=i.y;break;case"tm":i=this.constrainPointInParent(r),this.w=this.w,this.h=this.h+(this.y-i.y),this.x=this.x,this.y=i.y;break;case"tr":i=this.constrainPointInParent(r),this.w=i.x-this.x,this.h=this.h+(this.y-i.y),this.x=this.x,this.y=i.y;break;case"ml":i=this.constrainPointInParent(r),this.w=this.w+(this.x-i.x),this.h=this.h,this.x=i.x,this.y=this.y;break;case"mr":i=this.constrainPointInParent(r),this.w=i.x-this.x,this.h=this.h,this.x=this.x,this.y=this.y;break;case"bl":i=this.constrainPointInParent(r),this.w=this.w+(this.x-i.x),this.h=i.y-this.y,this.x=i.x,this.y=this.y;break;case"bm":i=this.constrainPointInParent(r),this.w=this.w,this.h=i.y-this.y,this.x=this.x,this.y=this.y;break;case"br":i=this.constrainPointInParent(r),this.w=i.x-this.x,this.h=i.y-this.y,this.x=this.x,this.y=this.y}return this.updateCropFrameFromFrame(),this.markDirty()}},e.prototype.onDragEnd=function(t){var e,r;return r=t.canvasPoint,e=this.frame(),this.x=e.x,this.y=e.y,this.w=e.w,this.h=e.h,this.trigger("change",this.cropFrame())},e.prototype.onClick=function(){},e.prototype.moveTo=function(t){var e,r,i;return e=this.convertToParent(t),r=Math.max(0,e.x),i=Math.max(0,e.y),r=Math.min(this.parent.bounds().w-this.w,r),i=Math.min(this.parent.bounds().h-this.h,i),this.x=r,this.y=i},e.prototype.setLooseTheAnts=function(){var t;return t=function(e){return function(){return e.marchingAnts&&(e.dashOffset+=.15,e.markDirty()),window.requestAnimationFrame(t)}}(this),window.requestAnimationFrame(t)},e.prototype.drawScreen=function(t){var e;return e=this.frame(),e.x=Math.round(e.x),e.y=Math.round(e.y),e.w=Math.round(e.w),e.h=Math.round(e.h),this.topScreen.set({parent:this.parent,x:0,y:0,w:this.parent.w,h:e.y}),this.bottomScreen.set({parent:this.parent,x:0,y:e.y+e.h,w:this.parent.w,h:this.parent.h-(e.y+e.h)}),this.leftScreen.set({parent:this.parent,x:0,y:e.y,w:e.x,h:e.h}),this.rightScreen.set({parent:this.parent,x:e.x+e.w,y:e.y,w:this.parent.w-(e.x+e.w),h:e.h}),this.topScreen.render(t),this.leftScreen.render(t),this.rightScreen.render(t),this.bottomScreen.render(t)},e.prototype.drawHandles=function(t){var e,r,i,n,o,h;r=this.frame(),r.x=Math.round(r.x),r.y=Math.round(r.y),r.w=Math.round(r.w),r.h=Math.round(r.h),n=function(t){return function(e,r){return new s.Rectangle({parent:t,x:e-t.handleSize/2-.5,y:r-t.handleSize/2-.5,w:t.handleSize,h:t.handleSize,lineWidth:1,strokeStyle:"rgba(192, 192, 192, 1)",fillStyle:"rgba(64, 64, 64, 1)"})}}(this),this.handles.tl=n(0,0),this.handles.tm=n(r.w/2,0),this.handles.tr=n(r.w,0),this.handles.ml=n(0,r.h/2),this.handles.mr=n(r.w,r.h/2),this.handles.bl=n(0,r.h),this.handles.bm=n(r.w/2,r.h),this.handles.br=n(r.w,r.h),o=this.handles,h=[];for(e in o)i=o[e],h.push(i.render(t));return h},e.prototype.drawCropLines=function(t){var e,r,i;return e=this.frame(),e.x=Math.round(e.x),e.y=Math.round(e.y),e.w=Math.round(e.w),e.h=Math.round(e.h),i="0.5",r=4,t.save(),this.positionContext(t,function(t){return function(n){var s,o,h,a,c,u,p,l,d;for(n.lineDashOffset=t.dashOffset,n.beginPath(),n.strokeStyle="rgba(255,255,255,1)",n.rect(.5,.5,e.w,e.h),n.closePath(),n.stroke(),n.beginPath(),n.strokeStyle="rgba(0,0,0,1)",n.setLineDash([r]),n.rect(.5,.5,e.w,e.h),n.closePath(),n.stroke(),n.lineDashOffset=0,p=[e.w/3+.5,e.w/3*2+.5],h=0,c=p.length;c>h;h++)s=p[h],n.beginPath(),n.moveTo(s,0),n.strokeStyle="rgba(255,255,255,"+i+")",n.setLineDash([]),n.lineTo(s,e.h),n.stroke(),n.beginPath(),n.moveTo(s,0),n.strokeStyle="rgba(0,0,0,"+i+")",n.setLineDash([r]),n.lineTo(s,e.h),n.stroke();for(l=[e.h/3+.5,e.h/3*2+.5],d=[],a=0,u=l.length;u>a;a++)o=l[a],n.beginPath(),n.moveTo(0,o),n.strokeStyle="rgba(255,255,255,"+i+")",n.setLineDash([]),n.lineTo(e.w,o),n.stroke(),n.beginPath(),n.moveTo(0,o),n.strokeStyle="rgba(0,0,0,"+i+")",n.setLineDash([r]),n.lineTo(e.w,o),d.push(n.stroke());return d}}(this)),t.restore()},e.prototype.draw=function(t){return this.drawScreen(t),this.drawCropLines(t),this.drawHandles(t)},e}(s.Drawable),r["default"]=i}),define("funderscore",["exports"],function(t){"use strict";var e,r,i,n,s,o;for(r={},r.clone=function(t){return r.extend({},t)},r.extend=function(t,e){var r;if(e)for(r in e)t[r]=e[r];return t},o=["Arguments","Function","String","Number","Date","RegExp"],i=function(t){return r["is"+t]=function(e){return Object.prototype.toString.call(e)==="[object "+t+"]"}},n=0,s=o.length;s>n;n++)e=o[n],i(e);t["default"]=r}),define("drawing",["funderscore","events","exports"],function(t,e,r){"use strict";var i,n,s,o,h,a=t["default"],c=e["default"],u={}.hasOwnProperty,p=function(t,e){function r(){this.constructor=t}for(var i in e)u.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t},l=[].slice;h={},n=function(t){function e(t){this.options=t,this.x=t.x,this.y=t.y,this.w=t.w,this.h=t.h,this.dirty=!0,this.scale=t.scale,this.parent=t.parent,this.canvas=t.canvas,this.children=t.children||[],this.dragable=t.dragable||!1,this.enabled=void 0!==t.enabled?!!t.enabled:!0}return p(e,t),e.prototype.set=function(t){var e,r,i;i=[];for(e in t)u.call(t,e)&&(r=t[e],i.push(this[e]=r));return i},e.prototype.enable=function(t){var e;return e=this.enabled,this.enabled=!!t,this.markDirty(),e!==this.enabled?this.enabled?this.trigger("enabled",this):this.trigger("disabled",this):void 0},e.prototype.markDirty=function(){return this.dirty=!0,this.parent?this.parent.markDirty():void 0},e.prototype.bubble=function(){var t,e,r,i,n;for(r=arguments[0],e=arguments[1],t=3<=arguments.length?l.call(arguments,2):[],e.currentTarget=this,this.trigger.apply(this,arguments),i=this.parent,n=[];i;)e=a.clone(e),e.currentTarget=i,i.trigger.apply(i,[r,e].concat(t)),n.push(i=i.parent);return n},e.prototype.findChildAtPoint=function(t){var e,r,i;for(i=this.children.length-1;i>=0;){if(e=this.children[i],r=e.findChildAtPoint(t))return r;if(e.containsCanvasPoint(t))return e;i--}},e.prototype.bounds=function(){return{x:0,y:0,w:this.w,h:this.h}},e.prototype.frame=function(){return{x:this.x,y:this.y,w:this.w,h:this.h}},e.prototype.convertToParent=function(t){var e;return e=this.frame(),{x:t.x+e.x,y:t.y+e.y}},e.prototype.convertFromParent=function(t){var e;return e=this.frame(),{x:t.x-e.x,y:t.y-e.y}},e.prototype.convertToCanvas=function(t){var e,r,i;for(e=this,r=t.x,i=t.y;e;)r+=e.frame().x,i+=e.frame().y,e=e.parent;return{x:r,y:i}},e.prototype.convertFromCanvas=function(t){var e,r,i;for(e=this,r=t.x,i=t.y;e;)r-=e.frame().x,i-=e.frame().y,e=e.parent;return{x:r,y:i}},e.prototype.positionContext=function(t,e){var r;return this.parent&&(r=this.convertToCanvas(this.parent.bounds()),t.translate(r.x,r.y)),e.call(this,t)},e.prototype.containsCanvasPoint=function(t){var e;return e=this.convertFromCanvas(t),this.containsPoint(e)},e.prototype.containsPoint=function(t){var e,r,i;return e=this.frame(),0<=(r=t.x)&&r<=e.w&&0<=(i=t.y)&&i<=e.h},e.prototype.addChild=function(t){return t.parent=this,this.children.push(t),this.markDirty()},e.prototype.removeChild=function(t){var e;return e=this.children.indexOf(t),e>=0?(t.parent=null,this.children.splice(e,1),this.markDirty()):void 0},e.prototype.renderChildren=function(t){var e,r,i,n,s;for(n=this.children,s=[],r=0,i=n.length;i>r;r++)e=n[r],s.push(e.enabled?e.render(t):void 0);return s},e.prototype.clear=function(t){var e;return e=this.frame(),this.parent?positionContext(t,function(){return function(t){return t.clearRect(e.x,e.y,e.w,e.h)}}(this)):t.clearRect(e.x,e.y,e.w,e.h)},e.prototype.render=function(t){return t.save(),this.draw(t),t.restore(),this.renderChildren(t),this.dirty=!1},e.prototype.draw=function(){},e}(c),h.Drawable=n,s=function(t){function e(t){null==t&&(t={}),e.__super__.constructor.call(this,t),this.padding=t.padding||10,this.fillParent=t.fillParent||!0}return p(e,t),e.prototype.frame=function(){var t;return this.fillParent?(t=this.parent.frame(),{x:this.padding,y:this.padding,w:t.w-2*this.padding,h:t.h-2*this.padding}):{x:this.x+this.padding,y:this.y+this.padding,w:this.w-2*this.padding,h:this.h-2*this.padding}},e.prototype.bounds=function(){var t;return this.fillParent?(t=this.parent.frame(),{x:0,y:0,w:t.w-2*this.padding,h:t.h-2*this.padding}):{x:0,y:0,w:this.w-2*this.padding,h:this.h-2*this.padding}},e}(n),h.PaddedContainer=s,i=function(t){function e(t){e.__super__.constructor.call(this,t),this.source=t.source,this.naturalWidth=t.naturalWidth,this.naturalHeight=t.naturalHeight,this.originalNaturalBounds=this.naturalBounds(),this.cropped=!1,this.cropStack=[],this.loaded=!1,this.cropX=0,this.cropY=0,this.cropWidth=this.naturalWidth,this.cropHeight=this.naturalHeight,this.loadImage()}return p(e,t),e.prototype.clearImage=function(){return this.loaded=!1,this.cropped=!1,this.w=null,this.h=null,this.naturalWidth=null,this.naturalHeight=null,this.cropStack=[],this.originalNaturalBounds=this.naturalBounds(),this.markDirty()},e.prototype.setSource=function(t){return this.clearImage(),this.source=t,this.loadImage()},e.prototype.naturalBounds=function(){return{x:0,y:0,w:this.naturalWidth,h:this.naturalHeight}},e.prototype.cropFrame=function(){return{x:this.cropX,y:this.cropY,w:this.cropWidth,h:this.cropHeight}},e.prototype.crop=function(t){return this.cropped||(this.cropped=!0,this.cropX=this.cropY=0),this.cropX=t.x+this.cropX,this.cropY=t.y+this.cropY,this.cropWidth=t.width,this.cropHeight=t.height,this.naturalWidth=this.cropWidth,this.naturalHeight=this.cropHeight,this.resizeToParent(),this.centerOnParent(),this.cropStack.push(this.cropFrame()),this.trigger("crop",this,this.cropStack[this.cropStack.length-2],this.cropFrame()),this.markDirty()},e.prototype.undoCrop=function(){var t,e;return this.cropStack.length>1?(e=this.cropStack.pop(),t=this.cropStack[this.cropStack.length-1],this.cropX=t.x,this.cropY=t.y,this.cropWidth=t.w,this.cropHeight=t.h,this.naturalWidth=t.w,this.naturalHeight=t.h,this.resizeToParent(),this.centerOnParent(),1===this.cropStack.length&&(this.cropped=!1),this.trigger("crop",this,e,this.cropFrame()),this.markDirty()):void 0},e.prototype.revertImage=function(){var t,e;return this.cropped=!1,this.cropStack.length>1?(e=this.cropStack[this.cropStack.length-1],t=this.cropStack[0],this.cropX=t.x,this.cropY=t.y,this.cropWidth=t.w,this.cropHeight=t.h,this.naturalWidth=t.w,this.naturalHeight=t.h,this.resizeToParent(),this.centerOnParent(),this.cropStack=[t],this.trigger("crop",this,e,t),this.markDirty()):void 0},e.prototype.resizeToParent=function(){var t,e,r,i;return e=this.parent.frame().w,t=this.parent.frame().h,r=1,i=1,this.naturalWidth>e&&(r=e/this.naturalWidth),this.naturalHeight>t&&(i=t/this.naturalHeight),this.scale=Math.min(r,i),this.w=this.naturalWidth*this.scale|0,this.h=this.naturalHeight*this.scale|0,this.trigger("resize",this.frame())},e.prototype.centerOnParent=function(){return this.x=this.parent.frame().w/2-this.w/2|0,this.y=this.parent.frame().h/2-this.h/2|0,this.trigger("reposition",this.frame())},e.prototype.toDataURL=function(t){var e,r;return null==t&&(t="image/png"),e=document.createElement("canvas"),e.width=this.cropWidth,e.height=this.cropHeight,r=e.getContext("2d"),this.cropped?r.drawImage(this.img,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.cropWidth,this.cropHeight):r.drawImage(this.img,0,0,this.cropWidth,this.cropHeight),e.toDataURL(t)},e.prototype.draw=function(t){return this.positionContext(t,function(t){return this.cropped?t.drawImage(this.img,this.cropX,this.cropY,this.cropWidth,this.cropHeight,0,0,this.w,this.h):t.drawImage(this.img,0,0,this.w,this.h)})},e.prototype.loadImage=function(){return this.img=document.createElement("img"),this.img.onload=function(t){return function(){return t.loaded=!0,t.naturalWidth=t.img.naturalWidth,t.naturalHeight=t.img.naturalHeight,t.cropped=!1,t.cropStack=[],t.cropX=0,t.cropY=0,t.cropWidth=t.img.naturalWidth,t.cropHeight=t.img.naturalHeight,t.cropStack.push(t.cropFrame()),t.markDirty(),t.trigger("load",t)}}(this),this.img.src=this.source},e}(n),h.CanvasImage=i,o=function(t){function e(t){e.__super__.constructor.call(this,t),this.fillStyle=t.fillStyle||"rgba(0, 0, 0, 0)",this.strokeStyle=t.strokeStyle,this.lineWidth=t.lineWidth}return p(e,t),e.prototype.draw=function(t){return this.positionContext(t,function(t){return function(e){return t.fillStyle&&(e.fillStyle=t.fillStyle),t.strokeStyle&&(e.strokeStyle=t.strokeStyle),t.lineWidth&&(e.lineWidth=t.lineWidth),e.beginPath(),e.rect(0,0,t.w,t.h),e.closePath(),t.fillStyle&&e.fill(),t.lineWidth&&t.strokeStyle?e.stroke():void 0}}(this))},e}(n),h.Rectangle=o,r["default"]=h}),define("events",["funderscore","exports"],function(t,e){"use strict";var r,i,n=t["default"];i=function(){function t(){}return t.prototype.on=function(t,e,r){var i;return this.events||(this.events={}),(i=this.events)[t]||(i[t]=[]),n.isFunction(e)?this.events[t].push([e,r]):void 0},t.prototype.trigger=function(t){var e,r,i,n,s,o,h,a;for(s=Array.prototype.slice.call(arguments,1),i=this.events&&this.events[t]?this.events[t]:[],a=[],o=0,h=i.length;h>o;o++)r=i[o],e=r[0],n=r[1]||this,a.push(e.apply(n,s));return a},t}(),r=function(){function t(t){var e,r;for(e in t)r=t[e],this[e]=r}return t}(),e["default"]=i,e.Event=r}),define("rodeo-crop",["funderscore","drawing","events","crop-box","stage","exports"],function(t,e,r,i,n,s){"use strict";var o,h,a=t["default"],c=e["default"],u=r["default"],p=i["default"],l=n["default"],d={}.hasOwnProperty,g=function(t,e){function r(){this.constructor=t}for(var i in e)d.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};h={},o=function(t){function e(t,e){this.el=a.isString(t)?document.querySelector(t):t,this.options=a.extend({cropEnabled:!0,cropX:null,cropY:null,cropWidth:null,cropHeight:null,marchingAnts:!0,handleSize:10,width:100,height:100,imageSource:null},e),this.ctx=null,this.stage=null,this.imageSource=this.options.imageSource,this.initializeCanvas(),this.createStage(),this.createImage(),this.createCropBox(),this.runLoop()}return g(e,t),e.prototype.initializeCanvas=function(){return this.canvas=document.createElement("canvas"),this.canvas.width=this.options.width,this.canvas.height=this.options.height,this.canvas.style.display="block",this.el.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d")},e.prototype.createStage=function(){return this.stage=new l({canvas:this.canvas})},e.prototype.createImage=function(){return this.paddedContainer=new c.PaddedContainer({padding:this.options.handleSize/2+1}),this.image=new c.CanvasImage({canvas:this.canvas,source:this.imageSource}),this.image.on("load",function(t){return function(){return t.image.resizeToParent(),t.image.centerOnParent()}}(this)),this.stage.on("resize",function(t){return function(){return t.image.resizeToParent(),t.image.centerOnParent()}}(this)),this.paddedContainer.addChild(this.image),this.stage.addChild(this.paddedContainer)},e.prototype.createCropBox=function(){return this.cropBox=new p({enabled:this.options.cropEnabled,canvas:this.canvas,image:this.image,cropX:this.options.cropX,cropY:this.options.cropY,cropWidth:this.options.cropWidth,cropHeight:this.options.cropHeight,handleSize:this.options.handleSize,marchingAnts:this.options.marchingAnts}),this.cropBox.on("disabled",function(t){return function(e){return t.trigger("disabled",e)}}(this)),this.cropBox.on("enabled",function(t){return function(e){return t.trigger("enabled",e)}}(this)),this.cropBox.on("change",function(t){return function(e){return t.trigger("change",e)}}(this)),this.image.on("resize",function(t){return function(){return t.cropBox.updateFrameFromCropFrame()}}(this)),this.image.addChild(this.cropBox)},e.prototype.isCropped=function(){return this.image.cropped},e.prototype.setImageSource=function(t){return this.image.setSource(t)},e.prototype.setCropFrame=function(t){return this.cropBox.setCropFrameAndUpdateFrame(t),this.cropBox.cropFrame()},e.prototype.enableCrop=function(t){return this.cropBox.enable(t)},e.prototype.revertImage=function(){return this.image.revertImage()},e.prototype.undoCropImage=function(){return this.image.undoCrop()},e.prototype.cropImage=function(){return this.cropBox.enabled?this.image.crop(this.cropBox.cropFrame()):void 0},e.prototype.toDataURL=function(t){return null==t&&(t="image/png"),this.image.toDataURL(t)},e.prototype.updateCanvasSize=function(){var t,e;return e=window.getComputedStyle(this.canvas.parentNode).getPropertyValue("width"),t=window.getComputedStyle(this.canvas.parentNode).getPropertyValue("height"),e=parseInt(e,10),t=parseInt(t,10),this.canvas.width!==e||this.canvas.height!==t?(this.canvas.width=e,this.canvas.height=t,!0):!1},e.prototype.runLoop=function(){var t;return t=this.updateCanvasSize(),(t||this.stage.dirty)&&(this.stage.clear(this.ctx),t&&this.stage.trigger("resize"),this.stage.render(this.ctx)),window.requestAnimationFrame(function(t){return function(){return t.runLoop()}}(this))},e}(u),h.Cropper=o,s["default"]=h}),define("stage",["funderscore","drawing","events","exports"],function(t,e,r,i){"use strict";var n,s=(t["default"],e["default"]),o=r.Event,h={}.hasOwnProperty,a=function(t,e){function r(){this.constructor=t}for(var i in e)h.call(e,i)&&(t[i]=e[i]);return r.prototype=e.prototype,t.prototype=new r,t.__super__=e.prototype,t};n=function(t){function e(t){e.__super__.constructor.call(this,t),this.canvas=t.canvas,this.lastMouseDownTarget=null,this.lastMouseMoveTarget=null,this.dragTarget=null,this.clickTarget=null,this.attachListeners()}return a(e,t),e.prototype.bubbleMouseEvent=function(t,e,r,i){var n;return n=new o({target:t,originalEvent:r,canvasPoint:i}),t.bubble(e,n)},e.prototype.attachListeners=function(){return window.addEventListener("mouseup",function(t){return function(e){var r,i;if(1===e.which)return r=t.windowToCanvas(e),i=t.findChildAtPoint(r)||t,t.bubbleMouseEvent(i,"mouseup",e,r),t.clickTarget===i&&t.bubbleMouseEvent(t.clickTarget,"click",e,r),t.dragTarget&&t.bubbleMouseEvent(t.dragTarget,"dragend",e,r),t.lastMouseDownTarget=null,t.lastMouseMoveTarget=null,t.dragTarget=null}}(this)),this.canvas.addEventListener("mousedown",function(t){return function(e){var r,i;if(1===e.which)return e.preventDefault(),r=t.windowToCanvas(e),i=t.findChildAtPoint(r)||t,t.bubbleMouseEvent(i,"mousedown",e,r),t.lastMouseDownTarget=i,t.clickTarget=i,t.movedSinceMouseDown=!1}}(this)),window.addEventListener("mousemove",function(t){return function(e){var r,i;return r=t.windowToCanvas(e),i=t.findChildAtPoint(r)||t,t.bubbleMouseEvent(i,"mousemove",e,r),t.lastMouseDownTarget&&(t.dragTarget||(t.bubbleMouseEvent(t.lastMouseDownTarget,"dragstart",e,r),t.dragTarget=t.lastMouseDownTarget),t.bubbleMouseEvent(t.dragTarget,"dragmove",e,r)),i!==t.lastMouseMoveTarget&&(t.lastMouseMoveTarget&&t.bubbleMouseEvent(t.lastMouseMoveTarget,"mouseout",e,r),t.bubbleMouseEvent(i,"mouseover",e,r)),t.lastMouseMoveTarget=i}}(this))},e.prototype.windowToCanvas=function(t){var e,r,i;return e=this.canvas.getBoundingClientRect(),r=t.clientX-e.left-parseInt(window.getComputedStyle(this.canvas).getPropertyValue("padding-left"),0),i=t.clientY-e.top-parseInt(window.getComputedStyle(this.canvas).getPropertyValue("padding-top"),0),{x:r,y:i}},e.prototype.frame=function(){return{x:0,y:0,w:this.canvas.width,h:this.canvas.height}},e.prototype.bounds=function(){return this.frame()},e}(s.Drawable),i["default"]=n}),define("vendor/loader",[],function(){"use strict";var t,e,r,i;!function(){var n={},s={};t=function(t,e,r){n[t]={deps:e,callback:r}},i=r=e=function(t){function r(e){if("."!==e.charAt(0))return e;for(var r=e.split("/"),i=t.split("/").slice(0,-1),n=0,s=r.length;s>n;n++){var o=r[n];if(".."===o)i.pop();else{if("."===o)continue;i.push(o)}}return i.join("/")}if(i._eak_seen=n,s.hasOwnProperty(t))return s[t];if(s[t]={},!n[t])throw new Error("Could not find module "+t);for(var o,h=n[t],a=h.deps,c=h.callback,u=[],p=0,l=a.length;l>p;p++)u.push("exports"===a[p]?o={}:e(r(a[p])));var d=c.apply(this,u);return s[t]=o||d}}()}),window.RodeoCrop=requireModule("rodeo-crop").default;
Please sign in to comment.
Something went wrong with that request. Please try again.