2009-04-03 14:18:47 -04:00
|
|
|
(function(a){a.Jcrop=function(d,v){var d=d,v=v;if(typeof(d)!=="object"){d=a(d)[0]}if(typeof(v)!=="object"){v={}}if(!("trackDocument" in v)){v.trackDocument=a.browser.msie?false:true}if(!("keySupport" in v)){v.keySupport=a.browser.msie?false:true}var Q={trackDocument:false,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:0.6,borderOpacity:0.4,handleOpacity:0.5,handlePad:5,handleSize:9,handleOffset:5,edgeMargin:14,aspectRatio:0,keySupport:true,cornerHandles:true,sideHandles:true,drawBorders:true,dragEdges:true,boxWidth:0,boxHeight:0,boundary:8,animationDelay:20,swingSpeed:3,watchShift:false,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){}};var E=Q;u(v);var ac=a(d).css({position:"absolute"});P(ac,E.boxWidth,E.boxHeight);var M=ac.width(),K=ac.height(),T=a("<div />").width(M).height(K).addClass(y("holder")).css({position:"relative",backgroundColor:E.bgColor});if(E.addClass){T.addClass(E.addClass)}ac.wrap(T);var F=a("<img />").attr("src",ac.attr("src")).css("position","absolute").width(M).height(K);var j=a("<div />").width(H(100)).height(H(100)).css({zIndex:310,position:"absolute",overflow:"hidden"}).append(F);var I=a("<div />").width(H(100)).height(H(100)).css({zIndex:320});var t=a("<div />").css({position:"absolute",zIndex:300}).insertBefore(ac).append(j,I);var q=E.boundary;var b=a("<div />").addClass(y("tracker")).width(M+(q*2)).height(K+(q*2)).css({position:"absolute",top:k(-q),left:k(-q),zIndex:290,opacity:0}).mousedown(W);var J,e;var X=A(d),o,z,ae,ad,x,V;if("trueSize" in E){J=E.trueSize[0]/M;e=E.trueSize[1]/K}var U=function(){var ah=0,at=0,ag=0,ar=0,ak,ai;function am(aw){var aw=aj(aw);ag=ah=aw[0];ar=at=aw[1]}function al(aw){var aw=aj(aw);ak=aw[0]-ag;ai=aw[1]-ar;ag=aw[0];ar=aw[1]}function av(){return[ak,ai]}function af(ay){var ax=ay[0],aw=ay[1];if(0>ah+ax){ax-=ax+ah}if(0>at+aw){aw-=aw+at}if(K<ar+aw){aw+=K-(ar+aw)}if(M<ag+ax){ax+=M-(ag+ax)}ah+=ax;ag+=ax;at+=aw;ar+=aw}function an(aw){var ax=au();switch(aw){case"ne":return[ax.x2,ax.y];case"nw":return[ax.x,ax.y];case"se":return[ax.x2,ax.y2];case"sw":return[ax.x,ax.y2]}}function au(){if(!E.aspectRatio&&!z){return aq()}var ax=E.aspectRatio?E.aspectRatio:z,aB=E.minSize,aE=E.maxSize,ay=ag-ah,aF=ar-at,az=Math.abs(ay),aA=Math.abs(aF),aC=az/aA,aw,aD;if(aC<ax){aD=ar;w=aA*ax;aw=ay<0?ah-w:w+ah;if(aw<0){aw=0;h=Math.abs((aw-ah)/ax);aD=aF<0?at-h:h+at}else{if(aw>M){aw=M;h=Math.abs((aw-ah)/ax);aD=aF<0?at-h:h+at}}}else{aw=ag;h=az/ax;aD=aF<0?at-h:at+h;if(aD<0){aD=0;w=Math.abs((aD-at)*ax);aw=ay<0?ah-w:w+ah}else{if(aD>K){aD=K;w=Math.abs(aD-at)*ax;aw=ay<0?ah-w:w+ah}}}return last=ap(ao(ah,at,aw,aD))}function aj(aw){if(aw[0]<0){aw[0]=0}if(aw[1]<0){aw[1]=0}if(aw[0]>M){aw[0]=M}if(aw[1]>K){aw[1]=K}return[aw[0],aw[1]]}function ao(az,aB,ay,aA){var aD=az,aC=ay,ax=aB,aw=aA;if(ay<az){aD=ay;aC=az}if(aA<aB){ax=aA;aw=aB}return[Math.round(aD),Math.round(ax),Math.round(aC),Math.round(aw)]}function aq(){var ax=ag-ah;var aw=ar-at;if(s&&(Math.abs(ax)>s)){ag=(ax>0)?(ah+s):(ah-s)}if(Z&&(Math.abs(aw)>Z)){ar=(aw>0)?(at+Z):(at-Z)}if(O&&(Math.abs(aw)<O)){ar=(aw>0)?(at+O):(at-O)}if(l&&(Math.abs(ax)<l)){ag=(ax>0)?(ah+l):(ah-l)}if(ah<0){ag-=ah;ah-=ah}if(at<0){ar-=at;at-=at}if(ag<0){ah-=ag;ag-=ag}if(ar<0){at-=ar;ar-=ar}if(ag>M){var ay=ag-M;ah-=ay;ag-=ay}if(ar>K){var ay=ar-K;at-=ay;ar-=ay}if(ah>M){var ay=ah-K;ar-=ay;at-=ay}if(at>K){var ay=at-K;ar-=ay;at-=ay}return ap(ao(ah,at,ag,ar))}function ap(aw){return{x:aw[0],y:aw[1],x2:aw[2],y2:aw[3],w:aw[2]-aw[0],h:aw[3]-aw[1]}}return{flipCoords:ao,setPressed:am,setCurrent:al,getOffset:av,moveOffset:af,getCorner:an,getFixed:au}}();var R=function(){var ak,ah,ar,aq,aA=370;var aj={};var aE={};var ag=false;var ap=E.handleOffset;if(E.drawBorders){aj={top:al("hline").css("top",a.browser.msie?k(-1):k(0)),bottom:al("hline"),left:al("vline"),right:al("vline")}}if(E.dragEdges){aE.t=az("n");aE.b=az("s");aE.r=az("e");aE.l=az("w")}E.sideHandles&&av(["n","s","e","w"]);E.cornerHandles&&av(["sw","nw","ne","se"]);function al(aH){var aI=a("<div />").css({position:"absolute",opacity:E.borderOpacity}).addClass(y(aH));j.append(aI);return aI}function af(aH,
|