root / trunk / web / dojo / dojox / grid / enhanced / dnd / _DndMovingManager.js
History | View | Annotate | Download (18.6 KB)
| 1 |
/*
|
|---|---|
| 2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
| 3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
| 4 |
see: http://dojotoolkit.org/license for details
|
| 5 |
*/
|
| 6 |
|
| 7 |
|
| 8 |
if(!dojo._hasResource["dojox.grid.enhanced.dnd._DndMovingManager"]){ |
| 9 |
dojo._hasResource["dojox.grid.enhanced.dnd._DndMovingManager"]=true; |
| 10 |
dojo.provide("dojox.grid.enhanced.dnd._DndMovingManager");
|
| 11 |
dojo.require("dojox.grid.enhanced.dnd._DndSelectingManager");
|
| 12 |
dojo.require("dojox.grid.enhanced.dnd._DndMover");
|
| 13 |
dojo.require("dojo.dnd.move");
|
| 14 |
dojo.declare("dojox.grid.enhanced.dnd._DndMovingManager",dojox.grid.enhanced.dnd._DndSelectingManager,{exceptRowsTo:-1,exceptColumnsTo:-1,coverDIVs:[],movers:[],constructor:function(_1){ |
| 15 |
if(this.grid.indirectSelection){ |
| 16 |
this.exceptColumnsTo=this.grid.pluginMgr.getFixedCellNumber()-1; |
| 17 |
} |
| 18 |
this.coverDIVs=this.movers=[]; |
| 19 |
dojo.subscribe("CTRL_KEY_DOWN",dojo.hitch(this,function(_2,_3){ |
| 20 |
if(_2==this.grid&&_2!=this){ |
| 21 |
this.keyboardMove(_3);
|
| 22 |
} |
| 23 |
})); |
| 24 |
dojo.forEach(this.grid.views.views,function(_4){ |
| 25 |
dojo.connect(_4.scrollboxNode,"onscroll",dojo.hitch(this,function(){ |
| 26 |
this.clearDrugDivs();
|
| 27 |
})); |
| 28 |
},this);
|
| 29 |
},getGridWidth:function(){ |
| 30 |
return dojo.contentBox(this.grid.domNode).w-this.grid.views.views[0].getWidth().replace("px",""); |
| 31 |
},isColSelected:function(_5){ |
| 32 |
return this.selectedColumns[_5]&&_5>this.exceptColumnsTo; |
| 33 |
},getHScrollBarHeight:function(){ |
| 34 |
this.scrollbarHeight=0; |
| 35 |
dojo.forEach(this.grid.views.views,function(_6,_7){ |
| 36 |
if(_6.scrollboxNode){
|
| 37 |
var _8=_6.scrollboxNode.offsetHeight-_6.scrollboxNode.clientHeight;
|
| 38 |
this.scrollbarHeight=_8>this.scrollbarHeight?_8:this.scrollbarHeight; |
| 39 |
} |
| 40 |
},this);
|
| 41 |
return this.scrollbarHeight; |
| 42 |
},getExceptionalColOffsetWidth:function(){ |
| 43 |
if(!this.grid.indirectSelection||!this.grid.rowSelectCell){ |
| 44 |
return 0; |
| 45 |
} |
| 46 |
var _9=(normalizedOffsetWidth=0),_a=this.grid.rowSelectCell.view.scrollboxNode; |
| 47 |
dojo.forEach(this.getHeaderNodes(),function(_b,_c){ |
| 48 |
if(_c<=this.exceptColumnsTo){ |
| 49 |
var _d=dojo.coords(_b);
|
| 50 |
_9+=_d.w; |
| 51 |
} |
| 52 |
},this);
|
| 53 |
normalizedOffsetWidth=_9-_a.scrollLeft*(dojo._isBodyLtr()?1:(dojo.isMoz?-1:1)); |
| 54 |
return normalizedOffsetWidth>0?normalizedOffsetWidth:0; |
| 55 |
},getGridCoords:function(_e){ |
| 56 |
if(!this.gridCoords||_e){ |
| 57 |
this.gridCoords=new Object(); |
| 58 |
if(!this.headerHeight){ |
| 59 |
this.headerHeight=dojo.coords(this.getHeaderNodes()[0]).h; |
| 60 |
} |
| 61 |
var _f=dojo.coords(this.grid.views.views[0].domNode); |
| 62 |
var _10=dojo.coords(this.grid.domNode); |
| 63 |
var _11=dojo.contentBox(this.grid.domNode); |
| 64 |
this.gridCoords.h=_11.h-this.headerHeight-this.getHScrollBarHeight(); |
| 65 |
this.gridCoords.t=_10.y;
|
| 66 |
this.gridCoords.l=dojo._isBodyLtr()?(_10.x+_f.w):_10.x;
|
| 67 |
this.gridCoords.w=_11.w-_f.w;
|
| 68 |
} |
| 69 |
return this.gridCoords; |
| 70 |
},createAvatar:function(_12,_13,_14,top,_15){ |
| 71 |
this.gridCoords=null; |
| 72 |
var _16=this.getGridCoords(); |
| 73 |
var _17=dojo.doc.createElement("DIV"); |
| 74 |
_17.className="dojoxGridSelectedDIV";
|
| 75 |
_17.id="grid_dnd_cover_div_"+_14+"_"+top; |
| 76 |
_17.style.width=_12+"px";
|
| 77 |
var _18=dojo._docScroll();
|
| 78 |
var _19=top<_16.t+this.headerHeight?_16.t+this.headerHeight-top:0; |
| 79 |
var _1a=_16.t+_16.h+this.headerHeight; |
| 80 |
var _1b=0; |
| 81 |
if(top<_16.t+this.headerHeight){ |
| 82 |
_1b=(_16.t+this.headerHeight);
|
| 83 |
}else{
|
| 84 |
if(top>_1a){
|
| 85 |
_1b=10000;
|
| 86 |
}else{
|
| 87 |
_1b=top; |
| 88 |
} |
| 89 |
} |
| 90 |
_17.style.top=_1b+_18.y+"px";
|
| 91 |
_17.style.left=(_14+_18.x)+"px";
|
| 92 |
var _1c=_1b+_13-_19;
|
| 93 |
if(_1c>_1a+(_15?this.scrollbarHeight:0)){ |
| 94 |
_1c=_1a; |
| 95 |
} |
| 96 |
_17.style.height=((_1c-_1b)>=0?(_1c-_1b):0)+"px"; |
| 97 |
dojo.doc.body.appendChild(_17); |
| 98 |
_17.connections=[]; |
| 99 |
_17.connections.push(dojo.connect(_17,"onmouseout",this,function(){ |
| 100 |
this.clearDrugDivs();
|
| 101 |
})); |
| 102 |
_17.connections.push(dojo.connect(_17,"onclick",this,"avataDivClick")); |
| 103 |
_17.connections.push(dojo.connect(_17,"keydown",this,function(e){ |
| 104 |
this.handleESC(e,this); |
| 105 |
})); |
| 106 |
this.coverDIVs.push(_17);
|
| 107 |
return _17;
|
| 108 |
},handleESC:function(e,_1d){ |
| 109 |
var dk=dojo.keys;
|
| 110 |
switch(e.keyCode){
|
| 111 |
case dk.ESCAPE:
|
| 112 |
try{
|
| 113 |
this.cancelDND();
|
| 114 |
} |
| 115 |
catch(e){
|
| 116 |
} |
| 117 |
break;
|
| 118 |
} |
| 119 |
},cancelDND:function(){ |
| 120 |
this.cleanAll();
|
| 121 |
this.clearDrugDivs();
|
| 122 |
if(this.mover){ |
| 123 |
this.mover.destroy();
|
| 124 |
} |
| 125 |
this.cleanAll();
|
| 126 |
},createCoverMover:function(_1e,_1f,_20,top,_21){ |
| 127 |
var _22=this.getGridCoords(),_23=(_21=="col"?true:false); |
| 128 |
var _24={box:{l:(_21=="row"?_20:_22.l)+dojo._docScroll().x,t:(_21=="col"?top:_22.t+this.headerHeight)+dojo._docScroll().y,w:_21=="row"?1:_22.w,h:_21=="col"?1:_22.h},within:true,movingType:_21,mover:dojox.grid.enhanced.dnd._DndMover}; |
| 129 |
return new dojox.grid.enhanced.dnd._DndBoxConstrainedMoveable(this.createAvatar(_1e,_1f,_20,top,_23),_24); |
| 130 |
},getBorderDiv:function(){ |
| 131 |
var _25=dojo.byId("borderDIV"+this.grid.id); |
| 132 |
if(_25==null){ |
| 133 |
_25=dojo.doc.createElement("DIV");
|
| 134 |
_25.id="borderDIV"+this.grid.id; |
| 135 |
_25.className="dojoxGridBorderDIV";
|
| 136 |
dojo.doc.body.appendChild(_25); |
| 137 |
} |
| 138 |
return _25;
|
| 139 |
},setBorderDiv:function(_26,_27,_28,top){ |
| 140 |
var _29=this.getBorderDiv(); |
| 141 |
dojo.style(_29,{"height":_27+"px","top":top+"px","width":_26+"px","left":_28+"px"});
|
| 142 |
return _29;
|
| 143 |
},removeOtherMovers:function(id){ |
| 144 |
if(!this.coverDIVs.hasRemovedOtherMovers){ |
| 145 |
var _2a;
|
| 146 |
dojo.forEach(this.coverDIVs,function(div){ |
| 147 |
if(div.id!=id){
|
| 148 |
dojo.doc.body.removeChild(div); |
| 149 |
}else{
|
| 150 |
_2a=div; |
| 151 |
} |
| 152 |
},this);
|
| 153 |
this.coverDIVs=[_2a];
|
| 154 |
this.coverDIVs.hasRemovedOtherMovers=true; |
| 155 |
} |
| 156 |
},addColMovers:function(){ |
| 157 |
var _2b=-1; |
| 158 |
dojo.forEach(this.selectedColumns,function(col,_2c){ |
| 159 |
if(this.isColSelected(_2c)){ |
| 160 |
if(_2b==-1){ |
| 161 |
_2b=_2c; |
| 162 |
} |
| 163 |
if(this.selectedColumns[_2c+1]==null){ |
| 164 |
this.addColMover(_2b,_2c);
|
| 165 |
_2b=-1;
|
| 166 |
} |
| 167 |
} |
| 168 |
},this);
|
| 169 |
},addColMover:function(_2d,_2e){ |
| 170 |
if(this.lock){ |
| 171 |
return;
|
| 172 |
} |
| 173 |
var _2f=(rightPosition=0); |
| 174 |
var top=null,_30=null; |
| 175 |
if(dojo._isBodyLtr()){
|
| 176 |
dojo.forEach(this.getHeaderNodes(),function(_31,_32){ |
| 177 |
var _33=dojo.coords(_31);
|
| 178 |
if(_32==_2d){
|
| 179 |
_2f=_33.x; |
| 180 |
top=_33.y+_33.h; |
| 181 |
_30=_33.h; |
| 182 |
} |
| 183 |
if(_32==_2e){
|
| 184 |
rightPosition=_33.x+_33.w; |
| 185 |
} |
| 186 |
}); |
| 187 |
}else{
|
| 188 |
dojo.forEach(this.getHeaderNodes(),function(_34,_35){ |
| 189 |
var _36=dojo.coords(_34);
|
| 190 |
if(_35==_2d){
|
| 191 |
rightPosition=_36.x+_36.w; |
| 192 |
_30=_36.h; |
| 193 |
} |
| 194 |
if(_35==_2e){
|
| 195 |
_2f=_36.x; |
| 196 |
top=_36.y+_36.h; |
| 197 |
} |
| 198 |
}); |
| 199 |
} |
| 200 |
var _37=this.normalizeColMoverCoords(_2f,rightPosition,_2d,_2e); |
| 201 |
var _38=_37.h,_39=_37.w;
|
| 202 |
_2f=_37.l,rightPosition=_37.r; |
| 203 |
var _3a=this.createCoverMover(_39,_38,_2f,top,"col"); |
| 204 |
this.movers.push(_3a);
|
| 205 |
var _3b=this.setBorderDiv(3,_38,-1000,top+dojo._docScroll().y); |
| 206 |
dojo.attr(_3b,"colH",_37.colH);
|
| 207 |
dojo.connect(_3a,"onMoveStart",dojo.hitch(this,function(_3c,_3d){ |
| 208 |
this.mover=_3c;
|
| 209 |
this.removeOtherMovers(_3c.node.id);
|
| 210 |
})); |
| 211 |
dojo.connect(_3a,"onMove",dojo.hitch(this,function(_3e,_3f,_40){ |
| 212 |
if(_3e.node==null||_3e.node.parentNode==null){ |
| 213 |
return;
|
| 214 |
} |
| 215 |
this.isMoving=true; |
| 216 |
this.moveColBorder(_3e,_40,_3b);
|
| 217 |
})); |
| 218 |
dojo.connect(_3a,"onMoveStop",dojo.hitch(this,function(_41){ |
| 219 |
if(this.drugDestIndex==null||this.isContinuousSelection(this.selectedColumns)&&(this.drugDestIndex==_2d||this.drugDestIndex==_2e||this.drugDestIndex==(_2e+1)&&this.drugBefore)){ |
| 220 |
this.movingIgnored=true; |
| 221 |
if(this.isMoving){ |
| 222 |
this.isMoving=false; |
| 223 |
this.clearDrugDivs();
|
| 224 |
} |
| 225 |
return;
|
| 226 |
} |
| 227 |
this.isMoving=false; |
| 228 |
this.mover=null; |
| 229 |
this.startMoveCols();
|
| 230 |
this.drugDestIndex=null; |
| 231 |
})); |
| 232 |
},normalizeColMoverCoords:function(_42,_43,_44,_45){ |
| 233 |
var _46=_43-_42,_47=this.grid.views.views,_48=this.grid.pluginMgr; |
| 234 |
var _49={"w":_46,"h":0,"l":_42,"r":_43,"colH":0}; |
| 235 |
var _4a=this.getGridWidth()-_47[_47.length-1].getScrollbarWidth(); |
| 236 |
var rtl=!dojo._isBodyLtr();
|
| 237 |
var _4b=_48.getViewByCellIdx(!rtl?_44:_45);
|
| 238 |
var _4c=_48.getViewByCellIdx(!rtl?_45:_44);
|
| 239 |
var _4d=(_4b==_4c);
|
| 240 |
if(!_4b||!_4c){
|
| 241 |
return _49;
|
| 242 |
} |
| 243 |
var _4e=dojo.coords(_4b.scrollboxNode).x+(rtl&&dojo.isIE?_4b.getScrollbarWidth():0); |
| 244 |
var _4f=dojo.coords(_4c.scrollboxNode);
|
| 245 |
var _50=_4f.x+_4f.w-((!rtl||!dojo.isIE)?_4c.getScrollbarWidth():0); |
| 246 |
if(_49.l<_4e){
|
| 247 |
_49.w=_49.r-_4e; |
| 248 |
_49.l=_4e; |
| 249 |
} |
| 250 |
if(_49.r>_50){
|
| 251 |
_49.w=_50-_49.l; |
| 252 |
} |
| 253 |
var i,_51=this.grid.views.views[0],_52=dojo.coords(_51.contentNode).h; |
| 254 |
var _53=_4c,_54=_4f.h;
|
| 255 |
_49.colH=_52; |
| 256 |
_54=!_4d?_54:(_54-(_53.scrollboxNode.offsetHeight-_53.scrollboxNode.clientHeight)); |
| 257 |
_49.h=_52<_54?_52:_54; |
| 258 |
return _49;
|
| 259 |
},moveColBorder:function(_55,_56,_57){ |
| 260 |
var _58=dojo._docScroll(),rtl=!dojo._isBodyLtr();
|
| 261 |
_56.x-=_58.x; |
| 262 |
var _59=this.grid.views.views,_5a=this.getGridCoords(); |
| 263 |
var _5b=_59[!rtl?1:_59.length-1].scrollboxNode; |
| 264 |
var _5c=_59[!rtl?_59.length-1:1].scrollboxNode; |
| 265 |
var _5d=(!rtl||!dojo.isIE)?_5a.l:(_5a.l+_5b.offsetWidth-_5b.clientWidth);
|
| 266 |
var _5e=(!rtl||dojo.isMoz)?(_5a.l+_5a.w-(_5c.offsetWidth-_5c.clientWidth)):(_5a.l+_5a.w);
|
| 267 |
dojo.forEach(this.getHeaderNodes(),dojo.hitch(this,function(_5f,_60){ |
| 268 |
if(_60>this.exceptColumnsTo){ |
| 269 |
var x,_61=dojo.coords(_5f);
|
| 270 |
if(_56.x>=_61.x&&_56.x<=_61.x+_61.w){
|
| 271 |
if(!this.selectedColumns[_60]||!this.selectedColumns[_60-1]){ |
| 272 |
x=_61.x+_58.x+(rtl?_61.w:0);
|
| 273 |
if(_56.x<_5d||_56.x>_5e||x<_5d||x>_5e){
|
| 274 |
return;
|
| 275 |
} |
| 276 |
dojo.style(_57,"left",x+"px"); |
| 277 |
this.drugDestIndex=_60;
|
| 278 |
this.drugBefore=true; |
| 279 |
!dojo.isIE&&this.normalizeColBorderHeight(_57,_60);
|
| 280 |
} |
| 281 |
}else{
|
| 282 |
if(this.getHeaderNodes()[_60+1]==null&&(!rtl?(_56.x>_61.x+_61.w):(_56.x<_61.x))){ |
| 283 |
x=_56.x<_5d?_5d:(_56.x>_5e?_5e:(_61.x+_58.x+(rtl?0:_61.w)));
|
| 284 |
dojo.style(_57,"left",x+"px"); |
| 285 |
this.drugDestIndex=_60;
|
| 286 |
this.drugBefore=false; |
| 287 |
!dojo.isIE&&this.normalizeColBorderHeight(_57,_60);
|
| 288 |
} |
| 289 |
} |
| 290 |
} |
| 291 |
})); |
| 292 |
},normalizeColBorderHeight:function(_62,_63){ |
| 293 |
var _64=this.grid.pluginMgr.getViewByCellIdx(_63); |
| 294 |
if(!_64){
|
| 295 |
return;
|
| 296 |
} |
| 297 |
var _65=_64.scrollboxNode,_66=dojo.attr(_62,"colH"); |
| 298 |
var _67=dojo.coords(_65).h-(_65.offsetHeight-_65.clientHeight);
|
| 299 |
_67=_66>0&&_66<_67?_66:_67;
|
| 300 |
dojo.style(_62,"height",_67+"px"); |
| 301 |
},avataDivClick:function(e){ |
| 302 |
if(this.movingIgnored){ |
| 303 |
this.movingIgnored=false; |
| 304 |
return;
|
| 305 |
} |
| 306 |
this.cleanAll();
|
| 307 |
this.clearDrugDivs();
|
| 308 |
},startMoveCols:function(){ |
| 309 |
this.changeCursorState("wait"); |
| 310 |
this.srcIndexdelta=0; |
| 311 |
deltaColAmount=0;
|
| 312 |
dojo.forEach(this.selectedColumns,dojo.hitch(this,function(col,_68){ |
| 313 |
if(this.isColSelected(_68)){ |
| 314 |
if(this.drugDestIndex>_68){ |
| 315 |
_68-=deltaColAmount; |
| 316 |
} |
| 317 |
deltaColAmount+=1;
|
| 318 |
var _69=this.grid.layout.cells[_68].view.idx; |
| 319 |
var _6a=this.grid.layout.cells[this.drugDestIndex].view.idx; |
| 320 |
if(_68!=this.drugDestIndex){ |
| 321 |
this.grid.layout.moveColumn(_69,_6a,_68,this.drugDestIndex,this.drugBefore); |
| 322 |
} |
| 323 |
if(this.drugDestIndex<=_68&&this.drugDestIndex+1<this.grid.layout.cells.length){ |
| 324 |
this.drugDestIndex+=1; |
| 325 |
} |
| 326 |
} |
| 327 |
})); |
| 328 |
var _6b=this.drugDestIndex+(this.drugBefore?0:1); |
| 329 |
this.clearDrugDivs();
|
| 330 |
this.cleanAll();
|
| 331 |
this.resetCellIdx();
|
| 332 |
this.drugSelectionStart.colIndex=_6b-deltaColAmount;
|
| 333 |
this.drugSelectColumn(this.drugSelectionStart.colIndex+deltaColAmount-1); |
| 334 |
},changeCursorState:function(_6c){ |
| 335 |
dojo.forEach(this.coverDIVs,function(div){ |
| 336 |
div.style.cursor="wait";
|
| 337 |
}); |
| 338 |
},addRowMovers:function(){ |
| 339 |
var _6d=-1; |
| 340 |
dojo.forEach(this.grid.selection.selected,function(row,_6e){ |
| 341 |
var _6f=this.grid.views.views[0]; |
| 342 |
if(row&&_6f.rowNodes[_6e]){
|
| 343 |
if(_6d==-1){ |
| 344 |
_6d=_6e; |
| 345 |
} |
| 346 |
if(this.grid.selection.selected[_6e+1]==null||!_6f.rowNodes[_6e+1]){ |
| 347 |
this.addRowMover(_6d,_6e);
|
| 348 |
_6d=-1;
|
| 349 |
} |
| 350 |
} |
| 351 |
},this);
|
| 352 |
},addRowMover:function(_70,to){ |
| 353 |
var _71=0,_72=this.grid.views.views; |
| 354 |
dojo.forEach(_72,function(_73,_74){
|
| 355 |
_71+=_73.getScrollbarWidth(); |
| 356 |
}); |
| 357 |
var _75=_72[_72.length-1].getScrollbarWidth(); |
| 358 |
var _76=!dojo._isBodyLtr()?(dojo.isIE?_71-_75:_71):0; |
| 359 |
var _77=this.getGridWidth()-_75; |
| 360 |
var _78=this.grid.views.views[0]; |
| 361 |
var _79=_78.rowNodes[_70],_7a=_78.rowNodes[to];
|
| 362 |
if(!_79||!_7a){
|
| 363 |
return;
|
| 364 |
} |
| 365 |
var _7b=dojo.coords(_79),_7c=dojo.coords(_7a);
|
| 366 |
var _7d=this.getExceptionalColOffsetWidth(); |
| 367 |
var _7e=this.createCoverMover(_77-_7d,(_7c.y-_7b.y+_7c.h),dojo._isBodyLtr()?(_7b.x+_7b.w+_7d):(_7b.x-_77-_76),_7b.y,"row"); |
| 368 |
var _7f=this.setBorderDiv(_77,3,(dojo._isBodyLtr()?(_7c.x+_7c.w):(_7c.x-_77-_76))+dojo._docScroll().x,-100); |
| 369 |
var _80=dojo.connect(_7e,"onMoveStart",dojo.hitch(this,function(_81,_82){ |
| 370 |
this.mover=_81;
|
| 371 |
this.removeOtherMovers(_81.node.id);
|
| 372 |
})); |
| 373 |
var _83=dojo.connect(_7e,"onMove",dojo.hitch(this,function(_84,_85,_86){ |
| 374 |
if(_84.node==null||_84.node.parentNode==null){ |
| 375 |
return;
|
| 376 |
} |
| 377 |
this.isMoving=true; |
| 378 |
this.moveRowBorder(_84,_85,_7f,_86);
|
| 379 |
})); |
| 380 |
var _87=dojo.connect(_7e,"onMoveStop",dojo.hitch(this,function(_88){ |
| 381 |
if(this.avaOnRowIndex==null||this.isContinuousSelection(this.grid.selection.selected)&&(this.avaOnRowIndex==_70||this.avaOnRowIndex==(to+1))){ |
| 382 |
this.movingIgnored=true; |
| 383 |
if(this.isMoving){ |
| 384 |
this.isMoving=false; |
| 385 |
this.clearDrugDivs();
|
| 386 |
} |
| 387 |
return;
|
| 388 |
} |
| 389 |
this.isMoving=false; |
| 390 |
this.mover=null; |
| 391 |
this.grid.select.outRangeY=false; |
| 392 |
this.grid.select.moveOutTop=false; |
| 393 |
this.grid.scroller.findScrollTop(this.grid.scroller.page*this.grid.scroller.rowsPerPage); |
| 394 |
this.startMoveRows();
|
| 395 |
this.avaOnRowIndex=null; |
| 396 |
delete _7e;
|
| 397 |
})); |
| 398 |
},moveRowBorder:function(_89,_8a,_8b,_8c){ |
| 399 |
var _8d=this.getGridCoords(true),_8e=dojo._docScroll(); |
| 400 |
var _8f=_8d.t+this.headerHeight+_8d.h; |
| 401 |
_8a.t-=_8e.y,_8c.y-=_8e.y; |
| 402 |
if(_8c.y>=_8f){
|
| 403 |
this.grid.select.outRangeY=true; |
| 404 |
this.autoMoveToNextRow();
|
| 405 |
}else{
|
| 406 |
if(_8c.y<=_8d.t+this.headerHeight){ |
| 407 |
this.grid.select.moveOutTop=true; |
| 408 |
this.autoMoveToPreRow();
|
| 409 |
}else{
|
| 410 |
this.grid.select.outRangeY=this.grid.select.moveOutTop=false; |
| 411 |
var _90=this.grid.views.views[0],_91=_90.rowNodes; |
| 412 |
var _92=dojo.coords(_90.contentNode).h;
|
| 413 |
var _93=0,_94=-1; |
| 414 |
for(i in _91){ |
| 415 |
i=parseInt(i); |
| 416 |
++_93; |
| 417 |
if(i>_94){
|
| 418 |
_94=i; |
| 419 |
} |
| 420 |
} |
| 421 |
var _95=dojo.coords(_91[_94]);
|
| 422 |
if(_92<_8d.h&&_8c.y>(_95.y+_95.h)){
|
| 423 |
this.avaOnRowIndex=_93;
|
| 424 |
dojo.style(_8b,{"top":_95.y+_95.h+_8e.y+"px"});
|
| 425 |
return;
|
| 426 |
} |
| 427 |
var _96,_97,_98;
|
| 428 |
for(var _99 in _91){ |
| 429 |
_99=parseInt(_99); |
| 430 |
if(isNaN(_99)){
|
| 431 |
continue;
|
| 432 |
} |
| 433 |
_97=_91[_99]; |
| 434 |
if(!_97){
|
| 435 |
continue;
|
| 436 |
} |
| 437 |
_96=dojo.coords(_97),_98=(_96.y<=_8f); |
| 438 |
if(_98&&_8c.y>_96.y&&_8c.y<_96.y+_96.h){
|
| 439 |
if(!this.grid.selection.selected[_99]||!this.grid.selection.selected[_99-1]){ |
| 440 |
this.avaOnRowIndex=_99;
|
| 441 |
dojo.style(_8b,{"top":_96.y+_8e.y+"px"});
|
| 442 |
} |
| 443 |
} |
| 444 |
} |
| 445 |
} |
| 446 |
} |
| 447 |
},autoMoveToPreRow:function(){ |
| 448 |
if(this.grid.select.moveOutTop){ |
| 449 |
if(this.grid.scroller.firstVisibleRow>0){ |
| 450 |
this.grid.scrollToRow(this.grid.scroller.firstVisibleRow-1); |
| 451 |
this.autoMoveBorderDivPre();
|
| 452 |
setTimeout(dojo.hitch(this,"autoMoveToPreRow"),this.autoScrollRate); |
| 453 |
} |
| 454 |
} |
| 455 |
},autoMoveBorderDivPre:function(){ |
| 456 |
var _9a=dojo._docScroll(),_9b=this.getGridCoords(); |
| 457 |
var _9c=_9b.t+this.headerHeight+_9a.y; |
| 458 |
var _9d,_9e=this.getBorderDiv(); |
| 459 |
if(this.avaOnRowIndex-1<=0){ |
| 460 |
this.avaOnRowIndex=0; |
| 461 |
_9d=_9c; |
| 462 |
}else{
|
| 463 |
this.avaOnRowIndex--;
|
| 464 |
_9d=dojo.coords(this.grid.views.views[0].rowNodes[this.avaOnRowIndex]).y+_9a.y; |
| 465 |
} |
| 466 |
_9e.style.top=(_9d<_9c?_9c:_9d)+"px";
|
| 467 |
},autoMoveToNextRow:function(){ |
| 468 |
if(this.grid.select.outRangeY){ |
| 469 |
if(this.avaOnRowIndex+1<=this.grid.scroller.rowCount){ |
| 470 |
this.grid.scrollToRow(this.grid.scroller.firstVisibleRow+1); |
| 471 |
this.autoMoveBorderDiv();
|
| 472 |
setTimeout(dojo.hitch(this,"autoMoveToNextRow"),this.autoScrollRate); |
| 473 |
} |
| 474 |
} |
| 475 |
},autoMoveBorderDiv:function(){ |
| 476 |
var _9f=dojo._docScroll(),_a0=this.getGridCoords(); |
| 477 |
var _a1=_a0.t+this.headerHeight+_a0.h+_9f.y; |
| 478 |
var _a2,_a3=this.getBorderDiv(); |
| 479 |
if(this.avaOnRowIndex+1>=this.grid.scroller.rowCount){ |
| 480 |
this.avaOnRowIndex=this.grid.scroller.rowCount; |
| 481 |
_a2=_a1; |
| 482 |
}else{
|
| 483 |
this.avaOnRowIndex++;
|
| 484 |
_a2=dojo.coords(this.grid.views.views[0].rowNodes[this.avaOnRowIndex]).y+_9f.y; |
| 485 |
} |
| 486 |
_a3.style.top=(_a2>_a1?_a1:_a2)+"px";
|
| 487 |
},startMoveRows:function(){ |
| 488 |
var _a4=Math.min(this.avaOnRowIndex,this.getFirstSelected()); |
| 489 |
var end=Math.max(this.avaOnRowIndex-1,this.getLastSelected()); |
| 490 |
this.moveRows(_a4,end,this.getPageInfo()); |
| 491 |
},moveRows:function(_a5,end,_a6){ |
| 492 |
var i,_a7=false,_a8=(selectedRowsAboveBorderDIV=0),_a9=[]; |
| 493 |
var _aa=this.grid.scroller,_ab=_aa.rowsPerPage; |
| 494 |
var _ac=_a6.topPage*_ab,_ad=(_a6.bottomPage+1)*_ab-1; |
| 495 |
var _ae=dojo.hitch(this,function(_af,to){ |
| 496 |
for(i=_af;i<to;i++){
|
| 497 |
if(!this.grid.selection.selected[i]||!this.grid._by_idx[i]){ |
| 498 |
_a9.push(this.grid._by_idx[i]);
|
| 499 |
} |
| 500 |
} |
| 501 |
}); |
| 502 |
_ae(_a5,this.avaOnRowIndex);
|
| 503 |
for(i=_a5;i<=end;i++){
|
| 504 |
if(this.grid.selection.selected[i]&&this.grid._by_idx[i]){ |
| 505 |
_a9.push(this.grid._by_idx[i]);
|
| 506 |
_a8++; |
| 507 |
if(this.avaOnRowIndex>i){ |
| 508 |
selectedRowsAboveBorderDIV++; |
| 509 |
} |
| 510 |
} |
| 511 |
} |
| 512 |
_ae(this.avaOnRowIndex,end+1); |
| 513 |
for(i=_a5,j=0;i<=end;i++){ |
| 514 |
this.grid._by_idx[i]=_a9[j++];
|
| 515 |
if(i>=_ac&&i<=_ad){
|
| 516 |
this.grid.updateRow(i);
|
| 517 |
_a7=true;
|
| 518 |
} |
| 519 |
} |
| 520 |
this.avaOnRowIndex+=_a8-selectedRowsAboveBorderDIV;
|
| 521 |
try{
|
| 522 |
this.clearDrugDivs();
|
| 523 |
this.cleanAll();
|
| 524 |
this.drugSelectionStart.rowIndex=this.avaOnRowIndex-_a8; |
| 525 |
this.drugSelectRow(this.drugSelectionStart.rowIndex+_a8-1); |
| 526 |
if(_a7){
|
| 527 |
var _b0=_aa.stack;
|
| 528 |
dojo.forEach(_a6.invalidPages,function(_b1){
|
| 529 |
_aa.destroyPage(_b1); |
| 530 |
i=dojo.indexOf(_b0,_b1); |
| 531 |
if(i>=0){ |
| 532 |
_b0.splice(i,1);
|
| 533 |
} |
| 534 |
}); |
| 535 |
} |
| 536 |
this.publishRowMove();
|
| 537 |
} |
| 538 |
catch(e){
|
| 539 |
} |
| 540 |
},clearDrugDivs:function(){ |
| 541 |
if(!this.isMoving){ |
| 542 |
var _b2=this.getBorderDiv(); |
| 543 |
_b2.style.top=-100+"px"; |
| 544 |
_b2.style.height="0px";
|
| 545 |
_b2.style.left=-100+"px"; |
| 546 |
dojo.forEach(this.coverDIVs,function(div){ |
| 547 |
dojo.forEach(div.connections,function(_b3){
|
| 548 |
dojo.disconnect(_b3); |
| 549 |
}); |
| 550 |
dojo.doc.body.removeChild(div); |
| 551 |
delete div;
|
| 552 |
},this);
|
| 553 |
this.coverDIVs=[];
|
| 554 |
} |
| 555 |
},setDrugCoverDivs:function(_b4,_b5){ |
| 556 |
if(!this.isMoving){ |
| 557 |
if(this.isColSelected(_b4)){ |
| 558 |
this.addColMovers();
|
| 559 |
}else{
|
| 560 |
if(this.grid.selection.selected[_b5]){ |
| 561 |
this.addRowMovers();
|
| 562 |
}else{
|
| 563 |
this.clearDrugDivs();
|
| 564 |
} |
| 565 |
} |
| 566 |
} |
| 567 |
},getPageInfo:function(){ |
| 568 |
var _b6=this.grid.scroller,_b7=(bottomPage=_b6.page); |
| 569 |
var _b8=_b6.firstVisibleRow,_b9=_b6.lastVisibleRow;
|
| 570 |
var _ba=_b6.rowsPerPage,_bb=_b6.pageNodes[0]; |
| 571 |
var _bc,_bd,_be=[],_bf;
|
| 572 |
dojo.forEach(_bb,function(_c0,_c1){
|
| 573 |
if(!_c0){
|
| 574 |
return;
|
| 575 |
} |
| 576 |
_bf=false;
|
| 577 |
_bc=_c1*_ba; |
| 578 |
_bd=(_c1+1)*_ba-1; |
| 579 |
if(_b8>=_bc&&_b8<=_bd){
|
| 580 |
_b7=_c1; |
| 581 |
_bf=true;
|
| 582 |
} |
| 583 |
if(_b9>=_bc&&_b9<=_bd){
|
| 584 |
bottomPage=_c1; |
| 585 |
_bf=true;
|
| 586 |
} |
| 587 |
if(!_bf&&(_bc>_b9||_bd<_b8)){
|
| 588 |
_be.push(_c1); |
| 589 |
} |
| 590 |
}); |
| 591 |
return {topPage:_b7,bottomPage:bottomPage,invalidPages:_be}; |
| 592 |
},resetCellIdx:function(){ |
| 593 |
var _c2=0; |
| 594 |
var _c3=-1; |
| 595 |
dojo.forEach(this.grid.views.views,function(_c4,_c5){ |
| 596 |
if(_c5==0){ |
| 597 |
return;
|
| 598 |
} |
| 599 |
if(_c4.structure.cells&&_c4.structure.cells[0]){ |
| 600 |
dojo.forEach(_c4.structure.cells[0],function(_c6,_c7){ |
| 601 |
var _c8=_c6.markup[2].split(" "); |
| 602 |
var idx=_c2+_c7;
|
| 603 |
_c8[1]="idx=\""+idx+"\""; |
| 604 |
_c6.markup[2]=_c8.join(" "); |
| 605 |
}); |
| 606 |
} |
| 607 |
for(i in _c4.rowNodes){ |
| 608 |
if(!_c4.rowNodes[i]){
|
| 609 |
return;
|
| 610 |
} |
| 611 |
dojo.forEach(_c4.rowNodes[i].firstChild.rows[0].cells,function(_c9,_ca){ |
| 612 |
if(_c9&&_c9.attributes){
|
| 613 |
if(_ca+_c2>_c3){
|
| 614 |
_c3=_ca+_c2; |
| 615 |
} |
| 616 |
var idx=document.createAttribute("idx"); |
| 617 |
idx.value=_ca+_c2; |
| 618 |
_c9.attributes.setNamedItem(idx); |
| 619 |
} |
| 620 |
}); |
| 621 |
} |
| 622 |
_c2=_c3+1;
|
| 623 |
}); |
| 624 |
},publishRowMove:function(){ |
| 625 |
dojo.publish(this.grid.rowMovedTopic,[this]); |
| 626 |
},keyboardMove:function(_cb){ |
| 627 |
var _cc=this.selectedColumns.length>0; |
| 628 |
var _cd=dojo.hitch(this.grid.selection,dojox.grid.Selection.prototype["getFirstSelected"])()>=0; |
| 629 |
var i,_ce,dk=dojo.keys,_cf=_cb.keyCode;
|
| 630 |
if(!dojo._isBodyLtr()){
|
| 631 |
_cf=(_cb.keyCode==dk.LEFT_ARROW)?dk.RIGHT_ARROW:(_cb.keyCode==dk.RIGHT_ARROW?dk.LEFT_ARROW:_cf); |
| 632 |
} |
| 633 |
switch(_cf){
|
| 634 |
case dk.LEFT_ARROW:
|
| 635 |
if(!_cc){
|
| 636 |
return;
|
| 637 |
} |
| 638 |
_ce=this.getHeaderNodes().length;
|
| 639 |
for(i=0;i<_ce;i++){ |
| 640 |
if(this.isColSelected(i)){ |
| 641 |
this.drugDestIndex=i-1; |
| 642 |
this.drugBefore=true; |
| 643 |
break;
|
| 644 |
} |
| 645 |
} |
| 646 |
var _d0=this.grid.indirectSelection?1:0; |
| 647 |
(this.drugDestIndex>=_d0)?this.startMoveCols():(this.drugDestIndex=_d0); |
| 648 |
break;
|
| 649 |
case dk.RIGHT_ARROW:
|
| 650 |
if(!_cc){
|
| 651 |
return;
|
| 652 |
} |
| 653 |
_ce=this.getHeaderNodes().length;
|
| 654 |
this.drugBefore=true; |
| 655 |
for(i=0;i<_ce;i++){ |
| 656 |
if(this.isColSelected(i)&&!this.isColSelected(i+1)){ |
| 657 |
this.drugDestIndex=i+2; |
| 658 |
if(this.drugDestIndex==_ce){ |
| 659 |
this.drugDestIndex--;
|
| 660 |
this.drugBefore=false; |
| 661 |
} |
| 662 |
break;
|
| 663 |
} |
| 664 |
} |
| 665 |
if(this.drugDestIndex<_ce){ |
| 666 |
this.startMoveCols();
|
| 667 |
} |
| 668 |
break;
|
| 669 |
case dk.UP_ARROW:
|
| 670 |
if(!_cd){
|
| 671 |
return;
|
| 672 |
} |
| 673 |
this.avaOnRowIndex=dojo.hitch(this.grid.selection,dojox.grid.Selection.prototype["getFirstSelected"])()-1; |
| 674 |
if(this.avaOnRowIndex>-1){ |
| 675 |
this.startMoveRows();
|
| 676 |
} |
| 677 |
break;
|
| 678 |
case dk.DOWN_ARROW:
|
| 679 |
if(!_cd){
|
| 680 |
return;
|
| 681 |
} |
| 682 |
for(i=0;i<this.grid.rowCount;i++){ |
| 683 |
if(this.grid.selection.selected[i]&&!this.grid.selection.selected[i+1]){ |
| 684 |
this.avaOnRowIndex=i+2; |
| 685 |
break;
|
| 686 |
} |
| 687 |
} |
| 688 |
if(this.avaOnRowIndex<=this.grid.rowCount){ |
| 689 |
this.startMoveRows();
|
| 690 |
} |
| 691 |
} |
| 692 |
}}); |
| 693 |
} |