parent
f1c920e000
commit
99c1b83133
2 changed files with 45 additions and 0 deletions
@ -0,0 +1,7 @@ |
||||
.vimvixen-hint { |
||||
background-color: yellow; |
||||
border: 1px solid gold; |
||||
font-weight: bold; |
||||
position: absolute; |
||||
text-transform: uppercase; |
||||
} |
@ -0,0 +1,38 @@ |
||||
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; |
||||
} |
||||
} |
||||
} |
Reference in new issue