1
1
/*!
2
2
* angular-ui-scroll
3
3
* https://github.com/angular-ui/ui-scroll.git
4
- * Version: 1.4.1 -- 2016-05-23T19:02:24.849Z
4
+ * Version: 1.4.1 -- 2016-05-24T16:17:58.257Z
5
5
* License: MIT
6
6
*/
7
7
@@ -125,15 +125,32 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
125
125
126
126
$timeout ( function ( ) {
127
127
scrollViewport . adapter . gridAdapter = new GridAdapter ( _this ) ;
128
- scrollViewport . adapter . transform = function ( item ) {
129
- return transform ( item ) ;
128
+ scrollViewport . adapter . transform = function ( scope , item ) {
129
+ return _this . transform ( scope , item ) ;
130
130
} ;
131
131
} ) ;
132
132
133
- function transform ( item ) {
134
- console . log ( item ) ;
135
- console . log ( rowMap . size ) ;
136
- }
133
+ this . transform = function ( scope , item ) {
134
+ var _this2 = this ;
135
+
136
+ var row = rowMap . get ( scope ) ;
137
+ var parent = row [ 0 ] . parent ( ) ;
138
+ var last = row [ row . length - 1 ] . next ( ) ;
139
+ var visible = [ ] ;
140
+ columns . forEach ( function ( column , index ) {
141
+ _this2 . applyCss ( row [ index ] , column . layout . css ) ;
142
+ visible [ columns [ index ] . mapTo ] = row [ index ] ;
143
+ } ) ;
144
+ var current = visible . shift ( ) ;
145
+ current . detach ( ) ;
146
+ if ( last . length ) last . before ( current ) ; else parent . append ( current ) ;
147
+
148
+ visible . forEach ( function ( cell ) {
149
+ cell . detach ( ) ;
150
+ current . after ( cell ) ;
151
+ current = cell ;
152
+ } ) ;
153
+ } ;
137
154
138
155
this . registerColumn = function ( header ) {
139
156
columns . push ( new ColumnController ( columns , header ) ) ;
@@ -152,13 +169,14 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
152
169
}
153
170
if ( index < columns . length ) {
154
171
columns [ index ] . cells . push ( cell ) ;
172
+
155
173
var row = rowMap . get ( scope ) ;
156
174
if ( ! row ) {
157
175
row = [ ] ;
158
176
rowMap . set ( scope , row ) ;
159
177
}
160
178
row [ index ] = cell ;
161
- this . applyCss ( cell , columns [ index ] . layout . css ) ;
179
+
162
180
return index ++ ;
163
181
}
164
182
return - 1 ;
@@ -175,13 +193,13 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
175
193
} ;
176
194
177
195
this . getColumns = function ( ) {
178
- var _this2 = this ;
196
+ var _this3 = this ;
179
197
180
198
var result = [ ] ;
181
199
columns . slice ( ) . sort ( function ( a , b ) {
182
200
return a . mapTo - b . mapTo ;
183
201
} ) . forEach ( function ( column ) {
184
- return result . push ( new ColumnAdapter ( _this2 , column ) ) ;
202
+ return result . push ( new ColumnAdapter ( _this3 , column ) ) ;
185
203
} ) ;
186
204
return result ;
187
205
} ;
@@ -199,16 +217,16 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
199
217
} ;
200
218
201
219
this . applyLayout = function ( columnDescriptors ) {
202
- var _this3 = this ;
220
+ var _this4 = this ;
203
221
204
222
if ( ! columnDescriptors || ! columnDescriptors . length ) {
205
223
return console . warn ( 'Nothing to apply.' ) ;
206
224
}
207
225
columnDescriptors . forEach ( function ( columnDescriptor , index ) {
208
226
if ( index < 0 || index >= columns . length ) return ;
209
- var columnAdapter = new ColumnAdapter ( _this3 , columns [ index ] ) ;
227
+ var columnAdapter = new ColumnAdapter ( _this4 , columns [ index ] ) ;
210
228
columns [ index ] . reset ( ) ;
211
- _this3 . applyCss ( columnAdapter , columnDescriptor . layout . css ) ;
229
+ _this4 . applyCss ( columnAdapter , columnDescriptor . layout . css ) ;
212
230
} ) ;
213
231
} ;
214
232
0 commit comments