mirror of
https://github.com/zulip/zulip.git
synced 2025-11-19 05:58:25 +00:00
eslint: Fix unicorn/prefer-add-event-listener.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
2694f5caed
commit
e0b1daa96d
@@ -264,6 +264,12 @@ run_test("set_tab", () => {
|
|||||||
assert.equal(val, 0);
|
assert.equal(val, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let hash_change_handler;
|
||||||
|
window.addEventListener = (event, handler) => {
|
||||||
|
assert.equal(event, "hashchange");
|
||||||
|
hash_change_handler = handler;
|
||||||
|
};
|
||||||
|
|
||||||
helpers.set_tab("upgrade");
|
helpers.set_tab("upgrade");
|
||||||
assert.equal(state.show_tab_billing, 1);
|
assert.equal(state.show_tab_billing, 1);
|
||||||
assert.equal(state.scrollTop, 1);
|
assert.equal(state.scrollTop, 1);
|
||||||
@@ -272,7 +278,6 @@ run_test("set_tab", () => {
|
|||||||
click_handler.call({hash: "#payment-method"});
|
click_handler.call({hash: "#payment-method"});
|
||||||
assert.equal(location.hash, "#payment-method");
|
assert.equal(location.hash, "#payment-method");
|
||||||
|
|
||||||
const hash_change_handler = window.onhashchange;
|
|
||||||
hash_change_handler();
|
hash_change_handler();
|
||||||
assert.equal(state.show_tab_payment_method, 1);
|
assert.equal(state.show_tab_payment_method, 1);
|
||||||
assert.equal(state.scrollTop, 2);
|
assert.equal(state.scrollTop, 2);
|
||||||
|
|||||||
@@ -109,6 +109,13 @@ exports.show_license_section = function (license) {
|
|||||||
$(input_id).prop("disabled", false);
|
$(input_id).prop("disabled", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let current_page;
|
||||||
|
|
||||||
|
function handle_hashchange() {
|
||||||
|
$("#" + current_page + '-tabs.nav a[href="' + location.hash + '"]').tab("show");
|
||||||
|
$("html").scrollTop(0);
|
||||||
|
}
|
||||||
|
|
||||||
exports.set_tab = function (page) {
|
exports.set_tab = function (page) {
|
||||||
const hash = location.hash;
|
const hash = location.hash;
|
||||||
if (hash) {
|
if (hash) {
|
||||||
@@ -120,10 +127,8 @@ exports.set_tab = function (page) {
|
|||||||
location.hash = this.hash;
|
location.hash = this.hash;
|
||||||
});
|
});
|
||||||
|
|
||||||
window.onhashchange = function () {
|
current_page = page;
|
||||||
$("#" + page + '-tabs.nav a[href="' + location.hash + '"]').tab("show");
|
window.addEventListener("hashchange", handle_hashchange);
|
||||||
$("html").scrollTop(0);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.is_valid_input = function (elem) {
|
exports.is_valid_input = function (elem) {
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ export async function select(name) {
|
|||||||
}
|
}
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
const sheet = new Image();
|
const sheet = new Image();
|
||||||
sheet.onload = resolve;
|
sheet.addEventListener("load", resolve);
|
||||||
sheet.onerror = reject;
|
sheet.addEventListener("error", reject);
|
||||||
sheet.src = new_emojiset.sheet;
|
sheet.src = new_emojiset.sheet;
|
||||||
});
|
});
|
||||||
if (current_emojiset) {
|
if (current_emojiset) {
|
||||||
|
|||||||
@@ -179,8 +179,8 @@ const funcs = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof meta.onresize === "function") {
|
if (typeof meta.resize_handler === "function") {
|
||||||
meta.onresize(canvas);
|
meta.resize_handler(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parent = {
|
const parent = {
|
||||||
@@ -267,7 +267,7 @@ class LightboxCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resize(callback) {
|
resize(callback) {
|
||||||
this.meta.onresize = callback;
|
this.meta.resize_handler = callback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user