emoji tooltips

This commit is contained in:
りき萌 2023-08-28 22:11:18 +02:00
parent 8df477e1d9
commit e7e848daeb
4 changed files with 78 additions and 3 deletions

30
static/js/emoji.js Normal file
View file

@ -0,0 +1,30 @@
// Emoji zoom-in functionality.
class Emoji extends HTMLImageElement {
constructor() {
super();
this.wrapper = document.createElement("span");
this.wrapper.className = "emoji-wrapper";
this.replaceWith(this.wrapper);
this.wrapper.appendChild(this);
this.enlarged = new Image();
this.enlarged.src = this.src;
this.titleElement = document.createElement("p");
this.titleElement.innerText = this.title;
this.tooltip = document.createElement("div");
this.tooltip.className = "emoji-tooltip";
this.tooltip.appendChild(this.enlarged);
this.tooltip.appendChild(this.titleElement);
this.wrapper.appendChild(this.tooltip);
this.alt = this.title;
this.title = "";
}
}
customElements.define("th-emoji", Emoji, { extends: "img" });