mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Merge pull request #220 from one-some/UI2
Remove tooltip on target remove
This commit is contained in:
@@ -5174,11 +5174,11 @@ let load_substitutions;
|
||||
/* -- Tooltips -- */
|
||||
function initalizeTooltips() {
|
||||
const tooltip = $e("span", document.body, {id: "tooltip-text", "style.display": "none"});
|
||||
let tooltipActive = false;
|
||||
let tooltipTarget = null;
|
||||
|
||||
function alterTooltipState(enabled, specialClass=null) {
|
||||
tooltipActive = enabled;
|
||||
tooltip.style.display = enabled ? "block" : "none";
|
||||
function alterTooltipState(target, specialClass=null) {
|
||||
tooltipTarget = target;
|
||||
tooltip.style.display = target ? "block" : "none";
|
||||
tooltip.className = specialClass || "";
|
||||
}
|
||||
|
||||
@@ -5193,11 +5193,11 @@ function initalizeTooltips() {
|
||||
// Kinda lame
|
||||
if (this.classList.contains("context-token")) specialClass = "tooltip-context-token";
|
||||
|
||||
alterTooltipState(true, specialClass);
|
||||
alterTooltipState(el, specialClass);
|
||||
});
|
||||
|
||||
el.addEventListener("mouseleave", function(event) {
|
||||
alterTooltipState(false);
|
||||
alterTooltipState(null);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5205,7 +5205,7 @@ function initalizeTooltips() {
|
||||
const yOffset = 15;
|
||||
|
||||
document.addEventListener("mousemove", function(event) {
|
||||
if (!tooltipActive) return;
|
||||
if (!tooltipTarget) return;
|
||||
|
||||
let [x, y] = [event.x, event.y];
|
||||
|
||||
@@ -5242,6 +5242,9 @@ function initalizeTooltips() {
|
||||
registerElement(record.target);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we remove the tooltip target, stop showing the tooltip. Maybe a little ineffecient.
|
||||
if (!document.body.contains(tooltipTarget)) alterTooltipState(null);
|
||||
|
||||
for (const node of record.addedNodes) {
|
||||
if (node.nodeType !== 1) continue;
|
||||
|
Reference in New Issue
Block a user