1 (($, { ajax, behaviors }) => {
2 behaviors.layoutBuilder = {
4 $(context).find('.layout-builder--layout__region').sortable({
6 connectWith: '.layout-builder--layout__region',
9 * Updates the layout with the new position of the block.
11 * @param {jQuery.Event} event
12 * The jQuery Event object.
14 * An object containing information about the item being sorted.
17 // Check if the region from the event and region for the item match.
18 const itemRegion = ui.item.closest('.layout-builder--layout__region');
19 if (event.target === itemRegion[0]) {
20 // Find the destination delta.
21 const deltaTo = ui.item.closest('[data-layout-delta]').data('layout-delta');
22 // If the block didn't leave the original delta use the destination.
23 const deltaFrom = ui.sender ? ui.sender.closest('[data-layout-delta]').data('layout-delta') : deltaTo;
26 ui.item.closest('[data-layout-update-url]').data('layout-update-url'),
29 itemRegion.data('region'),
30 ui.item.data('layout-block-uuid'),
31 ui.item.prev('[data-layout-block-uuid]').data('layout-block-uuid'),
33 .filter(element => element !== undefined)