diff --git a/excalibur/tasks.py b/excalibur/tasks.py index 4bf92be..2cbcf40 100644 --- a/excalibur/tasks.py +++ b/excalibur/tasks.py @@ -50,7 +50,7 @@ def split(file_id): filenames[page] = filename filepaths[page] = filepath imagenames[page] = imagename - imagepaths[page] = imagepath + imagepaths[page] = imagepaths[page] filedims[page] = get_file_dim(filepath) imagedims[page] = get_image_dim(imagepath) diff --git a/excalibur/www/static/js/vendor/jquery.selectareas.min.js b/excalibur/www/static/js/vendor/jquery.selectareas.min.js index 988ebdb..bd1c342 100644 --- a/excalibur/www/static/js/vendor/jquery.selectareas.min.js +++ b/excalibur/www/static/js/vendor/jquery.selectareas.min.js @@ -1 +1 @@ -!function(e){e.imageArea=function(t,i){var a,o,s,n=t.options,r=t.$image,h=t.$trigger,c={},l=!0,d=!0,u=[0,0],g=[0,0],p={id:i,x:0,y:0,z:0,height:0,width:0},m=function(){p.z=0,M("blur")},f=function(){t.blurAll(),p.z=100,M()},w=function(){return p},v=function(e){r.trigger(e,[p.id,t.areas()])},y=function(e){var t=e||window.event||{};t.cancelBubble=!0,t.returnValue=!1,t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()},S=function(){e.each(arguments,function(e,t){A(t)})},A=function(t,i){var a,o;switch(t){case"start":a="mousedown",o="touchstart";break;case"move":a="mousemove",o="touchmove";break;case"stop":a="mouseup",o="touchend";break;default:return}i&&jQuery.isFunction(i)?e(window.document).on(a,i).on(o,i):e(window.document).off(a).off(o)},x=function(){a.css({cursor:"default",width:p.width,height:p.height,left:p.x,top:p.y,"z-index":p.z}),o.css({backgroundPosition:-p.x-1+"px "+(-p.y-1)+"px",cursor:n.allowMove?"move":"default",width:p.width-2>0?p.width-2:0,height:p.height-2>0?p.height-2:0,left:p.x+1,top:p.y+1,"z-index":p.z+2})},b=function(t){n.allowResize&&(t?e.each(c,function(e,t){var i,a,o=Math.round(t.width()/2),s=Math.round(t.height()/2),n=e[0],r=e[e.length-1];i="n"===n?-s:"s"===n?p.height-s-1:Math.round(p.height/2)-s-1,a="e"===r?p.width-o-1:"w"===r?-o:Math.round(p.width/2)-o-1,t.css({display:"block",left:p.x+a,top:p.y+i,"z-index":p.z+1})}):e(".select-areas-resize-handler").each(function(){e(this).css({display:"none"})}))},z=function(e){s&&s.css({display:e?"block":"none",left:p.x+p.width+1,top:p.y-s.outerHeight()-1,"z-index":p.z+1})},$=function(e){a.css({cursor:e}),o.css({cursor:e})},M=function(e){switch(e){case"startSelection":t._refresh(),x(),b(),z(!0);break;case"pickSelection":case"pickResizeHandler":b();break;case"resizeSelection":x(),b(),$("crosshair"),z(!0);break;case"moveSelection":x(),b(),$("move"),z(!0);break;case"blur":x(),b(),z();break;default:x(),b(!0),z(!0)}},_=function(e){y(e),p.width=n.minSize[0],p.height=n.minSize[1],f(),A("move",C),A("stop",j),g=H(e),g[0]+p.width>r.width()&&(g[0]=r.width()-p.width),g[1]+p.height>r.height()&&(g[1]=r.height()-p.height),p.x=g[0],p.y=g[1],M("startSelection")},k=function(e){y(e),f(),A("move",D),A("stop",j);var t=H(e);u[0]=t[0]-p.x,u[1]=t[1]-p.y,M("pickSelection")},R=function(e){y(e),f();var t=e.target.className.split(" ")[1];"w"===t[t.length-1]&&(g[0]+=p.width,p.x=g[0]-p.width),"n"===t[0]&&(g[1]+=p.height,p.y=g[1]-p.height),"n"===t||"s"===t?l=!1:("e"===t||"w"===t)&&(d=!1),A("move",C),A("stop",j),M("pickResizeHandler")},C=function(e){y(e),f();var t=H(e),i=t[1]-g[1],a=t[0]-g[0];Math.abs(a)=0?n.minSize[0]:-n.minSize[0]),Math.abs(i)=0?n.minSize[1]:-n.minSize[1]),(g[0]+a<0||g[0]+a>r.width())&&(a=-a),(g[1]+i<0||g[1]+i>r.height())&&(i=-i),n.maxSize[0]>n.minSize[0]&&n.maxSize[1]>n.minSize[1]&&(Math.abs(a)>n.maxSize[0]&&(a=a>=0?n.maxSize[0]:-n.maxSize[0]),Math.abs(i)>n.maxSize[1]&&(i=i>=0?n.maxSize[1]:-n.maxSize[1])),l&&(p.width=a),d&&(p.height=i),n.aspectRatio&&(a>0&&i>0||0>a&&0>i?l?i=Math.round(a/n.aspectRatio):a=Math.round(i*n.aspectRatio):l?i=-Math.round(a/n.aspectRatio):a=-Math.round(i*n.aspectRatio),g[0]+a>r.width()&&(a=r.width()-g[0],i=i>0?Math.round(a/n.aspectRatio):-Math.round(a/n.aspectRatio)),g[1]+i<0&&(i=-g[1],a=a>0?-Math.round(i*n.aspectRatio):Math.round(i*n.aspectRatio)),g[1]+i>r.height()&&(i=r.height()-g[1],a=a>0?Math.round(i*n.aspectRatio):-Math.round(i*n.aspectRatio)),p.width=a,p.height=i),p.width<0?(p.width=Math.abs(p.width),p.x=g[0]-p.width):p.x=g[0],p.height<0?(p.height=Math.abs(p.height),p.y=g[1]-p.height):p.y=g[1],v("changing"),M("resizeSelection")},D=function(e){if(y(e),n.allowMove){f();var t=H(e);I({x:t[0]-u[0],y:t[1]-u[1]}),v("changing")}},I=function(e){e.x>0?e.x+p.width0?e.y+p.heighti?0:i>r.width()?r.width():i,a=0>a?0:a>r.height()?r.height():a,[i,a]};if(a=e('
').css({opacity:n.outlineOpacity,position:"absolute"}).insertAfter(h),o=e("
").addClass("select-areas-background-area").css({background:"#fff url("+r.attr("src")+") no-repeat",backgroundSize:r.width()+"px",position:"absolute"}).insertAfter(a),n.allowResize&&e.each(["nw","n","ne","e","se","s","sw","w"],function(t,i){c[i]=e('
').css({opacity:.5,position:"absolute",cursor:i+"-resize"}).insertAfter(o).mousedown(R).bind("touchstart",R)}),n.allowDelete){var N=function(e){return e.click(E).bind("touchstart",E).bind("tap",E),e};s=N(e('
')).append(N(e('
'))).insertAfter(o)}return n.allowMove&&o.mousedown(k).bind("touchstart",k),f(),{getData:w,startSelection:_,deleteSelection:E,options:n,blur:m,focus:f,nudge:function(e){e.x=p.x,e.y=p.y,e.d&&(e.y=p.y+e.d),e.u&&(e.y=p.y-e.u),e.l&&(e.x=p.x-e.l),e.r&&(e.x=p.x+e.r),I(e),v("changed")},set:function(t,i){p=e.extend(p,t),g[0]=p.x,g[1]=p.y,i||v("changed")},contains:function(e){return e.x>=p.x&&e.x<=p.x+p.width&&e.y>=p.y&&e.y<=p.y+p.height}}},e.imageSelectAreas=function(){},e.imageSelectAreas.prototype.init=function(t,i){var a=this,o={allowEdit:!0,allowMove:!0,allowResize:!0,allowSelect:!0,allowDelete:!0,allowNudge:!0,aspectRatio:0,minSize:[0,0],maxSize:[0,0],width:0,maxAreas:0,outlineOpacity:.5,overlayOpacity:.5,areas:[],onChanging:null,onChanged:null};this.options=e.extend(o,i),this.options.allowEdit||(this.options.allowSelect=this.options.allowMove=this.options.allowResize=this.options.allowDelete=!1),this._areas={},this.$image=e(t),this.ratio=1,this.options.width&&this.$image.width()&&this.options.width!==this.$image.width()&&(this.ratio=this.options.width/this.$image.width(),this.$image.width(this.options.width)),this.options.onChanging&&this.$image.on("changing",this.options.onChanging),this.options.onChanged&&this.$image.on("changed",this.options.onChanged),this.options.onLoaded&&this.$image.on("loaded",this.options.onLoaded),this.$holder=e("
").css({position:"relative",width:this.$image.width(),height:this.$image.height()}),this.$image.wrap(this.$holder).css({position:"absolute"}),this.$overlay=e('
').css({opacity:this.options.overlayOpacity,position:"absolute",width:this.$image.width(),height:this.$image.height()}).insertAfter(this.$image),this.$trigger=e("
").css({backgroundColor:"#000000",opacity:0,position:"absolute",width:this.$image.width(),height:this.$image.height()}).insertAfter(this.$overlay),e.each(this.options.areas,function(e,t){a._add(t,!0)}),this.blurAll(),this._refresh(),this.options.allowSelect&&this.$trigger.mousedown(e.proxy(this.newArea,this)).on("touchstart",e.proxy(this.newArea,this)),this.options.allowNudge&&e("html").keydown(function(e){var t,i={37:"l",38:"u",39:"r",40:"d"},o=i[e.which];if(o&&(a._eachArea(function(e){return 100===e.getData().z?(t=e,!1):void 0}),t)){var s={};s[o]=1,t.nudge(s)}})},e.imageSelectAreas.prototype._refresh=function(){var e=this.areas().length;this.$overlay.css({display:e?"block":"none"}),e?this.$image.addClass("blurred"):this.$image.removeClass("blurred"),this.$trigger.css({cursor:this.options.allowSelect?"crosshair":"default"})},e.imageSelectAreas.prototype._eachArea=function(t){e.each(this._areas,function(e,i){return i?t(i,e):void 0})},e.imageSelectAreas.prototype._remove=function(e){delete this._areas[e],this._refresh()},e.imageSelectAreas.prototype.remove=function(e){this._areas[e]&&this._areas[e].deleteSelection()},e.imageSelectAreas.prototype.newArea=function(t){var i=-1;return this.blurAll(),this.options.maxAreas&&this.options.maxAreas<=this.areas().length?i:(this._eachArea(function(e,t){i=Math.max(i,parseInt(t,10))}),i+=1,this._areas[i]=e.imageArea(this,i),t&&this._areas[i].startSelection(t),i)},e.imageSelectAreas.prototype.set=function(e,t,i){this._areas[e]&&(t.id=e,this._areas[e].set(t,i),this._areas[e].focus())},e.imageSelectAreas.prototype._add=function(e,t){var i=this.newArea();this.set(i,e,t)},e.imageSelectAreas.prototype.add=function(t){var i=this;this.blurAll(),e.isArray(t)?e.each(t,function(e,t){i._add(t)}):this._add(t),this._refresh(),this.options.allowSelect||this.options.allowMove||this.options.allowResize||this.options.allowDelete||this.blurAll()},e.imageSelectAreas.prototype.reset=function(){var e=this;this._eachArea(function(t,i){e.remove(i)}),this._refresh()},e.imageSelectAreas.prototype.destroy=function(){this.reset(),this.$holder.remove(),this.$overlay.remove(),this.$trigger.remove(),this.$image.css("width","").css("position","").unwrap(),this.$image.removeData("mainImageSelectAreas")},e.imageSelectAreas.prototype.areas=function(){var e=[];return this._eachArea(function(t){e.push(t.getData())}),e},e.imageSelectAreas.prototype.relativeAreas=function(){for(var t=this.areas(),i=[],a=this.ratio,o=function(e){return Math.floor(e/a)},s=0;s0?p.width-2:0,height:p.height-2>0?p.height-2:0,left:p.x+1,top:p.y+1,"z-index":p.z+2})},b=function(t){n.allowResize&&(t?e.each(c,function(e,t){var i,a,o=Math.round(t.width()/2),s=Math.round(t.height()/2),n=e[0],r=e[e.length-1];i="n"===n?-s:"s"===n?p.height-s-1:Math.round(p.height/2)-s-1,a="e"===r?p.width-o-1:"w"===r?-o:Math.round(p.width/2)-o-1,t.css({display:"block",left:p.x+a,top:p.y+i,"z-index":p.z+1})}):e(".select-areas-resize-handler").each(function(){e(this).css({display:"none"})}))},z=function(e){s&&s.css({display:e?"block":"none",left:p.x+p.width+1,top:p.y-s.outerHeight()-1,"z-index":p.z+1})},$=function(e){a.css({cursor:e}),o.css({cursor:e})},M=function(e){switch(e){case"startSelection":t._refresh(),x(),b(),z(!0);break;case"pickSelection":case"pickResizeHandler":b();break;case"resizeSelection":x(),b(),$("crosshair"),z(!0);break;case"moveSelection":x(),b(),$("move"),z(!0);break;case"blur":x(),b(),z();break;default:x(),b(!0),z(!0)}},_=function(e){y(e),p.width=n.minSize[0],p.height=n.minSize[1],f(),A("move",C),A("stop",j),g=H(e),g[0]+p.width>r.width()&&(g[0]=r.width()-p.width),g[1]+p.height>r.height()&&(g[1]=r.height()-p.height),p.x=g[0],p.y=g[1],M("startSelection")},k=function(e){y(e),f(),A("move",D),A("stop",j);var t=H(e);u[0]=t[0]-p.x,u[1]=t[1]-p.y,M("pickSelection")},R=function(e){y(e),f();var t=e.target.className.split(" ")[1];"w"===t[t.length-1]&&(g[0]+=p.width,p.x=g[0]-p.width),"n"===t[0]&&(g[1]+=p.height,p.y=g[1]-p.height),"n"===t||"s"===t?l=!1:("e"===t||"w"===t)&&(d=!1),A("move",C),A("stop",j),M("pickResizeHandler")},C=function(e){y(e),f();var t=H(e),i=t[1]-g[1],a=t[0]-g[0];Math.abs(a)=0?n.minSize[0]:-n.minSize[0]),Math.abs(i)=0?n.minSize[1]:-n.minSize[1]),(g[0]+a<0||g[0]+a>r.width())&&(a=-a),(g[1]+i<0||g[1]+i>r.height())&&(i=-i),n.maxSize[0]>n.minSize[0]&&n.maxSize[1]>n.minSize[1]&&(Math.abs(a)>n.maxSize[0]&&(a=a>=0?n.maxSize[0]:-n.maxSize[0]),Math.abs(i)>n.maxSize[1]&&(i=i>=0?n.maxSize[1]:-n.maxSize[1])),l&&(p.width=a),d&&(p.height=i),n.aspectRatio&&(a>0&&i>0||0>a&&0>i?l?i=Math.round(a/n.aspectRatio):a=Math.round(i*n.aspectRatio):l?i=-Math.round(a/n.aspectRatio):a=-Math.round(i*n.aspectRatio),g[0]+a>r.width()&&(a=r.width()-g[0],i=i>0?Math.round(a/n.aspectRatio):-Math.round(a/n.aspectRatio)),g[1]+i<0&&(i=-g[1],a=a>0?-Math.round(i*n.aspectRatio):Math.round(i*n.aspectRatio)),g[1]+i>r.height()&&(i=r.height()-g[1],a=a>0?Math.round(i*n.aspectRatio):-Math.round(i*n.aspectRatio)),p.width=a,p.height=i),p.width<0?(p.width=Math.abs(p.width),p.x=g[0]-p.width):p.x=g[0],p.height<0?(p.height=Math.abs(p.height),p.y=g[1]-p.height):p.y=g[1],v("changing"),M("resizeSelection")},D=function(e){if(y(e),n.allowMove){f();var t=H(e);I({x:t[0]-u[0],y:t[1]-u[1]}),v("changing")}},I=function(e){e.x>0?e.x+p.width0?e.y+p.heighti?0:i>r.width()?r.width():i,a=0>a?0:a>r.height()?r.height():a,[i,a]};if(a=e('
').css({opacity:n.outlineOpacity,position:"absolute"}).insertAfter(h),o=e("
").addClass("select-areas-background-area").css({background:"#fff url("+r.attr("src").replace(/\\/g, "/") +") no-repeat",backgroundSize:r.width()+"px",position:"absolute"}).insertAfter(a),n.allowResize&&e.each(["nw","n","ne","e","se","s","sw","w"],function(t,i){c[i]=e('
').css({opacity:.5,position:"absolute",cursor:i+"-resize"}).insertAfter(o).mousedown(R).bind("touchstart",R)}),n.allowDelete){var N=function(e){return e.click(E).bind("touchstart",E).bind("tap",E),e};s=N(e('
')).append(N(e('
'))).insertAfter(o)}return n.allowMove&&o.mousedown(k).bind("touchstart",k),f(),{getData:w,startSelection:_,deleteSelection:E,options:n,blur:m,focus:f,nudge:function(e){e.x=p.x,e.y=p.y,e.d&&(e.y=p.y+e.d),e.u&&(e.y=p.y-e.u),e.l&&(e.x=p.x-e.l),e.r&&(e.x=p.x+e.r),I(e),v("changed")},set:function(t,i){p=e.extend(p,t),g[0]=p.x,g[1]=p.y,i||v("changed")},contains:function(e){return e.x>=p.x&&e.x<=p.x+p.width&&e.y>=p.y&&e.y<=p.y+p.height}}},e.imageSelectAreas=function(){},e.imageSelectAreas.prototype.init=function(t,i){var a=this,o={allowEdit:!0,allowMove:!0,allowResize:!0,allowSelect:!0,allowDelete:!0,allowNudge:!0,aspectRatio:0,minSize:[0,0],maxSize:[0,0],width:0,maxAreas:0,outlineOpacity:.5,overlayOpacity:.5,areas:[],onChanging:null,onChanged:null};this.options=e.extend(o,i),this.options.allowEdit||(this.options.allowSelect=this.options.allowMove=this.options.allowResize=this.options.allowDelete=!1),this._areas={},this.$image=e(t),this.ratio=1,this.options.width&&this.$image.width()&&this.options.width!==this.$image.width()&&(this.ratio=this.options.width/this.$image.width(),this.$image.width(this.options.width)),this.options.onChanging&&this.$image.on("changing",this.options.onChanging),this.options.onChanged&&this.$image.on("changed",this.options.onChanged),this.options.onLoaded&&this.$image.on("loaded",this.options.onLoaded),this.$holder=e("
").css({position:"relative",width:this.$image.width(),height:this.$image.height()}),this.$image.wrap(this.$holder).css({position:"absolute"}),this.$overlay=e('
').css({opacity:this.options.overlayOpacity,position:"absolute",width:this.$image.width(),height:this.$image.height()}).insertAfter(this.$image),this.$trigger=e("
").css({backgroundColor:"#000000",opacity:0,position:"absolute",width:this.$image.width(),height:this.$image.height()}).insertAfter(this.$overlay),e.each(this.options.areas,function(e,t){a._add(t,!0)}),this.blurAll(),this._refresh(),this.options.allowSelect&&this.$trigger.mousedown(e.proxy(this.newArea,this)).on("touchstart",e.proxy(this.newArea,this)),this.options.allowNudge&&e("html").keydown(function(e){var t,i={37:"l",38:"u",39:"r",40:"d"},o=i[e.which];if(o&&(a._eachArea(function(e){return 100===e.getData().z?(t=e,!1):void 0}),t)){var s={};s[o]=1,t.nudge(s)}})},e.imageSelectAreas.prototype._refresh=function(){var e=this.areas().length;this.$overlay.css({display:e?"block":"none"}),e?this.$image.addClass("blurred"):this.$image.removeClass("blurred"),this.$trigger.css({cursor:this.options.allowSelect?"crosshair":"default"})},e.imageSelectAreas.prototype._eachArea=function(t){e.each(this._areas,function(e,i){return i?t(i,e):void 0})},e.imageSelectAreas.prototype._remove=function(e){delete this._areas[e],this._refresh()},e.imageSelectAreas.prototype.remove=function(e){this._areas[e]&&this._areas[e].deleteSelection()},e.imageSelectAreas.prototype.newArea=function(t){var i=-1;return this.blurAll(),this.options.maxAreas&&this.options.maxAreas<=this.areas().length?i:(this._eachArea(function(e,t){i=Math.max(i,parseInt(t,10))}),i+=1,this._areas[i]=e.imageArea(this,i),t&&this._areas[i].startSelection(t),i)},e.imageSelectAreas.prototype.set=function(e,t,i){this._areas[e]&&(t.id=e,this._areas[e].set(t,i),this._areas[e].focus())},e.imageSelectAreas.prototype._add=function(e,t){var i=this.newArea();this.set(i,e,t)},e.imageSelectAreas.prototype.add=function(t){var i=this;this.blurAll(),e.isArray(t)?e.each(t,function(e,t){i._add(t)}):this._add(t),this._refresh(),this.options.allowSelect||this.options.allowMove||this.options.allowResize||this.options.allowDelete||this.blurAll()},e.imageSelectAreas.prototype.reset=function(){var e=this;this._eachArea(function(t,i){e.remove(i)}),this._refresh()},e.imageSelectAreas.prototype.destroy=function(){this.reset(),this.$holder.remove(),this.$overlay.remove(),this.$trigger.remove(),this.$image.css("width","").css("position","").unwrap(),this.$image.removeData("mainImageSelectAreas")},e.imageSelectAreas.prototype.areas=function(){var e=[];return this._eachArea(function(t){e.push(t.getData())}),e},e.imageSelectAreas.prototype.relativeAreas=function(){for(var t=this.areas(),i=[],a=this.ratio,o=function(e){return Math.floor(e/a)},s=0;s