1
1
/**
2
2
* angular-ui-sortable - This directive allows you to jQueryUI Sortable.
3
- * @version v0.16.1 - 2016-12-16
3
+ * @version v0.17.0 - 2017-03-08
4
4
* @link http://angular-ui.github.com
5
5
* @license MIT
6
6
*/
@@ -23,10 +23,25 @@ angular.module('ui.sortable', [])
23
23
'uiSortableConfig' , '$timeout' , '$log' ,
24
24
function ( uiSortableConfig , $timeout , $log ) {
25
25
return {
26
- require : '?ngModel' ,
26
+ require :'?ngModel' ,
27
27
scope : {
28
- ngModel : '=' ,
29
- uiSortable : '='
28
+ ngModel :'=' ,
29
+ uiSortable :'=' ,
30
+ ////Expression bindings from html.
31
+ create :'&uiSortableCreate' ,
32
+ // helper:'&uiSortableHelper',
33
+ start :'&uiSortableStart' ,
34
+ activate :'&uiSortableActivate' ,
35
+ // sort:'&uiSortableSort',
36
+ // change:'&uiSortableChange',
37
+ // over:'&uiSortableOver',
38
+ // out:'&uiSortableOut',
39
+ beforeStop :'&uiSortableBeforeStop' ,
40
+ update :'&uiSortableUpdate' ,
41
+ remove :'&uiSortableRemove' ,
42
+ receive :'&uiSortableReceive' ,
43
+ deactivate :'&uiSortableDeactivate' ,
44
+ stop :'&uiSortableStop'
30
45
} ,
31
46
link : function ( scope , element , attrs , ngModel ) {
32
47
var savedNodes ;
@@ -226,11 +241,19 @@ angular.module('ui.sortable', [])
226
241
} ;
227
242
228
243
var callbacks = {
229
- receive : null ,
230
- remove : null ,
244
+ create : null ,
231
245
start : null ,
232
- stop : null ,
233
- update : null
246
+ activate : null ,
247
+ // sort: null,
248
+ // change: null,
249
+ // over: null,
250
+ // out: null,
251
+ beforeStop : null ,
252
+ update : null ,
253
+ remove : null ,
254
+ receive : null ,
255
+ deactivate : null ,
256
+ stop : null
234
257
} ;
235
258
236
259
var wrappers = {
@@ -331,7 +354,7 @@ angular.module('ui.sortable', [])
331
354
// Save current drop position but only if this is not a second
332
355
// update that happens when moving between lists because then
333
356
// the value will be overwritten with the old value
334
- if ( ! ui . item . sortable . received ) {
357
+ if ( ! ui . item . sortable . received ) {
335
358
ui . item . sortable . dropindex = getItemIndex ( ui . item ) ;
336
359
var droptarget = ui . item . closest ( '[ui-sortable], [data-ui-sortable], [x-ui-sortable]' ) ;
337
360
ui . item . sortable . droptarget = droptarget ;
@@ -365,19 +388,20 @@ angular.module('ui.sortable', [])
365
388
// it's safe to clear the restored nodes since:
366
389
// update is currently running and
367
390
// stop is not called for the target list.
368
- if ( ui . item . sortable . received ) {
391
+ if ( ui . item . sortable . received ) {
369
392
savedNodes = null ;
370
393
}
371
394
372
395
// If received is true (an item was dropped in from another list)
373
396
// then we add the new item to this list otherwise wait until the
374
397
// stop event where we will know if it was a sort or item was
375
398
// moved here from another list
376
- if ( ui . item . sortable . received && ! ui . item . sortable . isCanceled ( ) ) {
399
+ if ( ui . item . sortable . received && ! ui . item . sortable . isCanceled ( ) ) {
377
400
scope . $apply ( function ( ) {
378
401
ngModel . $modelValue . splice ( ui . item . sortable . dropindex , 0 ,
379
402
ui . item . sortable . moved ) ;
380
403
} ) ;
404
+ scope . $emit ( 'ui-sortable:moved' , ui ) ;
381
405
}
382
406
} ;
383
407
@@ -395,6 +419,7 @@ angular.module('ui.sortable', [])
395
419
ui . item . sortable . dropindex , 0 ,
396
420
ngModel . $modelValue . splice ( ui . item . sortable . index , 1 ) [ 0 ] ) ;
397
421
} ) ;
422
+ scope . $emit ( 'ui-sortable:moved' , ui ) ;
398
423
} else if ( ! wasMoved &&
399
424
! angular . equals ( element . contents ( ) . toArray ( ) , savedNodes . toArray ( ) ) ) {
400
425
// if the item was not moved
@@ -442,6 +467,21 @@ angular.module('ui.sortable', [])
442
467
}
443
468
} ;
444
469
470
+ // setup attribute handlers
471
+ angular . forEach ( callbacks , function ( value , key ) {
472
+ callbacks [ key ] = combineCallbacks ( callbacks [ key ] ,
473
+ function ( ) {
474
+ var attrHandler = scope [ key ] ;
475
+ var attrHandlerFn ;
476
+ if ( typeof attrHandler === 'function' &&
477
+ ( 'uiSortable' + key . substring ( 0 , 1 ) . toUpperCase ( ) + key . substring ( 1 ) ) . length &&
478
+ typeof ( attrHandlerFn = attrHandler ( ) ) === 'function' ) {
479
+ attrHandlerFn . apply ( this , arguments ) ;
480
+ }
481
+ } ) ;
482
+ } ) ;
483
+
484
+
445
485
wrappers . helper = function ( inner ) {
446
486
if ( inner && typeof inner === 'function' ) {
447
487
return function ( e , item ) {
0 commit comments