aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/mobeditor.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/mobeditor.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/mobeditor.js')
-rw-r--r--internal/admin/static/mobeditor.js28
1 files changed, 12 insertions, 16 deletions
diff --git a/internal/admin/static/mobeditor.js b/internal/admin/static/mobeditor.js
index 05d33da..2bef881 100644
--- a/internal/admin/static/mobeditor.js
+++ b/internal/admin/static/mobeditor.js
@@ -207,6 +207,9 @@ function renderMobEditor(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; });
+ });
ced_setupSearchFields();
setupMobProtectedToggle();
applyTaskVisibility();
@@ -230,20 +233,19 @@ function renderCurrent() {
// ---- Card rendering ----
function renderMobCard(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="toggleMobCard(\'' + 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();toggleMobCardWidth(\'' + sec.id + '\')" title="' + (isFull ? 'Half width' : 'Full width') + '">' + (isFull ? '\u2190' : '\u2192') + '</button>';
+ h += '<button class="btn btn-sm obj-card-expand" onclick="event.preventDefault();toggleMobCardWidth(\'' + sec.id + '\')" title="' + (isFull ? 'Half width' : 'Full width') + '">' + (isFull ? '\u2190' : '\u2192') + '</button>';
if (!sec.always) {
- h += '<button class="btn btn-sm btn-danger obj-card-remove" onclick="event.stopPropagation();removeMobSection(\'' + sec.id + '\')">X</button>';
+ h += '<button class="btn btn-sm btn-danger obj-card-remove" onclick="event.preventDefault();removeMobSection(\'' + sec.id + '\')">X</button>';
}
- h += '</div>';
- if (!collapsed) {
- h += '<div class="obj-card-body">';
+ h += '</summary>';
+ h += '<div class="obj-card-body">';
if (sec.id === 'core') {
h += renderMobCoreCard(data);
@@ -284,9 +286,8 @@ function renderMobCard(sec, data) {
h += '<div id="talktree"></div>';
}
}
- h += '</div>';
- }
h += '</div>';
+ h += '</details>';
return h;
}
@@ -746,11 +747,6 @@ function renderMobTableSubtable(sec, st, arr) {
// ---- Card toggle / section add-remove ----
-function toggleMobCard(id) {
- expandedCards[id] = expandedCards[id] === false ? true : false;
- renderCurrent();
-}
-
function toggleMobCardWidth(id) {
cardWidths[id] = !cardWidths[id];
renderCurrent();