Skip to content

Commit 996720b

Browse files
authored
Merge pull request joomla#38 from joomla-projects/C-Lodder-patch-2
Transform admin-login.js to ES6
2 parents 733b66e + 62e9ff2 commit 996720b

File tree

2 files changed

+51
-20
lines changed

2 files changed

+51
-20
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
3+
* @license GNU General Public License version 2 or later; see LICENSE.txt
4+
*/
5+
6+
(() => {
7+
'use strict';
8+
9+
const btn = document.getElementById('btn-login-submit');
10+
if (btn) {
11+
btn.addEventListener('click', (event) => {
12+
event.preventDefault();
13+
const form = document.getElementById('form-login');
14+
if (form && document.formvalidator.isValid(form)) {
15+
Joomla.submitbutton('login');
16+
}
17+
});
18+
}
19+
20+
const formTmp = document.querySelector('.login-initial');
21+
if (formTmp) {
22+
formTmp.style.display = 'block';
23+
if (!document.querySelector('joomla-alert')) {
24+
document.getElementById('mod-login-username').focus();
25+
}
26+
}
27+
})();

media/mod_login/js/admin-login.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1+
/**
2+
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
3+
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
4+
**/
5+
16
/**
27
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
38
* @license GNU General Public License version 2 or later; see LICENSE.txt
49
*/
510

6-
(function() {
7-
'use strict';
8-
9-
var btn = document.getElementById('btn-login-submit');
10-
if (btn) {
11-
btn.addEventListener('click', function(e) {
12-
e.preventDefault();
13-
var form = document.getElementById('form-login');
14-
if (form && document.formvalidator.isValid(form)) {
15-
Joomla.submitbutton('login')
16-
}
17-
});
18-
}
11+
(function () {
12+
'use strict';
1913

20-
var formTmp = document.querySelector('.login-initial');
21-
if (formTmp) {
22-
formTmp.style.display = 'block';
23-
if (!document.querySelector('joomla-alert')) {
24-
document.getElementById('mod-login-username').focus();
25-
}
26-
}
14+
var btn = document.getElementById('btn-login-submit');
15+
if (btn) {
16+
btn.addEventListener('click', function (event) {
17+
event.preventDefault();
18+
var form = document.getElementById('form-login');
19+
if (form && document.formvalidator.isValid(form)) {
20+
Joomla.submitbutton('login');
21+
}
22+
});
23+
}
2724

25+
var formTmp = document.querySelector('.login-initial');
26+
if (formTmp) {
27+
formTmp.style.display = 'block';
28+
if (!document.querySelector('joomla-alert')) {
29+
document.getElementById('mod-login-username').focus();
30+
}
31+
}
2832
})();

0 commit comments

Comments
 (0)