mirror of
https://github.com/thelounge/thelounge
synced 2024-11-15 08:47:16 +00:00
Merge pull request #2242 from thelounge/xpaw/fix-master
Keep input reference as jquery object
This commit is contained in:
commit
0858938eea
1 changed files with 9 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
||||||
const $ = require("jquery");
|
const $ = require("jquery");
|
||||||
const Mousetrap = require("mousetrap");
|
const Mousetrap = require("mousetrap");
|
||||||
const wrapCursor = require("undate").wrapCursor;
|
const wrapCursor = require("undate").wrapCursor;
|
||||||
const input = $("#input").get(0);
|
const input = $("#input");
|
||||||
const sidebar = $("#sidebar");
|
const sidebar = $("#sidebar");
|
||||||
const windows = $("#windows");
|
const windows = $("#windows");
|
||||||
const contextMenuContainer = $("#context-menu-container");
|
const contextMenuContainer = $("#context-menu-container");
|
||||||
|
@ -107,8 +107,10 @@ const colorsHotkeys = {
|
||||||
|
|
||||||
for (const hotkey in colorsHotkeys) {
|
for (const hotkey in colorsHotkeys) {
|
||||||
Mousetrap.bind("mod+" + hotkey, function(e) {
|
Mousetrap.bind("mod+" + hotkey, function(e) {
|
||||||
|
const inputElement = input.get(0);
|
||||||
|
|
||||||
// Do not handle modifier hotkeys if input is not focused
|
// Do not handle modifier hotkeys if input is not focused
|
||||||
if (document.activeElement !== input) {
|
if (document.activeElement !== inputElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +118,11 @@ for (const hotkey in colorsHotkeys) {
|
||||||
|
|
||||||
const modifier = colorsHotkeys[e.key];
|
const modifier = colorsHotkeys[e.key];
|
||||||
|
|
||||||
wrapCursor(input, modifier, input.selectionStart === input.selectionEnd ? "" : modifier);
|
wrapCursor(
|
||||||
|
inputElement,
|
||||||
|
modifier,
|
||||||
|
inputElement.selectionStart === inputElement.selectionEnd ? "" : modifier
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue