|
|
|
@ -64,11 +64,12 @@
|
|
|
|
|
// Export
|
|
|
|
|
return { |
|
|
|
|
restrict: 'AC', |
|
|
|
|
scope: { ngSortable: "=?" }, |
|
|
|
|
link: function (scope, $el, attrs) { |
|
|
|
|
var el = $el[0], |
|
|
|
|
ngSortable = attrs.ngSortable, |
|
|
|
|
options = scope.$eval(ngSortable) || {}, |
|
|
|
|
options = scope.ngSortable || {}, |
|
|
|
|
source = getSource(el), |
|
|
|
|
watchers = [], |
|
|
|
|
sortable |
|
|
|
|
; |
|
|
|
|
|
|
|
|
@ -154,27 +155,29 @@
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
$el.on('$destroy', function () { |
|
|
|
|
angular.forEach(watchers, function (/** Function */unwatch) { |
|
|
|
|
unwatch(); |
|
|
|
|
}); |
|
|
|
|
sortable.destroy(); |
|
|
|
|
watchers = null; |
|
|
|
|
sortable = null; |
|
|
|
|
nextSibling = null; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (ngSortable && !/{|}/.test(ngSortable)) { // todo: ugly
|
|
|
|
|
angular.forEach([ |
|
|
|
|
'sort', 'disabled', 'draggable', 'handle', 'animation', |
|
|
|
|
'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort' |
|
|
|
|
], function (name) { |
|
|
|
|
scope.$watch(ngSortable + '.' + name, function (value) { |
|
|
|
|
if (value !== void 0) { |
|
|
|
|
options[name] = value; |
|
|
|
|
|
|
|
|
|
if (!/^on[A-Z]/.test(name)) { |
|
|
|
|
sortable.option(name, value); |
|
|
|
|
} |
|
|
|
|
angular.forEach([ |
|
|
|
|
'sort', 'disabled', 'draggable', 'handle', 'animation', |
|
|
|
|
'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort' |
|
|
|
|
], function (name) { |
|
|
|
|
watchers.push(scope.$watch('ngSortable.' + name, function (value) { |
|
|
|
|
if (value !== void 0) { |
|
|
|
|
options[name] = value; |
|
|
|
|
|
|
|
|
|
if (!/^on[A-Z]/.test(name)) { |
|
|
|
|
sortable.option(name, value); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
})); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
}]); |
|
|
|
|