aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-08-20 18:11:52 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-08-20 18:11:52 +0900
commit99c1b831330462442e4c41553c29887ecdd96583 (patch)
tree7faaf92a5d48008dc10a2e9aedd7dce3f2a98aa9
parentf1c920e0003238a8f319fd29cd7aea068fd4f231 (diff)
add hint element wrapper
-rw-r--r--src/content/hint.css7
-rw-r--r--src/content/hint.js38
2 files changed, 45 insertions, 0 deletions
diff --git a/src/content/hint.css b/src/content/hint.css
new file mode 100644
index 0000000..a0f1233
--- /dev/null
+++ b/src/content/hint.css
@@ -0,0 +1,7 @@
+.vimvixen-hint {
+ background-color: yellow;
+ border: 1px solid gold;
+ font-weight: bold;
+ position: absolute;
+ text-transform: uppercase;
+}
diff --git a/src/content/hint.js b/src/content/hint.js
new file mode 100644
index 0000000..7979cf1
--- /dev/null
+++ b/src/content/hint.js
@@ -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;
+ }
+ }
+}