From 36374b6f4ea2f9e0348d8add3fc2ded988e42a2b Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@gmail.com>
Date: Tue, 6 Jul 2021 22:20:40 +0200
Subject: [PATCH] make slave "pop-up | goto" tooltip globally accessible

---
 src/js/slaveSummaryHelpers.js | 12 +++---------
 src/js/utilsSC.js             | 17 +++++++++++++++++
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/src/js/slaveSummaryHelpers.js b/src/js/slaveSummaryHelpers.js
index 3b4d8973ad4..94b521497f6 100644
--- a/src/js/slaveSummaryHelpers.js
+++ b/src/js/slaveSummaryHelpers.js
@@ -228,15 +228,9 @@ App.UI.SlaveSummaryImpl = function() {
 		 * @returns {HTMLSpanElement}
 		 */
 		function referenceSlaveWithPreview(container, slave, text) {
-			const res = App.UI.DOM.appendNewElement("span", container, text, "has-tooltip");
-			tippy(res, {
-				content: App.UI.DOM.generateLinksStrip([
-					App.UI.DOM.slaveDescriptionDialog(slave, "Pop-up", {eventDescription: false, noArt: true}),
-					App.UI.SlaveList.SlaveInteract.stdInteract(slave, "Go to")
-				]),
-				interactive: true
-			});
-			return res;
+			const preview = App.UI.DOM.referenceSlaveWithPreview(slave, text);
+			container.append(preview);
+			return preview;
 		}
 
 		const longFamilyBits = {
diff --git a/src/js/utilsSC.js b/src/js/utilsSC.js
index d2faa271d1a..e17fdad6ee3 100644
--- a/src/js/utilsSC.js
+++ b/src/js/utilsSC.js
@@ -255,6 +255,23 @@ App.UI.DOM.slaveDescriptionDialog = function(slave, text, options = {eventDescri
 	return App.UI.DOM.link(text ? text : SlaveFullName(slave), App.UI._showDescriptionDialog, [slave, options]);
 };
 
+/**
+ * @param {App.Entity.SlaveState} slave
+ * @param {string} text
+ * @returns {HTMLSpanElement}
+ */
+App.UI.DOM.referenceSlaveWithPreview = function( slave, text) {
+	const res = App.UI.DOM.makeElement("span",  text, "has-tooltip");
+	tippy(res, {
+		content: App.UI.DOM.generateLinksStrip([
+			App.UI.DOM.slaveDescriptionDialog(slave, "Pop-up", {eventDescription: false, noArt: true}),
+			App.UI.SlaveList.SlaveInteract.stdInteract(slave, "Go to")
+		]),
+		interactive: true
+	});
+	return res;
+};
+
 /**
  * Reloads the passage and stays at the same height.
  */
-- 
GitLab