A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
779 B
39 lines
779 B
7 years ago
|
import './hint.css';
|
||
|
|
||
|
export default class Hint {
|
||
|
constructor(target, tag) {
|
||
|
this.target = target;
|
||
|
|
||
|
let doc = target.ownerDocument
|
||
|
let { top, left } = target.getBoundingClientRect();
|
||
|
|
||
|
this.element = doc.createElement('span');
|
||
|
this.element.className = 'vimvixen-hint';
|
||
|
this.element.textContent = tag;
|
||
|
this.element.style.top = top + 'px';
|
||
|
this.element.style.left = left + 'px';
|
||
|
|
||
|
this.show();
|
||
|
doc.body.append(this.element);
|
||
|
}
|
||
|
|
||
|
show() {
|
||
|
this.element.style.display = 'inline';
|
||
|
}
|
||
|
|
||
|
hide() {
|
||
|
this.element.style.display = 'none';
|
||
|
}
|
||
|
|
||
|
remove() {
|
||
|
this.element.remove();
|
||
|
}
|
||
|
|
||
|
activate() {
|
||
|
if (this.target.tagName.toLowerCase() === 'a') {
|
||
|
let href = this.target.href;
|
||
|
window.location.href = href;
|
||
|
}
|
||
|
}
|
||
|
}
|