1
1
/*!
2
2
* angular-ui-scroll
3
3
* https://github.com/angular-ui/ui-scroll.git
4
- * Version: 1.5.2 -- 2017-01-13T00:53:53.341Z
4
+ * Version: 1.5.2 -- 2017-01-13T01:48:13.045Z
5
5
* License: MIT
6
6
*/
7
7
8
8
9
9
( function ( ) {
10
+ ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == 'function' && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( 'Cannot find module \'' + o + '\'' ) ; throw f . code = 'MODULE_NOT_FOUND' , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == 'function' && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
10
11
'use strict' ;
11
12
12
13
angular . module ( 'ui.scroll.grid' , [ ] ) . directive ( 'uiScrollTh' , [ '$log' , '$timeout' , function ( console , $timeout ) {
@@ -48,11 +49,11 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
48
49
} ;
49
50
50
51
this . moveBefore = function ( index ) {
51
- controller . moveBefore ( column , index ) ;
52
+ return controller . moveBefore ( column , index ) ;
52
53
} ;
53
54
54
55
this . exchangeWith = function ( index ) {
55
- controller . exchangeWith ( column , index ) ;
56
+ return controller . exchangeWith ( column , index ) ;
56
57
} ;
57
58
58
59
Object . defineProperty ( this , 'columnId' , { get : function get ( ) {
@@ -63,7 +64,6 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
63
64
function ColumnController ( controller , columns , header ) {
64
65
65
66
this . header = header ;
66
- this . cells = [ ] ;
67
67
this . css = { } ;
68
68
this . mapTo = columns . length ;
69
69
this . id = columns . length ;
@@ -95,10 +95,12 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
95
95
this . columnFromPoint = function ( x , y ) {
96
96
var _this2 = this ;
97
97
98
- if ( insidePoint ( header , x , y ) ) return this ;
99
- var result = undefined ;
98
+ if ( insidePoint ( header , x , y ) ) {
99
+ return this ;
100
+ }
101
+ var result = null ;
100
102
controller . forEachRow ( function ( row ) {
101
- if ( insidePoint ( row [ _this2 . id ] , x , y ) ) result = _this2 ;
103
+ return result = insidePoint ( row [ _this2 . id ] , x , y ) ? _this2 : result ;
102
104
} ) ;
103
105
return result ;
104
106
} ;
@@ -121,7 +123,7 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
121
123
target . before ( element ) ;
122
124
}
123
125
124
- function moveLast ( element , target ) {
126
+ function moveLast ( element ) {
125
127
var parent = element . parent ( ) ;
126
128
element . detach ( ) ;
127
129
parent . append ( element ) ;
@@ -130,12 +132,14 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
130
132
function applyCss ( target , css ) {
131
133
target . removeAttr ( 'style' ) ;
132
134
for ( var attr in css ) {
133
- if ( css . hasOwnProperty ( attr ) ) target . css ( attr , css [ attr ] ) ;
135
+ if ( css . hasOwnProperty ( attr ) ) {
136
+ target . css ( attr , css [ attr ] ) ;
137
+ }
134
138
}
135
- } ;
139
+ }
136
140
}
137
141
138
- function GridController ( scope , scrollViewport ) {
142
+ function GridController ( scrollViewport ) {
139
143
var _this3 = this ;
140
144
141
145
var columns = [ ] ;
@@ -154,13 +158,13 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
154
158
155
159
this . registerCell = function ( scope , cell ) {
156
160
var row = rowMap . get ( scope ) ;
157
-
158
161
if ( ! row ) {
159
162
row = [ ] ;
160
163
rowMap . set ( scope , row ) ;
161
164
}
162
-
163
- if ( row . length >= columns . length ) return false ;
165
+ if ( row . length >= columns . length ) {
166
+ return false ;
167
+ }
164
168
row . push ( cell ) ;
165
169
return true ;
166
170
} ;
@@ -169,7 +173,9 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
169
173
var row = rowMap . get ( scope ) ;
170
174
var i = row . indexOf ( cell ) ;
171
175
row . splice ( i , 1 ) ;
172
- if ( ! row . length ) rowMap . delete ( scope ) ;
176
+ if ( ! row . length ) {
177
+ rowMap [ 'delete' ] ( scope ) ;
178
+ }
173
179
} ;
174
180
175
181
this . forEachRow = function ( callback ) {
@@ -205,25 +211,28 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
205
211
throw new Error ( 'Failed to apply layout - number of layouts should match number of columns' ) ;
206
212
}
207
213
layouts . forEach ( function ( layout , index ) {
208
- columns [ index ] . applyLayout ( layout ) ;
214
+ return columns [ index ] . applyLayout ( layout ) ;
209
215
} ) ;
210
216
transform ( columns . map ( function ( column ) {
211
217
return column . header ;
212
218
} ) ) ;
213
219
rowMap . forEach ( function ( row ) {
214
- transform ( row ) ;
220
+ return transform ( row ) ;
215
221
} ) ;
216
222
} ;
217
223
218
224
this . moveBefore = function ( selected , target ) {
219
225
var index = target ;
220
226
221
- if ( target % 1 !== 0 ) index = target ? columns [ target . columnId ] . mapTo : columns . length ;
222
-
223
- if ( index < 0 || index > columns . length ) return ; // throw an error?
227
+ if ( target % 1 !== 0 ) {
228
+ index = target ? columns [ target . columnId ] . mapTo : columns . length ;
229
+ }
230
+ if ( index < 0 || index > columns . length ) {
231
+ return ; // throw an error?
232
+ }
224
233
225
234
var mapTo = selected . mapTo ,
226
- next = undefined ;
235
+ next = null ;
227
236
index -= mapTo < index ? 1 : 0 ;
228
237
229
238
columns . forEach ( function ( c ) {
@@ -237,20 +246,20 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
237
246
} ;
238
247
239
248
this . exchangeWith = function ( selected , index ) {
240
- if ( index < 0 || index >= columns . length ) return ;
249
+ if ( index < 0 || index >= columns . length ) {
250
+ return ;
251
+ }
241
252
columns . find ( function ( c ) {
242
253
return c . mapTo === index ;
243
254
} ) . mapTo = selected . mapTo ;
244
255
selected . mapTo = index ;
245
256
} ;
246
257
247
258
this . columnFromPoint = function ( x , y ) {
248
- for ( var i = 0 ; i < columns . length ; i ++ ) {
249
- var column = columns [ i ] . columnFromPoint ( x , y ) ;
250
- if ( column ) break ;
251
- }
252
- if ( column ) return new ColumnAdapter ( this , column ) ;
253
- return undefined ;
259
+ var column = columns . find ( function ( col ) {
260
+ return col . columnFromPoint ( x , y ) ;
261
+ } ) ;
262
+ return column ? new ColumnAdapter ( this , column ) : undefined ;
254
263
} ;
255
264
256
265
// function definitions
@@ -274,16 +283,16 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
274
283
return {
275
284
require : [ '^^uiScrollViewport' ] ,
276
285
restrict : 'A' ,
277
- link : function link ( $scope , element , $attr , controllers , linker ) {
278
- controllers [ 0 ] . gridController = controllers [ 0 ] . gridController || new GridController ( $scope , controllers [ 0 ] ) ;
286
+ link : function link ( $scope , element , $attr , controllers ) {
287
+ controllers [ 0 ] . gridController = controllers [ 0 ] . gridController || new GridController ( controllers [ 0 ] ) ;
279
288
controllers [ 0 ] . gridController . registerColumn ( element ) ;
280
289
}
281
290
} ;
282
- } ] ) . directive ( 'uiScrollTd' , [ '$log' , function ( console ) {
291
+ } ] ) . directive ( 'uiScrollTd' , [ '$log' , function ( ) {
283
292
return {
284
293
require : [ '?^^uiScrollViewport' ] ,
285
294
restrict : 'A' ,
286
- link : function link ( $scope , element , $attr , controllers , linker ) {
295
+ link : function link ( $scope , element , $attr , controllers ) {
287
296
if ( controllers [ 0 ] ) {
288
297
( function ( ) {
289
298
var gridController = controllers [ 0 ] . gridController ;
@@ -297,4 +306,6 @@ angular.module('ui.scroll.grid', []).directive('uiScrollTh', ['$log', '$timeout'
297
306
}
298
307
} ;
299
308
} ] ) ;
309
+
310
+ } , { } ] } , { } , [ 1 ] ) ;
300
311
} ( ) ) ;
0 commit comments