First commit of group-ironmen-master directory.

This commit is contained in:
2025-10-27 08:25:16 +08:00
commit a8467389ef
26390 changed files with 35396 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
rs-tooltip {
display: none;
position: absolute;
background: rgba(0, 0, 0, 0.8);
border: 1px solid rgba(255, 255, 255, 0.2);
padding: 4px;
pointer-events: none;
z-index: 10000;
top: 0;
left: 0;
color: white;
}

View File

@@ -0,0 +1 @@
${this.tooltipText}

View File

@@ -0,0 +1,53 @@
import { BaseElement } from "../base-element/base-element";
export class RsTooltip extends BaseElement {
constructor() {
super();
}
html() {
if (this.tooltipText) {
this.style.display = "block";
return `{{rs-tooltip.html}}`;
} else {
this.style.display = "none";
return "";
}
}
connectedCallback() {
super.connectedCallback();
this.render();
RsTooltip.globalTooltip = this;
}
disconnectedCallback() {
super.disconnectedCallback();
}
updatePosition(mouseEvent) {
const x = mouseEvent.clientX;
const y = mouseEvent.clientY;
const top = Math.max(0, y - this.height);
let left = x + 2;
if (left >= document.body.clientWidth / 2) {
left -= this.offsetWidth + 2;
}
this.style.transform = `translate(${left}px, ${top}px)`;
}
showTooltip(tooltipText) {
this.tooltipText = tooltipText;
this.eventListener(document.body, "mousemove", this.updatePosition.bind(this));
this.render();
this.height = this.offsetHeight;
}
hideTooltip() {
this.tooltipText = null;
this.unbindEvents();
this.render();
}
}
customElements.define("rs-tooltip", RsTooltip);

View File

@@ -0,0 +1,18 @@
class TooltipManager {
get globalTooltip() {
if (this._globalTooltip) return this._globalTooltip;
this._globalTooltip = document.querySelector("rs-tooltip");
return this._globalTooltip;
}
showTooltip(tooltipText) {
this.globalTooltip.showTooltip(tooltipText);
}
hideTooltip() {
this.globalTooltip.hideTooltip();
}
}
const tooltipManager = new TooltipManager();
export { tooltipManager };