mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-12 18:41:51 +00:00
Update luci-base
This commit is contained in:
parent
0291791eed
commit
56382b4306
4 changed files with 75 additions and 32 deletions
|
@ -196,6 +196,8 @@ var CBIMap = CBINode.extend({
|
||||||
|
|
||||||
if (changed && (n || 0) < 10)
|
if (changed && (n || 0) < 10)
|
||||||
this.checkDepends(ev, (n || 10) + 1);
|
this.checkDepends(ev, (n || 10) + 1);
|
||||||
|
|
||||||
|
ui.tabs.updateTabs(ev, this.root);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1065,6 +1067,10 @@ var CBITableSection = CBITypedSection.extend({
|
||||||
.catch(function() {});
|
.catch(function() {});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addModalOptions: function(modalSection, section_id, ev) {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
renderMoreOptionsModal: function(section_id, ev) {
|
renderMoreOptionsModal: function(section_id, ev) {
|
||||||
var parent = this.map,
|
var parent = this.map,
|
||||||
title = parent.title,
|
title = parent.title,
|
||||||
|
@ -1109,7 +1115,7 @@ var CBITableSection = CBITypedSection.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
//ev.target.classList.add('spinning');
|
//ev.target.classList.add('spinning');
|
||||||
m.render().then(L.bind(function(nodes) {
|
Promise.resolve(this.addModalOptions(s, section_id, ev)).then(L.bind(m.render, m)).then(L.bind(function(nodes) {
|
||||||
//ev.target.classList.remove('spinning');
|
//ev.target.classList.remove('spinning');
|
||||||
L.ui.showModal(title, [
|
L.ui.showModal(title, [
|
||||||
nodes,
|
nodes,
|
||||||
|
@ -1460,7 +1466,7 @@ var CBIListValue = CBIValue.extend({
|
||||||
id: this.cbid(section_id),
|
id: this.cbid(section_id),
|
||||||
size: this.size,
|
size: this.size,
|
||||||
sort: this.keylist,
|
sort: this.keylist,
|
||||||
optional: this.rmempty || this.optional,
|
optional: this.optional,
|
||||||
placeholder: this.placeholder,
|
placeholder: this.placeholder,
|
||||||
validate: L.bind(this.validate, this, section_id)
|
validate: L.bind(this.validate, this, section_id)
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,6 +23,20 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Promise.finally polyfill */
|
||||||
|
if (typeof Promise.prototype.finally !== 'function') {
|
||||||
|
Promise.prototype.finally = function(fn) {
|
||||||
|
var onFinally = function(cb) {
|
||||||
|
return Promise.resolve(fn.call(this)).then(cb);
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.then(
|
||||||
|
function(result) { return onFinally.call(this, function() { return result }) },
|
||||||
|
function(reason) { return onFinally.call(this, function() { return Promise.reject(reason) }) }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class declaration and inheritance helper
|
* Class declaration and inheritance helper
|
||||||
*/
|
*/
|
||||||
|
@ -1174,6 +1188,14 @@
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return inst[method].apply(inst, inst.varargs(arguments, 2));
|
return inst[method].apply(inst, inst.varargs(arguments, 2));
|
||||||
|
},
|
||||||
|
|
||||||
|
isEmpty: function(node) {
|
||||||
|
for (var child = node.firstElementChild; child != null; child = child.nextElementSibling)
|
||||||
|
if (!child.classList.contains('hidden'))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
@ -213,16 +213,19 @@ var UISelect = UIElement.extend({
|
||||||
if (!Array.isArray(value))
|
if (!Array.isArray(value))
|
||||||
value = (value != null && value != '') ? [ value ] : [];
|
value = (value != null && value != '') ? [ value ] : [];
|
||||||
|
|
||||||
if (!options.multi && value.length > 1)
|
if (!options.multiple && value.length > 1)
|
||||||
value.length = 1;
|
value.length = 1;
|
||||||
|
|
||||||
this.values = value;
|
this.values = value;
|
||||||
this.choices = choices;
|
this.choices = choices;
|
||||||
this.options = Object.assign({
|
this.options = Object.assign({
|
||||||
multi: false,
|
multiple: false,
|
||||||
widget: 'select',
|
widget: 'select',
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
|
if (this.choices.hasOwnProperty(''))
|
||||||
|
this.options.optional = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
@ -240,10 +243,10 @@ var UISelect = UIElement.extend({
|
||||||
'name': this.options.name,
|
'name': this.options.name,
|
||||||
'size': this.options.size,
|
'size': this.options.size,
|
||||||
'class': 'cbi-input-select',
|
'class': 'cbi-input-select',
|
||||||
'multiple': this.options.multi ? '' : null
|
'multiple': this.options.multiple ? '' : null
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (this.options.optional || this.choices.hasOwnProperty(''))
|
if (this.options.optional)
|
||||||
frameEl.lastChild.appendChild(E('option', {
|
frameEl.lastChild.appendChild(E('option', {
|
||||||
'value': '',
|
'value': '',
|
||||||
'selected': (this.values.length == 0 || this.values[0] == '') ? '' : null
|
'selected': (this.values.length == 0 || this.values[0] == '') ? '' : null
|
||||||
|
@ -267,8 +270,8 @@ var UISelect = UIElement.extend({
|
||||||
E('input', {
|
E('input', {
|
||||||
'id': this.options.id ? 'widget.' + this.options.id : null,
|
'id': this.options.id ? 'widget.' + this.options.id : null,
|
||||||
'name': this.options.id || this.options.name,
|
'name': this.options.id || this.options.name,
|
||||||
'type': this.options.multi ? 'checkbox' : 'radio',
|
'type': this.options.multiple ? 'checkbox' : 'radio',
|
||||||
'class': this.options.multi ? 'cbi-input-checkbox' : 'cbi-input-radio',
|
'class': this.options.multiple ? 'cbi-input-checkbox' : 'cbi-input-radio',
|
||||||
'value': keys[i],
|
'value': keys[i],
|
||||||
'checked': (this.values.indexOf(keys[i]) > -1) ? '' : null
|
'checked': (this.values.indexOf(keys[i]) > -1) ? '' : null
|
||||||
}),
|
}),
|
||||||
|
@ -320,8 +323,8 @@ var UISelect = UIElement.extend({
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = '';
|
value = '';
|
||||||
|
|
||||||
for (var i = 0; i < this.node.options.length; i++)
|
for (var i = 0; i < this.node.firstChild.options.length; i++)
|
||||||
this.node.options[i].selected = (this.node.options[i].value == value);
|
this.node.firstChild.options[i].selected = (this.node.firstChild.options[i].value == value);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -345,7 +348,7 @@ var UIDropdown = UIElement.extend({
|
||||||
this.choices = choices;
|
this.choices = choices;
|
||||||
this.options = Object.assign({
|
this.options = Object.assign({
|
||||||
sort: true,
|
sort: true,
|
||||||
multi: Array.isArray(value),
|
multiple: Array.isArray(value),
|
||||||
optional: true,
|
optional: true,
|
||||||
select_placeholder: _('-- Please choose --'),
|
select_placeholder: _('-- Please choose --'),
|
||||||
custom_placeholder: _('-- custom --'),
|
custom_placeholder: _('-- custom --'),
|
||||||
|
@ -361,7 +364,7 @@ var UIDropdown = UIElement.extend({
|
||||||
var sb = E('div', {
|
var sb = E('div', {
|
||||||
'id': this.options.id,
|
'id': this.options.id,
|
||||||
'class': 'cbi-dropdown',
|
'class': 'cbi-dropdown',
|
||||||
'multiple': this.options.multi ? '' : null,
|
'multiple': this.options.multiple ? '' : null,
|
||||||
'optional': this.options.optional ? '' : null,
|
'optional': this.options.optional ? '' : null,
|
||||||
}, E('ul'));
|
}, E('ul'));
|
||||||
|
|
||||||
|
@ -409,7 +412,7 @@ var UIDropdown = UIElement.extend({
|
||||||
bind: function(sb) {
|
bind: function(sb) {
|
||||||
var o = this.options;
|
var o = this.options;
|
||||||
|
|
||||||
o.multi = sb.hasAttribute('multiple');
|
o.multiple = sb.hasAttribute('multiple');
|
||||||
o.optional = sb.hasAttribute('optional');
|
o.optional = sb.hasAttribute('optional');
|
||||||
o.placeholder = sb.getAttribute('placeholder') || o.placeholder;
|
o.placeholder = sb.getAttribute('placeholder') || o.placeholder;
|
||||||
o.display_items = parseInt(sb.getAttribute('display-items') || o.display_items);
|
o.display_items = parseInt(sb.getAttribute('display-items') || o.display_items);
|
||||||
|
@ -425,7 +428,7 @@ var UIDropdown = UIElement.extend({
|
||||||
ndisplay = this.options.display_items,
|
ndisplay = this.options.display_items,
|
||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
if (this.options.multi) {
|
if (this.options.multiple) {
|
||||||
var items = ul.querySelectorAll('li');
|
var items = ul.querySelectorAll('li');
|
||||||
|
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
@ -657,7 +660,7 @@ var UIDropdown = UIElement.extend({
|
||||||
if (li.hasAttribute('unselectable'))
|
if (li.hasAttribute('unselectable'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.options.multi) {
|
if (this.options.multiple) {
|
||||||
var cbox = li.querySelector('input[type="checkbox"]'),
|
var cbox = li.querySelector('input[type="checkbox"]'),
|
||||||
items = li.parentNode.querySelectorAll('li'),
|
items = li.parentNode.querySelectorAll('li'),
|
||||||
label = sb.querySelector('ul.preview'),
|
label = sb.querySelector('ul.preview'),
|
||||||
|
@ -780,7 +783,7 @@ var UIDropdown = UIElement.extend({
|
||||||
element: sb
|
element: sb
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.options.multi)
|
if (this.options.multiple)
|
||||||
detail.values = values;
|
detail.values = values;
|
||||||
else
|
else
|
||||||
detail.value = values.length ? values[0] : null;
|
detail.value = values.length ? values[0] : null;
|
||||||
|
@ -800,12 +803,12 @@ var UIDropdown = UIElement.extend({
|
||||||
for (var value in values) {
|
for (var value in values) {
|
||||||
this.createItems(sb, value);
|
this.createItems(sb, value);
|
||||||
|
|
||||||
if (!this.options.multi)
|
if (!this.options.multiple)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.multi) {
|
if (this.options.multiple) {
|
||||||
var lis = ul.querySelectorAll('li[data-value]');
|
var lis = ul.querySelectorAll('li[data-value]');
|
||||||
for (var i = 0; i < lis.length; i++) {
|
for (var i = 0; i < lis.length; i++) {
|
||||||
var value = lis[i].getAttribute('data-value');
|
var value = lis[i].getAttribute('data-value');
|
||||||
|
@ -857,7 +860,7 @@ var UIDropdown = UIElement.extend({
|
||||||
val = (value || '').trim(),
|
val = (value || '').trim(),
|
||||||
ul = sb.querySelector('ul');
|
ul = sb.querySelector('ul');
|
||||||
|
|
||||||
if (!sbox.options.multi)
|
if (!sbox.options.multiple)
|
||||||
val = val.length ? [ val ] : [];
|
val = val.length ? [ val ] : [];
|
||||||
else
|
else
|
||||||
val = val.length ? val.split(/\s+/) : [];
|
val = val.length ? val.split(/\s+/) : [];
|
||||||
|
@ -881,7 +884,7 @@ var UIDropdown = UIElement.extend({
|
||||||
|
|
||||||
new_item = E(markup.replace(/{{value}}/g, '%h'.format(item)));
|
new_item = E(markup.replace(/{{value}}/g, '%h'.format(item)));
|
||||||
|
|
||||||
if (sbox.options.multi) {
|
if (sbox.options.multiple) {
|
||||||
sbox.transformItem(sb, new_item);
|
sbox.transformItem(sb, new_item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1071,7 +1074,7 @@ var UIDropdown = UIElement.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
setValue: function(values) {
|
setValue: function(values) {
|
||||||
if (this.options.multi) {
|
if (this.options.multiple) {
|
||||||
if (!Array.isArray(values))
|
if (!Array.isArray(values))
|
||||||
values = (values != null && values != '') ? [ values ] : [];
|
values = (values != null && values != '') ? [ values ] : [];
|
||||||
|
|
||||||
|
@ -1104,7 +1107,7 @@ var UIDropdown = UIElement.extend({
|
||||||
for (var i = 0; i < h.length; i++)
|
for (var i = 0; i < h.length; i++)
|
||||||
v.push(h[i].value);
|
v.push(h[i].value);
|
||||||
|
|
||||||
return this.options.multi ? v : v[0];
|
return this.options.multiple ? v : v[0];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1116,7 +1119,7 @@ var UICombobox = UIDropdown.extend({
|
||||||
dropdown_items: -1,
|
dropdown_items: -1,
|
||||||
sort: true
|
sort: true
|
||||||
}, options, {
|
}, options, {
|
||||||
multi: false,
|
multiple: false,
|
||||||
create: true,
|
create: true,
|
||||||
optional: true
|
optional: true
|
||||||
}) ]);
|
}) ]);
|
||||||
|
@ -1134,7 +1137,7 @@ var UIDynamicList = UIElement.extend({
|
||||||
this.values = values;
|
this.values = values;
|
||||||
this.choices = choices;
|
this.choices = choices;
|
||||||
this.options = Object.assign({}, options, {
|
this.options = Object.assign({}, options, {
|
||||||
multi: false,
|
multiple: false,
|
||||||
optional: true
|
optional: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -1327,11 +1330,17 @@ var UIDynamicList = UIElement.extend({
|
||||||
|
|
||||||
getValue: function() {
|
getValue: function() {
|
||||||
var items = this.node.querySelectorAll('.item > input[type="hidden"]'),
|
var items = this.node.querySelectorAll('.item > input[type="hidden"]'),
|
||||||
|
input = this.node.querySelector('.add-item > input[type="text"]'),
|
||||||
v = [];
|
v = [];
|
||||||
|
|
||||||
for (var i = 0; i < items.length; i++)
|
for (var i = 0; i < items.length; i++)
|
||||||
v.push(items[i].value);
|
v.push(items[i].value);
|
||||||
|
|
||||||
|
if (input && input.value != null && input.value.match(/\S/) &&
|
||||||
|
input.classList.contains('cbi-input-invalid') == false &&
|
||||||
|
v.filter(function(s) { return s == input.value }).length == 0)
|
||||||
|
v.push(input.value);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1580,8 +1589,14 @@ return L.Class.extend({
|
||||||
if (selected === null) {
|
if (selected === null) {
|
||||||
selected = this.getActiveTabId(groupId);
|
selected = this.getActiveTabId(groupId);
|
||||||
|
|
||||||
if (selected < 0 || selected >= panes.length)
|
if (selected < 0 || selected >= panes.length || L.dom.isEmpty(panes[selected])) {
|
||||||
selected = 0;
|
for (var i = 0; i < panes.length; i++) {
|
||||||
|
if (!L.dom.isEmpty(panes[i])) {
|
||||||
|
selected = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
menu.childNodes[selected].classList.add('cbi-tab');
|
menu.childNodes[selected].classList.add('cbi-tab');
|
||||||
menu.childNodes[selected].classList.remove('cbi-tab-disabled');
|
menu.childNodes[selected].classList.remove('cbi-tab-disabled');
|
||||||
|
@ -1621,13 +1636,13 @@ return L.Class.extend({
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTabs: function(ev) {
|
updateTabs: function(ev, root) {
|
||||||
document.querySelectorAll('[data-tab-title]').forEach(function(pane) {
|
(root || document).querySelectorAll('[data-tab-title]').forEach(function(pane) {
|
||||||
var menu = pane.parentNode.previousElementSibling,
|
var menu = pane.parentNode.previousElementSibling,
|
||||||
tab = menu.querySelector('[data-tab="%s"]'.format(pane.getAttribute('data-tab'))),
|
tab = menu.querySelector('[data-tab="%s"]'.format(pane.getAttribute('data-tab'))),
|
||||||
n_errors = pane.querySelectorAll('.cbi-input-invalid').length;
|
n_errors = pane.querySelectorAll('.cbi-input-invalid').length;
|
||||||
|
|
||||||
if (!pane.firstElementChild) {
|
if (L.dom.isEmpty(pane)) {
|
||||||
tab.style.display = 'none';
|
tab.style.display = 'none';
|
||||||
tab.classList.remove('flash');
|
tab.classList.remove('flash');
|
||||||
}
|
}
|
||||||
|
@ -1797,7 +1812,7 @@ return L.Class.extend({
|
||||||
return chg[1];
|
return chg[1];
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
return "'%ḧ'".format(chg[3].replace(/'/g, "'\"'\"'"));
|
return "'%h'".format(chg[3].replace(/'/g, "'\"'\"'"));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return chg[m1-1];
|
return chg[m1-1];
|
||||||
|
@ -1978,7 +1993,7 @@ return L.Class.extend({
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
L.ui.changes.displayStatus('warning',
|
L.ui.changes.displayStatus('warning',
|
||||||
E('p', _('Apply request failed with status <code>%h</code>%>')
|
E('p', _('Apply request failed with status <code>%h</code>')
|
||||||
.format(r.responseText || r.statusText || r.status)));
|
.format(r.responseText || r.statusText || r.status)));
|
||||||
|
|
||||||
window.setTimeout(function() {
|
window.setTimeout(function() {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
|
||||||
<meta http-equiv="refresh" content="0; URL=/cgi-bin/luci/" />
|
<meta http-equiv="refresh" content="0; URL=/cgi-bin/luci/" />
|
||||||
</head>
|
</head>
|
||||||
<body style="background-color: white">
|
<body style="background-color: white">
|
||||||
|
|
Loading…
Reference in a new issue