diff options
Diffstat (limited to 'internal/admin/static/objecteditor.js')
| -rw-r--r-- | internal/admin/static/objecteditor.js | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/internal/admin/static/objecteditor.js b/internal/admin/static/objecteditor.js index 363cca9..15b656b 100644 --- a/internal/admin/static/objecteditor.js +++ b/internal/admin/static/objecteditor.js @@ -173,6 +173,9 @@ function renderObjectEditor(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(); setupObjectDropViews(); setTimeout(function() { @@ -204,24 +207,23 @@ function fieldIDSub(sec, subKey, idx, fieldKey) { } 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; if (sec.labelHint) { h += ' <span style="color:#666;font-size:10px;font-weight:normal">' + esc(sec.labelHint) + '</span>'; } h += '</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>'; if (!sec.always) { - h += '<button class="btn btn-sm btn-danger obj-card-remove" onclick="event.stopPropagation();removeSection(\'' + sec.id + '\')">X</button>'; + h += '<button class="btn btn-sm btn-danger obj-card-remove" onclick="event.preventDefault();removeSection(\'' + sec.id + '\')">X</button>'; } - h += '</div>'; - if (!collapsed) { - h += '<div class="obj-card-body">'; + h += '</summary>'; + h += '<div class="obj-card-body">'; if (sec.isArray) { h += renderArraySection(sec, data); @@ -325,9 +327,8 @@ function renderCard(sec, data) { h += ced_renderTagHelp('gather'); } } - h += '</div>'; - } h += '</div>'; + h += '</details>'; return h; } @@ -731,11 +732,6 @@ function syncGatherToolsFromDOM() { } } -function toggleCard(id) { - expandedCards[id] = expandedCards[id] === false ? true : false; - renderCurrent(); -} - function toggleCardWidth(id) { cardWidths[id] = !cardWidths[id]; renderCurrent(); |
