forked from a64f7bb4-7358-4778-9fbe-3b882c34cc1d/v1
29 lines
975 B
JavaScript
29 lines
975 B
JavaScript
/* eslint-disable func-names, no-mutable-exports, comma-dangle, strict */
|
|
|
|
'use strict';
|
|
|
|
((Drupal) => {
|
|
Drupal.behaviors.ginEditForm = {
|
|
attach: (context) => {
|
|
once('ginEditForm', '.region-content form.gin-node-edit-form', context).forEach(form => {
|
|
const sticky = context.querySelector('.gin-sticky');
|
|
const newParent = context.querySelector('.region-sticky__items__inner');
|
|
|
|
if (newParent && newParent.querySelectorAll('.gin-sticky').length === 0) {
|
|
newParent.appendChild(sticky);
|
|
|
|
// Attach form elements to main form
|
|
const actionButtons = newParent.querySelectorAll('button, input, select, textarea');
|
|
|
|
if (actionButtons.length > 0) {
|
|
actionButtons.forEach((el) => {
|
|
el.setAttribute('form', form.getAttribute('id'));
|
|
el.setAttribute('id', el.getAttribute('id') + '--gin-edit-form');
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
};
|
|
})(Drupal);
|