Skip to content

Commit 9f12c3b

Browse files
authored
[5.2] Minor cleanup for plugins JS (#42797)
* Minor cleanup for plugins JS * Update build/media_source/plg_captcha_recaptcha/js/recaptcha.es6.js * Fix
1 parent 8ecc131 commit 9f12c3b

File tree

18 files changed

+43
-106
lines changed

18 files changed

+43
-106
lines changed

build/media_source/plg_captcha_recaptcha/js/recaptcha.es6.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
'use strict';
99

1010
window.JoomlainitReCaptcha2 = () => {
11-
const elements = [].slice.call(document.getElementsByClassName('g-recaptcha'));
1211
const optionKeys = ['sitekey', 'theme', 'size', 'tabindex', 'callback', 'expired-callback', 'error-callback'];
1312

14-
elements.forEach((element) => {
13+
document.querySelectorAll('.g-recaptcha').forEach((element) => {
1514
let options = {};
1615

1716
if (element.dataset) {

build/media_source/plg_captcha_recaptcha_invisible/js/recaptcha.es6.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
'use strict';
99

1010
window.JoomlainitReCaptchaInvisible = () => {
11-
const elements = [].slice.call(document.getElementsByClassName('g-recaptcha'));
1211
const optionKeys = ['sitekey', 'badge', 'size', 'tabindex', 'callback', 'expired-callback', 'error-callback'];
1312

14-
elements.forEach((element) => {
13+
document.getElementsByClassName('g-recaptcha').forEach((element) => {
1514
let options = {};
1615

1716
if (element.dataset) {

build/media_source/plg_editors_codemirror/js/codemirror.es6.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ const optionsToExtensions = async (options) => {
125125
const [module, methods] = extInfo;
126126
q.push(import(module).then((modObject) => {
127127
// Call each method
128-
methods.forEach((method) => {
129-
extensions.push(modObject[method]());
130-
});
128+
methods.forEach((method) => extensions.push(modObject[method]()));
131129
}));
132130
});
133131
}

build/media_source/plg_editors_codemirror/js/joomla-editor-codemirror.w-c.es6.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ class CodemirrorEditor extends HTMLElement {
103103

104104
// Relocate BS modals, to resolve z-index issue in full screen
105105
this.bsModals = this.querySelectorAll('.joomla-modal.modal');
106-
this.bsModals.forEach((modal) => {
107-
document.body.appendChild(modal);
108-
});
106+
this.bsModals.forEach((modal) => document.body.appendChild(modal));
109107
}
110108

111109
// Create and register the Editor
@@ -129,9 +127,7 @@ class CodemirrorEditor extends HTMLElement {
129127

130128
// Restore modals
131129
if (this.bsModals && this.bsModals.length) {
132-
this.bsModals.forEach((modal) => {
133-
this.appendChild(modal);
134-
});
130+
this.bsModals.forEach((modal) => this.appendChild(modal));
135131
}
136132
}
137133
}

build/media_source/plg_editors_tinymce/js/tinymce-builder.es6.js

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/media_source/plg_installer_packageinstaller/js/packageinstaller.es6.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ Joomla = window.Joomla || {};
6363
uploadUrl += `&return=${returnUrl}`;
6464
}
6565

66-
button.addEventListener('click', () => {
67-
fileInput.click();
68-
});
66+
button.addEventListener('click', () => fileInput.click());
6967

7068
fileInput.addEventListener('change', () => {
7169
if (uploading) {

build/media_source/plg_installer_webinstaller/js/client.es6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class WebInstaller {
184184
WebInstaller.clicker();
185185

186186
if (webInstallerOptions.view !== 'extension') {
187-
[].slice.call(document.querySelectorAll('div.load-extension')).forEach((element) => {
187+
document.querySelectorAll('div.load-extension').forEach((element) => {
188188
element.addEventListener('click', (event) => {
189189
event.preventDefault();
190190
this.processLinkClick(element.getAttribute('data-url'));
@@ -237,7 +237,7 @@ class WebInstaller {
237237
}
238238

239239
clickforlinks() {
240-
[].slice.call(document.querySelectorAll('a.transcode')).forEach((element) => {
240+
document.querySelectorAll('a.transcode').forEach((element) => {
241241
const ajaxurl = element.getAttribute('href');
242242

243243
element.addEventListener('click', (event) => {

build/media_source/plg_media-action_rotate/js/rotate.es6.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,18 @@ const initRotate = (image) => {
6262

6363
target.value = 0;
6464
// Deselect all buttons
65-
[].slice.call(document.querySelectorAll('#jform_rotate_distinct label'))
66-
.forEach((element) => {
67-
element.classList.remove('active');
68-
element.classList.remove('focus');
69-
});
65+
document.querySelectorAll('#jform_rotate_distinct label').forEach((element) => element.classList.remove('active', 'focus'));
7066
});
7167

7268
// The 90 degree rotate buttons listeners
73-
[].slice.call(document.querySelectorAll('#jform_rotate_distinct [type=radio]'))
74-
.forEach((element) => {
75-
element.addEventListener('click', ({ target }) => {
76-
rotate(parseInt(target.value, 10), image);
69+
document.querySelectorAll('#jform_rotate_distinct [type=radio]').forEach((element) => {
70+
element.addEventListener('click', ({ target }) => {
71+
rotate(parseInt(target.value, 10), image);
7772

78-
// Deselect all buttons
79-
[].slice.call(document.querySelectorAll('#jform_rotate_distinct label'))
80-
.forEach((el) => {
81-
el.classList.remove('active');
82-
el.classList.remove('focus');
83-
});
84-
});
73+
// Deselect all buttons
74+
document.querySelectorAll('#jform_rotate_distinct label').forEach((el) => el.classList.remove('active', 'focus'));
8575
});
76+
});
8677

8778
activated = true;
8879
}

build/media_source/plg_multifactorauth_webauthn/js/webauthn.es6.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,7 @@
188188
document.getElementById('users-mfa-captive-button-submit')
189189
.addEventListener('click', onValidateClick);
190190
} else {
191-
document.querySelectorAll('.multifactorauth_webauthn_setup').forEach((btn) => {
192-
btn.addEventListener('click', setUp);
193-
});
191+
document.querySelectorAll('.multifactorauth_webauthn_setup').forEach((btn) => btn.addEventListener('click', setUp));
194192
}
195193
});
196194
})(Joomla, document);

build/media_source/plg_quickicon_extensionupdate/js/extensionupdatecheck.es6.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@
1313

1414
const update = (type, text) => {
1515
const link = document.getElementById('plg_quickicon_extensionupdate');
16-
const linkSpans = [].slice.call(link.querySelectorAll('span.j-links-link'));
1716
if (link) {
1817
link.classList.add(type);
1918
}
2019

21-
if (linkSpans.length) {
22-
linkSpans.forEach((span) => {
23-
span.innerHTML = Joomla.sanitizeHtml(text);
24-
});
25-
}
20+
link.querySelectorAll('span.j-links-link').forEach((span) => {
21+
span.innerHTML = Joomla.sanitizeHtml(text);
22+
});
2623
};
2724

2825
/**
@@ -57,7 +54,5 @@
5754
};
5855

5956
// Give some times to the layout and other scripts to settle their stuff
60-
window.addEventListener('load', () => {
61-
setTimeout(fetchUpdate, 330);
62-
});
57+
window.addEventListener('load', () => setTimeout(fetchUpdate, 330));
6358
})();

0 commit comments

Comments
 (0)