Improve toggle behavior

This commit is contained in:
hankhill19580
2020-04-26 11:31:14 +00:00
parent 6859baba9f
commit b0c6c845bf

View File

@ -15,34 +15,27 @@ hideableTables.forEach(function(configTable) {
var collapseme = false; var collapseme = false;
for (var i = 0, row; (row = configTable.offsetParent.rows[i]); i++) { for (var i = 0, row; (row = configTable.offsetParent.rows[i]); i++) {
var l = lookupTableRow(); var l = lookupTableRow();
if (i > l) { if (i >= l) {
if (collapseme) { if (row.classList.contains("tunnelConfigExpanded")) {
if (row.firstElementChild.localName != "th") {
if (
!row.firstElementChild.classList.contains("buttons")
) {
row.style.visibility = "collapse"; row.style.visibility = "collapse";
}
}
} else if (row.style.visibility == "visible") {
if (row.firstElementChild.localName != "th") {
if (
!row.firstElementChild.classList.contains("buttons")
) {
row.style.visibility = "collapse";
collapseme = true;
}
}
row.querySelectorAll("th").forEach(function(configRow) { row.querySelectorAll("th").forEach(function(configRow) {
configRow.classList.toggle('tunnelConfigExpanded'); configRow.classList.remove('tunnelConfigExpanded');
configRow.parentElement.style.visiblity = "visible"
});
row.querySelectorAll(".buttons").forEach(function(configRow) {
configRow.classList.remove('tunnelConfigExpanded');
configRow.parentElement.style.visiblity = "visible"
}); });
configTable.classList.remove('tunnelConfigExpanded'); configTable.classList.remove('tunnelConfigExpanded');
row.classList.remove('tunnelConfigExpanded');
} else { } else {
row.style.visibility = "visible"; row.style.visibility = "visible";
row.querySelectorAll("th").forEach(function(configRow) { row.querySelectorAll("th").forEach(function(configRow) {
configRow.classList.add('tunnelConfigExpanded'); configRow.classList.add('tunnelConfigExpanded');
}); });
configTable.classList.add('tunnelConfigExpanded'); configTable.classList.add('tunnelConfigExpanded');
row.classList.add('tunnelConfigExpanded')
row.classList.add('excludeBackgroundImage')
} }
} }
} }
@ -52,6 +45,16 @@ hideableTables.forEach(function(configTable) {
if (row.firstElementChild.localName != "th") { if (row.firstElementChild.localName != "th") {
if (!row.firstElementChild.classList.contains("buttons")) { if (!row.firstElementChild.classList.contains("buttons")) {
row.style.visibility = "collapse"; row.style.visibility = "collapse";
row.querySelectorAll("th").forEach(function(configRow) {
configRow.classList.remove('tunnelConfigExpanded');
configRow.parentElement.style.visiblity = "visible"
});
row.querySelectorAll(".buttons").forEach(function(configRow) {
configRow.classList.remove('tunnelConfigExpanded');
configRow.parentElement.style.visiblity = "visible"
});
configTable.classList.remove('tunnelConfigExpanded');
row.classList.remove('tunnelConfigExpanded');
} }
} }
} }