mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-20 06:37:59 +01:00
add shortcut to open full image (furbooru/philomena#32)
This commit is contained in:
parent
35d80bcf9c
commit
d03b5a2c82
1 changed files with 12 additions and 2 deletions
|
@ -2,13 +2,22 @@
|
|||
* Keyboard shortcuts
|
||||
*/
|
||||
|
||||
import { $ } from './utils/dom';
|
||||
|
||||
function getHover() {
|
||||
const thumbBoxHover = document.querySelector('.media-box:hover');
|
||||
const thumbBoxHover = $('.media-box:hover');
|
||||
if (thumbBoxHover) return thumbBoxHover.dataset.imageId;
|
||||
}
|
||||
|
||||
function openFullView() {
|
||||
const imageHover = $('[data-uris]:hover');
|
||||
if (!imageHover) return;
|
||||
|
||||
window.location = JSON.parse(imageHover.dataset.uris).full;
|
||||
}
|
||||
|
||||
function click(selector) {
|
||||
const el = document.querySelector(selector);
|
||||
const el = $(selector);
|
||||
if (el) el.click();
|
||||
}
|
||||
|
||||
|
@ -25,6 +34,7 @@ const keyCodes = {
|
|||
82() { click('.js-rand'); }, // R - go to random image
|
||||
83() { click('.js-source-link'); }, // S - go to image source
|
||||
76() { click('.js-tag-sauce-toggle'); }, // L - edit tags
|
||||
79() { openFullView() }, // O - open original
|
||||
70() { // F - favourite image
|
||||
getHover() ? click(`a.interaction--fave[data-image-id="${getHover()}"]`)
|
||||
: click('.block__header a.interaction--fave');
|
||||
|
|
Loading…
Reference in a new issue