fix: #10256, allow quote tooltip on mobile

isekai-main
Barış Soner Uşaklı 3 years ago
parent 08f2a05053
commit fb3f4f9a13

@ -466,23 +466,24 @@ define('forum/topic/postTools', [
warning.modal();
}
const selectionChangeFn = utils.debounce(selectionChange, 100);
function handleSelectionTooltip() {
hooks.onPage('action:posts.loaded', delayedTooltip);
$(document).off('mouseup', delayedTooltip).on('mouseup', delayedTooltip);
$(document).off('selectionchange', selectionChange).on('selectionchange', selectionChange);
$(document).off('selectionchange', selectionChangeFn).on('selectionchange', selectionChangeFn);
}
let selectionEmpty = true;
function selectionChange() {
selectionEmpty = window.getSelection().toString() === '';
const selectionEmpty = window.getSelection().toString() === '';
if (selectionEmpty) {
$('[component="selection/tooltip"]').addClass('hidden');
} else {
delayedTooltip();
}
}
function delayedTooltip() {
setTimeout(async function () {
async function delayedTooltip() {
let selectionTooltip = $('[component="selection/tooltip"]');
selectionTooltip.addClass('hidden');
if (selectionTooltip.attr('data-ajaxify') === '1') {
@ -491,7 +492,7 @@ define('forum/topic/postTools', [
}
const selection = window.getSelection();
if (selection.focusNode && selection.type === 'Range' && ajaxify.data.template.topic && !selectionEmpty) {
if (selection.focusNode && selection.type === 'Range' && ajaxify.data.template.topic) {
const focusNode = $(selection.focusNode);
const anchorNode = $(selection.anchorNode);
const firstPid = anchorNode.parents('[data-pid]').attr('data-pid');
@ -518,7 +519,7 @@ define('forum/topic/postTools', [
selectionTooltip.removeClass('hidden');
$(window).one('action:ajaxify.start', function () {
selectionTooltip.attr('data-ajaxify', 1).addClass('hidden');
$(document).off('selectionchange', selectionChange);
$(document).off('selectionchange', selectionChangeFn);
});
const tooltipWidth = selectionTooltip.outerWidth(true);
selectionTooltip.css({
@ -526,7 +527,6 @@ define('forum/topic/postTools', [
left: tooltipWidth > lastRect.width ? lastRect.left : lastRect.left + lastRect.width - tooltipWidth,
});
}
}, 0);
}
return PostTools;

Loading…
Cancel
Save