summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2018-01-03 10:34:30 -0800
committerwebchick2018-01-03 10:34:30 -0800
commit35de151d0ef048ed588dacf0c8bf022ee208abcd (patch)
tree3f4d4d342eaa82fb8fe7762496eed11db81b9c9f
parent5485720ee8b53acb7b666433667a6f83b192a80e (diff)
Issue #2924351 by drpal, tedbow, xjm, dawehner: Fix coding standards issues with existing settings tray JavaScript
-rw-r--r--core/modules/settings_tray/js/settings_tray.es6.js25
-rw-r--r--core/modules/settings_tray/js/settings_tray.js2
2 files changed, 16 insertions, 11 deletions
diff --git a/core/modules/settings_tray/js/settings_tray.es6.js b/core/modules/settings_tray/js/settings_tray.es6.js
index a680115..6487690 100644
--- a/core/modules/settings_tray/js/settings_tray.es6.js
+++ b/core/modules/settings_tray/js/settings_tray.es6.js
@@ -5,7 +5,7 @@
* @private
*/
-(function ($, Drupal) {
+(($, Drupal) => {
const blockConfigureSelector = '[data-settings-tray-edit]';
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';
@@ -81,9 +81,10 @@
if ($editables.length) {
// Use event capture to prevent clicks on links.
document.querySelector('[data-off-canvas-main-canvas]').addEventListener('click', preventClick, true);
-
- // When a click occurs try and find the settings-tray edit link
- // and click it.
+ /**
+ * When a click occurs try and find the settings-tray edit link
+ * and click it.
+ */
$editables
.not(contextualItemsSelector)
.on('click.settingstray', (e) => {
@@ -154,14 +155,18 @@
function prepareAjaxLinks() {
// Find all Ajax instances that use the 'off_canvas' renderer.
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')
- // 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) => {
// 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.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');
@@ -253,4 +258,4 @@
}
},
});
-}(jQuery, Drupal));
+})(jQuery, Drupal);
diff --git a/core/modules/settings_tray/js/settings_tray.js b/core/modules/settings_tray/js/settings_tray.js
index 78c5b60..7a83e15 100644
--- a/core/modules/settings_tray/js/settings_tray.js
+++ b/core/modules/settings_tray/js/settings_tray.js
@@ -97,7 +97,7 @@
Drupal.ajax.instances.filter(function (instance) {
return instance && $(instance.element).attr('data-dialog-renderer') === 'off_canvas';
}).forEach(function (instance) {
- if (!('dialogOptions' in instance.options.data)) {
+ if (!instance.options.data.hasOwnProperty('dialogOptions')) {
instance.options.data.dialogOptions = {};
}
instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');