Updating styling
This commit is contained in:
parent
c8d0a8624f
commit
43d4abf317
@ -20,12 +20,14 @@
|
|||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1px solid #999;
|
border: 1px solid #999;
|
||||||
box-shadow: 0 0 10px rgba(0, 0, 0, .5);
|
box-shadow: 0 0 10px rgba(0, 0, 0, .5);
|
||||||
max-width: 50em;
|
color: #000;
|
||||||
|
max-height: 25em;
|
||||||
|
max-width: 30em;
|
||||||
|
overflow-y: scroll;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
pointer-events: none;
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: auto;
|
visibility: hidden;
|
||||||
z-index: 64;
|
z-index: 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
.yomichan-def-expression {
|
.yomichan-def-expression {
|
||||||
|
@ -23,16 +23,23 @@ class Client {
|
|||||||
this.popupOffset = 10;
|
this.popupOffset = 10;
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
|
|
||||||
$('body').append(this.popup);
|
$('body').append(this.popup).click(() => this.hidePopup());
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
|
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
|
||||||
window.addEventListener('mousemove', this.onMouseMove.bind(this));
|
window.addEventListener('mousemove', this.onMouseMove.bind(this));
|
||||||
|
window.addEventListener('keydown', this.onKeyDown.bind(this));
|
||||||
|
|
||||||
getState((state) => this.setEnabled(state === 'enabled'));
|
getState((state) => this.setEnabled(state === 'enabled'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onKeyDown(e) {
|
||||||
|
if (e.keyCode === 16 || e.charCode === 16) {
|
||||||
|
this.hidePopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMouseMove(e) {
|
onMouseMove(e) {
|
||||||
if (!this.enabled || !e.shiftKey) {
|
if (!this.enabled || (!e.shiftKey && e.which !== 2)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +60,7 @@ class Client {
|
|||||||
this.hidePopup();
|
this.hidePopup();
|
||||||
} else {
|
} else {
|
||||||
range.setEnd(range.endContainer, range.startOffset + length);
|
range.setEnd(range.endContainer, range.startOffset + length);
|
||||||
renderTemplate({defs: results.slice(0, 5)}, 'defs.html', (html) => {
|
renderTemplate({defs: results}, 'defs.html', (html) => {
|
||||||
this.popup.html(html);
|
this.popup.html(html);
|
||||||
this.showPopup(range);
|
this.showPopup(range);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user