zjquery: Refactor generic_event to wrap on.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-07-21 00:44:41 -07:00
committed by Tim Abbott
parent 9102c5a519
commit ded548ad16
4 changed files with 13 additions and 1 deletions

View File

@@ -700,6 +700,7 @@ run_test("initialize", () => {
activity.client_is_active = false;
$(window).off("focus");
activity.initialize();
$(window).trigger("focus");
clear();
@@ -719,6 +720,7 @@ run_test("initialize", () => {
};
global.setInterval = (func) => func();
$(window).off("focus");
activity.initialize();
assert($("#zephyr-mirror-error").hasClass("show"));

View File

@@ -748,6 +748,7 @@ run_test("send_message", () => {
$("#compose-send-status").show();
$("#compose-send-button").attr("disabled", "disabled");
$("#sending-indicator").show();
$("#compose-textarea").off("select");
$("#compose-textarea").select(noop);
echo_error_msg_checked = false;
echo.try_deliver_locally = function () {
@@ -822,6 +823,7 @@ run_test("finish", () => {
$("#compose-send-button").prop("disabled", false);
$("#compose-send-button").focus();
$("#sending-indicator").hide();
$("#compose-textarea").off("select");
$("#compose-textarea").select(noop);
$("#compose-textarea").val("");
const res = compose.finish();

View File

@@ -1097,6 +1097,14 @@ run_test("initialize", () => {
return true;
};
$("#enter_sends").click();
$("#stream_message_recipient_stream").off("focus");
$("#stream_message_recipient_topic").off("focus");
$("#private_message_recipient").off("focus");
$("form#send_message_form").off("keydown");
$("form#send_message_form").off("keyup");
$("#enter_sends").off("click");
$("#private_message_recipient").off("blur");
ct.initialize();
// Now let's make sure that all the stub functions have been called

View File

@@ -130,7 +130,7 @@ exports.make_event_store = (selector) => {
generic_event($element, event_name, arg) {
if (typeof arg === "function") {
on_functions.set(event_name, arg);
self.on(event_name, arg);
} else {
self.trigger($element, event_name, arg);
}