sortablejs.js 99 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817
  1. import {
  2. init_define_APP_INFO
  3. } from "./chunk-XY75H3MP.js";
  4. // dep:sortablejs
  5. init_define_APP_INFO();
  6. // node_modules/sortablejs/modular/sortable.esm.js
  7. init_define_APP_INFO();
  8. function ownKeys(object, enumerableOnly) {
  9. var keys = Object.keys(object);
  10. if (Object.getOwnPropertySymbols) {
  11. var symbols = Object.getOwnPropertySymbols(object);
  12. if (enumerableOnly) {
  13. symbols = symbols.filter(function(sym) {
  14. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  15. });
  16. }
  17. keys.push.apply(keys, symbols);
  18. }
  19. return keys;
  20. }
  21. function _objectSpread2(target) {
  22. for (var i = 1; i < arguments.length; i++) {
  23. var source = arguments[i] != null ? arguments[i] : {};
  24. if (i % 2) {
  25. ownKeys(Object(source), true).forEach(function(key) {
  26. _defineProperty(target, key, source[key]);
  27. });
  28. } else if (Object.getOwnPropertyDescriptors) {
  29. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  30. } else {
  31. ownKeys(Object(source)).forEach(function(key) {
  32. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  33. });
  34. }
  35. }
  36. return target;
  37. }
  38. function _typeof(obj) {
  39. "@babel/helpers - typeof";
  40. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  41. _typeof = function(obj2) {
  42. return typeof obj2;
  43. };
  44. } else {
  45. _typeof = function(obj2) {
  46. return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
  47. };
  48. }
  49. return _typeof(obj);
  50. }
  51. function _defineProperty(obj, key, value) {
  52. if (key in obj) {
  53. Object.defineProperty(obj, key, {
  54. value,
  55. enumerable: true,
  56. configurable: true,
  57. writable: true
  58. });
  59. } else {
  60. obj[key] = value;
  61. }
  62. return obj;
  63. }
  64. function _extends() {
  65. _extends = Object.assign || function(target) {
  66. for (var i = 1; i < arguments.length; i++) {
  67. var source = arguments[i];
  68. for (var key in source) {
  69. if (Object.prototype.hasOwnProperty.call(source, key)) {
  70. target[key] = source[key];
  71. }
  72. }
  73. }
  74. return target;
  75. };
  76. return _extends.apply(this, arguments);
  77. }
  78. function _objectWithoutPropertiesLoose(source, excluded) {
  79. if (source == null)
  80. return {};
  81. var target = {};
  82. var sourceKeys = Object.keys(source);
  83. var key, i;
  84. for (i = 0; i < sourceKeys.length; i++) {
  85. key = sourceKeys[i];
  86. if (excluded.indexOf(key) >= 0)
  87. continue;
  88. target[key] = source[key];
  89. }
  90. return target;
  91. }
  92. function _objectWithoutProperties(source, excluded) {
  93. if (source == null)
  94. return {};
  95. var target = _objectWithoutPropertiesLoose(source, excluded);
  96. var key, i;
  97. if (Object.getOwnPropertySymbols) {
  98. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  99. for (i = 0; i < sourceSymbolKeys.length; i++) {
  100. key = sourceSymbolKeys[i];
  101. if (excluded.indexOf(key) >= 0)
  102. continue;
  103. if (!Object.prototype.propertyIsEnumerable.call(source, key))
  104. continue;
  105. target[key] = source[key];
  106. }
  107. }
  108. return target;
  109. }
  110. function _toConsumableArray(arr) {
  111. return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
  112. }
  113. function _arrayWithoutHoles(arr) {
  114. if (Array.isArray(arr))
  115. return _arrayLikeToArray(arr);
  116. }
  117. function _iterableToArray(iter) {
  118. if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
  119. return Array.from(iter);
  120. }
  121. function _unsupportedIterableToArray(o, minLen) {
  122. if (!o)
  123. return;
  124. if (typeof o === "string")
  125. return _arrayLikeToArray(o, minLen);
  126. var n = Object.prototype.toString.call(o).slice(8, -1);
  127. if (n === "Object" && o.constructor)
  128. n = o.constructor.name;
  129. if (n === "Map" || n === "Set")
  130. return Array.from(o);
  131. if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  132. return _arrayLikeToArray(o, minLen);
  133. }
  134. function _arrayLikeToArray(arr, len) {
  135. if (len == null || len > arr.length)
  136. len = arr.length;
  137. for (var i = 0, arr2 = new Array(len); i < len; i++)
  138. arr2[i] = arr[i];
  139. return arr2;
  140. }
  141. function _nonIterableSpread() {
  142. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  143. }
  144. var version = "1.15.0";
  145. function userAgent(pattern) {
  146. if (typeof window !== "undefined" && window.navigator) {
  147. return !!navigator.userAgent.match(pattern);
  148. }
  149. }
  150. var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
  151. var Edge = userAgent(/Edge/i);
  152. var FireFox = userAgent(/firefox/i);
  153. var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
  154. var IOS = userAgent(/iP(ad|od|hone)/i);
  155. var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
  156. var captureMode = {
  157. capture: false,
  158. passive: false
  159. };
  160. function on(el, event, fn) {
  161. el.addEventListener(event, fn, !IE11OrLess && captureMode);
  162. }
  163. function off(el, event, fn) {
  164. el.removeEventListener(event, fn, !IE11OrLess && captureMode);
  165. }
  166. function matches(el, selector) {
  167. if (!selector)
  168. return;
  169. selector[0] === ">" && (selector = selector.substring(1));
  170. if (el) {
  171. try {
  172. if (el.matches) {
  173. return el.matches(selector);
  174. } else if (el.msMatchesSelector) {
  175. return el.msMatchesSelector(selector);
  176. } else if (el.webkitMatchesSelector) {
  177. return el.webkitMatchesSelector(selector);
  178. }
  179. } catch (_) {
  180. return false;
  181. }
  182. }
  183. return false;
  184. }
  185. function getParentOrHost(el) {
  186. return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
  187. }
  188. function closest(el, selector, ctx, includeCTX) {
  189. if (el) {
  190. ctx = ctx || document;
  191. do {
  192. if (selector != null && (selector[0] === ">" ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
  193. return el;
  194. }
  195. if (el === ctx)
  196. break;
  197. } while (el = getParentOrHost(el));
  198. }
  199. return null;
  200. }
  201. var R_SPACE = /\s+/g;
  202. function toggleClass(el, name, state) {
  203. if (el && name) {
  204. if (el.classList) {
  205. el.classList[state ? "add" : "remove"](name);
  206. } else {
  207. var className = (" " + el.className + " ").replace(R_SPACE, " ").replace(" " + name + " ", " ");
  208. el.className = (className + (state ? " " + name : "")).replace(R_SPACE, " ");
  209. }
  210. }
  211. }
  212. function css(el, prop, val) {
  213. var style = el && el.style;
  214. if (style) {
  215. if (val === void 0) {
  216. if (document.defaultView && document.defaultView.getComputedStyle) {
  217. val = document.defaultView.getComputedStyle(el, "");
  218. } else if (el.currentStyle) {
  219. val = el.currentStyle;
  220. }
  221. return prop === void 0 ? val : val[prop];
  222. } else {
  223. if (!(prop in style) && prop.indexOf("webkit") === -1) {
  224. prop = "-webkit-" + prop;
  225. }
  226. style[prop] = val + (typeof val === "string" ? "" : "px");
  227. }
  228. }
  229. }
  230. function matrix(el, selfOnly) {
  231. var appliedTransforms = "";
  232. if (typeof el === "string") {
  233. appliedTransforms = el;
  234. } else {
  235. do {
  236. var transform = css(el, "transform");
  237. if (transform && transform !== "none") {
  238. appliedTransforms = transform + " " + appliedTransforms;
  239. }
  240. } while (!selfOnly && (el = el.parentNode));
  241. }
  242. var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
  243. return matrixFn && new matrixFn(appliedTransforms);
  244. }
  245. function find(ctx, tagName, iterator) {
  246. if (ctx) {
  247. var list = ctx.getElementsByTagName(tagName), i = 0, n = list.length;
  248. if (iterator) {
  249. for (; i < n; i++) {
  250. iterator(list[i], i);
  251. }
  252. }
  253. return list;
  254. }
  255. return [];
  256. }
  257. function getWindowScrollingElement() {
  258. var scrollingElement = document.scrollingElement;
  259. if (scrollingElement) {
  260. return scrollingElement;
  261. } else {
  262. return document.documentElement;
  263. }
  264. }
  265. function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
  266. if (!el.getBoundingClientRect && el !== window)
  267. return;
  268. var elRect, top, left, bottom, right, height, width;
  269. if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
  270. elRect = el.getBoundingClientRect();
  271. top = elRect.top;
  272. left = elRect.left;
  273. bottom = elRect.bottom;
  274. right = elRect.right;
  275. height = elRect.height;
  276. width = elRect.width;
  277. } else {
  278. top = 0;
  279. left = 0;
  280. bottom = window.innerHeight;
  281. right = window.innerWidth;
  282. height = window.innerHeight;
  283. width = window.innerWidth;
  284. }
  285. if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
  286. container = container || el.parentNode;
  287. if (!IE11OrLess) {
  288. do {
  289. if (container && container.getBoundingClientRect && (css(container, "transform") !== "none" || relativeToNonStaticParent && css(container, "position") !== "static")) {
  290. var containerRect = container.getBoundingClientRect();
  291. top -= containerRect.top + parseInt(css(container, "border-top-width"));
  292. left -= containerRect.left + parseInt(css(container, "border-left-width"));
  293. bottom = top + elRect.height;
  294. right = left + elRect.width;
  295. break;
  296. }
  297. } while (container = container.parentNode);
  298. }
  299. }
  300. if (undoScale && el !== window) {
  301. var elMatrix = matrix(container || el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d;
  302. if (elMatrix) {
  303. top /= scaleY;
  304. left /= scaleX;
  305. width /= scaleX;
  306. height /= scaleY;
  307. bottom = top + height;
  308. right = left + width;
  309. }
  310. }
  311. return {
  312. top,
  313. left,
  314. bottom,
  315. right,
  316. width,
  317. height
  318. };
  319. }
  320. function isScrolledPast(el, elSide, parentSide) {
  321. var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
  322. while (parent) {
  323. var parentSideVal = getRect(parent)[parentSide], visible = void 0;
  324. if (parentSide === "top" || parentSide === "left") {
  325. visible = elSideVal >= parentSideVal;
  326. } else {
  327. visible = elSideVal <= parentSideVal;
  328. }
  329. if (!visible)
  330. return parent;
  331. if (parent === getWindowScrollingElement())
  332. break;
  333. parent = getParentAutoScrollElement(parent, false);
  334. }
  335. return false;
  336. }
  337. function getChild(el, childNum, options, includeDragEl) {
  338. var currentChild = 0, i = 0, children = el.children;
  339. while (i < children.length) {
  340. if (children[i].style.display !== "none" && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
  341. if (currentChild === childNum) {
  342. return children[i];
  343. }
  344. currentChild++;
  345. }
  346. i++;
  347. }
  348. return null;
  349. }
  350. function lastChild(el, selector) {
  351. var last = el.lastElementChild;
  352. while (last && (last === Sortable.ghost || css(last, "display") === "none" || selector && !matches(last, selector))) {
  353. last = last.previousElementSibling;
  354. }
  355. return last || null;
  356. }
  357. function index(el, selector) {
  358. var index2 = 0;
  359. if (!el || !el.parentNode) {
  360. return -1;
  361. }
  362. while (el = el.previousElementSibling) {
  363. if (el.nodeName.toUpperCase() !== "TEMPLATE" && el !== Sortable.clone && (!selector || matches(el, selector))) {
  364. index2++;
  365. }
  366. }
  367. return index2;
  368. }
  369. function getRelativeScrollOffset(el) {
  370. var offsetLeft = 0, offsetTop = 0, winScroller = getWindowScrollingElement();
  371. if (el) {
  372. do {
  373. var elMatrix = matrix(el), scaleX = elMatrix.a, scaleY = elMatrix.d;
  374. offsetLeft += el.scrollLeft * scaleX;
  375. offsetTop += el.scrollTop * scaleY;
  376. } while (el !== winScroller && (el = el.parentNode));
  377. }
  378. return [offsetLeft, offsetTop];
  379. }
  380. function indexOfObject(arr, obj) {
  381. for (var i in arr) {
  382. if (!arr.hasOwnProperty(i))
  383. continue;
  384. for (var key in obj) {
  385. if (obj.hasOwnProperty(key) && obj[key] === arr[i][key])
  386. return Number(i);
  387. }
  388. }
  389. return -1;
  390. }
  391. function getParentAutoScrollElement(el, includeSelf) {
  392. if (!el || !el.getBoundingClientRect)
  393. return getWindowScrollingElement();
  394. var elem = el;
  395. var gotSelf = false;
  396. do {
  397. if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
  398. var elemCSS = css(elem);
  399. if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == "auto" || elemCSS.overflowX == "scroll") || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == "auto" || elemCSS.overflowY == "scroll")) {
  400. if (!elem.getBoundingClientRect || elem === document.body)
  401. return getWindowScrollingElement();
  402. if (gotSelf || includeSelf)
  403. return elem;
  404. gotSelf = true;
  405. }
  406. }
  407. } while (elem = elem.parentNode);
  408. return getWindowScrollingElement();
  409. }
  410. function extend(dst, src) {
  411. if (dst && src) {
  412. for (var key in src) {
  413. if (src.hasOwnProperty(key)) {
  414. dst[key] = src[key];
  415. }
  416. }
  417. }
  418. return dst;
  419. }
  420. function isRectEqual(rect1, rect2) {
  421. 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);
  422. }
  423. var _throttleTimeout;
  424. function throttle(callback, ms) {
  425. return function() {
  426. if (!_throttleTimeout) {
  427. var args = arguments, _this = this;
  428. if (args.length === 1) {
  429. callback.call(_this, args[0]);
  430. } else {
  431. callback.apply(_this, args);
  432. }
  433. _throttleTimeout = setTimeout(function() {
  434. _throttleTimeout = void 0;
  435. }, ms);
  436. }
  437. };
  438. }
  439. function cancelThrottle() {
  440. clearTimeout(_throttleTimeout);
  441. _throttleTimeout = void 0;
  442. }
  443. function scrollBy(el, x, y) {
  444. el.scrollLeft += x;
  445. el.scrollTop += y;
  446. }
  447. function clone(el) {
  448. var Polymer = window.Polymer;
  449. var $ = window.jQuery || window.Zepto;
  450. if (Polymer && Polymer.dom) {
  451. return Polymer.dom(el).cloneNode(true);
  452. } else if ($) {
  453. return $(el).clone(true)[0];
  454. } else {
  455. return el.cloneNode(true);
  456. }
  457. }
  458. function setRect(el, rect) {
  459. css(el, "position", "absolute");
  460. css(el, "top", rect.top);
  461. css(el, "left", rect.left);
  462. css(el, "width", rect.width);
  463. css(el, "height", rect.height);
  464. }
  465. function unsetRect(el) {
  466. css(el, "position", "");
  467. css(el, "top", "");
  468. css(el, "left", "");
  469. css(el, "width", "");
  470. css(el, "height", "");
  471. }
  472. var expando = "Sortable" + new Date().getTime();
  473. function AnimationStateManager() {
  474. var animationStates = [], animationCallbackId;
  475. return {
  476. captureAnimationState: function captureAnimationState() {
  477. animationStates = [];
  478. if (!this.options.animation)
  479. return;
  480. var children = [].slice.call(this.el.children);
  481. children.forEach(function(child) {
  482. if (css(child, "display") === "none" || child === Sortable.ghost)
  483. return;
  484. animationStates.push({
  485. target: child,
  486. rect: getRect(child)
  487. });
  488. var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
  489. if (child.thisAnimationDuration) {
  490. var childMatrix = matrix(child, true);
  491. if (childMatrix) {
  492. fromRect.top -= childMatrix.f;
  493. fromRect.left -= childMatrix.e;
  494. }
  495. }
  496. child.fromRect = fromRect;
  497. });
  498. },
  499. addAnimationState: function addAnimationState(state) {
  500. animationStates.push(state);
  501. },
  502. removeAnimationState: function removeAnimationState(target) {
  503. animationStates.splice(indexOfObject(animationStates, {
  504. target
  505. }), 1);
  506. },
  507. animateAll: function animateAll(callback) {
  508. var _this = this;
  509. if (!this.options.animation) {
  510. clearTimeout(animationCallbackId);
  511. if (typeof callback === "function")
  512. callback();
  513. return;
  514. }
  515. var animating = false, animationTime = 0;
  516. animationStates.forEach(function(state) {
  517. var time = 0, target = state.target, fromRect = target.fromRect, toRect = getRect(target), prevFromRect = target.prevFromRect, prevToRect = target.prevToRect, animatingRect = state.rect, targetMatrix = matrix(target, true);
  518. if (targetMatrix) {
  519. toRect.top -= targetMatrix.f;
  520. toRect.left -= targetMatrix.e;
  521. }
  522. target.toRect = toRect;
  523. if (target.thisAnimationDuration) {
  524. if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
  525. time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
  526. }
  527. }
  528. if (!isRectEqual(toRect, fromRect)) {
  529. target.prevFromRect = fromRect;
  530. target.prevToRect = toRect;
  531. if (!time) {
  532. time = _this.options.animation;
  533. }
  534. _this.animate(target, animatingRect, toRect, time);
  535. }
  536. if (time) {
  537. animating = true;
  538. animationTime = Math.max(animationTime, time);
  539. clearTimeout(target.animationResetTimer);
  540. target.animationResetTimer = setTimeout(function() {
  541. target.animationTime = 0;
  542. target.prevFromRect = null;
  543. target.fromRect = null;
  544. target.prevToRect = null;
  545. target.thisAnimationDuration = null;
  546. }, time);
  547. target.thisAnimationDuration = time;
  548. }
  549. });
  550. clearTimeout(animationCallbackId);
  551. if (!animating) {
  552. if (typeof callback === "function")
  553. callback();
  554. } else {
  555. animationCallbackId = setTimeout(function() {
  556. if (typeof callback === "function")
  557. callback();
  558. }, animationTime);
  559. }
  560. animationStates = [];
  561. },
  562. animate: function animate(target, currentRect, toRect, duration) {
  563. if (duration) {
  564. css(target, "transition", "");
  565. css(target, "transform", "");
  566. var elMatrix = matrix(this.el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d, translateX = (currentRect.left - toRect.left) / (scaleX || 1), translateY = (currentRect.top - toRect.top) / (scaleY || 1);
  567. target.animatingX = !!translateX;
  568. target.animatingY = !!translateY;
  569. css(target, "transform", "translate3d(" + translateX + "px," + translateY + "px,0)");
  570. this.forRepaintDummy = repaint(target);
  571. css(target, "transition", "transform " + duration + "ms" + (this.options.easing ? " " + this.options.easing : ""));
  572. css(target, "transform", "translate3d(0,0,0)");
  573. typeof target.animated === "number" && clearTimeout(target.animated);
  574. target.animated = setTimeout(function() {
  575. css(target, "transition", "");
  576. css(target, "transform", "");
  577. target.animated = false;
  578. target.animatingX = false;
  579. target.animatingY = false;
  580. }, duration);
  581. }
  582. }
  583. };
  584. }
  585. function repaint(target) {
  586. return target.offsetWidth;
  587. }
  588. function calculateRealTime(animatingRect, fromRect, toRect, options) {
  589. 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;
  590. }
  591. var plugins = [];
  592. var defaults = {
  593. initializeByDefault: true
  594. };
  595. var PluginManager = {
  596. mount: function mount(plugin) {
  597. for (var option2 in defaults) {
  598. if (defaults.hasOwnProperty(option2) && !(option2 in plugin)) {
  599. plugin[option2] = defaults[option2];
  600. }
  601. }
  602. plugins.forEach(function(p) {
  603. if (p.pluginName === plugin.pluginName) {
  604. throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
  605. }
  606. });
  607. plugins.push(plugin);
  608. },
  609. pluginEvent: function pluginEvent(eventName, sortable, evt) {
  610. var _this = this;
  611. this.eventCanceled = false;
  612. evt.cancel = function() {
  613. _this.eventCanceled = true;
  614. };
  615. var eventNameGlobal = eventName + "Global";
  616. plugins.forEach(function(plugin) {
  617. if (!sortable[plugin.pluginName])
  618. return;
  619. if (sortable[plugin.pluginName][eventNameGlobal]) {
  620. sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
  621. sortable
  622. }, evt));
  623. }
  624. if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
  625. sortable[plugin.pluginName][eventName](_objectSpread2({
  626. sortable
  627. }, evt));
  628. }
  629. });
  630. },
  631. initializePlugins: function initializePlugins(sortable, el, defaults2, options) {
  632. plugins.forEach(function(plugin) {
  633. var pluginName = plugin.pluginName;
  634. if (!sortable.options[pluginName] && !plugin.initializeByDefault)
  635. return;
  636. var initialized = new plugin(sortable, el, sortable.options);
  637. initialized.sortable = sortable;
  638. initialized.options = sortable.options;
  639. sortable[pluginName] = initialized;
  640. _extends(defaults2, initialized.defaults);
  641. });
  642. for (var option2 in sortable.options) {
  643. if (!sortable.options.hasOwnProperty(option2))
  644. continue;
  645. var modified = this.modifyOption(sortable, option2, sortable.options[option2]);
  646. if (typeof modified !== "undefined") {
  647. sortable.options[option2] = modified;
  648. }
  649. }
  650. },
  651. getEventProperties: function getEventProperties(name, sortable) {
  652. var eventProperties = {};
  653. plugins.forEach(function(plugin) {
  654. if (typeof plugin.eventProperties !== "function")
  655. return;
  656. _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
  657. });
  658. return eventProperties;
  659. },
  660. modifyOption: function modifyOption(sortable, name, value) {
  661. var modifiedValue;
  662. plugins.forEach(function(plugin) {
  663. if (!sortable[plugin.pluginName])
  664. return;
  665. if (plugin.optionListeners && typeof plugin.optionListeners[name] === "function") {
  666. modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
  667. }
  668. });
  669. return modifiedValue;
  670. }
  671. };
  672. function dispatchEvent(_ref) {
  673. var sortable = _ref.sortable, rootEl2 = _ref.rootEl, name = _ref.name, targetEl = _ref.targetEl, cloneEl2 = _ref.cloneEl, toEl = _ref.toEl, fromEl = _ref.fromEl, oldIndex2 = _ref.oldIndex, newIndex2 = _ref.newIndex, oldDraggableIndex2 = _ref.oldDraggableIndex, newDraggableIndex2 = _ref.newDraggableIndex, originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, extraEventProperties = _ref.extraEventProperties;
  674. sortable = sortable || rootEl2 && rootEl2[expando];
  675. if (!sortable)
  676. return;
  677. var evt, options = sortable.options, onName = "on" + name.charAt(0).toUpperCase() + name.substr(1);
  678. if (window.CustomEvent && !IE11OrLess && !Edge) {
  679. evt = new CustomEvent(name, {
  680. bubbles: true,
  681. cancelable: true
  682. });
  683. } else {
  684. evt = document.createEvent("Event");
  685. evt.initEvent(name, true, true);
  686. }
  687. evt.to = toEl || rootEl2;
  688. evt.from = fromEl || rootEl2;
  689. evt.item = targetEl || rootEl2;
  690. evt.clone = cloneEl2;
  691. evt.oldIndex = oldIndex2;
  692. evt.newIndex = newIndex2;
  693. evt.oldDraggableIndex = oldDraggableIndex2;
  694. evt.newDraggableIndex = newDraggableIndex2;
  695. evt.originalEvent = originalEvent;
  696. evt.pullMode = putSortable2 ? putSortable2.lastPutMode : void 0;
  697. var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
  698. for (var option2 in allEventProperties) {
  699. evt[option2] = allEventProperties[option2];
  700. }
  701. if (rootEl2) {
  702. rootEl2.dispatchEvent(evt);
  703. }
  704. if (options[onName]) {
  705. options[onName].call(sortable, evt);
  706. }
  707. }
  708. var _excluded = ["evt"];
  709. var pluginEvent2 = function pluginEvent3(eventName, sortable) {
  710. var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, originalEvent = _ref.evt, data = _objectWithoutProperties(_ref, _excluded);
  711. PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
  712. dragEl,
  713. parentEl,
  714. ghostEl,
  715. rootEl,
  716. nextEl,
  717. lastDownEl,
  718. cloneEl,
  719. cloneHidden,
  720. dragStarted: moved,
  721. putSortable,
  722. activeSortable: Sortable.active,
  723. originalEvent,
  724. oldIndex,
  725. oldDraggableIndex,
  726. newIndex,
  727. newDraggableIndex,
  728. hideGhostForTarget: _hideGhostForTarget,
  729. unhideGhostForTarget: _unhideGhostForTarget,
  730. cloneNowHidden: function cloneNowHidden() {
  731. cloneHidden = true;
  732. },
  733. cloneNowShown: function cloneNowShown() {
  734. cloneHidden = false;
  735. },
  736. dispatchSortableEvent: function dispatchSortableEvent(name) {
  737. _dispatchEvent({
  738. sortable,
  739. name,
  740. originalEvent
  741. });
  742. }
  743. }, data));
  744. };
  745. function _dispatchEvent(info) {
  746. dispatchEvent(_objectSpread2({
  747. putSortable,
  748. cloneEl,
  749. targetEl: dragEl,
  750. rootEl,
  751. oldIndex,
  752. oldDraggableIndex,
  753. newIndex,
  754. newDraggableIndex
  755. }, info));
  756. }
  757. var dragEl;
  758. var parentEl;
  759. var ghostEl;
  760. var rootEl;
  761. var nextEl;
  762. var lastDownEl;
  763. var cloneEl;
  764. var cloneHidden;
  765. var oldIndex;
  766. var newIndex;
  767. var oldDraggableIndex;
  768. var newDraggableIndex;
  769. var activeGroup;
  770. var putSortable;
  771. var awaitingDragStarted = false;
  772. var ignoreNextClick = false;
  773. var sortables = [];
  774. var tapEvt;
  775. var touchEvt;
  776. var lastDx;
  777. var lastDy;
  778. var tapDistanceLeft;
  779. var tapDistanceTop;
  780. var moved;
  781. var lastTarget;
  782. var lastDirection;
  783. var pastFirstInvertThresh = false;
  784. var isCircumstantialInvert = false;
  785. var targetMoveDistance;
  786. var ghostRelativeParent;
  787. var ghostRelativeParentInitialScroll = [];
  788. var _silent = false;
  789. var savedInputChecked = [];
  790. var documentExists = typeof document !== "undefined";
  791. var PositionGhostAbsolutely = IOS;
  792. var CSSFloatProperty = Edge || IE11OrLess ? "cssFloat" : "float";
  793. var supportDraggable = documentExists && !ChromeForAndroid && !IOS && "draggable" in document.createElement("div");
  794. var supportCssPointerEvents = function() {
  795. if (!documentExists)
  796. return;
  797. if (IE11OrLess) {
  798. return false;
  799. }
  800. var el = document.createElement("x");
  801. el.style.cssText = "pointer-events:auto";
  802. return el.style.pointerEvents === "auto";
  803. }();
  804. var _detectDirection = function _detectDirection2(el, options) {
  805. var elCSS = css(el), elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), child1 = getChild(el, 0, options), child2 = getChild(el, 1, options), firstChildCSS = child1 && css(child1), secondChildCSS = child2 && css(child2), firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width, secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
  806. if (elCSS.display === "flex") {
  807. return elCSS.flexDirection === "column" || elCSS.flexDirection === "column-reverse" ? "vertical" : "horizontal";
  808. }
  809. if (elCSS.display === "grid") {
  810. return elCSS.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
  811. }
  812. if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== "none") {
  813. var touchingSideChild2 = firstChildCSS["float"] === "left" ? "left" : "right";
  814. return child2 && (secondChildCSS.clear === "both" || secondChildCSS.clear === touchingSideChild2) ? "vertical" : "horizontal";
  815. }
  816. 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";
  817. };
  818. var _dragElInRowColumn = function _dragElInRowColumn2(dragRect, targetRect, vertical) {
  819. var dragElS1Opp = vertical ? dragRect.left : dragRect.top, dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, dragElOppLength = vertical ? dragRect.width : dragRect.height, targetS1Opp = vertical ? targetRect.left : targetRect.top, targetS2Opp = vertical ? targetRect.right : targetRect.bottom, targetOppLength = vertical ? targetRect.width : targetRect.height;
  820. return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
  821. };
  822. var _detectNearestEmptySortable = function _detectNearestEmptySortable2(x, y) {
  823. var ret;
  824. sortables.some(function(sortable) {
  825. var threshold = sortable[expando].options.emptyInsertThreshold;
  826. if (!threshold || lastChild(sortable))
  827. return;
  828. var rect = getRect(sortable), insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold, insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
  829. if (insideHorizontally && insideVertically) {
  830. return ret = sortable;
  831. }
  832. });
  833. return ret;
  834. };
  835. var _prepareGroup = function _prepareGroup2(options) {
  836. function toFn(value, pull) {
  837. return function(to, from, dragEl2, evt) {
  838. var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
  839. if (value == null && (pull || sameGroup)) {
  840. return true;
  841. } else if (value == null || value === false) {
  842. return false;
  843. } else if (pull && value === "clone") {
  844. return value;
  845. } else if (typeof value === "function") {
  846. return toFn(value(to, from, dragEl2, evt), pull)(to, from, dragEl2, evt);
  847. } else {
  848. var otherGroup = (pull ? to : from).options.group.name;
  849. return value === true || typeof value === "string" && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
  850. }
  851. };
  852. }
  853. var group = {};
  854. var originalGroup = options.group;
  855. if (!originalGroup || _typeof(originalGroup) != "object") {
  856. originalGroup = {
  857. name: originalGroup
  858. };
  859. }
  860. group.name = originalGroup.name;
  861. group.checkPull = toFn(originalGroup.pull, true);
  862. group.checkPut = toFn(originalGroup.put);
  863. group.revertClone = originalGroup.revertClone;
  864. options.group = group;
  865. };
  866. var _hideGhostForTarget = function _hideGhostForTarget2() {
  867. if (!supportCssPointerEvents && ghostEl) {
  868. css(ghostEl, "display", "none");
  869. }
  870. };
  871. var _unhideGhostForTarget = function _unhideGhostForTarget2() {
  872. if (!supportCssPointerEvents && ghostEl) {
  873. css(ghostEl, "display", "");
  874. }
  875. };
  876. if (documentExists && !ChromeForAndroid) {
  877. document.addEventListener("click", function(evt) {
  878. if (ignoreNextClick) {
  879. evt.preventDefault();
  880. evt.stopPropagation && evt.stopPropagation();
  881. evt.stopImmediatePropagation && evt.stopImmediatePropagation();
  882. ignoreNextClick = false;
  883. return false;
  884. }
  885. }, true);
  886. }
  887. var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent2(evt) {
  888. if (dragEl) {
  889. evt = evt.touches ? evt.touches[0] : evt;
  890. var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
  891. if (nearest) {
  892. var event = {};
  893. for (var i in evt) {
  894. if (evt.hasOwnProperty(i)) {
  895. event[i] = evt[i];
  896. }
  897. }
  898. event.target = event.rootEl = nearest;
  899. event.preventDefault = void 0;
  900. event.stopPropagation = void 0;
  901. nearest[expando]._onDragOver(event);
  902. }
  903. }
  904. };
  905. var _checkOutsideTargetEl = function _checkOutsideTargetEl2(evt) {
  906. if (dragEl) {
  907. dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
  908. }
  909. };
  910. function Sortable(el, options) {
  911. if (!(el && el.nodeType && el.nodeType === 1)) {
  912. throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
  913. }
  914. this.el = el;
  915. this.options = options = _extends({}, options);
  916. el[expando] = this;
  917. var defaults2 = {
  918. group: null,
  919. sort: true,
  920. disabled: false,
  921. store: null,
  922. handle: null,
  923. draggable: /^[uo]l$/i.test(el.nodeName) ? ">li" : ">*",
  924. swapThreshold: 1,
  925. invertSwap: false,
  926. invertedSwapThreshold: null,
  927. removeCloneOnHide: true,
  928. direction: function direction() {
  929. return _detectDirection(el, this.options);
  930. },
  931. ghostClass: "sortable-ghost",
  932. chosenClass: "sortable-chosen",
  933. dragClass: "sortable-drag",
  934. ignore: "a, img",
  935. filter: null,
  936. preventOnFilter: true,
  937. animation: 0,
  938. easing: null,
  939. setData: function setData(dataTransfer, dragEl2) {
  940. dataTransfer.setData("Text", dragEl2.textContent);
  941. },
  942. dropBubble: false,
  943. dragoverBubble: false,
  944. dataIdAttr: "data-id",
  945. delay: 0,
  946. delayOnTouchOnly: false,
  947. touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
  948. forceFallback: false,
  949. fallbackClass: "sortable-fallback",
  950. fallbackOnBody: false,
  951. fallbackTolerance: 0,
  952. fallbackOffset: {
  953. x: 0,
  954. y: 0
  955. },
  956. supportPointer: Sortable.supportPointer !== false && "PointerEvent" in window && !Safari,
  957. emptyInsertThreshold: 5
  958. };
  959. PluginManager.initializePlugins(this, el, defaults2);
  960. for (var name in defaults2) {
  961. !(name in options) && (options[name] = defaults2[name]);
  962. }
  963. _prepareGroup(options);
  964. for (var fn in this) {
  965. if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
  966. this[fn] = this[fn].bind(this);
  967. }
  968. }
  969. this.nativeDraggable = options.forceFallback ? false : supportDraggable;
  970. if (this.nativeDraggable) {
  971. this.options.touchStartThreshold = 1;
  972. }
  973. if (options.supportPointer) {
  974. on(el, "pointerdown", this._onTapStart);
  975. } else {
  976. on(el, "mousedown", this._onTapStart);
  977. on(el, "touchstart", this._onTapStart);
  978. }
  979. if (this.nativeDraggable) {
  980. on(el, "dragover", this);
  981. on(el, "dragenter", this);
  982. }
  983. sortables.push(this.el);
  984. options.store && options.store.get && this.sort(options.store.get(this) || []);
  985. _extends(this, AnimationStateManager());
  986. }
  987. Sortable.prototype = {
  988. constructor: Sortable,
  989. _isOutsideThisEl: function _isOutsideThisEl(target) {
  990. if (!this.el.contains(target) && target !== this.el) {
  991. lastTarget = null;
  992. }
  993. },
  994. _getDirection: function _getDirection(evt, target) {
  995. return typeof this.options.direction === "function" ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
  996. },
  997. _onTapStart: function _onTapStart(evt) {
  998. if (!evt.cancelable)
  999. return;
  1000. var _this = this, el = this.el, options = this.options, preventOnFilter = options.preventOnFilter, type = evt.type, touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === "touch" && evt, target = (touch || evt).target, originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target, filter = options.filter;
  1001. _saveInputCheckedState(el);
  1002. if (dragEl) {
  1003. return;
  1004. }
  1005. if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
  1006. return;
  1007. }
  1008. if (originalTarget.isContentEditable) {
  1009. return;
  1010. }
  1011. if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === "SELECT") {
  1012. return;
  1013. }
  1014. target = closest(target, options.draggable, el, false);
  1015. if (target && target.animated) {
  1016. return;
  1017. }
  1018. if (lastDownEl === target) {
  1019. return;
  1020. }
  1021. oldIndex = index(target);
  1022. oldDraggableIndex = index(target, options.draggable);
  1023. if (typeof filter === "function") {
  1024. if (filter.call(this, evt, target, this)) {
  1025. _dispatchEvent({
  1026. sortable: _this,
  1027. rootEl: originalTarget,
  1028. name: "filter",
  1029. targetEl: target,
  1030. toEl: el,
  1031. fromEl: el
  1032. });
  1033. pluginEvent2("filter", _this, {
  1034. evt
  1035. });
  1036. preventOnFilter && evt.cancelable && evt.preventDefault();
  1037. return;
  1038. }
  1039. } else if (filter) {
  1040. filter = filter.split(",").some(function(criteria) {
  1041. criteria = closest(originalTarget, criteria.trim(), el, false);
  1042. if (criteria) {
  1043. _dispatchEvent({
  1044. sortable: _this,
  1045. rootEl: criteria,
  1046. name: "filter",
  1047. targetEl: target,
  1048. fromEl: el,
  1049. toEl: el
  1050. });
  1051. pluginEvent2("filter", _this, {
  1052. evt
  1053. });
  1054. return true;
  1055. }
  1056. });
  1057. if (filter) {
  1058. preventOnFilter && evt.cancelable && evt.preventDefault();
  1059. return;
  1060. }
  1061. }
  1062. if (options.handle && !closest(originalTarget, options.handle, el, false)) {
  1063. return;
  1064. }
  1065. this._prepareDragStart(evt, touch, target);
  1066. },
  1067. _prepareDragStart: function _prepareDragStart(evt, touch, target) {
  1068. var _this = this, el = _this.el, options = _this.options, ownerDocument = el.ownerDocument, dragStartFn;
  1069. if (target && !dragEl && target.parentNode === el) {
  1070. var dragRect = getRect(target);
  1071. rootEl = el;
  1072. dragEl = target;
  1073. parentEl = dragEl.parentNode;
  1074. nextEl = dragEl.nextSibling;
  1075. lastDownEl = target;
  1076. activeGroup = options.group;
  1077. Sortable.dragged = dragEl;
  1078. tapEvt = {
  1079. target: dragEl,
  1080. clientX: (touch || evt).clientX,
  1081. clientY: (touch || evt).clientY
  1082. };
  1083. tapDistanceLeft = tapEvt.clientX - dragRect.left;
  1084. tapDistanceTop = tapEvt.clientY - dragRect.top;
  1085. this._lastX = (touch || evt).clientX;
  1086. this._lastY = (touch || evt).clientY;
  1087. dragEl.style["will-change"] = "all";
  1088. dragStartFn = function dragStartFn2() {
  1089. pluginEvent2("delayEnded", _this, {
  1090. evt
  1091. });
  1092. if (Sortable.eventCanceled) {
  1093. _this._onDrop();
  1094. return;
  1095. }
  1096. _this._disableDelayedDragEvents();
  1097. if (!FireFox && _this.nativeDraggable) {
  1098. dragEl.draggable = true;
  1099. }
  1100. _this._triggerDragStart(evt, touch);
  1101. _dispatchEvent({
  1102. sortable: _this,
  1103. name: "choose",
  1104. originalEvent: evt
  1105. });
  1106. toggleClass(dragEl, options.chosenClass, true);
  1107. };
  1108. options.ignore.split(",").forEach(function(criteria) {
  1109. find(dragEl, criteria.trim(), _disableDraggable);
  1110. });
  1111. on(ownerDocument, "dragover", nearestEmptyInsertDetectEvent);
  1112. on(ownerDocument, "mousemove", nearestEmptyInsertDetectEvent);
  1113. on(ownerDocument, "touchmove", nearestEmptyInsertDetectEvent);
  1114. on(ownerDocument, "mouseup", _this._onDrop);
  1115. on(ownerDocument, "touchend", _this._onDrop);
  1116. on(ownerDocument, "touchcancel", _this._onDrop);
  1117. if (FireFox && this.nativeDraggable) {
  1118. this.options.touchStartThreshold = 4;
  1119. dragEl.draggable = true;
  1120. }
  1121. pluginEvent2("delayStart", this, {
  1122. evt
  1123. });
  1124. if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
  1125. if (Sortable.eventCanceled) {
  1126. this._onDrop();
  1127. return;
  1128. }
  1129. on(ownerDocument, "mouseup", _this._disableDelayedDrag);
  1130. on(ownerDocument, "touchend", _this._disableDelayedDrag);
  1131. on(ownerDocument, "touchcancel", _this._disableDelayedDrag);
  1132. on(ownerDocument, "mousemove", _this._delayedDragTouchMoveHandler);
  1133. on(ownerDocument, "touchmove", _this._delayedDragTouchMoveHandler);
  1134. options.supportPointer && on(ownerDocument, "pointermove", _this._delayedDragTouchMoveHandler);
  1135. _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
  1136. } else {
  1137. dragStartFn();
  1138. }
  1139. }
  1140. },
  1141. _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e) {
  1142. var touch = e.touches ? e.touches[0] : e;
  1143. 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))) {
  1144. this._disableDelayedDrag();
  1145. }
  1146. },
  1147. _disableDelayedDrag: function _disableDelayedDrag() {
  1148. dragEl && _disableDraggable(dragEl);
  1149. clearTimeout(this._dragStartTimer);
  1150. this._disableDelayedDragEvents();
  1151. },
  1152. _disableDelayedDragEvents: function _disableDelayedDragEvents() {
  1153. var ownerDocument = this.el.ownerDocument;
  1154. off(ownerDocument, "mouseup", this._disableDelayedDrag);
  1155. off(ownerDocument, "touchend", this._disableDelayedDrag);
  1156. off(ownerDocument, "touchcancel", this._disableDelayedDrag);
  1157. off(ownerDocument, "mousemove", this._delayedDragTouchMoveHandler);
  1158. off(ownerDocument, "touchmove", this._delayedDragTouchMoveHandler);
  1159. off(ownerDocument, "pointermove", this._delayedDragTouchMoveHandler);
  1160. },
  1161. _triggerDragStart: function _triggerDragStart(evt, touch) {
  1162. touch = touch || evt.pointerType == "touch" && evt;
  1163. if (!this.nativeDraggable || touch) {
  1164. if (this.options.supportPointer) {
  1165. on(document, "pointermove", this._onTouchMove);
  1166. } else if (touch) {
  1167. on(document, "touchmove", this._onTouchMove);
  1168. } else {
  1169. on(document, "mousemove", this._onTouchMove);
  1170. }
  1171. } else {
  1172. on(dragEl, "dragend", this);
  1173. on(rootEl, "dragstart", this._onDragStart);
  1174. }
  1175. try {
  1176. if (document.selection) {
  1177. _nextTick(function() {
  1178. document.selection.empty();
  1179. });
  1180. } else {
  1181. window.getSelection().removeAllRanges();
  1182. }
  1183. } catch (err) {
  1184. }
  1185. },
  1186. _dragStarted: function _dragStarted(fallback, evt) {
  1187. awaitingDragStarted = false;
  1188. if (rootEl && dragEl) {
  1189. pluginEvent2("dragStarted", this, {
  1190. evt
  1191. });
  1192. if (this.nativeDraggable) {
  1193. on(document, "dragover", _checkOutsideTargetEl);
  1194. }
  1195. var options = this.options;
  1196. !fallback && toggleClass(dragEl, options.dragClass, false);
  1197. toggleClass(dragEl, options.ghostClass, true);
  1198. Sortable.active = this;
  1199. fallback && this._appendGhost();
  1200. _dispatchEvent({
  1201. sortable: this,
  1202. name: "start",
  1203. originalEvent: evt
  1204. });
  1205. } else {
  1206. this._nulling();
  1207. }
  1208. },
  1209. _emulateDragOver: function _emulateDragOver() {
  1210. if (touchEvt) {
  1211. this._lastX = touchEvt.clientX;
  1212. this._lastY = touchEvt.clientY;
  1213. _hideGhostForTarget();
  1214. var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
  1215. var parent = target;
  1216. while (target && target.shadowRoot) {
  1217. target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
  1218. if (target === parent)
  1219. break;
  1220. parent = target;
  1221. }
  1222. dragEl.parentNode[expando]._isOutsideThisEl(target);
  1223. if (parent) {
  1224. do {
  1225. if (parent[expando]) {
  1226. var inserted = void 0;
  1227. inserted = parent[expando]._onDragOver({
  1228. clientX: touchEvt.clientX,
  1229. clientY: touchEvt.clientY,
  1230. target,
  1231. rootEl: parent
  1232. });
  1233. if (inserted && !this.options.dragoverBubble) {
  1234. break;
  1235. }
  1236. }
  1237. target = parent;
  1238. } while (parent = parent.parentNode);
  1239. }
  1240. _unhideGhostForTarget();
  1241. }
  1242. },
  1243. _onTouchMove: function _onTouchMove(evt) {
  1244. if (tapEvt) {
  1245. var options = this.options, fallbackTolerance = options.fallbackTolerance, fallbackOffset = options.fallbackOffset, touch = evt.touches ? evt.touches[0] : evt, ghostMatrix = ghostEl && matrix(ghostEl, true), scaleX = ghostEl && ghostMatrix && ghostMatrix.a, scaleY = ghostEl && ghostMatrix && ghostMatrix.d, relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent), dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
  1246. if (!Sortable.active && !awaitingDragStarted) {
  1247. if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
  1248. return;
  1249. }
  1250. this._onDragStart(evt, true);
  1251. }
  1252. if (ghostEl) {
  1253. if (ghostMatrix) {
  1254. ghostMatrix.e += dx - (lastDx || 0);
  1255. ghostMatrix.f += dy - (lastDy || 0);
  1256. } else {
  1257. ghostMatrix = {
  1258. a: 1,
  1259. b: 0,
  1260. c: 0,
  1261. d: 1,
  1262. e: dx,
  1263. f: dy
  1264. };
  1265. }
  1266. var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
  1267. css(ghostEl, "webkitTransform", cssMatrix);
  1268. css(ghostEl, "mozTransform", cssMatrix);
  1269. css(ghostEl, "msTransform", cssMatrix);
  1270. css(ghostEl, "transform", cssMatrix);
  1271. lastDx = dx;
  1272. lastDy = dy;
  1273. touchEvt = touch;
  1274. }
  1275. evt.cancelable && evt.preventDefault();
  1276. }
  1277. },
  1278. _appendGhost: function _appendGhost() {
  1279. if (!ghostEl) {
  1280. var container = this.options.fallbackOnBody ? document.body : rootEl, rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container), options = this.options;
  1281. if (PositionGhostAbsolutely) {
  1282. ghostRelativeParent = container;
  1283. while (css(ghostRelativeParent, "position") === "static" && css(ghostRelativeParent, "transform") === "none" && ghostRelativeParent !== document) {
  1284. ghostRelativeParent = ghostRelativeParent.parentNode;
  1285. }
  1286. if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
  1287. if (ghostRelativeParent === document)
  1288. ghostRelativeParent = getWindowScrollingElement();
  1289. rect.top += ghostRelativeParent.scrollTop;
  1290. rect.left += ghostRelativeParent.scrollLeft;
  1291. } else {
  1292. ghostRelativeParent = getWindowScrollingElement();
  1293. }
  1294. ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
  1295. }
  1296. ghostEl = dragEl.cloneNode(true);
  1297. toggleClass(ghostEl, options.ghostClass, false);
  1298. toggleClass(ghostEl, options.fallbackClass, true);
  1299. toggleClass(ghostEl, options.dragClass, true);
  1300. css(ghostEl, "transition", "");
  1301. css(ghostEl, "transform", "");
  1302. css(ghostEl, "box-sizing", "border-box");
  1303. css(ghostEl, "margin", 0);
  1304. css(ghostEl, "top", rect.top);
  1305. css(ghostEl, "left", rect.left);
  1306. css(ghostEl, "width", rect.width);
  1307. css(ghostEl, "height", rect.height);
  1308. css(ghostEl, "opacity", "0.8");
  1309. css(ghostEl, "position", PositionGhostAbsolutely ? "absolute" : "fixed");
  1310. css(ghostEl, "zIndex", "100000");
  1311. css(ghostEl, "pointerEvents", "none");
  1312. Sortable.ghost = ghostEl;
  1313. container.appendChild(ghostEl);
  1314. css(ghostEl, "transform-origin", tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + "% " + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + "%");
  1315. }
  1316. },
  1317. _onDragStart: function _onDragStart(evt, fallback) {
  1318. var _this = this;
  1319. var dataTransfer = evt.dataTransfer;
  1320. var options = _this.options;
  1321. pluginEvent2("dragStart", this, {
  1322. evt
  1323. });
  1324. if (Sortable.eventCanceled) {
  1325. this._onDrop();
  1326. return;
  1327. }
  1328. pluginEvent2("setupClone", this);
  1329. if (!Sortable.eventCanceled) {
  1330. cloneEl = clone(dragEl);
  1331. cloneEl.removeAttribute("id");
  1332. cloneEl.draggable = false;
  1333. cloneEl.style["will-change"] = "";
  1334. this._hideClone();
  1335. toggleClass(cloneEl, this.options.chosenClass, false);
  1336. Sortable.clone = cloneEl;
  1337. }
  1338. _this.cloneId = _nextTick(function() {
  1339. pluginEvent2("clone", _this);
  1340. if (Sortable.eventCanceled)
  1341. return;
  1342. if (!_this.options.removeCloneOnHide) {
  1343. rootEl.insertBefore(cloneEl, dragEl);
  1344. }
  1345. _this._hideClone();
  1346. _dispatchEvent({
  1347. sortable: _this,
  1348. name: "clone"
  1349. });
  1350. });
  1351. !fallback && toggleClass(dragEl, options.dragClass, true);
  1352. if (fallback) {
  1353. ignoreNextClick = true;
  1354. _this._loopId = setInterval(_this._emulateDragOver, 50);
  1355. } else {
  1356. off(document, "mouseup", _this._onDrop);
  1357. off(document, "touchend", _this._onDrop);
  1358. off(document, "touchcancel", _this._onDrop);
  1359. if (dataTransfer) {
  1360. dataTransfer.effectAllowed = "move";
  1361. options.setData && options.setData.call(_this, dataTransfer, dragEl);
  1362. }
  1363. on(document, "drop", _this);
  1364. css(dragEl, "transform", "translateZ(0)");
  1365. }
  1366. awaitingDragStarted = true;
  1367. _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
  1368. on(document, "selectstart", _this);
  1369. moved = true;
  1370. if (Safari) {
  1371. css(document.body, "user-select", "none");
  1372. }
  1373. },
  1374. _onDragOver: function _onDragOver(evt) {
  1375. var el = this.el, target = evt.target, dragRect, targetRect, revert, options = this.options, group = options.group, activeSortable = Sortable.active, isOwner = activeGroup === group, canSort = options.sort, fromSortable = putSortable || activeSortable, vertical, _this = this, completedFired = false;
  1376. if (_silent)
  1377. return;
  1378. function dragOverEvent(name, extra) {
  1379. pluginEvent2(name, _this, _objectSpread2({
  1380. evt,
  1381. isOwner,
  1382. axis: vertical ? "vertical" : "horizontal",
  1383. revert,
  1384. dragRect,
  1385. targetRect,
  1386. canSort,
  1387. fromSortable,
  1388. target,
  1389. completed,
  1390. onMove: function onMove(target2, after2) {
  1391. return _onMove(rootEl, el, dragEl, dragRect, target2, getRect(target2), evt, after2);
  1392. },
  1393. changed
  1394. }, extra));
  1395. }
  1396. function capture() {
  1397. dragOverEvent("dragOverAnimationCapture");
  1398. _this.captureAnimationState();
  1399. if (_this !== fromSortable) {
  1400. fromSortable.captureAnimationState();
  1401. }
  1402. }
  1403. function completed(insertion) {
  1404. dragOverEvent("dragOverCompleted", {
  1405. insertion
  1406. });
  1407. if (insertion) {
  1408. if (isOwner) {
  1409. activeSortable._hideClone();
  1410. } else {
  1411. activeSortable._showClone(_this);
  1412. }
  1413. if (_this !== fromSortable) {
  1414. toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
  1415. toggleClass(dragEl, options.ghostClass, true);
  1416. }
  1417. if (putSortable !== _this && _this !== Sortable.active) {
  1418. putSortable = _this;
  1419. } else if (_this === Sortable.active && putSortable) {
  1420. putSortable = null;
  1421. }
  1422. if (fromSortable === _this) {
  1423. _this._ignoreWhileAnimating = target;
  1424. }
  1425. _this.animateAll(function() {
  1426. dragOverEvent("dragOverAnimationComplete");
  1427. _this._ignoreWhileAnimating = null;
  1428. });
  1429. if (_this !== fromSortable) {
  1430. fromSortable.animateAll();
  1431. fromSortable._ignoreWhileAnimating = null;
  1432. }
  1433. }
  1434. if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
  1435. lastTarget = null;
  1436. }
  1437. if (!options.dragoverBubble && !evt.rootEl && target !== document) {
  1438. dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
  1439. !insertion && nearestEmptyInsertDetectEvent(evt);
  1440. }
  1441. !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
  1442. return completedFired = true;
  1443. }
  1444. function changed() {
  1445. newIndex = index(dragEl);
  1446. newDraggableIndex = index(dragEl, options.draggable);
  1447. _dispatchEvent({
  1448. sortable: _this,
  1449. name: "change",
  1450. toEl: el,
  1451. newIndex,
  1452. newDraggableIndex,
  1453. originalEvent: evt
  1454. });
  1455. }
  1456. if (evt.preventDefault !== void 0) {
  1457. evt.cancelable && evt.preventDefault();
  1458. }
  1459. target = closest(target, options.draggable, el, true);
  1460. dragOverEvent("dragOver");
  1461. if (Sortable.eventCanceled)
  1462. return completedFired;
  1463. if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
  1464. return completed(false);
  1465. }
  1466. ignoreNextClick = false;
  1467. if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
  1468. vertical = this._getDirection(evt, target) === "vertical";
  1469. dragRect = getRect(dragEl);
  1470. dragOverEvent("dragOverValid");
  1471. if (Sortable.eventCanceled)
  1472. return completedFired;
  1473. if (revert) {
  1474. parentEl = rootEl;
  1475. capture();
  1476. this._hideClone();
  1477. dragOverEvent("revert");
  1478. if (!Sortable.eventCanceled) {
  1479. if (nextEl) {
  1480. rootEl.insertBefore(dragEl, nextEl);
  1481. } else {
  1482. rootEl.appendChild(dragEl);
  1483. }
  1484. }
  1485. return completed(true);
  1486. }
  1487. var elLastChild = lastChild(el, options.draggable);
  1488. if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
  1489. if (elLastChild === dragEl) {
  1490. return completed(false);
  1491. }
  1492. if (elLastChild && el === evt.target) {
  1493. target = elLastChild;
  1494. }
  1495. if (target) {
  1496. targetRect = getRect(target);
  1497. }
  1498. if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
  1499. capture();
  1500. if (elLastChild && elLastChild.nextSibling) {
  1501. el.insertBefore(dragEl, elLastChild.nextSibling);
  1502. } else {
  1503. el.appendChild(dragEl);
  1504. }
  1505. parentEl = el;
  1506. changed();
  1507. return completed(true);
  1508. }
  1509. } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
  1510. var firstChild = getChild(el, 0, options, true);
  1511. if (firstChild === dragEl) {
  1512. return completed(false);
  1513. }
  1514. target = firstChild;
  1515. targetRect = getRect(target);
  1516. if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
  1517. capture();
  1518. el.insertBefore(dragEl, firstChild);
  1519. parentEl = el;
  1520. changed();
  1521. return completed(true);
  1522. }
  1523. } else if (target.parentNode === el) {
  1524. targetRect = getRect(target);
  1525. var direction = 0, targetBeforeFirstSwap, differentLevel = dragEl.parentNode !== el, differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical), side1 = vertical ? "top" : "left", scrolledPastTop = isScrolledPast(target, "top", "top") || isScrolledPast(dragEl, "top", "top"), scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
  1526. if (lastTarget !== target) {
  1527. targetBeforeFirstSwap = targetRect[side1];
  1528. pastFirstInvertThresh = false;
  1529. isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
  1530. }
  1531. direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
  1532. var sibling;
  1533. if (direction !== 0) {
  1534. var dragIndex = index(dragEl);
  1535. do {
  1536. dragIndex -= direction;
  1537. sibling = parentEl.children[dragIndex];
  1538. } while (sibling && (css(sibling, "display") === "none" || sibling === ghostEl));
  1539. }
  1540. if (direction === 0 || sibling === target) {
  1541. return completed(false);
  1542. }
  1543. lastTarget = target;
  1544. lastDirection = direction;
  1545. var nextSibling = target.nextElementSibling, after = false;
  1546. after = direction === 1;
  1547. var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
  1548. if (moveVector !== false) {
  1549. if (moveVector === 1 || moveVector === -1) {
  1550. after = moveVector === 1;
  1551. }
  1552. _silent = true;
  1553. setTimeout(_unsilent, 30);
  1554. capture();
  1555. if (after && !nextSibling) {
  1556. el.appendChild(dragEl);
  1557. } else {
  1558. target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
  1559. }
  1560. if (scrolledPastTop) {
  1561. scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
  1562. }
  1563. parentEl = dragEl.parentNode;
  1564. if (targetBeforeFirstSwap !== void 0 && !isCircumstantialInvert) {
  1565. targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
  1566. }
  1567. changed();
  1568. return completed(true);
  1569. }
  1570. }
  1571. if (el.contains(dragEl)) {
  1572. return completed(false);
  1573. }
  1574. }
  1575. return false;
  1576. },
  1577. _ignoreWhileAnimating: null,
  1578. _offMoveEvents: function _offMoveEvents() {
  1579. off(document, "mousemove", this._onTouchMove);
  1580. off(document, "touchmove", this._onTouchMove);
  1581. off(document, "pointermove", this._onTouchMove);
  1582. off(document, "dragover", nearestEmptyInsertDetectEvent);
  1583. off(document, "mousemove", nearestEmptyInsertDetectEvent);
  1584. off(document, "touchmove", nearestEmptyInsertDetectEvent);
  1585. },
  1586. _offUpEvents: function _offUpEvents() {
  1587. var ownerDocument = this.el.ownerDocument;
  1588. off(ownerDocument, "mouseup", this._onDrop);
  1589. off(ownerDocument, "touchend", this._onDrop);
  1590. off(ownerDocument, "pointerup", this._onDrop);
  1591. off(ownerDocument, "touchcancel", this._onDrop);
  1592. off(document, "selectstart", this);
  1593. },
  1594. _onDrop: function _onDrop(evt) {
  1595. var el = this.el, options = this.options;
  1596. newIndex = index(dragEl);
  1597. newDraggableIndex = index(dragEl, options.draggable);
  1598. pluginEvent2("drop", this, {
  1599. evt
  1600. });
  1601. parentEl = dragEl && dragEl.parentNode;
  1602. newIndex = index(dragEl);
  1603. newDraggableIndex = index(dragEl, options.draggable);
  1604. if (Sortable.eventCanceled) {
  1605. this._nulling();
  1606. return;
  1607. }
  1608. awaitingDragStarted = false;
  1609. isCircumstantialInvert = false;
  1610. pastFirstInvertThresh = false;
  1611. clearInterval(this._loopId);
  1612. clearTimeout(this._dragStartTimer);
  1613. _cancelNextTick(this.cloneId);
  1614. _cancelNextTick(this._dragStartId);
  1615. if (this.nativeDraggable) {
  1616. off(document, "drop", this);
  1617. off(el, "dragstart", this._onDragStart);
  1618. }
  1619. this._offMoveEvents();
  1620. this._offUpEvents();
  1621. if (Safari) {
  1622. css(document.body, "user-select", "");
  1623. }
  1624. css(dragEl, "transform", "");
  1625. if (evt) {
  1626. if (moved) {
  1627. evt.cancelable && evt.preventDefault();
  1628. !options.dropBubble && evt.stopPropagation();
  1629. }
  1630. ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
  1631. if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== "clone") {
  1632. cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
  1633. }
  1634. if (dragEl) {
  1635. if (this.nativeDraggable) {
  1636. off(dragEl, "dragend", this);
  1637. }
  1638. _disableDraggable(dragEl);
  1639. dragEl.style["will-change"] = "";
  1640. if (moved && !awaitingDragStarted) {
  1641. toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
  1642. }
  1643. toggleClass(dragEl, this.options.chosenClass, false);
  1644. _dispatchEvent({
  1645. sortable: this,
  1646. name: "unchoose",
  1647. toEl: parentEl,
  1648. newIndex: null,
  1649. newDraggableIndex: null,
  1650. originalEvent: evt
  1651. });
  1652. if (rootEl !== parentEl) {
  1653. if (newIndex >= 0) {
  1654. _dispatchEvent({
  1655. rootEl: parentEl,
  1656. name: "add",
  1657. toEl: parentEl,
  1658. fromEl: rootEl,
  1659. originalEvent: evt
  1660. });
  1661. _dispatchEvent({
  1662. sortable: this,
  1663. name: "remove",
  1664. toEl: parentEl,
  1665. originalEvent: evt
  1666. });
  1667. _dispatchEvent({
  1668. rootEl: parentEl,
  1669. name: "sort",
  1670. toEl: parentEl,
  1671. fromEl: rootEl,
  1672. originalEvent: evt
  1673. });
  1674. _dispatchEvent({
  1675. sortable: this,
  1676. name: "sort",
  1677. toEl: parentEl,
  1678. originalEvent: evt
  1679. });
  1680. }
  1681. putSortable && putSortable.save();
  1682. } else {
  1683. if (newIndex !== oldIndex) {
  1684. if (newIndex >= 0) {
  1685. _dispatchEvent({
  1686. sortable: this,
  1687. name: "update",
  1688. toEl: parentEl,
  1689. originalEvent: evt
  1690. });
  1691. _dispatchEvent({
  1692. sortable: this,
  1693. name: "sort",
  1694. toEl: parentEl,
  1695. originalEvent: evt
  1696. });
  1697. }
  1698. }
  1699. }
  1700. if (Sortable.active) {
  1701. if (newIndex == null || newIndex === -1) {
  1702. newIndex = oldIndex;
  1703. newDraggableIndex = oldDraggableIndex;
  1704. }
  1705. _dispatchEvent({
  1706. sortable: this,
  1707. name: "end",
  1708. toEl: parentEl,
  1709. originalEvent: evt
  1710. });
  1711. this.save();
  1712. }
  1713. }
  1714. }
  1715. this._nulling();
  1716. },
  1717. _nulling: function _nulling() {
  1718. pluginEvent2("nulling", this);
  1719. 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;
  1720. savedInputChecked.forEach(function(el) {
  1721. el.checked = true;
  1722. });
  1723. savedInputChecked.length = lastDx = lastDy = 0;
  1724. },
  1725. handleEvent: function handleEvent(evt) {
  1726. switch (evt.type) {
  1727. case "drop":
  1728. case "dragend":
  1729. this._onDrop(evt);
  1730. break;
  1731. case "dragenter":
  1732. case "dragover":
  1733. if (dragEl) {
  1734. this._onDragOver(evt);
  1735. _globalDragOver(evt);
  1736. }
  1737. break;
  1738. case "selectstart":
  1739. evt.preventDefault();
  1740. break;
  1741. }
  1742. },
  1743. toArray: function toArray() {
  1744. var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
  1745. for (; i < n; i++) {
  1746. el = children[i];
  1747. if (closest(el, options.draggable, this.el, false)) {
  1748. order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
  1749. }
  1750. }
  1751. return order;
  1752. },
  1753. sort: function sort(order, useAnimation) {
  1754. var items = {}, rootEl2 = this.el;
  1755. this.toArray().forEach(function(id, i) {
  1756. var el = rootEl2.children[i];
  1757. if (closest(el, this.options.draggable, rootEl2, false)) {
  1758. items[id] = el;
  1759. }
  1760. }, this);
  1761. useAnimation && this.captureAnimationState();
  1762. order.forEach(function(id) {
  1763. if (items[id]) {
  1764. rootEl2.removeChild(items[id]);
  1765. rootEl2.appendChild(items[id]);
  1766. }
  1767. });
  1768. useAnimation && this.animateAll();
  1769. },
  1770. save: function save() {
  1771. var store = this.options.store;
  1772. store && store.set && store.set(this);
  1773. },
  1774. closest: function closest$1(el, selector) {
  1775. return closest(el, selector || this.options.draggable, this.el, false);
  1776. },
  1777. option: function option(name, value) {
  1778. var options = this.options;
  1779. if (value === void 0) {
  1780. return options[name];
  1781. } else {
  1782. var modifiedValue = PluginManager.modifyOption(this, name, value);
  1783. if (typeof modifiedValue !== "undefined") {
  1784. options[name] = modifiedValue;
  1785. } else {
  1786. options[name] = value;
  1787. }
  1788. if (name === "group") {
  1789. _prepareGroup(options);
  1790. }
  1791. }
  1792. },
  1793. destroy: function destroy() {
  1794. pluginEvent2("destroy", this);
  1795. var el = this.el;
  1796. el[expando] = null;
  1797. off(el, "mousedown", this._onTapStart);
  1798. off(el, "touchstart", this._onTapStart);
  1799. off(el, "pointerdown", this._onTapStart);
  1800. if (this.nativeDraggable) {
  1801. off(el, "dragover", this);
  1802. off(el, "dragenter", this);
  1803. }
  1804. Array.prototype.forEach.call(el.querySelectorAll("[draggable]"), function(el2) {
  1805. el2.removeAttribute("draggable");
  1806. });
  1807. this._onDrop();
  1808. this._disableDelayedDragEvents();
  1809. sortables.splice(sortables.indexOf(this.el), 1);
  1810. this.el = el = null;
  1811. },
  1812. _hideClone: function _hideClone() {
  1813. if (!cloneHidden) {
  1814. pluginEvent2("hideClone", this);
  1815. if (Sortable.eventCanceled)
  1816. return;
  1817. css(cloneEl, "display", "none");
  1818. if (this.options.removeCloneOnHide && cloneEl.parentNode) {
  1819. cloneEl.parentNode.removeChild(cloneEl);
  1820. }
  1821. cloneHidden = true;
  1822. }
  1823. },
  1824. _showClone: function _showClone(putSortable2) {
  1825. if (putSortable2.lastPutMode !== "clone") {
  1826. this._hideClone();
  1827. return;
  1828. }
  1829. if (cloneHidden) {
  1830. pluginEvent2("showClone", this);
  1831. if (Sortable.eventCanceled)
  1832. return;
  1833. if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
  1834. rootEl.insertBefore(cloneEl, dragEl);
  1835. } else if (nextEl) {
  1836. rootEl.insertBefore(cloneEl, nextEl);
  1837. } else {
  1838. rootEl.appendChild(cloneEl);
  1839. }
  1840. if (this.options.group.revertClone) {
  1841. this.animate(dragEl, cloneEl);
  1842. }
  1843. css(cloneEl, "display", "");
  1844. cloneHidden = false;
  1845. }
  1846. }
  1847. };
  1848. function _globalDragOver(evt) {
  1849. if (evt.dataTransfer) {
  1850. evt.dataTransfer.dropEffect = "move";
  1851. }
  1852. evt.cancelable && evt.preventDefault();
  1853. }
  1854. function _onMove(fromEl, toEl, dragEl2, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
  1855. var evt, sortable = fromEl[expando], onMoveFn = sortable.options.onMove, retVal;
  1856. if (window.CustomEvent && !IE11OrLess && !Edge) {
  1857. evt = new CustomEvent("move", {
  1858. bubbles: true,
  1859. cancelable: true
  1860. });
  1861. } else {
  1862. evt = document.createEvent("Event");
  1863. evt.initEvent("move", true, true);
  1864. }
  1865. evt.to = toEl;
  1866. evt.from = fromEl;
  1867. evt.dragged = dragEl2;
  1868. evt.draggedRect = dragRect;
  1869. evt.related = targetEl || toEl;
  1870. evt.relatedRect = targetRect || getRect(toEl);
  1871. evt.willInsertAfter = willInsertAfter;
  1872. evt.originalEvent = originalEvent;
  1873. fromEl.dispatchEvent(evt);
  1874. if (onMoveFn) {
  1875. retVal = onMoveFn.call(sortable, evt, originalEvent);
  1876. }
  1877. return retVal;
  1878. }
  1879. function _disableDraggable(el) {
  1880. el.draggable = false;
  1881. }
  1882. function _unsilent() {
  1883. _silent = false;
  1884. }
  1885. function _ghostIsFirst(evt, vertical, sortable) {
  1886. var rect = getRect(getChild(sortable.el, 0, sortable.options, true));
  1887. var spacer = 10;
  1888. 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;
  1889. }
  1890. function _ghostIsLast(evt, vertical, sortable) {
  1891. var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
  1892. var spacer = 10;
  1893. 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;
  1894. }
  1895. function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
  1896. var mouseOnAxis = vertical ? evt.clientY : evt.clientX, targetLength = vertical ? targetRect.height : targetRect.width, targetS1 = vertical ? targetRect.top : targetRect.left, targetS2 = vertical ? targetRect.bottom : targetRect.right, invert = false;
  1897. if (!invertSwap) {
  1898. if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
  1899. if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
  1900. pastFirstInvertThresh = true;
  1901. }
  1902. if (!pastFirstInvertThresh) {
  1903. if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance : mouseOnAxis > targetS2 - targetMoveDistance) {
  1904. return -lastDirection;
  1905. }
  1906. } else {
  1907. invert = true;
  1908. }
  1909. } else {
  1910. if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
  1911. return _getInsertDirection(target);
  1912. }
  1913. }
  1914. }
  1915. invert = invert || invertSwap;
  1916. if (invert) {
  1917. if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
  1918. return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
  1919. }
  1920. }
  1921. return 0;
  1922. }
  1923. function _getInsertDirection(target) {
  1924. if (index(dragEl) < index(target)) {
  1925. return 1;
  1926. } else {
  1927. return -1;
  1928. }
  1929. }
  1930. function _generateId(el) {
  1931. var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
  1932. while (i--) {
  1933. sum += str.charCodeAt(i);
  1934. }
  1935. return sum.toString(36);
  1936. }
  1937. function _saveInputCheckedState(root) {
  1938. savedInputChecked.length = 0;
  1939. var inputs = root.getElementsByTagName("input");
  1940. var idx = inputs.length;
  1941. while (idx--) {
  1942. var el = inputs[idx];
  1943. el.checked && savedInputChecked.push(el);
  1944. }
  1945. }
  1946. function _nextTick(fn) {
  1947. return setTimeout(fn, 0);
  1948. }
  1949. function _cancelNextTick(id) {
  1950. return clearTimeout(id);
  1951. }
  1952. if (documentExists) {
  1953. on(document, "touchmove", function(evt) {
  1954. if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
  1955. evt.preventDefault();
  1956. }
  1957. });
  1958. }
  1959. Sortable.utils = {
  1960. on,
  1961. off,
  1962. css,
  1963. find,
  1964. is: function is(el, selector) {
  1965. return !!closest(el, selector, el, false);
  1966. },
  1967. extend,
  1968. throttle,
  1969. closest,
  1970. toggleClass,
  1971. clone,
  1972. index,
  1973. nextTick: _nextTick,
  1974. cancelNextTick: _cancelNextTick,
  1975. detectDirection: _detectDirection,
  1976. getChild
  1977. };
  1978. Sortable.get = function(element) {
  1979. return element[expando];
  1980. };
  1981. Sortable.mount = function() {
  1982. for (var _len = arguments.length, plugins2 = new Array(_len), _key = 0; _key < _len; _key++) {
  1983. plugins2[_key] = arguments[_key];
  1984. }
  1985. if (plugins2[0].constructor === Array)
  1986. plugins2 = plugins2[0];
  1987. plugins2.forEach(function(plugin) {
  1988. if (!plugin.prototype || !plugin.prototype.constructor) {
  1989. throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
  1990. }
  1991. if (plugin.utils)
  1992. Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
  1993. PluginManager.mount(plugin);
  1994. });
  1995. };
  1996. Sortable.create = function(el, options) {
  1997. return new Sortable(el, options);
  1998. };
  1999. Sortable.version = version;
  2000. var autoScrolls = [];
  2001. var scrollEl;
  2002. var scrollRootEl;
  2003. var scrolling = false;
  2004. var lastAutoScrollX;
  2005. var lastAutoScrollY;
  2006. var touchEvt$1;
  2007. var pointerElemChangedInterval;
  2008. function AutoScrollPlugin() {
  2009. function AutoScroll() {
  2010. this.defaults = {
  2011. scroll: true,
  2012. forceAutoScrollFallback: false,
  2013. scrollSensitivity: 30,
  2014. scrollSpeed: 10,
  2015. bubbleScroll: true
  2016. };
  2017. for (var fn in this) {
  2018. if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
  2019. this[fn] = this[fn].bind(this);
  2020. }
  2021. }
  2022. }
  2023. AutoScroll.prototype = {
  2024. dragStarted: function dragStarted2(_ref) {
  2025. var originalEvent = _ref.originalEvent;
  2026. if (this.sortable.nativeDraggable) {
  2027. on(document, "dragover", this._handleAutoScroll);
  2028. } else {
  2029. if (this.options.supportPointer) {
  2030. on(document, "pointermove", this._handleFallbackAutoScroll);
  2031. } else if (originalEvent.touches) {
  2032. on(document, "touchmove", this._handleFallbackAutoScroll);
  2033. } else {
  2034. on(document, "mousemove", this._handleFallbackAutoScroll);
  2035. }
  2036. }
  2037. },
  2038. dragOverCompleted: function dragOverCompleted(_ref2) {
  2039. var originalEvent = _ref2.originalEvent;
  2040. if (!this.options.dragOverBubble && !originalEvent.rootEl) {
  2041. this._handleAutoScroll(originalEvent);
  2042. }
  2043. },
  2044. drop: function drop3() {
  2045. if (this.sortable.nativeDraggable) {
  2046. off(document, "dragover", this._handleAutoScroll);
  2047. } else {
  2048. off(document, "pointermove", this._handleFallbackAutoScroll);
  2049. off(document, "touchmove", this._handleFallbackAutoScroll);
  2050. off(document, "mousemove", this._handleFallbackAutoScroll);
  2051. }
  2052. clearPointerElemChangedInterval();
  2053. clearAutoScrolls();
  2054. cancelThrottle();
  2055. },
  2056. nulling: function nulling() {
  2057. touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
  2058. autoScrolls.length = 0;
  2059. },
  2060. _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
  2061. this._handleAutoScroll(evt, true);
  2062. },
  2063. _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
  2064. var _this = this;
  2065. var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, elem = document.elementFromPoint(x, y);
  2066. touchEvt$1 = evt;
  2067. if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
  2068. autoScroll(evt, this.options, elem, fallback);
  2069. var ogElemScroller = getParentAutoScrollElement(elem, true);
  2070. if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
  2071. pointerElemChangedInterval && clearPointerElemChangedInterval();
  2072. pointerElemChangedInterval = setInterval(function() {
  2073. var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
  2074. if (newElem !== ogElemScroller) {
  2075. ogElemScroller = newElem;
  2076. clearAutoScrolls();
  2077. }
  2078. autoScroll(evt, _this.options, newElem, fallback);
  2079. }, 10);
  2080. lastAutoScrollX = x;
  2081. lastAutoScrollY = y;
  2082. }
  2083. } else {
  2084. if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
  2085. clearAutoScrolls();
  2086. return;
  2087. }
  2088. autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
  2089. }
  2090. }
  2091. };
  2092. return _extends(AutoScroll, {
  2093. pluginName: "scroll",
  2094. initializeByDefault: true
  2095. });
  2096. }
  2097. function clearAutoScrolls() {
  2098. autoScrolls.forEach(function(autoScroll2) {
  2099. clearInterval(autoScroll2.pid);
  2100. });
  2101. autoScrolls = [];
  2102. }
  2103. function clearPointerElemChangedInterval() {
  2104. clearInterval(pointerElemChangedInterval);
  2105. }
  2106. var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
  2107. if (!options.scroll)
  2108. return;
  2109. var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, sens = options.scrollSensitivity, speed = options.scrollSpeed, winScroller = getWindowScrollingElement();
  2110. var scrollThisInstance = false, scrollCustomFn;
  2111. if (scrollRootEl !== rootEl2) {
  2112. scrollRootEl = rootEl2;
  2113. clearAutoScrolls();
  2114. scrollEl = options.scroll;
  2115. scrollCustomFn = options.scrollFn;
  2116. if (scrollEl === true) {
  2117. scrollEl = getParentAutoScrollElement(rootEl2, true);
  2118. }
  2119. }
  2120. var layersOut = 0;
  2121. var currentParent = scrollEl;
  2122. do {
  2123. var el = currentParent, rect = getRect(el), top = rect.top, bottom = rect.bottom, left = rect.left, right = rect.right, width = rect.width, height = rect.height, canScrollX = void 0, canScrollY = void 0, scrollWidth = el.scrollWidth, scrollHeight = el.scrollHeight, elCSS = css(el), scrollPosX = el.scrollLeft, scrollPosY = el.scrollTop;
  2124. if (el === winScroller) {
  2125. canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll" || elCSS.overflowX === "visible");
  2126. canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll" || elCSS.overflowY === "visible");
  2127. } else {
  2128. canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll");
  2129. canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll");
  2130. }
  2131. var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
  2132. var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
  2133. if (!autoScrolls[layersOut]) {
  2134. for (var i = 0; i <= layersOut; i++) {
  2135. if (!autoScrolls[i]) {
  2136. autoScrolls[i] = {};
  2137. }
  2138. }
  2139. }
  2140. if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
  2141. autoScrolls[layersOut].el = el;
  2142. autoScrolls[layersOut].vx = vx;
  2143. autoScrolls[layersOut].vy = vy;
  2144. clearInterval(autoScrolls[layersOut].pid);
  2145. if (vx != 0 || vy != 0) {
  2146. scrollThisInstance = true;
  2147. autoScrolls[layersOut].pid = setInterval(function() {
  2148. if (isFallback && this.layer === 0) {
  2149. Sortable.active._onTouchMove(touchEvt$1);
  2150. }
  2151. var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
  2152. var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
  2153. if (typeof scrollCustomFn === "function") {
  2154. if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== "continue") {
  2155. return;
  2156. }
  2157. }
  2158. scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
  2159. }.bind({
  2160. layer: layersOut
  2161. }), 24);
  2162. }
  2163. }
  2164. layersOut++;
  2165. } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
  2166. scrolling = scrollThisInstance;
  2167. }, 30);
  2168. var drop = function drop2(_ref) {
  2169. var originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, dragEl2 = _ref.dragEl, activeSortable = _ref.activeSortable, dispatchSortableEvent = _ref.dispatchSortableEvent, hideGhostForTarget = _ref.hideGhostForTarget, unhideGhostForTarget = _ref.unhideGhostForTarget;
  2170. if (!originalEvent)
  2171. return;
  2172. var toSortable = putSortable2 || activeSortable;
  2173. hideGhostForTarget();
  2174. var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
  2175. var target = document.elementFromPoint(touch.clientX, touch.clientY);
  2176. unhideGhostForTarget();
  2177. if (toSortable && !toSortable.el.contains(target)) {
  2178. dispatchSortableEvent("spill");
  2179. this.onSpill({
  2180. dragEl: dragEl2,
  2181. putSortable: putSortable2
  2182. });
  2183. }
  2184. };
  2185. function Revert() {
  2186. }
  2187. Revert.prototype = {
  2188. startIndex: null,
  2189. dragStart: function dragStart(_ref2) {
  2190. var oldDraggableIndex2 = _ref2.oldDraggableIndex;
  2191. this.startIndex = oldDraggableIndex2;
  2192. },
  2193. onSpill: function onSpill(_ref3) {
  2194. var dragEl2 = _ref3.dragEl, putSortable2 = _ref3.putSortable;
  2195. this.sortable.captureAnimationState();
  2196. if (putSortable2) {
  2197. putSortable2.captureAnimationState();
  2198. }
  2199. var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
  2200. if (nextSibling) {
  2201. this.sortable.el.insertBefore(dragEl2, nextSibling);
  2202. } else {
  2203. this.sortable.el.appendChild(dragEl2);
  2204. }
  2205. this.sortable.animateAll();
  2206. if (putSortable2) {
  2207. putSortable2.animateAll();
  2208. }
  2209. },
  2210. drop
  2211. };
  2212. _extends(Revert, {
  2213. pluginName: "revertOnSpill"
  2214. });
  2215. function Remove() {
  2216. }
  2217. Remove.prototype = {
  2218. onSpill: function onSpill2(_ref4) {
  2219. var dragEl2 = _ref4.dragEl, putSortable2 = _ref4.putSortable;
  2220. var parentSortable = putSortable2 || this.sortable;
  2221. parentSortable.captureAnimationState();
  2222. dragEl2.parentNode && dragEl2.parentNode.removeChild(dragEl2);
  2223. parentSortable.animateAll();
  2224. },
  2225. drop
  2226. };
  2227. _extends(Remove, {
  2228. pluginName: "removeOnSpill"
  2229. });
  2230. var lastSwapEl;
  2231. function SwapPlugin() {
  2232. function Swap() {
  2233. this.defaults = {
  2234. swapClass: "sortable-swap-highlight"
  2235. };
  2236. }
  2237. Swap.prototype = {
  2238. dragStart: function dragStart2(_ref) {
  2239. var dragEl2 = _ref.dragEl;
  2240. lastSwapEl = dragEl2;
  2241. },
  2242. dragOverValid: function dragOverValid(_ref2) {
  2243. var completed = _ref2.completed, target = _ref2.target, onMove = _ref2.onMove, activeSortable = _ref2.activeSortable, changed = _ref2.changed, cancel = _ref2.cancel;
  2244. if (!activeSortable.options.swap)
  2245. return;
  2246. var el = this.sortable.el, options = this.options;
  2247. if (target && target !== el) {
  2248. var prevSwapEl = lastSwapEl;
  2249. if (onMove(target) !== false) {
  2250. toggleClass(target, options.swapClass, true);
  2251. lastSwapEl = target;
  2252. } else {
  2253. lastSwapEl = null;
  2254. }
  2255. if (prevSwapEl && prevSwapEl !== lastSwapEl) {
  2256. toggleClass(prevSwapEl, options.swapClass, false);
  2257. }
  2258. }
  2259. changed();
  2260. completed(true);
  2261. cancel();
  2262. },
  2263. drop: function drop3(_ref3) {
  2264. var activeSortable = _ref3.activeSortable, putSortable2 = _ref3.putSortable, dragEl2 = _ref3.dragEl;
  2265. var toSortable = putSortable2 || this.sortable;
  2266. var options = this.options;
  2267. lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
  2268. if (lastSwapEl && (options.swap || putSortable2 && putSortable2.options.swap)) {
  2269. if (dragEl2 !== lastSwapEl) {
  2270. toSortable.captureAnimationState();
  2271. if (toSortable !== activeSortable)
  2272. activeSortable.captureAnimationState();
  2273. swapNodes(dragEl2, lastSwapEl);
  2274. toSortable.animateAll();
  2275. if (toSortable !== activeSortable)
  2276. activeSortable.animateAll();
  2277. }
  2278. }
  2279. },
  2280. nulling: function nulling() {
  2281. lastSwapEl = null;
  2282. }
  2283. };
  2284. return _extends(Swap, {
  2285. pluginName: "swap",
  2286. eventProperties: function eventProperties() {
  2287. return {
  2288. swapItem: lastSwapEl
  2289. };
  2290. }
  2291. });
  2292. }
  2293. function swapNodes(n1, n2) {
  2294. var p1 = n1.parentNode, p2 = n2.parentNode, i1, i2;
  2295. if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1))
  2296. return;
  2297. i1 = index(n1);
  2298. i2 = index(n2);
  2299. if (p1.isEqualNode(p2) && i1 < i2) {
  2300. i2++;
  2301. }
  2302. p1.insertBefore(n2, p1.children[i1]);
  2303. p2.insertBefore(n1, p2.children[i2]);
  2304. }
  2305. var multiDragElements = [];
  2306. var multiDragClones = [];
  2307. var lastMultiDragSelect;
  2308. var multiDragSortable;
  2309. var initialFolding = false;
  2310. var folding = false;
  2311. var dragStarted = false;
  2312. var dragEl$1;
  2313. var clonesFromRect;
  2314. var clonesHidden;
  2315. function MultiDragPlugin() {
  2316. function MultiDrag(sortable) {
  2317. for (var fn in this) {
  2318. if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
  2319. this[fn] = this[fn].bind(this);
  2320. }
  2321. }
  2322. if (!sortable.options.avoidImplicitDeselect) {
  2323. if (sortable.options.supportPointer) {
  2324. on(document, "pointerup", this._deselectMultiDrag);
  2325. } else {
  2326. on(document, "mouseup", this._deselectMultiDrag);
  2327. on(document, "touchend", this._deselectMultiDrag);
  2328. }
  2329. }
  2330. on(document, "keydown", this._checkKeyDown);
  2331. on(document, "keyup", this._checkKeyUp);
  2332. this.defaults = {
  2333. selectedClass: "sortable-selected",
  2334. multiDragKey: null,
  2335. avoidImplicitDeselect: false,
  2336. setData: function setData(dataTransfer, dragEl2) {
  2337. var data = "";
  2338. if (multiDragElements.length && multiDragSortable === sortable) {
  2339. multiDragElements.forEach(function(multiDragElement, i) {
  2340. data += (!i ? "" : ", ") + multiDragElement.textContent;
  2341. });
  2342. } else {
  2343. data = dragEl2.textContent;
  2344. }
  2345. dataTransfer.setData("Text", data);
  2346. }
  2347. };
  2348. }
  2349. MultiDrag.prototype = {
  2350. multiDragKeyDown: false,
  2351. isMultiDrag: false,
  2352. delayStartGlobal: function delayStartGlobal(_ref) {
  2353. var dragged = _ref.dragEl;
  2354. dragEl$1 = dragged;
  2355. },
  2356. delayEnded: function delayEnded() {
  2357. this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1);
  2358. },
  2359. setupClone: function setupClone(_ref2) {
  2360. var sortable = _ref2.sortable, cancel = _ref2.cancel;
  2361. if (!this.isMultiDrag)
  2362. return;
  2363. for (var i = 0; i < multiDragElements.length; i++) {
  2364. multiDragClones.push(clone(multiDragElements[i]));
  2365. multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex;
  2366. multiDragClones[i].draggable = false;
  2367. multiDragClones[i].style["will-change"] = "";
  2368. toggleClass(multiDragClones[i], this.options.selectedClass, false);
  2369. multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false);
  2370. }
  2371. sortable._hideClone();
  2372. cancel();
  2373. },
  2374. clone: function clone2(_ref3) {
  2375. var sortable = _ref3.sortable, rootEl2 = _ref3.rootEl, dispatchSortableEvent = _ref3.dispatchSortableEvent, cancel = _ref3.cancel;
  2376. if (!this.isMultiDrag)
  2377. return;
  2378. if (!this.options.removeCloneOnHide) {
  2379. if (multiDragElements.length && multiDragSortable === sortable) {
  2380. insertMultiDragClones(true, rootEl2);
  2381. dispatchSortableEvent("clone");
  2382. cancel();
  2383. }
  2384. }
  2385. },
  2386. showClone: function showClone(_ref4) {
  2387. var cloneNowShown = _ref4.cloneNowShown, rootEl2 = _ref4.rootEl, cancel = _ref4.cancel;
  2388. if (!this.isMultiDrag)
  2389. return;
  2390. insertMultiDragClones(false, rootEl2);
  2391. multiDragClones.forEach(function(clone2) {
  2392. css(clone2, "display", "");
  2393. });
  2394. cloneNowShown();
  2395. clonesHidden = false;
  2396. cancel();
  2397. },
  2398. hideClone: function hideClone(_ref5) {
  2399. var _this = this;
  2400. var sortable = _ref5.sortable, cloneNowHidden = _ref5.cloneNowHidden, cancel = _ref5.cancel;
  2401. if (!this.isMultiDrag)
  2402. return;
  2403. multiDragClones.forEach(function(clone2) {
  2404. css(clone2, "display", "none");
  2405. if (_this.options.removeCloneOnHide && clone2.parentNode) {
  2406. clone2.parentNode.removeChild(clone2);
  2407. }
  2408. });
  2409. cloneNowHidden();
  2410. clonesHidden = true;
  2411. cancel();
  2412. },
  2413. dragStartGlobal: function dragStartGlobal(_ref6) {
  2414. var sortable = _ref6.sortable;
  2415. if (!this.isMultiDrag && multiDragSortable) {
  2416. multiDragSortable.multiDrag._deselectMultiDrag();
  2417. }
  2418. multiDragElements.forEach(function(multiDragElement) {
  2419. multiDragElement.sortableIndex = index(multiDragElement);
  2420. });
  2421. multiDragElements = multiDragElements.sort(function(a, b) {
  2422. return a.sortableIndex - b.sortableIndex;
  2423. });
  2424. dragStarted = true;
  2425. },
  2426. dragStarted: function dragStarted2(_ref7) {
  2427. var _this2 = this;
  2428. var sortable = _ref7.sortable;
  2429. if (!this.isMultiDrag)
  2430. return;
  2431. if (this.options.sort) {
  2432. sortable.captureAnimationState();
  2433. if (this.options.animation) {
  2434. multiDragElements.forEach(function(multiDragElement) {
  2435. if (multiDragElement === dragEl$1)
  2436. return;
  2437. css(multiDragElement, "position", "absolute");
  2438. });
  2439. var dragRect = getRect(dragEl$1, false, true, true);
  2440. multiDragElements.forEach(function(multiDragElement) {
  2441. if (multiDragElement === dragEl$1)
  2442. return;
  2443. setRect(multiDragElement, dragRect);
  2444. });
  2445. folding = true;
  2446. initialFolding = true;
  2447. }
  2448. }
  2449. sortable.animateAll(function() {
  2450. folding = false;
  2451. initialFolding = false;
  2452. if (_this2.options.animation) {
  2453. multiDragElements.forEach(function(multiDragElement) {
  2454. unsetRect(multiDragElement);
  2455. });
  2456. }
  2457. if (_this2.options.sort) {
  2458. removeMultiDragElements();
  2459. }
  2460. });
  2461. },
  2462. dragOver: function dragOver(_ref8) {
  2463. var target = _ref8.target, completed = _ref8.completed, cancel = _ref8.cancel;
  2464. if (folding && ~multiDragElements.indexOf(target)) {
  2465. completed(false);
  2466. cancel();
  2467. }
  2468. },
  2469. revert: function revert(_ref9) {
  2470. var fromSortable = _ref9.fromSortable, rootEl2 = _ref9.rootEl, sortable = _ref9.sortable, dragRect = _ref9.dragRect;
  2471. if (multiDragElements.length > 1) {
  2472. multiDragElements.forEach(function(multiDragElement) {
  2473. sortable.addAnimationState({
  2474. target: multiDragElement,
  2475. rect: folding ? getRect(multiDragElement) : dragRect
  2476. });
  2477. unsetRect(multiDragElement);
  2478. multiDragElement.fromRect = dragRect;
  2479. fromSortable.removeAnimationState(multiDragElement);
  2480. });
  2481. folding = false;
  2482. insertMultiDragElements(!this.options.removeCloneOnHide, rootEl2);
  2483. }
  2484. },
  2485. dragOverCompleted: function dragOverCompleted(_ref10) {
  2486. var sortable = _ref10.sortable, isOwner = _ref10.isOwner, insertion = _ref10.insertion, activeSortable = _ref10.activeSortable, parentEl2 = _ref10.parentEl, putSortable2 = _ref10.putSortable;
  2487. var options = this.options;
  2488. if (insertion) {
  2489. if (isOwner) {
  2490. activeSortable._hideClone();
  2491. }
  2492. initialFolding = false;
  2493. if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable2)) {
  2494. var dragRectAbsolute = getRect(dragEl$1, false, true, true);
  2495. multiDragElements.forEach(function(multiDragElement) {
  2496. if (multiDragElement === dragEl$1)
  2497. return;
  2498. setRect(multiDragElement, dragRectAbsolute);
  2499. parentEl2.appendChild(multiDragElement);
  2500. });
  2501. folding = true;
  2502. }
  2503. if (!isOwner) {
  2504. if (!folding) {
  2505. removeMultiDragElements();
  2506. }
  2507. if (multiDragElements.length > 1) {
  2508. var clonesHiddenBefore = clonesHidden;
  2509. activeSortable._showClone(sortable);
  2510. if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) {
  2511. multiDragClones.forEach(function(clone2) {
  2512. activeSortable.addAnimationState({
  2513. target: clone2,
  2514. rect: clonesFromRect
  2515. });
  2516. clone2.fromRect = clonesFromRect;
  2517. clone2.thisAnimationDuration = null;
  2518. });
  2519. }
  2520. } else {
  2521. activeSortable._showClone(sortable);
  2522. }
  2523. }
  2524. }
  2525. },
  2526. dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) {
  2527. var dragRect = _ref11.dragRect, isOwner = _ref11.isOwner, activeSortable = _ref11.activeSortable;
  2528. multiDragElements.forEach(function(multiDragElement) {
  2529. multiDragElement.thisAnimationDuration = null;
  2530. });
  2531. if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) {
  2532. clonesFromRect = _extends({}, dragRect);
  2533. var dragMatrix = matrix(dragEl$1, true);
  2534. clonesFromRect.top -= dragMatrix.f;
  2535. clonesFromRect.left -= dragMatrix.e;
  2536. }
  2537. },
  2538. dragOverAnimationComplete: function dragOverAnimationComplete() {
  2539. if (folding) {
  2540. folding = false;
  2541. removeMultiDragElements();
  2542. }
  2543. },
  2544. drop: function drop3(_ref12) {
  2545. var evt = _ref12.originalEvent, rootEl2 = _ref12.rootEl, parentEl2 = _ref12.parentEl, sortable = _ref12.sortable, dispatchSortableEvent = _ref12.dispatchSortableEvent, oldIndex2 = _ref12.oldIndex, putSortable2 = _ref12.putSortable;
  2546. var toSortable = putSortable2 || this.sortable;
  2547. if (!evt)
  2548. return;
  2549. var options = this.options, children = parentEl2.children;
  2550. if (!dragStarted) {
  2551. if (options.multiDragKey && !this.multiDragKeyDown) {
  2552. this._deselectMultiDrag();
  2553. }
  2554. toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
  2555. if (!~multiDragElements.indexOf(dragEl$1)) {
  2556. multiDragElements.push(dragEl$1);
  2557. dispatchEvent({
  2558. sortable,
  2559. rootEl: rootEl2,
  2560. name: "select",
  2561. targetEl: dragEl$1,
  2562. originalEvent: evt
  2563. });
  2564. if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) {
  2565. var lastIndex = index(lastMultiDragSelect), currentIndex = index(dragEl$1);
  2566. if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) {
  2567. var n, i;
  2568. if (currentIndex > lastIndex) {
  2569. i = lastIndex;
  2570. n = currentIndex;
  2571. } else {
  2572. i = currentIndex;
  2573. n = lastIndex + 1;
  2574. }
  2575. for (; i < n; i++) {
  2576. if (~multiDragElements.indexOf(children[i]))
  2577. continue;
  2578. toggleClass(children[i], options.selectedClass, true);
  2579. multiDragElements.push(children[i]);
  2580. dispatchEvent({
  2581. sortable,
  2582. rootEl: rootEl2,
  2583. name: "select",
  2584. targetEl: children[i],
  2585. originalEvent: evt
  2586. });
  2587. }
  2588. }
  2589. } else {
  2590. lastMultiDragSelect = dragEl$1;
  2591. }
  2592. multiDragSortable = toSortable;
  2593. } else {
  2594. multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1);
  2595. lastMultiDragSelect = null;
  2596. dispatchEvent({
  2597. sortable,
  2598. rootEl: rootEl2,
  2599. name: "deselect",
  2600. targetEl: dragEl$1,
  2601. originalEvent: evt
  2602. });
  2603. }
  2604. }
  2605. if (dragStarted && this.isMultiDrag) {
  2606. folding = false;
  2607. if ((parentEl2[expando].options.sort || parentEl2 !== rootEl2) && multiDragElements.length > 1) {
  2608. var dragRect = getRect(dragEl$1), multiDragIndex = index(dragEl$1, ":not(." + this.options.selectedClass + ")");
  2609. if (!initialFolding && options.animation)
  2610. dragEl$1.thisAnimationDuration = null;
  2611. toSortable.captureAnimationState();
  2612. if (!initialFolding) {
  2613. if (options.animation) {
  2614. dragEl$1.fromRect = dragRect;
  2615. multiDragElements.forEach(function(multiDragElement) {
  2616. multiDragElement.thisAnimationDuration = null;
  2617. if (multiDragElement !== dragEl$1) {
  2618. var rect = folding ? getRect(multiDragElement) : dragRect;
  2619. multiDragElement.fromRect = rect;
  2620. toSortable.addAnimationState({
  2621. target: multiDragElement,
  2622. rect
  2623. });
  2624. }
  2625. });
  2626. }
  2627. removeMultiDragElements();
  2628. multiDragElements.forEach(function(multiDragElement) {
  2629. if (children[multiDragIndex]) {
  2630. parentEl2.insertBefore(multiDragElement, children[multiDragIndex]);
  2631. } else {
  2632. parentEl2.appendChild(multiDragElement);
  2633. }
  2634. multiDragIndex++;
  2635. });
  2636. if (oldIndex2 === index(dragEl$1)) {
  2637. var update = false;
  2638. multiDragElements.forEach(function(multiDragElement) {
  2639. if (multiDragElement.sortableIndex !== index(multiDragElement)) {
  2640. update = true;
  2641. return;
  2642. }
  2643. });
  2644. if (update) {
  2645. dispatchSortableEvent("update");
  2646. }
  2647. }
  2648. }
  2649. multiDragElements.forEach(function(multiDragElement) {
  2650. unsetRect(multiDragElement);
  2651. });
  2652. toSortable.animateAll();
  2653. }
  2654. multiDragSortable = toSortable;
  2655. }
  2656. if (rootEl2 === parentEl2 || putSortable2 && putSortable2.lastPutMode !== "clone") {
  2657. multiDragClones.forEach(function(clone2) {
  2658. clone2.parentNode && clone2.parentNode.removeChild(clone2);
  2659. });
  2660. }
  2661. },
  2662. nullingGlobal: function nullingGlobal() {
  2663. this.isMultiDrag = dragStarted = false;
  2664. multiDragClones.length = 0;
  2665. },
  2666. destroyGlobal: function destroyGlobal() {
  2667. this._deselectMultiDrag();
  2668. off(document, "pointerup", this._deselectMultiDrag);
  2669. off(document, "mouseup", this._deselectMultiDrag);
  2670. off(document, "touchend", this._deselectMultiDrag);
  2671. off(document, "keydown", this._checkKeyDown);
  2672. off(document, "keyup", this._checkKeyUp);
  2673. },
  2674. _deselectMultiDrag: function _deselectMultiDrag(evt) {
  2675. if (typeof dragStarted !== "undefined" && dragStarted)
  2676. return;
  2677. if (multiDragSortable !== this.sortable)
  2678. return;
  2679. if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false))
  2680. return;
  2681. if (evt && evt.button !== 0)
  2682. return;
  2683. while (multiDragElements.length) {
  2684. var el = multiDragElements[0];
  2685. toggleClass(el, this.options.selectedClass, false);
  2686. multiDragElements.shift();
  2687. dispatchEvent({
  2688. sortable: this.sortable,
  2689. rootEl: this.sortable.el,
  2690. name: "deselect",
  2691. targetEl: el,
  2692. originalEvent: evt
  2693. });
  2694. }
  2695. },
  2696. _checkKeyDown: function _checkKeyDown(evt) {
  2697. if (evt.key === this.options.multiDragKey) {
  2698. this.multiDragKeyDown = true;
  2699. }
  2700. },
  2701. _checkKeyUp: function _checkKeyUp(evt) {
  2702. if (evt.key === this.options.multiDragKey) {
  2703. this.multiDragKeyDown = false;
  2704. }
  2705. }
  2706. };
  2707. return _extends(MultiDrag, {
  2708. pluginName: "multiDrag",
  2709. utils: {
  2710. select: function select(el) {
  2711. var sortable = el.parentNode[expando];
  2712. if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el))
  2713. return;
  2714. if (multiDragSortable && multiDragSortable !== sortable) {
  2715. multiDragSortable.multiDrag._deselectMultiDrag();
  2716. multiDragSortable = sortable;
  2717. }
  2718. toggleClass(el, sortable.options.selectedClass, true);
  2719. multiDragElements.push(el);
  2720. },
  2721. deselect: function deselect(el) {
  2722. var sortable = el.parentNode[expando], index2 = multiDragElements.indexOf(el);
  2723. if (!sortable || !sortable.options.multiDrag || !~index2)
  2724. return;
  2725. toggleClass(el, sortable.options.selectedClass, false);
  2726. multiDragElements.splice(index2, 1);
  2727. }
  2728. },
  2729. eventProperties: function eventProperties() {
  2730. var _this3 = this;
  2731. var oldIndicies = [], newIndicies = [];
  2732. multiDragElements.forEach(function(multiDragElement) {
  2733. oldIndicies.push({
  2734. multiDragElement,
  2735. index: multiDragElement.sortableIndex
  2736. });
  2737. var newIndex2;
  2738. if (folding && multiDragElement !== dragEl$1) {
  2739. newIndex2 = -1;
  2740. } else if (folding) {
  2741. newIndex2 = index(multiDragElement, ":not(." + _this3.options.selectedClass + ")");
  2742. } else {
  2743. newIndex2 = index(multiDragElement);
  2744. }
  2745. newIndicies.push({
  2746. multiDragElement,
  2747. index: newIndex2
  2748. });
  2749. });
  2750. return {
  2751. items: _toConsumableArray(multiDragElements),
  2752. clones: [].concat(multiDragClones),
  2753. oldIndicies,
  2754. newIndicies
  2755. };
  2756. },
  2757. optionListeners: {
  2758. multiDragKey: function multiDragKey(key) {
  2759. key = key.toLowerCase();
  2760. if (key === "ctrl") {
  2761. key = "Control";
  2762. } else if (key.length > 1) {
  2763. key = key.charAt(0).toUpperCase() + key.substr(1);
  2764. }
  2765. return key;
  2766. }
  2767. }
  2768. });
  2769. }
  2770. function insertMultiDragElements(clonesInserted, rootEl2) {
  2771. multiDragElements.forEach(function(multiDragElement, i) {
  2772. var target = rootEl2.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
  2773. if (target) {
  2774. rootEl2.insertBefore(multiDragElement, target);
  2775. } else {
  2776. rootEl2.appendChild(multiDragElement);
  2777. }
  2778. });
  2779. }
  2780. function insertMultiDragClones(elementsInserted, rootEl2) {
  2781. multiDragClones.forEach(function(clone2, i) {
  2782. var target = rootEl2.children[clone2.sortableIndex + (elementsInserted ? Number(i) : 0)];
  2783. if (target) {
  2784. rootEl2.insertBefore(clone2, target);
  2785. } else {
  2786. rootEl2.appendChild(clone2);
  2787. }
  2788. });
  2789. }
  2790. function removeMultiDragElements() {
  2791. multiDragElements.forEach(function(multiDragElement) {
  2792. if (multiDragElement === dragEl$1)
  2793. return;
  2794. multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
  2795. });
  2796. }
  2797. Sortable.mount(new AutoScrollPlugin());
  2798. Sortable.mount(Remove, Revert);
  2799. var sortable_esm_default = Sortable;
  2800. // dep:sortablejs
  2801. var sortablejs_default = sortable_esm_default;
  2802. export {
  2803. MultiDragPlugin as MultiDrag,
  2804. Sortable,
  2805. SwapPlugin as Swap,
  2806. sortablejs_default as default
  2807. };
  2808. /**!
  2809. * Sortable 1.15.0
  2810. * @author RubaXa <trash@rubaxa.org>
  2811. * @author owenm <owen23355@gmail.com>
  2812. * @license MIT
  2813. */
  2814. //# sourceMappingURL=sortablejs.js.map