Browse Source

#475: * merge 'dev' branch

bernerbits-dev
RubaXa 10 years ago
parent
commit
960d7da05b
  1. 23
      Sortable.js
  2. 2
      Sortable.min.js

23
Sortable.js

@ -25,6 +25,7 @@
"use strict";
var dragEl,
parentEl,
ghostEl,
cloneEl,
rootEl,
@ -303,6 +304,7 @@
rootEl = el;
dragEl = target;
parentEl = target.parentNode;
nextEl = dragEl.nextSibling;
activeGroup = options.group;
@ -706,19 +708,20 @@
_disableDraggable(dragEl);
_toggleClass(dragEl, this.options.ghostClass, false);
if (rootEl !== dragEl.parentNode) {
if (rootEl !== parentEl) {
newIndex = _index(dragEl);
if (newIndex != -1) {
// drag from one list and drop into another
_dispatchEvent(null, dragEl.parentNode, 'sort', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
// Add event
_dispatchEvent(null, dragEl.parentNode, 'add', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex);
// Remove event
_dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex);
}
}
else {
// Remove clone
cloneEl && cloneEl.parentNode.removeChild(cloneEl);
@ -726,12 +729,13 @@
if (dragEl.nextSibling !== nextEl) {
// Get the index of the dragged element within its parent
newIndex = _index(dragEl);
if (newIndex != -1) {
// drag & drop within the same list
_dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
}
}
}
if (Sortable.active) {
// Drag end event
@ -745,6 +749,7 @@
// Nulling
rootEl =
dragEl =
parentEl =
ghostEl =
nextEl =
cloneEl =
@ -1092,6 +1097,9 @@
* @private
*/
function _index(/**HTMLElement*/el) {
if (!el || !el.parentNode) {
return -1;
}
var index = 0;
while (el && (el = el.previousElementSibling)) {
if (el.nodeName.toUpperCase() !== 'TEMPLATE') {
@ -1152,9 +1160,6 @@
};
Sortable.version = '1.2.2';
/**
* Create sortable instance
* @param {HTMLElement} el
@ -1164,6 +1169,8 @@
return new Sortable(el, options);
};
// Export
Sortable.version = '1.2.2';
return Sortable;
});

2
Sortable.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save