@oiz/stzh-components 1.4.0-npmjstest → 1.5.0-alpha

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.
Files changed (212) hide show
  1. package/README.md +1 -56
  2. package/dist/cjs/{app-globals-e07b8f5f.js → app-globals-3b6f75bd.js} +5 -3
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/stzh-actions.cjs.entry.js +1 -1
  5. package/dist/cjs/stzh-appnav.cjs.entry.js +1 -1
  6. package/dist/cjs/stzh-badge_3.cjs.entry.js +1 -1
  7. package/dist/cjs/stzh-checkbox.cjs.entry.js +1 -1
  8. package/dist/cjs/stzh-checkboxgroup.cjs.entry.js +2 -4
  9. package/dist/cjs/stzh-components.cjs.js +2 -2
  10. package/dist/cjs/stzh-cspace.cjs.entry.js +1 -1
  11. package/dist/cjs/stzh-datepicker_4.cjs.entry.js +2 -4
  12. package/dist/cjs/stzh-dialog.cjs.entry.js +2 -2
  13. package/dist/cjs/stzh-dropdown.cjs.entry.js +30 -3
  14. package/dist/cjs/stzh-figure.cjs.entry.js +1 -1
  15. package/dist/cjs/stzh-footer.cjs.entry.js +1 -1
  16. package/dist/cjs/stzh-ghettobox_2.cjs.entry.js +1 -1
  17. package/dist/cjs/stzh-header.cjs.entry.js +1 -1
  18. package/dist/cjs/stzh-input.cjs.entry.js +9 -4
  19. package/dist/cjs/stzh-link.cjs.entry.js +1 -1
  20. package/dist/cjs/stzh-menu_2.cjs.entry.js +1 -1
  21. package/dist/cjs/stzh-pagetitle.cjs.entry.js +1 -1
  22. package/dist/cjs/stzh-portal-mitwirken.cjs.entry.js +1 -1
  23. package/dist/cjs/stzh-readspeaker.cjs.entry.js +1 -1
  24. package/dist/cjs/stzh-servicecard-list.cjs.entry.js +20 -3
  25. package/dist/cjs/stzh-servicecard.cjs.entry.js +26 -4
  26. package/dist/cjs/stzh-sortable.cjs.entry.js +3214 -2441
  27. package/dist/cjs/stzh-table.cjs.entry.js +1 -1
  28. package/dist/cjs/stzh-toggle.cjs.entry.js +1 -1
  29. package/dist/cjs/stzh-upload.cjs.entry.js +44 -11
  30. package/dist/cjs/utils-8dc66449.js +76 -0
  31. package/dist/collection/assets/fonts.css +5 -5
  32. package/dist/collection/components/stzh-checkboxgroup/stzh-checkboxgroup.js +1 -3
  33. package/dist/collection/components/stzh-cspace/stzh-cspace.css +6 -0
  34. package/dist/collection/components/stzh-dialog/stzh-dialog.css +9 -1
  35. package/dist/collection/components/stzh-dialog/stzh-dialog.stories.js +18 -8
  36. package/dist/collection/components/stzh-dropdown/stzh-dropdown.css +2 -4
  37. package/dist/collection/components/stzh-dropdown/stzh-dropdown.js +79 -1
  38. package/dist/collection/components/stzh-dropdown/stzh-dropdown.stories.js +3328 -0
  39. package/dist/collection/components/stzh-input/stzh-input.css +13 -4
  40. package/dist/collection/components/stzh-input/stzh-input.js +79 -4
  41. package/dist/collection/components/stzh-portal-mitwirken/stzh-portal-mitwirken.css +0 -9
  42. package/dist/collection/components/stzh-radiogroup/stzh-radiogroup.js +1 -3
  43. package/dist/collection/components/stzh-servicecard/stzh-servicecard.css +4 -4
  44. package/dist/collection/components/stzh-servicecard/stzh-servicecard.js +24 -2
  45. package/dist/collection/components/stzh-servicecard-list/stzh-servicecard-list.js +54 -11
  46. package/dist/collection/components/stzh-servicecard-list/stzh-servicecard-list.stories.js +2 -1
  47. package/dist/collection/components/stzh-sortable/stzh-sortable.js +37 -8
  48. package/dist/collection/components/stzh-upload/stzh-upload.css +3 -0
  49. package/dist/collection/components/stzh-upload/stzh-upload.js +43 -10
  50. package/dist/collection/components/stzh-upload/stzh-upload.stories.js +10 -8
  51. package/dist/collection/global/js/helpers/autofocus.js +3 -1
  52. package/dist/collection/global/js/script.js +1 -1
  53. package/dist/collection/libraries/sortable.js +3791 -0
  54. package/dist/collection/utils/utils.js +39 -0
  55. package/dist/components/index.js +5 -3
  56. package/dist/components/stzh-checkboxgroup.js +1 -3
  57. package/dist/components/stzh-cspace.js +1 -1
  58. package/dist/components/stzh-dialog.js +1 -1
  59. package/dist/components/stzh-dropdown2.js +33 -3
  60. package/dist/components/stzh-input2.js +12 -3
  61. package/dist/components/stzh-portal-mitwirken.js +1 -1
  62. package/dist/components/stzh-radiogroup2.js +1 -3
  63. package/dist/components/stzh-servicecard-list.js +22 -4
  64. package/dist/components/stzh-servicecard.js +25 -3
  65. package/dist/components/stzh-sortable2.js +3216 -2442
  66. package/dist/components/stzh-upload.js +43 -10
  67. package/dist/components/utils.js +40 -1
  68. package/dist/esm/{app-globals-70c229e3.js → app-globals-c42494e9.js} +5 -3
  69. package/dist/esm/loader.js +2 -2
  70. package/dist/esm/stzh-actions.entry.js +1 -1
  71. package/dist/esm/stzh-appnav.entry.js +1 -1
  72. package/dist/esm/stzh-badge_3.entry.js +1 -1
  73. package/dist/esm/stzh-checkbox.entry.js +1 -1
  74. package/dist/esm/stzh-checkboxgroup.entry.js +2 -4
  75. package/dist/esm/stzh-components.js +2 -2
  76. package/dist/esm/stzh-cspace.entry.js +1 -1
  77. package/dist/esm/stzh-datepicker_4.entry.js +2 -4
  78. package/dist/esm/stzh-dialog.entry.js +2 -2
  79. package/dist/esm/stzh-dropdown.entry.js +30 -3
  80. package/dist/esm/stzh-figure.entry.js +1 -1
  81. package/dist/esm/stzh-footer.entry.js +1 -1
  82. package/dist/esm/stzh-ghettobox_2.entry.js +1 -1
  83. package/dist/esm/stzh-header.entry.js +1 -1
  84. package/dist/esm/stzh-input.entry.js +9 -4
  85. package/dist/esm/stzh-link.entry.js +1 -1
  86. package/dist/esm/stzh-menu_2.entry.js +1 -1
  87. package/dist/esm/stzh-pagetitle.entry.js +1 -1
  88. package/dist/esm/stzh-portal-mitwirken.entry.js +1 -1
  89. package/dist/esm/stzh-readspeaker.entry.js +1 -1
  90. package/dist/esm/stzh-servicecard-list.entry.js +20 -3
  91. package/dist/esm/stzh-servicecard.entry.js +26 -4
  92. package/dist/esm/stzh-sortable.entry.js +3214 -2441
  93. package/dist/esm/stzh-table.entry.js +1 -1
  94. package/dist/esm/stzh-toggle.entry.js +1 -1
  95. package/dist/esm/stzh-upload.entry.js +44 -11
  96. package/dist/esm/utils-68a28fce.js +72 -0
  97. package/dist/esm-es5/app-globals-c42494e9.js +1 -0
  98. package/dist/esm-es5/loader.js +1 -1
  99. package/dist/esm-es5/stzh-actions.entry.js +1 -1
  100. package/dist/esm-es5/stzh-appnav.entry.js +1 -1
  101. package/dist/esm-es5/stzh-badge_3.entry.js +1 -1
  102. package/dist/esm-es5/stzh-checkbox.entry.js +1 -1
  103. package/dist/esm-es5/stzh-checkboxgroup.entry.js +1 -1
  104. package/dist/esm-es5/stzh-components.js +1 -1
  105. package/dist/esm-es5/stzh-cspace.entry.js +1 -1
  106. package/dist/esm-es5/stzh-datepicker_4.entry.js +1 -1
  107. package/dist/esm-es5/stzh-dialog.entry.js +1 -1
  108. package/dist/esm-es5/stzh-dropdown.entry.js +1 -1
  109. package/dist/esm-es5/stzh-figure.entry.js +1 -1
  110. package/dist/esm-es5/stzh-footer.entry.js +1 -1
  111. package/dist/esm-es5/stzh-ghettobox_2.entry.js +1 -1
  112. package/dist/esm-es5/stzh-header.entry.js +1 -1
  113. package/dist/esm-es5/stzh-input.entry.js +1 -1
  114. package/dist/esm-es5/stzh-link.entry.js +1 -1
  115. package/dist/esm-es5/stzh-menu_2.entry.js +1 -1
  116. package/dist/esm-es5/stzh-pagetitle.entry.js +1 -1
  117. package/dist/esm-es5/stzh-portal-mitwirken.entry.js +1 -1
  118. package/dist/esm-es5/stzh-readspeaker.entry.js +1 -1
  119. package/dist/esm-es5/stzh-servicecard-list.entry.js +1 -1
  120. package/dist/esm-es5/stzh-servicecard.entry.js +1 -1
  121. package/dist/esm-es5/stzh-sortable.entry.js +2 -2
  122. package/dist/esm-es5/stzh-table.entry.js +1 -1
  123. package/dist/esm-es5/stzh-toggle.entry.js +1 -1
  124. package/dist/esm-es5/stzh-upload.entry.js +1 -1
  125. package/dist/esm-es5/utils-68a28fce.js +1 -0
  126. package/dist/stzh-components/assets/fonts.css +5 -5
  127. package/dist/stzh-components/{p-30cb8bc0.system.entry.js → p-006135ed.system.entry.js} +1 -1
  128. package/dist/stzh-components/p-0230004d.system.js +1 -0
  129. package/dist/stzh-components/{p-c6ad1a8c.entry.js → p-03e2634c.entry.js} +1 -1
  130. package/dist/stzh-components/{p-6ec17efc.entry.js → p-04d7b18f.entry.js} +1 -1
  131. package/dist/stzh-components/{p-60b4f34c.system.entry.js → p-07772cd7.system.entry.js} +1 -1
  132. package/dist/stzh-components/{p-82d85c3a.system.entry.js → p-1c88ceff.system.entry.js} +1 -1
  133. package/dist/stzh-components/p-1f57d28e.js +1 -0
  134. package/dist/stzh-components/p-2b11d549.system.entry.js +1 -0
  135. package/dist/stzh-components/{p-07f16263.entry.js → p-32988d74.entry.js} +1 -1
  136. package/dist/stzh-components/{p-cb4a91b7.system.entry.js → p-33946fed.system.entry.js} +1 -1
  137. package/dist/stzh-components/{p-1d914f6c.entry.js → p-34190502.entry.js} +1 -1
  138. package/dist/stzh-components/{p-9e6c25ed.system.entry.js → p-370b82e7.system.entry.js} +1 -1
  139. package/dist/stzh-components/p-3ebd2c03.js +1 -0
  140. package/dist/stzh-components/{p-f544cf3d.entry.js → p-3ed69b16.entry.js} +1 -1
  141. package/dist/stzh-components/{p-e58d3bc7.entry.js → p-409c0d50.entry.js} +1 -1
  142. package/dist/stzh-components/{p-19344366.system.entry.js → p-4a398453.system.entry.js} +1 -1
  143. package/dist/stzh-components/{p-49e37004.entry.js → p-586cae98.entry.js} +1 -1
  144. package/dist/stzh-components/p-5e0cccc9.system.entry.js +1 -0
  145. package/dist/stzh-components/{p-2990206c.system.entry.js → p-5ea652ae.system.entry.js} +1 -1
  146. package/dist/stzh-components/{p-634095bd.system.entry.js → p-68a8b7b7.system.entry.js} +1 -1
  147. package/dist/stzh-components/{p-2f2cb544.system.entry.js → p-6c3b2508.system.entry.js} +1 -1
  148. package/dist/stzh-components/{p-a4100bd8.system.entry.js → p-6fc271d0.system.entry.js} +1 -1
  149. package/dist/stzh-components/p-7921db30.system.entry.js +1 -0
  150. package/dist/stzh-components/p-79bfc485.entry.js +1 -0
  151. package/dist/stzh-components/{p-4cfe83b5.system.entry.js → p-87ab53c4.system.entry.js} +1 -1
  152. package/dist/stzh-components/{p-b1976630.entry.js → p-8a60addb.entry.js} +1 -1
  153. package/dist/stzh-components/{p-298276e4.entry.js → p-8bd3ba06.entry.js} +1 -1
  154. package/dist/stzh-components/{p-0c92ee26.system.entry.js → p-90a10825.system.entry.js} +1 -1
  155. package/dist/stzh-components/{p-c2d58384.entry.js → p-95a297aa.entry.js} +1 -1
  156. package/dist/stzh-components/{p-86d3ce62.entry.js → p-95eb03b2.entry.js} +1 -1
  157. package/dist/stzh-components/p-983f6070.entry.js +1 -0
  158. package/dist/stzh-components/p-a7253852.entry.js +1 -0
  159. package/dist/stzh-components/{p-f8d9411d.system.entry.js → p-a760352a.system.entry.js} +1 -1
  160. package/dist/stzh-components/p-aaa2e48f.system.js +1 -0
  161. package/dist/stzh-components/p-b281b653.entry.js +8 -0
  162. package/dist/stzh-components/p-b35b0270.entry.js +1 -0
  163. package/dist/stzh-components/p-b4fc71ff.system.entry.js +1 -0
  164. package/dist/stzh-components/{p-79ca1ba6.entry.js → p-bb2e1dda.entry.js} +1 -1
  165. package/dist/stzh-components/{p-55188328.entry.js → p-bdba7714.entry.js} +1 -1
  166. package/dist/stzh-components/p-c581e798.system.entry.js +1 -0
  167. package/dist/stzh-components/p-c7c17bb7.system.entry.js +7 -0
  168. package/dist/stzh-components/{p-1ccbd2d6.system.entry.js → p-c863ffd0.system.entry.js} +1 -1
  169. package/dist/stzh-components/{p-3c4478b0.entry.js → p-d8471675.entry.js} +1 -1
  170. package/dist/stzh-components/{p-0433fff9.system.entry.js → p-da063c7e.system.entry.js} +1 -1
  171. package/dist/stzh-components/p-e12db90a.entry.js +1 -0
  172. package/dist/stzh-components/{p-2d0685e3.entry.js → p-ec3d4dd4.entry.js} +1 -1
  173. package/dist/stzh-components/p-ee5ceac4.entry.js +1 -0
  174. package/dist/stzh-components/p-f0ca6848.system.entry.js +1 -0
  175. package/dist/stzh-components/{p-bba52769.system.entry.js → p-f1a58a7c.system.entry.js} +1 -1
  176. package/dist/stzh-components/{p-1bfc1097.entry.js → p-f2050d1e.entry.js} +1 -1
  177. package/dist/stzh-components/{p-ff8a3e96.entry.js → p-f610f725.entry.js} +1 -1
  178. package/dist/stzh-components/p-faf20030.system.js +1 -0
  179. package/dist/stzh-components/{p-f9dc7a9b.entry.js → p-fba76dba.entry.js} +1 -1
  180. package/dist/stzh-components/{p-e987954a.system.entry.js → p-fce0e218.system.entry.js} +1 -1
  181. package/dist/stzh-components/{p-a6486f64.system.entry.js → p-fd16e20e.system.entry.js} +1 -1
  182. package/dist/stzh-components/stzh-components.css +1 -1
  183. package/dist/stzh-components/stzh-components.esm.js +1 -1
  184. package/dist/stzh-components/stzh-components.js +1 -1
  185. package/dist/types/components.d.ts +68 -2
  186. package/dist/types/index.d.ts +1 -0
  187. package/dist/types/utils/utils.d.ts +2 -0
  188. package/dist/vscode-data.json +20 -1
  189. package/package.json +1 -1
  190. package/dist/cjs/utils-d327c19d.js +0 -36
  191. package/dist/esm/utils-904416df.js +0 -33
  192. package/dist/esm-es5/app-globals-70c229e3.js +0 -1
  193. package/dist/esm-es5/utils-904416df.js +0 -1
  194. package/dist/stzh-components/p-043ab41e.system.entry.js +0 -1
  195. package/dist/stzh-components/p-323fdc2f.entry.js +0 -1
  196. package/dist/stzh-components/p-49ea222f.system.entry.js +0 -1
  197. package/dist/stzh-components/p-5f7b72c8.entry.js +0 -1
  198. package/dist/stzh-components/p-5f856307.system.js +0 -1
  199. package/dist/stzh-components/p-6c502e6e.js +0 -1
  200. package/dist/stzh-components/p-6ea5c23d.system.entry.js +0 -7
  201. package/dist/stzh-components/p-7279af4a.system.entry.js +0 -1
  202. package/dist/stzh-components/p-8462ba57.entry.js +0 -1
  203. package/dist/stzh-components/p-88bef2cd.entry.js +0 -1
  204. package/dist/stzh-components/p-a7c3b41a.entry.js +0 -1
  205. package/dist/stzh-components/p-aa4e28cc.system.js +0 -1
  206. package/dist/stzh-components/p-ac1da083.system.js +0 -1
  207. package/dist/stzh-components/p-b63d6ded.system.entry.js +0 -1
  208. package/dist/stzh-components/p-bcade28e.entry.js +0 -1
  209. package/dist/stzh-components/p-be21cebd.js +0 -1
  210. package/dist/stzh-components/p-d04e8743.system.entry.js +0 -1
  211. package/dist/stzh-components/p-d8819b74.system.entry.js +0 -1
  212. package/dist/stzh-components/p-e048de42.entry.js +0 -8
@@ -0,0 +1,3791 @@
1
+ /**!
2
+ * Sortable 1.15.0
3
+ * @author RubaXa <trash@rubaxa.org>
4
+ * @author owenm <owen23355@gmail.com>
5
+ * @license MIT
6
+ */
7
+
8
+ function ownKeys(object, enumerableOnly) {
9
+ var keys = Object.keys(object);
10
+
11
+ if (Object.getOwnPropertySymbols) {
12
+ var symbols = Object.getOwnPropertySymbols(object);
13
+
14
+ if (enumerableOnly) {
15
+ symbols = symbols.filter(function (sym) {
16
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
17
+ });
18
+ }
19
+
20
+ keys.push.apply(keys, symbols);
21
+ }
22
+
23
+ return keys;
24
+ }
25
+
26
+ function _objectSpread2(target) {
27
+ for (var i = 1; i < arguments.length; i++) {
28
+ var source = arguments[i] != null ? arguments[i] : {};
29
+
30
+ if (i % 2) {
31
+ ownKeys(Object(source), true).forEach(function (key) {
32
+ _defineProperty(target, key, source[key]);
33
+ });
34
+ } else if (Object.getOwnPropertyDescriptors) {
35
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
36
+ } else {
37
+ ownKeys(Object(source)).forEach(function (key) {
38
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
39
+ });
40
+ }
41
+ }
42
+
43
+ return target;
44
+ }
45
+
46
+ function _typeof(obj) {
47
+ "@babel/helpers - typeof";
48
+
49
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
50
+ _typeof = function (obj) {
51
+ return typeof obj;
52
+ };
53
+ } else {
54
+ _typeof = function (obj) {
55
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
56
+ };
57
+ }
58
+
59
+ return _typeof(obj);
60
+ }
61
+
62
+ function _defineProperty(obj, key, value) {
63
+ if (key in obj) {
64
+ Object.defineProperty(obj, key, {
65
+ value: value,
66
+ enumerable: true,
67
+ configurable: true,
68
+ writable: true
69
+ });
70
+ } else {
71
+ obj[key] = value;
72
+ }
73
+
74
+ return obj;
75
+ }
76
+
77
+ function _extends() {
78
+ _extends = Object.assign || function (target) {
79
+ for (var i = 1; i < arguments.length; i++) {
80
+ var source = arguments[i];
81
+
82
+ for (var key in source) {
83
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
84
+ target[key] = source[key];
85
+ }
86
+ }
87
+ }
88
+
89
+ return target;
90
+ };
91
+
92
+ return _extends.apply(this, arguments);
93
+ }
94
+
95
+ function _objectWithoutPropertiesLoose(source, excluded) {
96
+ if (source == null) return {};
97
+ var target = {};
98
+ var sourceKeys = Object.keys(source);
99
+ var key, i;
100
+
101
+ for (i = 0; i < sourceKeys.length; i++) {
102
+ key = sourceKeys[i];
103
+ if (excluded.indexOf(key) >= 0) continue;
104
+ target[key] = source[key];
105
+ }
106
+
107
+ return target;
108
+ }
109
+
110
+ function _objectWithoutProperties(source, excluded) {
111
+ if (source == null) return {};
112
+
113
+ var target = _objectWithoutPropertiesLoose(source, excluded);
114
+
115
+ var key, i;
116
+
117
+ if (Object.getOwnPropertySymbols) {
118
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
119
+
120
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
121
+ key = sourceSymbolKeys[i];
122
+ if (excluded.indexOf(key) >= 0) continue;
123
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
124
+ target[key] = source[key];
125
+ }
126
+ }
127
+
128
+ return target;
129
+ }
130
+
131
+ function _toConsumableArray(arr) {
132
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
133
+ }
134
+
135
+ function _arrayWithoutHoles(arr) {
136
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
137
+ }
138
+
139
+ function _iterableToArray(iter) {
140
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
141
+ }
142
+
143
+ function _unsupportedIterableToArray(o, minLen) {
144
+ if (!o) return;
145
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
146
+ var n = Object.prototype.toString.call(o).slice(8, -1);
147
+ if (n === "Object" && o.constructor) n = o.constructor.name;
148
+ if (n === "Map" || n === "Set") return Array.from(o);
149
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
150
+ }
151
+
152
+ function _arrayLikeToArray(arr, len) {
153
+ if (len == null || len > arr.length) len = arr.length;
154
+
155
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
156
+
157
+ return arr2;
158
+ }
159
+
160
+ function _nonIterableSpread() {
161
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
162
+ }
163
+
164
+ var version = "1.15.0";
165
+
166
+ function userAgent(pattern) {
167
+ if (typeof window !== 'undefined' && window.navigator) {
168
+ return !! /*@__PURE__*/navigator.userAgent.match(pattern);
169
+ }
170
+ }
171
+
172
+ var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
173
+ var Edge = userAgent(/Edge/i);
174
+ var FireFox = userAgent(/firefox/i);
175
+ var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
176
+ var IOS = userAgent(/iP(ad|od|hone)/i);
177
+ var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
178
+
179
+ var captureMode = {
180
+ capture: false,
181
+ passive: false
182
+ };
183
+
184
+ function on(el, event, fn) {
185
+ el.addEventListener(event, fn, !IE11OrLess && captureMode);
186
+ }
187
+
188
+ function off(el, event, fn) {
189
+ el.removeEventListener(event, fn, !IE11OrLess && captureMode);
190
+ }
191
+
192
+ function matches(
193
+ /**HTMLElement*/
194
+ el,
195
+ /**String*/
196
+ selector) {
197
+ if (!selector) return;
198
+ selector[0] === '>' && (selector = selector.substring(1));
199
+
200
+ if (el) {
201
+ try {
202
+ if (el.matches) {
203
+ return el.matches(selector);
204
+ } else if (el.msMatchesSelector) {
205
+ return el.msMatchesSelector(selector);
206
+ } else if (el.webkitMatchesSelector) {
207
+ return el.webkitMatchesSelector(selector);
208
+ }
209
+ } catch (_) {
210
+ return false;
211
+ }
212
+ }
213
+
214
+ return false;
215
+ }
216
+
217
+ function getParentOrHost(el) {
218
+ return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
219
+ }
220
+
221
+ function closest(
222
+ /**HTMLElement*/
223
+ el,
224
+ /**String*/
225
+ selector,
226
+ /**HTMLElement*/
227
+ ctx, includeCTX) {
228
+ if (el) {
229
+ ctx = ctx || document;
230
+
231
+ do {
232
+ if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
233
+ return el;
234
+ }
235
+
236
+ if (el === ctx) break;
237
+ /* jshint boss:true */
238
+ } while (el = getParentOrHost(el));
239
+ }
240
+
241
+ return null;
242
+ }
243
+
244
+ var R_SPACE = /\s+/g;
245
+
246
+ function toggleClass(el, name, state) {
247
+ if (el && name) {
248
+ if (el.classList) {
249
+ el.classList[state ? 'add' : 'remove'](name);
250
+ } else {
251
+ var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
252
+ el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
253
+ }
254
+ }
255
+ }
256
+
257
+ function css(el, prop, val) {
258
+ var style = el && el.style;
259
+
260
+ if (style) {
261
+ if (val === void 0) {
262
+ if (document.defaultView && document.defaultView.getComputedStyle) {
263
+ val = document.defaultView.getComputedStyle(el, '');
264
+ } else if (el.currentStyle) {
265
+ val = el.currentStyle;
266
+ }
267
+
268
+ return prop === void 0 ? val : val[prop];
269
+ } else {
270
+ if (!(prop in style) && prop.indexOf('webkit') === -1) {
271
+ prop = '-webkit-' + prop;
272
+ }
273
+
274
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
275
+ }
276
+ }
277
+ }
278
+
279
+ function matrix(el, selfOnly) {
280
+ var appliedTransforms = '';
281
+
282
+ if (typeof el === 'string') {
283
+ appliedTransforms = el;
284
+ } else {
285
+ do {
286
+ var transform = css(el, 'transform');
287
+
288
+ if (transform && transform !== 'none') {
289
+ appliedTransforms = transform + ' ' + appliedTransforms;
290
+ }
291
+ /* jshint boss:true */
292
+
293
+ } while (!selfOnly && (el = el.parentNode));
294
+ }
295
+
296
+ var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
297
+ /*jshint -W056 */
298
+
299
+ return matrixFn && new matrixFn(appliedTransforms);
300
+ }
301
+
302
+ function find(ctx, tagName, iterator) {
303
+ if (ctx) {
304
+ var list = ctx.getElementsByTagName(tagName),
305
+ i = 0,
306
+ n = list.length;
307
+
308
+ if (iterator) {
309
+ for (; i < n; i++) {
310
+ iterator(list[i], i);
311
+ }
312
+ }
313
+
314
+ return list;
315
+ }
316
+
317
+ return [];
318
+ }
319
+
320
+ function getWindowScrollingElement() {
321
+ var scrollingElement = document.scrollingElement;
322
+
323
+ if (scrollingElement) {
324
+ return scrollingElement;
325
+ } else {
326
+ return document.documentElement;
327
+ }
328
+ }
329
+ /**
330
+ * Returns the "bounding client rect" of given element
331
+ * @param {HTMLElement} el The element whose boundingClientRect is wanted
332
+ * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
333
+ * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
334
+ * @param {[Boolean]} undoScale Whether the container's scale() should be undone
335
+ * @param {[HTMLElement]} container The parent the element will be placed in
336
+ * @return {Object} The boundingClientRect of el, with specified adjustments
337
+ */
338
+
339
+
340
+ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
341
+ if (!el.getBoundingClientRect && el !== window) return;
342
+ var elRect, top, left, bottom, right, height, width;
343
+
344
+ if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
345
+ elRect = el.getBoundingClientRect();
346
+ top = elRect.top;
347
+ left = elRect.left;
348
+ bottom = elRect.bottom;
349
+ right = elRect.right;
350
+ height = elRect.height;
351
+ width = elRect.width;
352
+ } else {
353
+ top = 0;
354
+ left = 0;
355
+ bottom = window.innerHeight;
356
+ right = window.innerWidth;
357
+ height = window.innerHeight;
358
+ width = window.innerWidth;
359
+ }
360
+
361
+ if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
362
+ // Adjust for translate()
363
+ container = container || el.parentNode; // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
364
+ // Not needed on <= IE11
365
+
366
+ if (!IE11OrLess) {
367
+ do {
368
+ if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
369
+ var containerRect = container.getBoundingClientRect(); // Set relative to edges of padding box of container
370
+
371
+ top -= containerRect.top + parseInt(css(container, 'border-top-width'));
372
+ left -= containerRect.left + parseInt(css(container, 'border-left-width'));
373
+ bottom = top + elRect.height;
374
+ right = left + elRect.width;
375
+ break;
376
+ }
377
+ /* jshint boss:true */
378
+
379
+ } while (container = container.parentNode);
380
+ }
381
+ }
382
+
383
+ if (undoScale && el !== window) {
384
+ // Adjust for scale()
385
+ var elMatrix = matrix(container || el),
386
+ scaleX = elMatrix && elMatrix.a,
387
+ scaleY = elMatrix && elMatrix.d;
388
+
389
+ if (elMatrix) {
390
+ top /= scaleY;
391
+ left /= scaleX;
392
+ width /= scaleX;
393
+ height /= scaleY;
394
+ bottom = top + height;
395
+ right = left + width;
396
+ }
397
+ }
398
+
399
+ return {
400
+ top: top,
401
+ left: left,
402
+ bottom: bottom,
403
+ right: right,
404
+ width: width,
405
+ height: height
406
+ };
407
+ }
408
+ /**
409
+ * Checks if a side of an element is scrolled past a side of its parents
410
+ * @param {HTMLElement} el The element who's side being scrolled out of view is in question
411
+ * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
412
+ * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
413
+ * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
414
+ */
415
+
416
+
417
+ function isScrolledPast(el, elSide, parentSide) {
418
+ var parent = getParentAutoScrollElement(el, true),
419
+ elSideVal = getRect(el)[elSide];
420
+ /* jshint boss:true */
421
+
422
+ while (parent) {
423
+ var parentSideVal = getRect(parent)[parentSide],
424
+ visible = void 0;
425
+
426
+ if (parentSide === 'top' || parentSide === 'left') {
427
+ visible = elSideVal >= parentSideVal;
428
+ } else {
429
+ visible = elSideVal <= parentSideVal;
430
+ }
431
+
432
+ if (!visible) return parent;
433
+ if (parent === getWindowScrollingElement()) break;
434
+ parent = getParentAutoScrollElement(parent, false);
435
+ }
436
+
437
+ return false;
438
+ }
439
+ /**
440
+ * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
441
+ * and non-draggable elements
442
+ * @param {HTMLElement} el The parent element
443
+ * @param {Number} childNum The index of the child
444
+ * @param {Object} options Parent Sortable's options
445
+ * @return {HTMLElement} The child at index childNum, or null if not found
446
+ */
447
+
448
+
449
+ function getChild(el, childNum, options, includeDragEl) {
450
+ var currentChild = 0,
451
+ i = 0,
452
+ children = el.children;
453
+
454
+ while (i < children.length) {
455
+ if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
456
+ if (currentChild === childNum) {
457
+ return children[i];
458
+ }
459
+
460
+ currentChild++;
461
+ }
462
+
463
+ i++;
464
+ }
465
+
466
+ return null;
467
+ }
468
+ /**
469
+ * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
470
+ * @param {HTMLElement} el Parent element
471
+ * @param {selector} selector Any other elements that should be ignored
472
+ * @return {HTMLElement} The last child, ignoring ghostEl
473
+ */
474
+
475
+
476
+ function lastChild(el, selector) {
477
+ var last = el.lastElementChild;
478
+
479
+ while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
480
+ last = last.previousElementSibling;
481
+ }
482
+
483
+ return last || null;
484
+ }
485
+ /**
486
+ * Returns the index of an element within its parent for a selected set of
487
+ * elements
488
+ * @param {HTMLElement} el
489
+ * @param {selector} selector
490
+ * @return {number}
491
+ */
492
+
493
+
494
+ function index(el, selector) {
495
+ var index = 0;
496
+
497
+ if (!el || !el.parentNode) {
498
+ return -1;
499
+ }
500
+ /* jshint boss:true */
501
+
502
+
503
+ while (el = el.previousElementSibling) {
504
+ if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
505
+ index++;
506
+ }
507
+ }
508
+
509
+ return index;
510
+ }
511
+ /**
512
+ * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
513
+ * The value is returned in real pixels.
514
+ * @param {HTMLElement} el
515
+ * @return {Array} Offsets in the format of [left, top]
516
+ */
517
+
518
+
519
+ function getRelativeScrollOffset(el) {
520
+ var offsetLeft = 0,
521
+ offsetTop = 0,
522
+ winScroller = getWindowScrollingElement();
523
+
524
+ if (el) {
525
+ do {
526
+ var elMatrix = matrix(el),
527
+ scaleX = elMatrix.a,
528
+ scaleY = elMatrix.d;
529
+ offsetLeft += el.scrollLeft * scaleX;
530
+ offsetTop += el.scrollTop * scaleY;
531
+ } while (el !== winScroller && (el = el.parentNode));
532
+ }
533
+
534
+ return [offsetLeft, offsetTop];
535
+ }
536
+ /**
537
+ * Returns the index of the object within the given array
538
+ * @param {Array} arr Array that may or may not hold the object
539
+ * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
540
+ * @return {Number} The index of the object in the array, or -1
541
+ */
542
+
543
+
544
+ function indexOfObject(arr, obj) {
545
+ for (var i in arr) {
546
+ if (!arr.hasOwnProperty(i)) continue;
547
+
548
+ for (var key in obj) {
549
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
550
+ }
551
+ }
552
+
553
+ return -1;
554
+ }
555
+
556
+ function getParentAutoScrollElement(el, includeSelf) {
557
+ // skip to window
558
+ if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
559
+ var elem = el;
560
+ var gotSelf = false;
561
+
562
+ do {
563
+ // we don't need to get elem css if it isn't even overflowing in the first place (performance)
564
+ if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
565
+ var elemCSS = css(elem);
566
+
567
+ if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
568
+ if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
569
+ if (gotSelf || includeSelf) return elem;
570
+ gotSelf = true;
571
+ }
572
+ }
573
+ /* jshint boss:true */
574
+
575
+ } while (elem = elem.parentNode);
576
+
577
+ return getWindowScrollingElement();
578
+ }
579
+
580
+ function extend(dst, src) {
581
+ if (dst && src) {
582
+ for (var key in src) {
583
+ if (src.hasOwnProperty(key)) {
584
+ dst[key] = src[key];
585
+ }
586
+ }
587
+ }
588
+
589
+ return dst;
590
+ }
591
+
592
+ function isRectEqual(rect1, rect2) {
593
+ return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
594
+ }
595
+
596
+ var _throttleTimeout;
597
+
598
+ function throttle(callback, ms) {
599
+ return function () {
600
+ if (!_throttleTimeout) {
601
+ var args = arguments,
602
+ _this = this;
603
+
604
+ if (args.length === 1) {
605
+ callback.call(_this, args[0]);
606
+ } else {
607
+ callback.apply(_this, args);
608
+ }
609
+
610
+ _throttleTimeout = setTimeout(function () {
611
+ _throttleTimeout = void 0;
612
+ }, ms);
613
+ }
614
+ };
615
+ }
616
+
617
+ function cancelThrottle() {
618
+ clearTimeout(_throttleTimeout);
619
+ _throttleTimeout = void 0;
620
+ }
621
+
622
+ function scrollBy(el, x, y) {
623
+ el.scrollLeft += x;
624
+ el.scrollTop += y;
625
+ }
626
+
627
+ function clone(el) {
628
+ var Polymer = window.Polymer;
629
+ var $ = window.jQuery || window.Zepto;
630
+
631
+ if (Polymer && Polymer.dom) {
632
+ return Polymer.dom(el).cloneNode(true);
633
+ } else if ($) {
634
+ return $(el).clone(true)[0];
635
+ } else {
636
+ return el.cloneNode(true);
637
+ }
638
+ }
639
+
640
+ function setRect(el, rect) {
641
+ css(el, 'position', 'absolute');
642
+ css(el, 'top', rect.top);
643
+ css(el, 'left', rect.left);
644
+ css(el, 'width', rect.width);
645
+ css(el, 'height', rect.height);
646
+ }
647
+
648
+ function unsetRect(el) {
649
+ css(el, 'position', '');
650
+ css(el, 'top', '');
651
+ css(el, 'left', '');
652
+ css(el, 'width', '');
653
+ css(el, 'height', '');
654
+ }
655
+
656
+ var expando = 'Sortable' + new Date().getTime();
657
+
658
+ function AnimationStateManager() {
659
+ var animationStates = [],
660
+ animationCallbackId;
661
+ return {
662
+ captureAnimationState: function captureAnimationState() {
663
+ animationStates = [];
664
+ if (!this.options.animation) return;
665
+ var children = [].slice.call(this.el.children);
666
+ children.forEach(function (child) {
667
+ if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
668
+ animationStates.push({
669
+ target: child,
670
+ rect: getRect(child)
671
+ });
672
+
673
+ var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect); // If animating: compensate for current animation
674
+
675
+
676
+ if (child.thisAnimationDuration) {
677
+ var childMatrix = matrix(child, true);
678
+
679
+ if (childMatrix) {
680
+ fromRect.top -= childMatrix.f;
681
+ fromRect.left -= childMatrix.e;
682
+ }
683
+ }
684
+
685
+ child.fromRect = fromRect;
686
+ });
687
+ },
688
+ addAnimationState: function addAnimationState(state) {
689
+ animationStates.push(state);
690
+ },
691
+ removeAnimationState: function removeAnimationState(target) {
692
+ animationStates.splice(indexOfObject(animationStates, {
693
+ target: target
694
+ }), 1);
695
+ },
696
+ animateAll: function animateAll(callback) {
697
+ var _this = this;
698
+
699
+ if (!this.options.animation) {
700
+ clearTimeout(animationCallbackId);
701
+ if (typeof callback === 'function') callback();
702
+ return;
703
+ }
704
+
705
+ var animating = false,
706
+ animationTime = 0;
707
+ animationStates.forEach(function (state) {
708
+ var time = 0,
709
+ target = state.target,
710
+ fromRect = target.fromRect,
711
+ toRect = getRect(target),
712
+ prevFromRect = target.prevFromRect,
713
+ prevToRect = target.prevToRect,
714
+ animatingRect = state.rect,
715
+ targetMatrix = matrix(target, true);
716
+
717
+ if (targetMatrix) {
718
+ // Compensate for current animation
719
+ toRect.top -= targetMatrix.f;
720
+ toRect.left -= targetMatrix.e;
721
+ }
722
+
723
+ target.toRect = toRect;
724
+
725
+ if (target.thisAnimationDuration) {
726
+ // Could also check if animatingRect is between fromRect and toRect
727
+ if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && // Make sure animatingRect is on line between toRect & fromRect
728
+ (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
729
+ // If returning to same place as started from animation and on same axis
730
+ time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
731
+ }
732
+ } // if fromRect != toRect: animate
733
+
734
+
735
+ if (!isRectEqual(toRect, fromRect)) {
736
+ target.prevFromRect = fromRect;
737
+ target.prevToRect = toRect;
738
+
739
+ if (!time) {
740
+ time = _this.options.animation;
741
+ }
742
+
743
+ _this.animate(target, animatingRect, toRect, time);
744
+ }
745
+
746
+ if (time) {
747
+ animating = true;
748
+ animationTime = Math.max(animationTime, time);
749
+ clearTimeout(target.animationResetTimer);
750
+ target.animationResetTimer = setTimeout(function () {
751
+ target.animationTime = 0;
752
+ target.prevFromRect = null;
753
+ target.fromRect = null;
754
+ target.prevToRect = null;
755
+ target.thisAnimationDuration = null;
756
+ }, time);
757
+ target.thisAnimationDuration = time;
758
+ }
759
+ });
760
+ clearTimeout(animationCallbackId);
761
+
762
+ if (!animating) {
763
+ if (typeof callback === 'function') callback();
764
+ } else {
765
+ animationCallbackId = setTimeout(function () {
766
+ if (typeof callback === 'function') callback();
767
+ }, animationTime);
768
+ }
769
+
770
+ animationStates = [];
771
+ },
772
+ animate: function animate(target, currentRect, toRect, duration) {
773
+ if (duration) {
774
+ css(target, 'transition', '');
775
+ css(target, 'transform', '');
776
+ var elMatrix = matrix(this.el),
777
+ scaleX = elMatrix && elMatrix.a,
778
+ scaleY = elMatrix && elMatrix.d,
779
+ translateX = (currentRect.left - toRect.left) / (scaleX || 1),
780
+ translateY = (currentRect.top - toRect.top) / (scaleY || 1);
781
+ target.animatingX = !!translateX;
782
+ target.animatingY = !!translateY;
783
+ css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
784
+ this.forRepaintDummy = repaint(target); // repaint
785
+
786
+ css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
787
+ css(target, 'transform', 'translate3d(0,0,0)');
788
+ typeof target.animated === 'number' && clearTimeout(target.animated);
789
+ target.animated = setTimeout(function () {
790
+ css(target, 'transition', '');
791
+ css(target, 'transform', '');
792
+ target.animated = false;
793
+ target.animatingX = false;
794
+ target.animatingY = false;
795
+ }, duration);
796
+ }
797
+ }
798
+ };
799
+ }
800
+
801
+ function repaint(target) {
802
+ return target.offsetWidth;
803
+ }
804
+
805
+ function calculateRealTime(animatingRect, fromRect, toRect, options) {
806
+ return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
807
+ }
808
+
809
+ var plugins = [];
810
+ var defaults = {
811
+ initializeByDefault: true
812
+ };
813
+ var PluginManager = {
814
+ mount: function mount(plugin) {
815
+ // Set default static properties
816
+ for (var option in defaults) {
817
+ if (defaults.hasOwnProperty(option) && !(option in plugin)) {
818
+ plugin[option] = defaults[option];
819
+ }
820
+ }
821
+
822
+ plugins.forEach(function (p) {
823
+ if (p.pluginName === plugin.pluginName) {
824
+ throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
825
+ }
826
+ });
827
+ plugins.push(plugin);
828
+ },
829
+ pluginEvent: function pluginEvent(eventName, sortable, evt) {
830
+ var _this = this;
831
+
832
+ this.eventCanceled = false;
833
+
834
+ evt.cancel = function () {
835
+ _this.eventCanceled = true;
836
+ };
837
+
838
+ var eventNameGlobal = eventName + 'Global';
839
+ plugins.forEach(function (plugin) {
840
+ if (!sortable[plugin.pluginName]) return; // Fire global events if it exists in this sortable
841
+
842
+ if (sortable[plugin.pluginName][eventNameGlobal]) {
843
+ sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
844
+ sortable: sortable
845
+ }, evt));
846
+ } // Only fire plugin event if plugin is enabled in this sortable,
847
+ // and plugin has event defined
848
+
849
+
850
+ if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
851
+ sortable[plugin.pluginName][eventName](_objectSpread2({
852
+ sortable: sortable
853
+ }, evt));
854
+ }
855
+ });
856
+ },
857
+ initializePlugins: function initializePlugins(sortable, el, defaults, options) {
858
+ plugins.forEach(function (plugin) {
859
+ var pluginName = plugin.pluginName;
860
+ if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
861
+ var initialized = new plugin(sortable, el, sortable.options);
862
+ initialized.sortable = sortable;
863
+ initialized.options = sortable.options;
864
+ sortable[pluginName] = initialized; // Add default options from plugin
865
+
866
+ _extends(defaults, initialized.defaults);
867
+ });
868
+
869
+ for (var option in sortable.options) {
870
+ if (!sortable.options.hasOwnProperty(option)) continue;
871
+ var modified = this.modifyOption(sortable, option, sortable.options[option]);
872
+
873
+ if (typeof modified !== 'undefined') {
874
+ sortable.options[option] = modified;
875
+ }
876
+ }
877
+ },
878
+ getEventProperties: function getEventProperties(name, sortable) {
879
+ var eventProperties = {};
880
+ plugins.forEach(function (plugin) {
881
+ if (typeof plugin.eventProperties !== 'function') return;
882
+
883
+ _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
884
+ });
885
+ return eventProperties;
886
+ },
887
+ modifyOption: function modifyOption(sortable, name, value) {
888
+ var modifiedValue;
889
+ plugins.forEach(function (plugin) {
890
+ // Plugin must exist on the Sortable
891
+ if (!sortable[plugin.pluginName]) return; // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
892
+
893
+ if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
894
+ modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
895
+ }
896
+ });
897
+ return modifiedValue;
898
+ }
899
+ };
900
+
901
+ function dispatchEvent(_ref) {
902
+ var sortable = _ref.sortable,
903
+ rootEl = _ref.rootEl,
904
+ name = _ref.name,
905
+ targetEl = _ref.targetEl,
906
+ cloneEl = _ref.cloneEl,
907
+ toEl = _ref.toEl,
908
+ fromEl = _ref.fromEl,
909
+ oldIndex = _ref.oldIndex,
910
+ newIndex = _ref.newIndex,
911
+ oldDraggableIndex = _ref.oldDraggableIndex,
912
+ newDraggableIndex = _ref.newDraggableIndex,
913
+ originalEvent = _ref.originalEvent,
914
+ putSortable = _ref.putSortable,
915
+ extraEventProperties = _ref.extraEventProperties;
916
+ sortable = sortable || rootEl && rootEl[expando];
917
+ if (!sortable) return;
918
+ var evt,
919
+ options = sortable.options,
920
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); // Support for new CustomEvent feature
921
+
922
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
923
+ evt = new CustomEvent(name, {
924
+ bubbles: true,
925
+ cancelable: true
926
+ });
927
+ } else {
928
+ evt = document.createEvent('Event');
929
+ evt.initEvent(name, true, true);
930
+ }
931
+
932
+ evt.to = toEl || rootEl;
933
+ evt.from = fromEl || rootEl;
934
+ evt.item = targetEl || rootEl;
935
+ evt.clone = cloneEl;
936
+ evt.oldIndex = oldIndex;
937
+ evt.newIndex = newIndex;
938
+ evt.oldDraggableIndex = oldDraggableIndex;
939
+ evt.newDraggableIndex = newDraggableIndex;
940
+ evt.originalEvent = originalEvent;
941
+ evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
942
+
943
+ var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
944
+
945
+ for (var option in allEventProperties) {
946
+ evt[option] = allEventProperties[option];
947
+ }
948
+
949
+ if (rootEl) {
950
+ rootEl.dispatchEvent(evt);
951
+ }
952
+
953
+ if (options[onName]) {
954
+ options[onName].call(sortable, evt);
955
+ }
956
+ }
957
+
958
+ var _excluded = ["evt"];
959
+
960
+ var pluginEvent = function pluginEvent(eventName, sortable) {
961
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
962
+ originalEvent = _ref.evt,
963
+ data = _objectWithoutProperties(_ref, _excluded);
964
+
965
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
966
+ dragEl: dragEl,
967
+ parentEl: parentEl,
968
+ ghostEl: ghostEl,
969
+ rootEl: rootEl,
970
+ nextEl: nextEl,
971
+ lastDownEl: lastDownEl,
972
+ cloneEl: cloneEl,
973
+ cloneHidden: cloneHidden,
974
+ dragStarted: moved,
975
+ putSortable: putSortable,
976
+ activeSortable: Sortable.active,
977
+ originalEvent: originalEvent,
978
+ oldIndex: oldIndex,
979
+ oldDraggableIndex: oldDraggableIndex,
980
+ newIndex: newIndex,
981
+ newDraggableIndex: newDraggableIndex,
982
+ hideGhostForTarget: _hideGhostForTarget,
983
+ unhideGhostForTarget: _unhideGhostForTarget,
984
+ cloneNowHidden: function cloneNowHidden() {
985
+ cloneHidden = true;
986
+ },
987
+ cloneNowShown: function cloneNowShown() {
988
+ cloneHidden = false;
989
+ },
990
+ dispatchSortableEvent: function dispatchSortableEvent(name) {
991
+ _dispatchEvent({
992
+ sortable: sortable,
993
+ name: name,
994
+ originalEvent: originalEvent
995
+ });
996
+ }
997
+ }, data));
998
+ };
999
+
1000
+ function _dispatchEvent(info) {
1001
+ dispatchEvent(_objectSpread2({
1002
+ putSortable: putSortable,
1003
+ cloneEl: cloneEl,
1004
+ targetEl: dragEl,
1005
+ rootEl: rootEl,
1006
+ oldIndex: oldIndex,
1007
+ oldDraggableIndex: oldDraggableIndex,
1008
+ newIndex: newIndex,
1009
+ newDraggableIndex: newDraggableIndex
1010
+ }, info));
1011
+ }
1012
+
1013
+ var dragEl,
1014
+ parentEl,
1015
+ ghostEl,
1016
+ rootEl,
1017
+ nextEl,
1018
+ lastDownEl,
1019
+ cloneEl,
1020
+ cloneHidden,
1021
+ oldIndex,
1022
+ newIndex,
1023
+ oldDraggableIndex,
1024
+ newDraggableIndex,
1025
+ activeGroup,
1026
+ putSortable,
1027
+ awaitingDragStarted = false,
1028
+ ignoreNextClick = false,
1029
+ sortables = [],
1030
+ tapEvt,
1031
+ touchEvt,
1032
+ lastDx,
1033
+ lastDy,
1034
+ tapDistanceLeft,
1035
+ tapDistanceTop,
1036
+ moved,
1037
+ lastTarget,
1038
+ lastDirection,
1039
+ pastFirstInvertThresh = false,
1040
+ isCircumstantialInvert = false,
1041
+ targetMoveDistance,
1042
+ // For positioning ghost absolutely
1043
+ ghostRelativeParent,
1044
+ ghostRelativeParentInitialScroll = [],
1045
+ // (left, top)
1046
+ _silent = false,
1047
+ savedInputChecked = [];
1048
+ /** @const */
1049
+
1050
+ var documentExists = typeof document !== 'undefined',
1051
+ PositionGhostAbsolutely = IOS,
1052
+ CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
1053
+ // This will not pass for IE9, because IE9 DnD only works on anchors
1054
+ supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
1055
+ supportCssPointerEvents = function () {
1056
+ if (!documentExists) return; // false when <= IE11
1057
+
1058
+ if (IE11OrLess) {
1059
+ return false;
1060
+ }
1061
+
1062
+ var el = document.createElement('x');
1063
+ el.style.cssText = 'pointer-events:auto';
1064
+ return el.style.pointerEvents === 'auto';
1065
+ }(),
1066
+ _detectDirection = function _detectDirection(el, options) {
1067
+ var elCSS = css(el),
1068
+ elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
1069
+ child1 = getChild(el, 0, options),
1070
+ child2 = getChild(el, 1, options),
1071
+ firstChildCSS = child1 && css(child1),
1072
+ secondChildCSS = child2 && css(child2),
1073
+ firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
1074
+ secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
1075
+
1076
+ if (elCSS.display === 'flex') {
1077
+ return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
1078
+ }
1079
+
1080
+ if (elCSS.display === 'grid') {
1081
+ return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
1082
+ }
1083
+
1084
+ if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
1085
+ var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
1086
+ return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
1087
+ }
1088
+
1089
+ return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
1090
+ },
1091
+ _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
1092
+ var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
1093
+ dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
1094
+ dragElOppLength = vertical ? dragRect.width : dragRect.height,
1095
+ targetS1Opp = vertical ? targetRect.left : targetRect.top,
1096
+ targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
1097
+ targetOppLength = vertical ? targetRect.width : targetRect.height;
1098
+ return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
1099
+ },
1100
+
1101
+ /**
1102
+ * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
1103
+ * @param {Number} x X position
1104
+ * @param {Number} y Y position
1105
+ * @return {HTMLElement} Element of the first found nearest Sortable
1106
+ */
1107
+ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
1108
+ var ret;
1109
+ sortables.some(function (sortable) {
1110
+ var threshold = sortable[expando].options.emptyInsertThreshold;
1111
+ if (!threshold || lastChild(sortable)) return;
1112
+ var rect = getRect(sortable),
1113
+ insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
1114
+ insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
1115
+
1116
+ if (insideHorizontally && insideVertically) {
1117
+ return ret = sortable;
1118
+ }
1119
+ });
1120
+ return ret;
1121
+ },
1122
+ _prepareGroup = function _prepareGroup(options) {
1123
+ function toFn(value, pull) {
1124
+ return function (to, from, dragEl, evt) {
1125
+ var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
1126
+
1127
+ if (value == null && (pull || sameGroup)) {
1128
+ // Default pull value
1129
+ // Default pull and put value if same group
1130
+ return true;
1131
+ } else if (value == null || value === false) {
1132
+ return false;
1133
+ } else if (pull && value === 'clone') {
1134
+ return value;
1135
+ } else if (typeof value === 'function') {
1136
+ return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
1137
+ } else {
1138
+ var otherGroup = (pull ? to : from).options.group.name;
1139
+ return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
1140
+ }
1141
+ };
1142
+ }
1143
+
1144
+ var group = {};
1145
+ var originalGroup = options.group;
1146
+
1147
+ if (!originalGroup || _typeof(originalGroup) != 'object') {
1148
+ originalGroup = {
1149
+ name: originalGroup
1150
+ };
1151
+ }
1152
+
1153
+ group.name = originalGroup.name;
1154
+ group.checkPull = toFn(originalGroup.pull, true);
1155
+ group.checkPut = toFn(originalGroup.put);
1156
+ group.revertClone = originalGroup.revertClone;
1157
+ options.group = group;
1158
+ },
1159
+ _hideGhostForTarget = function _hideGhostForTarget() {
1160
+ if (!supportCssPointerEvents && ghostEl) {
1161
+ css(ghostEl, 'display', 'none');
1162
+ }
1163
+ },
1164
+ _unhideGhostForTarget = function _unhideGhostForTarget() {
1165
+ if (!supportCssPointerEvents && ghostEl) {
1166
+ css(ghostEl, 'display', '');
1167
+ }
1168
+ }; // #1184 fix - Prevent click event on fallback if dragged but item not changed position
1169
+
1170
+
1171
+ if (documentExists && !ChromeForAndroid) {
1172
+ document.addEventListener('click', function (evt) {
1173
+ if (ignoreNextClick) {
1174
+ evt.preventDefault();
1175
+ evt.stopPropagation && evt.stopPropagation();
1176
+ evt.stopImmediatePropagation && evt.stopImmediatePropagation();
1177
+ ignoreNextClick = false;
1178
+ return false;
1179
+ }
1180
+ }, true);
1181
+ }
1182
+
1183
+ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
1184
+ if (dragEl) {
1185
+ evt = evt.touches ? evt.touches[0] : evt;
1186
+
1187
+ var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
1188
+
1189
+ if (nearest) {
1190
+ // Create imitation event
1191
+ var event = {};
1192
+
1193
+ for (var i in evt) {
1194
+ if (evt.hasOwnProperty(i)) {
1195
+ event[i] = evt[i];
1196
+ }
1197
+ }
1198
+
1199
+ event.target = event.rootEl = nearest;
1200
+ event.preventDefault = void 0;
1201
+ event.stopPropagation = void 0;
1202
+
1203
+ nearest[expando]._onDragOver(event);
1204
+ }
1205
+ }
1206
+ };
1207
+
1208
+ var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1209
+ if (dragEl) {
1210
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1211
+ }
1212
+ };
1213
+ /**
1214
+ * @class Sortable
1215
+ * @param {HTMLElement} el
1216
+ * @param {Object} [options]
1217
+ */
1218
+
1219
+
1220
+ function Sortable(el, options) {
1221
+ if (!(el && el.nodeType && el.nodeType === 1)) {
1222
+ throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
1223
+ }
1224
+
1225
+ this.el = el; // root element
1226
+
1227
+ this.options = options = _extends({}, options); // Export instance
1228
+
1229
+ el[expando] = this;
1230
+ var defaults = {
1231
+ group: null,
1232
+ sort: true,
1233
+ disabled: false,
1234
+ store: null,
1235
+ handle: null,
1236
+ draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
1237
+ swapThreshold: 1,
1238
+ // percentage; 0 <= x <= 1
1239
+ invertSwap: false,
1240
+ // invert always
1241
+ invertedSwapThreshold: null,
1242
+ // will be set to same as swapThreshold if default
1243
+ removeCloneOnHide: true,
1244
+ direction: function direction() {
1245
+ return _detectDirection(el, this.options);
1246
+ },
1247
+ ghostClone: function(dragEl) {
1248
+ return dragEl.cloneNode(true);
1249
+ },
1250
+ ghostClass: 'sortable-ghost',
1251
+ chosenClass: 'sortable-chosen',
1252
+ dragClass: 'sortable-drag',
1253
+ ignore: 'a, img',
1254
+ filter: null,
1255
+ preventOnFilter: true,
1256
+ animation: 0,
1257
+ easing: null,
1258
+ setData: function setData(dataTransfer, dragEl) {
1259
+ dataTransfer.setData('Text', dragEl.textContent);
1260
+ },
1261
+ dropBubble: false,
1262
+ dragoverBubble: false,
1263
+ dataIdAttr: 'data-id',
1264
+ delay: 0,
1265
+ delayOnTouchOnly: false,
1266
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
1267
+ forceFallback: false,
1268
+ fallbackClass: 'sortable-fallback',
1269
+ fallbackOnBody: false,
1270
+ fallbackTolerance: 0,
1271
+ fallbackOffset: {
1272
+ x: 0,
1273
+ y: 0
1274
+ },
1275
+ supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && !Safari,
1276
+ emptyInsertThreshold: 5
1277
+ };
1278
+ PluginManager.initializePlugins(this, el, defaults); // Set default options
1279
+
1280
+ for (var name in defaults) {
1281
+ !(name in options) && (options[name] = defaults[name]);
1282
+ }
1283
+
1284
+ _prepareGroup(options); // Bind all private methods
1285
+
1286
+
1287
+ for (var fn in this) {
1288
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
1289
+ this[fn] = this[fn].bind(this);
1290
+ }
1291
+ } // Setup drag mode
1292
+
1293
+
1294
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
1295
+
1296
+ if (this.nativeDraggable) {
1297
+ // Touch start threshold cannot be greater than the native dragstart threshold
1298
+ this.options.touchStartThreshold = 1;
1299
+ } // Bind events
1300
+
1301
+
1302
+ if (options.supportPointer) {
1303
+ on(el, 'pointerdown', this._onTapStart);
1304
+ } else {
1305
+ on(el, 'mousedown', this._onTapStart);
1306
+ on(el, 'touchstart', this._onTapStart);
1307
+ }
1308
+
1309
+ if (this.nativeDraggable) {
1310
+ on(el, 'dragover', this);
1311
+ on(el, 'dragenter', this);
1312
+ }
1313
+
1314
+ sortables.push(this.el); // Restore sorting
1315
+
1316
+ options.store && options.store.get && this.sort(options.store.get(this) || []); // Add animation state manager
1317
+
1318
+ _extends(this, AnimationStateManager());
1319
+ }
1320
+
1321
+ Sortable.prototype =
1322
+ /** @lends Sortable.prototype */
1323
+ {
1324
+ constructor: Sortable,
1325
+ _isOutsideThisEl: function _isOutsideThisEl(target) {
1326
+ if (!this.el.contains(target) && target !== this.el) {
1327
+ lastTarget = null;
1328
+ }
1329
+ },
1330
+ _getDirection: function _getDirection(evt, target) {
1331
+ return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
1332
+ },
1333
+ _onTapStart: function _onTapStart(
1334
+ /** Event|TouchEvent */
1335
+ evt) {
1336
+ if (!evt.cancelable) return;
1337
+
1338
+ var _this = this,
1339
+ el = this.el,
1340
+ options = this.options,
1341
+ preventOnFilter = options.preventOnFilter,
1342
+ type = evt.type,
1343
+ touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
1344
+ target = (touch || evt).target,
1345
+ originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
1346
+ filter = options.filter;
1347
+
1348
+ _saveInputCheckedState(el); // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
1349
+
1350
+
1351
+ if (dragEl) {
1352
+ return;
1353
+ }
1354
+
1355
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
1356
+ return; // only left button and enabled
1357
+ } // cancel dnd if original target is content editable
1358
+
1359
+
1360
+ if (originalTarget.isContentEditable) {
1361
+ return;
1362
+ } // Safari ignores further event handling after mousedown
1363
+
1364
+
1365
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
1366
+ return;
1367
+ }
1368
+
1369
+ target = closest(target, options.draggable, el, false);
1370
+
1371
+ if (target && target.animated) {
1372
+ return;
1373
+ }
1374
+
1375
+ if (lastDownEl === target) {
1376
+ // Ignoring duplicate `down`
1377
+ return;
1378
+ } // Get the index of the dragged element within its parent
1379
+
1380
+
1381
+ oldIndex = index(target);
1382
+ oldDraggableIndex = index(target, options.draggable); // Check filter
1383
+
1384
+ if (typeof filter === 'function') {
1385
+ if (filter.call(this, evt, target, this)) {
1386
+ _dispatchEvent({
1387
+ sortable: _this,
1388
+ rootEl: originalTarget,
1389
+ name: 'filter',
1390
+ targetEl: target,
1391
+ toEl: el,
1392
+ fromEl: el
1393
+ });
1394
+
1395
+ pluginEvent('filter', _this, {
1396
+ evt: evt
1397
+ });
1398
+ preventOnFilter && evt.cancelable && evt.preventDefault();
1399
+ return; // cancel dnd
1400
+ }
1401
+ } else if (filter) {
1402
+ filter = filter.split(',').some(function (criteria) {
1403
+ criteria = closest(originalTarget, criteria.trim(), el, false);
1404
+
1405
+ if (criteria) {
1406
+ _dispatchEvent({
1407
+ sortable: _this,
1408
+ rootEl: criteria,
1409
+ name: 'filter',
1410
+ targetEl: target,
1411
+ fromEl: el,
1412
+ toEl: el
1413
+ });
1414
+
1415
+ pluginEvent('filter', _this, {
1416
+ evt: evt
1417
+ });
1418
+ return true;
1419
+ }
1420
+ });
1421
+
1422
+ if (filter) {
1423
+ preventOnFilter && evt.cancelable && evt.preventDefault();
1424
+ return; // cancel dnd
1425
+ }
1426
+ }
1427
+
1428
+ if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1429
+ return;
1430
+ } // Prepare `dragstart`
1431
+
1432
+
1433
+ this._prepareDragStart(evt, touch, target);
1434
+ },
1435
+ _prepareDragStart: function _prepareDragStart(
1436
+ /** Event */
1437
+ evt,
1438
+ /** Touch */
1439
+ touch,
1440
+ /** HTMLElement */
1441
+ target) {
1442
+ var _this = this,
1443
+ el = _this.el,
1444
+ options = _this.options,
1445
+ ownerDocument = el.ownerDocument,
1446
+ dragStartFn;
1447
+
1448
+ if (target && !dragEl && target.parentNode === el) {
1449
+ var dragRect = getRect(target);
1450
+ rootEl = el;
1451
+ dragEl = target;
1452
+ parentEl = dragEl.parentNode;
1453
+ nextEl = dragEl.nextSibling;
1454
+ lastDownEl = target;
1455
+ activeGroup = options.group;
1456
+ Sortable.dragged = dragEl;
1457
+ tapEvt = {
1458
+ target: dragEl,
1459
+ clientX: (touch || evt).clientX,
1460
+ clientY: (touch || evt).clientY
1461
+ };
1462
+ tapDistanceLeft = tapEvt.clientX - dragRect.left;
1463
+ tapDistanceTop = tapEvt.clientY - dragRect.top;
1464
+ this._lastX = (touch || evt).clientX;
1465
+ this._lastY = (touch || evt).clientY;
1466
+ dragEl.style['will-change'] = 'all';
1467
+
1468
+ dragStartFn = function dragStartFn() {
1469
+ pluginEvent('delayEnded', _this, {
1470
+ evt: evt
1471
+ });
1472
+
1473
+ if (Sortable.eventCanceled) {
1474
+ _this._onDrop();
1475
+
1476
+ return;
1477
+ } // Delayed drag has been triggered
1478
+ // we can re-enable the events: touchmove/mousemove
1479
+
1480
+
1481
+ _this._disableDelayedDragEvents();
1482
+
1483
+ if (!FireFox && _this.nativeDraggable) {
1484
+ dragEl.draggable = true;
1485
+ } // Bind the events: dragstart/dragend
1486
+
1487
+
1488
+ _this._triggerDragStart(evt, touch); // Drag start event
1489
+
1490
+
1491
+ _dispatchEvent({
1492
+ sortable: _this,
1493
+ name: 'choose',
1494
+ originalEvent: evt
1495
+ }); // Chosen item
1496
+
1497
+
1498
+ toggleClass(dragEl, options.chosenClass, true);
1499
+ }; // Disable "draggable"
1500
+
1501
+
1502
+ options.ignore.split(',').forEach(function (criteria) {
1503
+ find(dragEl, criteria.trim(), _disableDraggable);
1504
+ });
1505
+ on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
1506
+ on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
1507
+ on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1508
+ on(ownerDocument, 'mouseup', _this._onDrop);
1509
+ on(ownerDocument, 'touchend', _this._onDrop);
1510
+ on(ownerDocument, 'touchcancel', _this._onDrop); // Make dragEl draggable (must be before delay for FireFox)
1511
+
1512
+ if (FireFox && this.nativeDraggable) {
1513
+ this.options.touchStartThreshold = 4;
1514
+ dragEl.draggable = true;
1515
+ }
1516
+
1517
+ pluginEvent('delayStart', this, {
1518
+ evt: evt
1519
+ }); // Delay is impossible for native DnD in Edge or IE
1520
+
1521
+ if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1522
+ if (Sortable.eventCanceled) {
1523
+ this._onDrop();
1524
+
1525
+ return;
1526
+ } // If the user moves the pointer or let go the click or touch
1527
+ // before the delay has been reached:
1528
+ // disable the delayed drag
1529
+
1530
+
1531
+ on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1532
+ on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1533
+ on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1534
+ on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
1535
+ on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
1536
+ options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
1537
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
1538
+ } else {
1539
+ dragStartFn();
1540
+ }
1541
+ }
1542
+ },
1543
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(
1544
+ /** TouchEvent|PointerEvent **/
1545
+ e) {
1546
+ var touch = e.touches ? e.touches[0] : e;
1547
+
1548
+ if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
1549
+ this._disableDelayedDrag();
1550
+ }
1551
+ },
1552
+ _disableDelayedDrag: function _disableDelayedDrag() {
1553
+ dragEl && _disableDraggable(dragEl);
1554
+ clearTimeout(this._dragStartTimer);
1555
+
1556
+ this._disableDelayedDragEvents();
1557
+ },
1558
+ _disableDelayedDragEvents: function _disableDelayedDragEvents() {
1559
+ var ownerDocument = this.el.ownerDocument;
1560
+ off(ownerDocument, 'mouseup', this._disableDelayedDrag);
1561
+ off(ownerDocument, 'touchend', this._disableDelayedDrag);
1562
+ off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1563
+ off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
1564
+ off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
1565
+ off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
1566
+ },
1567
+ _triggerDragStart: function _triggerDragStart(
1568
+ /** Event */
1569
+ evt,
1570
+ /** Touch */
1571
+ touch) {
1572
+ touch = touch || evt.pointerType == 'touch' && evt;
1573
+
1574
+ if (!this.nativeDraggable || touch) {
1575
+ if (this.options.supportPointer) {
1576
+ on(document, 'pointermove', this._onTouchMove);
1577
+ } else if (touch) {
1578
+ on(document, 'touchmove', this._onTouchMove);
1579
+ } else {
1580
+ on(document, 'mousemove', this._onTouchMove);
1581
+ }
1582
+ } else {
1583
+ on(dragEl, 'dragend', this);
1584
+ on(rootEl, 'dragstart', this._onDragStart);
1585
+ }
1586
+
1587
+ try {
1588
+ if (document.selection) {
1589
+ // Timeout neccessary for IE9
1590
+ _nextTick(function () {
1591
+ document.selection.empty();
1592
+ });
1593
+ } else {
1594
+ window.getSelection().removeAllRanges();
1595
+ }
1596
+ } catch (err) {}
1597
+ },
1598
+ _dragStarted: function _dragStarted(fallback, evt) {
1599
+
1600
+ awaitingDragStarted = false;
1601
+
1602
+ if (rootEl && dragEl) {
1603
+ pluginEvent('dragStarted', this, {
1604
+ evt: evt
1605
+ });
1606
+
1607
+ if (this.nativeDraggable) {
1608
+ on(document, 'dragover', _checkOutsideTargetEl);
1609
+ }
1610
+
1611
+ var options = this.options; // Apply effect
1612
+
1613
+ !fallback && toggleClass(dragEl, options.dragClass, false);
1614
+ toggleClass(dragEl, options.ghostClass, true);
1615
+ Sortable.active = this;
1616
+ fallback && this._appendGhost(); // Drag start event
1617
+
1618
+ _dispatchEvent({
1619
+ sortable: this,
1620
+ name: 'start',
1621
+ originalEvent: evt
1622
+ });
1623
+ } else {
1624
+ this._nulling();
1625
+ }
1626
+ },
1627
+ _emulateDragOver: function _emulateDragOver() {
1628
+ if (touchEvt) {
1629
+ this._lastX = touchEvt.clientX;
1630
+ this._lastY = touchEvt.clientY;
1631
+
1632
+ _hideGhostForTarget();
1633
+
1634
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1635
+ var parent = target;
1636
+
1637
+ while (target && target.shadowRoot) {
1638
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1639
+ if (target === parent) break;
1640
+ parent = target;
1641
+ }
1642
+
1643
+ dragEl.parentNode[expando]._isOutsideThisEl(target);
1644
+
1645
+ if (parent) {
1646
+ do {
1647
+ if (parent[expando]) {
1648
+ var inserted = void 0;
1649
+ inserted = parent[expando]._onDragOver({
1650
+ clientX: touchEvt.clientX,
1651
+ clientY: touchEvt.clientY,
1652
+ target: target,
1653
+ rootEl: parent
1654
+ });
1655
+
1656
+ if (inserted && !this.options.dragoverBubble) {
1657
+ break;
1658
+ }
1659
+ }
1660
+
1661
+ target = parent; // store last element
1662
+ }
1663
+ /* jshint boss:true */
1664
+ while (parent = parent.parentNode);
1665
+ }
1666
+
1667
+ _unhideGhostForTarget();
1668
+ }
1669
+ },
1670
+ _onTouchMove: function _onTouchMove(
1671
+ /**TouchEvent*/
1672
+ evt) {
1673
+ if (tapEvt) {
1674
+ var options = this.options,
1675
+ fallbackTolerance = options.fallbackTolerance,
1676
+ fallbackOffset = options.fallbackOffset,
1677
+ touch = evt.touches ? evt.touches[0] : evt,
1678
+ ghostMatrix = ghostEl && matrix(ghostEl, true),
1679
+ scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
1680
+ scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
1681
+ relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
1682
+ dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
1683
+ dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1); // only set the status to dragging, when we are actually dragging
1684
+
1685
+ if (!Sortable.active && !awaitingDragStarted) {
1686
+ if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
1687
+ return;
1688
+ }
1689
+
1690
+ this._onDragStart(evt, true);
1691
+ }
1692
+
1693
+ if (ghostEl) {
1694
+ if (ghostMatrix) {
1695
+ ghostMatrix.e += dx - (lastDx || 0);
1696
+ ghostMatrix.f += dy - (lastDy || 0);
1697
+ } else {
1698
+ ghostMatrix = {
1699
+ a: 1,
1700
+ b: 0,
1701
+ c: 0,
1702
+ d: 1,
1703
+ e: dx,
1704
+ f: dy
1705
+ };
1706
+ }
1707
+
1708
+ var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
1709
+ css(ghostEl, 'webkitTransform', cssMatrix);
1710
+ css(ghostEl, 'mozTransform', cssMatrix);
1711
+ css(ghostEl, 'msTransform', cssMatrix);
1712
+ css(ghostEl, 'transform', cssMatrix);
1713
+ lastDx = dx;
1714
+ lastDy = dy;
1715
+ touchEvt = touch;
1716
+ }
1717
+
1718
+ evt.cancelable && evt.preventDefault();
1719
+ }
1720
+ },
1721
+ _appendGhost: function _appendGhost() {
1722
+ // Bug if using scale(): https://stackoverflow.com/questions/2637058
1723
+ // Not being adjusted for
1724
+ if (!ghostEl) {
1725
+ var container = this.options.fallbackOnBody ? document.body : rootEl,
1726
+ rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
1727
+ options = this.options; // Position absolutely
1728
+
1729
+ if (PositionGhostAbsolutely) {
1730
+ // Get relatively positioned parent
1731
+ ghostRelativeParent = container;
1732
+
1733
+ while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
1734
+ ghostRelativeParent = ghostRelativeParent.parentNode;
1735
+ }
1736
+
1737
+ if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
1738
+ if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
1739
+ rect.top += ghostRelativeParent.scrollTop;
1740
+ rect.left += ghostRelativeParent.scrollLeft;
1741
+ } else {
1742
+ ghostRelativeParent = getWindowScrollingElement();
1743
+ }
1744
+
1745
+ ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
1746
+ }
1747
+
1748
+ ghostEl = options.ghostClone(dragEl);
1749
+ toggleClass(ghostEl, options.ghostClass, false);
1750
+ toggleClass(ghostEl, options.fallbackClass, true);
1751
+ toggleClass(ghostEl, options.dragClass, true);
1752
+ css(ghostEl, 'transition', '');
1753
+ css(ghostEl, 'transform', '');
1754
+ css(ghostEl, 'box-sizing', 'border-box');
1755
+ css(ghostEl, 'margin', 0);
1756
+ css(ghostEl, 'top', rect.top);
1757
+ css(ghostEl, 'left', rect.left);
1758
+ css(ghostEl, 'width', rect.width);
1759
+ css(ghostEl, 'height', rect.height);
1760
+ css(ghostEl, 'opacity', '0.8');
1761
+ css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
1762
+ css(ghostEl, 'zIndex', '100000');
1763
+ css(ghostEl, 'pointerEvents', 'none');
1764
+ Sortable.ghost = ghostEl;
1765
+ container.appendChild(ghostEl); // Set transform-origin
1766
+
1767
+ css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
1768
+ }
1769
+ },
1770
+ _onDragStart: function _onDragStart(
1771
+ /**Event*/
1772
+ evt,
1773
+ /**boolean*/
1774
+ fallback) {
1775
+ var _this = this;
1776
+
1777
+ var dataTransfer = evt.dataTransfer;
1778
+ var options = _this.options;
1779
+ pluginEvent('dragStart', this, {
1780
+ evt: evt
1781
+ });
1782
+
1783
+ if (Sortable.eventCanceled) {
1784
+ this._onDrop();
1785
+
1786
+ return;
1787
+ }
1788
+
1789
+ pluginEvent('setupClone', this);
1790
+
1791
+ if (!Sortable.eventCanceled) {
1792
+ cloneEl = clone(dragEl);
1793
+ cloneEl.removeAttribute("id");
1794
+ cloneEl.draggable = false;
1795
+ cloneEl.style['will-change'] = '';
1796
+
1797
+ this._hideClone();
1798
+
1799
+ toggleClass(cloneEl, this.options.chosenClass, false);
1800
+ Sortable.clone = cloneEl;
1801
+ } // #1143: IFrame support workaround
1802
+
1803
+
1804
+ _this.cloneId = _nextTick(function () {
1805
+ pluginEvent('clone', _this);
1806
+ if (Sortable.eventCanceled) return;
1807
+
1808
+ if (!_this.options.removeCloneOnHide) {
1809
+ rootEl.insertBefore(cloneEl, dragEl);
1810
+ }
1811
+
1812
+ _this._hideClone();
1813
+
1814
+ _dispatchEvent({
1815
+ sortable: _this,
1816
+ name: 'clone'
1817
+ });
1818
+ });
1819
+ !fallback && toggleClass(dragEl, options.dragClass, true); // Set proper drop events
1820
+
1821
+ if (fallback) {
1822
+ ignoreNextClick = true;
1823
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
1824
+ } else {
1825
+ // Undo what was set in _prepareDragStart before drag started
1826
+ off(document, 'mouseup', _this._onDrop);
1827
+ off(document, 'touchend', _this._onDrop);
1828
+ off(document, 'touchcancel', _this._onDrop);
1829
+
1830
+ if (dataTransfer) {
1831
+ dataTransfer.effectAllowed = 'move';
1832
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
1833
+ }
1834
+
1835
+ on(document, 'drop', _this); // #1276 fix:
1836
+
1837
+ css(dragEl, 'transform', 'translateZ(0)');
1838
+ }
1839
+
1840
+ awaitingDragStarted = true;
1841
+ _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
1842
+ on(document, 'selectstart', _this);
1843
+ moved = true;
1844
+
1845
+ if (Safari) {
1846
+ css(document.body, 'user-select', 'none');
1847
+ }
1848
+ },
1849
+ // Returns true - if no further action is needed (either inserted or another condition)
1850
+ _onDragOver: function _onDragOver(
1851
+ /**Event*/
1852
+ evt) {
1853
+ var el = this.el,
1854
+ target = evt.target,
1855
+ dragRect,
1856
+ targetRect,
1857
+ revert,
1858
+ options = this.options,
1859
+ group = options.group,
1860
+ activeSortable = Sortable.active,
1861
+ isOwner = activeGroup === group,
1862
+ canSort = options.sort,
1863
+ fromSortable = putSortable || activeSortable,
1864
+ vertical,
1865
+ _this = this,
1866
+ completedFired = false;
1867
+
1868
+ if (_silent) return;
1869
+
1870
+ function dragOverEvent(name, extra) {
1871
+ pluginEvent(name, _this, _objectSpread2({
1872
+ evt: evt,
1873
+ isOwner: isOwner,
1874
+ axis: vertical ? 'vertical' : 'horizontal',
1875
+ revert: revert,
1876
+ dragRect: dragRect,
1877
+ targetRect: targetRect,
1878
+ canSort: canSort,
1879
+ fromSortable: fromSortable,
1880
+ target: target,
1881
+ completed: completed,
1882
+ onMove: function onMove(target, after) {
1883
+ return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1884
+ },
1885
+ changed: changed
1886
+ }, extra));
1887
+ } // Capture animation state
1888
+
1889
+
1890
+ function capture() {
1891
+ dragOverEvent('dragOverAnimationCapture');
1892
+
1893
+ _this.captureAnimationState();
1894
+
1895
+ if (_this !== fromSortable) {
1896
+ fromSortable.captureAnimationState();
1897
+ }
1898
+ } // Return invocation when dragEl is inserted (or completed)
1899
+
1900
+
1901
+ function completed(insertion) {
1902
+ dragOverEvent('dragOverCompleted', {
1903
+ insertion: insertion
1904
+ });
1905
+
1906
+ if (insertion) {
1907
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
1908
+ if (isOwner) {
1909
+ activeSortable._hideClone();
1910
+ } else {
1911
+ activeSortable._showClone(_this);
1912
+ }
1913
+
1914
+ if (_this !== fromSortable) {
1915
+ // Set ghost class to new sortable's ghost class
1916
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1917
+ toggleClass(dragEl, options.ghostClass, true);
1918
+ }
1919
+
1920
+ if (putSortable !== _this && _this !== Sortable.active) {
1921
+ putSortable = _this;
1922
+ } else if (_this === Sortable.active && putSortable) {
1923
+ putSortable = null;
1924
+ } // Animation
1925
+
1926
+
1927
+ if (fromSortable === _this) {
1928
+ _this._ignoreWhileAnimating = target;
1929
+ }
1930
+
1931
+ _this.animateAll(function () {
1932
+ dragOverEvent('dragOverAnimationComplete');
1933
+ _this._ignoreWhileAnimating = null;
1934
+ });
1935
+
1936
+ if (_this !== fromSortable) {
1937
+ fromSortable.animateAll();
1938
+ fromSortable._ignoreWhileAnimating = null;
1939
+ }
1940
+ } // Null lastTarget if it is not inside a previously swapped element
1941
+
1942
+
1943
+ if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
1944
+ lastTarget = null;
1945
+ } // no bubbling and not fallback
1946
+
1947
+
1948
+ if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1949
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target); // Do not detect for empty insert if already inserted
1950
+
1951
+
1952
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1953
+ }
1954
+
1955
+ !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1956
+ return completedFired = true;
1957
+ } // Call when dragEl has been inserted
1958
+
1959
+
1960
+ function changed() {
1961
+ newIndex = index(dragEl);
1962
+ newDraggableIndex = index(dragEl, options.draggable);
1963
+
1964
+ _dispatchEvent({
1965
+ sortable: _this,
1966
+ name: 'change',
1967
+ toEl: el,
1968
+ newIndex: newIndex,
1969
+ newDraggableIndex: newDraggableIndex,
1970
+ originalEvent: evt
1971
+ });
1972
+ }
1973
+
1974
+ if (evt.preventDefault !== void 0) {
1975
+ evt.cancelable && evt.preventDefault();
1976
+ }
1977
+
1978
+ target = closest(target, options.draggable, el, true);
1979
+ dragOverEvent('dragOver');
1980
+ if (Sortable.eventCanceled) return completedFired;
1981
+
1982
+ if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
1983
+ return completed(false);
1984
+ }
1985
+
1986
+ ignoreNextClick = false;
1987
+
1988
+ if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
1989
+ : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
1990
+ vertical = this._getDirection(evt, target) === 'vertical';
1991
+ dragRect = getRect(dragEl);
1992
+ dragOverEvent('dragOverValid');
1993
+ if (Sortable.eventCanceled) return completedFired;
1994
+
1995
+ if (revert) {
1996
+ parentEl = rootEl; // actualization
1997
+
1998
+ capture();
1999
+
2000
+ this._hideClone();
2001
+
2002
+ dragOverEvent('revert');
2003
+
2004
+ if (!Sortable.eventCanceled) {
2005
+ if (nextEl) {
2006
+ rootEl.insertBefore(dragEl, nextEl);
2007
+ } else {
2008
+ rootEl.appendChild(dragEl);
2009
+ }
2010
+ }
2011
+
2012
+ return completed(true);
2013
+ }
2014
+
2015
+ var elLastChild = lastChild(el, options.draggable);
2016
+
2017
+ if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
2018
+ // Insert to end of list
2019
+ // If already at end of list: Do not insert
2020
+ if (elLastChild === dragEl) {
2021
+ return completed(false);
2022
+ } // if there is a last element, it is the target
2023
+
2024
+
2025
+ if (elLastChild && el === evt.target) {
2026
+ target = elLastChild;
2027
+ }
2028
+
2029
+ if (target) {
2030
+ targetRect = getRect(target);
2031
+ }
2032
+
2033
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
2034
+ capture();
2035
+
2036
+ if (elLastChild && elLastChild.nextSibling) {
2037
+ // the last draggable element is not the last node
2038
+ el.insertBefore(dragEl, elLastChild.nextSibling);
2039
+ } else {
2040
+ el.appendChild(dragEl);
2041
+ }
2042
+
2043
+ parentEl = el; // actualization
2044
+
2045
+ changed();
2046
+ return completed(true);
2047
+ }
2048
+ } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
2049
+ // Insert to start of list
2050
+ var firstChild = getChild(el, 0, options, true);
2051
+
2052
+ if (firstChild === dragEl) {
2053
+ return completed(false);
2054
+ }
2055
+
2056
+ target = firstChild;
2057
+ targetRect = getRect(target);
2058
+
2059
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
2060
+ capture();
2061
+ el.insertBefore(dragEl, firstChild);
2062
+ parentEl = el; // actualization
2063
+
2064
+ changed();
2065
+ return completed(true);
2066
+ }
2067
+ } else if (target.parentNode === el) {
2068
+ targetRect = getRect(target);
2069
+ var direction = 0,
2070
+ targetBeforeFirstSwap,
2071
+ differentLevel = dragEl.parentNode !== el,
2072
+ differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
2073
+ side1 = vertical ? 'top' : 'left',
2074
+ scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
2075
+ scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
2076
+
2077
+ if (lastTarget !== target) {
2078
+ targetBeforeFirstSwap = targetRect[side1];
2079
+ pastFirstInvertThresh = false;
2080
+ isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
2081
+ }
2082
+
2083
+ direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
2084
+ var sibling;
2085
+
2086
+ if (direction !== 0) {
2087
+ // Check if target is beside dragEl in respective direction (ignoring hidden elements)
2088
+ var dragIndex = index(dragEl);
2089
+
2090
+ do {
2091
+ dragIndex -= direction;
2092
+ sibling = parentEl.children[dragIndex];
2093
+ } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
2094
+ } // If dragEl is already beside target: Do not insert
2095
+
2096
+
2097
+ if (direction === 0 || sibling === target) {
2098
+ return completed(false);
2099
+ }
2100
+
2101
+ lastTarget = target;
2102
+ lastDirection = direction;
2103
+ var nextSibling = target.nextElementSibling,
2104
+ after = false;
2105
+ after = direction === 1;
2106
+
2107
+ var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
2108
+
2109
+ if (moveVector !== false) {
2110
+ if (moveVector === 1 || moveVector === -1) {
2111
+ after = moveVector === 1;
2112
+ }
2113
+
2114
+ _silent = true;
2115
+ setTimeout(_unsilent, 30);
2116
+ capture();
2117
+
2118
+ if (after && !nextSibling) {
2119
+ el.appendChild(dragEl);
2120
+ } else {
2121
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
2122
+ } // Undo chrome's scroll adjustment (has no effect on other browsers)
2123
+
2124
+
2125
+ if (scrolledPastTop) {
2126
+ scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
2127
+ }
2128
+
2129
+ parentEl = dragEl.parentNode; // actualization
2130
+ // must be done before animation
2131
+
2132
+ if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
2133
+ targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
2134
+ }
2135
+
2136
+ changed();
2137
+ return completed(true);
2138
+ }
2139
+ }
2140
+
2141
+ if (el.contains(dragEl)) {
2142
+ return completed(false);
2143
+ }
2144
+ }
2145
+
2146
+ return false;
2147
+ },
2148
+ _ignoreWhileAnimating: null,
2149
+ _offMoveEvents: function _offMoveEvents() {
2150
+ off(document, 'mousemove', this._onTouchMove);
2151
+ off(document, 'touchmove', this._onTouchMove);
2152
+ off(document, 'pointermove', this._onTouchMove);
2153
+ off(document, 'dragover', nearestEmptyInsertDetectEvent);
2154
+ off(document, 'mousemove', nearestEmptyInsertDetectEvent);
2155
+ off(document, 'touchmove', nearestEmptyInsertDetectEvent);
2156
+ },
2157
+ _offUpEvents: function _offUpEvents() {
2158
+ var ownerDocument = this.el.ownerDocument;
2159
+ off(ownerDocument, 'mouseup', this._onDrop);
2160
+ off(ownerDocument, 'touchend', this._onDrop);
2161
+ off(ownerDocument, 'pointerup', this._onDrop);
2162
+ off(ownerDocument, 'touchcancel', this._onDrop);
2163
+ off(document, 'selectstart', this);
2164
+ },
2165
+ _onDrop: function _onDrop(
2166
+ /**Event*/
2167
+ evt) {
2168
+ var el = this.el,
2169
+ options = this.options; // Get the index of the dragged element within its parent
2170
+
2171
+ newIndex = index(dragEl);
2172
+ newDraggableIndex = index(dragEl, options.draggable);
2173
+ pluginEvent('drop', this, {
2174
+ evt: evt
2175
+ });
2176
+ parentEl = dragEl && dragEl.parentNode; // Get again after plugin event
2177
+
2178
+ newIndex = index(dragEl);
2179
+ newDraggableIndex = index(dragEl, options.draggable);
2180
+
2181
+ if (Sortable.eventCanceled) {
2182
+ this._nulling();
2183
+
2184
+ return;
2185
+ }
2186
+
2187
+ awaitingDragStarted = false;
2188
+ isCircumstantialInvert = false;
2189
+ pastFirstInvertThresh = false;
2190
+ clearInterval(this._loopId);
2191
+ clearTimeout(this._dragStartTimer);
2192
+
2193
+ _cancelNextTick(this.cloneId);
2194
+
2195
+ _cancelNextTick(this._dragStartId); // Unbind events
2196
+
2197
+
2198
+ if (this.nativeDraggable) {
2199
+ off(document, 'drop', this);
2200
+ off(el, 'dragstart', this._onDragStart);
2201
+ }
2202
+
2203
+ this._offMoveEvents();
2204
+
2205
+ this._offUpEvents();
2206
+
2207
+ if (Safari) {
2208
+ css(document.body, 'user-select', '');
2209
+ }
2210
+
2211
+ css(dragEl, 'transform', '');
2212
+
2213
+ if (evt) {
2214
+ if (moved) {
2215
+ evt.cancelable && evt.preventDefault();
2216
+ !options.dropBubble && evt.stopPropagation();
2217
+ }
2218
+
2219
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
2220
+
2221
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
2222
+ // Remove clone(s)
2223
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
2224
+ }
2225
+
2226
+ if (dragEl) {
2227
+ if (this.nativeDraggable) {
2228
+ off(dragEl, 'dragend', this);
2229
+ }
2230
+
2231
+ _disableDraggable(dragEl);
2232
+
2233
+ dragEl.style['will-change'] = ''; // Remove classes
2234
+ // ghostClass is added in dragStarted
2235
+
2236
+ if (moved && !awaitingDragStarted) {
2237
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
2238
+ }
2239
+
2240
+ toggleClass(dragEl, this.options.chosenClass, false); // Drag stop event
2241
+
2242
+ _dispatchEvent({
2243
+ sortable: this,
2244
+ name: 'unchoose',
2245
+ toEl: parentEl,
2246
+ newIndex: null,
2247
+ newDraggableIndex: null,
2248
+ originalEvent: evt
2249
+ });
2250
+
2251
+ if (rootEl !== parentEl) {
2252
+ if (newIndex >= 0) {
2253
+ // Add event
2254
+ _dispatchEvent({
2255
+ rootEl: parentEl,
2256
+ name: 'add',
2257
+ toEl: parentEl,
2258
+ fromEl: rootEl,
2259
+ originalEvent: evt
2260
+ }); // Remove event
2261
+
2262
+
2263
+ _dispatchEvent({
2264
+ sortable: this,
2265
+ name: 'remove',
2266
+ toEl: parentEl,
2267
+ originalEvent: evt
2268
+ }); // drag from one list and drop into another
2269
+
2270
+
2271
+ _dispatchEvent({
2272
+ rootEl: parentEl,
2273
+ name: 'sort',
2274
+ toEl: parentEl,
2275
+ fromEl: rootEl,
2276
+ originalEvent: evt
2277
+ });
2278
+
2279
+ _dispatchEvent({
2280
+ sortable: this,
2281
+ name: 'sort',
2282
+ toEl: parentEl,
2283
+ originalEvent: evt
2284
+ });
2285
+ }
2286
+
2287
+ putSortable && putSortable.save();
2288
+ } else {
2289
+ if (newIndex !== oldIndex) {
2290
+ if (newIndex >= 0) {
2291
+ // drag & drop within the same list
2292
+ _dispatchEvent({
2293
+ sortable: this,
2294
+ name: 'update',
2295
+ toEl: parentEl,
2296
+ originalEvent: evt
2297
+ });
2298
+
2299
+ _dispatchEvent({
2300
+ sortable: this,
2301
+ name: 'sort',
2302
+ toEl: parentEl,
2303
+ originalEvent: evt
2304
+ });
2305
+ }
2306
+ }
2307
+ }
2308
+
2309
+ if (Sortable.active) {
2310
+ /* jshint eqnull:true */
2311
+ if (newIndex == null || newIndex === -1) {
2312
+ newIndex = oldIndex;
2313
+ newDraggableIndex = oldDraggableIndex;
2314
+ }
2315
+
2316
+ _dispatchEvent({
2317
+ sortable: this,
2318
+ name: 'end',
2319
+ toEl: parentEl,
2320
+ originalEvent: evt
2321
+ }); // Save sorting
2322
+
2323
+
2324
+ this.save();
2325
+ }
2326
+ }
2327
+ }
2328
+
2329
+ this._nulling();
2330
+ },
2331
+ _nulling: function _nulling() {
2332
+ pluginEvent('nulling', this);
2333
+ rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
2334
+ savedInputChecked.forEach(function (el) {
2335
+ el.checked = true;
2336
+ });
2337
+ savedInputChecked.length = lastDx = lastDy = 0;
2338
+ },
2339
+ handleEvent: function handleEvent(
2340
+ /**Event*/
2341
+ evt) {
2342
+ switch (evt.type) {
2343
+ case 'drop':
2344
+ case 'dragend':
2345
+ this._onDrop(evt);
2346
+
2347
+ break;
2348
+
2349
+ case 'dragenter':
2350
+ case 'dragover':
2351
+ if (dragEl) {
2352
+ this._onDragOver(evt);
2353
+
2354
+ _globalDragOver(evt);
2355
+ }
2356
+
2357
+ break;
2358
+
2359
+ case 'selectstart':
2360
+ evt.preventDefault();
2361
+ break;
2362
+ }
2363
+ },
2364
+
2365
+ /**
2366
+ * Serializes the item into an array of string.
2367
+ * @returns {String[]}
2368
+ */
2369
+ toArray: function toArray() {
2370
+ var order = [],
2371
+ el,
2372
+ children = this.el.children,
2373
+ i = 0,
2374
+ n = children.length,
2375
+ options = this.options;
2376
+
2377
+ for (; i < n; i++) {
2378
+ el = children[i];
2379
+
2380
+ if (closest(el, options.draggable, this.el, false)) {
2381
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
2382
+ }
2383
+ }
2384
+
2385
+ return order;
2386
+ },
2387
+
2388
+ /**
2389
+ * Sorts the elements according to the array.
2390
+ * @param {String[]} order order of the items
2391
+ */
2392
+ sort: function sort(order, useAnimation) {
2393
+ var items = {},
2394
+ rootEl = this.el;
2395
+ this.toArray().forEach(function (id, i) {
2396
+ var el = rootEl.children[i];
2397
+
2398
+ if (closest(el, this.options.draggable, rootEl, false)) {
2399
+ items[id] = el;
2400
+ }
2401
+ }, this);
2402
+ useAnimation && this.captureAnimationState();
2403
+ order.forEach(function (id) {
2404
+ if (items[id]) {
2405
+ rootEl.removeChild(items[id]);
2406
+ rootEl.appendChild(items[id]);
2407
+ }
2408
+ });
2409
+ useAnimation && this.animateAll();
2410
+ },
2411
+
2412
+ /**
2413
+ * Save the current sorting
2414
+ */
2415
+ save: function save() {
2416
+ var store = this.options.store;
2417
+ store && store.set && store.set(this);
2418
+ },
2419
+
2420
+ /**
2421
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
2422
+ * @param {HTMLElement} el
2423
+ * @param {String} [selector] default: `options.draggable`
2424
+ * @returns {HTMLElement|null}
2425
+ */
2426
+ closest: function closest$1(el, selector) {
2427
+ return closest(el, selector || this.options.draggable, this.el, false);
2428
+ },
2429
+
2430
+ /**
2431
+ * Set/get option
2432
+ * @param {string} name
2433
+ * @param {*} [value]
2434
+ * @returns {*}
2435
+ */
2436
+ option: function option(name, value) {
2437
+ var options = this.options;
2438
+
2439
+ if (value === void 0) {
2440
+ return options[name];
2441
+ } else {
2442
+ var modifiedValue = PluginManager.modifyOption(this, name, value);
2443
+
2444
+ if (typeof modifiedValue !== 'undefined') {
2445
+ options[name] = modifiedValue;
2446
+ } else {
2447
+ options[name] = value;
2448
+ }
2449
+
2450
+ if (name === 'group') {
2451
+ _prepareGroup(options);
2452
+ }
2453
+ }
2454
+ },
2455
+
2456
+ /**
2457
+ * Destroy
2458
+ */
2459
+ destroy: function destroy() {
2460
+ pluginEvent('destroy', this);
2461
+ var el = this.el;
2462
+ el[expando] = null;
2463
+ off(el, 'mousedown', this._onTapStart);
2464
+ off(el, 'touchstart', this._onTapStart);
2465
+ off(el, 'pointerdown', this._onTapStart);
2466
+
2467
+ if (this.nativeDraggable) {
2468
+ off(el, 'dragover', this);
2469
+ off(el, 'dragenter', this);
2470
+ } // Remove draggable attributes
2471
+
2472
+
2473
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
2474
+ el.removeAttribute('draggable');
2475
+ });
2476
+
2477
+ this._onDrop();
2478
+
2479
+ this._disableDelayedDragEvents();
2480
+
2481
+ sortables.splice(sortables.indexOf(this.el), 1);
2482
+ this.el = el = null;
2483
+ },
2484
+ _hideClone: function _hideClone() {
2485
+ if (!cloneHidden) {
2486
+ pluginEvent('hideClone', this);
2487
+ if (Sortable.eventCanceled) return;
2488
+ css(cloneEl, 'display', 'none');
2489
+
2490
+ if (this.options.removeCloneOnHide && cloneEl.parentNode) {
2491
+ cloneEl.parentNode.removeChild(cloneEl);
2492
+ }
2493
+
2494
+ cloneHidden = true;
2495
+ }
2496
+ },
2497
+ _showClone: function _showClone(putSortable) {
2498
+ if (putSortable.lastPutMode !== 'clone') {
2499
+ this._hideClone();
2500
+
2501
+ return;
2502
+ }
2503
+
2504
+ if (cloneHidden) {
2505
+ pluginEvent('showClone', this);
2506
+ if (Sortable.eventCanceled) return; // show clone at dragEl or original position
2507
+
2508
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
2509
+ rootEl.insertBefore(cloneEl, dragEl);
2510
+ } else if (nextEl) {
2511
+ rootEl.insertBefore(cloneEl, nextEl);
2512
+ } else {
2513
+ rootEl.appendChild(cloneEl);
2514
+ }
2515
+
2516
+ if (this.options.group.revertClone) {
2517
+ this.animate(dragEl, cloneEl);
2518
+ }
2519
+
2520
+ css(cloneEl, 'display', '');
2521
+ cloneHidden = false;
2522
+ }
2523
+ }
2524
+ };
2525
+
2526
+ function _globalDragOver(
2527
+ /**Event*/
2528
+ evt) {
2529
+ if (evt.dataTransfer) {
2530
+ evt.dataTransfer.dropEffect = 'move';
2531
+ }
2532
+
2533
+ evt.cancelable && evt.preventDefault();
2534
+ }
2535
+
2536
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
2537
+ var evt,
2538
+ sortable = fromEl[expando],
2539
+ onMoveFn = sortable.options.onMove,
2540
+ retVal; // Support for new CustomEvent feature
2541
+
2542
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
2543
+ evt = new CustomEvent('move', {
2544
+ bubbles: true,
2545
+ cancelable: true
2546
+ });
2547
+ } else {
2548
+ evt = document.createEvent('Event');
2549
+ evt.initEvent('move', true, true);
2550
+ }
2551
+
2552
+ evt.to = toEl;
2553
+ evt.from = fromEl;
2554
+ evt.dragged = dragEl;
2555
+ evt.draggedRect = dragRect;
2556
+ evt.related = targetEl || toEl;
2557
+ evt.relatedRect = targetRect || getRect(toEl);
2558
+ evt.willInsertAfter = willInsertAfter;
2559
+ evt.originalEvent = originalEvent;
2560
+ fromEl.dispatchEvent(evt);
2561
+
2562
+ if (onMoveFn) {
2563
+ retVal = onMoveFn.call(sortable, evt, originalEvent);
2564
+ }
2565
+
2566
+ return retVal;
2567
+ }
2568
+
2569
+ function _disableDraggable(el) {
2570
+ el.draggable = false;
2571
+ }
2572
+
2573
+ function _unsilent() {
2574
+ _silent = false;
2575
+ }
2576
+
2577
+ function _ghostIsFirst(evt, vertical, sortable) {
2578
+ var rect = getRect(getChild(sortable.el, 0, sortable.options, true));
2579
+ var spacer = 10;
2580
+ return vertical ? evt.clientX < rect.left - spacer || evt.clientY < rect.top && evt.clientX < rect.right : evt.clientY < rect.top - spacer || evt.clientY < rect.bottom && evt.clientX < rect.left;
2581
+ }
2582
+
2583
+ function _ghostIsLast(evt, vertical, sortable) {
2584
+ var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
2585
+ var spacer = 10;
2586
+ return vertical ? evt.clientX > rect.right + spacer || evt.clientX <= rect.right && evt.clientY > rect.bottom && evt.clientX >= rect.left : evt.clientX > rect.right && evt.clientY > rect.top || evt.clientX <= rect.right && evt.clientY > rect.bottom + spacer;
2587
+ }
2588
+
2589
+ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
2590
+ var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2591
+ targetLength = vertical ? targetRect.height : targetRect.width,
2592
+ targetS1 = vertical ? targetRect.top : targetRect.left,
2593
+ targetS2 = vertical ? targetRect.bottom : targetRect.right,
2594
+ invert = false;
2595
+
2596
+ if (!invertSwap) {
2597
+ // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
2598
+ if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
2599
+ // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
2600
+ // check if past first invert threshold on side opposite of lastDirection
2601
+ if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
2602
+ // past first invert threshold, do not restrict inverted threshold to dragEl shadow
2603
+ pastFirstInvertThresh = true;
2604
+ }
2605
+
2606
+ if (!pastFirstInvertThresh) {
2607
+ // dragEl shadow (target move distance shadow)
2608
+ if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
2609
+ : mouseOnAxis > targetS2 - targetMoveDistance) {
2610
+ return -lastDirection;
2611
+ }
2612
+ } else {
2613
+ invert = true;
2614
+ }
2615
+ } else {
2616
+ // Regular
2617
+ if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
2618
+ return _getInsertDirection(target);
2619
+ }
2620
+ }
2621
+ }
2622
+
2623
+ invert = invert || invertSwap;
2624
+
2625
+ if (invert) {
2626
+ // Invert of regular
2627
+ if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
2628
+ return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
2629
+ }
2630
+ }
2631
+
2632
+ return 0;
2633
+ }
2634
+ /**
2635
+ * Gets the direction dragEl must be swapped relative to target in order to make it
2636
+ * seem that dragEl has been "inserted" into that element's position
2637
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
2638
+ * @return {Number} Direction dragEl must be swapped
2639
+ */
2640
+
2641
+
2642
+ function _getInsertDirection(target) {
2643
+ if (index(dragEl) < index(target)) {
2644
+ return 1;
2645
+ } else {
2646
+ return -1;
2647
+ }
2648
+ }
2649
+ /**
2650
+ * Generate id
2651
+ * @param {HTMLElement} el
2652
+ * @returns {String}
2653
+ * @private
2654
+ */
2655
+
2656
+
2657
+ function _generateId(el) {
2658
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
2659
+ i = str.length,
2660
+ sum = 0;
2661
+
2662
+ while (i--) {
2663
+ sum += str.charCodeAt(i);
2664
+ }
2665
+
2666
+ return sum.toString(36);
2667
+ }
2668
+
2669
+ function _saveInputCheckedState(root) {
2670
+ savedInputChecked.length = 0;
2671
+ var inputs = root.getElementsByTagName('input');
2672
+ var idx = inputs.length;
2673
+
2674
+ while (idx--) {
2675
+ var el = inputs[idx];
2676
+ el.checked && savedInputChecked.push(el);
2677
+ }
2678
+ }
2679
+
2680
+ function _nextTick(fn) {
2681
+ return setTimeout(fn, 0);
2682
+ }
2683
+
2684
+ function _cancelNextTick(id) {
2685
+ return clearTimeout(id);
2686
+ } // Fixed #973:
2687
+
2688
+
2689
+ if (documentExists) {
2690
+ on(document, 'touchmove', function (evt) {
2691
+ if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
2692
+ evt.preventDefault();
2693
+ }
2694
+ });
2695
+ } // Export utils
2696
+
2697
+
2698
+ Sortable.utils = {
2699
+ on: on,
2700
+ off: off,
2701
+ css: css,
2702
+ find: find,
2703
+ is: function is(el, selector) {
2704
+ return !!closest(el, selector, el, false);
2705
+ },
2706
+ extend: extend,
2707
+ throttle: throttle,
2708
+ closest: closest,
2709
+ toggleClass: toggleClass,
2710
+ clone: clone,
2711
+ index: index,
2712
+ nextTick: _nextTick,
2713
+ cancelNextTick: _cancelNextTick,
2714
+ detectDirection: _detectDirection,
2715
+ getChild: getChild
2716
+ };
2717
+ /**
2718
+ * Get the Sortable instance of an element
2719
+ * @param {HTMLElement} element The element
2720
+ * @return {Sortable|undefined} The instance of Sortable
2721
+ */
2722
+
2723
+ Sortable.get = function (element) {
2724
+ return element[expando];
2725
+ };
2726
+ /**
2727
+ * Mount a plugin to Sortable
2728
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2729
+ */
2730
+
2731
+
2732
+ Sortable.mount = function () {
2733
+ for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
2734
+ plugins[_key] = arguments[_key];
2735
+ }
2736
+
2737
+ if (plugins[0].constructor === Array) plugins = plugins[0];
2738
+ plugins.forEach(function (plugin) {
2739
+ if (!plugin.prototype || !plugin.prototype.constructor) {
2740
+ throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
2741
+ }
2742
+
2743
+ if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
2744
+ PluginManager.mount(plugin);
2745
+ });
2746
+ };
2747
+ /**
2748
+ * Create sortable instance
2749
+ * @param {HTMLElement} el
2750
+ * @param {Object} [options]
2751
+ */
2752
+
2753
+
2754
+ Sortable.create = function (el, options) {
2755
+ return new Sortable(el, options);
2756
+ }; // Export
2757
+
2758
+
2759
+ Sortable.version = version;
2760
+
2761
+ var autoScrolls = [],
2762
+ scrollEl,
2763
+ scrollRootEl,
2764
+ scrolling = false,
2765
+ lastAutoScrollX,
2766
+ lastAutoScrollY,
2767
+ touchEvt$1,
2768
+ pointerElemChangedInterval;
2769
+
2770
+ function AutoScrollPlugin() {
2771
+ function AutoScroll() {
2772
+ this.defaults = {
2773
+ scroll: true,
2774
+ forceAutoScrollFallback: false,
2775
+ scrollSensitivity: 30,
2776
+ scrollSpeed: 10,
2777
+ bubbleScroll: true
2778
+ }; // Bind all private methods
2779
+
2780
+ for (var fn in this) {
2781
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2782
+ this[fn] = this[fn].bind(this);
2783
+ }
2784
+ }
2785
+ }
2786
+
2787
+ AutoScroll.prototype = {
2788
+ dragStarted: function dragStarted(_ref) {
2789
+ var originalEvent = _ref.originalEvent;
2790
+
2791
+ if (this.sortable.nativeDraggable) {
2792
+ on(document, 'dragover', this._handleAutoScroll);
2793
+ } else {
2794
+ if (this.options.supportPointer) {
2795
+ on(document, 'pointermove', this._handleFallbackAutoScroll);
2796
+ } else if (originalEvent.touches) {
2797
+ on(document, 'touchmove', this._handleFallbackAutoScroll);
2798
+ } else {
2799
+ on(document, 'mousemove', this._handleFallbackAutoScroll);
2800
+ }
2801
+ }
2802
+ },
2803
+ dragOverCompleted: function dragOverCompleted(_ref2) {
2804
+ var originalEvent = _ref2.originalEvent;
2805
+
2806
+ // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
2807
+ if (!this.options.dragOverBubble && !originalEvent.rootEl) {
2808
+ this._handleAutoScroll(originalEvent);
2809
+ }
2810
+ },
2811
+ drop: function drop() {
2812
+ if (this.sortable.nativeDraggable) {
2813
+ off(document, 'dragover', this._handleAutoScroll);
2814
+ } else {
2815
+ off(document, 'pointermove', this._handleFallbackAutoScroll);
2816
+ off(document, 'touchmove', this._handleFallbackAutoScroll);
2817
+ off(document, 'mousemove', this._handleFallbackAutoScroll);
2818
+ }
2819
+
2820
+ clearPointerElemChangedInterval();
2821
+ clearAutoScrolls();
2822
+ cancelThrottle();
2823
+ },
2824
+ nulling: function nulling() {
2825
+ touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
2826
+ autoScrolls.length = 0;
2827
+ },
2828
+ _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
2829
+ this._handleAutoScroll(evt, true);
2830
+ },
2831
+ _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
2832
+ var _this = this;
2833
+
2834
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2835
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2836
+ elem = document.elementFromPoint(x, y);
2837
+ touchEvt$1 = evt; // IE does not seem to have native autoscroll,
2838
+ // Edge's autoscroll seems too conditional,
2839
+ // MACOS Safari does not have autoscroll,
2840
+ // Firefox and Chrome are good
2841
+
2842
+ if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
2843
+ autoScroll(evt, this.options, elem, fallback); // Listener for pointer element change
2844
+
2845
+ var ogElemScroller = getParentAutoScrollElement(elem, true);
2846
+
2847
+ if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
2848
+ pointerElemChangedInterval && clearPointerElemChangedInterval(); // Detect for pointer elem change, emulating native DnD behaviour
2849
+
2850
+ pointerElemChangedInterval = setInterval(function () {
2851
+ var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
2852
+
2853
+ if (newElem !== ogElemScroller) {
2854
+ ogElemScroller = newElem;
2855
+ clearAutoScrolls();
2856
+ }
2857
+
2858
+ autoScroll(evt, _this.options, newElem, fallback);
2859
+ }, 10);
2860
+ lastAutoScrollX = x;
2861
+ lastAutoScrollY = y;
2862
+ }
2863
+ } else {
2864
+ // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
2865
+ if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
2866
+ clearAutoScrolls();
2867
+ return;
2868
+ }
2869
+
2870
+ autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
2871
+ }
2872
+ }
2873
+ };
2874
+ return _extends(AutoScroll, {
2875
+ pluginName: 'scroll',
2876
+ initializeByDefault: true
2877
+ });
2878
+ }
2879
+
2880
+ function clearAutoScrolls() {
2881
+ autoScrolls.forEach(function (autoScroll) {
2882
+ clearInterval(autoScroll.pid);
2883
+ });
2884
+ autoScrolls = [];
2885
+ }
2886
+
2887
+ function clearPointerElemChangedInterval() {
2888
+ clearInterval(pointerElemChangedInterval);
2889
+ }
2890
+
2891
+ var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
2892
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
2893
+ if (!options.scroll) return;
2894
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2895
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2896
+ sens = options.scrollSensitivity,
2897
+ speed = options.scrollSpeed,
2898
+ winScroller = getWindowScrollingElement();
2899
+ var scrollThisInstance = false,
2900
+ scrollCustomFn; // New scroll root, set scrollEl
2901
+
2902
+ if (scrollRootEl !== rootEl) {
2903
+ scrollRootEl = rootEl;
2904
+ clearAutoScrolls();
2905
+ scrollEl = options.scroll;
2906
+ scrollCustomFn = options.scrollFn;
2907
+
2908
+ if (scrollEl === true) {
2909
+ scrollEl = getParentAutoScrollElement(rootEl, true);
2910
+ }
2911
+ }
2912
+
2913
+ var layersOut = 0;
2914
+ var currentParent = scrollEl;
2915
+
2916
+ do {
2917
+ var el = currentParent,
2918
+ rect = getRect(el),
2919
+ top = rect.top,
2920
+ bottom = rect.bottom,
2921
+ left = rect.left,
2922
+ right = rect.right,
2923
+ width = rect.width,
2924
+ height = rect.height,
2925
+ canScrollX = void 0,
2926
+ canScrollY = void 0,
2927
+ scrollWidth = el.scrollWidth,
2928
+ scrollHeight = el.scrollHeight,
2929
+ elCSS = css(el),
2930
+ scrollPosX = el.scrollLeft,
2931
+ scrollPosY = el.scrollTop;
2932
+
2933
+ if (el === winScroller) {
2934
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
2935
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
2936
+ } else {
2937
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
2938
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
2939
+ }
2940
+
2941
+ var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
2942
+ var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
2943
+
2944
+ if (!autoScrolls[layersOut]) {
2945
+ for (var i = 0; i <= layersOut; i++) {
2946
+ if (!autoScrolls[i]) {
2947
+ autoScrolls[i] = {};
2948
+ }
2949
+ }
2950
+ }
2951
+
2952
+ if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
2953
+ autoScrolls[layersOut].el = el;
2954
+ autoScrolls[layersOut].vx = vx;
2955
+ autoScrolls[layersOut].vy = vy;
2956
+ clearInterval(autoScrolls[layersOut].pid);
2957
+
2958
+ if (vx != 0 || vy != 0) {
2959
+ scrollThisInstance = true;
2960
+ /* jshint loopfunc:true */
2961
+
2962
+ autoScrolls[layersOut].pid = setInterval(function () {
2963
+ // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
2964
+ if (isFallback && this.layer === 0) {
2965
+ Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
2966
+
2967
+ }
2968
+
2969
+ var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
2970
+ var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
2971
+
2972
+ if (typeof scrollCustomFn === 'function') {
2973
+ if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
2974
+ return;
2975
+ }
2976
+ }
2977
+
2978
+ scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2979
+ }.bind({
2980
+ layer: layersOut
2981
+ }), 24);
2982
+ }
2983
+ }
2984
+
2985
+ layersOut++;
2986
+ } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
2987
+
2988
+ scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
2989
+ }, 30);
2990
+
2991
+ var drop = function drop(_ref) {
2992
+ var originalEvent = _ref.originalEvent,
2993
+ putSortable = _ref.putSortable,
2994
+ dragEl = _ref.dragEl,
2995
+ activeSortable = _ref.activeSortable,
2996
+ dispatchSortableEvent = _ref.dispatchSortableEvent,
2997
+ hideGhostForTarget = _ref.hideGhostForTarget,
2998
+ unhideGhostForTarget = _ref.unhideGhostForTarget;
2999
+ if (!originalEvent) return;
3000
+ var toSortable = putSortable || activeSortable;
3001
+ hideGhostForTarget();
3002
+ var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
3003
+ var target = document.elementFromPoint(touch.clientX, touch.clientY);
3004
+ unhideGhostForTarget();
3005
+
3006
+ if (toSortable && !toSortable.el.contains(target)) {
3007
+ dispatchSortableEvent('spill');
3008
+ this.onSpill({
3009
+ dragEl: dragEl,
3010
+ putSortable: putSortable
3011
+ });
3012
+ }
3013
+ };
3014
+
3015
+ function Revert() {}
3016
+
3017
+ Revert.prototype = {
3018
+ startIndex: null,
3019
+ dragStart: function dragStart(_ref2) {
3020
+ var oldDraggableIndex = _ref2.oldDraggableIndex;
3021
+ this.startIndex = oldDraggableIndex;
3022
+ },
3023
+ onSpill: function onSpill(_ref3) {
3024
+ var dragEl = _ref3.dragEl,
3025
+ putSortable = _ref3.putSortable;
3026
+ this.sortable.captureAnimationState();
3027
+
3028
+ if (putSortable) {
3029
+ putSortable.captureAnimationState();
3030
+ }
3031
+
3032
+ var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
3033
+
3034
+ if (nextSibling) {
3035
+ this.sortable.el.insertBefore(dragEl, nextSibling);
3036
+ } else {
3037
+ this.sortable.el.appendChild(dragEl);
3038
+ }
3039
+
3040
+ this.sortable.animateAll();
3041
+
3042
+ if (putSortable) {
3043
+ putSortable.animateAll();
3044
+ }
3045
+ },
3046
+ drop: drop
3047
+ };
3048
+
3049
+ _extends(Revert, {
3050
+ pluginName: 'revertOnSpill'
3051
+ });
3052
+
3053
+ function Remove() {}
3054
+
3055
+ Remove.prototype = {
3056
+ onSpill: function onSpill(_ref4) {
3057
+ var dragEl = _ref4.dragEl,
3058
+ putSortable = _ref4.putSortable;
3059
+ var parentSortable = putSortable || this.sortable;
3060
+ parentSortable.captureAnimationState();
3061
+ dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
3062
+ parentSortable.animateAll();
3063
+ },
3064
+ drop: drop
3065
+ };
3066
+
3067
+ _extends(Remove, {
3068
+ pluginName: 'removeOnSpill'
3069
+ });
3070
+
3071
+ var lastSwapEl;
3072
+
3073
+ function SwapPlugin() {
3074
+ function Swap() {
3075
+ this.defaults = {
3076
+ swapClass: 'sortable-swap-highlight'
3077
+ };
3078
+ }
3079
+
3080
+ Swap.prototype = {
3081
+ dragStart: function dragStart(_ref) {
3082
+ var dragEl = _ref.dragEl;
3083
+ lastSwapEl = dragEl;
3084
+ },
3085
+ dragOverValid: function dragOverValid(_ref2) {
3086
+ var completed = _ref2.completed,
3087
+ target = _ref2.target,
3088
+ onMove = _ref2.onMove,
3089
+ activeSortable = _ref2.activeSortable,
3090
+ changed = _ref2.changed,
3091
+ cancel = _ref2.cancel;
3092
+ if (!activeSortable.options.swap) return;
3093
+ var el = this.sortable.el,
3094
+ options = this.options;
3095
+
3096
+ if (target && target !== el) {
3097
+ var prevSwapEl = lastSwapEl;
3098
+
3099
+ if (onMove(target) !== false) {
3100
+ toggleClass(target, options.swapClass, true);
3101
+ lastSwapEl = target;
3102
+ } else {
3103
+ lastSwapEl = null;
3104
+ }
3105
+
3106
+ if (prevSwapEl && prevSwapEl !== lastSwapEl) {
3107
+ toggleClass(prevSwapEl, options.swapClass, false);
3108
+ }
3109
+ }
3110
+
3111
+ changed();
3112
+ completed(true);
3113
+ cancel();
3114
+ },
3115
+ drop: function drop(_ref3) {
3116
+ var activeSortable = _ref3.activeSortable,
3117
+ putSortable = _ref3.putSortable,
3118
+ dragEl = _ref3.dragEl;
3119
+ var toSortable = putSortable || this.sortable;
3120
+ var options = this.options;
3121
+ lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
3122
+
3123
+ if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
3124
+ if (dragEl !== lastSwapEl) {
3125
+ toSortable.captureAnimationState();
3126
+ if (toSortable !== activeSortable) activeSortable.captureAnimationState();
3127
+ swapNodes(dragEl, lastSwapEl);
3128
+ toSortable.animateAll();
3129
+ if (toSortable !== activeSortable) activeSortable.animateAll();
3130
+ }
3131
+ }
3132
+ },
3133
+ nulling: function nulling() {
3134
+ lastSwapEl = null;
3135
+ }
3136
+ };
3137
+ return _extends(Swap, {
3138
+ pluginName: 'swap',
3139
+ eventProperties: function eventProperties() {
3140
+ return {
3141
+ swapItem: lastSwapEl
3142
+ };
3143
+ }
3144
+ });
3145
+ }
3146
+
3147
+ function swapNodes(n1, n2) {
3148
+ var p1 = n1.parentNode,
3149
+ p2 = n2.parentNode,
3150
+ i1,
3151
+ i2;
3152
+ if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return;
3153
+ i1 = index(n1);
3154
+ i2 = index(n2);
3155
+
3156
+ if (p1.isEqualNode(p2) && i1 < i2) {
3157
+ i2++;
3158
+ }
3159
+
3160
+ p1.insertBefore(n2, p1.children[i1]);
3161
+ p2.insertBefore(n1, p2.children[i2]);
3162
+ }
3163
+
3164
+ var multiDragElements = [],
3165
+ multiDragClones = [],
3166
+ lastMultiDragSelect,
3167
+ // for selection with modifier key down (SHIFT)
3168
+ multiDragSortable,
3169
+ initialFolding = false,
3170
+ // Initial multi-drag fold when drag started
3171
+ folding = false,
3172
+ // Folding any other time
3173
+ dragStarted = false,
3174
+ dragEl$1,
3175
+ clonesFromRect,
3176
+ clonesHidden;
3177
+
3178
+ function MultiDragPlugin() {
3179
+ function MultiDrag(sortable) {
3180
+ // Bind all private methods
3181
+ for (var fn in this) {
3182
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
3183
+ this[fn] = this[fn].bind(this);
3184
+ }
3185
+ }
3186
+
3187
+ if (!sortable.options.avoidImplicitDeselect) {
3188
+ if (sortable.options.supportPointer) {
3189
+ on(document, 'pointerup', this._deselectMultiDrag);
3190
+ } else {
3191
+ on(document, 'mouseup', this._deselectMultiDrag);
3192
+ on(document, 'touchend', this._deselectMultiDrag);
3193
+ }
3194
+ }
3195
+
3196
+ on(document, 'keydown', this._checkKeyDown);
3197
+ on(document, 'keyup', this._checkKeyUp);
3198
+ this.defaults = {
3199
+ selectedClass: 'sortable-selected',
3200
+ multiDragKey: null,
3201
+ avoidImplicitDeselect: false,
3202
+ setData: function setData(dataTransfer, dragEl) {
3203
+ var data = '';
3204
+
3205
+ if (multiDragElements.length && multiDragSortable === sortable) {
3206
+ multiDragElements.forEach(function (multiDragElement, i) {
3207
+ data += (!i ? '' : ', ') + multiDragElement.textContent;
3208
+ });
3209
+ } else {
3210
+ data = dragEl.textContent;
3211
+ }
3212
+
3213
+ dataTransfer.setData('Text', data);
3214
+ }
3215
+ };
3216
+ }
3217
+
3218
+ MultiDrag.prototype = {
3219
+ multiDragKeyDown: false,
3220
+ isMultiDrag: false,
3221
+ delayStartGlobal: function delayStartGlobal(_ref) {
3222
+ var dragged = _ref.dragEl;
3223
+ dragEl$1 = dragged;
3224
+ },
3225
+ delayEnded: function delayEnded() {
3226
+ this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
3227
+ },
3228
+ setupClone: function setupClone(_ref2) {
3229
+ var sortable = _ref2.sortable,
3230
+ cancel = _ref2.cancel;
3231
+ if (!this.isMultiDrag) return;
3232
+
3233
+ for (var i = 0; i < multiDragElements.length; i++) {
3234
+ multiDragClones.push(clone(multiDragElements[i]));
3235
+ multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
3236
+ multiDragClones[i].draggable = false;
3237
+ multiDragClones[i].style['will-change'] = '';
3238
+ toggleClass(multiDragClones[i], this.options.selectedClass, false);
3239
+ multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
3240
+ }
3241
+
3242
+ sortable._hideClone();
3243
+
3244
+ cancel();
3245
+ },
3246
+ clone: function clone(_ref3) {
3247
+ var sortable = _ref3.sortable,
3248
+ rootEl = _ref3.rootEl,
3249
+ dispatchSortableEvent = _ref3.dispatchSortableEvent,
3250
+ cancel = _ref3.cancel;
3251
+ if (!this.isMultiDrag) return;
3252
+
3253
+ if (!this.options.removeCloneOnHide) {
3254
+ if (multiDragElements.length && multiDragSortable === sortable) {
3255
+ insertMultiDragClones(true, rootEl);
3256
+ dispatchSortableEvent('clone');
3257
+ cancel();
3258
+ }
3259
+ }
3260
+ },
3261
+ showClone: function showClone(_ref4) {
3262
+ var cloneNowShown = _ref4.cloneNowShown,
3263
+ rootEl = _ref4.rootEl,
3264
+ cancel = _ref4.cancel;
3265
+ if (!this.isMultiDrag) return;
3266
+ insertMultiDragClones(false, rootEl);
3267
+ multiDragClones.forEach(function (clone) {
3268
+ css(clone, 'display', '');
3269
+ });
3270
+ cloneNowShown();
3271
+ clonesHidden = false;
3272
+ cancel();
3273
+ },
3274
+ hideClone: function hideClone(_ref5) {
3275
+ var _this = this;
3276
+
3277
+ var sortable = _ref5.sortable,
3278
+ cloneNowHidden = _ref5.cloneNowHidden,
3279
+ cancel = _ref5.cancel;
3280
+ if (!this.isMultiDrag) return;
3281
+ multiDragClones.forEach(function (clone) {
3282
+ css(clone, 'display', 'none');
3283
+
3284
+ if (_this.options.removeCloneOnHide && clone.parentNode) {
3285
+ clone.parentNode.removeChild(clone);
3286
+ }
3287
+ });
3288
+ cloneNowHidden();
3289
+ clonesHidden = true;
3290
+ cancel();
3291
+ },
3292
+ dragStartGlobal: function dragStartGlobal(_ref6) {
3293
+ var sortable = _ref6.sortable;
3294
+
3295
+ if (!this.isMultiDrag && multiDragSortable) {
3296
+ multiDragSortable.multiDrag._deselectMultiDrag();
3297
+ }
3298
+
3299
+ multiDragElements.forEach(function (multiDragElement) {
3300
+ multiDragElement.sortableIndex = index(multiDragElement);
3301
+ }); // Sort multi-drag elements
3302
+
3303
+ multiDragElements = multiDragElements.sort(function (a, b) {
3304
+ return a.sortableIndex - b.sortableIndex;
3305
+ });
3306
+ dragStarted = true;
3307
+ },
3308
+ dragStarted: function dragStarted(_ref7) {
3309
+ var _this2 = this;
3310
+
3311
+ var sortable = _ref7.sortable;
3312
+ if (!this.isMultiDrag) return;
3313
+
3314
+ if (this.options.sort) {
3315
+ // Capture rects,
3316
+ // hide multi drag elements (by positioning them absolute),
3317
+ // set multi drag elements rects to dragRect,
3318
+ // show multi drag elements,
3319
+ // animate to rects,
3320
+ // unset rects & remove from DOM
3321
+ sortable.captureAnimationState();
3322
+
3323
+ if (this.options.animation) {
3324
+ multiDragElements.forEach(function (multiDragElement) {
3325
+ if (multiDragElement === dragEl$1) return;
3326
+ css(multiDragElement, 'position', 'absolute');
3327
+ });
3328
+ var dragRect = getRect(dragEl$1, false, true, true);
3329
+ multiDragElements.forEach(function (multiDragElement) {
3330
+ if (multiDragElement === dragEl$1) return;
3331
+ setRect(multiDragElement, dragRect);
3332
+ });
3333
+ folding = true;
3334
+ initialFolding = true;
3335
+ }
3336
+ }
3337
+
3338
+ sortable.animateAll(function () {
3339
+ folding = false;
3340
+ initialFolding = false;
3341
+
3342
+ if (_this2.options.animation) {
3343
+ multiDragElements.forEach(function (multiDragElement) {
3344
+ unsetRect(multiDragElement);
3345
+ });
3346
+ } // Remove all auxiliary multidrag items from el, if sorting enabled
3347
+
3348
+
3349
+ if (_this2.options.sort) {
3350
+ removeMultiDragElements();
3351
+ }
3352
+ });
3353
+ },
3354
+ dragOver: function dragOver(_ref8) {
3355
+ var target = _ref8.target,
3356
+ completed = _ref8.completed,
3357
+ cancel = _ref8.cancel;
3358
+
3359
+ if (folding && ~multiDragElements.indexOf(target)) {
3360
+ completed(false);
3361
+ cancel();
3362
+ }
3363
+ },
3364
+ revert: function revert(_ref9) {
3365
+ var fromSortable = _ref9.fromSortable,
3366
+ rootEl = _ref9.rootEl,
3367
+ sortable = _ref9.sortable,
3368
+ dragRect = _ref9.dragRect;
3369
+
3370
+ if (multiDragElements.length > 1) {
3371
+ // Setup unfold animation
3372
+ multiDragElements.forEach(function (multiDragElement) {
3373
+ sortable.addAnimationState({
3374
+ target: multiDragElement,
3375
+ rect: folding ? getRect(multiDragElement) : dragRect
3376
+ });
3377
+ unsetRect(multiDragElement);
3378
+ multiDragElement.fromRect = dragRect;
3379
+ fromSortable.removeAnimationState(multiDragElement);
3380
+ });
3381
+ folding = false;
3382
+ insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
3383
+ }
3384
+ },
3385
+ dragOverCompleted: function dragOverCompleted(_ref10) {
3386
+ var sortable = _ref10.sortable,
3387
+ isOwner = _ref10.isOwner,
3388
+ insertion = _ref10.insertion,
3389
+ activeSortable = _ref10.activeSortable,
3390
+ parentEl = _ref10.parentEl,
3391
+ putSortable = _ref10.putSortable;
3392
+ var options = this.options;
3393
+
3394
+ if (insertion) {
3395
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
3396
+ if (isOwner) {
3397
+ activeSortable._hideClone();
3398
+ }
3399
+
3400
+ initialFolding = false; // If leaving sort:false root, or already folding - Fold to new location
3401
+
3402
+ if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
3403
+ // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible
3404
+ var dragRectAbsolute = getRect(dragEl$1, false, true, true);
3405
+ multiDragElements.forEach(function (multiDragElement) {
3406
+ if (multiDragElement === dragEl$1) return;
3407
+ setRect(multiDragElement, dragRectAbsolute); // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted
3408
+ // while folding, and so that we can capture them again because old sortable will no longer be fromSortable
3409
+
3410
+ parentEl.appendChild(multiDragElement);
3411
+ });
3412
+ folding = true;
3413
+ } // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out
3414
+
3415
+
3416
+ if (!isOwner) {
3417
+ // Only remove if not folding (folding will remove them anyways)
3418
+ if (!folding) {
3419
+ removeMultiDragElements();
3420
+ }
3421
+
3422
+ if (multiDragElements.length > 1) {
3423
+ var clonesHiddenBefore = clonesHidden;
3424
+
3425
+ activeSortable._showClone(sortable); // Unfold animation for clones if showing from hidden
3426
+
3427
+
3428
+ if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
3429
+ multiDragClones.forEach(function (clone) {
3430
+ activeSortable.addAnimationState({
3431
+ target: clone,
3432
+ rect: clonesFromRect
3433
+ });
3434
+ clone.fromRect = clonesFromRect;
3435
+ clone.thisAnimationDuration = null;
3436
+ });
3437
+ }
3438
+ } else {
3439
+ activeSortable._showClone(sortable);
3440
+ }
3441
+ }
3442
+ }
3443
+ },
3444
+ dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
3445
+ var dragRect = _ref11.dragRect,
3446
+ isOwner = _ref11.isOwner,
3447
+ activeSortable = _ref11.activeSortable;
3448
+ multiDragElements.forEach(function (multiDragElement) {
3449
+ multiDragElement.thisAnimationDuration = null;
3450
+ });
3451
+
3452
+ if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
3453
+ clonesFromRect = _extends({}, dragRect);
3454
+ var dragMatrix = matrix(dragEl$1, true);
3455
+ clonesFromRect.top -= dragMatrix.f;
3456
+ clonesFromRect.left -= dragMatrix.e;
3457
+ }
3458
+ },
3459
+ dragOverAnimationComplete: function dragOverAnimationComplete() {
3460
+ if (folding) {
3461
+ folding = false;
3462
+ removeMultiDragElements();
3463
+ }
3464
+ },
3465
+ drop: function drop(_ref12) {
3466
+ var evt = _ref12.originalEvent,
3467
+ rootEl = _ref12.rootEl,
3468
+ parentEl = _ref12.parentEl,
3469
+ sortable = _ref12.sortable,
3470
+ dispatchSortableEvent = _ref12.dispatchSortableEvent,
3471
+ oldIndex = _ref12.oldIndex,
3472
+ putSortable = _ref12.putSortable;
3473
+ var toSortable = putSortable || this.sortable;
3474
+ if (!evt) return;
3475
+ var options = this.options,
3476
+ children = parentEl.children; // Multi-drag selection
3477
+
3478
+ if (!dragStarted) {
3479
+ if (options.multiDragKey && !this.multiDragKeyDown) {
3480
+ this._deselectMultiDrag();
3481
+ }
3482
+
3483
+ toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
3484
+
3485
+ if (!~multiDragElements.indexOf(dragEl$1)) {
3486
+ multiDragElements.push(dragEl$1);
3487
+ dispatchEvent({
3488
+ sortable: sortable,
3489
+ rootEl: rootEl,
3490
+ name: 'select',
3491
+ targetEl: dragEl$1,
3492
+ originalEvent: evt
3493
+ }); // Modifier activated, select from last to dragEl
3494
+
3495
+ if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
3496
+ var lastIndex = index(lastMultiDragSelect),
3497
+ currentIndex = index(dragEl$1);
3498
+
3499
+ if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
3500
+ // Must include lastMultiDragSelect (select it), in case modified selection from no selection
3501
+ // (but previous selection existed)
3502
+ var n, i;
3503
+
3504
+ if (currentIndex > lastIndex) {
3505
+ i = lastIndex;
3506
+ n = currentIndex;
3507
+ } else {
3508
+ i = currentIndex;
3509
+ n = lastIndex + 1;
3510
+ }
3511
+
3512
+ for (; i < n; i++) {
3513
+ if (~multiDragElements.indexOf(children[i])) continue;
3514
+ toggleClass(children[i], options.selectedClass, true);
3515
+ multiDragElements.push(children[i]);
3516
+ dispatchEvent({
3517
+ sortable: sortable,
3518
+ rootEl: rootEl,
3519
+ name: 'select',
3520
+ targetEl: children[i],
3521
+ originalEvent: evt
3522
+ });
3523
+ }
3524
+ }
3525
+ } else {
3526
+ lastMultiDragSelect = dragEl$1;
3527
+ }
3528
+
3529
+ multiDragSortable = toSortable;
3530
+ } else {
3531
+ multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
3532
+ lastMultiDragSelect = null;
3533
+ dispatchEvent({
3534
+ sortable: sortable,
3535
+ rootEl: rootEl,
3536
+ name: 'deselect',
3537
+ targetEl: dragEl$1,
3538
+ originalEvent: evt
3539
+ });
3540
+ }
3541
+ } // Multi-drag drop
3542
+
3543
+
3544
+ if (dragStarted && this.isMultiDrag) {
3545
+ folding = false; // Do not "unfold" after around dragEl if reverted
3546
+
3547
+ if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
3548
+ var dragRect = getRect(dragEl$1),
3549
+ multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')');
3550
+ if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
3551
+ toSortable.captureAnimationState();
3552
+
3553
+ if (!initialFolding) {
3554
+ if (options.animation) {
3555
+ dragEl$1.fromRect = dragRect;
3556
+ multiDragElements.forEach(function (multiDragElement) {
3557
+ multiDragElement.thisAnimationDuration = null;
3558
+
3559
+ if (multiDragElement !== dragEl$1) {
3560
+ var rect = folding ? getRect(multiDragElement) : dragRect;
3561
+ multiDragElement.fromRect = rect; // Prepare unfold animation
3562
+
3563
+ toSortable.addAnimationState({
3564
+ target: multiDragElement,
3565
+ rect: rect
3566
+ });
3567
+ }
3568
+ });
3569
+ } // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert
3570
+ // properly they must all be removed
3571
+
3572
+
3573
+ removeMultiDragElements();
3574
+ multiDragElements.forEach(function (multiDragElement) {
3575
+ if (children[multiDragIndex]) {
3576
+ parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
3577
+ } else {
3578
+ parentEl.appendChild(multiDragElement);
3579
+ }
3580
+
3581
+ multiDragIndex++;
3582
+ }); // If initial folding is done, the elements may have changed position because they are now
3583
+ // unfolding around dragEl, even though dragEl may not have his index changed, so update event
3584
+ // must be fired here as Sortable will not.
3585
+
3586
+ if (oldIndex === index(dragEl$1)) {
3587
+ var update = false;
3588
+ multiDragElements.forEach(function (multiDragElement) {
3589
+ if (multiDragElement.sortableIndex !== index(multiDragElement)) {
3590
+ update = true;
3591
+ return;
3592
+ }
3593
+ });
3594
+
3595
+ if (update) {
3596
+ dispatchSortableEvent('update');
3597
+ }
3598
+ }
3599
+ } // Must be done after capturing individual rects (scroll bar)
3600
+
3601
+
3602
+ multiDragElements.forEach(function (multiDragElement) {
3603
+ unsetRect(multiDragElement);
3604
+ });
3605
+ toSortable.animateAll();
3606
+ }
3607
+
3608
+ multiDragSortable = toSortable;
3609
+ } // Remove clones if necessary
3610
+
3611
+
3612
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
3613
+ multiDragClones.forEach(function (clone) {
3614
+ clone.parentNode && clone.parentNode.removeChild(clone);
3615
+ });
3616
+ }
3617
+ },
3618
+ nullingGlobal: function nullingGlobal() {
3619
+ this.isMultiDrag = dragStarted = false;
3620
+ multiDragClones.length = 0;
3621
+ },
3622
+ destroyGlobal: function destroyGlobal() {
3623
+ this._deselectMultiDrag();
3624
+
3625
+ off(document, 'pointerup', this._deselectMultiDrag);
3626
+ off(document, 'mouseup', this._deselectMultiDrag);
3627
+ off(document, 'touchend', this._deselectMultiDrag);
3628
+ off(document, 'keydown', this._checkKeyDown);
3629
+ off(document, 'keyup', this._checkKeyUp);
3630
+ },
3631
+ _deselectMultiDrag: function _deselectMultiDrag(evt) {
3632
+ if (typeof dragStarted !== "undefined" && dragStarted) return; // Only deselect if selection is in this sortable
3633
+
3634
+ if (multiDragSortable !== this.sortable) return; // Only deselect if target is not item in this sortable
3635
+
3636
+ if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return; // Only deselect if left click
3637
+
3638
+ if (evt && evt.button !== 0) return;
3639
+
3640
+ while (multiDragElements.length) {
3641
+ var el = multiDragElements[0];
3642
+ toggleClass(el, this.options.selectedClass, false);
3643
+ multiDragElements.shift();
3644
+ dispatchEvent({
3645
+ sortable: this.sortable,
3646
+ rootEl: this.sortable.el,
3647
+ name: 'deselect',
3648
+ targetEl: el,
3649
+ originalEvent: evt
3650
+ });
3651
+ }
3652
+ },
3653
+ _checkKeyDown: function _checkKeyDown(evt) {
3654
+ if (evt.key === this.options.multiDragKey) {
3655
+ this.multiDragKeyDown = true;
3656
+ }
3657
+ },
3658
+ _checkKeyUp: function _checkKeyUp(evt) {
3659
+ if (evt.key === this.options.multiDragKey) {
3660
+ this.multiDragKeyDown = false;
3661
+ }
3662
+ }
3663
+ };
3664
+ return _extends(MultiDrag, {
3665
+ // Static methods & properties
3666
+ pluginName: 'multiDrag',
3667
+ utils: {
3668
+ /**
3669
+ * Selects the provided multi-drag item
3670
+ * @param {HTMLElement} el The element to be selected
3671
+ */
3672
+ select: function select(el) {
3673
+ var sortable = el.parentNode[expando];
3674
+ if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return;
3675
+
3676
+ if (multiDragSortable && multiDragSortable !== sortable) {
3677
+ multiDragSortable.multiDrag._deselectMultiDrag();
3678
+
3679
+ multiDragSortable = sortable;
3680
+ }
3681
+
3682
+ toggleClass(el, sortable.options.selectedClass, true);
3683
+ multiDragElements.push(el);
3684
+ },
3685
+
3686
+ /**
3687
+ * Deselects the provided multi-drag item
3688
+ * @param {HTMLElement} el The element to be deselected
3689
+ */
3690
+ deselect: function deselect(el) {
3691
+ var sortable = el.parentNode[expando],
3692
+ index = multiDragElements.indexOf(el);
3693
+ if (!sortable || !sortable.options.multiDrag || !~index) return;
3694
+ toggleClass(el, sortable.options.selectedClass, false);
3695
+ multiDragElements.splice(index, 1);
3696
+ }
3697
+ },
3698
+ eventProperties: function eventProperties() {
3699
+ var _this3 = this;
3700
+
3701
+ var oldIndicies = [],
3702
+ newIndicies = [];
3703
+ multiDragElements.forEach(function (multiDragElement) {
3704
+ oldIndicies.push({
3705
+ multiDragElement: multiDragElement,
3706
+ index: multiDragElement.sortableIndex
3707
+ }); // multiDragElements will already be sorted if folding
3708
+
3709
+ var newIndex;
3710
+
3711
+ if (folding && multiDragElement !== dragEl$1) {
3712
+ newIndex = -1;
3713
+ } else if (folding) {
3714
+ newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')');
3715
+ } else {
3716
+ newIndex = index(multiDragElement);
3717
+ }
3718
+
3719
+ newIndicies.push({
3720
+ multiDragElement: multiDragElement,
3721
+ index: newIndex
3722
+ });
3723
+ });
3724
+ return {
3725
+ items: _toConsumableArray(multiDragElements),
3726
+ clones: [].concat(multiDragClones),
3727
+ oldIndicies: oldIndicies,
3728
+ newIndicies: newIndicies
3729
+ };
3730
+ },
3731
+ optionListeners: {
3732
+ multiDragKey: function multiDragKey(key) {
3733
+ key = key.toLowerCase();
3734
+
3735
+ if (key === 'ctrl') {
3736
+ key = 'Control';
3737
+ } else if (key.length > 1) {
3738
+ key = key.charAt(0).toUpperCase() + key.substr(1);
3739
+ }
3740
+
3741
+ return key;
3742
+ }
3743
+ }
3744
+ });
3745
+ }
3746
+
3747
+ function insertMultiDragElements(clonesInserted, rootEl) {
3748
+ multiDragElements.forEach(function (multiDragElement, i) {
3749
+ var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
3750
+
3751
+ if (target) {
3752
+ rootEl.insertBefore(multiDragElement, target);
3753
+ } else {
3754
+ rootEl.appendChild(multiDragElement);
3755
+ }
3756
+ });
3757
+ }
3758
+ /**
3759
+ * Insert multi-drag clones
3760
+ * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
3761
+ * @param {HTMLElement} rootEl
3762
+ */
3763
+
3764
+
3765
+ function insertMultiDragClones(elementsInserted, rootEl) {
3766
+ multiDragClones.forEach(function (clone, i) {
3767
+ var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
3768
+
3769
+ if (target) {
3770
+ rootEl.insertBefore(clone, target);
3771
+ } else {
3772
+ rootEl.appendChild(clone);
3773
+ }
3774
+ });
3775
+ }
3776
+
3777
+ function removeMultiDragElements() {
3778
+ multiDragElements.forEach(function (multiDragElement) {
3779
+ if (multiDragElement === dragEl$1) return;
3780
+ multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
3781
+ });
3782
+ }
3783
+
3784
+ Sortable.mount(new AutoScrollPlugin());
3785
+ Sortable.mount(Remove, Revert);
3786
+
3787
+ Sortable.mount(new SwapPlugin());
3788
+ Sortable.mount(new MultiDragPlugin());
3789
+
3790
+ export default Sortable;
3791
+