mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-25 13:01:31 +01:00
Merge pull request #467 from MareStare/fix/burger-button-eating-click
Get rid of `stopPropagation` on `click` events to make autocomplete popup disappear
This commit is contained in:
commit
fa70d20943
2 changed files with 31 additions and 20 deletions
|
@ -53,19 +53,24 @@ export function setupBurgerMenu() {
|
||||||
|
|
||||||
copyUserLinksTo(burger);
|
copyUserLinksTo(burger);
|
||||||
|
|
||||||
toggle.addEventListener('click', event => {
|
document.addEventListener('click', event => {
|
||||||
event.stopPropagation();
|
if (!(event.target instanceof Node)) {
|
||||||
event.preventDefault();
|
return;
|
||||||
|
|
||||||
if (content.classList.contains('open')) {
|
|
||||||
close(burger, content, body, root);
|
|
||||||
} else {
|
|
||||||
open(burger, content, body, root);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
content.addEventListener('click', () => {
|
if (toggle.contains(event.target)) {
|
||||||
if (content.classList.contains('open')) {
|
event.preventDefault();
|
||||||
|
|
||||||
|
if (content.classList.contains('open')) {
|
||||||
|
close(burger, content, body, root);
|
||||||
|
} else {
|
||||||
|
open(burger, content, body, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (content.contains(event.target) && content.classList.contains('open')) {
|
||||||
close(burger, content, body, root);
|
close(burger, content, body, root);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,13 @@ const endpoints = {
|
||||||
|
|
||||||
const spoilerDownvoteMsg = 'Neigh! - Remove spoilered tags from your filters to downvote from thumbnails';
|
const spoilerDownvoteMsg = 'Neigh! - Remove spoilered tags from your filters to downvote from thumbnails';
|
||||||
|
|
||||||
/* Quick helper function to less verbosely iterate a QSA */
|
/**
|
||||||
|
* Quick helper function to less verbosely iterate a QSA
|
||||||
|
*
|
||||||
|
* @param {string} id
|
||||||
|
* @param {string} selector
|
||||||
|
* @param {(node: HTMLElement) => void} cb
|
||||||
|
*/
|
||||||
function onImage(id, selector, cb) {
|
function onImage(id, selector, cb) {
|
||||||
[].forEach.call(document.querySelectorAll(`${selector}[data-image-id="${id}"]`), cb);
|
[].forEach.call(document.querySelectorAll(`${selector}[data-image-id="${id}"]`), cb);
|
||||||
}
|
}
|
||||||
|
@ -145,14 +151,6 @@ function loadInteractions() {
|
||||||
|
|
||||||
icon.setAttribute('title', spoilerDownvoteMsg);
|
icon.setAttribute('title', spoilerDownvoteMsg);
|
||||||
a.classList.add('disabled');
|
a.classList.add('disabled');
|
||||||
a.addEventListener(
|
|
||||||
'click',
|
|
||||||
event => {
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -163,6 +161,10 @@ const targets = {
|
||||||
interact('vote', imageId, 'DELETE').then(() => resetVoted(imageId));
|
interact('vote', imageId, 'DELETE').then(() => resetVoted(imageId));
|
||||||
},
|
},
|
||||||
'.interaction--downvote.active'(imageId) {
|
'.interaction--downvote.active'(imageId) {
|
||||||
|
if (window.booru.imagesWithDownvotingDisabled.includes(imageId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
interact('vote', imageId, 'DELETE').then(() => resetVoted(imageId));
|
interact('vote', imageId, 'DELETE').then(() => resetVoted(imageId));
|
||||||
},
|
},
|
||||||
'.interaction--fave.active'(imageId) {
|
'.interaction--fave.active'(imageId) {
|
||||||
|
@ -180,6 +182,10 @@ const targets = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'.interaction--downvote:not(.active)'(imageId) {
|
'.interaction--downvote:not(.active)'(imageId) {
|
||||||
|
if (window.booru.imagesWithDownvotingDisabled.includes(imageId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
interact('vote', imageId, 'POST', { up: false }).then(() => {
|
interact('vote', imageId, 'POST', { up: false }).then(() => {
|
||||||
resetVoted(imageId);
|
resetVoted(imageId);
|
||||||
showDownvoted(imageId);
|
showDownvoted(imageId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue