From b8259ddef65bb229df16d2f4a68b413de81e82ed Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Wed, 18 Nov 2020 17:19:42 -0500 Subject: [PATCH] fix no tab refresh --- src/interaction/siModify.js | 2 +- src/interaction/slaveInteract.js | 33 +++++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/interaction/siModify.js b/src/interaction/siModify.js index 21effcd53d6..d71672b9735 100644 --- a/src/interaction/siModify.js +++ b/src/interaction/siModify.js @@ -1,6 +1,6 @@ /** * @param {App.Entity.SlaveState} slave - * @returns {Node} + * @returns {DocumentFragment} */ App.UI.SlaveInteract.modify = function(slave) { const {he, his} = getPronouns(slave); diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index 0b85f03a034..f7084dd5510 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -70,7 +70,7 @@ App.UI.SlaveInteract.mainPage = function(slave) { * @typedef {Object} siCategory * @property {string} title * @property {string} id - * @property {Node} node + * @property {DocumentFragment|HTMLElement} node * @property {Function} [onClick] */ @@ -156,6 +156,10 @@ App.UI.SlaveInteract.mainPage = function(slave) { return el; + /** + * @param {siCategory} item + * @returns {HTMLElement} + */ function makeTabButton(item) { const btn = document.createElement("button"); btn.className = "tab-links"; @@ -173,18 +177,26 @@ App.UI.SlaveInteract.mainPage = function(slave) { } } + /** + * @returns {DocumentFragment} + */ function displayWithoutTabs() { const el = new DocumentFragment(); App.Events.drawEventArt(el, slave); for (const item of buttons) { App.UI.DOM.appendNewElement("h2", el, item.title); - el.append(item.node); + el.append(makeContentSpan(item)); if (item.hasOwnProperty("onClick")) { item.onClick(); } } return el; } + + /** + * @param {siCategory} item + * @returns {HTMLElement} + */ function makeTabContents(item) { const wrapperEl = document.createElement("div"); wrapperEl.id = item.id; @@ -193,14 +205,21 @@ App.UI.SlaveInteract.mainPage = function(slave) { const classEl = document.createElement("div"); classEl.classList.add("content"); + classEl.append(makeContentSpan(item)); + wrapperEl.append(classEl); + + return wrapperEl; + } + + /** + * @param {siCategory} item + * @returns {HTMLElement} + */ + function makeContentSpan(item) { const uniqueContent = document.createElement("span"); uniqueContent.id = `content-${item.id}`; uniqueContent.append(item.node); - classEl.append(uniqueContent); - wrapperEl.append(classEl); - - - return wrapperEl; + return uniqueContent; } }; -- GitLab