From 6f38f7d8887acccf5cd90954d0b3cd99fa9d07af Mon Sep 17 00:00:00 2001 From: Chris Nielsen Date: Tue, 3 Feb 2015 11:47:41 -0500 Subject: [PATCH] Remove unused variables and function parameters This clears various warnings emitted by UglifyJS2. --- js/jquery.Jcrop.js | 9 ++++----- js/jquery.Jcrop.min.js | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/js/jquery.Jcrop.js b/js/jquery.Jcrop.js index 09b1bcf7..cff8f2e4 100644 --- a/js/jquery.Jcrop.js +++ b/js/jquery.Jcrop.js @@ -213,7 +213,7 @@ }; } //}}} - function doneSelect(pos) //{{{ + function doneSelect() //{{{ { var c = Coords.getFixed(); if ((c.w > options.minSelect[0]) && (c.h > options.minSelect[1])) { @@ -386,7 +386,7 @@ // Set more variables {{{ var bgcolor = options.bgColor, bgopacity = options.bgOpacity, - xlimit, ylimit, xmin, ymin, xscale, yscale, enabled = true, + xlimit, ylimit, xmin, ymin, xscale, yscale, btndown, animating, shift_down; docOffset = getPos($img); @@ -1239,7 +1239,7 @@ } } //}}} - function onBlur(e) //{{{ + function onBlur() //{{{ { $keymgr.hide(); } @@ -1341,7 +1341,6 @@ y2 = animat[3]; Selection.animMode(true); - var anim_timer; function queueAnimator() { window.setTimeout(animator, interv); @@ -1628,7 +1627,7 @@ $img .bind('load.jcloader',completeCheck) - .bind('error.jcloader',function(e){ + .bind('error.jcloader',function(){ $img.unbind('.jcloader'); if ($.isFunction(error)) error.call(img); }); diff --git a/js/jquery.Jcrop.min.js b/js/jquery.Jcrop.min.js index d9ae1adf..f1268994 100644 --- a/js/jquery.Jcrop.min.js +++ b/js/jquery.Jcrop.min.js @@ -1,7 +1,7 @@ /** - * jquery.Jcrop.min.js v0.9.12 (build:20140524) + * jquery.Jcrop.min.js v0.9.12 (build:20150203) * jQuery Image Cropping Plugin - released under MIT License * Copyright (c) 2008-2013 Tapmodo Interactive LLC * https://github.com/tapmodo/Jcrop */ -!function($){$.Jcrop=function(obj,opt){function px(n){return Math.round(n)+"px"}function cssClass(cl){return options.baseClass+"-"+cl}function supportsColorFade(){return $.fx.step.hasOwnProperty("backgroundColor")}function getPos(obj){var pos=$(obj).offset();return[pos.left,pos.top]}function mouseAbs(e){return[e.pageX-docOffset[0],e.pageY-docOffset[1]]}function setOptions(opt){"object"!=typeof opt&&(opt={}),options=$.extend(options,opt),$.each(["onChange","onSelect","onRelease","onDblClick"],function(i,e){"function"!=typeof options[e]&&(options[e]=function(){})})}function startDragMode(mode,pos,touch){if(docOffset=getPos($img),Tracker.setCursor("move"===mode?mode:mode+"-resize"),"move"===mode)return Tracker.activateHandlers(createMover(pos),doneSelect,touch);var fc=Coords.getFixed(),opp=oppLockCorner(mode),opc=Coords.getCorner(oppLockCorner(opp));Coords.setPressed(Coords.getCorner(opp)),Coords.setCurrent(opc),Tracker.activateHandlers(dragmodeHandler(mode,fc),doneSelect,touch)}function dragmodeHandler(mode,f){return function(pos){if(options.aspectRatio)switch(mode){case"e":pos[1]=f.y+1;break;case"w":pos[1]=f.y+1;break;case"n":pos[0]=f.x+1;break;case"s":pos[0]=f.x+1}else switch(mode){case"e":pos[1]=f.y2;break;case"w":pos[1]=f.y2;break;case"n":pos[0]=f.x2;break;case"s":pos[0]=f.x2}Coords.setCurrent(pos),Selection.update()}}function createMover(pos){var lloc=pos;return KeyManager.watchKeys(),function(pos){Coords.moveOffset([pos[0]-lloc[0],pos[1]-lloc[1]]),lloc=pos,Selection.update()}}function oppLockCorner(ord){switch(ord){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function createDragger(ord){return function(e){return options.disabled?!1:"move"!==ord||options.allowMove?(docOffset=getPos($img),btndown=!0,startDragMode(ord,mouseAbs(e)),e.stopPropagation(),e.preventDefault(),!1):!1}}function presize($obj,w,h){var nw=$obj.width(),nh=$obj.height();nw>w&&w>0&&(nw=w,nh=w/$obj.width()*$obj.height()),nh>h&&h>0&&(nh=h,nw=h/$obj.height()*$obj.width()),xscale=$obj.width()/nw,yscale=$obj.height()/nh,$obj.width(nw).height(nh)}function unscale(c){return{x:c.x*xscale,y:c.y*yscale,x2:c.x2*xscale,y2:c.y2*yscale,w:c.w*xscale,h:c.h*yscale}}function doneSelect(){var c=Coords.getFixed();c.w>options.minSelect[0]&&c.h>options.minSelect[1]?(Selection.enableHandles(),Selection.done()):Selection.release(),Tracker.setCursor(options.allowSelect?"crosshair":"default")}function newSelection(e){if(!options.disabled&&options.allowSelect){btndown=!0,docOffset=getPos($img),Selection.disableHandles(),Tracker.setCursor("crosshair");var pos=mouseAbs(e);return Coords.setPressed(pos),Selection.update(),Tracker.activateHandlers(selectDrag,doneSelect,"touch"===e.type.substring(0,5)),KeyManager.watchKeys(),e.stopPropagation(),e.preventDefault(),!1}}function selectDrag(pos){Coords.setCurrent(pos),Selection.update()}function newTracker(){var trk=$("
").addClass(cssClass("tracker"));return is_msie&&trk.css({opacity:0,backgroundColor:"white"}),trk}function setClass(cname){$div.removeClass().addClass(cssClass("holder")).addClass(cname)}function animateTo(a,callback){function queueAnimator(){window.setTimeout(animator,interv)}var x1=a[0]/xscale,y1=a[1]/yscale,x2=a[2]/xscale,y2=a[3]/yscale;if(!animating){var animto=Coords.flipCoords(x1,y1,x2,y2),c=Coords.getFixed(),initcr=[c.x,c.y,c.x2,c.y2],animat=initcr,interv=options.animationDelay,ix1=animto[0]-initcr[0],iy1=animto[1]-initcr[1],ix2=animto[2]-initcr[2],iy2=animto[3]-initcr[3],pcent=0,velocity=options.swingSpeed;x1=animat[0],y1=animat[1],x2=animat[2],y2=animat[3],Selection.animMode(!0);var animator=function(){return function(){pcent+=(100-pcent)/velocity,animat[0]=Math.round(x1+pcent/100*ix1),animat[1]=Math.round(y1+pcent/100*iy1),animat[2]=Math.round(x2+pcent/100*ix2),animat[3]=Math.round(y2+pcent/100*iy2),pcent>=99.8&&(pcent=100),100>pcent?(setSelectRaw(animat),queueAnimator()):(Selection.done(),Selection.animMode(!1),"function"==typeof callback&&callback.call(api))}}();queueAnimator()}}function setSelect(rect){setSelectRaw([rect[0]/xscale,rect[1]/yscale,rect[2]/xscale,rect[3]/yscale]),options.onSelect.call(api,unscale(Coords.getFixed())),Selection.enableHandles()}function setSelectRaw(l){Coords.setPressed([l[0],l[1]]),Coords.setCurrent([l[2],l[3]]),Selection.update()}function tellSelect(){return unscale(Coords.getFixed())}function tellScaled(){return Coords.getFixed()}function setOptionsNew(opt){setOptions(opt),interfaceUpdate()}function disableCrop(){options.disabled=!0,Selection.disableHandles(),Selection.setCursor("default"),Tracker.setCursor("default")}function enableCrop(){options.disabled=!1,interfaceUpdate()}function cancelCrop(){Selection.done(),Tracker.activateHandlers(null,null)}function destroy(){$div.remove(),$origimg.show(),$origimg.css("visibility","visible"),$(obj).removeData("Jcrop")}function setImage(src,callback){Selection.release(),disableCrop();var img=new Image;img.onload=function(){var iw=img.width,ih=img.height,bw=options.boxWidth,bh=options.boxHeight;$img.width(iw).height(ih),$img.attr("src",src),$img2.attr("src",src),presize($img,bw,bh),boundx=$img.width(),boundy=$img.height(),$img2.width(boundx).height(boundy),$trk.width(boundx+2*bound).height(boundy+2*bound),$div.width(boundx).height(boundy),Shade.resize(boundx,boundy),enableCrop(),"function"==typeof callback&&callback.call(api)},img.src=src}function colorChangeMacro($obj,color,now){var mycolor=color||options.bgColor;options.bgFade&&supportsColorFade()&&options.fadeTime&&!now?$obj.animate({backgroundColor:mycolor},{queue:!1,duration:options.fadeTime}):$obj.css("backgroundColor",mycolor)}function interfaceUpdate(alt){options.allowResize?alt?Selection.enableOnly():Selection.enableHandles():Selection.disableHandles(),Tracker.setCursor(options.allowSelect?"crosshair":"default"),Selection.setCursor(options.allowMove?"move":"default"),options.hasOwnProperty("trueSize")&&(xscale=options.trueSize[0]/boundx,yscale=options.trueSize[1]/boundy),options.hasOwnProperty("setSelect")&&(setSelect(options.setSelect),Selection.done(),delete options.setSelect),Shade.refresh(),options.bgColor!=bgcolor&&(colorChangeMacro(options.shade?Shade.getShades():$div,options.shade?options.shadeColor||options.bgColor:options.bgColor),bgcolor=options.bgColor),bgopacity!=options.bgOpacity&&(bgopacity=options.bgOpacity,options.shade?Shade.refresh():Selection.setBgOpacity(bgopacity)),xlimit=options.maxSize[0]||0,ylimit=options.maxSize[1]||0,xmin=options.minSize[0]||0,ymin=options.minSize[1]||0,options.hasOwnProperty("outerImage")&&($img.attr("src",options.outerImage),delete options.outerImage),Selection.refresh()}var docOffset,options=$.extend({},$.Jcrop.defaults),_ua=navigator.userAgent.toLowerCase(),is_msie=/msie/.test(_ua),ie6mode=/msie [1-6]\./.test(_ua);"object"!=typeof obj&&(obj=$(obj)[0]),"object"!=typeof opt&&(opt={}),setOptions(opt);var img_css={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},$origimg=$(obj),img_mode=!0;if("IMG"==obj.tagName){if(0!=$origimg[0].width&&0!=$origimg[0].height)$origimg.width($origimg[0].width),$origimg.height($origimg[0].height);else{var tempImage=new Image;tempImage.src=$origimg[0].src,$origimg.width(tempImage.width),$origimg.height(tempImage.height)}var $img=$origimg.clone().removeAttr("id").css(img_css).show();$img.width($origimg.width()),$img.height($origimg.height()),$origimg.after($img).hide()}else $img=$origimg.css(img_css).show(),img_mode=!1,null===options.shade&&(options.shade=!0);presize($img,options.boxWidth,options.boxHeight);var boundx=$img.width(),boundy=$img.height(),$div=$("
").width(boundx).height(boundy).addClass(cssClass("holder")).css({position:"relative",backgroundColor:options.bgColor}).insertAfter($origimg).append($img);options.addClass&&$div.addClass(options.addClass);var $img2=$("
"),$img_holder=$("
").width("100%").height("100%").css({zIndex:310,position:"absolute",overflow:"hidden"}),$hdl_holder=$("
").width("100%").height("100%").css("zIndex",320),$sel=$("
").css({position:"absolute",zIndex:600}).dblclick(function(){var c=Coords.getFixed();options.onDblClick.call(api,c)}).insertBefore($img).append($img_holder,$hdl_holder);img_mode&&($img2=$("").attr("src",$img.attr("src")).css(img_css).width(boundx).height(boundy),$img_holder.append($img2)),ie6mode&&$sel.css({overflowY:"hidden"});var xlimit,ylimit,xmin,ymin,xscale,yscale,btndown,animating,shift_down,bound=options.boundary,$trk=newTracker().width(boundx+2*bound).height(boundy+2*bound).css({position:"absolute",top:px(-bound),left:px(-bound),zIndex:290}).mousedown(newSelection),bgcolor=options.bgColor,bgopacity=options.bgOpacity;docOffset=getPos($img);var Touch=function(){function hasTouchSupport(){var i,support={},events=["touchstart","touchmove","touchend"],el=document.createElement("div");try{for(i=0;ix1+ox&&(ox-=ox+x1),0>y1+oy&&(oy-=oy+y1),y2+oy>boundy&&(oy+=boundy-(y2+oy)),x2+ox>boundx&&(ox+=boundx-(x2+ox)),x1+=ox,x2+=ox,y1+=oy,y2+=oy}function getCorner(ord){var c=getFixed();switch(ord){case"ne":return[c.x2,c.y];case"nw":return[c.x,c.y];case"se":return[c.x2,c.y2];case"sw":return[c.x,c.y2]}}function getFixed(){if(!options.aspectRatio)return getRect();var xx,yy,w,h,aspect=options.aspectRatio,min_x=options.minSize[0]/xscale,max_x=options.maxSize[0]/xscale,max_y=options.maxSize[1]/yscale,rw=x2-x1,rh=y2-y1,rwa=Math.abs(rw),rha=Math.abs(rh),real_ratio=rwa/rha;return 0===max_x&&(max_x=10*boundx),0===max_y&&(max_y=10*boundy),aspect>real_ratio?(yy=y2,w=rha*aspect,xx=0>rw?x1-w:w+x1,0>xx?(xx=0,h=Math.abs((xx-x1)/aspect),yy=0>rh?y1-h:h+y1):xx>boundx&&(xx=boundx,h=Math.abs((xx-x1)/aspect),yy=0>rh?y1-h:h+y1)):(xx=x2,h=rwa/aspect,yy=0>rh?y1-h:y1+h,0>yy?(yy=0,w=Math.abs((yy-y1)*aspect),xx=0>rw?x1-w:w+x1):yy>boundy&&(yy=boundy,w=Math.abs(yy-y1)*aspect,xx=0>rw?x1-w:w+x1)),xx>x1?(min_x>xx-x1?xx=x1+min_x:xx-x1>max_x&&(xx=x1+max_x),yy=yy>y1?y1+(xx-x1)/aspect:y1-(xx-x1)/aspect):x1>xx&&(min_x>x1-xx?xx=x1-min_x:x1-xx>max_x&&(xx=x1-max_x),yy=yy>y1?y1+(x1-xx)/aspect:y1-(x1-xx)/aspect),0>xx?(x1-=xx,xx=0):xx>boundx&&(x1-=xx-boundx,xx=boundx),0>yy?(y1-=yy,yy=0):yy>boundy&&(y1-=yy-boundy,yy=boundy),makeObj(flipCoords(x1,y1,xx,yy))}function rebound(p){return p[0]<0&&(p[0]=0),p[1]<0&&(p[1]=0),p[0]>boundx&&(p[0]=boundx),p[1]>boundy&&(p[1]=boundy),[Math.round(p[0]),Math.round(p[1])]}function flipCoords(x1,y1,x2,y2){var xa=x1,xb=x2,ya=y1,yb=y2;return x1>x2&&(xa=x2,xb=x1),y1>y2&&(ya=y2,yb=y1),[xa,ya,xb,yb]}function getRect(){var delta,xsize=x2-x1,ysize=y2-y1;return xlimit&&Math.abs(xsize)>xlimit&&(x2=xsize>0?x1+xlimit:x1-xlimit),ylimit&&Math.abs(ysize)>ylimit&&(y2=ysize>0?y1+ylimit:y1-ylimit),ymin/yscale&&Math.abs(ysize)0?y1+ymin/yscale:y1-ymin/yscale),xmin/xscale&&Math.abs(xsize)0?x1+xmin/xscale:x1-xmin/xscale),0>x1&&(x2-=x1,x1-=x1),0>y1&&(y2-=y1,y1-=y1),0>x2&&(x1-=x2,x2-=x2),0>y2&&(y1-=y2,y2-=y2),x2>boundx&&(delta=x2-boundx,x1-=delta,x2-=delta),y2>boundy&&(delta=y2-boundy,y1-=delta,y2-=delta),x1>boundx&&(delta=x1-boundy,y2-=delta,y1-=delta),y1>boundy&&(delta=y1-boundy,y2-=delta,y1-=delta),makeObj(flipCoords(x1,y1,x2,y2))}function makeObj(a){return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]}}var ox,oy,x1=0,y1=0,x2=0,y2=0;return{flipCoords:flipCoords,setPressed:setPressed,setCurrent:setCurrent,getOffset:getOffset,moveOffset:moveOffset,getCorner:getCorner,getFixed:getFixed}}(),Shade=function(){function resizeShades(w,h){shades.left.css({height:px(h)}),shades.right.css({height:px(h)})}function updateAuto(){return updateShade(Coords.getFixed())}function updateShade(c){shades.top.css({left:px(c.x),width:px(c.w),height:px(c.y)}),shades.bottom.css({top:px(c.y2),left:px(c.x),width:px(c.w),height:px(boundy-c.y2)}),shades.right.css({left:px(c.x2),width:px(boundx-c.x2)}),shades.left.css({width:px(c.x)})}function createShade(){return $("
").css({position:"absolute",backgroundColor:options.shadeColor||options.bgColor}).appendTo(holder)}function enableShade(){enabled||(enabled=!0,holder.insertBefore($img),updateAuto(),Selection.setBgOpacity(1,0,1),$img2.hide(),setBgColor(options.shadeColor||options.bgColor,1),Selection.isAwake()?setOpacity(options.bgOpacity,1):setOpacity(1,1))}function setBgColor(color,now){colorChangeMacro(getShades(),color,now)}function disableShade(){enabled&&(holder.remove(),$img2.show(),enabled=!1,Selection.isAwake()?Selection.setBgOpacity(options.bgOpacity,1,1):(Selection.setBgOpacity(1,1,1),Selection.disableHandles()),colorChangeMacro($div,0,1))}function setOpacity(opacity,now){enabled&&(options.bgFade&&!now?holder.animate({opacity:1-opacity},{queue:!1,duration:options.fadeTime}):holder.css({opacity:1-opacity}))}function refreshAll(){options.shade?enableShade():disableShade(),Selection.isAwake()&&setOpacity(options.bgOpacity)}function getShades(){return holder.children()}var enabled=!1,holder=$("
").css({position:"absolute",zIndex:240,opacity:0}),shades={top:createShade(),left:createShade().height(boundy),right:createShade().height(boundy),bottom:createShade()};return{update:updateAuto,updateRaw:updateShade,getShades:getShades,setBgColor:setBgColor,enable:enableShade,disable:disableShade,resize:resizeShades,refresh:refreshAll,opacity:setOpacity}}(),Selection=function(){function insertBorder(type){var jq=$("
").css({position:"absolute",opacity:options.borderOpacity}).addClass(cssClass(type));return $img_holder.append(jq),jq}function dragDiv(ord,zi){var jq=$("
").mousedown(createDragger(ord)).css({cursor:ord+"-resize",position:"absolute",zIndex:zi}).addClass("ord-"+ord);return Touch.support&&jq.bind("touchstart.jcrop",Touch.createDragger(ord)),$hdl_holder.append(jq),jq}function insertHandle(ord){var hs=options.handleSize,div=dragDiv(ord,hdep++).css({opacity:options.handleOpacity}).addClass(cssClass("handle"));return hs&&div.width(hs).height(hs),div}function insertDragbar(ord){return dragDiv(ord,hdep++).addClass("jcrop-dragbar")}function createDragbars(li){var i;for(i=0;i').css({position:"fixed",left:"-120px",width:"12px"}).addClass("jcrop-keymgr"),$keywrap=$("
").css({position:"absolute",overflow:"hidden"}).append($keymgr);return options.keySupport&&($keymgr.keydown(parseKey).blur(onBlur),ie6mode||!options.fixedSupport?($keymgr.css({position:"absolute",left:"-20px"}),$keywrap.append($keymgr).insertBefore($img)):$keymgr.insertBefore($img)),{watchKeys:watchKeys}}();Touch.support&&$trk.bind("touchstart.jcrop",Touch.newSelection),$hdl_holder.hide(),interfaceUpdate(!0);var api={setImage:setImage,animateTo:animateTo,setSelect:setSelect,setOptions:setOptionsNew,tellSelect:tellSelect,tellScaled:tellScaled,setClass:setClass,disable:disableCrop,enable:enableCrop,cancel:cancelCrop,release:Selection.release,destroy:destroy,focus:KeyManager.watchKeys,getBounds:function(){return[boundx*xscale,boundy*yscale]},getWidgetSize:function(){return[boundx,boundy]},getScaleFactor:function(){return[xscale,yscale]},getOptions:function(){return options},ui:{holder:$div,selection:$sel}};return is_msie&&$div.bind("selectstart",function(){return!1}),$origimg.data("Jcrop",api),api},$.fn.Jcrop=function(options,callback){var api;return this.each(function(){if($(this).data("Jcrop")){if("api"===options)return $(this).data("Jcrop");$(this).data("Jcrop").setOptions(options)}else"IMG"==this.tagName?$.Jcrop.Loader(this,function(){$(this).css({display:"block",visibility:"hidden"}),api=$.Jcrop(this,options),$.isFunction(callback)&&callback.call(api)}):($(this).css({display:"block",visibility:"hidden"}),api=$.Jcrop(this,options),$.isFunction(callback)&&callback.call(api))}),this},$.Jcrop.Loader=function(imgobj,success,error){function completeCheck(){img.complete?($img.unbind(".jcloader"),$.isFunction(success)&&success.call(img)):window.setTimeout(completeCheck,50)}var $img=$(imgobj),img=$img[0];$img.bind("load.jcloader",completeCheck).bind("error.jcloader",function(){$img.unbind(".jcloader"),$.isFunction(error)&&error.call(img)}),img.complete&&$.isFunction(success)&&($img.unbind(".jcloader"),success.call(img))},$.Jcrop.defaults={allowSelect:!0,allowMove:!0,allowResize:!0,trackDocument:!0,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,bgFade:!1,borderOpacity:.4,handleOpacity:.5,handleSize:null,aspectRatio:0,keySupport:!0,createHandles:["n","s","e","w","nw","ne","se","sw"],createDragbars:["n","s","e","w"],createBorders:["n","s","e","w"],drawBorders:!0,dragEdges:!0,fixedSupport:!0,touchSupport:null,shade:null,boxWidth:0,boxHeight:0,boundary:2,fadeTime:400,animationDelay:20,swingSpeed:3,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){},onDblClick:function(){},onRelease:function(){}}}(jQuery); \ No newline at end of file +!function(e){e.Jcrop=function(t,n){function o(e){return Math.round(e)+"px"}function r(e){return J.baseClass+"-"+e}function i(){return e.fx.step.hasOwnProperty("backgroundColor")}function a(t){var n=e(t).offset();return[n.left,n.top]}function s(e){return[e.pageX-P[0],e.pageY-P[1]]}function c(t){"object"!=typeof t&&(t={}),J=e.extend(J,t),e.each(["onChange","onSelect","onRelease","onDblClick"],function(e,t){"function"!=typeof J[t]&&(J[t]=function(){})})}function u(e,t,n){if(P=a(q),pt.setCursor("move"===e?e:e+"-resize"),"move"===e)return pt.activateHandlers(l(t),b,n);var o=lt.getFixed(),r=h(e),i=lt.getCorner(h(r));lt.setPressed(lt.getCorner(r)),lt.setCurrent(i),pt.activateHandlers(d(e,o),b,n)}function d(e,t){return function(n){if(J.aspectRatio)switch(e){case"e":n[1]=t.y+1;break;case"w":n[1]=t.y+1;break;case"n":n[0]=t.x+1;break;case"s":n[0]=t.x+1}else switch(e){case"e":n[1]=t.y2;break;case"w":n[1]=t.y2;break;case"n":n[0]=t.x2;break;case"s":n[0]=t.x2}lt.setCurrent(n),ft.update()}}function l(e){var t=e;return gt.watchKeys(),function(e){lt.moveOffset([e[0]-t[0],e[1]-t[1]]),t=e,ft.update()}}function h(e){switch(e){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function f(e){return function(t){return J.disabled?!1:"move"!==e||J.allowMove?(P=a(q),ot=!0,u(e,s(t)),t.stopPropagation(),t.preventDefault(),!1):!1}}function p(e,t,n){var o=e.width(),r=e.height();o>t&&t>0&&(o=t,r=t/e.width()*e.height()),r>n&&n>0&&(r=n,o=n/e.height()*e.width()),tt=e.width()/o,nt=e.height()/r,e.width(o).height(r)}function g(e){return{x:e.x*tt,y:e.y*nt,x2:e.x2*tt,y2:e.y2*nt,w:e.w*tt,h:e.h*nt}}function b(){var e=lt.getFixed();e.w>J.minSelect[0]&&e.h>J.minSelect[1]?(ft.enableHandles(),ft.done()):ft.release(),pt.setCursor(J.allowSelect?"crosshair":"default")}function w(e){if(!J.disabled&&J.allowSelect){ot=!0,P=a(q),ft.disableHandles(),pt.setCursor("crosshair");var t=s(e);return lt.setPressed(t),ft.update(),pt.activateHandlers(v,b,"touch"===e.type.substring(0,5)),gt.watchKeys(),e.stopPropagation(),e.preventDefault(),!1}}function v(e){lt.setCurrent(e),ft.update()}function y(){var t=e("
").addClass(r("tracker"));return R&&t.css({opacity:0,backgroundColor:"white"}),t}function m(e){G.removeClass().addClass(r("holder")).addClass(e)}function x(e,t){function n(){window.setTimeout(v,l)}var o=e[0]/tt,r=e[1]/nt,i=e[2]/tt,a=e[3]/nt;if(!rt){var s=lt.flipCoords(o,r,i,a),c=lt.getFixed(),u=[c.x,c.y,c.x2,c.y2],d=u,l=J.animationDelay,h=s[0]-u[0],f=s[1]-u[1],p=s[2]-u[2],g=s[3]-u[3],b=0,w=J.swingSpeed;o=d[0],r=d[1],i=d[2],a=d[3],ft.animMode(!0);var v=function(){return function(){b+=(100-b)/w,d[0]=Math.round(o+b/100*h),d[1]=Math.round(r+b/100*f),d[2]=Math.round(i+b/100*p),d[3]=Math.round(a+b/100*g),b>=99.8&&(b=100),100>b?(S(d),n()):(ft.done(),ft.animMode(!1),"function"==typeof t&&t.call(bt))}}();n()}}function C(e){S([e[0]/tt,e[1]/nt,e[2]/tt,e[3]/nt]),J.onSelect.call(bt,g(lt.getFixed())),ft.enableHandles()}function S(e){lt.setPressed([e[0],e[1]]),lt.setCurrent([e[2],e[3]]),ft.update()}function k(){return g(lt.getFixed())}function z(){return lt.getFixed()}function M(e){c(e),B()}function O(){J.disabled=!0,ft.disableHandles(),ft.setCursor("default"),pt.setCursor("default")}function j(){J.disabled=!1,B()}function F(){ft.done(),pt.activateHandlers(null,null)}function H(){G.remove(),E.show(),E.css("visibility","visible"),e(t).removeData("Jcrop")}function D(e,t){ft.release(),O();var n=new Image;n.onload=function(){var o=n.width,r=n.height,i=J.boxWidth,a=J.boxHeight;q.width(o).height(r),q.attr("src",e),N.attr("src",e),p(q,i,a),L=q.width(),X=q.height(),N.width(L).height(X),st.width(L+2*at).height(X+2*at),G.width(L).height(X),ht.resize(L,X),j(),"function"==typeof t&&t.call(bt)},n.src=e}function I(e,t,n){var o=t||J.bgColor;J.bgFade&&i()&&J.fadeTime&&!n?e.animate({backgroundColor:o},{queue:!1,duration:J.fadeTime}):e.css("backgroundColor",o)}function B(e){J.allowResize?e?ft.enableOnly():ft.enableHandles():ft.disableHandles(),pt.setCursor(J.allowSelect?"crosshair":"default"),ft.setCursor(J.allowMove?"move":"default"),J.hasOwnProperty("trueSize")&&(tt=J.trueSize[0]/L,nt=J.trueSize[1]/X),J.hasOwnProperty("setSelect")&&(C(J.setSelect),ft.done(),delete J.setSelect),ht.refresh(),J.bgColor!=ct&&(I(J.shade?ht.getShades():G,J.shade?J.shadeColor||J.bgColor:J.bgColor),ct=J.bgColor),ut!=J.bgOpacity&&(ut=J.bgOpacity,J.shade?ht.refresh():ft.setBgOpacity(ut)),Z=J.maxSize[0]||0,$=J.maxSize[1]||0,_=J.minSize[0]||0,et=J.minSize[1]||0,J.hasOwnProperty("outerImage")&&(q.attr("src",J.outerImage),delete J.outerImage),ft.refresh()}var P,J=e.extend({},e.Jcrop.defaults),A=navigator.userAgent.toLowerCase(),R=/msie/.test(A),T=/msie [1-6]\./.test(A);"object"!=typeof t&&(t=e(t)[0]),"object"!=typeof n&&(n={}),c(n);var K={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},E=e(t),W=!0;if("IMG"==t.tagName){if(0!=E[0].width&&0!=E[0].height)E.width(E[0].width),E.height(E[0].height);else{var Y=new Image;Y.src=E[0].src,E.width(Y.width),E.height(Y.height)}var q=E.clone().removeAttr("id").css(K).show();q.width(E.width()),q.height(E.height()),E.after(q).hide()}else q=E.css(K).show(),W=!1,null===J.shade&&(J.shade=!0);p(q,J.boxWidth,J.boxHeight);var L=q.width(),X=q.height(),G=e("
").width(L).height(X).addClass(r("holder")).css({position:"relative",backgroundColor:J.bgColor}).insertAfter(E).append(q);J.addClass&&G.addClass(J.addClass);var N=e("
"),V=e("
").width("100%").height("100%").css({zIndex:310,position:"absolute",overflow:"hidden"}),Q=e("
").width("100%").height("100%").css("zIndex",320),U=e("
").css({position:"absolute",zIndex:600}).dblclick(function(){var e=lt.getFixed();J.onDblClick.call(bt,e)}).insertBefore(q).append(V,Q);W&&(N=e("").attr("src",q.attr("src")).css(K).width(L).height(X),V.append(N)),T&&U.css({overflowY:"hidden"});var Z,$,_,et,tt,nt,ot,rt,it,at=J.boundary,st=y().width(L+2*at).height(X+2*at).css({position:"absolute",top:o(-at),left:o(-at),zIndex:290}).mousedown(w),ct=J.bgColor,ut=J.bgOpacity;P=a(q);var dt=function(){function e(){var e,t={},n=["touchstart","touchmove","touchend"],o=document.createElement("div");try{for(e=0;eh+t&&(t-=t+h),0>f+n&&(n-=n+f),g+n>X&&(n+=X-(g+n)),p+t>L&&(t+=L-(p+t)),h+=t,p+=t,f+=n,g+=n}function r(e){var t=i();switch(e){case"ne":return[t.x2,t.y];case"nw":return[t.x,t.y];case"se":return[t.x2,t.y2];case"sw":return[t.x,t.y2]}}function i(){if(!J.aspectRatio)return c();var e,t,n,o,r=J.aspectRatio,i=J.minSize[0]/tt,a=J.maxSize[0]/tt,d=J.maxSize[1]/nt,l=p-h,b=g-f,w=Math.abs(l),v=Math.abs(b),y=w/v;return 0===a&&(a=10*L),0===d&&(d=10*X),r>y?(t=g,n=v*r,e=0>l?h-n:n+h,0>e?(e=0,o=Math.abs((e-h)/r),t=0>b?f-o:o+f):e>L&&(e=L,o=Math.abs((e-h)/r),t=0>b?f-o:o+f)):(e=p,o=w/r,t=0>b?f-o:f+o,0>t?(t=0,n=Math.abs((t-f)*r),e=0>l?h-n:n+h):t>X&&(t=X,n=Math.abs(t-f)*r,e=0>l?h-n:n+h)),e>h?(i>e-h?e=h+i:e-h>a&&(e=h+a),t=t>f?f+(e-h)/r:f-(e-h)/r):h>e&&(i>h-e?e=h-i:h-e>a&&(e=h-a),t=t>f?f+(h-e)/r:f-(h-e)/r),0>e?(h-=e,e=0):e>L&&(h-=e-L,e=L),0>t?(f-=t,t=0):t>X&&(f-=t-X,t=X),u(s(h,f,e,t))}function a(e){return e[0]<0&&(e[0]=0),e[1]<0&&(e[1]=0),e[0]>L&&(e[0]=L),e[1]>X&&(e[1]=X),[Math.round(e[0]),Math.round(e[1])]}function s(e,t,n,o){var r=e,i=n,a=t,s=o;return e>n&&(r=n,i=e),t>o&&(a=o,s=t),[r,a,i,s]}function c(){var e,t=p-h,n=g-f;return Z&&Math.abs(t)>Z&&(p=t>0?h+Z:h-Z),$&&Math.abs(n)>$&&(g=n>0?f+$:f-$),et/nt&&Math.abs(n)0?f+et/nt:f-et/nt),_/tt&&Math.abs(t)<_/tt&&(p=t>0?h+_/tt:h-_/tt),0>h&&(p-=h,h-=h),0>f&&(g-=f,f-=f),0>p&&(h-=p,p-=p),0>g&&(f-=g,g-=g),p>L&&(e=p-L,h-=e,p-=e),g>X&&(e=g-X,f-=e,g-=e),h>L&&(e=h-X,g-=e,f-=e),f>X&&(e=f-X,g-=e,f-=e),u(s(h,f,p,g))}function u(e){return{x:e[0],y:e[1],x2:e[2],y2:e[3],w:e[2]-e[0],h:e[3]-e[1]}}var d,l,h=0,f=0,p=0,g=0;return{flipCoords:s,setPressed:e,setCurrent:t,getOffset:n,moveOffset:o,getCorner:r,getFixed:i}}(),ht=function(){function t(e,t){p.left.css({height:o(t)}),p.right.css({height:o(t)})}function n(){return r(lt.getFixed())}function r(e){p.top.css({left:o(e.x),width:o(e.w),height:o(e.y)}),p.bottom.css({top:o(e.y2),left:o(e.x),width:o(e.w),height:o(X-e.y2)}),p.right.css({left:o(e.x2),width:o(L-e.x2)}),p.left.css({width:o(e.x)})}function i(){return e("
").css({position:"absolute",backgroundColor:J.shadeColor||J.bgColor}).appendTo(f)}function a(){h||(h=!0,f.insertBefore(q),n(),ft.setBgOpacity(1,0,1),N.hide(),s(J.shadeColor||J.bgColor,1),ft.isAwake()?u(J.bgOpacity,1):u(1,1))}function s(e,t){I(l(),e,t)}function c(){h&&(f.remove(),N.show(),h=!1,ft.isAwake()?ft.setBgOpacity(J.bgOpacity,1,1):(ft.setBgOpacity(1,1,1),ft.disableHandles()),I(G,0,1))}function u(e,t){h&&(J.bgFade&&!t?f.animate({opacity:1-e},{queue:!1,duration:J.fadeTime}):f.css({opacity:1-e}))}function d(){J.shade?a():c(),ft.isAwake()&&u(J.bgOpacity)}function l(){return f.children()}var h=!1,f=e("
").css({position:"absolute",zIndex:240,opacity:0}),p={top:i(),left:i().height(X),right:i().height(X),bottom:i()};return{update:n,updateRaw:r,getShades:l,setBgColor:s,enable:a,disable:c,resize:t,refresh:d,opacity:u}}(),ft=function(){function t(t){var n=e("
").css({position:"absolute",opacity:J.borderOpacity}).addClass(r(t));return V.append(n),n}function n(t,n){var o=e("
").mousedown(f(t)).css({cursor:t+"-resize",position:"absolute",zIndex:n}).addClass("ord-"+t);return dt.support&&o.bind("touchstart.jcrop",dt.createDragger(t)),Q.append(o),o}function i(e){var t=J.handleSize,o=n(e,O++).css({opacity:J.handleOpacity}).addClass(r("handle"));return t&&o.width(t).height(t),o}function a(e){return n(e,O++).addClass("jcrop-dragbar")}function s(e){var t;for(t=0;t').css({position:"fixed",left:"-120px",width:"12px"}).addClass("jcrop-keymgr"),a=e("
").css({position:"absolute",overflow:"hidden"}).append(i);return J.keySupport&&(i.keydown(r).blur(n),T||!J.fixedSupport?(i.css({position:"absolute",left:"-20px"}),a.append(i).insertBefore(q)):i.insertBefore(q)),{watchKeys:t}}();dt.support&&st.bind("touchstart.jcrop",dt.newSelection),Q.hide(),B(!0);var bt={setImage:D,animateTo:x,setSelect:C,setOptions:M,tellSelect:k,tellScaled:z,setClass:m,disable:O,enable:j,cancel:F,release:ft.release,destroy:H,focus:gt.watchKeys,getBounds:function(){return[L*tt,X*nt]},getWidgetSize:function(){return[L,X]},getScaleFactor:function(){return[tt,nt]},getOptions:function(){return J},ui:{holder:G,selection:U}};return R&&G.bind("selectstart",function(){return!1}),E.data("Jcrop",bt),bt},e.fn.Jcrop=function(t,n){var o;return this.each(function(){if(e(this).data("Jcrop")){if("api"===t)return e(this).data("Jcrop");e(this).data("Jcrop").setOptions(t)}else"IMG"==this.tagName?e.Jcrop.Loader(this,function(){e(this).css({display:"block",visibility:"hidden"}),o=e.Jcrop(this,t),e.isFunction(n)&&n.call(o)}):(e(this).css({display:"block",visibility:"hidden"}),o=e.Jcrop(this,t),e.isFunction(n)&&n.call(o))}),this},e.Jcrop.Loader=function(t,n,o){function r(){a.complete?(i.unbind(".jcloader"),e.isFunction(n)&&n.call(a)):window.setTimeout(r,50)}var i=e(t),a=i[0];i.bind("load.jcloader",r).bind("error.jcloader",function(){i.unbind(".jcloader"),e.isFunction(o)&&o.call(a)}),a.complete&&e.isFunction(n)&&(i.unbind(".jcloader"),n.call(a))},e.Jcrop.defaults={allowSelect:!0,allowMove:!0,allowResize:!0,trackDocument:!0,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,bgFade:!1,borderOpacity:.4,handleOpacity:.5,handleSize:null,aspectRatio:0,keySupport:!0,createHandles:["n","s","e","w","nw","ne","se","sw"],createDragbars:["n","s","e","w"],createBorders:["n","s","e","w"],drawBorders:!0,dragEdges:!0,fixedSupport:!0,touchSupport:null,shade:null,boxWidth:0,boxHeight:0,boundary:2,fadeTime:400,animationDelay:20,swingSpeed:3,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){},onDblClick:function(){},onRelease:function(){}}}(jQuery); \ No newline at end of file