aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/techeditor.js
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-07-13 19:59:34 -0400
committerhistoria <[not public]>2026-07-13 19:59:34 -0400
commit223d198c95b64d3d803be5d914c5b899dd30c8eb (patch)
tree0ab3824cef83dc33dc2d4409b0e36f6b7d504379 /internal/admin/static/techeditor.js
parent1bedf06969b8ab8e51dd4301a0831200df5c8f59 (diff)
downloadthehouseoficarus-223d198c95b64d3d803be5d914c5b899dd30c8eb.tar.gz
refactor(admin): simplify css and js of card collapsing and side bar directories
Diffstat (limited to 'internal/admin/static/techeditor.js')
-rw-r--r--internal/admin/static/techeditor.js34
1 files changed, 15 insertions, 19 deletions
diff --git a/internal/admin/static/techeditor.js b/internal/admin/static/techeditor.js
index 812cded..020ba11 100644
--- a/internal/admin/static/techeditor.js
+++ b/internal/admin/static/techeditor.js
@@ -95,6 +95,9 @@ function renderTechEditor(id, data) {
html += '</div>';
$('#editorMain').innerHTML = html;
+ document.querySelectorAll('details.obj-card').forEach(function(d) {
+ d.addEventListener('toggle', function() { expandedCards[d.getAttribute('data-card')] = d.open; });
+ });
setupSearchFields();
}
@@ -105,25 +108,23 @@ function renderCurrent() {
}
function renderCard(sec, data) {
- var collapsed = expandedCards[sec.id] === false;
+ var openAttr = expandedCards[sec.id] === false ? '' : ' open';
var isFull = cardWidths[sec.id] !== undefined ? cardWidths[sec.id] : (sec.fullWidth || false);
var fullClass = isFull ? ' obj-card-full' : '';
- var h = '<div class="obj-card' + fullClass + '" data-card="' + sec.id + '">';
- h += '<div class="obj-card-header" onclick="toggleCard(\'' + sec.id + '\')">';
- h += '<span class="obj-card-arrow">' + (collapsed ? '&#9654;' : '&#9660;') + '</span>';
+ var h = '<details class="obj-card' + fullClass + '" data-card="' + sec.id + '"' + openAttr + '>';
+ h += '<summary class="obj-card-header">';
+ h += '<span class="obj-card-arrow"></span>';
h += '<span class="obj-card-label">' + sec.label + '</span>';
- h += '<button class="btn btn-sm obj-card-expand" onclick="event.stopPropagation();toggleCardWidth(\'' + sec.id + '\')" title="' + (isFull ? 'Half width' : 'Full width') + '">' + (isFull ? '\u2190' : '\u2192') + '</button>';
+ h += '<button class="btn btn-sm obj-card-expand" onclick="event.preventDefault();toggleCardWidth(\'' + sec.id + '\')" title="' + (isFull ? 'Half width' : 'Full width') + '">' + (isFull ? '\u2190' : '\u2192') + '</button>';
+ h += '</summary>';
+ h += '<div class="obj-card-body">';
+ h += '<div class="obj-card-grid">';
+ sec.fields.forEach(function(f) {
+ h += renderField(sec, f, data, -1);
+ });
h += '</div>';
- if (!collapsed) {
- h += '<div class="obj-card-body">';
- h += '<div class="obj-card-grid">';
- sec.fields.forEach(function(f) {
- h += renderField(sec, f, data, -1);
- });
- h += '</div>';
- h += '</div>';
- }
h += '</div>';
+ h += '</details>';
return h;
}
@@ -131,11 +132,6 @@ function renderField(sec, f, data, idx) {
return ced_renderField(sec, f, data, idx, null, null, cardPath, fieldID, getVal);
}
-function toggleCard(id) {
- expandedCards[id] = expandedCards[id] === false ? true : false;
- renderCurrent();
-}
-
function toggleCardWidth(id) {
cardWidths[id] = !cardWidths[id];
renderCurrent();