|
|
|
@ -31,8 +31,13 @@
|
|
|
|
|
var removed, |
|
|
|
|
nextSibling; |
|
|
|
|
|
|
|
|
|
// Export
|
|
|
|
|
return { |
|
|
|
|
restrict: 'AC', |
|
|
|
|
scope: { ngSortable: "=?" }, |
|
|
|
|
link: function (scope, $el, attrs) { |
|
|
|
|
|
|
|
|
|
function getSource(el) { |
|
|
|
|
var scope = angular.element(el).scope(); |
|
|
|
|
var ngRepeat = [].filter.call(el.childNodes, function (node) { |
|
|
|
|
return ( |
|
|
|
|
(node.nodeType === 8) && |
|
|
|
@ -52,21 +57,12 @@
|
|
|
|
|
var itemsExpr = $parse(ngRepeat[2]); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
item: function (el) { |
|
|
|
|
return itemExpr(angular.element(el).scope()); |
|
|
|
|
}, |
|
|
|
|
items: function () { |
|
|
|
|
return itemsExpr(scope); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Export
|
|
|
|
|
return { |
|
|
|
|
restrict: 'AC', |
|
|
|
|
scope: { ngSortable: "=?" }, |
|
|
|
|
link: function (scope, $el, attrs) { |
|
|
|
|
var el = $el[0], |
|
|
|
|
options = angular.extend(scope.ngSortable || {}, ngSortableConfig), |
|
|
|
|
source = getSource(el), |
|
|
|
@ -80,7 +76,7 @@
|
|
|
|
|
|
|
|
|
|
/* jshint expr:true */ |
|
|
|
|
options[name] && options[name]({ |
|
|
|
|
model: item || source && source.item(evt.item), |
|
|
|
|
model: item || source && source.items()[evt.newIndex], |
|
|
|
|
models: source && source.items(), |
|
|
|
|
oldIndex: evt.oldIndex, |
|
|
|
|
newIndex: evt.newIndex |
|
|
|
|