Issue #2905922 by tim.plunkett, tedbow, xjm, EclipseGc, webchick, vijaycs85, larowlan, andrewmacpherson, droplet, Bojhan, mgifford, drpal, phenaproxima, DyanneNova, japerry: Implementation issue for Layout Builder
2017-11-17 19:01:26 +00:00
|
|
|
(($, { ajax, behaviors }) => {
|
|
|
|
behaviors.layoutBuilder = {
|
|
|
|
attach(context) {
|
|
|
|
$(context).find('.layout-builder--layout__region').sortable({
|
|
|
|
items: '> .draggable',
|
|
|
|
connectWith: '.layout-builder--layout__region',
|
2018-04-08 04:27:31 +00:00
|
|
|
placeholder: 'ui-state-drop',
|
Issue #2905922 by tim.plunkett, tedbow, xjm, EclipseGc, webchick, vijaycs85, larowlan, andrewmacpherson, droplet, Bojhan, mgifford, drpal, phenaproxima, DyanneNova, japerry: Implementation issue for Layout Builder
2017-11-17 19:01:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the layout with the new position of the block.
|
|
|
|
*
|
|
|
|
* @param {jQuery.Event} event
|
|
|
|
* The jQuery Event object.
|
|
|
|
* @param {Object} ui
|
|
|
|
* An object containing information about the item being sorted.
|
|
|
|
*/
|
|
|
|
update(event, ui) {
|
2018-01-26 20:50:00 +00:00
|
|
|
// Check if the region from the event and region for the item match.
|
|
|
|
const itemRegion = ui.item.closest('.layout-builder--layout__region');
|
|
|
|
if (event.target === itemRegion[0]) {
|
|
|
|
// Find the destination delta.
|
|
|
|
const deltaTo = ui.item.closest('[data-layout-delta]').data('layout-delta');
|
|
|
|
// If the block didn't leave the original delta use the destination.
|
|
|
|
const deltaFrom = ui.sender ? ui.sender.closest('[data-layout-delta]').data('layout-delta') : deltaTo;
|
Issue #2905922 by tim.plunkett, tedbow, xjm, EclipseGc, webchick, vijaycs85, larowlan, andrewmacpherson, droplet, Bojhan, mgifford, drpal, phenaproxima, DyanneNova, japerry: Implementation issue for Layout Builder
2017-11-17 19:01:26 +00:00
|
|
|
ajax({
|
|
|
|
url: [
|
|
|
|
ui.item.closest('[data-layout-update-url]').data('layout-update-url'),
|
2018-01-26 20:50:00 +00:00
|
|
|
deltaFrom,
|
|
|
|
deltaTo,
|
|
|
|
itemRegion.data('region'),
|
Issue #2905922 by tim.plunkett, tedbow, xjm, EclipseGc, webchick, vijaycs85, larowlan, andrewmacpherson, droplet, Bojhan, mgifford, drpal, phenaproxima, DyanneNova, japerry: Implementation issue for Layout Builder
2017-11-17 19:01:26 +00:00
|
|
|
ui.item.data('layout-block-uuid'),
|
|
|
|
ui.item.prev('[data-layout-block-uuid]').data('layout-block-uuid'),
|
|
|
|
]
|
2018-07-05 15:34:50 +00:00
|
|
|
.filter(element => element !== undefined)
|
|
|
|
.join('/'),
|
Issue #2905922 by tim.plunkett, tedbow, xjm, EclipseGc, webchick, vijaycs85, larowlan, andrewmacpherson, droplet, Bojhan, mgifford, drpal, phenaproxima, DyanneNova, japerry: Implementation issue for Layout Builder
2017-11-17 19:01:26 +00:00
|
|
|
}).execute();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
})(jQuery, Drupal);
|