mirror of
https://github.com/openwrt/luci.git
synced 2025-12-26 11:16:38 +04:00
luci-theme-bootstrap: use ES6 syntax
Replaced L.bind with arrow functions, used Array.from for array conversion, applied concise method syntax, and switched to block-scoped declarations. Signed-off-by: Eamon Xiong <eamonxiong@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
return baseclass.extend({
|
return baseclass.extend({
|
||||||
__init__() {
|
__init__() {
|
||||||
ui.menu.load().then(L.bind(this.render, this));
|
ui.menu.load().then((tree) => this.render(tree));
|
||||||
},
|
},
|
||||||
|
|
||||||
render(tree) {
|
render(tree) {
|
||||||
|
|||||||
@@ -3,26 +3,30 @@
|
|||||||
'require view';
|
'require view';
|
||||||
|
|
||||||
return view.extend({
|
return view.extend({
|
||||||
render: function() {
|
render() {
|
||||||
var form = document.querySelector('form'),
|
const form = document.querySelector('form');
|
||||||
btn = document.querySelector('button');
|
const btn = document.querySelector('button');
|
||||||
|
|
||||||
var dlg = ui.showModal(
|
const dlg = ui.showModal(
|
||||||
_('Authorization Required'),
|
_('Authorization Required'),
|
||||||
[].slice.call(document.querySelectorAll('section > *')),
|
Array.from(document.querySelectorAll('section > *')),
|
||||||
'login'
|
'login'
|
||||||
);
|
);
|
||||||
|
|
||||||
form.addEventListener('keypress', function(ev) {
|
form.addEventListener('keypress', (ev) => {
|
||||||
if (ev.key == 'Enter')
|
if (ev.key === 'Enter')
|
||||||
btn.click();
|
btn.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
btn.addEventListener('click', function() {
|
btn.addEventListener('click', () => {
|
||||||
dlg.querySelectorAll('*').forEach(function(node) { node.style.display = 'none' });
|
dlg.querySelectorAll('*').forEach((node) => {
|
||||||
dlg.appendChild(E('div', { 'class': 'spinning' }, _('Logging in…')));
|
node.style.display = 'none';
|
||||||
|
});
|
||||||
|
dlg.appendChild(E('div', {
|
||||||
|
class: 'spinning'
|
||||||
|
}, _('Logging in…')));
|
||||||
|
|
||||||
form.submit()
|
form.submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelector('input[type="password"]').focus();
|
document.querySelector('input[type="password"]').focus();
|
||||||
@@ -30,5 +34,6 @@ return view.extend({
|
|||||||
return '';
|
return '';
|
||||||
},
|
},
|
||||||
|
|
||||||
addFooter: function() {}
|
addFooter() {},
|
||||||
});
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user