DEV: Fix ember/jquery-ember-run lint (#29113)

See: https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/jquery-ember-run.md
This commit is contained in:
Jarek Radosz 2024-10-08 18:26:28 +02:00 committed by GitHub
parent 520f71b8f8
commit 60e2b72b7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,4 @@
import { bind } from "@ember/runloop";
import $ from "jquery";
const CLICK_ATTRIBUTE_NAME = "_discourse_click_widget";
@ -206,104 +207,143 @@ WidgetClickHook.setupDocumentCallback = function () {
return;
}
$(document).on("mouseover.discourse-widget", (e) => {
nodeCallback(e.target, MOUSE_OVER_ATTRIBUTE_NAME, (w) => w.mouseOver(e), {
rerender: false,
});
});
$(document).on(
"mouseover.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, MOUSE_OVER_ATTRIBUTE_NAME, (w) => w.mouseOver(e), {
rerender: false,
});
})
);
$(document).on("mouseout.discourse-widget", (e) => {
nodeCallback(e.target, MOUSE_OUT_ATTRIBUTE_NAME, (w) => w.mouseOut(e), {
rerender: false,
});
});
$(document).on(
"mouseout.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, MOUSE_OUT_ATTRIBUTE_NAME, (w) => w.mouseOut(e), {
rerender: false,
});
})
);
$(document).on("dblclick.discourse-widget", (e) => {
nodeCallback(e.target, DOUBLE_CLICK_ATTRIBUTE_NAME, (w) =>
w.doubleClick(e)
);
});
$(document).on(
"dblclick.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, DOUBLE_CLICK_ATTRIBUTE_NAME, (w) =>
w.doubleClick(e)
);
})
);
$(document).on("click.discourse-widget", (e) => {
nodeCallback(e.target, CLICK_ATTRIBUTE_NAME, (w) => w.click(e));
$(document).on(
"click.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, CLICK_ATTRIBUTE_NAME, (w) => w.click(e));
let node = e.target;
const $outside = $("[data-click-outside]");
$outside.each((i, outNode) => {
if (
outNode.contains(node) ||
(outNode === node && outNode.style.position === "absolute")
) {
return;
}
let node = e.target;
const $outside = $("[data-click-outside]");
$outside.each((i, outNode) => {
if (
outNode.contains(node) ||
(outNode === node && outNode.style.position === "absolute")
) {
return;
}
const widget2 = outNode[CLICK_OUTSIDE_ATTRIBUTE_NAME];
if (widget2) {
widget2.clickOutside(e);
}
});
});
const widget2 = outNode[CLICK_OUTSIDE_ATTRIBUTE_NAME];
if (widget2) {
widget2.clickOutside(e);
}
});
})
);
$(document).on("mousedown.discourse-widget", (e) => {
let node = e.target;
const $outside = $("[data-mouse-down-outside]");
$outside.each((i, outNode) => {
if (outNode.contains(node)) {
return;
}
const widget2 = outNode[MOUSE_DOWN_OUTSIDE_ATTRIBUTE_NAME];
if (widget2) {
widget2.mouseDownOutside(e);
}
});
});
$(document).on(
"mousedown.discourse-widget",
bind(this, (e) => {
let node = e.target;
const $outside = $("[data-mouse-down-outside]");
$outside.each((i, outNode) => {
if (outNode.contains(node)) {
return;
}
const widget2 = outNode[MOUSE_DOWN_OUTSIDE_ATTRIBUTE_NAME];
if (widget2) {
widget2.mouseDownOutside(e);
}
});
})
);
$(document).on("keyup.discourse-widget", (e) => {
nodeCallback(e.target, KEY_UP_ATTRIBUTE_NAME, (w) => w.keyUp(e));
});
$(document).on(
"keyup.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, KEY_UP_ATTRIBUTE_NAME, (w) => w.keyUp(e));
})
);
$(document).on("keydown.discourse-widget", (e) => {
nodeCallback(e.target, KEY_DOWN_ATTRIBUTE_NAME, (w) => w.keyDown(e));
});
$(document).on(
"keydown.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, KEY_DOWN_ATTRIBUTE_NAME, (w) => w.keyDown(e));
})
);
$(document).on("input.discourse-widget", (e) => {
nodeCallback(e.target, INPUT_ATTRIBUTE_NAME, (w) => w.input(e), {
rerender: false,
});
});
$(document).on(
"input.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, INPUT_ATTRIBUTE_NAME, (w) => w.input(e), {
rerender: false,
});
})
);
$(document).on("change.discourse-widget", (e) => {
nodeCallback(e.target, CHANGE_ATTRIBUTE_NAME, (w) => w.change(e), {
rerender: false,
});
});
$(document).on(
"change.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, CHANGE_ATTRIBUTE_NAME, (w) => w.change(e), {
rerender: false,
});
})
);
$(document).on("touchend.discourse-widget", (e) => {
nodeCallback(e.target, TOUCH_END_ATTRIBUTE_NAME, (w) => w.touchEnd(e), {
rerender: false,
});
});
$(document).on(
"touchend.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, TOUCH_END_ATTRIBUTE_NAME, (w) => w.touchEnd(e), {
rerender: false,
});
})
);
$(document).on("mousedown.discourse-widget", (e) => {
nodeCallback(
e.target,
MOUSE_DOWN_ATTRIBUTE_NAME,
(w) => {
w.mouseDown(e);
},
{ rerender: false }
);
});
$(document).on(
"mousedown.discourse-widget",
bind(this, (e) => {
nodeCallback(
e.target,
MOUSE_DOWN_ATTRIBUTE_NAME,
(w) => {
w.mouseDown(e);
},
{ rerender: false }
);
})
);
$(document).on("mouseup.discourse-widget", (e) => {
nodeCallback(e.target, MOUSE_UP_ATTRIBUTE_NAME, (w) => w.mouseUp(e), {
rerender: false,
});
});
$(document).on(
"mouseup.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, MOUSE_UP_ATTRIBUTE_NAME, (w) => w.mouseUp(e), {
rerender: false,
});
})
);
$(document).on("mousemove.discourse-widget", (e) => {
nodeCallback(e.target, MOUSE_MOVE_ATTRIBUTE_NAME, (w) => w.mouseMove(e));
});
$(document).on(
"mousemove.discourse-widget",
bind(this, (e) => {
nodeCallback(e.target, MOUSE_MOVE_ATTRIBUTE_NAME, (w) => w.mouseMove(e));
})
);
_watchingDocument = true;
};