';
+ h += '';
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();
diff --git a/internal/admin/static/editor.js b/internal/admin/static/editor.js
index 593bf7f..7a4fcb1 100644
--- a/internal/admin/static/editor.js
+++ b/internal/admin/static/editor.js
@@ -3,7 +3,7 @@ var editorFields = [];
var currentID = null;
var allIDs = [];
var treeData = { root: [], dirs: {} };
-var collapsedDirs = {};
+var dirOpenState = {};
function initEditor(type, fields) {
editorType = type;
@@ -49,6 +49,12 @@ function renderList(filter) {
}
el.innerHTML = html;
+ el.querySelectorAll('details.dir-group').forEach(function(d) {
+ d.addEventListener('toggle', function() {
+ var n = d.getAttribute('data-name');
+ if (n) dirOpenState[n] = d.open;
+ });
+ });
}
function renderDirGroup(name, ids, filter) {
@@ -59,30 +65,37 @@ function renderDirGroup(name, ids, filter) {
displayIds = ids.filter(function(id) { return String(id).toLowerCase().indexOf(filter) >= 0; });
if (displayIds.length === 0) return '';
}
- var expanded = isFiltering ? true : (collapsedDirs[name] === true);
- var displayName = name || editorType.charAt(0).toUpperCase() + editorType.slice(1);
- var h = '
';
- if (name) {
- h += '';
+
+ function renderItems() {
+ var h = '';
+ displayIds.forEach(function(id) {
+ h += '
' + esc(id) + '
';
+ });
+ return h;
}
- h += '
';
- displayIds.forEach(function(id) {
- h += '
' + esc(id) + '
';
- });
- h += '
';
+
+ if (!name) {
+ var fh = '
';
+ fh += renderItems();
+ fh += '
';
+ return fh;
+ }
+
+ var open = isFiltering || dirOpenState[name] === true;
+ var openAttr = open ? ' open' : '';
+ var h = '
';
+ h += '';
+ h += '';
+ h += renderItems();
h += '
';
+ h += ' ';
return h;
}
-function toggleDir(name) {
- collapsedDirs[name] = collapsedDirs[name] !== true;
- renderList('');
-}
-
function filterList(val) {
renderList(val);
}
diff --git a/internal/admin/static/hazardeditor.js b/internal/admin/static/hazardeditor.js
index 1f5fdf3..f85cde3 100644
--- a/internal/admin/static/hazardeditor.js
+++ b/internal/admin/static/hazardeditor.js
@@ -114,6 +114,9 @@ function renderHazardEditor(id, data) {
html += '
';
$('#editorMain').innerHTML = html;
+ document.querySelectorAll('details.obj-card').forEach(function(d) {
+ d.addEventListener('toggle', function() { expandedCards[d.getAttribute('data-card')] = d.open; });
+ });
setupSearchFields();
}
@@ -124,35 +127,33 @@ 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 = '
';
- h += '';
- if (!collapsed) {
- h += '
';
- if (sec.id === 'combat') {
- h += renderHazardCombatCard(data);
- } else {
- h += '
';
- sec.fields.forEach(function(f) {
- h += renderField(sec, f, data, -1);
- });
- h += '
';
- if (sec.id === 'core') {
- h += ced_renderTagHelp('color');
- }
- }
+ h += '';
+ h += '
';
+ if (sec.id === 'combat') {
+ h += renderHazardCombatCard(data);
+ } else {
+ h += '
';
+ sec.fields.forEach(function(f) {
+ h += renderField(sec, f, data, -1);
+ });
h += '
';
+ if (sec.id === 'core') {
+ h += ced_renderTagHelp('color');
+ }
}
h += '
';
+ h += '';
return h;
}
@@ -160,11 +161,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();
diff --git a/internal/admin/static/itemeditor.js b/internal/admin/static/itemeditor.js
index 2283c91..4097e64 100644
--- a/internal/admin/static/itemeditor.js
+++ b/internal/admin/static/itemeditor.js
@@ -216,6 +216,9 @@ function renderItemEditor(id, data) {
html += '
';
$('#editorMain').innerHTML = html;
+ document.querySelectorAll('details.obj-card').forEach(function(d) {
+ d.addEventListener('toggle', function() { expandedCards[d.getAttribute('data-card')] = d.open; });
+ });
setupSearchFields();
setupCraftTypeChange();
setupEquipTypeChange();
@@ -238,20 +241,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 = '
';
- h += '';
- if (!collapsed) {
- h += '
';
+ h += '';
+ h += '
';
if (sec.isArray) {
if (sec.interactionStyle) {
@@ -315,8 +317,7 @@ function renderCard(sec, data) {
}
}
h += '
';
- }
- h += '
';
+ h += '';
return h;
}
@@ -1031,11 +1032,6 @@ function renderKV(sec, il, data, keyOptions) {
// Card toggle / section add-remove
// =========================================================================
-function toggleCard(id) {
- expandedCards[id] = expandedCards[id] === false ? true : false;
- renderCurrent();
-}
-
function toggleCardWidth(id) {
cardWidths[id] = !cardWidths[id];
renderCurrent();
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 += '
';
$('#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 = '
';
- h += '';
- if (!collapsed) {
- h += '
';
+ h += '';
+ h += '
';
if (sec.id === 'core') {
h += renderMobCoreCard(data);
@@ -284,9 +286,8 @@ function renderMobCard(sec, data) {
h += '
';
}
}
- h += '
';
- }
h += '
';
+ h += '';
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();
diff --git a/internal/admin/static/moduleeditor.js b/internal/admin/static/moduleeditor.js
index b2eb79f..ff9d8a4 100644
--- a/internal/admin/static/moduleeditor.js
+++ b/internal/admin/static/moduleeditor.js
@@ -106,6 +106,9 @@ function renderModuleEditor(id, data) {
html += '
';
$('#editorMain').innerHTML = html;
+ document.querySelectorAll('details.obj-card').forEach(function(d) {
+ d.addEventListener('toggle', function() { expandedCards[d.getAttribute('data-card')] = d.open; });
+ });
setupSearchFields();
}
@@ -116,43 +119,41 @@ 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 = '
';
- h += '';
- if (!collapsed) {
- h += '
';
+ h += '';
+ h += '
';
- if (sec.isArray) {
- h += renderArraySection(sec, data);
- } else {
- h += '
';
- sec.fields.forEach(function(f) {
- h += renderField(sec, f, data, -1);
+ if (sec.isArray) {
+ h += renderArraySection(sec, data);
+ } else {
+ h += '
';
+ sec.fields.forEach(function(f) {
+ h += renderField(sec, f, data, -1);
+ });
+ h += '
';
+
+ if (sec.inline) {
+ sec.inline.forEach(function(il) {
+ if (il.type === 'kv') {
+ h += ced_renderKV(sec, il, data);
+ } else if (il.type === 'kv_search') {
+ h += ced_renderKVSearch(sec, il, data);
+ }
});
- h += '
';
-
- if (sec.inline) {
- sec.inline.forEach(function(il) {
- if (il.type === 'kv') {
- h += ced_renderKV(sec, il, data);
- } else if (il.type === 'kv_search') {
- h += ced_renderKVSearch(sec, il, data);
- }
- });
- }
}
- h += '
';
}
h += '
';
+ h += '';
return h;
}
@@ -177,11 +178,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();
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 += '
';
$('#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 = '
';
- h += '';
- if (!collapsed) {
- h += '
';
+ h += '';
+ h += '
';
if (sec.isArray) {
h += renderArraySection(sec, data);
@@ -325,9 +327,8 @@ function renderCard(sec, data) {
h += ced_renderTagHelp('gather');
}
}
- h += '
';
- }
h += '
';
+ h += '';
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();
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 += '
';
$('#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 = '
';
- h += '