diff options
Diffstat (limited to 'internal/admin/static/dropeditor.js')
| -rw-r--r-- | internal/admin/static/dropeditor.js | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/internal/admin/static/dropeditor.js b/internal/admin/static/dropeditor.js index e8ade87..029b983 100644 --- a/internal/admin/static/dropeditor.js +++ b/internal/admin/static/dropeditor.js @@ -77,6 +77,9 @@ function renderDropEditor(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(); setupDropEditorDropView(); } @@ -88,21 +91,19 @@ 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 ? '▶' : '▼') + '</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 += '</div>'; - if (!collapsed) { - h += '<div class="obj-card-body">'; - h += renderArraySection(sec, data); - h += '</div>'; - } + 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 += renderArraySection(sec, data); h += '</div>'; + h += '</details>'; return h; } @@ -159,11 +160,6 @@ function addDropRow(cardID, kind) { renderCurrent(); } -function toggleCard(id) { - expandedCards[id] = expandedCards[id] === false ? true : false; - renderCurrent(); -} - function toggleCardWidth(id) { cardWidths[id] = !cardWidths[id]; renderCurrent(); |
