Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / mdnd / dropMode / VerticalDropMode.js @ 9

History | View | Annotate | Download (3.15 KB)

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