mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +01:00
fix: copy dropdown closing on copy ip/text/link
This commit is contained in:
@@ -225,18 +225,23 @@ define('forum/chats', [
|
|||||||
|
|
||||||
Chats.addIPHandler = function (container) {
|
Chats.addIPHandler = function (container) {
|
||||||
container.off('click', '.chat-ip-button')
|
container.off('click', '.chat-ip-button')
|
||||||
.on('click', '.chat-ip-button', async function () {
|
.on('click', '.chat-ip-button', async function (ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
const ipEl = $(this);
|
const ipEl = $(this);
|
||||||
|
const ipCopyText = ipEl.find('.copy .copy-ip-text');
|
||||||
let ip = ipEl.attr('data-ip');
|
let ip = ipEl.attr('data-ip');
|
||||||
if (ip) {
|
if (ip) {
|
||||||
navigator.clipboard.writeText(ip);
|
navigator.clipboard.writeText(ip);
|
||||||
ipEl.translateText('[[global:copied]]');
|
ipCopyText.translateText('[[global:copied]]');
|
||||||
setTimeout(() => ipEl.text(ip), 2000);
|
setTimeout(() => ipCopyText.text(ip), 2000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const mid = ipEl.parents('[data-mid]').attr('data-mid');
|
const mid = ipEl.parents('[data-mid]').attr('data-mid');
|
||||||
({ ip } = await api.get(`/chats/${ajaxify.data.roomId}/messages/${mid}/ip`));
|
({ ip } = await api.get(`/chats/${ajaxify.data.roomId}/messages/${mid}/ip`));
|
||||||
ipEl.text(ip).attr('data-ip', ip);
|
ipEl.attr('data-ip', ip);
|
||||||
|
ipEl.find('.show').addClass('hidden');
|
||||||
|
ipEl.find('.copy').removeClass('hidden');
|
||||||
|
ipCopyText.text(ip);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -248,7 +253,8 @@ define('forum/chats', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
container.off('click', '[data-action="copy-link"]')
|
container.off('click', '[data-action="copy-link"]')
|
||||||
.on('click', '[data-action="copy-link"]', function () {
|
.on('click', '[data-action="copy-link"]', function (ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
const copyEl = $(this);
|
const copyEl = $(this);
|
||||||
const mid = copyEl.attr('data-mid');
|
const mid = copyEl.attr('data-mid');
|
||||||
if (mid) {
|
if (mid) {
|
||||||
@@ -257,7 +263,8 @@ define('forum/chats', [
|
|||||||
});
|
});
|
||||||
|
|
||||||
container.off('click', '[data-action="copy-text"]')
|
container.off('click', '[data-action="copy-text"]')
|
||||||
.on('click', '[data-action="copy-text"]', function () {
|
.on('click', '[data-action="copy-text"]', function (ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
const copyEl = $(this);
|
const copyEl = $(this);
|
||||||
const messageEl = copyEl.parents('[data-mid]');
|
const messageEl = copyEl.parents('[data-mid]');
|
||||||
if (messageEl.length) {
|
if (messageEl.length) {
|
||||||
|
|||||||
@@ -54,7 +54,10 @@
|
|||||||
|
|
||||||
{{{ if isAdminOrGlobalMod }}}
|
{{{ if isAdminOrGlobalMod }}}
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="dropdown-item rounded-1 chat-ip-button" role="menuitem"><span class="d-inline-flex align-items-center gap-2"><i class="fa fa-fw fa-info-circle text-muted"></i> [[modules:chat.show-ip]]</span></a>
|
<a href="#" class="dropdown-item rounded-1 chat-ip-button" role="menuitem">
|
||||||
|
<span class="d-inline-flex align-items-center gap-2 show"><i class="fa fa-fw fa-info-circle text-muted"></i> [[modules:chat.show-ip]]</span>
|
||||||
|
<span class="d-inline-flex align-items-center gap-2 copy hidden"><i class="fa fa-fw fa-copy text-muted"></i> <span class="copy-ip-text"></span></span>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{{ end }}}
|
{{{ end }}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user