mercury_editor-2.0.x-dev/components/component-outline/component-outline.sortable.min.js

components/component-outline/component-outline.sortable.min.js
!function(){"use strict";((e,t,o)=>{e.behaviors.mercuryEditorComponentOutlineSortable={attach:function(n,r){t("me-component-outline-sortable",".me-component-outline__list, .me-component-outline__components",n).forEach((t=>{const n=t.closest("[data-layout-id]").getAttribute("data-layout-id"),i=t.closest("[data-mercury-editor-id]").getAttribute("data-mercury-editor-id"),l=r.lpBuilder[n]||{};o.create(t,{draggable:".me-component-outline__component",group:`components-${n}`,direction:"vertical",invertSwap:!0,swapThreshold:.5,ghostClass:"me-component-outline-sortable-ghost",filter:t=>function(t,o,n,r){return e._lpbMoveErrors.moves.map((e=>e.apply(null,[t,o,n,r]))).filter((e=>!1!==e&&void 0!==e))}(l,null,null,t.target).length>0,onStart:e=>{const t=e.item,o=t.cloneNode(!0);t.closest(".me-component-outline__list").classList.add("me-is-sorting"),o.querySelector(".me-component-outline-drag-image")?.remove(),o.classList.add("me-component-outline-sortable-placeholder"),o.classList.remove("me-component-outline-sortable-ghost"),t.parentNode.insertBefore(o,t)},onMove:(t,o)=>{if(function(t,o,n,r,i){return e._lpbMoveErrors.accepts.map((e=>e.apply(null,[t,o,n,r,i]))).filter((e=>!1!==e&&void 0!==e))}(l,t.dragged,t.to,t.from,t.related).length>0)return t.to&&t.to.classList.add("sortable-to--disallowed"),!1;if(t.related&&t.to){const e=Array.from(t.to.children),o=e.indexOf(t.related),n=t.willInsertAfter?e[o+1]:e[o];if(n&&n.classList.contains("me-component-outline-sortable-placeholder"))return!1}},onEnd:e=>{document.querySelectorAll(".me-component-outline-sortable-placeholder").forEach((e=>e.remove()));const{item:t}=e;function o(e){let t=0;for(;e=e.parentNode.closest(".me-component-outline__component");)t++;return t}t.closest(".me-component-outline__list").classList.remove("me-is-sorting"),t.style.setProperty("--me-treeitem-depth",o(t)),t.querySelectorAll(".me-component-outline__region, .me-component-outline__component").forEach((e=>{e.style.setProperty("--me-treeitem-depth",o(e))}));const r=t.closest("[data-uuid]").getAttribute("data-uuid");!function(e,t,o){const n=Array.from(document.querySelectorAll(".me-component-outline__list .me-component-outline__component")).map((e=>({uuid:e.getAttribute("data-uuid"),parentUuid:e.parentNode.closest("[data-uuid]")?.getAttribute("data-uuid")||null,region:e.closest("[data-region]")?.getAttribute("data-region")||null}))),r=new CustomEvent("mercuryEditorComponentAction",{detail:{mercuryEditorEntityId:e,layoutParagraphsLayoutId:t,action:"reorder",components:n,componentUuid:o}});document.dispatchEvent(r)}(i,n,r)}})}))}},document.addEventListener("dragstart",(e=>{if(e.target.classList.contains("me-component-outline__component")){const t=e.target.cloneNode(!0);t.classList.add("me-component-outline-drag-image"),t.childNodes.forEach((e=>{e.classList&&!e.classList.contains("me-component-outline__component-controls")&&e.remove()})),Object.assign(t.style,{position:"absolute",top:"-9999px",left:"-9999px",pointerEvents:"none",width:`${e.target.offsetWidth}px`}),e.target.prepend(t);const o=e.target.getBoundingClientRect(),n=e.clientX,r=e.clientY,i=n-o.left,l=r-o.top;e.target.classList.add("me-component-outline-is-dragging"),e.dataTransfer.setDragImage(t,i,l),setTimeout((()=>{t.remove()}),0)}}))})(Drupal,once,Sortable)}();

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc