You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
423 KiB
JavaScript

(()=>{var t={3004:function(t){var e,r;e=function(){var t,e=0,r={},n={},i=(t=window.MutationObserver||window.WebKitMutationObserver,function(e,r){e&&1===e.nodeType&&(t?new t((function(t,e){r(t)})).observe(e,{childList:!0,subtree:!1}):window.addEventListener&&e.addEventListener("DOMNodeInserted",r,!1))});function o(t,e){if(!t)return this;e=e||{},this.parentElm=t,this.uid=e.uid,this.settings={selector:"*",callbacks:{}},Object.assign(this.settings,e),this.setup(),i(this.parentElm,this.setup.bind(this)),this.bindEvents()}return o.prototype={namespace:"dragsort",setup(){[...this.parentElm.childNodes].forEach((t=>{if(1!=t.nodeType)return t.parentNode.removeChild(t);t.matches(this.settings.selector)&&(t.draggable=!0)})),this.gap=this.getItemsGap(this.parentElm.firstElementChild)},throttle(t,e){var r=!1,n=this;return function(i){r||(t.call(n,i),r=!0,setTimeout((()=>r=!1),e))}},getDraggableElm(t){if(!t.closest)return null;var e=t.closest('[draggable="true"]');return this.uid==r.uid?e:null},dragstart(t,e){r=this;var n,i=this.getDraggableElm(e);i?(this.source=this.getInitialState(),this.target=this.getInitialState(),n=i.getBoundingClientRect(),this.source.elm=i,this.source.idx=this.getNodeIndex(i),this.source.size.width=n.width,this.source.size.height=n.height,t.dataTransfer.effectAllowed="move",this.settings.callbacks.dragStart&&this.settings.callbacks.dragStart(this.source.elm,t),setTimeout(this.afterDragStart.bind(this))):r={}},afterDragStart(){var t="vertical"==this.settings.mode?"height":"width";this.parentElm.classList.add(`${this.namespace}--dragStart`),this.source.elm.style[t]=this.source.size[t]+"px",this.source.elm.classList.add(`${this.namespace}--dragElem`)},dragover(t){t.preventDefault(),t.stopPropagation();var e=t.target;if((e=this.getDraggableElm(e))&&this.target){var r=this.target.elm,n=this.target.hoverDirection;t.dataTransfer.dropEffect="move",this.target.hoverDirection=this.getTargetDirection(t),r==e&&n==this.target.hoverDirection||this.directionAwareDragEnter(t,e)}},dragenter(t,e){(e=this.getDraggableElm(e))&&this.target&&this.isValidElm(e)&&this.source.elm!=e&&this.source.elm&&(this.target.bounding=e.getBoundingClientRect())},directionAwareDragEnter(t,e){var r;t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect="none",this.isValidElm(e)&&this.source.elm!=e&&this.source.elm&&(t.dataTransfer.dropEffect="move",this.cleanupLastTarget(),this.target.elm=e,this.target.idx=this.getNodeIndex(e),e.classList.add("over"),r=Math.abs(this.target.idx-this.source.idx),this.source.elm.classList.toggle(`${this.namespace}--hide`,r>0),"vertical"==this.settings.mode?this.target.elm.style[this.target.hoverDirection?"marginBottom":"marginTop"]=this.source.size.height+this.gap+"px":this.target.elm.style[this.target.hoverDirection?"marginRight":"marginLeft"]=this.source.size.width+this.gap+"px")},dragend(t){if(clearTimeout(this.dragoverTimeout),this.dragoverTimeout=null,this.parentElm.classList.remove(`${this.namespace}--dragStart`),!this.isValidElm(this.target.elm))return this.cleanup();var e=this.target.hoverDirection?this.target.elm.nextElementSibling:this.target.elm;return this.source.elm!=this.target.elm&&this.target.elm&&(this.target.elm.classList.add(`${this.namespace}--noAnim`),this.cleanup(),this.parentElm.insertBefore(this.source.elm,e)),this.source.elm&&this.source.elm.classList.remove(`${this.namespace}--dragElem`,`${this.namespace}--hide`),this.settings.callbacks.dragEnd&&this.settings.callbacks.dragEnd(this.source.elm),this},isTargetLastChild(){return this.parentElm.lastElementChild==this.target.elm},getTargetDirection(t){if(this.target.bounding)return"vertical"==this.settings.mode?t.pageY>this.target.bounding.top+this.target.bounding.height/2?1:0:t.pageX>this.target.bounding.left+this.target.bounding.width/2?1:0},getNodeIndex(t){for(var e=0;t=t.previousSibling;)3==t.nodeType&&/^\s*$/.test(t.data)||e++;return e},isValidElm(t){return t&&t.nodeType&&t.parentNode==this.parentElm},cleanup(){r={},[...this.parentElm.children].forEach((t=>{t.removeAttribute("style"),setTimeout((()=>{t.classList.remove(`${this.namesp