Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit a2e6128

Browse files
author
AngularUI (via TravisCI)
committed
Travis commit : build 364
1 parent ee3af2a commit a2e6128

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ui-sortable",
3-
"version": "0.13.2",
3+
"version": "0.13.3",
44
"main": ["./sortable.js"],
55
"dependencies": {
66
"angular": ">=1.2.x",

sortable.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ angular.module('ui.sortable', [])
1313
return {
1414
require: '?ngModel',
1515
scope: {
16-
ngModel: '=ngModel',
17-
uiSortable: '=uiSortable'
16+
ngModel: '=',
17+
uiSortable: '='
1818
},
1919
link: function(scope, element, attrs, ngModel) {
2020
var savedNodes;
@@ -49,6 +49,18 @@ angular.module('ui.sortable', [])
4949
return (/left|right/).test(item.css('float')) || (/inline|table-cell/).test(item.css('display'));
5050
}
5151

52+
function getElementScope(elementScopes, element) {
53+
var result = null;
54+
for (var i = 0; i < elementScopes.length; i++) {
55+
var x = elementScopes[i];
56+
if (x.element[0] === element[0]) {
57+
result = x.scope;
58+
break;
59+
}
60+
}
61+
return result;
62+
}
63+
5264
function afterStop(e, ui) {
5365
ui.item.sortable._destroy();
5466
}
@@ -128,7 +140,7 @@ angular.module('ui.sortable', [])
128140
};
129141
};
130142

131-
callbacks.activate = function(/*e, ui*/) {
143+
callbacks.activate = function(e, ui) {
132144
// We need to make a copy of the current element's contents so
133145
// we can restore it after sortable has messed it up.
134146
// This is inside activate (instead of start) in order to save
@@ -153,10 +165,20 @@ angular.module('ui.sortable', [])
153165
// exact match with the placeholder's class attribute to handle
154166
// the case that multiple connected sortables exist and
155167
// the placehoilder option equals the class of sortable items
156-
var excludes = element.find('[class="' + phElement.attr('class') + '"]');
168+
var excludes = element.find('[class="' + phElement.attr('class') + '"]:not([ng-repeat], [data-ng-repeat])');
157169

158170
savedNodes = savedNodes.not(excludes);
159171
}
172+
173+
// save the directive's scope so that it is accessible from ui.item.sortable
174+
var connectedSortables = ui.item.sortable._connectedSortables || [];
175+
176+
connectedSortables.push({
177+
element: element,
178+
scope: scope
179+
});
180+
181+
ui.item.sortable._connectedSortables = connectedSortables;
160182
};
161183

162184
callbacks.update = function(e, ui) {
@@ -167,8 +189,9 @@ angular.module('ui.sortable', [])
167189
ui.item.sortable.dropindex = ui.item.index();
168190
var droptarget = ui.item.parent();
169191
ui.item.sortable.droptarget = droptarget;
170-
var attr = droptarget.attr('ng-model') || droptarget.attr('data-ng-model');
171-
ui.item.sortable.droptargetModel = droptarget.scope().$eval(attr);
192+
193+
var droptargetScope = getElementScope(ui.item.sortable._connectedSortables, droptarget);
194+
ui.item.sortable.droptargetModel = droptargetScope.ngModel;
172195

173196
// Cancel the sort (let ng-repeat do the sort for us)
174197
// Don't cancel if this is the received list because it has

sortable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)