added delete option for youtube-dl download;added options for copying links;

This commit is contained in:
huangjx
2022-02-19 00:44:45 +08:00
parent d25e0c1ec1
commit 06e1588d06
13 changed files with 219 additions and 23 deletions

50
src/lib/tooltip.js Normal file
View File

@@ -0,0 +1,50 @@
import $ from 'jquery'
class Tooltip {
id = "ncdownloader-tooltip";
messageNode;
style = {};
text;
constructor(element, text) {
if (typeof element !== 'string' && !(element instanceof HTMLElement))
throw ("invalid element!");
this.element = typeof element == 'object' ? element : document.querySelector(element);
this.style = {
position: 'fixed',
display: 'block',
}
this.text = text || element.getAttribute("data-text");
}
create(id) {
this.messageNode = document.createElement("div");
this.messageNode.classList.add(this.id);
this.messageNode.setAttribute("id", this.id);
this.messageNode.style.display = this.style.display;
this.messageNode.style.position = this.style.position;
this.messageNode.style.zIndex = 10000;
let div = document.createElement('div');
div.setAttribute("id", id);
let text = document.createTextNode(this.text);
div.appendChild(text);
this.messageNode.appendChild(div);
this.setPosition();
return this;
}
render() {
document.body.appendChild(this.messageNode);
}
html() {
return this.messageNode;
}
setPosition(bottomMargin, leftMargin) {
bottomMargin = bottomMargin || 20;
leftMargin = leftMargin || 0;
let rect = this.element.getBoundingClientRect();
let top = (rect['top'] + bottomMargin) + "px";
let left = (rect['left'] - leftMargin) + "px";
this.messageNode.style.top = top;
this.messageNode.style.left = left
}
}
export default Tooltip;