|
|
@ -707,16 +707,17 @@ |
|
|
|
|
|
|
|
|
|
|
|
if (rootEl !== parentEl) { |
|
|
|
if (rootEl !== parentEl) { |
|
|
|
newIndex = _index(dragEl); |
|
|
|
newIndex = _index(dragEl); |
|
|
|
|
|
|
|
if (newIndex != -1) { |
|
|
|
|
|
|
|
// drag from one list and drop into another
|
|
|
|
|
|
|
|
_dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
|
|
|
|
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
|
|
|
|
|
|
|
|
// drag from one list and drop into another
|
|
|
|
// Add event
|
|
|
|
_dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
_dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add event
|
|
|
|
|
|
|
|
_dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Remove event
|
|
|
|
// Remove event
|
|
|
|
_dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
_dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
// Remove clone
|
|
|
|
// Remove clone
|
|
|
@ -725,10 +726,11 @@ |
|
|
|
if (dragEl.nextSibling !== nextEl) { |
|
|
|
if (dragEl.nextSibling !== nextEl) { |
|
|
|
// Get the index of the dragged element within its parent
|
|
|
|
// Get the index of the dragged element within its parent
|
|
|
|
newIndex = _index(dragEl); |
|
|
|
newIndex = _index(dragEl); |
|
|
|
|
|
|
|
if (newIndex != -1) { |
|
|
|
// drag & drop within the same list
|
|
|
|
// drag & drop within the same list
|
|
|
|
_dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
_dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -740,7 +742,7 @@ |
|
|
|
this.save(); |
|
|
|
this.save(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Nulling
|
|
|
|
// Nulling
|
|
|
|
rootEl = |
|
|
|
rootEl = |
|
|
|
dragEl = |
|
|
|
dragEl = |
|
|
@ -1092,6 +1094,9 @@ |
|
|
|
* @private |
|
|
|
* @private |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function _index(/**HTMLElement*/el) { |
|
|
|
function _index(/**HTMLElement*/el) { |
|
|
|
|
|
|
|
if (!el || !el.parentNode) { |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
var index = 0; |
|
|
|
var index = 0; |
|
|
|
while (el && (el = el.previousElementSibling)) { |
|
|
|
while (el && (el = el.previousElementSibling)) { |
|
|
|
if (el.nodeName.toUpperCase() !== 'TEMPLATE') { |
|
|
|
if (el.nodeName.toUpperCase() !== 'TEMPLATE') { |
|
|
@ -1151,10 +1156,8 @@ |
|
|
|
index: _index |
|
|
|
index: _index |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Sortable.version = '1.2.2'; |
|
|
|
Sortable.version = '1.2.2'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create sortable instance |
|
|
|
* Create sortable instance |
|
|
|
* @param {HTMLElement} el |
|
|
|
* @param {HTMLElement} el |
|
|
|