Edit File by line
/home/barbar84/public_h.../wp-inclu.../js/crop
File: cropper.js
/**
[0] Fix | Delete
* Copyright (c) 2006, David Spurr (http://www.defusion.org.uk/)
[1] Fix | Delete
* All rights reserved.
[2] Fix | Delete
*
[3] Fix | Delete
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
[4] Fix | Delete
*
[5] Fix | Delete
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
[6] Fix | Delete
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
[7] Fix | Delete
* * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
[8] Fix | Delete
*
[9] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[10] Fix | Delete
*
[11] Fix | Delete
* http://www.opensource.org/licenses/bsd-license.php
[12] Fix | Delete
*
[13] Fix | Delete
* See scriptaculous.js for full scriptaculous licence
[14] Fix | Delete
*/
[15] Fix | Delete
[16] Fix | Delete
var CropDraggable=Class.create();
[17] Fix | Delete
Object.extend(Object.extend(CropDraggable.prototype,Draggable.prototype),{initialize:function(_1){
[18] Fix | Delete
this.options=Object.extend({drawMethod:function(){
[19] Fix | Delete
}},arguments[1]||{});
[20] Fix | Delete
this.element=$(_1);
[21] Fix | Delete
this.handle=this.element;
[22] Fix | Delete
this.delta=this.currentDelta();
[23] Fix | Delete
this.dragging=false;
[24] Fix | Delete
this.eventMouseDown=this.initDrag.bindAsEventListener(this);
[25] Fix | Delete
Event.observe(this.handle,"mousedown",this.eventMouseDown);
[26] Fix | Delete
Draggables.register(this);
[27] Fix | Delete
},draw:function(_2){
[28] Fix | Delete
var _3=Position.cumulativeOffset(this.element);
[29] Fix | Delete
var d=this.currentDelta();
[30] Fix | Delete
_3[0]-=d[0];
[31] Fix | Delete
_3[1]-=d[1];
[32] Fix | Delete
var p=[0,1].map(function(i){
[33] Fix | Delete
return (_2[i]-_3[i]-this.offset[i]);
[34] Fix | Delete
}.bind(this));
[35] Fix | Delete
this.options.drawMethod(p);
[36] Fix | Delete
}});
[37] Fix | Delete
var Cropper={};
[38] Fix | Delete
Cropper.Img=Class.create();
[39] Fix | Delete
Cropper.Img.prototype={initialize:function(_7,_8){
[40] Fix | Delete
this.options=Object.extend({ratioDim:{x:0,y:0},minWidth:0,minHeight:0,displayOnInit:false,onEndCrop:Prototype.emptyFunction,captureKeys:true},_8||{});
[41] Fix | Delete
if(this.options.minWidth>0&&this.options.minHeight>0){
[42] Fix | Delete
this.options.ratioDim.x=this.options.minWidth;
[43] Fix | Delete
this.options.ratioDim.y=this.options.minHeight;
[44] Fix | Delete
}
[45] Fix | Delete
this.img=$(_7);
[46] Fix | Delete
this.clickCoords={x:0,y:0};
[47] Fix | Delete
this.dragging=false;
[48] Fix | Delete
this.resizing=false;
[49] Fix | Delete
this.isWebKit=/Konqueror|Safari|KHTML/.test(navigator.userAgent);
[50] Fix | Delete
this.isIE=/MSIE/.test(navigator.userAgent);
[51] Fix | Delete
this.isOpera8=/Opera\s[1-8]/.test(navigator.userAgent);
[52] Fix | Delete
this.ratioX=0;
[53] Fix | Delete
this.ratioY=0;
[54] Fix | Delete
this.attached=false;
[55] Fix | Delete
$A(document.getElementsByTagName("script")).each(function(s){
[56] Fix | Delete
if(s.src.match(/cropper\.js/)){
[57] Fix | Delete
var _a=s.src.replace(/cropper\.js(.*)?/,"");
[58] Fix | Delete
var _b=document.createElement("link");
[59] Fix | Delete
_b.rel="stylesheet";
[60] Fix | Delete
_b.type="text/css";
[61] Fix | Delete
_b.href=_a+"cropper.css";
[62] Fix | Delete
_b.media="screen";
[63] Fix | Delete
document.getElementsByTagName("head")[0].appendChild(_b);
[64] Fix | Delete
}
[65] Fix | Delete
});
[66] Fix | Delete
if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0){
[67] Fix | Delete
var _c=this.getGCD(this.options.ratioDim.x,this.options.ratioDim.y);
[68] Fix | Delete
this.ratioX=this.options.ratioDim.x/_c;
[69] Fix | Delete
this.ratioY=this.options.ratioDim.y/_c;
[70] Fix | Delete
}
[71] Fix | Delete
this.subInitialize();
[72] Fix | Delete
if(this.img.complete||this.isWebKit){
[73] Fix | Delete
this.onLoad();
[74] Fix | Delete
}else{
[75] Fix | Delete
Event.observe(this.img,"load",this.onLoad.bindAsEventListener(this));
[76] Fix | Delete
}
[77] Fix | Delete
},getGCD:function(a,b){return 1;
[78] Fix | Delete
if(b==0){
[79] Fix | Delete
return a;
[80] Fix | Delete
}
[81] Fix | Delete
return this.getGCD(b,a%b);
[82] Fix | Delete
},onLoad:function(){
[83] Fix | Delete
var _f="imgCrop_";
[84] Fix | Delete
var _10=this.img.parentNode;
[85] Fix | Delete
var _11="";
[86] Fix | Delete
if(this.isOpera8){
[87] Fix | Delete
_11=" opera8";
[88] Fix | Delete
}
[89] Fix | Delete
this.imgWrap=Builder.node("div",{"class":_f+"wrap"+_11});
[90] Fix | Delete
if(this.isIE){
[91] Fix | Delete
this.north=Builder.node("div",{"class":_f+"overlay "+_f+"north"},[Builder.node("span")]);
[92] Fix | Delete
this.east=Builder.node("div",{"class":_f+"overlay "+_f+"east"},[Builder.node("span")]);
[93] Fix | Delete
this.south=Builder.node("div",{"class":_f+"overlay "+_f+"south"},[Builder.node("span")]);
[94] Fix | Delete
this.west=Builder.node("div",{"class":_f+"overlay "+_f+"west"},[Builder.node("span")]);
[95] Fix | Delete
var _12=[this.north,this.east,this.south,this.west];
[96] Fix | Delete
}else{
[97] Fix | Delete
this.overlay=Builder.node("div",{"class":_f+"overlay"});
[98] Fix | Delete
var _12=[this.overlay];
[99] Fix | Delete
}
[100] Fix | Delete
this.dragArea=Builder.node("div",{"class":_f+"dragArea"},_12);
[101] Fix | Delete
this.handleN=Builder.node("div",{"class":_f+"handle "+_f+"handleN"});
[102] Fix | Delete
this.handleNE=Builder.node("div",{"class":_f+"handle "+_f+"handleNE"});
[103] Fix | Delete
this.handleE=Builder.node("div",{"class":_f+"handle "+_f+"handleE"});
[104] Fix | Delete
this.handleSE=Builder.node("div",{"class":_f+"handle "+_f+"handleSE"});
[105] Fix | Delete
this.handleS=Builder.node("div",{"class":_f+"handle "+_f+"handleS"});
[106] Fix | Delete
this.handleSW=Builder.node("div",{"class":_f+"handle "+_f+"handleSW"});
[107] Fix | Delete
this.handleW=Builder.node("div",{"class":_f+"handle "+_f+"handleW"});
[108] Fix | Delete
this.handleNW=Builder.node("div",{"class":_f+"handle "+_f+"handleNW"});
[109] Fix | Delete
this.selArea=Builder.node("div",{"class":_f+"selArea"},[Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeNorth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeEast"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeHoriz "+_f+"marqueeSouth"},[Builder.node("span")]),Builder.node("div",{"class":_f+"marqueeVert "+_f+"marqueeWest"},[Builder.node("span")]),this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW,Builder.node("div",{"class":_f+"clickArea"})]);
[110] Fix | Delete
Element.setStyle($(this.selArea),{backgroundColor:"transparent",backgroundRepeat:"no-repeat",backgroundPosition:"0 0"});
[111] Fix | Delete
this.imgWrap.appendChild(this.img);
[112] Fix | Delete
this.imgWrap.appendChild(this.dragArea);
[113] Fix | Delete
this.dragArea.appendChild(this.selArea);
[114] Fix | Delete
this.dragArea.appendChild(Builder.node("div",{"class":_f+"clickArea"}));
[115] Fix | Delete
_10.appendChild(this.imgWrap);
[116] Fix | Delete
Event.observe(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));
[117] Fix | Delete
Event.observe(document,"mousemove",this.onDrag.bindAsEventListener(this));
[118] Fix | Delete
Event.observe(document,"mouseup",this.endCrop.bindAsEventListener(this));
[119] Fix | Delete
var _13=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];
[120] Fix | Delete
for(var i=0;i<_13.length;i++){
[121] Fix | Delete
Event.observe(_13[i],"mousedown",this.startResize.bindAsEventListener(this));
[122] Fix | Delete
}
[123] Fix | Delete
if(this.options.captureKeys){
[124] Fix | Delete
Event.observe(document,"keydown",this.handleKeys.bindAsEventListener(this));
[125] Fix | Delete
}
[126] Fix | Delete
new CropDraggable(this.selArea,{drawMethod:this.moveArea.bindAsEventListener(this)});
[127] Fix | Delete
this.setParams();
[128] Fix | Delete
},setParams:function(){
[129] Fix | Delete
this.imgW=this.img.width;
[130] Fix | Delete
this.imgH=this.img.height;
[131] Fix | Delete
if(!this.isIE){
[132] Fix | Delete
Element.setStyle($(this.overlay),{width:this.imgW+"px",height:this.imgH+"px"});
[133] Fix | Delete
Element.hide($(this.overlay));
[134] Fix | Delete
Element.setStyle($(this.selArea),{backgroundImage:"url("+this.img.src+")"});
[135] Fix | Delete
}else{
[136] Fix | Delete
Element.setStyle($(this.north),{height:0});
[137] Fix | Delete
Element.setStyle($(this.east),{width:0,height:0});
[138] Fix | Delete
Element.setStyle($(this.south),{height:0});
[139] Fix | Delete
Element.setStyle($(this.west),{width:0,height:0});
[140] Fix | Delete
}
[141] Fix | Delete
Element.setStyle($(this.imgWrap),{"width":this.imgW+"px","height":this.imgH+"px"});
[142] Fix | Delete
Element.hide($(this.selArea));
[143] Fix | Delete
var _15=Position.positionedOffset(this.imgWrap);
[144] Fix | Delete
this.wrapOffsets={"top":_15[1],"left":_15[0]};
[145] Fix | Delete
var _16={x1:0,y1:0,x2:0,y2:0};
[146] Fix | Delete
this.setAreaCoords(_16);
[147] Fix | Delete
if(this.options.ratioDim.x>0&&this.options.ratioDim.y>0&&this.options.displayOnInit){
[148] Fix | Delete
_16.x1=Math.ceil((this.imgW-this.options.ratioDim.x)/2);
[149] Fix | Delete
_16.y1=Math.ceil((this.imgH-this.options.ratioDim.y)/2);
[150] Fix | Delete
_16.x2=_16.x1+this.options.ratioDim.x;
[151] Fix | Delete
_16.y2=_16.y1+this.options.ratioDim.y;
[152] Fix | Delete
Element.show(this.selArea);
[153] Fix | Delete
this.drawArea();
[154] Fix | Delete
this.endCrop();
[155] Fix | Delete
}
[156] Fix | Delete
this.attached=true;
[157] Fix | Delete
},remove:function(){
[158] Fix | Delete
this.attached=false;
[159] Fix | Delete
this.imgWrap.parentNode.insertBefore(this.img,this.imgWrap);
[160] Fix | Delete
this.imgWrap.parentNode.removeChild(this.imgWrap);
[161] Fix | Delete
Event.stopObserving(this.dragArea,"mousedown",this.startDrag.bindAsEventListener(this));
[162] Fix | Delete
Event.stopObserving(document,"mousemove",this.onDrag.bindAsEventListener(this));
[163] Fix | Delete
Event.stopObserving(document,"mouseup",this.endCrop.bindAsEventListener(this));
[164] Fix | Delete
var _17=[this.handleN,this.handleNE,this.handleE,this.handleSE,this.handleS,this.handleSW,this.handleW,this.handleNW];
[165] Fix | Delete
for(var i=0;i<_17.length;i++){
[166] Fix | Delete
Event.stopObserving(_17[i],"mousedown",this.startResize.bindAsEventListener(this));
[167] Fix | Delete
}
[168] Fix | Delete
if(this.options.captureKeys){
[169] Fix | Delete
Event.stopObserving(document,"keydown",this.handleKeys.bindAsEventListener(this));
[170] Fix | Delete
}
[171] Fix | Delete
},reset:function(){
[172] Fix | Delete
if(!this.attached){
[173] Fix | Delete
this.onLoad();
[174] Fix | Delete
}else{
[175] Fix | Delete
this.setParams();
[176] Fix | Delete
}
[177] Fix | Delete
this.endCrop();
[178] Fix | Delete
},handleKeys:function(e){
[179] Fix | Delete
var dir={x:0,y:0};
[180] Fix | Delete
if(!this.dragging){
[181] Fix | Delete
switch(e.keyCode){
[182] Fix | Delete
case (37):
[183] Fix | Delete
dir.x=-1;
[184] Fix | Delete
break;
[185] Fix | Delete
case (38):
[186] Fix | Delete
dir.y=-1;
[187] Fix | Delete
break;
[188] Fix | Delete
case (39):
[189] Fix | Delete
dir.x=1;
[190] Fix | Delete
break;
[191] Fix | Delete
case (40):
[192] Fix | Delete
dir.y=1;
[193] Fix | Delete
break;
[194] Fix | Delete
}
[195] Fix | Delete
if(dir.x!=0||dir.y!=0){
[196] Fix | Delete
if(e.shiftKey){
[197] Fix | Delete
dir.x*=10;
[198] Fix | Delete
dir.y*=10;
[199] Fix | Delete
}
[200] Fix | Delete
this.moveArea([this.areaCoords.x1+dir.x,this.areaCoords.y1+dir.y]);
[201] Fix | Delete
Event.stop(e);
[202] Fix | Delete
}
[203] Fix | Delete
}
[204] Fix | Delete
},calcW:function(){
[205] Fix | Delete
return (this.areaCoords.x2-this.areaCoords.x1);
[206] Fix | Delete
},calcH:function(){
[207] Fix | Delete
return (this.areaCoords.y2-this.areaCoords.y1);
[208] Fix | Delete
},moveArea:function(_1b){
[209] Fix | Delete
this.setAreaCoords({x1:_1b[0],y1:_1b[1],x2:_1b[0]+this.calcW(),y2:_1b[1]+this.calcH()},true);
[210] Fix | Delete
this.drawArea();
[211] Fix | Delete
},cloneCoords:function(_1c){
[212] Fix | Delete
return {x1:_1c.x1,y1:_1c.y1,x2:_1c.x2,y2:_1c.y2};
[213] Fix | Delete
},setAreaCoords:function(_1d,_1e,_1f,_20,_21){
[214] Fix | Delete
var _22=typeof _1e!="undefined"?_1e:false;
[215] Fix | Delete
var _23=typeof _1f!="undefined"?_1f:false;
[216] Fix | Delete
if(_1e){
[217] Fix | Delete
var _24=_1d.x2-_1d.x1;
[218] Fix | Delete
var _25=_1d.y2-_1d.y1;
[219] Fix | Delete
if(_1d.x1<0){
[220] Fix | Delete
_1d.x1=0;
[221] Fix | Delete
_1d.x2=_24;
[222] Fix | Delete
}
[223] Fix | Delete
if(_1d.y1<0){
[224] Fix | Delete
_1d.y1=0;
[225] Fix | Delete
_1d.y2=_25;
[226] Fix | Delete
}
[227] Fix | Delete
if(_1d.x2>this.imgW){
[228] Fix | Delete
_1d.x2=this.imgW;
[229] Fix | Delete
_1d.x1=this.imgW-_24;
[230] Fix | Delete
}
[231] Fix | Delete
if(_1d.y2>this.imgH){
[232] Fix | Delete
_1d.y2=this.imgH;
[233] Fix | Delete
_1d.y1=this.imgH-_25;
[234] Fix | Delete
}
[235] Fix | Delete
}else{
[236] Fix | Delete
if(_1d.x1<0){
[237] Fix | Delete
_1d.x1=0;
[238] Fix | Delete
}
[239] Fix | Delete
if(_1d.y1<0){
[240] Fix | Delete
_1d.y1=0;
[241] Fix | Delete
}
[242] Fix | Delete
if(_1d.x2>this.imgW){
[243] Fix | Delete
_1d.x2=this.imgW;
[244] Fix | Delete
}
[245] Fix | Delete
if(_1d.y2>this.imgH){
[246] Fix | Delete
_1d.y2=this.imgH;
[247] Fix | Delete
}
[248] Fix | Delete
if(typeof (_20)!="undefined"){
[249] Fix | Delete
if(this.ratioX>0){
[250] Fix | Delete
this.applyRatio(_1d,{x:this.ratioX,y:this.ratioY},_20,_21);
[251] Fix | Delete
}else{
[252] Fix | Delete
if(_23){
[253] Fix | Delete
this.applyRatio(_1d,{x:1,y:1},_20,_21);
[254] Fix | Delete
}
[255] Fix | Delete
}
[256] Fix | Delete
var _26={a1:_1d.x1,a2:_1d.x2};
[257] Fix | Delete
var _27={a1:_1d.y1,a2:_1d.y2};
[258] Fix | Delete
var _28=this.options.minWidth;
[259] Fix | Delete
var _29=this.options.minHeight;
[260] Fix | Delete
if((_28==0||_29==0)&&_23){
[261] Fix | Delete
if(_28>0){
[262] Fix | Delete
_29=_28;
[263] Fix | Delete
}else{
[264] Fix | Delete
if(_29>0){
[265] Fix | Delete
_28=_29;
[266] Fix | Delete
}
[267] Fix | Delete
}
[268] Fix | Delete
}
[269] Fix | Delete
this.applyMinDimension(_26,_28,_20.x,{min:0,max:this.imgW});
[270] Fix | Delete
this.applyMinDimension(_27,_29,_20.y,{min:0,max:this.imgH});
[271] Fix | Delete
_1d={x1:_26.a1,y1:_27.a1,x2:_26.a2,y2:_27.a2};
[272] Fix | Delete
}
[273] Fix | Delete
}
[274] Fix | Delete
this.areaCoords=_1d;
[275] Fix | Delete
},applyMinDimension:function(_2a,_2b,_2c,_2d){
[276] Fix | Delete
if((_2a.a2-_2a.a1)<_2b){
[277] Fix | Delete
if(_2c==1){
[278] Fix | Delete
_2a.a2=_2a.a1+_2b;
[279] Fix | Delete
}else{
[280] Fix | Delete
_2a.a1=_2a.a2-_2b;
[281] Fix | Delete
}
[282] Fix | Delete
if(_2a.a1<_2d.min){
[283] Fix | Delete
_2a.a1=_2d.min;
[284] Fix | Delete
_2a.a2=_2b;
[285] Fix | Delete
}else{
[286] Fix | Delete
if(_2a.a2>_2d.max){
[287] Fix | Delete
_2a.a1=_2d.max-_2b;
[288] Fix | Delete
_2a.a2=_2d.max;
[289] Fix | Delete
}
[290] Fix | Delete
}
[291] Fix | Delete
}
[292] Fix | Delete
},applyRatio:function(_2e,_2f,_30,_31){
[293] Fix | Delete
var _32;
[294] Fix | Delete
if(_31=="N"||_31=="S"){
[295] Fix | Delete
_32=this.applyRatioToAxis({a1:_2e.y1,b1:_2e.x1,a2:_2e.y2,b2:_2e.x2},{a:_2f.y,b:_2f.x},{a:_30.y,b:_30.x},{min:0,max:this.imgW});
[296] Fix | Delete
_2e.x1=_32.b1;
[297] Fix | Delete
_2e.y1=_32.a1;
[298] Fix | Delete
_2e.x2=_32.b2;
[299] Fix | Delete
_2e.y2=_32.a2;
[300] Fix | Delete
}else{
[301] Fix | Delete
_32=this.applyRatioToAxis({a1:_2e.x1,b1:_2e.y1,a2:_2e.x2,b2:_2e.y2},{a:_2f.x,b:_2f.y},{a:_30.x,b:_30.y},{min:0,max:this.imgH});
[302] Fix | Delete
_2e.x1=_32.a1;
[303] Fix | Delete
_2e.y1=_32.b1;
[304] Fix | Delete
_2e.x2=_32.a2;
[305] Fix | Delete
_2e.y2=_32.b2;
[306] Fix | Delete
}
[307] Fix | Delete
},applyRatioToAxis:function(_33,_34,_35,_36){
[308] Fix | Delete
var _37=Object.extend(_33,{});
[309] Fix | Delete
var _38=_37.a2-_37.a1;
[310] Fix | Delete
var _3a=Math.floor(_38*_34.b/_34.a);
[311] Fix | Delete
var _3b;
[312] Fix | Delete
var _3c;
[313] Fix | Delete
var _3d=null;
[314] Fix | Delete
if(_35.b==1){
[315] Fix | Delete
_3b=_37.b1+_3a;
[316] Fix | Delete
if(_3b>_36.max){
[317] Fix | Delete
_3b=_36.max;
[318] Fix | Delete
_3d=_3b-_37.b1;
[319] Fix | Delete
}
[320] Fix | Delete
_37.b2=_3b;
[321] Fix | Delete
}else{
[322] Fix | Delete
_3b=_37.b2-_3a;
[323] Fix | Delete
if(_3b<_36.min){
[324] Fix | Delete
_3b=_36.min;
[325] Fix | Delete
_3d=_3b+_37.b2;
[326] Fix | Delete
}
[327] Fix | Delete
_37.b1=_3b;
[328] Fix | Delete
}
[329] Fix | Delete
if(_3d!=null){
[330] Fix | Delete
_3c=Math.floor(_3d*_34.a/_34.b);
[331] Fix | Delete
if(_35.a==1){
[332] Fix | Delete
_37.a2=_37.a1+_3c;
[333] Fix | Delete
}else{
[334] Fix | Delete
_37.a1=_37.a1=_37.a2-_3c;
[335] Fix | Delete
}
[336] Fix | Delete
}
[337] Fix | Delete
return _37;
[338] Fix | Delete
},drawArea:function(){
[339] Fix | Delete
if(!this.isIE){
[340] Fix | Delete
Element.show($(this.overlay));
[341] Fix | Delete
}
[342] Fix | Delete
var _3e=this.calcW();
[343] Fix | Delete
var _3f=this.calcH();
[344] Fix | Delete
var _40=this.areaCoords.x2;
[345] Fix | Delete
var _41=this.areaCoords.y2;
[346] Fix | Delete
var _42=this.selArea.style;
[347] Fix | Delete
_42.left=this.areaCoords.x1+"px";
[348] Fix | Delete
_42.top=this.areaCoords.y1+"px";
[349] Fix | Delete
_42.width=_3e+"px";
[350] Fix | Delete
_42.height=_3f+"px";
[351] Fix | Delete
var _43=Math.ceil((_3e-6)/2)+"px";
[352] Fix | Delete
var _44=Math.ceil((_3f-6)/2)+"px";
[353] Fix | Delete
this.handleN.style.left=_43;
[354] Fix | Delete
this.handleE.style.top=_44;
[355] Fix | Delete
this.handleS.style.left=_43;
[356] Fix | Delete
this.handleW.style.top=_44;
[357] Fix | Delete
if(this.isIE){
[358] Fix | Delete
this.north.style.height=this.areaCoords.y1+"px";
[359] Fix | Delete
var _45=this.east.style;
[360] Fix | Delete
_45.top=this.areaCoords.y1+"px";
[361] Fix | Delete
_45.height=_3f+"px";
[362] Fix | Delete
_45.left=_40+"px";
[363] Fix | Delete
_45.width=(this.img.width-_40)+"px";
[364] Fix | Delete
var _46=this.south.style;
[365] Fix | Delete
_46.top=_41+"px";
[366] Fix | Delete
_46.height=(this.img.height-_41)+"px";
[367] Fix | Delete
var _47=this.west.style;
[368] Fix | Delete
_47.top=this.areaCoords.y1+"px";
[369] Fix | Delete
_47.height=_3f+"px";
[370] Fix | Delete
_47.width=this.areaCoords.x1+"px";
[371] Fix | Delete
}else{
[372] Fix | Delete
_42.backgroundPosition="-"+this.areaCoords.x1+"px "+"-"+this.areaCoords.y1+"px";
[373] Fix | Delete
}
[374] Fix | Delete
this.subDrawArea();
[375] Fix | Delete
this.forceReRender();
[376] Fix | Delete
},forceReRender:function(){
[377] Fix | Delete
if(this.isIE||this.isWebKit){
[378] Fix | Delete
var n=document.createTextNode(" ");
[379] Fix | Delete
var d,el,fixEL,i;
[380] Fix | Delete
if(this.isIE){
[381] Fix | Delete
fixEl=this.selArea;
[382] Fix | Delete
}else{
[383] Fix | Delete
if(this.isWebKit){
[384] Fix | Delete
fixEl=document.getElementsByClassName("imgCrop_marqueeSouth",this.imgWrap)[0];
[385] Fix | Delete
d=Builder.node("div","");
[386] Fix | Delete
d.style.visibility="hidden";
[387] Fix | Delete
var _4a=["SE","S","SW"];
[388] Fix | Delete
for(i=0;i<_4a.length;i++){
[389] Fix | Delete
el=document.getElementsByClassName("imgCrop_handle"+_4a[i],this.selArea)[0];
[390] Fix | Delete
if(el.childNodes.length){
[391] Fix | Delete
el.removeChild(el.childNodes[0]);
[392] Fix | Delete
}
[393] Fix | Delete
el.appendChild(d);
[394] Fix | Delete
}
[395] Fix | Delete
}
[396] Fix | Delete
}
[397] Fix | Delete
fixEl.appendChild(n);
[398] Fix | Delete
fixEl.removeChild(n);
[399] Fix | Delete
}
[400] Fix | Delete
},startResize:function(e){
[401] Fix | Delete
this.startCoords=this.cloneCoords(this.areaCoords);
[402] Fix | Delete
this.resizing=true;
[403] Fix | Delete
this.resizeHandle=Element.classNames(Event.element(e)).toString().replace(/([^N|NE|E|SE|S|SW|W|NW])+/,"");
[404] Fix | Delete
Event.stop(e);
[405] Fix | Delete
},startDrag:function(e){
[406] Fix | Delete
Element.show(this.selArea);
[407] Fix | Delete
this.clickCoords=this.getCurPos(e);
[408] Fix | Delete
this.setAreaCoords({x1:this.clickCoords.x,y1:this.clickCoords.y,x2:this.clickCoords.x,y2:this.clickCoords.y});
[409] Fix | Delete
this.dragging=true;
[410] Fix | Delete
this.onDrag(e);
[411] Fix | Delete
Event.stop(e);
[412] Fix | Delete
},getCurPos:function(e){
[413] Fix | Delete
return curPos={x:Event.pointerX(e)-this.wrapOffsets.left,y:Event.pointerY(e)-this.wrapOffsets.top};
[414] Fix | Delete
},onDrag:function(e){
[415] Fix | Delete
var _4f=null;
[416] Fix | Delete
if(this.dragging||this.resizing){
[417] Fix | Delete
var _50=this.getCurPos(e);
[418] Fix | Delete
var _51=this.cloneCoords(this.areaCoords);
[419] Fix | Delete
var _52={x:1,y:1};
[420] Fix | Delete
}
[421] Fix | Delete
if(this.dragging){
[422] Fix | Delete
if(_50.x<this.clickCoords.x){
[423] Fix | Delete
_52.x=-1;
[424] Fix | Delete
}
[425] Fix | Delete
if(_50.y<this.clickCoords.y){
[426] Fix | Delete
_52.y=-1;
[427] Fix | Delete
}
[428] Fix | Delete
this.transformCoords(_50.x,this.clickCoords.x,_51,"x");
[429] Fix | Delete
this.transformCoords(_50.y,this.clickCoords.y,_51,"y");
[430] Fix | Delete
}else{
[431] Fix | Delete
if(this.resizing){
[432] Fix | Delete
_4f=this.resizeHandle;
[433] Fix | Delete
if(_4f.match(/E/)){
[434] Fix | Delete
this.transformCoords(_50.x,this.startCoords.x1,_51,"x");
[435] Fix | Delete
if(_50.x<this.startCoords.x1){
[436] Fix | Delete
_52.x=-1;
[437] Fix | Delete
}
[438] Fix | Delete
}else{
[439] Fix | Delete
if(_4f.match(/W/)){
[440] Fix | Delete
this.transformCoords(_50.x,this.startCoords.x2,_51,"x");
[441] Fix | Delete
if(_50.x<this.startCoords.x2){
[442] Fix | Delete
_52.x=-1;
[443] Fix | Delete
}
[444] Fix | Delete
}
[445] Fix | Delete
}
[446] Fix | Delete
if(_4f.match(/N/)){
[447] Fix | Delete
this.transformCoords(_50.y,this.startCoords.y2,_51,"y");
[448] Fix | Delete
if(_50.y<this.startCoords.y2){
[449] Fix | Delete
_52.y=-1;
[450] Fix | Delete
}
[451] Fix | Delete
}else{
[452] Fix | Delete
if(_4f.match(/S/)){
[453] Fix | Delete
this.transformCoords(_50.y,this.startCoords.y1,_51,"y");
[454] Fix | Delete
if(_50.y<this.startCoords.y1){
[455] Fix | Delete
_52.y=-1;
[456] Fix | Delete
}
[457] Fix | Delete
}
[458] Fix | Delete
}
[459] Fix | Delete
}
[460] Fix | Delete
}
[461] Fix | Delete
if(this.dragging||this.resizing){
[462] Fix | Delete
this.setAreaCoords(_51,false,e.shiftKey,_52,_4f);
[463] Fix | Delete
this.drawArea();
[464] Fix | Delete
Event.stop(e);
[465] Fix | Delete
}
[466] Fix | Delete
},transformCoords:function(_53,_54,_55,_56){
[467] Fix | Delete
var _57=new Array();
[468] Fix | Delete
if(_53<_54){
[469] Fix | Delete
_57[0]=_53;
[470] Fix | Delete
_57[1]=_54;
[471] Fix | Delete
}else{
[472] Fix | Delete
_57[0]=_54;
[473] Fix | Delete
_57[1]=_53;
[474] Fix | Delete
}
[475] Fix | Delete
if(_56=="x"){
[476] Fix | Delete
_55.x1=_57[0];
[477] Fix | Delete
_55.x2=_57[1];
[478] Fix | Delete
}else{
[479] Fix | Delete
_55.y1=_57[0];
[480] Fix | Delete
_55.y2=_57[1];
[481] Fix | Delete
}
[482] Fix | Delete
},endCrop:function(){
[483] Fix | Delete
this.dragging=false;
[484] Fix | Delete
this.resizing=false;
[485] Fix | Delete
this.options.onEndCrop(this.areaCoords,{width:this.calcW(),height:this.calcH()});
[486] Fix | Delete
},subInitialize:function(){
[487] Fix | Delete
},subDrawArea:function(){
[488] Fix | Delete
}};
[489] Fix | Delete
Cropper.ImgWithPreview=Class.create();
[490] Fix | Delete
Object.extend(Object.extend(Cropper.ImgWithPreview.prototype,Cropper.Img.prototype),{subInitialize:function(){
[491] Fix | Delete
this.hasPreviewImg=false;
[492] Fix | Delete
if(typeof (this.options.previewWrap)!="undefined"&&this.options.minWidth>0&&this.options.minHeight>0){
[493] Fix | Delete
this.previewWrap=$(this.options.previewWrap);
[494] Fix | Delete
this.previewImg=this.img.cloneNode(false);
[495] Fix | Delete
this.options.displayOnInit=true;
[496] Fix | Delete
this.hasPreviewImg=true;
[497] Fix | Delete
Element.addClassName(this.previewWrap,"imgCrop_previewWrap");
[498] Fix | Delete
Element.setStyle(this.previewWrap,{width:this.options.minWidth+"px",height:this.options.minHeight+"px"});
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function