Issue #2924351 by drpal, tedbow, xjm, dawehner: Fix coding standards issues with existing settings tray JavaScript
parent
5485720ee8
commit
35de151d0e
|
@ -5,7 +5,7 @@
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function ($, Drupal) {
|
(($, Drupal) => {
|
||||||
const blockConfigureSelector = '[data-settings-tray-edit]';
|
const blockConfigureSelector = '[data-settings-tray-edit]';
|
||||||
const toggleEditSelector = '[data-drupal-settingstray="toggle"]';
|
const toggleEditSelector = '[data-drupal-settingstray="toggle"]';
|
||||||
const itemsToToggleSelector = '[data-off-canvas-main-canvas], #toolbar-bar, [data-drupal-settingstray="editable"] a, [data-drupal-settingstray="editable"] button';
|
const itemsToToggleSelector = '[data-off-canvas-main-canvas], #toolbar-bar, [data-drupal-settingstray="editable"] a, [data-drupal-settingstray="editable"] button';
|
||||||
|
@ -81,9 +81,10 @@
|
||||||
if ($editables.length) {
|
if ($editables.length) {
|
||||||
// Use event capture to prevent clicks on links.
|
// Use event capture to prevent clicks on links.
|
||||||
document.querySelector('[data-off-canvas-main-canvas]').addEventListener('click', preventClick, true);
|
document.querySelector('[data-off-canvas-main-canvas]').addEventListener('click', preventClick, true);
|
||||||
|
/**
|
||||||
// When a click occurs try and find the settings-tray edit link
|
* When a click occurs try and find the settings-tray edit link
|
||||||
// and click it.
|
* and click it.
|
||||||
|
*/
|
||||||
$editables
|
$editables
|
||||||
.not(contextualItemsSelector)
|
.not(contextualItemsSelector)
|
||||||
.on('click.settingstray', (e) => {
|
.on('click.settingstray', (e) => {
|
||||||
|
@ -154,14 +155,18 @@
|
||||||
function prepareAjaxLinks() {
|
function prepareAjaxLinks() {
|
||||||
// Find all Ajax instances that use the 'off_canvas' renderer.
|
// Find all Ajax instances that use the 'off_canvas' renderer.
|
||||||
Drupal.ajax.instances
|
Drupal.ajax.instances
|
||||||
// If there is an element and the renderer is 'off_canvas' then we want
|
/**
|
||||||
// to add our changes.
|
* If there is an element and the renderer is 'off_canvas' then we want
|
||||||
|
* to add our changes.
|
||||||
|
*/
|
||||||
.filter(instance => instance && $(instance.element).attr('data-dialog-renderer') === 'off_canvas')
|
.filter(instance => instance && $(instance.element).attr('data-dialog-renderer') === 'off_canvas')
|
||||||
// Loop through all Ajax instances that use the 'off_canvas' renderer to
|
/**
|
||||||
// set active editable ID.
|
* Loop through all Ajax instances that use the 'off_canvas' renderer to
|
||||||
|
* set active editable ID.
|
||||||
|
*/
|
||||||
.forEach((instance) => {
|
.forEach((instance) => {
|
||||||
// Check to make sure existing dialogOptions aren't overridden.
|
// Check to make sure existing dialogOptions aren't overridden.
|
||||||
if (!('dialogOptions' in instance.options.data)) {
|
if (!instance.options.data.hasOwnProperty('dialogOptions')) {
|
||||||
instance.options.data.dialogOptions = {};
|
instance.options.data.dialogOptions = {};
|
||||||
}
|
}
|
||||||
instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');
|
instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');
|
||||||
|
@ -253,4 +258,4 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}(jQuery, Drupal));
|
})(jQuery, Drupal);
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
Drupal.ajax.instances.filter(function (instance) {
|
Drupal.ajax.instances.filter(function (instance) {
|
||||||
return instance && $(instance.element).attr('data-dialog-renderer') === 'off_canvas';
|
return instance && $(instance.element).attr('data-dialog-renderer') === 'off_canvas';
|
||||||
}).forEach(function (instance) {
|
}).forEach(function (instance) {
|
||||||
if (!('dialogOptions' in instance.options.data)) {
|
if (!instance.options.data.hasOwnProperty('dialogOptions')) {
|
||||||
instance.options.data.dialogOptions = {};
|
instance.options.data.dialogOptions = {};
|
||||||
}
|
}
|
||||||
instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');
|
instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');
|
||||||
|
|
Loading…
Reference in New Issue