diff --git a/src/interaction/siDescription.js b/src/interaction/siDescription.js index 7122453cbf018beb712563bb5896c8a3b910642c..d1c113c1cf4659358f77dff8312af42b1d90be2a 100644 --- a/src/interaction/siDescription.js +++ b/src/interaction/siDescription.js @@ -1,58 +1,58 @@ -App.UI.SlaveInteract.description = function(slave) { +App.UI.SlaveInteract.descriptionWrapper = function(slave) { const el = document.createElement("p"); el.id = "si-description"; - el.append(description()); + el.append(App.UI.SlaveInteract.description(slave)); return el; +}; - function description() { - const el = new DocumentFragment(); - const descriptionLink = document.createElement("div"); - descriptionLink.style.fontStyle = "italic"; - descriptionLink.id = "description-link"; - if (V.seeDetails === 1) { - descriptionLink.append(showOptions()); - el.append(descriptionLink); +App.UI.SlaveInteract.description = function(slave) { + const el = new DocumentFragment(); + const descriptionLink = document.createElement("div"); + descriptionLink.style.fontStyle = "italic"; + descriptionLink.id = "description-link"; + if (V.seeDetails === 1) { + descriptionLink.append(showOptions()); + el.append(descriptionLink); - const descriptionOptions = document.createElement("div"); - descriptionOptions.id = "description-options"; - el.append(descriptionOptions); + const descriptionOptions = document.createElement("div"); + descriptionOptions.id = "description-options"; + el.append(descriptionOptions); - el.append(App.Desc.longSlave(getSlave(V.AS), {noArt: true})); - } else { - descriptionLink.append( - App.UI.DOM.link( - "Show descriptions", - () => { - V.seeDetails = 1; - }, - [], - "Slave Interact" - ) - ); - el.append(descriptionLink); - } + el.append(App.Desc.longSlave(slave, {noArt: true})); + } else { + descriptionLink.append( + App.UI.DOM.link( + "Show descriptions", + () => { + V.seeDetails = 1; + }, + [], + "Slave Interact" + ) + ); + el.append(descriptionLink); + } - return el; + return el; - function showOptions() { - return App.UI.DOM.link( - "Description Options", - () => { - jQuery("#description-link").empty().append(hideOptions()); - jQuery("#description-options").empty().append(App.UI.DOM.renderPassage("Description Options")); - } - ); - } + function showOptions() { + return App.UI.DOM.link( + "Description Options", + () => { + jQuery("#description-link").empty().append(hideOptions()); + jQuery("#description-options").empty().append(App.UI.DOM.renderPassage("Description Options")); + } + ); + } - function hideOptions() { - return App.UI.DOM.link( - "Description Options", - () => { - jQuery("#description-link").empty().append(showOptions()); - jQuery("#description-options").empty().append(); - } - ); - } + function hideOptions() { + return App.UI.DOM.link( + "Description Options", + () => { + jQuery("#description-link").empty().append(showOptions()); + jQuery("#description-options").empty().append(); + } + ); } -}; +} diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index ea2705d4b2dac9a5208c2100b2a2c9e1c340a6a1..ab9a7b7d57ad5f1e4feb15ce6bc5738939e6f7ae 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -79,7 +79,8 @@ App.UI.SlaveInteract.mainPage = function(slave) { { title: "Description", id: "description", - get node() { return App.UI.SlaveInteract.description(slave); } + onClick: () => jQuery("#si-description").empty().append(App.UI.SlaveInteract.description(slave)), + get node() { return App.UI.SlaveInteract.descriptionWrapper(slave); } }, { title: "Modify", @@ -117,10 +118,10 @@ App.UI.SlaveInteract.mainPage = function(slave) { get node() { return App.UI.SlaveInteract.custom(slave); } }, { - title: "Family", - id: "family-tab", - onClick: () => renderFamilyTree(V.slaves, slave.ID), - get node() { return App.UI.SlaveInteract.family(); } + title: "Family", + id: "family-tab", + onClick: () => renderFamilyTree(V.slaves, slave.ID), + get node() { return App.UI.SlaveInteract.family(); } } ];