Browse Source

Merge branch 'master' of https://github.com/Tradiio/Sortable into Tradiio-master

ng-sortable-with-debugInfoEnabled-false
RubaXa 9 years ago
parent
commit
e7415899ac
  1. 18
      ng-sortable.js

18
ng-sortable.js

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

Loading…
Cancel
Save