Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / mdnd / dropMode / OverDropMode.js @ 13

History | View | Annotate | Download (2.89 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.mdnd.dropMode.OverDropMode"]){
9
dojo._hasResource["dojox.mdnd.dropMode.OverDropMode"]=true;
10
dojo.provide("dojox.mdnd.dropMode.OverDropMode");
11
dojo.require("dojox.mdnd.AreaManager");
12
dojo.declare("dojox.mdnd.dropMode.OverDropMode",null,{_oldXPoint:null,_oldYPoint:null,_oldBehaviour:"up",constructor:function(){
13
this._dragHandler=[dojo.connect(dojox.mdnd.areaManager(),"onDragEnter",function(_1,_2){
14
var m=dojox.mdnd.areaManager();
15
if(m._oldIndexArea==-1){
16
m._oldIndexArea=m._lastValidIndexArea;
17
}
18
})];
19
},addArea:function(_3,_4){
20
var _5=_3.length,_6=dojo.position(_4.node,true);
21
_4.coords={"x":_6.x,"y":_6.y};
22
if(_5==0){
23
_3.push(_4);
24
}else{
25
var x=_4.coords.x;
26
for(var i=0;i<_5;i++){
27
if(x<_3[i].coords.x){
28
for(var j=_5-1;j>=i;j--){
29
_3[j+1]=_3[j];
30
}
31
_3[i]=_4;
32
break;
33
}
34
}
35
if(i==_5){
36
_3.push(_4);
37
}
38
}
39
return _3;
40
},updateAreas:function(_7){
41
var _8=_7.length;
42
for(var i=0;i<_8;i++){
43
this._updateArea(_7[i]);
44
}
45
},_updateArea:function(_9){
46
var _a=dojo.position(_9.node,true);
47
_9.coords.x=_a.x;
48
_9.coords.x2=_a.x+_a.w;
49
_9.coords.y=_a.y;
50
},initItems:function(_b){
51
dojo.forEach(_b.items,function(_c){
52
var _d=_c.item.node;
53
var _e=dojo.position(_d,true);
54
var y=_e.y+_e.h/2;
55
_c.y=y;
56
});
57
_b.initItems=true;
58
},refreshItems:function(_f,_10,_11,_12){
59
if(_10==-1){
60
return;
61
}else{
62
if(_f&&_11&&_11.h){
63
var _13=_11.h;
64
if(_f.margin){
65
_13+=_f.margin.t;
66
}
67
var _14=_f.items.length;
68
for(var i=_10;i<_14;i++){
69
var _15=_f.items[i];
70
if(_12){
71
_15.y+=_13;
72
}else{
73
_15.y-=_13;
74
}
75
}
76
}
77
}
78
},getDragPoint:function(_16,_17,_18){
79
return {"x":_18.x,"y":_18.y};
80
},getTargetArea:function(_19,_1a,_1b){
81
var _1c=0;
82
var x=_1a.x;
83
var y=_1a.y;
84
var end=_19.length;
85
var _1d=0,_1e="right",_1f=false;
86
if(_1b==-1||arguments.length<3){
87
_1f=true;
88
}else{
89
if(this._checkInterval(_19,_1b,x,y)){
90
_1c=_1b;
91
}else{
92
if(this._oldXPoint<x){
93
_1d=_1b+1;
94
}else{
95
_1d=_1b-1;
96
end=0;
97
_1e="left";
98
}
99
_1f=true;
100
}
101
}
102
if(_1f){
103
if(_1e==="right"){
104
for(var i=_1d;i<end;i++){
105
if(this._checkInterval(_19,i,x,y)){
106
_1c=i;
107
break;
108
}
109
}
110
if(i==end){
111
_1c=-1;
112
}
113
}else{
114
for(var i=_1d;i>=end;i--){
115
if(this._checkInterval(_19,i,x,y)){
116
_1c=i;
117
break;
118
}
119
}
120
if(i==end-1){
121
_1c=-1;
122
}
123
}
124
}
125
this._oldXPoint=x;
126
return _1c;
127
},_checkInterval:function(_20,_21,x,y){
128
var _22=_20[_21];
129
var _23=_22.node;
130
var _24=_22.coords;
131
var _25=_24.x;
132
var _26=_24.x2;
133
var _27=_24.y;
134
var _28=_27+_23.offsetHeight;
135
if(_25<=x&&x<=_26&&_27<=y&&y<=_28){
136
return true;
137
}
138
return false;
139
},getDropIndex:function(_29,_2a){
140
var _2b=_29.items.length;
141
var _2c=_29.coords;
142
var y=_2a.y;
143
if(_2b>0){
144
for(var i=0;i<_2b;i++){
145
if(y<_29.items[i].y){
146
return i;
147
}else{
148
if(i==_2b-1){
149
return -1;
150
}
151
}
152
}
153
}
154
return -1;
155
},destroy:function(){
156
dojo.forEach(this._dragHandler,dojo.disconnect);
157
}});
158
(function(){
159
dojox.mdnd.areaManager()._dropMode=new dojox.mdnd.dropMode.OverDropMode();
160
}());
161
}