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