From ec36f3cd6da7963946606c927465bb6a3813eb5c Mon Sep 17 00:00:00 2001 From: KrinklesMontgomery Date: Tue, 7 Jul 2020 18:36:17 -0700 Subject: [PATCH 1/4] Locks chat mainwindow when context menu is opened --- assets/chat/js/chat.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index 6a62f724..79b2f374 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -598,7 +598,8 @@ class Chat { if ($(e.target).parent().data("username").toLowerCase() !== this.user.username.toLowerCase()) { e.preventDefault(); this.contextMenu = new ChatContextMenu(this, e); - this.contextMenu.show(e) + this.contextMenu.show(e); + this.mainwindow.lock(); } }) @@ -606,6 +607,9 @@ class Chat { if (this.contextMenu) { if (!$(e.target).is(this.contextMenu.ui)) { this.contextMenu.hide() + if (this.mainwindow.locked()) { + this.mainwindow.unlock(); + } } } }) From 45cff2892b576b58c517f6dc400e1c8acd943b8b Mon Sep 17 00:00:00 2001 From: KrinklesMontgomery Date: Wed, 8 Jul 2020 12:03:59 -0700 Subject: [PATCH 2/4] Clears selected text on contextmenu event for a.user --- assets/chat/js/chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index 79b2f374..d910dcb0 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -593,10 +593,10 @@ class Chat { } }) - // Context menu this.output.on("contextmenu", "a.user", e => { if ($(e.target).parent().data("username").toLowerCase() !== this.user.username.toLowerCase()) { e.preventDefault(); + window.getSelection().removeAllRanges(); this.contextMenu = new ChatContextMenu(this, e); this.contextMenu.show(e); this.mainwindow.lock(); From 4166a471f65e29dd036b2726a90c2f2f030f7c5e Mon Sep 17 00:00:00 2001 From: KrinklesMontgomery Date: Wed, 8 Jul 2020 13:29:29 -0700 Subject: [PATCH 3/4] Hides opened context menu and unlocks main window on scroll --- assets/chat/js/scroll.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/assets/chat/js/scroll.js b/assets/chat/js/scroll.js index 95634ebe..04d70362 100644 --- a/assets/chat/js/scroll.js +++ b/assets/chat/js/scroll.js @@ -12,9 +12,16 @@ class ChatScrollPlugin { const $el = $(e); if ($el.find(".chat-scroll-notify").length > 0) { - $el.on("update", () => + $el.on("update", () => { + if (chat.contextMenu) { + chat.contextMenu.hide(); + if (chat.mainwindow.locked()) { + chat.mainwindow.unlock(); + } + } $el.toggleClass("chat-unpinned", !this.isPinned()) - ); //debounce + }); + //debounce $el.on("mousedown", ".chat-scroll-notify", () => false); $el.on("mouseup", ".chat-scroll-notify", () => { this.updateAndPin(true); From c762b34a982a801c382f14049cd4f7e340efd66d Mon Sep 17 00:00:00 2001 From: KrinklesMontgomery Date: Wed, 8 Jul 2020 13:32:53 -0700 Subject: [PATCH 4/4] rolls back comments --- assets/chat/js/chat.js | 1 + assets/chat/js/scroll.js | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index d910dcb0..fe250899 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -593,6 +593,7 @@ class Chat { } }) + // Context menu this.output.on("contextmenu", "a.user", e => { if ($(e.target).parent().data("username").toLowerCase() !== this.user.username.toLowerCase()) { e.preventDefault(); diff --git a/assets/chat/js/scroll.js b/assets/chat/js/scroll.js index 04d70362..1cba6a70 100644 --- a/assets/chat/js/scroll.js +++ b/assets/chat/js/scroll.js @@ -20,8 +20,7 @@ class ChatScrollPlugin { } } $el.toggleClass("chat-unpinned", !this.isPinned()) - }); - //debounce + }); //debounce $el.on("mousedown", ".chat-scroll-notify", () => false); $el.on("mouseup", ".chat-scroll-notify", () => { this.updateAndPin(true);