Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support IE9 #240

Closed
wants to merge 14 commits into from
6 changes: 3 additions & 3 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"strict": true,
"newcap": false, // "Tolerate uncapitalized constructors"
"newcap": false,
"node": true,
"expr": true, // - true && call() "Expected an assignment or function call and instead saw an expression."
"supernew": true, // - "Missing '()' invoking a constructor."
"expr": true,
"supernew": true,
"laxbreak": true,
"white": true,
"globals": {
Expand Down
81 changes: 40 additions & 41 deletions Sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,46 +228,46 @@
}

// Prepare `dragstart`
if (target && !dragEl && (target.parentNode === el)) {
if (target && (target.parentNode === el)) {
// IE 9 Support
(type === 'selectstart') && target.dragDrop();

tapEvt = evt;

rootEl = this.el;
dragEl = target;
nextEl = dragEl.nextSibling;
activeGroup = this.options.group;

dragEl.draggable = true;
if (type === 'selectstart') {
target.dragDrop();
} else if (!dragEl) {
tapEvt = evt;

rootEl = this.el;
dragEl = target;
nextEl = dragEl.nextSibling;
activeGroup = this.options.group;

dragEl.draggable = true;

// Disable "draggable"
options.ignore.split(',').forEach(function (criteria) {
_find(target, criteria.trim(), _disableDraggable);
});

if (touch) {
// Touch device support
tapEvt = {
target: target,
clientX: touch.clientX,
clientY: touch.clientY
};

this._onDragStart(tapEvt, true);
evt.preventDefault();
}

// Disable "draggable"
options.ignore.split(',').forEach(function (criteria) {
_find(target, criteria.trim(), _disableDraggable);
});
_on(document, 'mouseup', this._onDrop);
_on(document, 'touchend', this._onDrop);
_on(document, 'touchcancel', this._onDrop);

if (touch) {
// Touch device support
tapEvt = {
target: target,
clientX: touch.clientX,
clientY: touch.clientY
};
_on(dragEl, 'dragend', this);
_on(rootEl, 'dragstart', this._onDragStart);

this._onDragStart(tapEvt, true);
evt.preventDefault();
_on(document, 'dragover', this);
}

_on(document, 'mouseup', this._onDrop);
_on(document, 'touchend', this._onDrop);
_on(document, 'touchcancel', this._onDrop);

_on(dragEl, 'dragend', this);
_on(rootEl, 'dragstart', this._onDragStart);

_on(document, 'dragover', this);


try {
if (document.selection) {
document.selection.empty();
Expand Down Expand Up @@ -469,7 +469,7 @@
!options.dragoverBubble && evt.stopPropagation();
}

if (!_silent && activeGroup &&
if (!_silent && activeGroup && !options.disabled &&
(isOwner
? canSort || (revert = !rootEl.contains(dragEl))
: activeGroup.pull && groupPut && (
Expand All @@ -496,7 +496,6 @@
return;
}


if ((el.children.length === 0) || (el.children[0] === ghostEl) ||
(el === evt.target) && (target = _ghostInBottom(el, evt))
) {
Expand All @@ -508,7 +507,6 @@
}

_cloneHide(isOwner);

el.appendChild(dragEl);
this._animate(dragRect, dragEl);
target && this._animate(targetRect, target);
Expand All @@ -535,7 +533,6 @@
setTimeout(_unsilent, 30);

_cloneHide(isOwner);

if (floating) {
after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide;
} else {
Expand Down Expand Up @@ -949,8 +946,10 @@
*/
function _index(/**HTMLElement*/el) {
var index = 0;
while (el && (el = el.previousElementSibling) && (el.nodeName.toUpperCase() !== 'TEMPLATE')) {
index++;
while (el && (el = el.previousElementSibling)) {
if (el.nodeName.toUpperCase() !== 'TEMPLATE') {
index++;
}
}
return index;
}
Expand Down
Loading