@@ -20,6 +20,7 @@ angular.module('ui.sortable', [])
20
20
uiSortable : '='
21
21
} ,
22
22
link : function ( scope , element , attrs , ngModel ) {
23
+ 'use strict' ;
23
24
var savedNodes ;
24
25
25
26
function combineCallbacks ( first , second ) {
@@ -35,6 +36,28 @@ angular.module('ui.sortable', [])
35
36
return first ;
36
37
}
37
38
39
+ function wrappersHelper ( inner ) {
40
+ return function ( e , item ) {
41
+ var oldItemSortable = item . sortable ;
42
+ var index = getItemIndex ( item ) ;
43
+ item . sortable = {
44
+ model : ngModel . $modelValue [ index ] ,
45
+ index : index ,
46
+ source : item . parent ( ) ,
47
+ sourceModel : ngModel . $modelValue ,
48
+ _restore : function ( ) {
49
+ delete item . sortable ;
50
+ item . sortable = oldItemSortable ;
51
+ }
52
+ } ;
53
+
54
+ var innerResult = inner . apply ( this , arguments ) ;
55
+ item . sortable . _restore ( ) ;
56
+ item . sortable . _isCustomHelperUsed = item !== innerResult ;
57
+ return innerResult ;
58
+ } ;
59
+ }
60
+
38
61
function getSortableWidgetInstance ( element ) {
39
62
// this is a fix to support jquery-ui prior to v1.11.x
40
63
// otherwise we should be using `element.sortable('instance')`
@@ -363,28 +386,6 @@ angular.module('ui.sortable', [])
363
386
}
364
387
} ;
365
388
366
- function wrappersHelper ( inner ) {
367
- return function ( e , item ) {
368
- var oldItemSortable = item . sortable ;
369
- var index = getItemIndex ( item ) ;
370
- item . sortable = {
371
- model : ngModel . $modelValue [ index ] ,
372
- index : index ,
373
- source : item . parent ( ) ,
374
- sourceModel : ngModel . $modelValue ,
375
- _restore : function ( ) {
376
- delete item . sortable ;
377
- item . sortable = oldItemSortable ;
378
- }
379
- } ;
380
-
381
- var innerResult = inner . apply ( this , arguments ) ;
382
- item . sortable . _restore ( ) ;
383
- item . sortable . _isCustomHelperUsed = item !== innerResult ;
384
- return innerResult ;
385
- } ;
386
- } ;
387
-
388
389
scope . $watchCollection ( 'uiSortable' , function ( newVal , oldVal ) {
389
390
// ensure that the jquery-ui-sortable widget instance
390
391
// is still bound to the directive's element
0 commit comments