sortablejs 1.8.4 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -84,6 +84,7 @@ var sortable = new Sortable(el, {
84
84
  group: "name", // or { name: "...", pull: [true, false, 'clone', array], put: [true, false, array] }
85
85
  sort: true, // sorting inside list
86
86
  delay: 0, // time in milliseconds to define when the sorting should start
87
+ delayOnTouchOnly: false, // only delay if user is using touch
87
88
  touchStartThreshold: 0, // px, how many pixels the point should move before cancelling a delayed drag event
88
89
  disabled: false, // Disables the sortable if set to true.
89
90
  store: null, // @see Store
@@ -146,6 +147,8 @@ var sortable = new Sortable(el, {
146
147
  evt.from; // previous list
147
148
  evt.oldIndex; // element's old index within old parent
148
149
  evt.newIndex; // element's new index within new parent
150
+ evt.oldDraggableIndex; // element's old index within old parent, only counting draggable elements
151
+ evt.newDraggableIndex; // element's new index within new parent, only counting draggable elements
149
152
  evt.clone // the clone element
150
153
  evt.pullMode; // when item is in another sortable: `"clone"` if cloning, `true` if moving
151
154
  },
@@ -245,6 +248,13 @@ Demo: https://jsbin.com/zosiwah/edit?js,output
245
248
  ---
246
249
 
247
250
 
251
+ #### `delayOnTouchOnly` option
252
+ Whether or not the delay should be applied only if the user is using touch (eg. on a mobile device). No delay will be applied in any other case. Defaults to `false`.
253
+
254
+
255
+ ---
256
+
257
+
248
258
  #### `swapThreshold` option
249
259
  Percentage of the target that the swap zone will take up, as a float between `0` and `1`.
250
260
 
@@ -531,6 +541,8 @@ Demo: https://jsbin.com/becavoj/edit?js,output
531
541
  - clone:`HTMLElement`
532
542
  - oldIndex:`Number|undefined` — old index within parent
533
543
  - newIndex:`Number|undefined` — new index within parent
544
+ - oldDraggableIndex: `Number|undefined` — old index within parent, only counting draggable elements
545
+ - newDraggableIndex: `Number|undefined` — new index within parent, only counting draggable elements
534
546
  - pullMode:`String|Boolean|undefined` — Pull mode if dragging into another sortable (`"clone"`, `true`, or `false`), otherwise undefined
535
547
 
536
548
 
package/Sortable.js CHANGED
@@ -41,6 +41,8 @@
41
41
 
42
42
  oldIndex,
43
43
  newIndex,
44
+ oldDraggableIndex,
45
+ newDraggableIndex,
44
46
 
45
47
  activeGroup,
46
48
  putSortable,
@@ -74,8 +76,6 @@
74
76
  ghostRelativeParent,
75
77
  ghostRelativeParentInitialScroll = [], // (left, top)
76
78
 
77
-
78
- forRepaintDummy,
79
79
  realDragElRect, // dragEl rect after current animation
80
80
 
81
81
  /** @const */
@@ -189,7 +189,7 @@
189
189
  insideHorizontally = x >= (rect.left - threshold) && x <= (rect.right + threshold),
190
190
  insideVertically = y >= (rect.top - threshold) && y <= (rect.bottom + threshold);
191
191
 
192
- if (insideHorizontally && insideVertically) {
192
+ if (threshold && insideHorizontally && insideVertically) {
193
193
  return sortables[i];
194
194
  }
195
195
  }
@@ -435,29 +435,6 @@
435
435
  dragEl.parentNode[expando] && dragEl.parentNode[expando]._computeIsAligned(evt);
436
436
  },
437
437
 
438
- _isTrueParentSortable = function(el, target) {
439
- var trueParent = target;
440
- while (!trueParent[expando]) {
441
- trueParent = trueParent.parentNode;
442
- }
443
-
444
- return el === trueParent;
445
- },
446
-
447
- _artificalBubble = function(sortable, originalEvt, method) {
448
- // Artificial IE bubbling
449
- var nextParent = sortable.parentNode;
450
- while (nextParent && !nextParent[expando]) {
451
- nextParent = nextParent.parentNode;
452
- }
453
-
454
- if (nextParent) {
455
- nextParent[expando][method](_extend(originalEvt, {
456
- artificialBubble: true
457
- }));
458
- }
459
- },
460
-
461
438
  _hideGhostForTarget = function() {
462
439
  if (!supportCssPointerEvents && ghostEl) {
463
440
  _css(ghostEl, 'display', 'none');
@@ -483,24 +460,23 @@
483
460
  }, true);
484
461
 
485
462
  var nearestEmptyInsertDetectEvent = function(evt) {
486
- evt = evt.touches ? evt.touches[0] : evt;
487
463
  if (dragEl) {
464
+ evt = evt.touches ? evt.touches[0] : evt;
488
465
  var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
489
466
 
490
467
  if (nearest) {
491
- nearest[expando]._onDragOver({
492
- clientX: evt.clientX,
493
- clientY: evt.clientY,
494
- target: nearest,
495
- rootEl: nearest
496
- });
468
+ // Create imitation event
469
+ var event = {};
470
+ for (var i in evt) {
471
+ event[i] = evt[i];
472
+ }
473
+ event.target = event.rootEl = nearest;
474
+ event.preventDefault = void 0;
475
+ event.stopPropagation = void 0;
476
+ nearest[expando]._onDragOver(event);
497
477
  }
498
478
  }
499
479
  };
500
- // We do not want this to be triggered if completed (bubbling canceled), so only define it here
501
- _on(document, 'dragover', nearestEmptyInsertDetectEvent);
502
- _on(document, 'mousemove', nearestEmptyInsertDetectEvent);
503
- _on(document, 'touchmove', nearestEmptyInsertDetectEvent);
504
480
 
505
481
  /**
506
482
  * @class Sortable
@@ -553,16 +529,14 @@
553
529
  dragoverBubble: false,
554
530
  dataIdAttr: 'data-id',
555
531
  delay: 0,
532
+ delayOnTouchOnly: false,
556
533
  touchStartThreshold: parseInt(window.devicePixelRatio, 10) || 1,
557
534
  forceFallback: false,
558
535
  fallbackClass: 'sortable-fallback',
559
536
  fallbackOnBody: false,
560
537
  fallbackTolerance: 0,
561
538
  fallbackOffset: {x: 0, y: 0},
562
- supportPointer: Sortable.supportPointer !== false && (
563
- ('PointerEvent' in window) ||
564
- window.navigator && ('msPointerEnabled' in window.navigator) // microsoft
565
- ),
539
+ supportPointer: Sortable.supportPointer !== false && ('PointerEvent' in window),
566
540
  emptyInsertThreshold: 5
567
541
  };
568
542
 
@@ -660,17 +634,11 @@
660
634
  target = (touch || evt).target,
661
635
  originalTarget = evt.target.shadowRoot && ((evt.path && evt.path[0]) || (evt.composedPath && evt.composedPath()[0])) || target,
662
636
  filter = options.filter,
663
- startIndex;
637
+ startIndex,
638
+ startDraggableIndex;
664
639
 
665
640
  _saveInputCheckedState(el);
666
641
 
667
-
668
- // IE: Calls events in capture mode if event element is nested. This ensures only correct element's _onTapStart goes through.
669
- // This process is also done in _onDragOver
670
- if (IE11OrLess && !evt.artificialBubble && !_isTrueParentSortable(el, target)) {
671
- return;
672
- }
673
-
674
642
  // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
675
643
  if (dragEl) {
676
644
  return;
@@ -687,12 +655,6 @@
687
655
 
688
656
  target = _closest(target, options.draggable, el, false);
689
657
 
690
- if (!target) {
691
- if (IE11OrLess) {
692
- _artificalBubble(el, evt, '_onTapStart');
693
- }
694
- return;
695
- }
696
658
 
697
659
  if (lastDownEl === target) {
698
660
  // Ignoring duplicate `down`
@@ -700,12 +662,13 @@
700
662
  }
701
663
 
702
664
  // Get the index of the dragged element within its parent
703
- startIndex = _index(target, options.draggable);
665
+ startIndex = _index(target);
666
+ startDraggableIndex = _index(target, options.draggable);
704
667
 
705
668
  // Check filter
706
669
  if (typeof filter === 'function') {
707
670
  if (filter.call(this, evt, target, this)) {
708
- _dispatchEvent(_this, originalTarget, 'filter', target, el, el, startIndex);
671
+ _dispatchEvent(_this, originalTarget, 'filter', target, el, el, startIndex, undefined, startDraggableIndex);
709
672
  preventOnFilter && evt.cancelable && evt.preventDefault();
710
673
  return; // cancel dnd
711
674
  }
@@ -715,7 +678,7 @@
715
678
  criteria = _closest(originalTarget, criteria.trim(), el, false);
716
679
 
717
680
  if (criteria) {
718
- _dispatchEvent(_this, criteria, 'filter', target, el, el, startIndex);
681
+ _dispatchEvent(_this, criteria, 'filter', target, el, el, startIndex, undefined, startDraggableIndex);
719
682
  return true;
720
683
  }
721
684
  });
@@ -731,7 +694,7 @@
731
694
  }
732
695
 
733
696
  // Prepare `dragstart`
734
- this._prepareDragStart(evt, touch, target, startIndex);
697
+ this._prepareDragStart(evt, touch, target, startIndex, startDraggableIndex);
735
698
  },
736
699
 
737
700
 
@@ -787,7 +750,7 @@
787
750
  }
788
751
  },
789
752
 
790
- _prepareDragStart: function (/** Event */evt, /** Touch */touch, /** HTMLElement */target, /** Number */startIndex) {
753
+ _prepareDragStart: function (/** Event */evt, /** Touch */touch, /** HTMLElement */target, /** Number */startIndex, /** Number */startDraggableIndex) {
791
754
  var _this = this,
792
755
  el = _this.el,
793
756
  options = _this.options,
@@ -802,6 +765,7 @@
802
765
  lastDownEl = target;
803
766
  activeGroup = options.group;
804
767
  oldIndex = startIndex;
768
+ oldDraggableIndex = startDraggableIndex;
805
769
 
806
770
  tapEvt = {
807
771
  target: dragEl,
@@ -830,7 +794,7 @@
830
794
  _this._triggerDragStart(evt, touch);
831
795
 
832
796
  // Drag start event
833
- _dispatchEvent(_this, rootEl, 'choose', dragEl, rootEl, rootEl, oldIndex);
797
+ _dispatchEvent(_this, rootEl, 'choose', dragEl, rootEl, rootEl, oldIndex, undefined, oldDraggableIndex);
834
798
 
835
799
  // Chosen item
836
800
  _toggleClass(dragEl, options.chosenClass, true);
@@ -841,13 +805,13 @@
841
805
  _find(dragEl, criteria.trim(), _disableDraggable);
842
806
  });
843
807
 
844
- if (options.supportPointer) {
845
- _on(ownerDocument, 'pointerup', _this._onDrop);
846
- } else {
847
- _on(ownerDocument, 'mouseup', _this._onDrop);
848
- _on(ownerDocument, 'touchend', _this._onDrop);
849
- _on(ownerDocument, 'touchcancel', _this._onDrop);
850
- }
808
+ _on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
809
+ _on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
810
+ _on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
811
+
812
+ _on(ownerDocument, 'mouseup', _this._onDrop);
813
+ _on(ownerDocument, 'touchend', _this._onDrop);
814
+ _on(ownerDocument, 'touchcancel', _this._onDrop);
851
815
 
852
816
  // Make dragEl draggable (must be before delay for FireFox)
853
817
  if (FireFox && this.nativeDraggable) {
@@ -856,7 +820,7 @@
856
820
  }
857
821
 
858
822
  // Delay is impossible for native DnD in Edge or IE
859
- if (options.delay && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
823
+ if (options.delay && (options.delayOnTouchOnly ? touch : true) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
860
824
  // If the user moves the pointer or let go the click or touch
861
825
  // before the delay has been reached:
862
826
  // disable the delayed drag
@@ -950,7 +914,7 @@
950
914
  fallback && this._appendGhost();
951
915
 
952
916
  // Drag start event
953
- _dispatchEvent(this, rootEl, 'start', dragEl, rootEl, rootEl, oldIndex, undefined, evt);
917
+ _dispatchEvent(this, rootEl, 'start', dragEl, rootEl, rootEl, oldIndex, undefined, oldDraggableIndex, undefined, evt);
954
918
  } else {
955
919
  this._nulling();
956
920
  }
@@ -971,6 +935,7 @@
971
935
 
972
936
  while (target && target.shadowRoot) {
973
937
  target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
938
+ if (target === parent) break;
974
939
  parent = target;
975
940
  }
976
941
 
@@ -1181,11 +1146,6 @@
1181
1146
 
1182
1147
  if (_silent) return;
1183
1148
 
1184
- // IE event order fix
1185
- if (IE11OrLess && !evt.rootEl && !evt.artificialBubble && !_isTrueParentSortable(el, target)) {
1186
- return;
1187
- }
1188
-
1189
1149
  // Return invocation when dragEl is inserted (or completed)
1190
1150
  function completed(insertion) {
1191
1151
  if (insertion) {
@@ -1217,10 +1177,14 @@
1217
1177
  if ((target === dragEl && !dragEl.animated) || (target === el && !target.animated)) {
1218
1178
  lastTarget = null;
1219
1179
  }
1180
+
1220
1181
  // no bubbling and not fallback
1221
1182
  if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1222
1183
  _this._handleAutoScroll(evt);
1223
1184
  dragEl.parentNode[expando]._computeIsAligned(evt);
1185
+
1186
+ // Do not detect for empty insert if already inserted
1187
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1224
1188
  }
1225
1189
 
1226
1190
  !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
@@ -1230,7 +1194,7 @@
1230
1194
 
1231
1195
  // Call when dragEl has been inserted
1232
1196
  function changed() {
1233
- _dispatchEvent(_this, rootEl, 'change', target, el, rootEl, oldIndex, _index(dragEl, options.draggable), evt);
1197
+ _dispatchEvent(_this, rootEl, 'change', target, el, rootEl, oldIndex, _index(dragEl), oldDraggableIndex, _index(dragEl, options.draggable), evt);
1234
1198
  }
1235
1199
 
1236
1200
 
@@ -1244,7 +1208,7 @@
1244
1208
  target = _closest(target, options.draggable, el, true);
1245
1209
 
1246
1210
  // target is dragEl or target is animated
1247
- if (!!_closest(evt.target, null, dragEl, true) || target.animated) {
1211
+ if (dragEl.contains(evt.target) || target.animated) {
1248
1212
  return completed(false);
1249
1213
  }
1250
1214
 
@@ -1408,10 +1372,6 @@
1408
1372
  }
1409
1373
  }
1410
1374
 
1411
- if (IE11OrLess && !evt.rootEl) {
1412
- _artificalBubble(el, evt, '_onDragOver');
1413
- }
1414
-
1415
1375
  return false;
1416
1376
  },
1417
1377
 
@@ -1443,7 +1403,7 @@
1443
1403
  + (prevRect.top - currentRect.top) / (scaleY ? scaleY : 1) + 'px,0)'
1444
1404
  );
1445
1405
 
1446
- forRepaintDummy = target.offsetWidth; // repaint
1406
+ this._repaint(target);
1447
1407
  _css(target, 'transition', 'transform ' + ms + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
1448
1408
  _css(target, 'transform', 'translate3d(0,0,0)');
1449
1409
  }
@@ -1457,11 +1417,21 @@
1457
1417
  }
1458
1418
  },
1459
1419
 
1460
- _offUpEvents: function () {
1461
- var ownerDocument = this.el.ownerDocument;
1420
+ _repaint: function(target) {
1421
+ return target.offsetWidth;
1422
+ },
1462
1423
 
1424
+ _offMoveEvents: function() {
1463
1425
  _off(document, 'touchmove', this._onTouchMove);
1464
1426
  _off(document, 'pointermove', this._onTouchMove);
1427
+ _off(document, 'dragover', nearestEmptyInsertDetectEvent);
1428
+ _off(document, 'mousemove', nearestEmptyInsertDetectEvent);
1429
+ _off(document, 'touchmove', nearestEmptyInsertDetectEvent);
1430
+ },
1431
+
1432
+ _offUpEvents: function () {
1433
+ var ownerDocument = this.el.ownerDocument;
1434
+
1465
1435
  _off(ownerDocument, 'mouseup', this._onDrop);
1466
1436
  _off(ownerDocument, 'touchend', this._onDrop);
1467
1437
  _off(ownerDocument, 'pointerup', this._onDrop);
@@ -1503,6 +1473,7 @@
1503
1473
  _css(document.body, 'user-select', '');
1504
1474
  }
1505
1475
 
1476
+ this._offMoveEvents();
1506
1477
  this._offUpEvents();
1507
1478
 
1508
1479
  if (evt) {
@@ -1531,21 +1502,22 @@
1531
1502
  _toggleClass(dragEl, this.options.chosenClass, false);
1532
1503
 
1533
1504
  // Drag stop event
1534
- _dispatchEvent(this, rootEl, 'unchoose', dragEl, parentEl, rootEl, oldIndex, null, evt);
1505
+ _dispatchEvent(this, rootEl, 'unchoose', dragEl, parentEl, rootEl, oldIndex, null, oldDraggableIndex, null, evt);
1535
1506
 
1536
1507
  if (rootEl !== parentEl) {
1537
- newIndex = _index(dragEl, options.draggable);
1508
+ newIndex = _index(dragEl);
1509
+ newDraggableIndex = _index(dragEl, options.draggable);
1538
1510
 
1539
1511
  if (newIndex >= 0) {
1540
1512
  // Add event
1541
- _dispatchEvent(null, parentEl, 'add', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
1513
+ _dispatchEvent(null, parentEl, 'add', dragEl, parentEl, rootEl, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, evt);
1542
1514
 
1543
1515
  // Remove event
1544
- _dispatchEvent(this, rootEl, 'remove', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
1516
+ _dispatchEvent(this, rootEl, 'remove', dragEl, parentEl, rootEl, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, evt);
1545
1517
 
1546
1518
  // drag from one list and drop into another
1547
- _dispatchEvent(null, parentEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
1548
- _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
1519
+ _dispatchEvent(null, parentEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, evt);
1520
+ _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, evt);
1549
1521
  }
1550
1522
 
1551
1523
  putSortable && putSortable.save();
@@ -1553,12 +1525,13 @@
1553
1525
  else {
1554
1526
  if (dragEl.nextSibling !== nextEl) {
1555
1527
  // Get the index of the dragged element within its parent
1556
- newIndex = _index(dragEl, options.draggable);
1528
+ newIndex = _index(dragEl);
1529
+ newDraggableIndex = _index(dragEl, options.draggable);
1557
1530
 
1558
1531
  if (newIndex >= 0) {
1559
1532
  // drag & drop within the same list
1560
- _dispatchEvent(this, rootEl, 'update', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
1561
- _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
1533
+ _dispatchEvent(this, rootEl, 'update', dragEl, parentEl, rootEl, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, evt);
1534
+ _dispatchEvent(this, rootEl, 'sort', dragEl, parentEl, rootEl, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, evt);
1562
1535
  }
1563
1536
  }
1564
1537
  }
@@ -1567,8 +1540,9 @@
1567
1540
  /* jshint eqnull:true */
1568
1541
  if (newIndex == null || newIndex === -1) {
1569
1542
  newIndex = oldIndex;
1543
+ newDraggableIndex = oldDraggableIndex;
1570
1544
  }
1571
- _dispatchEvent(this, rootEl, 'end', dragEl, parentEl, rootEl, oldIndex, newIndex, evt);
1545
+ _dispatchEvent(this, rootEl, 'end', dragEl, parentEl, rootEl, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, evt);
1572
1546
 
1573
1547
  // Save sorting
1574
1548
  this.save();
@@ -1606,7 +1580,6 @@
1606
1580
  lastTarget =
1607
1581
  lastDirection =
1608
1582
 
1609
- forRepaintDummy =
1610
1583
  realDragElRect =
1611
1584
 
1612
1585
  putSortable =
@@ -1801,7 +1774,8 @@
1801
1774
  if (
1802
1775
  selector != null &&
1803
1776
  (
1804
- selector[0] === '>' && el.parentNode === ctx && _matches(el, selector.substring(1)) ||
1777
+ selector[0] === '>' ?
1778
+ el.parentNode === ctx && _matches(el, selector) :
1805
1779
  _matches(el, selector)
1806
1780
  ) ||
1807
1781
  includeCTX && el === ctx
@@ -1834,12 +1808,12 @@
1834
1808
 
1835
1809
 
1836
1810
  function _on(el, event, fn) {
1837
- el.addEventListener(event, fn, captureMode);
1811
+ el.addEventListener(event, fn, IE11OrLess ? false : captureMode);
1838
1812
  }
1839
1813
 
1840
1814
 
1841
1815
  function _off(el, event, fn) {
1842
- el.removeEventListener(event, fn, captureMode);
1816
+ el.removeEventListener(event, fn, IE11OrLess ? false : captureMode);
1843
1817
  }
1844
1818
 
1845
1819
 
@@ -1919,7 +1893,13 @@
1919
1893
 
1920
1894
 
1921
1895
 
1922
- function _dispatchEvent(sortable, rootEl, name, targetEl, toEl, fromEl, startIndex, newIndex, originalEvt) {
1896
+ function _dispatchEvent(
1897
+ sortable, rootEl, name,
1898
+ targetEl, toEl, fromEl,
1899
+ startIndex, newIndex,
1900
+ startDraggableIndex, newDraggableIndex,
1901
+ originalEvt
1902
+ ) {
1923
1903
  sortable = (sortable || rootEl[expando]);
1924
1904
  var evt,
1925
1905
  options = sortable.options,
@@ -1943,6 +1923,9 @@
1943
1923
  evt.oldIndex = startIndex;
1944
1924
  evt.newIndex = newIndex;
1945
1925
 
1926
+ evt.oldDraggableIndex = startDraggableIndex;
1927
+ evt.newDraggableIndex = newDraggableIndex;
1928
+
1946
1929
  evt.originalEvent = originalEvt;
1947
1930
  evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
1948
1931
 
@@ -2038,7 +2021,7 @@
2038
2021
  function _lastChild(el) {
2039
2022
  var last = el.lastElementChild;
2040
2023
 
2041
- while (last && (last === ghostEl || last.style.display === 'none')) {
2024
+ while (last && (last === ghostEl || _css(last, 'display') === 'none')) {
2042
2025
  last = last.previousElementSibling;
2043
2026
  }
2044
2027
 
@@ -2187,7 +2170,7 @@
2187
2170
  }
2188
2171
 
2189
2172
  while (el && (el = el.previousElementSibling)) {
2190
- if ((el.nodeName.toUpperCase() !== 'TEMPLATE') && el !== cloneEl) {
2173
+ if ((el.nodeName.toUpperCase() !== 'TEMPLATE') && el !== cloneEl && (!selector || _matches(el, selector))) {
2191
2174
  index++;
2192
2175
  }
2193
2176
  }
@@ -2196,6 +2179,10 @@
2196
2179
  }
2197
2180
 
2198
2181
  function _matches(/**HTMLElement*/el, /**String*/selector) {
2182
+ if (!selector) return;
2183
+
2184
+ selector[0] === '>' && (selector = selector.substring(1));
2185
+
2199
2186
  if (el) {
2200
2187
  try {
2201
2188
  if (el.matches) {
@@ -2468,6 +2455,6 @@
2468
2455
 
2469
2456
 
2470
2457
  // Export
2471
- Sortable.version = '1.8.4';
2458
+ Sortable.version = '1.9.0';
2472
2459
  return Sortable;
2473
2460
  });
package/Sortable.min.js CHANGED
@@ -1,3 +1,3 @@
1
- /*! Sortable 1.8.4 - MIT | git://github.com/SortableJS/Sortable.git */
1
+ /*! Sortable 1.9.0 - MIT | git://github.com/SortableJS/Sortable.git */
2
2
 
3
- !function(t){"use strict";"function"==typeof define&&define.amd?define(t):"undefined"!=typeof module&&void 0!==module.exports?module.exports=t():window.Sortable=t()}(function(){"use strict";if("undefined"==typeof window||!window.document)return function(){throw new Error("Sortable.js requires a window with a document")};var U,V,f,u,q,G,h,X,Y,A,K,n,Z,Q,l,s,c,p,k,J,$,tt,et,ot,g,nt,I=[],B=!1,v=!1,it=!1,d=[],rt=!1,at=!1,m=[],i=/\s+/g,lt="Sortable"+(new Date).getTime(),b=window,st=b.document,w=b.parseInt,ct=b.setTimeout,e=b.jQuery||b.Zepto,o=b.Polymer,r={capture:!1,passive:!1},dt=!!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie|iemobile)/i),_=!!navigator.userAgent.match(/Edge/i),y=!!navigator.userAgent.match(/firefox/i),D=!(!navigator.userAgent.match(/safari/i)||navigator.userAgent.match(/chrome/i)||navigator.userAgent.match(/android/i)),S=!!navigator.userAgent.match(/iP(ad|od|hone)/i),T=_||dt?"cssFloat":"float",a="draggable"in st.createElement("div"),C=function(){if(dt)return!1;var t=st.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}(),ht=!1,E=!1,ut=Math.abs,x=Math.min,N=Math.max,M=[],P=function(t,e){var o=Dt(t),n=w(o.width)-w(o.paddingLeft)-w(o.paddingRight)-w(o.borderLeftWidth)-w(o.borderRightWidth),i=Mt(t,0,e),r=Mt(t,1,e),a=i&&Dt(i),l=r&&Dt(r),s=a&&w(a.marginLeft)+w(a.marginRight)+Lt(i).width,c=l&&w(l.marginLeft)+w(l.marginRight)+Lt(r).width;if("flex"===o.display)return"column"===o.flexDirection||"column-reverse"===o.flexDirection?"vertical":"horizontal";if("grid"===o.display)return o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&"none"!==a.float){var d="left"===a.float?"left":"right";return!r||"both"!==l.clear&&l.clear!==d?"horizontal":"vertical"}return i&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||n<=s&&"none"===o[T]||r&&"none"===o[T]&&n<s+c)?"vertical":"horizontal"},O=function(t,e){if(!t||!t.getBoundingClientRect)return H();var o=t,n=!1;do{if(o.clientWidth<o.scrollWidth||o.clientHeight<o.scrollHeight){var i=Dt(o);if(o.clientWidth<o.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||o.clientHeight<o.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!o||!o.getBoundingClientRect||o===st.body)return H();if(n||e)return o;n=!0}}}while(o=o.parentNode);return H()},H=function(){return dt?st.documentElement:st.scrollingElement},ft=function(t,e,o){t.scrollLeft+=e,t.scrollTop+=o},R=It(function(o,t,e,n){if(t.scroll){var i=e?e[lt]:window,r=t.scrollSensitivity,a=t.scrollSpeed,l=o.clientX,s=o.clientY,c=H(),d=!1;Y!==e&&(L(),X=t.scroll,A=t.scrollFn,!0===X&&(X=O(e,!0),Y=X));var h=0,u=X;do{var f,p,g,v,m,b,w,_,y,D=u,S=Lt(D),T=S.top,C=S.bottom,E=S.left,x=S.right,N=S.width,M=S.height;if(f=D.scrollWidth,p=D.scrollHeight,g=Dt(D),_=D.scrollLeft,y=D.scrollTop,w=D===c?(b=N<f&&("auto"===g.overflowX||"scroll"===g.overflowX||"visible"===g.overflowX),M<p&&("auto"===g.overflowY||"scroll"===g.overflowY||"visible"===g.overflowY)):(b=N<f&&("auto"===g.overflowX||"scroll"===g.overflowX),M<p&&("auto"===g.overflowY||"scroll"===g.overflowY)),v=b&&(ut(x-l)<=r&&_+N<f)-(ut(E-l)<=r&&!!_),m=w&&(ut(C-s)<=r&&y+M<p)-(ut(T-s)<=r&&!!y),!I[h])for(var P=0;P<=h;P++)I[P]||(I[P]={});I[h].vx==v&&I[h].vy==m&&I[h].el===D||(I[h].el=D,I[h].vx=v,I[h].vy=m,clearInterval(I[h].pid),!D||0==v&&0==m||(d=!0,I[h].pid=setInterval(function(){n&&0===this.layer&&(mt.active._emulateDragOver(!0),mt.active._onTouchMove(k,!0));var t=I[this.layer].vy?I[this.layer].vy*a:0,e=I[this.layer].vx?I[this.layer].vx*a:0;"function"==typeof A&&"continue"!==A.call(i,e,t,o,k,I[this.layer].el)||ft(I[this.layer].el,e,t)}.bind({layer:h}),24))),h++}while(t.bubbleScroll&&u!==c&&(u=O(u,!1)));B=d}},30),L=function(){I.forEach(function(t){clearInterval(t.pid)}),I=[]},W=function(t){function s(a,l){return function(t,e,o,n){var i=t.options.group.name&&e.options.group.name&&t.options.group.name===e.options.group.name;if(null==a&&(l||i))return!0;if(null==a||!1===a)return!1;if(l&&"clone"===a)return a;if("function"==typeof a)return s(a(t,e,o,n),l)(t,e,o,n);var r=(l?t:e).options.group.name;return!0===a||"string"==typeof a&&a===r||a.join&&-1<a.indexOf(r)}}var e={},o=t.group;o&&"object"==typeof o||(o={name:o}),e.name=o.name,e.checkPull=s(o.pull,!0),e.checkPut=s(o.put),e.revertClone=o.revertClone,t.group=e},F=function(t){U&&U.parentNode&&U.parentNode[lt]&&U.parentNode[lt]._computeIsAligned(t)},pt=function(t,e){for(var o=e;!o[lt];)o=o.parentNode;return t===o},gt=function(t,e,o){for(var n=t.parentNode;n&&!n[lt];)n=n.parentNode;n&&n[lt][o](Bt(e,{artificialBubble:!0}))},z=function(){!C&&f&&Dt(f,"display","none")},j=function(){!C&&f&&Dt(f,"display","")};st.addEventListener("click",function(t){if(it)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),it=!1},!0);var vt,t=function(t){if(t=t.touches?t.touches[0]:t,U){var e=function(t,e){for(var o=0;o<d.length;o++)if(!Pt(d[o])){var n=Lt(d[o]),i=d[o][lt].options.emptyInsertThreshold,r=t>=n.left-i&&t<=n.right+i,a=e>=n.top-i&&e<=n.bottom+i;if(r&&a)return d[o]}}(t.clientX,t.clientY);e&&e[lt]._onDragOver({clientX:t.clientX,clientY:t.clientY,target:e,rootEl:e})}};function mt(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be HTMLElement, not "+{}.toString.call(t);this.el=t,this.options=e=Bt({},e),t[lt]=this;var o={group:null,sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0,draggable:/[uo]l/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return P(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,touchStartThreshold:w(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==mt.supportPointer&&("PointerEvent"in window||window.navigator&&"msPointerEnabled"in window.navigator),emptyInsertThreshold:5};for(var n in o)!(n in e)&&(e[n]=o[n]);for(var i in W(e),this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&a,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?wt(t,"pointerdown",this._onTapStart):(wt(t,"mousedown",this._onTapStart),wt(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(wt(t,"dragover",this),wt(t,"dragenter",this)),d.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[])}function bt(t,e,o,n){if(t){o=o||st;do{if(null!=e&&(">"===e[0]&&t.parentNode===o&&kt(t,e.substring(1))||kt(t,e))||n&&t===o)return t;if(t===o)break}while(t=(i=t).host&&i!==st&&i.host.nodeType?i.host:i.parentNode)}var i;return null}function wt(t,e,o){t.addEventListener(e,o,r)}function _t(t,e,o){t.removeEventListener(e,o,r)}function yt(t,e,o){if(t&&e)if(t.classList)t.classList[o?"add":"remove"](e);else{var n=(" "+t.className+" ").replace(i," ").replace(" "+e+" "," ");t.className=(n+(o?" "+e:"")).replace(i," ")}}function Dt(t,e,o){var n=t&&t.style;if(n){if(void 0===o)return st.defaultView&&st.defaultView.getComputedStyle?o=st.defaultView.getComputedStyle(t,""):t.currentStyle&&(o=t.currentStyle),void 0===e?o:o[e];e in n||-1!==e.indexOf("webkit")||(e="-webkit-"+e),n[e]=o+("string"==typeof o?"":"px")}}function St(t){var e="";do{var o=Dt(t,"transform");o&&"none"!==o&&(e=o+" "+e)}while(t=t.parentNode);return window.DOMMatrix?new DOMMatrix(e):window.WebKitCSSMatrix?new WebKitCSSMatrix(e):window.CSSMatrix?new CSSMatrix(e):void 0}function Tt(t,e,o){if(t){var n=t.getElementsByTagName(e),i=0,r=n.length;if(o)for(;i<r;i++)o(n[i],i);return n}return[]}function Ct(t,e,o,n,i,r,a,l,s){var c,d=(t=t||e[lt]).options,h="on"+o.charAt(0).toUpperCase()+o.substr(1);!window.CustomEvent||dt||_?(c=st.createEvent("Event")).initEvent(o,!0,!0):c=new CustomEvent(o,{bubbles:!0,cancelable:!0}),c.to=i||e,c.from=r||e,c.item=n||e,c.clone=u,c.oldIndex=a,c.newIndex=l,c.originalEvent=s,c.pullMode=Q?Q.lastPutMode:void 0,e&&e.dispatchEvent(c),d[h]&&d[h].call(t,c)}function Et(t,e,o,n,i,r,a,l){var s,c,d=t[lt],h=d.options.onMove;return!window.CustomEvent||dt||_?(s=st.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=o,s.draggedRect=n,s.related=i||e,s.relatedRect=r||Lt(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),h&&(c=h.call(d,s,a)),c}function xt(t){t.draggable=!1}function Nt(){ht=!1}function Mt(t,e,o){for(var n=0,i=0,r=t.children;i<r.length;){if("none"!==r[i].style.display&&r[i]!==f&&r[i]!==U&&bt(r[i],o.draggable,t,!1)){if(n===e)return r[i];n++}i++}return null}function Pt(t){for(var e=t.lastElementChild;e&&(e===f||"none"===e.style.display);)e=e.previousElementSibling;return e||null}function Xt(t){return At(U)<At(t)?1:-1}function Yt(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,o=e.length,n=0;o--;)n+=e.charCodeAt(o);return n.toString(36)}function At(t,e){var o=0;if(!t||!t.parentNode)return-1;for(;t&&(t=t.previousElementSibling);)"TEMPLATE"!==t.nodeName.toUpperCase()&&t!==u&&o++;return o}function kt(t,e){if(t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}function It(o,n){return function(){if(!vt){var t=arguments,e=this;vt=ct(function(){1===t.length?o.call(e,t[0]):o.apply(e,t),vt=void 0},n)}}}function Bt(t,e){if(t&&e)for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);return t}function Ot(t){return o&&o.dom?o.dom(t).cloneNode(!0):e?e(t).clone(!0)[0]:t.cloneNode(!0)}function Ht(t){return ct(t,0)}function Rt(t){return clearTimeout(t)}function Lt(t,e,o,n){if(t.getBoundingClientRect||t===b){var i,r,a,l,s,c,d;if(d=t!==b&&t!==H()?(r=(i=t.getBoundingClientRect()).top,a=i.left,l=i.bottom,s=i.right,c=i.height,i.width):(a=r=0,l=window.innerHeight,s=window.innerWidth,c=window.innerHeight,window.innerWidth),n&&t!==b&&(o=o||t.parentNode,!dt))do{if(o&&o.getBoundingClientRect&&"none"!==Dt(o,"transform")){var h=o.getBoundingClientRect();r-=h.top+w(Dt(o,"border-top-width")),a-=h.left+w(Dt(o,"border-left-width")),l=r+i.height,s=a+i.width;break}}while(o=o.parentNode);if(e&&t!==b){var u=St(o||t),f=u&&u.a,p=u&&u.d;u&&(l=(r/=p)+(c/=p),s=(a/=f)+(d/=f))}return{top:r,left:a,bottom:l,right:s,width:d,height:c}}}function Wt(t,e){for(var o=O(t,!0),n=Lt(t)[e];o;){var i=Lt(o)[e];if(!("top"===e||"left"===e?i<=n:n<=i))return o;if(o===H())break;o=O(o,!1)}return!1}function Ft(t){var e=0,o=0,n=H();if(t)do{var i=St(t),r=i.a,a=i.d;e+=t.scrollLeft*r,o+=t.scrollTop*a}while(t!==n&&(t=t.parentNode));return[e,o]}return wt(st,"dragover",t),wt(st,"mousemove",t),wt(st,"touchmove",t),mt.prototype={constructor:mt,_computeIsAligned:function(t){var e;if(f&&!C?(z(),e=st.elementFromPoint(t.clientX,t.clientY),j()):e=t.target,e=bt(e,this.options.draggable,this.el,!1),!E&&U&&U.parentNode===this.el){for(var o,n,i,r,a,l,s,c,d=this.el.children,h=0;h<d.length;h++)bt(d[h],this.options.draggable,this.el,!1)&&d[h]!==e&&(d[h].sortableMouseAligned=(o=t.clientX,n=t.clientY,i=d[h],r=this._getDirection(t,null),this.options,void 0,a=Lt(i),l="vertical"===r?a.left:a.top,s="vertical"===r?a.right:a.bottom,l<(c="vertical"===r?o:n)&&c<s));bt(e,this.options.draggable,this.el,!0)||($=null),E=!0,ct(function(){E=!1},30)}},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,U):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e,o=this,n=this.el,i=this.options,r=i.preventOnFilter,a=t.type,l=t.touches&&t.touches[0],s=(l||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,d=i.filter;if(function(t){M.length=0;var e=t.getElementsByTagName("input"),o=e.length;for(;o--;){var n=e[o];n.checked&&M.push(n)}}(n),(!dt||t.artificialBubble||pt(n,s))&&!U&&!(/mousedown|pointerdown/.test(a)&&0!==t.button||i.disabled||c.isContentEditable))if(s=bt(s,i.draggable,n,!1)){if(h!==s){if(e=At(s,i.draggable),"function"==typeof d){if(d.call(this,t,s,this))return Ct(o,c,"filter",s,n,n,e),void(r&&t.cancelable&&t.preventDefault())}else if(d&&(d=d.split(",").some(function(t){if(t=bt(c,t.trim(),n,!1))return Ct(o,t,"filter",s,n,n,e),!0})))return void(r&&t.cancelable&&t.preventDefault());i.handle&&!bt(c,i.handle,n,!1)||this._prepareDragStart(t,l,s,e)}}else dt&&gt(n,t,"_onTapStart")}},_handleAutoScroll:function(e,o){if(U&&this.options.scroll){var n=e.clientX,i=e.clientY,t=st.elementFromPoint(n,i),r=this;if(o||_||dt||D){R(e,r.options,t,o);var a=O(t,!0);!B||l&&n===s&&i===c||(l&&clearInterval(l),l=setInterval(function(){if(U){var t=O(st.elementFromPoint(n,i),!0);t!==a&&(a=t,L(),R(e,r.options,a,o))}},10),s=n,c=i)}else{if(!r.options.bubbleScroll||O(t,!0)===H())return void L();R(e,r.options,O(t,!1),!1)}}},_prepareDragStart:function(t,e,o,n){var i,r=this,a=r.el,l=r.options,s=a.ownerDocument;o&&!U&&o.parentNode===a&&(q=a,V=(U=o).parentNode,G=U.nextSibling,h=o,Z=l.group,K=n,p={target:U,clientX:(e||t).clientX,clientY:(e||t).clientY},this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,U.style["will-change"]="all",U.style.transition="",U.style.transform="",i=function(){r._disableDelayedDragEvents(),!y&&r.nativeDraggable&&(U.draggable=!0),r._triggerDragStart(t,e),Ct(r,q,"choose",U,q,q,K),yt(U,l.chosenClass,!0)},l.ignore.split(",").forEach(function(t){Tt(U,t.trim(),xt)}),l.supportPointer?wt(s,"pointerup",r._onDrop):(wt(s,"mouseup",r._onDrop),wt(s,"touchend",r._onDrop),wt(s,"touchcancel",r._onDrop)),y&&this.nativeDraggable&&(this.options.touchStartThreshold=4,U.draggable=!0),!l.delay||this.nativeDraggable&&(_||dt)?i():(wt(s,"mouseup",r._disableDelayedDrag),wt(s,"touchend",r._disableDelayedDrag),wt(s,"touchcancel",r._disableDelayedDrag),wt(s,"mousemove",r._delayedDragTouchMoveHandler),wt(s,"touchmove",r._delayedDragTouchMoveHandler),l.supportPointer&&wt(s,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=ct(i,l.delay)))},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;N(ut(e.clientX-this._lastX),ut(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){U&&xt(U),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;_t(t,"mouseup",this._disableDelayedDrag),_t(t,"touchend",this._disableDelayedDrag),_t(t,"touchcancel",this._disableDelayedDrag),_t(t,"mousemove",this._delayedDragTouchMoveHandler),_t(t,"touchmove",this._delayedDragTouchMoveHandler),_t(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||("touch"==t.pointerType?t:null),!this.nativeDraggable||e?this.options.supportPointer?wt(st,"pointermove",this._onTouchMove):wt(st,e?"touchmove":"mousemove",this._onTouchMove):(wt(U,"dragend",this),wt(q,"dragstart",this._onDragStart));try{st.selection?Ht(function(){st.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(v=!1,q&&U){this.nativeDraggable&&(wt(st,"dragover",this._handleAutoScroll),wt(st,"dragover",F));var o=this.options;!t&&yt(U,o.dragClass,!1),yt(U,o.ghostClass,!0),Dt(U,"transform",""),mt.active=this,t&&this._appendGhost(),Ct(this,q,"start",U,q,q,K,void 0,e)}else this._nulling()},_emulateDragOver:function(t){if(k){if(this._lastX===k.clientX&&this._lastY===k.clientY&&!t)return;this._lastX=k.clientX,this._lastY=k.clientY,z();for(var e=st.elementFromPoint(k.clientX,k.clientY),o=e;e&&e.shadowRoot;)o=e=e.shadowRoot.elementFromPoint(k.clientX,k.clientY);if(o)do{if(o[lt])if(o[lt]._onDragOver({clientX:k.clientX,clientY:k.clientY,target:e,rootEl:o})&&!this.options.dragoverBubble)break;e=o}while(o=o.parentNode);U.parentNode[lt]._computeIsAligned(k),j()}},_onTouchMove:function(t,e){if(p){var o=this.options,n=o.fallbackTolerance,i=o.fallbackOffset,r=t.touches?t.touches[0]:t,a=f&&St(f),l=f&&a&&a.a,s=f&&a&&a.d,c=S&&g&&Ft(g),d=(r.clientX-p.clientX+i.x)/(l||1)+(c?c[0]-m[0]:0)/(l||1),h=(r.clientY-p.clientY+i.y)/(s||1)+(c?c[1]-m[1]:0)/(s||1),u=t.touches?"translate3d("+d+"px,"+h+"px,0)":"translate("+d+"px,"+h+"px)";if(!mt.active&&!v){if(n&&x(ut(r.clientX-this._lastX),ut(r.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}!e&&this._handleAutoScroll(r,!0),J=!0,k=r,Dt(f,"webkitTransform",u),Dt(f,"mozTransform",u),Dt(f,"msTransform",u),Dt(f,"transform",u),t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!f){var t=this.options.fallbackOnBody?st.body:q,e=Lt(U,!0,t,!S),o=(Dt(U),this.options);if(S){for(g=t;"static"===Dt(g,"position")&&"none"===Dt(g,"transform")&&g!==st;)g=g.parentNode;if(g!==st){var n=Lt(g,!0);e.top-=n.top,e.left-=n.left}g!==st.body&&g!==st.documentElement?(g===st&&(g=H()),e.top+=g.scrollTop,e.left+=g.scrollLeft):g=H(),m=Ft(g)}yt(f=U.cloneNode(!0),o.ghostClass,!1),yt(f,o.fallbackClass,!0),yt(f,o.dragClass,!0),Dt(f,"box-sizing","border-box"),Dt(f,"margin",0),Dt(f,"top",e.top),Dt(f,"left",e.left),Dt(f,"width",e.width),Dt(f,"height",e.height),Dt(f,"opacity","0.8"),Dt(f,"position",S?"absolute":"fixed"),Dt(f,"zIndex","100000"),Dt(f,"pointerEvents","none"),t.appendChild(f)}},_onDragStart:function(t,e){var o=this,n=t.dataTransfer,i=o.options;(u=Ot(U)).draggable=!1,u.style["will-change"]="",this._hideClone(),yt(u,o.options.chosenClass,!1),o._cloneId=Ht(function(){o.options.removeCloneOnHide||q.insertBefore(u,U),Ct(o,q,"clone",U)}),!e&&yt(U,i.dragClass,!0),e?(it=!0,o._loopId=setInterval(o._emulateDragOver,50)):(_t(st,"mouseup",o._onDrop),_t(st,"touchend",o._onDrop),_t(st,"touchcancel",o._onDrop),n&&(n.effectAllowed="move",i.setData&&i.setData.call(o,n,U)),wt(st,"drop",o),Dt(U,"transform","translateZ(0)")),v=!0,o._dragStartId=Ht(o._dragStarted.bind(o,e,t)),wt(st,"selectstart",o),D&&Dt(st.body,"user-select","none")},_onDragOver:function(e){var o,n,t,i=this.el,r=e.target,a=this.options,l=a.group,s=mt.active,c=Z===l,d=a.sort,h=this;if(!ht&&(!dt||e.rootEl||e.artificialBubble||pt(i,r))){if(void 0!==e.preventDefault&&e.cancelable&&e.preventDefault(),J=!0,r=bt(r,a.draggable,i,!0),bt(e.target,null,U,!0)||r.animated)return z(!1);if(r!==U&&(it=!1),s&&!a.disabled&&(c?d||(t=!q.contains(U)):Q===this||(this.lastPutMode=Z.checkPull(this,s,U,e))&&l.checkPut(this,s,U,e))){var u=this._getDirection(e,r);if(o=Lt(U),t)return this._hideClone(),V=q,G?q.insertBefore(U,G):q.appendChild(U),z(!0);var f=Pt(i);if(f&&(I=e,B=u,O=Lt(Pt(i)),H="vertical"===B?I.clientY:I.clientX,R="vertical"===B?I.clientX:I.clientY,L="vertical"===B?O.bottom:O.right,W="vertical"===B?O.left:O.top,F="vertical"===B?O.right:O.bottom,!("vertical"===B?F+10<R||R<=F&&L<H&&W<=R:L<H&&W<R||H<=L&&F+10<R)||f.animated)){if(r&&r!==U&&r.parentNode===i){var p,g=0,v=r.sortableMouseAligned,m=U.parentNode!==i,b="vertical"===u?"top":"left",w=Wt(r,"top")||Wt(U,"top"),_=w?w.scrollTop:void 0;if($!==r&&(et=null,p=Lt(r)[b],rt=!1),C=r,E=u,x=(T=U)===U&&nt||Lt(T),N=C===U&&nt||Lt(C),M="vertical"===E?x.left:x.top,P="vertical"===E?x.right:x.bottom,X="vertical"===E?x.width:x.height,Y="vertical"===E?N.left:N.top,A="vertical"===E?N.right:N.bottom,k="vertical"===E?N.width:N.height,et=(M===Y||P===A||M+X/2===Y+k/2)&&v||m||w||a.invertSwap||"insert"===et||"swap"===et?("swap"!==et&&(at=a.invertSwap||m),g=function(t,e,o,n,i,r,a){var l=Lt(e),s="vertical"===o?t.clientY:t.clientX,c="vertical"===o?l.height:l.width,d="vertical"===o?l.top:l.left,h="vertical"===o?l.bottom:l.right,u=Lt(U),f=!1;if(!r)if(a&&ot<c*n)if(!rt&&(1===tt?d+c*i/2<s:s<h-c*i/2)&&(rt=!0),rt)f=!0;else{"vertical"===o?u.top:u.left,"vertical"===o?u.bottom:u.right;if(1===tt?s<d+ot:h-ot<s)return-1*tt}else if(d+c*(1-n)/2<s&&s<h-c*(1-n)/2)return Xt(e);if((f=f||r)&&(s<d+c*i/2||h-c*i/2<s))return d+c/2<s?1:-1;return 0}(e,r,u,a.swapThreshold,null==a.invertedSwapThreshold?a.swapThreshold:a.invertedSwapThreshold,at,$===r),"swap"):(g=Xt(r),"insert"),0===g)return z(!1);nt=null,tt=g,n=Lt($=r);var y=r.nextElementSibling,D=!1,S=Et(q,i,U,o,r,n,e,D=1===g);if(!1!==S)return 1!==S&&-1!==S||(D=1===S),ht=!0,ct(Nt,30),c?s._hideClone():s._showClone(this),D&&!y?i.appendChild(U):r.parentNode.insertBefore(U,D?y:r),w&&ft(w,0,_-w.scrollTop),V=U.parentNode,void 0===p||at||(ot=ut(p-Lt(r)[b])),j(),z(!0)}}else if(f&&i===e.target&&(r=f),r&&(n=Lt(r)),c?s._hideClone():s._showClone(this),!1!==Et(q,i,U,o,r,n,e,!!r))return i.appendChild(U),V=i,nt=null,j(),z(!0);if(i.contains(U))return z(!1)}var T,C,E,x,N,M,P,X,Y,A,k,I,B,O,H,R,L,W,F;return dt&&!e.rootEl&&gt(i,e,"_onDragOver"),!1}function z(t){return t&&(c?s._hideClone():s._showClone(h),s&&(yt(U,Q?Q.options.ghostClass:s.options.ghostClass,!1),yt(U,a.ghostClass,!0)),Q!==h&&h!==mt.active?Q=h:h===mt.active&&(Q=null),o&&h._animate(o,U),r&&n&&h._animate(n,r)),(r===U&&!U.animated||r===i&&!r.animated)&&($=null),a.dragoverBubble||e.rootEl||r===st||(h._handleAutoScroll(e),U.parentNode[lt]._computeIsAligned(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),!0}function j(){Ct(h,q,"change",r,i,q,K,At(U,a.draggable),e)}},_animate:function(t,e){var o=this.options.animation;if(o){var n=Lt(e);if(e===U&&(nt=n),1===t.nodeType&&(t=Lt(t)),t.left+t.width/2!==n.left+n.width/2||t.top+t.height/2!==n.top+n.height/2){var i=St(this.el),r=i&&i.a,a=i&&i.d;Dt(e,"transition","none"),Dt(e,"transform","translate3d("+(t.left-n.left)/(r||1)+"px,"+(t.top-n.top)/(a||1)+"px,0)"),e.offsetWidth,Dt(e,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),Dt(e,"transform","translate3d(0,0,0)")}"number"==typeof e.animated&&clearTimeout(e.animated),e.animated=ct(function(){Dt(e,"transition",""),Dt(e,"transform",""),e.animated=!1},o)}},_offUpEvents:function(){var t=this.el.ownerDocument;_t(st,"touchmove",this._onTouchMove),_t(st,"pointermove",this._onTouchMove),_t(t,"mouseup",this._onDrop),_t(t,"touchend",this._onDrop),_t(t,"pointerup",this._onDrop),_t(t,"touchcancel",this._onDrop),_t(st,"selectstart",this)},_onDrop:function(t){var e=this.el,o=this.options;rt=at=B=v=!1,clearInterval(this._loopId),clearInterval(l),L(),clearTimeout(vt),vt=void 0,clearTimeout(this._dragStartTimer),Rt(this._cloneId),Rt(this._dragStartId),_t(st,"mousemove",this._onTouchMove),this.nativeDraggable&&(_t(st,"drop",this),_t(e,"dragstart",this._onDragStart),_t(st,"dragover",this._handleAutoScroll),_t(st,"dragover",F)),D&&Dt(st.body,"user-select",""),this._offUpEvents(),t&&(J&&(t.cancelable&&t.preventDefault(),!o.dropBubble&&t.stopPropagation()),f&&f.parentNode&&f.parentNode.removeChild(f),(q===V||Q&&"clone"!==Q.lastPutMode)&&u&&u.parentNode&&u.parentNode.removeChild(u),U&&(this.nativeDraggable&&_t(U,"dragend",this),xt(U),U.style["will-change"]="",yt(U,Q?Q.options.ghostClass:this.options.ghostClass,!1),yt(U,this.options.chosenClass,!1),Ct(this,q,"unchoose",U,V,q,K,null,t),q!==V?(0<=(n=At(U,o.draggable))&&(Ct(null,V,"add",U,V,q,K,n,t),Ct(this,q,"remove",U,V,q,K,n,t),Ct(null,V,"sort",U,V,q,K,n,t),Ct(this,q,"sort",U,V,q,K,n,t)),Q&&Q.save()):U.nextSibling!==G&&0<=(n=At(U,o.draggable))&&(Ct(this,q,"update",U,V,q,K,n,t),Ct(this,q,"sort",U,V,q,K,n,t)),mt.active&&(null!=n&&-1!==n||(n=K),Ct(this,q,"end",U,V,q,K,n,t),this.save()))),this._nulling()},_nulling:function(){q=U=V=f=G=u=h=X=Y=I.length=l=s=c=p=k=J=n=K=$=tt=nt=Q=Z=mt.active=null,M.forEach(function(t){t.checked=!0}),M.length=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":U&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],o=this.el.children,n=0,i=o.length,r=this.options;n<i;n++)bt(t=o[n],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Yt(t));return e},sort:function(t){var n={},i=this.el;this.toArray().forEach(function(t,e){var o=i.children[e];bt(o,this.options.draggable,i,!1)&&(n[t]=o)},this),t.forEach(function(t){n[t]&&(i.removeChild(n[t]),i.appendChild(n[t]))})},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return bt(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var o=this.options;if(void 0===e)return o[t];o[t]=e,"group"===t&&W(o)},destroy:function(){var t=this.el;t[lt]=null,_t(t,"mousedown",this._onTapStart),_t(t,"touchstart",this._onTapStart),_t(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(_t(t,"dragover",this),_t(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),d.splice(d.indexOf(this.el),1),this.el=t=null},_hideClone:function(){u.cloneHidden||(Dt(u,"display","none"),u.cloneHidden=!0,u.parentNode&&this.options.removeCloneOnHide&&u.parentNode.removeChild(u))},_showClone:function(t){"clone"===t.lastPutMode?u.cloneHidden&&(q.contains(U)&&!this.options.group.revertClone?q.insertBefore(u,U):G?q.insertBefore(u,G):q.appendChild(u),this.options.group.revertClone&&this._animate(U,u),Dt(u,"display",""),u.cloneHidden=!1):this._hideClone()}},wt(st,"touchmove",function(t){(mt.active||v)&&t.cancelable&&t.preventDefault()}),mt.utils={on:wt,off:_t,css:Dt,find:Tt,is:function(t,e){return!!bt(t,e,t,!1)},extend:Bt,throttle:It,closest:bt,toggleClass:yt,clone:Ot,index:At,nextTick:Ht,cancelNextTick:Rt,detectDirection:P,getChild:Mt},mt.create=function(t,e){return new mt(t,e)},mt.version="1.8.4",mt});
3
+ !function(t){"use strict";"function"==typeof define&&define.amd?define(t):"undefined"!=typeof module&&void 0!==module.exports?module.exports=t():window.Sortable=t()}(function(){"use strict";if("undefined"==typeof window||!window.document)return function(){throw new Error("Sortable.js requires a window with a document")};function A(t,e){if(!t||!t.getBoundingClientRect)return ut();var o=t,n=!1;do{if(o.clientWidth<o.scrollWidth||o.clientHeight<o.scrollHeight){var i=Tt(o);if(o.clientWidth<o.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||o.clientHeight<o.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!o||!o.getBoundingClientRect||o===J.body)return ut();if(n||e)return o;n=!0}}}while(o=o.parentNode);return ut()}function X(t,e,o){t.scrollLeft+=e,t.scrollTop+=o}function n(t){E&&E.parentNode&&E.parentNode[Q]&&E.parentNode[Q]._computeIsAligned(t)}function u(){!it&&p&&Tt(p,"display","none")}function f(){!it&&p&&Tt(p,"display","")}var E,x,p,v,M,N,g,Y,k,I,P,i,O,r,H,B,l,s,c,m,R,L,W,F,z,j,b,U,V=[],q=!1,w=!1,G=!1,d=[],K=!1,Z=!1,_=[],a=/\s+/g,Q="Sortable"+(new Date).getTime(),y=window,J=y.document,D=y.parseInt,$=y.setTimeout,e=y.jQuery||y.Zepto,o=y.Polymer,h={capture:!1,passive:!1},T=!!navigator.userAgent.match(/(?:Trident.*rv[ :]?11\.|msie|iemobile)/i),S=!!navigator.userAgent.match(/Edge/i),C=!!navigator.userAgent.match(/firefox/i),tt=!(!navigator.userAgent.match(/safari/i)||navigator.userAgent.match(/chrome/i)||navigator.userAgent.match(/android/i)),et=!!navigator.userAgent.match(/iP(ad|od|hone)/i),ot=S||T?"cssFloat":"float",nt="draggable"in J.createElement("div"),it=function(){if(T)return!1;var t=J.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}(),rt=!1,at=!1,lt=Math.abs,st=Math.min,ct=Math.max,dt=[],ht=function(t,e){var o=Tt(t),n=D(o.width)-D(o.paddingLeft)-D(o.paddingRight)-D(o.borderLeftWidth)-D(o.borderRightWidth),i=Pt(t,0,e),r=Pt(t,1,e),a=i&&Tt(i),l=r&&Tt(r),s=a&&D(a.marginLeft)+D(a.marginRight)+Lt(i).width,c=l&&D(l.marginLeft)+D(l.marginRight)+Lt(r).width;if("flex"===o.display)return"column"===o.flexDirection||"column-reverse"===o.flexDirection?"vertical":"horizontal";if("grid"===o.display)return o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&"none"!==a.float){var d="left"===a.float?"left":"right";return!r||"both"!==l.clear&&l.clear!==d?"horizontal":"vertical"}return i&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||n<=s&&"none"===o[ot]||r&&"none"===o[ot]&&n<s+c)?"vertical":"horizontal"},ut=function(){return T?J.documentElement:J.scrollingElement},ft=t(function(o,t,e,n){if(t.scroll){var i=e?e[Q]:window,r=t.scrollSensitivity,a=t.scrollSpeed,l=o.clientX,s=o.clientY,c=ut(),d=!1;k!==e&&(pt(),Y=t.scroll,I=t.scrollFn,!0===Y&&(Y=A(e,!0),k=Y));var h=0,u=Y;do{var f,p,v,g,m,b,w,_,y,D=u,T=Lt(D),S=T.top,C=T.bottom,E=T.left,x=T.right,M=T.width,N=T.height;if(f=D.scrollWidth,p=D.scrollHeight,v=Tt(D),_=D.scrollLeft,y=D.scrollTop,w=D===c?(b=M<f&&("auto"===v.overflowX||"scroll"===v.overflowX||"visible"===v.overflowX),N<p&&("auto"===v.overflowY||"scroll"===v.overflowY||"visible"===v.overflowY)):(b=M<f&&("auto"===v.overflowX||"scroll"===v.overflowX),N<p&&("auto"===v.overflowY||"scroll"===v.overflowY)),g=b&&(lt(x-l)<=r&&_+M<f)-(lt(E-l)<=r&&!!_),m=w&&(lt(C-s)<=r&&y+N<p)-(lt(S-s)<=r&&!!y),!V[h])for(var P=0;P<=h;P++)V[P]||(V[P]={});V[h].vx==g&&V[h].vy==m&&V[h].el===D||(V[h].el=D,V[h].vx=g,V[h].vy=m,clearInterval(V[h].pid),!D||0==g&&0==m||(d=!0,V[h].pid=setInterval(function(){n&&0===this.layer&&(bt.active._emulateDragOver(!0),bt.active._onTouchMove(R,!0));var t=V[this.layer].vy?V[this.layer].vy*a:0,e=V[this.layer].vx?V[this.layer].vx*a:0;"function"==typeof I&&"continue"!==I.call(i,e,t,o,R,V[this.layer].el)||X(V[this.layer].el,e,t)}.bind({layer:h}),24))),h++}while(t.bubbleScroll&&u!==c&&(u=A(u,!1)));q=d}},30),pt=function(){V.forEach(function(t){clearInterval(t.pid)}),V=[]},vt=function(t){function s(a,l){return function(t,e,o,n){var i=t.options.group.name&&e.options.group.name&&t.options.group.name===e.options.group.name;if(null==a&&(l||i))return!0;if(null==a||!1===a)return!1;if(l&&"clone"===a)return a;if("function"==typeof a)return s(a(t,e,o,n),l)(t,e,o,n);var r=(l?t:e).options.group.name;return!0===a||"string"==typeof a&&a===r||a.join&&-1<a.indexOf(r)}}var e={},o=t.group;o&&"object"==typeof o||(o={name:o}),e.name=o.name,e.checkPull=s(o.pull,!0),e.checkPut=s(o.put),e.revertClone=o.revertClone,t.group=e};J.addEventListener("click",function(t){if(G)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),G=!1},!0);function gt(t){if(E){var e=function(t,e){for(var o=0;o<d.length;o++)if(!At(d[o])){var n=Lt(d[o]),i=d[o][Q].options.emptyInsertThreshold,r=t>=n.left-i&&t<=n.right+i,a=e>=n.top-i&&e<=n.bottom+i;if(i&&r&&a)return d[o]}}((t=t.touches?t.touches[0]:t).clientX,t.clientY);if(e){var o={};for(var n in t)o[n]=t[n];o.target=o.rootEl=e,o.preventDefault=void 0,o.stopPropagation=void 0,e[Q]._onDragOver(o)}}}var mt;function bt(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be HTMLElement, not "+{}.toString.call(t);this.el=t,this.options=e=Ot({},e),t[Q]=this;var o={group:null,sort:!0,disabled:!1,store:null,handle:null,scroll:!0,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0,draggable:/[uo]l/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return ht(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:D(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==bt.supportPointer&&"PointerEvent"in window,emptyInsertThreshold:5};for(var n in o)!(n in e)&&(e[n]=o[n]);for(var i in vt(e),this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&nt,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?_t(t,"pointerdown",this._onTapStart):(_t(t,"mousedown",this._onTapStart),_t(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(_t(t,"dragover",this),_t(t,"dragenter",this)),d.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[])}function wt(t,e,o,n){if(t){o=o||J;do{if(null!=e&&(">"===e[0]?t.parentNode===o&&It(t,e):It(t,e))||n&&t===o)return t;if(t===o)break}while(t=(i=t).host&&i!==J&&i.host.nodeType?i.host:i.parentNode)}var i;return null}function _t(t,e,o){t.addEventListener(e,o,!T&&h)}function yt(t,e,o){t.removeEventListener(e,o,!T&&h)}function Dt(t,e,o){if(t&&e)if(t.classList)t.classList[o?"add":"remove"](e);else{var n=(" "+t.className+" ").replace(a," ").replace(" "+e+" "," ");t.className=(n+(o?" "+e:"")).replace(a," ")}}function Tt(t,e,o){var n=t&&t.style;if(n){if(void 0===o)return J.defaultView&&J.defaultView.getComputedStyle?o=J.defaultView.getComputedStyle(t,""):t.currentStyle&&(o=t.currentStyle),void 0===e?o:o[e];e in n||-1!==e.indexOf("webkit")||(e="-webkit-"+e),n[e]=o+("string"==typeof o?"":"px")}}function St(t){var e="";do{var o=Tt(t,"transform");o&&"none"!==o&&(e=o+" "+e)}while(t=t.parentNode);return window.DOMMatrix?new DOMMatrix(e):window.WebKitCSSMatrix?new WebKitCSSMatrix(e):window.CSSMatrix?new CSSMatrix(e):void 0}function Ct(t,e,o){if(t){var n=t.getElementsByTagName(e),i=0,r=n.length;if(o)for(;i<r;i++)o(n[i],i);return n}return[]}function Et(t,e,o,n,i,r,a,l,s,c,d){var h,u=(t=t||e[Q]).options,f="on"+o.charAt(0).toUpperCase()+o.substr(1);!window.CustomEvent||T||S?(h=J.createEvent("Event")).initEvent(o,!0,!0):h=new CustomEvent(o,{bubbles:!0,cancelable:!0}),h.to=i||e,h.from=r||e,h.item=n||e,h.clone=v,h.oldIndex=a,h.newIndex=l,h.oldDraggableIndex=s,h.newDraggableIndex=c,h.originalEvent=d,h.pullMode=B?B.lastPutMode:void 0,e&&e.dispatchEvent(h),u[f]&&u[f].call(t,h)}function xt(t,e,o,n,i,r,a,l){var s,c,d=t[Q],h=d.options.onMove;return!window.CustomEvent||T||S?(s=J.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=o,s.draggedRect=n,s.related=i||e,s.relatedRect=r||Lt(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),h&&(c=h.call(d,s,a)),c}function Mt(t){t.draggable=!1}function Nt(){rt=!1}function Pt(t,e,o){for(var n=0,i=0,r=t.children;i<r.length;){if("none"!==r[i].style.display&&r[i]!==p&&r[i]!==E&&wt(r[i],o.draggable,t,!1)){if(n===e)return r[i];n++}i++}return null}function At(t){for(var e=t.lastElementChild;e&&(e===p||"none"===Tt(e,"display"));)e=e.previousElementSibling;return e||null}function Xt(t){return kt(E)<kt(t)?1:-1}function Yt(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,o=e.length,n=0;o--;)n+=e.charCodeAt(o);return n.toString(36)}function kt(t,e){var o=0;if(!t||!t.parentNode)return-1;for(;t&&(t=t.previousElementSibling);)"TEMPLATE"===t.nodeName.toUpperCase()||t===v||e&&!It(t,e)||o++;return o}function It(t,e){if(e){if(">"===e[0]&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}}function t(o,n){return function(){if(!mt){var t=arguments,e=this;mt=$(function(){1===t.length?o.call(e,t[0]):o.apply(e,t),mt=void 0},n)}}}function Ot(t,e){if(t&&e)for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);return t}function Ht(t){return o&&o.dom?o.dom(t).cloneNode(!0):e?e(t).clone(!0)[0]:t.cloneNode(!0)}function Bt(t){return $(t,0)}function Rt(t){return clearTimeout(t)}function Lt(t,e,o,n){if(t.getBoundingClientRect||t===y){var i,r,a,l,s,c,d;if(d=t!==y&&t!==ut()?(r=(i=t.getBoundingClientRect()).top,a=i.left,l=i.bottom,s=i.right,c=i.height,i.width):(a=r=0,l=window.innerHeight,s=window.innerWidth,c=window.innerHeight,window.innerWidth),n&&t!==y&&(o=o||t.parentNode,!T))do{if(o&&o.getBoundingClientRect&&"none"!==Tt(o,"transform")){var h=o.getBoundingClientRect();r-=h.top+D(Tt(o,"border-top-width")),a-=h.left+D(Tt(o,"border-left-width")),l=r+i.height,s=a+i.width;break}}while(o=o.parentNode);if(e&&t!==y){var u=St(o||t),f=u&&u.a,p=u&&u.d;u&&(l=(r/=p)+(c/=p),s=(a/=f)+(d/=f))}return{top:r,left:a,bottom:l,right:s,width:d,height:c}}}function Wt(t,e){for(var o=A(t,!0),n=Lt(t)[e];o;){var i=Lt(o)[e];if(!("top"===e||"left"===e?i<=n:n<=i))return o;if(o===ut())break;o=A(o,!1)}return!1}function Ft(t){var e=0,o=0,n=ut();if(t)do{var i=St(t),r=i.a,a=i.d;e+=t.scrollLeft*r,o+=t.scrollTop*a}while(t!==n&&(t=t.parentNode));return[e,o]}return bt.prototype={constructor:bt,_computeIsAligned:function(t){var e;if(p&&!it?(u(),e=J.elementFromPoint(t.clientX,t.clientY),f()):e=t.target,e=wt(e,this.options.draggable,this.el,!1),!at&&E&&E.parentNode===this.el){for(var o,n,i,r,a,l,s,c,d=this.el.children,h=0;h<d.length;h++)wt(d[h],this.options.draggable,this.el,!1)&&d[h]!==e&&(d[h].sortableMouseAligned=(o=t.clientX,n=t.clientY,i=d[h],r=this._getDirection(t,null),this.options,void 0,a=Lt(i),l="vertical"===r?a.left:a.top,s="vertical"===r?a.right:a.bottom,l<(c="vertical"===r?o:n)&&c<s));wt(e,this.options.draggable,this.el,!0)||(W=null),at=!0,$(function(){at=!1},30)}},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,E):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e,o,n=this,i=this.el,r=this.options,a=r.preventOnFilter,l=t.type,s=t.touches&&t.touches[0],c=(s||t).target,d=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||c,h=r.filter;if(function(t){dt.length=0;var e=t.getElementsByTagName("input"),o=e.length;for(;o--;){var n=e[o];n.checked&&dt.push(n)}}(i),!E&&!(/mousedown|pointerdown/.test(l)&&0!==t.button||r.disabled||d.isContentEditable||(c=wt(c,r.draggable,i,!1),g===c))){if(e=kt(c),o=kt(c,r.draggable),"function"==typeof h){if(h.call(this,t,c,this))return Et(n,d,"filter",c,i,i,e,void 0,o),void(a&&t.cancelable&&t.preventDefault())}else if(h&&(h=h.split(",").some(function(t){if(t=wt(d,t.trim(),i,!1))return Et(n,t,"filter",c,i,i,e,void 0,o),!0})))return void(a&&t.cancelable&&t.preventDefault());r.handle&&!wt(d,r.handle,i,!1)||this._prepareDragStart(t,s,c,e,o)}}},_handleAutoScroll:function(e,o){if(E&&this.options.scroll){var n=e.clientX,i=e.clientY,t=J.elementFromPoint(n,i),r=this;if(o||S||T||tt){ft(e,r.options,t,o);var a=A(t,!0);!q||l&&n===s&&i===c||(l&&clearInterval(l),l=setInterval(function(){if(E){var t=A(J.elementFromPoint(n,i),!0);t!==a&&(a=t,pt(),ft(e,r.options,a,o))}},10),s=n,c=i)}else{if(!r.options.bubbleScroll||A(t,!0)===ut())return void pt();ft(e,r.options,A(t,!1),!1)}}},_prepareDragStart:function(t,e,o,n,i){var r,a=this,l=a.el,s=a.options,c=l.ownerDocument;o&&!E&&o.parentNode===l&&(M=l,x=(E=o).parentNode,N=E.nextSibling,g=o,H=s.group,P=n,O=i,m={target:E,clientX:(e||t).clientX,clientY:(e||t).clientY},this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,E.style["will-change"]="all",E.style.transition="",E.style.transform="",r=function(){a._disableDelayedDragEvents(),!C&&a.nativeDraggable&&(E.draggable=!0),a._triggerDragStart(t,e),Et(a,M,"choose",E,M,M,P,void 0,O),Dt(E,s.chosenClass,!0)},s.ignore.split(",").forEach(function(t){Ct(E,t.trim(),Mt)}),_t(c,"dragover",gt),_t(c,"mousemove",gt),_t(c,"touchmove",gt),_t(c,"mouseup",a._onDrop),_t(c,"touchend",a._onDrop),_t(c,"touchcancel",a._onDrop),C&&this.nativeDraggable&&(this.options.touchStartThreshold=4,E.draggable=!0),!s.delay||s.delayOnTouchOnly&&!e||this.nativeDraggable&&(S||T)?r():(_t(c,"mouseup",a._disableDelayedDrag),_t(c,"touchend",a._disableDelayedDrag),_t(c,"touchcancel",a._disableDelayedDrag),_t(c,"mousemove",a._delayedDragTouchMoveHandler),_t(c,"touchmove",a._delayedDragTouchMoveHandler),s.supportPointer&&_t(c,"pointermove",a._delayedDragTouchMoveHandler),a._dragStartTimer=$(r,s.delay)))},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;ct(lt(e.clientX-this._lastX),lt(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){E&&Mt(E),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;yt(t,"mouseup",this._disableDelayedDrag),yt(t,"touchend",this._disableDelayedDrag),yt(t,"touchcancel",this._disableDelayedDrag),yt(t,"mousemove",this._delayedDragTouchMoveHandler),yt(t,"touchmove",this._delayedDragTouchMoveHandler),yt(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||("touch"==t.pointerType?t:null),!this.nativeDraggable||e?this.options.supportPointer?_t(J,"pointermove",this._onTouchMove):_t(J,e?"touchmove":"mousemove",this._onTouchMove):(_t(E,"dragend",this),_t(M,"dragstart",this._onDragStart));try{J.selection?Bt(function(){J.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(w=!1,M&&E){this.nativeDraggable&&(_t(J,"dragover",this._handleAutoScroll),_t(J,"dragover",n));var o=this.options;!t&&Dt(E,o.dragClass,!1),Dt(E,o.ghostClass,!0),Tt(E,"transform",""),bt.active=this,t&&this._appendGhost(),Et(this,M,"start",E,M,M,P,void 0,O,void 0,e)}else this._nulling()},_emulateDragOver:function(t){if(R){if(this._lastX===R.clientX&&this._lastY===R.clientY&&!t)return;this._lastX=R.clientX,this._lastY=R.clientY,u();for(var e=J.elementFromPoint(R.clientX,R.clientY),o=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(R.clientX,R.clientY))!==o;)o=e;if(o)do{if(o[Q])if(o[Q]._onDragOver({clientX:R.clientX,clientY:R.clientY,target:e,rootEl:o})&&!this.options.dragoverBubble)break;e=o}while(o=o.parentNode);E.parentNode[Q]._computeIsAligned(R),f()}},_onTouchMove:function(t,e){if(m){var o=this.options,n=o.fallbackTolerance,i=o.fallbackOffset,r=t.touches?t.touches[0]:t,a=p&&St(p),l=p&&a&&a.a,s=p&&a&&a.d,c=et&&b&&Ft(b),d=(r.clientX-m.clientX+i.x)/(l||1)+(c?c[0]-_[0]:0)/(l||1),h=(r.clientY-m.clientY+i.y)/(s||1)+(c?c[1]-_[1]:0)/(s||1),u=t.touches?"translate3d("+d+"px,"+h+"px,0)":"translate("+d+"px,"+h+"px)";if(!bt.active&&!w){if(n&&st(lt(r.clientX-this._lastX),lt(r.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}!e&&this._handleAutoScroll(r,!0),L=!0,R=r,Tt(p,"webkitTransform",u),Tt(p,"mozTransform",u),Tt(p,"msTransform",u),Tt(p,"transform",u),t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!p){var t=this.options.fallbackOnBody?J.body:M,e=Lt(E,!0,t,!et),o=(Tt(E),this.options);if(et){for(b=t;"static"===Tt(b,"position")&&"none"===Tt(b,"transform")&&b!==J;)b=b.parentNode;if(b!==J){var n=Lt(b,!0);e.top-=n.top,e.left-=n.left}b!==J.body&&b!==J.documentElement?(b===J&&(b=ut()),e.top+=b.scrollTop,e.left+=b.scrollLeft):b=ut(),_=Ft(b)}Dt(p=E.cloneNode(!0),o.ghostClass,!1),Dt(p,o.fallbackClass,!0),Dt(p,o.dragClass,!0),Tt(p,"box-sizing","border-box"),Tt(p,"margin",0),Tt(p,"top",e.top),Tt(p,"left",e.left),Tt(p,"width",e.width),Tt(p,"height",e.height),Tt(p,"opacity","0.8"),Tt(p,"position",et?"absolute":"fixed"),Tt(p,"zIndex","100000"),Tt(p,"pointerEvents","none"),t.appendChild(p)}},_onDragStart:function(t,e){var o=this,n=t.dataTransfer,i=o.options;(v=Ht(E)).draggable=!1,v.style["will-change"]="",this._hideClone(),Dt(v,o.options.chosenClass,!1),o._cloneId=Bt(function(){o.options.removeCloneOnHide||M.insertBefore(v,E),Et(o,M,"clone",E)}),!e&&Dt(E,i.dragClass,!0),e?(G=!0,o._loopId=setInterval(o._emulateDragOver,50)):(yt(J,"mouseup",o._onDrop),yt(J,"touchend",o._onDrop),yt(J,"touchcancel",o._onDrop),n&&(n.effectAllowed="move",i.setData&&i.setData.call(o,n,E)),_t(J,"drop",o),Tt(E,"transform","translateZ(0)")),w=!0,o._dragStartId=Bt(o._dragStarted.bind(o,e,t)),_t(J,"selectstart",o),tt&&Tt(J.body,"user-select","none")},_onDragOver:function(e){var o,n,t,i=this.el,r=e.target,a=this.options,l=a.group,s=bt.active,c=H===l,d=a.sort,h=this;if(!rt){if(void 0!==e.preventDefault&&e.cancelable&&e.preventDefault(),L=!0,r=wt(r,a.draggable,i,!0),E.contains(e.target)||r.animated)return S(!1);if(r!==E&&(G=!1),s&&!a.disabled&&(c?d||(t=!M.contains(E)):B===this||(this.lastPutMode=H.checkPull(this,s,E,e))&&l.checkPut(this,s,E,e))){var u=this._getDirection(e,r);if(o=Lt(E),t)return this._hideClone(),x=M,N?M.insertBefore(E,N):M.appendChild(E),S(!0);var f=At(i);if(!f||function(t,e,o){var n=Lt(At(o)),i="vertical"===e?t.clientY:t.clientX,r="vertical"===e?t.clientX:t.clientY,a="vertical"===e?n.bottom:n.right,l="vertical"===e?n.left:n.top,s="vertical"===e?n.right:n.bottom;return"vertical"===e?s+10<r||r<=s&&a<i&&l<=r:a<i&&l<r||i<=a&&s+10<r}(e,u,i)&&!f.animated){if(f&&i===e.target&&(r=f),r&&(n=Lt(r)),c?s._hideClone():s._showClone(this),!1!==xt(M,i,E,o,r,n,e,!!r))return i.appendChild(E),x=i,U=null,C(),S(!0)}else if(r&&r!==E&&r.parentNode===i){var p,v=0,g=r.sortableMouseAligned,m=E.parentNode!==i,b="vertical"===u?"top":"left",w=Wt(r,"top")||Wt(E,"top"),_=w?w.scrollTop:void 0;if(W!==r&&(z=null,p=Lt(r)[b],K=!1),z=function(t,e,o){var n=t===E&&U||Lt(t),i=e===E&&U||Lt(e),r="vertical"===o?n.left:n.top,a="vertical"===o?n.right:n.bottom,l="vertical"===o?n.width:n.height,s="vertical"===o?i.left:i.top,c="vertical"===o?i.right:i.bottom,d="vertical"===o?i.width:i.height;return r===s||a===c||r+l/2===s+d/2}(E,r,u)&&g||m||w||a.invertSwap||"insert"===z||"swap"===z?("swap"!==z&&(Z=a.invertSwap||m),v=function(t,e,o,n,i,r,a){var l=Lt(e),s="vertical"===o?t.clientY:t.clientX,c="vertical"===o?l.height:l.width,d="vertical"===o?l.top:l.left,h="vertical"===o?l.bottom:l.right,u=Lt(E),f=!1;if(!r)if(a&&j<c*n)if(!K&&(1===F?d+c*i/2<s:s<h-c*i/2)&&(K=!0),K)f=!0;else{"vertical"===o?u.top:u.left,"vertical"===o?u.bottom:u.right;if(1===F?s<d+j:h-j<s)return-1*F}else if(d+c*(1-n)/2<s&&s<h-c*(1-n)/2)return Xt(e);if((f=f||r)&&(s<d+c*i/2||h-c*i/2<s))return d+c/2<s?1:-1;return 0}(e,r,u,a.swapThreshold,null==a.invertedSwapThreshold?a.swapThreshold:a.invertedSwapThreshold,Z,W===r),"swap"):(v=Xt(r),"insert"),0===v)return S(!1);U=null,F=v,n=Lt(W=r);var y=r.nextElementSibling,D=!1,T=xt(M,i,E,o,r,n,e,D=1===v);if(!1!==T)return 1!==T&&-1!==T||(D=1===T),rt=!0,$(Nt,30),c?s._hideClone():s._showClone(this),D&&!y?i.appendChild(E):r.parentNode.insertBefore(E,D?y:r),w&&X(w,0,_-w.scrollTop),x=E.parentNode,void 0===p||Z||(j=lt(p-Lt(r)[b])),C(),S(!0)}if(i.contains(E))return S(!1)}return!1}function S(t){return t&&(c?s._hideClone():s._showClone(h),s&&(Dt(E,B?B.options.ghostClass:s.options.ghostClass,!1),Dt(E,a.ghostClass,!0)),B!==h&&h!==bt.active?B=h:h===bt.active&&(B=null),o&&h._animate(o,E),r&&n&&h._animate(n,r)),(r===E&&!E.animated||r===i&&!r.animated)&&(W=null),a.dragoverBubble||e.rootEl||r===J||(h._handleAutoScroll(e),E.parentNode[Q]._computeIsAligned(e),!t&&gt(e)),!a.dragoverBubble&&e.stopPropagation&&e.stopPropagation(),!0}function C(){Et(h,M,"change",r,i,M,P,kt(E),O,kt(E,a.draggable),e)}},_animate:function(t,e){var o=this.options.animation;if(o){var n=Lt(e);if(e===E&&(U=n),1===t.nodeType&&(t=Lt(t)),t.left+t.width/2!==n.left+n.width/2||t.top+t.height/2!==n.top+n.height/2){var i=St(this.el),r=i&&i.a,a=i&&i.d;Tt(e,"transition","none"),Tt(e,"transform","translate3d("+(t.left-n.left)/(r||1)+"px,"+(t.top-n.top)/(a||1)+"px,0)"),this._repaint(e),Tt(e,"transition","transform "+o+"ms"+(this.options.easing?" "+this.options.easing:"")),Tt(e,"transform","translate3d(0,0,0)")}"number"==typeof e.animated&&clearTimeout(e.animated),e.animated=$(function(){Tt(e,"transition",""),Tt(e,"transform",""),e.animated=!1},o)}},_repaint:function(t){return t.offsetWidth},_offMoveEvents:function(){yt(J,"touchmove",this._onTouchMove),yt(J,"pointermove",this._onTouchMove),yt(J,"dragover",gt),yt(J,"mousemove",gt),yt(J,"touchmove",gt)},_offUpEvents:function(){var t=this.el.ownerDocument;yt(t,"mouseup",this._onDrop),yt(t,"touchend",this._onDrop),yt(t,"pointerup",this._onDrop),yt(t,"touchcancel",this._onDrop),yt(J,"selectstart",this)},_onDrop:function(t){var e=this.el,o=this.options;K=Z=q=w=!1,clearInterval(this._loopId),clearInterval(l),pt(),clearTimeout(mt),mt=void 0,clearTimeout(this._dragStartTimer),Rt(this._cloneId),Rt(this._dragStartId),yt(J,"mousemove",this._onTouchMove),this.nativeDraggable&&(yt(J,"drop",this),yt(e,"dragstart",this._onDragStart),yt(J,"dragover",this._handleAutoScroll),yt(J,"dragover",n)),tt&&Tt(J.body,"user-select",""),this._offMoveEvents(),this._offUpEvents(),t&&(L&&(t.cancelable&&t.preventDefault(),!o.dropBubble&&t.stopPropagation()),p&&p.parentNode&&p.parentNode.removeChild(p),(M===x||B&&"clone"!==B.lastPutMode)&&v&&v.parentNode&&v.parentNode.removeChild(v),E&&(this.nativeDraggable&&yt(E,"dragend",this),Mt(E),E.style["will-change"]="",Dt(E,B?B.options.ghostClass:this.options.ghostClass,!1),Dt(E,this.options.chosenClass,!1),Et(this,M,"unchoose",E,x,M,P,null,O,null,t),M!==x?(i=kt(E),r=kt(E,o.draggable),0<=i&&(Et(null,x,"add",E,x,M,P,i,O,r,t),Et(this,M,"remove",E,x,M,P,i,O,r,t),Et(null,x,"sort",E,x,M,P,i,O,r,t),Et(this,M,"sort",E,x,M,P,i,O,r,t)),B&&B.save()):E.nextSibling!==N&&(i=kt(E),r=kt(E,o.draggable),0<=i&&(Et(this,M,"update",E,x,M,P,i,O,r,t),Et(this,M,"sort",E,x,M,P,i,O,r,t))),bt.active&&(null!=i&&-1!==i||(i=P,r=O),Et(this,M,"end",E,x,M,P,i,O,r,t),this.save()))),this._nulling()},_nulling:function(){M=E=x=p=N=v=g=Y=k=V.length=l=s=c=m=R=L=i=P=W=F=U=B=H=bt.active=null,dt.forEach(function(t){t.checked=!0}),dt.length=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":E&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],o=this.el.children,n=0,i=o.length,r=this.options;n<i;n++)wt(t=o[n],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Yt(t));return e},sort:function(t){var n={},i=this.el;this.toArray().forEach(function(t,e){var o=i.children[e];wt(o,this.options.draggable,i,!1)&&(n[t]=o)},this),t.forEach(function(t){n[t]&&(i.removeChild(n[t]),i.appendChild(n[t]))})},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return wt(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var o=this.options;if(void 0===e)return o[t];o[t]=e,"group"===t&&vt(o)},destroy:function(){var t=this.el;t[Q]=null,yt(t,"mousedown",this._onTapStart),yt(t,"touchstart",this._onTapStart),yt(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(yt(t,"dragover",this),yt(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),d.splice(d.indexOf(this.el),1),this.el=t=null},_hideClone:function(){v.cloneHidden||(Tt(v,"display","none"),v.cloneHidden=!0,v.parentNode&&this.options.removeCloneOnHide&&v.parentNode.removeChild(v))},_showClone:function(t){"clone"===t.lastPutMode?v.cloneHidden&&(M.contains(E)&&!this.options.group.revertClone?M.insertBefore(v,E):N?M.insertBefore(v,N):M.appendChild(v),this.options.group.revertClone&&this._animate(E,v),Tt(v,"display",""),v.cloneHidden=!1):this._hideClone()}},_t(J,"touchmove",function(t){(bt.active||w)&&t.cancelable&&t.preventDefault()}),bt.utils={on:_t,off:yt,css:Tt,find:Ct,is:function(t,e){return!!wt(t,e,t,!1)},extend:Ot,throttle:t,closest:wt,toggleClass:Dt,clone:Ht,index:kt,nextTick:Bt,cancelNextTick:Rt,detectDirection:ht,getChild:Pt},bt.create=function(t,e){return new bt(t,e)},bt.version="1.9.0",bt});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sortablejs",
3
3
  "exportName": "Sortable",
4
- "version": "1.8.4",
4
+ "version": "1.9.0",
5
5
  "devDependencies": {
6
6
  "gulp": "^4.0.0",
7
7
  "gulp-each": "^0.5.0",