|
1 | 1 | /**
|
2 | 2 | * angular-ui-sortable - This directive allows you to jQueryUI Sortable.
|
3 |
| - * @version v0.14.0 - 2016-03-28 |
| 3 | + * @version v0.14.1 - 2016-06-06 |
4 | 4 | * @link http://angular-ui.github.com
|
5 | 5 | * @license MIT
|
6 | 6 | */
|
@@ -218,10 +218,10 @@ angular.module('ui.sortable', [])
|
218 | 218 | // return the index of ui.item among the items
|
219 | 219 | // we can't just do ui.item.index() because there it might have siblings
|
220 | 220 | // which are not items
|
221 |
| - function getItemIndex(ui) { |
222 |
| - return ui.item.parent() |
| 221 | + function getItemIndex(item) { |
| 222 | + return item.parent() |
223 | 223 | .find(opts['ui-model-items'])
|
224 |
| - .index(ui.item); |
| 224 | + .index(item); |
225 | 225 | }
|
226 | 226 |
|
227 | 227 | var opts = {};
|
@@ -275,7 +275,7 @@ angular.module('ui.sortable', [])
|
275 | 275 | }
|
276 | 276 |
|
277 | 277 | // Save the starting position of dragged item
|
278 |
| - var index = getItemIndex(ui); |
| 278 | + var index = getItemIndex(ui.item); |
279 | 279 | ui.item.sortable = {
|
280 | 280 | model: ngModel.$modelValue[index],
|
281 | 281 | index: index,
|
@@ -331,7 +331,7 @@ angular.module('ui.sortable', [])
|
331 | 331 | // update that happens when moving between lists because then
|
332 | 332 | // the value will be overwritten with the old value
|
333 | 333 | if(!ui.item.sortable.received) {
|
334 |
| - ui.item.sortable.dropindex = getItemIndex(ui); |
| 334 | + ui.item.sortable.dropindex = getItemIndex(ui.item); |
335 | 335 | var droptarget = ui.item.parent();
|
336 | 336 | ui.item.sortable.droptarget = droptarget;
|
337 | 337 |
|
@@ -440,7 +440,24 @@ angular.module('ui.sortable', [])
|
440 | 440 | wrappers.helper = function (inner) {
|
441 | 441 | if (inner && typeof inner === 'function') {
|
442 | 442 | return function (e, item) {
|
| 443 | + var oldItemSortable = item.sortable; |
| 444 | + var index = getItemIndex(item); |
| 445 | + item.sortable = { |
| 446 | + model: ngModel.$modelValue[index], |
| 447 | + index: index, |
| 448 | + source: item.parent(), |
| 449 | + sourceModel: ngModel.$modelValue, |
| 450 | + _restore: function () { |
| 451 | + angular.forEach(item.sortable, function(value, key) { |
| 452 | + item.sortable[key] = undefined; |
| 453 | + }); |
| 454 | + |
| 455 | + item.sortable = oldItemSortable; |
| 456 | + } |
| 457 | + }; |
| 458 | + |
443 | 459 | var innerResult = inner.apply(this, arguments);
|
| 460 | + item.sortable._restore(); |
444 | 461 | item.sortable._isCustomHelperUsed = item !== innerResult;
|
445 | 462 | return innerResult;
|
446 | 463 | };
|
|
0 commit comments