@@ -31,12 +31,17 @@ namespace BioDeep.UI {
31
31
srcContainer : string ,
32
32
containers : string [ ] ) {
33
33
34
- this . containers = new Dictionary < string [ ] > ( TypeInfo . EmptyObject ( containers , ( ) => ( < string [ ] > [ ] ) ) ) ;
34
+ var union = [ ...containers ] ;
35
+ union . push ( srcContainer ) ;
36
+
37
+ this . containers = new Dictionary < string [ ] > ( TypeInfo . EmptyObject ( union , ( ) => ( < string [ ] > [ ] ) ) ) ;
35
38
this . registerDatas ( items , srcContainer ) ;
36
39
this . registerContainers ( containers ) ;
40
+ this . registerContainers ( [ srcContainer ] ) ;
37
41
38
42
stylingContainers ( containers ) ;
39
43
stylingItems ( From ( items ) . Select ( id => id . key ) ) ;
44
+ stylingContainers ( [ srcContainer ] ) ;
40
45
}
41
46
42
47
private registerContainers ( names : string [ ] ) {
@@ -56,6 +61,7 @@ namespace BioDeep.UI {
56
61
*/
57
62
private binEach ( bin : HTMLElement , container : Dictionary < string [ ] > ) {
58
63
var key : string = bin . id ;
64
+ var dev = this ;
59
65
60
66
Linq . DOM . addEvent ( bin , 'dragover' , function ( e ) {
61
67
if ( e . preventDefault ) {
@@ -88,26 +94,67 @@ namespace BioDeep.UI {
88
94
var event = < DragEvent > e ;
89
95
var strval : string = event . dataTransfer . getData ( 'Text' ) ;
90
96
91
- console . log ( strval ) ;
97
+ // console.log(strval);
92
98
93
99
var data = < Map < string , string > > JSON . parse ( strval ) ;
94
100
var keyId : string = data . key ;
95
101
var el = document . getElementById ( keyId ) ;
102
+ // var newItem = Container.createNewItem(data);
103
+ var newItem = Container . createItem ( data ) ;
96
104
97
- el . parentNode . removeChild ( el ) ;
105
+ el . parentNode . parentNode . removeChild ( el . parentNode ) ;
98
106
// stupid nom text + fade effect
99
107
bin . className = '' ;
100
- document . getElementById ( `${ bin . id } -ul` ) . appendChild ( Container . createItem ( data ) . key ) ;
108
+ document . getElementById ( `${ bin . id } -ul` ) . appendChild ( newItem . key ) ;
101
109
applyItemStyle ( keyId ) ;
110
+ dev . registerItemDragEvent ( newItem . value ) ;
111
+
112
+ container . Keys . ForEach ( key => {
113
+ if ( container . Item ( key ) . indexOf ( data . key ) > - 1 ) {
114
+ var list = From ( container . Item ( key ) )
115
+ . Where ( id => id != data . key )
116
+ . ToArray ( ) ;
117
+
118
+ container . Delete ( key ) . Add ( key , list ) ;
119
+ }
120
+ } )
102
121
103
122
// 在这里得到data数据之后,将数据添加进入对应的容器之中
104
- // console.log(container);
123
+
105
124
container . Item ( key ) . push ( data . key ) ;
125
+ localStorage . setItem ( "groupset" , JSON . stringify ( dev . Data ) ) ;
106
126
127
+ // console.log(container);
107
128
return false ;
108
129
} ) ;
109
130
}
110
131
132
+ /**
133
+ * 将其他的容器之中的数据给删除
134
+ */
135
+ // public deleteData(idValue: string ) {
136
+
137
+
138
+ // }
139
+
140
+ private registerItemDragEvent ( a : HTMLAnchorElement ) : void {
141
+ a . setAttribute ( 'draggable' , 'true' ) ;
142
+
143
+ Linq . DOM . addEvent ( a , 'dragstart' , function ( e ) {
144
+ var event = < DragEvent > e ;
145
+ var data : string = JSON . stringify ( {
146
+ key : a . id ,
147
+ value : a . innerText
148
+ } ) ;
149
+
150
+ // only dropEffect='copy' will be dropable
151
+ event . dataTransfer . effectAllowed = 'copy' ;
152
+ // required otherwise doesn't work
153
+ event . dataTransfer . setData ( 'Text' , data ) ;
154
+ } ) ;
155
+ }
156
+
157
+
111
158
/**
112
159
* 为数据对象在容器之中注册鼠标事件
113
160
*/
@@ -120,27 +167,61 @@ namespace BioDeep.UI {
120
167
} )
121
168
data . Select ( a => a . value )
122
169
. ForEach ( el => {
123
- el . setAttribute ( 'draggable' , 'true' ) ;
124
-
125
- Linq . DOM . addEvent ( el , 'dragstart' , function ( e ) {
126
- var event = < DragEvent > e ;
127
- var data : string = JSON . stringify ( {
128
- key : el . id ,
129
- value : el . innerText
130
- } ) ;
131
-
132
- // only dropEffect='copy' will be dropable
133
- event . dataTransfer . effectAllowed = 'copy' ;
134
- // required otherwise doesn't work
135
- event . dataTransfer . setData ( 'Text' , data ) ;
136
- } ) ;
170
+ this . registerItemDragEvent ( el ) ;
137
171
} ) ;
138
172
}
139
173
140
- private static createItem ( item : Map < string , string > ) : Map < HTMLLIElement , HTMLAnchorElement > {
174
+ /**
175
+ * 测试部分开始
176
+ */
177
+
178
+ /**
179
+ * 原始数据分组移动时,在新的分组中添加数据显示
180
+ */
181
+
182
+ private static createNewItem ( item : Map < string , string > ) : Map < HTMLLIElement , HTMLAnchorElement > {
141
183
var li = document . createElement ( "li" ) ;
142
184
var a = document . createElement ( "a" ) ;
185
+ var i_tag = document . createElement ( "i" ) ;
186
+
187
+ a . id = item . key ;
188
+ a . href = "#" ;
189
+ a . innerText = item . value ;
190
+ var a_style = a . style ;
191
+ a_style . cssFloat = "left" ;
192
+ li . appendChild ( a ) ;
193
+
194
+ i_tag . className = "fa fa-times" ;
195
+ i_tag . onclick = function ( ) {
196
+ i_tag . parentNode . removeChild ( i_tag ) ;
197
+
198
+ } ;
199
+ var style = i_tag . style ;
200
+ style . lineHeight = "line-height: 52px" ;
201
+ style . color = "red" ;
202
+ style . fontSize = "20px" ;
203
+ style . cursor = "pointer" ;
204
+ style . cssFloat = "right" ;
205
+ style . marginRight = "10px" ;
206
+ style . marginTop = "20px" ;
207
+ li . appendChild ( i_tag ) ;
208
+
209
+ return < Map < HTMLLIElement , HTMLAnchorElement > > {
210
+ key : li , value : a
211
+ } ;
212
+ }
213
+
214
+
215
+ /**
216
+ * 测试结束
217
+ */
143
218
219
+
220
+
221
+ private static createItem ( item : Map < string , string > ) : Map < HTMLLIElement , HTMLAnchorElement > {
222
+ var li = document . createElement ( "li" ) ;
223
+ var a = document . createElement ( "a" ) ;
224
+
144
225
a . id = item . key ;
145
226
a . href = "#" ;
146
227
a . innerText = item . value ;
0 commit comments