Files
Batflat/inc/jscripts/html.sortable.min.js

2 lines
6.4 KiB
JavaScript
Raw Permalink Normal View History

2018-03-12 13:23:44 +01:00
/* https://github.com/voidberg/html5sortable */
!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.sortable=t()}(this,function(){"use strict";var e,t,n,r=[],a=[],i=function(e,t,n){return void 0===n?e&&e.h5s&&e.h5s.data&&e.h5s.data[t]:(e.h5s=e.h5s||{},e.h5s.data=e.h5s.data||{},e.h5s.data[t]=n,void 0)},o=function(e){e.h5s&&delete e.h5s.data};switch(!0){case"matches"in window.Element.prototype:n="matches";break;case"msMatchesSelector"in window.Element.prototype:n="msMatchesSelector";break;case"webkitMatchesSelector"in window.Element.prototype:n="webkitMatchesSelector"}var s=function(e,t){if(!t)return Array.prototype.slice.call(e);for(var r=[],a=0;a<e.length;++a)"string"==typeof t&&e[a][n](t)&&r.push(e[a]),t.indexOf(e[a])!==-1&&r.push(e[a]);return r},l=function(e,t,n){if(e instanceof Array)for(var r=0;r<e.length;++r)l(e[r],t,n);else e.addEventListener(t,n),e.h5s=e.h5s||{},e.h5s.events=e.h5s.events||{},e.h5s.events[t]=n},d=function(e,t){if(e instanceof Array)for(var n=0;n<e.length;++n)d(e[n],t);else e.h5s&&e.h5s.events&&e.h5s.events[t]&&(e.removeEventListener(t,e.h5s.events[t]),delete e.h5s.events[t])},c=function(e,t,n){if(e instanceof Array)for(var r=0;r<e.length;++r)c(e[r],t,n);else e.setAttribute(t,n)},f=function(e,t){if(e instanceof Array)for(var n=0;n<e.length;++n)f(e[n],t);else e.removeAttribute(t)},p=function(e){var t=e.getClientRects()[0];return{left:t.left+window.scrollX,top:t.top+window.scrollY}},u=function(e){d(e,"dragstart"),d(e,"dragend"),d(e,"selectstart"),d(e,"dragover"),d(e,"dragenter"),d(e,"drop")},h=function(e){d(e,"dragover"),d(e,"dragenter"),d(e,"drop")},g=function(e,t){e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text",""),e.dataTransfer.setDragImage&&e.dataTransfer.setDragImage(t.draggedItem,t.x,t.y)},m=function(e,t){return t.x||(t.x=parseInt(e.pageX-p(t.draggedItem).left)),t.y||(t.y=parseInt(e.pageY-p(t.draggedItem).top)),t},v=function(e){return{draggedItem:e}},y=function(e,t){var n=v(t);n=m(e,n),g(e,n)},b=function(e){o(e),f(e,"aria-dropeffect")},E=function(e){f(e,"aria-grabbed"),f(e,"draggable"),f(e,"role")},w=function(e,t){return e===t||void 0!==i(e,"connectWith")&&i(e,"connectWith")===i(t,"connectWith")},x=function(e,t){var n,r=[];if(!t)return e;for(var a=0;a<e.length;++a)n=e[a].querySelectorAll(t),r=r.concat(Array.prototype.slice.call(n));return r},I=function(e){var t=i(e,"opts")||{},n=s(e.children,t.items),r=x(n,t.handle);h(e),b(e),d(r,"mousedown"),u(n),E(n)},A=function(e){var t=i(e,"opts"),n=s(e.children,t.items),r=x(n,t.handle);c(e,"aria-dropeffect","move"),c(r,"draggable","true");var a=(document||window.document).createElement("span");"function"!=typeof a.dragDrop||t.disableIEFix||l(r,"mousedown",function(){if(n.indexOf(this)!==-1)this.dragDrop();else{for(var e=this.parentElement;t.items.indexOf(e)===-1;)e=e.parentElement;e.dragDrop()}})},C=function(e){var t=i(e,"opts"),n=s(e.children,t.items),r=x(n,t.handle);c(e,"aria-dropeffect","none"),c(r,"draggable","false"),d(r,"mousedown")},D=function(e){var t=i(e,"opts"),n=s(e.children,t.items),r=x(n,t.handle);u(n),d(r,"mousedown"),h(e)},S=function(e){return e.parentElement?Array.prototype.indexOf.call(e.parentElement.children,e):0},L=function(e){return!!e.parentNode},O=function(e){if("string"!=typeof e)return e;var t=document.createElement("div");return t.innerHTML=e,t.firstChild},W=function(e,t){e.parentElement.insertBefore(t,e)},N=function(e,t){e.parentElement.insertBefore(t,e.nextElementSibling)},T=function(e){e.parentNode&&e.parentNode.removeChild(e)},M=function(e,t){var n=document.createEvent("Event");return t&&(n.detail=t),n.initEvent(e,!1,!0),n},k=function(e,t){a.forEach(function(n){w(e,n)&&n.dispatchEvent(t)})},P=function(n,o){var d=String(o);return o=function(e){var t={connectWith:!1,placeholder:null,dragImage:null,disableIEFix:!1,placeholderClass:"sortable-placeholder",draggingClass:"sortable-dragging",hoverClass:!1};for(var n in e)t[n]=e[n];return t}(o),"string"==typeof n&&(n=document.querySelectorAll(n)),n instanceof window.Element&&(n=[n]),n=Array.prototype.slice.call(n),n.forEach(function(n){if(/enable|disable|