stub-html-' + data.name;
});
diff --git a/frontend_tests/node_tests/stream_sort.js b/frontend_tests/node_tests/stream_sort.js
index 24380bab7d..696db98d2a 100644
--- a/frontend_tests/node_tests/stream_sort.js
+++ b/frontend_tests/node_tests/stream_sort.js
@@ -50,10 +50,8 @@ function sort_groups(query) {
return stream_sort.sort_groups(streams, query);
}
-with_overrides(function (override) {
- override('stream_data.is_active', function (sub) {
- return sub.name !== "pneumonia";
- });
+with_overrides((override) => {
+ override('stream_data.is_active', (sub) => sub.name !== "pneumonia");
// Test sorting into categories/alphabetized
let sorted = sort_groups("");
diff --git a/frontend_tests/node_tests/timerender.js b/frontend_tests/node_tests/timerender.js
index a1a3be74be..0f33ad07a6 100644
--- a/frontend_tests/node_tests/timerender.js
+++ b/frontend_tests/node_tests/timerender.js
@@ -225,49 +225,49 @@ run_test('last_seen_status_from_date', () => {
assert.equal(actual_status, expected_status);
}
- assert_same(function (d) { return d.addSeconds(-20); },
+ assert_same((d) => d.addSeconds(-20),
i18n.t("Just now"));
- assert_same(function (d) { return d.addMinutes(-1); },
+ assert_same((d) => d.addMinutes(-1),
i18n.t("Just now"));
- assert_same(function (d) { return d.addMinutes(-2); },
+ assert_same((d) => d.addMinutes(-2),
i18n.t("Just now"));
- assert_same(function (d) { return d.addMinutes(-30); },
+ assert_same((d) => d.addMinutes(-30),
i18n.t("30 minutes ago"));
- assert_same(function (d) { return d.addHours(-1); },
+ assert_same((d) => d.addHours(-1),
i18n.t("An hour ago"));
- assert_same(function (d) { return d.addHours(-2); },
+ assert_same((d) => d.addHours(-2),
i18n.t("2 hours ago"));
- assert_same(function (d) { return d.addHours(-20); },
+ assert_same((d) => d.addHours(-20),
i18n.t("20 hours ago"));
- assert_same(function (d) { return d.addDays(-1); },
+ assert_same((d) => d.addDays(-1),
i18n.t("Yesterday"));
- assert_same(function (d) { return d.addDays(-2); },
+ assert_same((d) => d.addDays(-2),
i18n.t("2 days ago"));
- assert_same(function (d) { return d.addDays(-61); },
+ assert_same((d) => d.addDays(-61),
i18n.t("61 days ago"));
- assert_same(function (d) { return d.addDays(-300); },
+ assert_same((d) => d.addDays(-300),
i18n.t("May 06,\xa02015"));
- assert_same(function (d) { return d.addDays(-366); },
+ assert_same((d) => d.addDays(-366),
i18n.t("Mar 01,\xa02015"));
- assert_same(function (d) { return d.addYears(-3); },
+ assert_same((d) => d.addYears(-3),
i18n.t("Mar 01,\xa02013"));
// Set base_dateto to May 1 2016 12.30 AM (months are zero based)
base_date = new XDate(2016, 4, 1, 0, 30);
- assert_same(function (d) { return d.addDays(-91); },
+ assert_same((d) => d.addDays(-91),
i18n.t("Jan\xa031"));
});
diff --git a/frontend_tests/node_tests/typeahead_helper.js b/frontend_tests/node_tests/typeahead_helper.js
index 079017f768..f8efdd8f46 100644
--- a/frontend_tests/node_tests/typeahead_helper.js
+++ b/frontend_tests/node_tests/typeahead_helper.js
@@ -1,7 +1,5 @@
set_global('page_params', {realm_is_zephyr_mirror_realm: false});
-set_global('md5', function (s) {
- return 'md5-' + s;
-});
+set_global('md5', (s) => 'md5-' + s);
const settings_config = zrequire('settings_config');
page_params.realm_email_address_visibility =
@@ -504,7 +502,7 @@ run_test('render_person when emails hidden', () => {
// Test render_person with regular person, under hidden email visibility case
page_params.is_admin = false;
let rendered = false;
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, b_user_1.full_name);
assert.equal(args.secondary, undefined);
@@ -519,7 +517,7 @@ run_test('render_person', () => {
page_params.is_admin = true;
// Test render_person with regular person
let rendered = false;
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, a_user.full_name);
assert.equal(args.secondary, a_user.email);
@@ -539,7 +537,7 @@ run_test('render_person', () => {
special_item_text: "special_text",
};
rendered = false;
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, special_person.special_item_text);
rendered = true;
@@ -551,7 +549,7 @@ run_test('render_person', () => {
run_test('clear_rendered_person', () => {
let rendered = false;
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, b_bot.full_name);
assert.equal(args.secondary, b_bot.email);
@@ -583,7 +581,7 @@ run_test('render_stream', () => {
stream_id: 42,
name: 'Short Description',
};
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, stream.name);
assert.equal(args.secondary, stream.description);
@@ -600,7 +598,7 @@ run_test('render_stream', () => {
stream_id: 43,
name: 'Long Description',
};
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, stream.name);
const short_desc = stream.description.substring(0, 35);
@@ -619,7 +617,7 @@ run_test('clear_rendered_stream', () => {
stream_id: 44,
name: 'Stream To Be Cleared',
};
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.equal(args.primary, stream.name);
assert.equal(args.secondary, stream.description);
@@ -650,7 +648,7 @@ run_test('render_emoji', () => {
realm_emoji: 'TBD',
}));
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.deepEqual(args, {
primary: 'thumbs up',
@@ -672,7 +670,7 @@ run_test('render_emoji', () => {
emoji_url: 'TBD',
};
- global.stub_templates(function (template_name, args) {
+ global.stub_templates((template_name, args) => {
assert.equal(template_name, 'typeahead_list_item');
assert.deepEqual(args, {
primary: 'realm emoji',
diff --git a/frontend_tests/node_tests/typing_status.js b/frontend_tests/node_tests/typing_status.js
index 86d4aaca1d..7d852b40bf 100644
--- a/frontend_tests/node_tests/typing_status.js
+++ b/frontend_tests/node_tests/typing_status.js
@@ -268,7 +268,7 @@ run_test('basics', () => {
// stub functions to see how may time they are called
for (const method of Object.keys(call_count)) {
- typing_status.__Rewire__(method, function () {
+ typing_status.__Rewire__(method, () => {
call_count[method] += 1;
});
}
diff --git a/frontend_tests/node_tests/user_pill.js b/frontend_tests/node_tests/user_pill.js
index 45529154bb..0b3888033c 100644
--- a/frontend_tests/node_tests/user_pill.js
+++ b/frontend_tests/node_tests/user_pill.js
@@ -1,7 +1,5 @@
zrequire('people');
-set_global('md5', function (s) {
- return 'md5-' + s;
-});
+set_global('md5', (s) => 'md5-' + s);
zrequire('user_pill');
set_global('page_params', {
diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js
index f182fb80a1..56d7d78767 100644
--- a/frontend_tests/node_tests/util.js
+++ b/frontend_tests/node_tests/util.js
@@ -101,7 +101,7 @@ run_test('robust_uri_decode', () => {
assert.equal(util.robust_uri_decode('xxx%3Ayyy'), 'xxx:yyy');
assert.equal(util.robust_uri_decode('xxx%3'), 'xxx');
- set_global('decodeURIComponent', function () { throw 'foo'; });
+ set_global('decodeURIComponent', () => { throw 'foo'; });
try {
util.robust_uri_decode('%E0%A4%A');
} catch (e) {
@@ -151,7 +151,7 @@ run_test('random_int', () => {
const min = 0;
const max = 100;
- _.times(500, function () {
+ _.times(500, () => {
const val = util.random_int(min, max);
assert(min <= val);
assert(val <= max);
diff --git a/frontend_tests/node_tests/zjquery.js b/frontend_tests/node_tests/zjquery.js
index 965412f3ff..44a7528e20 100644
--- a/frontend_tests/node_tests/zjquery.js
+++ b/frontend_tests/node_tests/zjquery.js
@@ -117,11 +117,11 @@ run_test('clicks', () => {
const state = {};
function set_up_click_handlers() {
- $('#widget1').click(function () {
+ $('#widget1').click(() => {
state.clicked = true;
});
- $('.some-class').keydown(function () {
+ $('.some-class').keydown(() => {
state.keydown = true;
});
}
@@ -149,12 +149,12 @@ run_test('events', () => {
let value;
function initialize_handler() {
- $('#my-parent').on('click', '.button-red', function (e) {
+ $('#my-parent').on('click', '.button-red', (e) => {
value = 'red'; // just a dummy side effect
e.stopPropagation();
});
- $('#my-parent').on('click', '.button-blue', function (e) {
+ $('#my-parent').on('click', '.button-blue', (e) => {
value = 'blue';
e.stopPropagation();
});
diff --git a/frontend_tests/zjsunit/finder.js b/frontend_tests/zjsunit/finder.js
index 366d1d57dd..bc6b716a24 100644
--- a/frontend_tests/zjsunit/finder.js
+++ b/frontend_tests/zjsunit/finder.js
@@ -8,8 +8,8 @@ exports.find_files_to_run = function () {
if (process.argv[2]) {
oneFileFilter = process.argv
.slice(2)
- .filter(function (filename) {return (/[.]js$/).test(filename);})
- .map(function (filename) {return filename.replace(/\.js$/i, '');});
+ .filter((filename) => (/[.]js$/).test(filename))
+ .map((filename) => filename.replace(/\.js$/i, ''));
}
// tests_dir is where we find our specific unit tests (as opposed
@@ -17,24 +17,22 @@ exports.find_files_to_run = function () {
const tests_dir = __dirname.replace(/zjsunit/, 'node_tests');
let tests = fs.readdirSync(tests_dir)
- .filter(function (filename) {return !(/^\./i).test(filename);})
- .filter(function (filename) {return (/\.js$/i).test(filename);})
- .map(function (filename) {return filename.replace(/\.js$/i, '');});
+ .filter((filename) => !(/^\./i).test(filename))
+ .filter((filename) => (/\.js$/i).test(filename))
+ .map((filename) => filename.replace(/\.js$/i, ''));
if (oneFileFilter.length > 0) {
- tests = tests.filter(function (filename) {
- return oneFileFilter.includes(filename);
- });
+ tests = tests.filter((filename) => oneFileFilter.includes(filename));
testsDifference = _.difference(oneFileFilter, tests);
}
- testsDifference.forEach(function (filename) {
+ testsDifference.forEach((filename) => {
throw filename + ".js does not exist";
});
tests.sort();
- const files = tests.map(function (fn) {
+ const files = tests.map((fn) => {
const obj = {};
obj.name = fn;
obj.full_name = path.join(tests_dir, fn);
diff --git a/frontend_tests/zjsunit/index.js b/frontend_tests/zjsunit/index.js
index af4c85055f..239c365ef2 100644
--- a/frontend_tests/zjsunit/index.js
+++ b/frontend_tests/zjsunit/index.js
@@ -104,7 +104,7 @@ global.run_test = (label, f) => {
};
try {
- files.forEach(function (file) {
+ files.forEach((file) => {
set_global('location', {
hash: '#',
});
diff --git a/frontend_tests/zjsunit/namespace.js b/frontend_tests/zjsunit/namespace.js
index d0fa8900a1..1b5fa0012d 100644
--- a/frontend_tests/zjsunit/namespace.js
+++ b/frontend_tests/zjsunit/namespace.js
@@ -45,7 +45,7 @@ exports.clear_zulip_refs = function () {
};
exports.restore = function () {
- requires.forEach(function (fn) {
+ requires.forEach((fn) => {
delete require.cache[require.resolve(fn)];
});
Object.assign(global, old_globals);
@@ -57,14 +57,12 @@ exports.restore = function () {
};
exports.stub_out_jquery = function () {
- set_global('$', function () {
- return {
- on: function () {},
- trigger: function () {},
- hide: function () {},
- removeClass: function () {},
- };
- });
+ set_global('$', () => ({
+ on: function () {},
+ trigger: function () {},
+ hide: function () {},
+ removeClass: function () {},
+ }));
$.fn = {};
$.now = function () {};
};
@@ -86,7 +84,7 @@ exports.with_overrides = function (test_function) {
global[module][func_name] = f;
- clobber_callbacks.push(function () {
+ clobber_callbacks.push(() => {
// If you get a failure from this, you probably just
// need to have your test do its own overrides and
// not cherry-pick off of the prior test's setup.
diff --git a/frontend_tests/zjsunit/stub.js b/frontend_tests/zjsunit/stub.js
index 8ff449c895..03ac5dd97e 100644
--- a/frontend_tests/zjsunit/stub.js
+++ b/frontend_tests/zjsunit/stub.js
@@ -33,7 +33,7 @@ exports.with_stub = function (f) {
};
(function test_ourselves() {
- exports.with_stub(function (stub) {
+ exports.with_stub((stub) => {
stub.f('blue', 42);
const args = stub.get_args('color', 'n');
assert.equal(args.color, 'blue');
diff --git a/frontend_tests/zjsunit/zjquery.js b/frontend_tests/zjsunit/zjquery.js
index bb6beeb56d..4fa725e86c 100644
--- a/frontend_tests/zjsunit/zjquery.js
+++ b/frontend_tests/zjsunit/zjquery.js
@@ -305,7 +305,7 @@ exports.make_new_elem = function (selector, opts) {
},
removeClass: function (class_names) {
class_names = class_names.split(' ');
- class_names.forEach(function (class_name) {
+ class_names.forEach((class_name) => {
classes.delete(class_name);
});
return self;
diff --git a/static/js/activity.js b/static/js/activity.js
index 4aa06b763b..d12b4ce794 100644
--- a/static/js/activity.js
+++ b/static/js/activity.js
@@ -202,7 +202,7 @@ function mark_client_active() {
}
exports.initialize = function () {
- $("html").on("mousemove", function () {
+ $("html").on("mousemove", () => {
exports.new_user_input = true;
});
diff --git a/static/js/alert_words.js b/static/js/alert_words.js
index ec4e6459f6..8c0135b3ad 100644
--- a/static/js/alert_words.js
+++ b/static/js/alert_words.js
@@ -41,8 +41,8 @@ exports.process_message = function (message) {
const regex = new RegExp('(' + before_punctuation + ')' +
'(' + clean + ')' +
'(' + after_punctuation + ')', 'ig');
- message.content = message.content.replace(regex, function (match, before, word,
- after, offset, content) {
+ message.content = message.content.replace(regex, (match, before, word,
+ after, offset, content) => {
// Logic for ensuring that we don't muck up rendered HTML.
const pre_match = content.substring(0, offset);
// We want to find the position of the `<` and `>` only in the
diff --git a/static/js/alert_words_ui.js b/static/js/alert_words_ui.js
index 0f62276358..3df2466172 100644
--- a/static/js/alert_words_ui.js
+++ b/static/js/alert_words_ui.js
@@ -76,17 +76,17 @@ exports.set_up_alert_words = function () {
exports.render_alert_words_ui();
- $('#create_alert_word_form').on('click', '#create_alert_word_button', function () {
+ $('#create_alert_word_form').on('click', '#create_alert_word_button', () => {
const word = $('#create_alert_word_name').val();
add_alert_word(word);
});
- $('#alert_words_list').on('click', '.remove-alert-word', function (event) {
+ $('#alert_words_list').on('click', '.remove-alert-word', (event) => {
const word = $(event.currentTarget).parents('li').find('.value').text();
remove_alert_word(word);
});
- $('#create_alert_word_form').on('keypress', '#create_alert_word_name', function (event) {
+ $('#create_alert_word_form').on('keypress', '#create_alert_word_name', (event) => {
const key = event.which;
// Handle enter (13) as "add".
if (key === 13) {
@@ -97,7 +97,7 @@ exports.set_up_alert_words = function () {
}
});
- $('#alert-word-settings').on('click', '.close-alert-word-status', function (event) {
+ $('#alert-word-settings').on('click', '.close-alert-word-status', (event) => {
event.preventDefault();
const alert = $(event.currentTarget).parents('.alert');
alert.hide();
diff --git a/static/js/analytics/activity.js b/static/js/analytics/activity.js
index fbc3c4e8f2..f89e0043d5 100644
--- a/static/js/analytics/activity.js
+++ b/static/js/analytics/activity.js
@@ -1,4 +1,4 @@
-$(function () {
+$(() => {
$('a.envelope-link').click(function () {
common.copy_data_attribute_value($(this), "admin-emails");
});
diff --git a/static/js/analytics/support.js b/static/js/analytics/support.js
index 67437dee88..27b43a8ee2 100644
--- a/static/js/analytics/support.js
+++ b/static/js/analytics/support.js
@@ -1,4 +1,4 @@
-$(function () {
+$(() => {
$("body").on("click", ".scrub-realm-button", function (e) {
e.preventDefault();
const string_id = $(this).data("string-id");
diff --git a/static/js/archive.js b/static/js/archive.js
index 29fa1076ac..fac744ec79 100644
--- a/static/js/archive.js
+++ b/static/js/archive.js
@@ -117,14 +117,14 @@ function scroll_finish() {
scroll_timer = setTimeout(floating_recipient_bar.update, 100);
}
-$(function () {
+$(() => {
$.fn.safeOuterHeight = function (...args) {
return this.outerHeight(...args) || 0;
};
$.fn.safeOuterWidth = function (...args) {
return this.outerWidth(...args) || 0;
};
- $('.app').scroll(_.throttle(function () {
+ $('.app').scroll(_.throttle(() => {
scroll_finish();
}, 50));
exports.initialize();
diff --git a/static/js/attachments_ui.js b/static/js/attachments_ui.js
index 97ac3f6144..6f00820685 100644
--- a/static/js/attachments_ui.js
+++ b/static/js/attachments_ui.js
@@ -115,9 +115,7 @@ exports.update_attachments = function (event) {
return;
}
if (event.op === 'remove' || event.op === 'update') {
- attachments = attachments.filter(function (a) {
- return a.id !== event.attachment.id;
- });
+ attachments = attachments.filter((a) => a.id !== event.attachment.id);
}
if (event.op === 'add' || event.op === 'update') {
format_attachment_data([event.attachment]);
@@ -135,7 +133,7 @@ exports.set_up_attachments = function () {
const status = $('#delete-upload-status');
loading.make_indicator($('#attachments_loading_indicator'), {text: 'Loading...'});
- $('#uploaded_files_table').on('click', '.remove-attachment', function (e) {
+ $('#uploaded_files_table').on('click', '.remove-attachment', (e) => {
delete_attachments($(e.target).closest(".uploaded_file_row").attr('data-attachment-id'));
});
diff --git a/static/js/avatar.js b/static/js/avatar.js
index 9428533d78..327425fab4 100644
--- a/static/js/avatar.js
+++ b/static/js/avatar.js
@@ -52,7 +52,7 @@ exports.build_user_avatar_widget = function (upload_function) {
$("#user-avatar-source").hide();
}
- $("#user-avatar-upload-widget .settings-page-delete-button").on('click keydown', function (e) {
+ $("#user-avatar-upload-widget .settings-page-delete-button").on('click keydown', (e) => {
e.preventDefault();
e.stopPropagation();
channel.del({
diff --git a/static/js/billing/billing.js b/static/js/billing/billing.js
index cf3cbf8bdc..6fa780d1cd 100644
--- a/static/js/billing/billing.js
+++ b/static/js/billing/billing.js
@@ -11,7 +11,7 @@ exports.initialize = function () {
},
});
- $('#update-card-button').on('click', function (e) {
+ $('#update-card-button').on('click', (e) => {
const email = $("#payment-method").data("email");
card_change_handler.open({
name: 'Zulip',
@@ -25,7 +25,7 @@ exports.initialize = function () {
e.preventDefault();
});
- $("#change-plan-status").on('click', function (e) {
+ $("#change-plan-status").on('click', (e) => {
helpers.create_ajax_request("/json/billing/plan/change", "planchange", undefined, ["status"]);
e.preventDefault();
});
@@ -33,6 +33,6 @@ exports.initialize = function () {
window.billing = exports;
-$(function () {
+$(() => {
exports.initialize();
});
diff --git a/static/js/billing/helpers.js b/static/js/billing/helpers.js
index 16cc336719..b5484415b2 100644
--- a/static/js/billing/helpers.js
+++ b/static/js/billing/helpers.js
@@ -22,7 +22,7 @@ exports.create_ajax_request = function (url, form_name, stripe_token = null, num
data.stripe_token = JSON.stringify(stripe_token.id);
}
- form.serializeArray().forEach(function (item) {
+ form.serializeArray().forEach((item) => {
if (numeric_inputs.includes(item.name)) {
data[item.name] = item.value;
} else {
diff --git a/static/js/billing/upgrade.js b/static/js/billing/upgrade.js
index e6df0098bb..f0dc85e363 100644
--- a/static/js/billing/upgrade.js
+++ b/static/js/billing/upgrade.js
@@ -10,7 +10,7 @@ exports.initialize = () => {
},
});
- $('#add-card-button').on('click', function (e) {
+ $('#add-card-button').on('click', (e) => {
const license_management = $('input[type=radio][name=license_management]:checked').val();
if (helpers.is_valid_input($("#" + license_management + "_license_count")) === false) {
return;
@@ -28,7 +28,7 @@ exports.initialize = () => {
e.preventDefault();
});
- $("#invoice-button").on("click", function (e) {
+ $("#invoice-button").on("click", (e) => {
if (helpers.is_valid_input($("#invoiced_licenses")) === false) {
return;
}
@@ -36,7 +36,7 @@ exports.initialize = () => {
helpers.create_ajax_request("/json/billing/upgrade", "invoice", undefined, ["licenses"]);
});
- $("#sponsorship-button").on("click", function (e) {
+ $("#sponsorship-button").on("click", (e) => {
e.preventDefault();
helpers.create_ajax_request("/json/billing/sponsorship", "sponsorship", undefined, undefined, "/");
});
@@ -69,6 +69,6 @@ exports.initialize = () => {
window.upgrade = exports;
-$(function () {
+$(() => {
exports.initialize();
});
diff --git a/static/js/blueslip.js b/static/js/blueslip.js
index 0e60a35e8f..8f5ae50c8d 100644
--- a/static/js/blueslip.js
+++ b/static/js/blueslip.js
@@ -200,7 +200,7 @@ exports.exception_msg = function blueslip_exception_msg(ex) {
return message;
};
-$(window).on('error', function (event) {
+$(window).on('error', (event) => {
const ex = event.originalEvent.error;
if (!ex || ex instanceof BlueslipError) {
return;
diff --git a/static/js/bot_data.js b/static/js/bot_data.js
index 215f24032b..f877b045b2 100644
--- a/static/js/bot_data.js
+++ b/static/js/bot_data.js
@@ -19,7 +19,7 @@ const services = new Map();
const services_fields = ['base_url', 'interface',
'config_data', 'service_name', 'token'];
-const send_change_event = _.debounce(function () {
+const send_change_event = _.debounce(() => {
settings_bots.render_bots();
}, 50);
diff --git a/static/js/buddy_list.js b/static/js/buddy_list.js
index a11055af1b..e3a3c39baa 100644
--- a/static/js/buddy_list.js
+++ b/static/js/buddy_list.js
@@ -123,9 +123,7 @@ function buddy_list_create() {
self.get_items = function () {
const obj = self.container.find(self.item_sel);
- return obj.map(function (i, elem) {
- return $(elem);
- });
+ return obj.map((i, elem) => $(elem));
};
self.first_key = function () {
@@ -317,7 +315,7 @@ function buddy_list_create() {
// sure everything's in place.
const scroll_container = ui.get_scroll_element($(self.scroll_container_sel));
- scroll_container.scroll(function () {
+ scroll_container.scroll(() => {
self.fill_screen_with_content();
});
};
diff --git a/static/js/channel.js b/static/js/channel.js
index 32afb9a83c..d7ef99a87b 100644
--- a/static/js/channel.js
+++ b/static/js/channel.js
@@ -77,7 +77,7 @@ function call(args, idempotent) {
if (!data && idempotent) {
// If idempotent, retry
blueslip.log("Retrying idempotent" + args);
- setTimeout(function () {
+ setTimeout(() => {
const jqXHR = $.ajax(args);
add_pending_request(jqXHR);
}, 0);
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 279519ba5f..dad439964d 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -32,7 +32,7 @@ exports.initialize = function () {
return;
}
current_msg_list.select_id(id);
- setTimeout(function () {
+ setTimeout(() => {
// The algorithm to trigger long tap is that first, we check
// whether the message is still touched after MS_DELAY ms and
// the user isn't scrolling the messages(see other touch event
@@ -45,18 +45,18 @@ exports.initialize = function () {
$(this).trigger("longtap");
}
}
- }.bind(this), MS_DELAY);
+ }, MS_DELAY);
});
- $("#main_div").on("touchend", ".messagebox", function () {
+ $("#main_div").on("touchend", ".messagebox", () => {
meta.touchdown = false;
});
- $("#main_div").on("touchmove", ".messagebox", function () {
+ $("#main_div").on("touchmove", ".messagebox", () => {
meta.invalid = true;
});
- $("#main_div").on("contextmenu", ".messagebox", function (e) {
+ $("#main_div").on("contextmenu", ".messagebox", (e) => {
e.preventDefault();
});
}
@@ -178,19 +178,19 @@ exports.initialize = function () {
$(".tooltip").remove();
});
- $('body').on('mouseenter', '.message_edit_notice', function (e) {
+ $('body').on('mouseenter', '.message_edit_notice', (e) => {
if (page_params.realm_allow_edit_history) {
$(e.currentTarget).addClass("message_edit_notice_hover");
}
});
- $('body').on('mouseleave', '.message_edit_notice', function (e) {
+ $('body').on('mouseleave', '.message_edit_notice', (e) => {
if (page_params.realm_allow_edit_history) {
$(e.currentTarget).removeClass("message_edit_notice_hover");
}
});
- $('body').on('click', '.message_edit_notice', function (e) {
+ $('body').on('click', '.message_edit_notice', (e) => {
popovers.hide_all();
const message_id = rows.id($(e.currentTarget).closest(".message_row"));
const row = current_msg_list.get_row(message_id);
@@ -207,7 +207,7 @@ exports.initialize = function () {
// TOOLTIP FOR MESSAGE REACTIONS
- $('#main_div').on('mouseenter', '.message_reaction', function (e) {
+ $('#main_div').on('mouseenter', '.message_reaction', (e) => {
e.stopPropagation();
const elem = $(e.currentTarget);
const local_id = elem.attr('data-reaction-id');
@@ -226,14 +226,14 @@ exports.initialize = function () {
$(".tooltip-arrow").remove();
});
- $('#main_div').on('mouseleave', '.message_reaction', function (e) {
+ $('#main_div').on('mouseleave', '.message_reaction', (e) => {
e.stopPropagation();
$(e.currentTarget).tooltip('destroy');
});
// DESTROY PERSISTING TOOLTIPS ON HOVER
- $("body").on('mouseenter', '.tooltip', function (e) {
+ $("body").on('mouseenter', '.tooltip', (e) => {
e.stopPropagation();
$(e.currentTarget).remove();
});
@@ -252,7 +252,7 @@ exports.initialize = function () {
// USER STATUS MODAL
- $(".user-status-value").on("click", function (e) {
+ $(".user-status-value").on("click", (e) => {
e.stopPropagation();
const user_status_value = $(e.currentTarget).attr("data-user-status-value");
$("input.user_status").val(user_status_value);
@@ -373,7 +373,7 @@ exports.initialize = function () {
// MUTING
- $('body').on('click', '.on_hover_topic_mute', function (e) {
+ $('body').on('click', '.on_hover_topic_mute', (e) => {
e.stopPropagation();
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
const topic = $(e.currentTarget).attr('data-topic-name');
@@ -382,7 +382,7 @@ exports.initialize = function () {
$('body').on('keydown', '.on_hover_topic_mute', convert_enter_to_click);
- $('body').on('click', '.on_hover_topic_unmute', function (e) {
+ $('body').on('click', '.on_hover_topic_unmute', (e) => {
e.stopPropagation();
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
const topic = $(e.currentTarget).attr('data-topic-name');
@@ -393,12 +393,12 @@ exports.initialize = function () {
// RECENT TOPICS
- $('body').on('click', '#recent_topics_search', function (e) {
+ $('body').on('click', '#recent_topics_search', (e) => {
e.stopPropagation();
recent_topics.change_focused_element(e, 'click');
});
- $('body').on('click', '.on_hover_topic_read', function (e) {
+ $('body').on('click', '.on_hover_topic_read', (e) => {
e.stopPropagation();
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
const topic = $(e.currentTarget).attr('data-topic-name');
@@ -407,19 +407,19 @@ exports.initialize = function () {
$('body').on('keydown', '.on_hover_topic_read', convert_enter_to_click);
- $('body').on('click', '.btn-recent-filters', function (e) {
+ $('body').on('click', '.btn-recent-filters', (e) => {
e.stopPropagation();
recent_topics.set_filter(e.currentTarget.dataset.filter);
recent_topics.update_filters_view();
});
// Search for all table rows (this combines stream & topic names)
- $('body').on('keyup', '#recent_topics_search', _.debounce(function () {
+ $('body').on('keyup', '#recent_topics_search', _.debounce(() => {
recent_topics.update_filters_view();
// Wait for user to go idle before initiating search.
}, 300));
- $('body').on('click', '#recent_topics_search_clear', function (e) {
+ $('body').on('click', '#recent_topics_search_clear', (e) => {
e.stopPropagation();
$('#recent_topics_search').val("");
recent_topics.update_filters_view();
@@ -459,7 +459,7 @@ exports.initialize = function () {
// SIDEBARS
- $("#userlist-toggle-button").on("click", function (e) {
+ $("#userlist-toggle-button").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
@@ -470,7 +470,7 @@ exports.initialize = function () {
}
});
- $("#streamlist-toggle-button").on("click", function (e) {
+ $("#streamlist-toggle-button").on("click", (e) => {
e.preventDefault();
e.stopPropagation();
@@ -481,7 +481,7 @@ exports.initialize = function () {
}
});
- $('#user_presences').expectOne().on('click', '.selectable_sidebar_block', function (e) {
+ $('#user_presences').expectOne().on('click', '.selectable_sidebar_block', (e) => {
const li = $(e.target).parents('li');
activity.narrow_for_user({li: li});
@@ -508,7 +508,7 @@ exports.initialize = function () {
}
// BUDDY LIST TOOLTIPS
- $('#user_presences').on('mouseenter', '.user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block', function (e) {
+ $('#user_presences').on('mouseenter', '.user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block', (e) => {
e.stopPropagation();
const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
const user_id_string = elem.attr('data-user-id');
@@ -516,14 +516,14 @@ exports.initialize = function () {
do_render_buddy_list_tooltip(elem, title_data);
});
- $('#user_presences').on('mouseleave click', '.user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block', function (e) {
+ $('#user_presences').on('mouseleave click', '.user-presence-link, .user_sidebar_entry .user_circle, .user_sidebar_entry .selectable_sidebar_block', (e) => {
e.stopPropagation();
const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
$(elem).tooltip('destroy');
});
// PM LIST TOOLTIPS
- $("body").on('mouseenter', '#pm_user_status', function (e) {
+ $("body").on('mouseenter', '#pm_user_status', (e) => {
$(".tooltip").remove();
e.stopPropagation();
const elem = $(e.currentTarget);
@@ -535,14 +535,14 @@ exports.initialize = function () {
do_render_buddy_list_tooltip(elem, title_data);
});
- $("body").on('mouseleave', '#pm_user_status', function (e) {
+ $("body").on('mouseleave', '#pm_user_status', (e) => {
e.stopPropagation();
$(e.currentTarget).tooltip('destroy');
});
// HOME
- $(document).on('click', ".top_left_all_messages", function (e) {
+ $(document).on('click', ".top_left_all_messages", (e) => {
ui_util.change_tab_to('#home');
narrow.deactivate();
search.update_button_visibility();
@@ -552,7 +552,7 @@ exports.initialize = function () {
e.preventDefault();
});
- $(".brand").on('click', function (e) {
+ $(".brand").on('click', (e) => {
if (overlays.is_active()) {
overlays.close_active();
} else {
@@ -577,11 +577,11 @@ exports.initialize = function () {
stream_popover.register_click_handlers();
notifications.register_click_handlers();
- $('body').on('click', '.logout_button', function () {
+ $('body').on('click', '.logout_button', () => {
$('#logout_form').submit();
});
- $('.restart_get_events_button').click(function () {
+ $('.restart_get_events_button').click(() => {
server_events.restart_get_events({dont_block: true});
});
@@ -589,12 +589,12 @@ exports.initialize = function () {
$("body").on("click", ".alert-box > div .exit", function () {
const $alert = $(this).closest(".alert-box > div");
$alert.addClass("fade-out");
- setTimeout(function () {
+ setTimeout(() => {
$alert.removeClass("fade-out show");
}, 300);
});
- $("#settings_page").on("click", ".collapse-settings-btn", function () {
+ $("#settings_page").on("click", ".collapse-settings-btn", () => {
settings_toggle.toggle_org_setting_collapse();
});
@@ -607,40 +607,40 @@ exports.initialize = function () {
// NB: This just binds to current elements, and won't bind to elements
// created after ready() is called.
$('#compose-send-status .compose-send-status-close').click(
- function () { $('#compose-send-status').stop(true).fadeOut(500); }
+ () => { $('#compose-send-status').stop(true).fadeOut(500); }
);
$('#nonexistent_stream_reply_error .compose-send-status-close').click(
- function () { $('#nonexistent_stream_reply_error').stop(true).fadeOut(500); }
+ () => { $('#nonexistent_stream_reply_error').stop(true).fadeOut(500); }
);
- $('.compose_stream_button').click(function () {
+ $('.compose_stream_button').click(() => {
popovers.hide_mobile_message_buttons_popover();
compose_actions.start('stream', {trigger: 'new topic button'});
});
- $('.compose_private_button').click(function () {
+ $('.compose_private_button').click(() => {
popovers.hide_mobile_message_buttons_popover();
compose_actions.start('private');
});
- $('body').on('click', '.compose_mobile_stream_button', function () {
+ $('body').on('click', '.compose_mobile_stream_button', () => {
popovers.hide_mobile_message_buttons_popover();
compose_actions.start('stream', {trigger: 'new topic button'});
});
- $('body').on('click', '.compose_mobile_private_button', function () {
+ $('body').on('click', '.compose_mobile_private_button', () => {
popovers.hide_mobile_message_buttons_popover();
compose_actions.start('private');
});
- $('.compose_reply_button').click(function () {
+ $('.compose_reply_button').click(() => {
compose_actions.respond_to_message({trigger: 'reply button'});
});
- $('.empty_feed_compose_stream').click(function (e) {
+ $('.empty_feed_compose_stream').click((e) => {
compose_actions.start('stream', {trigger: 'empty feed message'});
e.preventDefault();
});
- $('.empty_feed_compose_private').click(function (e) {
+ $('.empty_feed_compose_private').click((e) => {
compose_actions.start('private', {trigger: 'empty feed message'});
e.preventDefault();
});
@@ -677,23 +677,23 @@ exports.initialize = function () {
$("#compose_buttons").click(handle_compose_click);
$(".compose-content").click(handle_compose_click);
- $("#compose_close").click(function () {
+ $("#compose_close").click(() => {
compose_actions.cancel();
});
- $("#streams_inline_cog").click(function (e) {
+ $("#streams_inline_cog").click((e) => {
e.stopPropagation();
hashchange.go_to_location('streams/subscribed');
});
- $("#streams_filter_icon").click(function (e) {
+ $("#streams_filter_icon").click((e) => {
e.stopPropagation();
stream_list.toggle_filter_displayed(e);
});
// WEBATHENA
- $('body').on('click', '.webathena_login', function (e) {
+ $('body').on('click', '.webathena_login', (e) => {
$("#zephyr-mirror-error").removeClass("show");
const principal = ["zephyr", "zephyr"];
WinChan.open({
@@ -703,7 +703,7 @@ exports.initialize = function () {
realm: "ATHENA.MIT.EDU",
principal: principal,
},
- }, function (err, r) {
+ }, (err, r) => {
if (err) {
blueslip.warn(err);
return;
@@ -731,9 +731,7 @@ exports.initialize = function () {
// End Webathena code
// disable the draggability for left-sidebar components
- $('#stream_filters, #global_filters').on('dragstart', function () {
- return false;
- });
+ $('#stream_filters, #global_filters').on('dragstart', () => false);
(function () {
const map = {
@@ -760,9 +758,7 @@ exports.initialize = function () {
}
});
- $(document).on("drop", ".editable-section", function () {
- return false;
- });
+ $(document).on("drop", ".editable-section", () => false);
$(document).on("input", ".editable-section", function () {
// if there are any child nodes, inclusive of
which means you
@@ -863,7 +859,7 @@ exports.initialize = function () {
$('#hotspot_' + hotspot_name + '_icon').remove();
});
- $('body').on('click', '.hotspot-button', function (e) {
+ $('body').on('click', '.hotspot-button', (e) => {
e.preventDefault();
e.stopPropagation();
@@ -872,14 +868,14 @@ exports.initialize = function () {
});
// stop propagation
- $('body').on('click', '.hotspot.overlay .hotspot-popover', function (e) {
+ $('body').on('click', '.hotspot.overlay .hotspot-popover', (e) => {
e.stopPropagation();
});
// MAIN CLICK HANDLER
- $(document).on('click', function (e) {
+ $(document).on('click', (e) => {
if (e.button !== 0 || $(e.target).is(".drag")) {
// Firefox emits right click events on the document, but not on
// the child nodes, so the #compose stopPropagation doesn't get a
@@ -925,11 +921,11 @@ exports.initialize = function () {
// Workaround for Bootstrap issue #5900, which basically makes dropdowns
// unclickable on mobile devices.
// https://github.com/twitter/bootstrap/issues/5900
- $('a.dropdown-toggle, .dropdown-menu a').on('touchstart', function (e) {
+ $('a.dropdown-toggle, .dropdown-menu a').on('touchstart', (e) => {
e.stopPropagation();
});
- $(".settings-header.mobile .fa-chevron-left").on("click", function () {
+ $(".settings-header.mobile .fa-chevron-left").on("click", () => {
settings_panel_menu.mobile_deactivate_section();
});
};
diff --git a/static/js/common.js b/static/js/common.js
index 4c6df4c24d..e316a6e681 100644
--- a/static/js/common.js
+++ b/static/js/common.js
@@ -6,7 +6,7 @@ if (module.hot) {
exports.status_classes = 'alert-error alert-success alert-info alert-warning';
exports.autofocus = function (selector) {
- $(function () {
+ $(() => {
$(selector).focus();
});
};
diff --git a/static/js/components.js b/static/js/components.js
index 3129ed868b..20cab11f3c 100644
--- a/static/js/components.js
+++ b/static/js/components.js
@@ -18,7 +18,7 @@ exports.toggle = function (opts) {
// classes need to be added for correct alignment or other purposes
_component.addClass(opts.html_class);
}
- opts.values.forEach(function (value, i) {
+ opts.values.forEach((value, i) => {
// create a tab with a tab-id so they don't have to be referenced
// by text value which can be inconsistent.
const tab = $("
" + value.label + "
");
diff --git a/static/js/compose.js b/static/js/compose.js
index 754767583d..f7e6ec0fe9 100644
--- a/static/js/compose.js
+++ b/static/js/compose.js
@@ -259,7 +259,7 @@ exports.compose_error = compose_error;
function nonexistent_stream_reply_error() {
$("#nonexistent_stream_reply_error").show();
$("#compose-reply-error-msg").html("There are no messages to reply to yet.");
- setTimeout(function () {
+ setTimeout(() => {
$("#nonexistent_stream_reply_error").hide();
}, 5000);
}
@@ -936,14 +936,14 @@ exports.initialize = function () {
$("#below-compose-content .video_link").toggle(exports.compute_show_video_chat_button());
$('#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient').on('keyup', update_fade);
$('#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient').on('change', update_fade);
- $('#compose-textarea').on('keydown', function (event) {
+ $('#compose-textarea').on('keydown', (event) => {
exports.handle_keydown(event, $("#compose-textarea").expectOne());
});
- $('#compose-textarea').on('keyup', function (event) {
+ $('#compose-textarea').on('keyup', (event) => {
exports.handle_keyup(event, $("#compose-textarea").expectOne());
});
- $("#compose form").on("submit", function (e) {
+ $("#compose form").on("submit", (e) => {
e.preventDefault();
exports.finish();
});
@@ -952,7 +952,7 @@ exports.initialize = function () {
upload.feature_check($("#compose #attach_files"));
- $("#compose-all-everyone").on('click', '.compose-all-everyone-confirm', function (event) {
+ $("#compose-all-everyone").on('click', '.compose-all-everyone-confirm', (event) => {
event.preventDefault();
$(event.target).parents('.compose-all-everyone').remove();
@@ -961,7 +961,7 @@ exports.initialize = function () {
exports.finish();
});
- $("#compose-announce").on('click', '.compose-announce-confirm', function (event) {
+ $("#compose-announce").on('click', '.compose-announce-confirm', (event) => {
event.preventDefault();
$(event.target).parents('.compose-announce').remove();
@@ -970,7 +970,7 @@ exports.initialize = function () {
exports.finish();
});
- $("#compose-send-status").on('click', '.sub_unsub_button', function (event) {
+ $("#compose-send-status").on('click', '.sub_unsub_button', (event) => {
event.preventDefault();
const stream_name = $('#stream_message_recipient_stream').val();
@@ -982,13 +982,13 @@ exports.initialize = function () {
$("#compose-send-status").hide();
});
- $("#compose-send-status").on('click', '#compose_not_subscribed_close', function (event) {
+ $("#compose-send-status").on('click', '#compose_not_subscribed_close', (event) => {
event.preventDefault();
$("#compose-send-status").hide();
});
- $("#compose_invite_users").on('click', '.compose_invite_link', function (event) {
+ $("#compose_invite_users").on('click', '.compose_invite_link', (event) => {
event.preventDefault();
const invite_row = $(event.target).parents('.compose_invite_user');
@@ -1030,7 +1030,7 @@ exports.initialize = function () {
stream_edit.invite_user_to_stream([user_id], sub, success, xhr_failure);
});
- $("#compose_invite_users").on('click', '.compose_invite_close', function (event) {
+ $("#compose_invite_users").on('click', '.compose_invite_close', (event) => {
const invite_row = $(event.target).parents('.compose_invite_user');
const all_invites = $("#compose_invite_users");
@@ -1041,7 +1041,7 @@ exports.initialize = function () {
}
});
- $("#compose_private_stream_alert").on('click', '.compose_private_stream_alert_close', function (event) {
+ $("#compose_private_stream_alert").on('click', '.compose_private_stream_alert_close', (event) => {
const stream_alert_row = $(event.target).parents('.compose_private_stream_alert');
const stream_alert = $("#compose_private_stream_alert");
@@ -1055,12 +1055,12 @@ exports.initialize = function () {
// Click event binding for "Attach files" button
// Triggers a click on a hidden file input field
- $("#compose").on("click", "#attach_files", function (e) {
+ $("#compose").on("click", "#attach_files", (e) => {
e.preventDefault();
$("#compose #file_input").trigger("click");
});
- $('body').on('click', '.video_link', function (e) {
+ $('body').on('click', '.video_link', (e) => {
e.preventDefault();
let target_textarea;
@@ -1138,7 +1138,7 @@ exports.initialize = function () {
}
});
- $("#compose").on("click", "#markdown_preview", function (e) {
+ $("#compose").on("click", "#markdown_preview", (e) => {
e.preventDefault();
const content = $("#compose-textarea").val();
$("#compose-textarea").hide();
@@ -1149,7 +1149,7 @@ exports.initialize = function () {
exports.render_and_show_preview($("#markdown_preview_spinner"), $("#preview_content"), content);
});
- $("#compose").on("click", "#undo_markdown_preview", function (e) {
+ $("#compose").on("click", "#undo_markdown_preview", (e) => {
e.preventDefault();
exports.clear_preview_area();
});
@@ -1158,7 +1158,7 @@ exports.initialize = function () {
mode: "compose",
});
- $("#compose-textarea").focus(function () {
+ $("#compose-textarea").focus(() => {
const opts = {
message_type: compose_state.get_message_type(),
stream: $('#stream_message_recipient_stream').val(),
diff --git a/static/js/compose_fade.js b/static/js/compose_fade.js
index 09ea6f588b..41b8338bce 100644
--- a/static/js/compose_fade.js
+++ b/static/js/compose_fade.js
@@ -69,7 +69,7 @@ function fade_messages() {
}
// Defer updating all message groups so that the compose box can open sooner
- setTimeout(function (expected_msg_list, expected_recipient) {
+ setTimeout((expected_msg_list, expected_recipient) => {
const all_groups = rows.get_table(current_msg_list.table_name).find(".recipient_row");
if (current_msg_list !== expected_msg_list ||
diff --git a/static/js/compose_pm_pill.js b/static/js/compose_pm_pill.js
index 849247a25e..620eb09906 100644
--- a/static/js/compose_pm_pill.js
+++ b/static/js/compose_pm_pill.js
@@ -51,9 +51,7 @@ exports.get_user_ids_string = function () {
exports.get_emails = function () {
// return something like "alice@example.com,bob@example.com"
const user_ids = exports.get_user_ids();
- const emails = user_ids.map(function (id) {
- return people.get_by_user_id(id).email;
- }).join(",");
+ const emails = user_ids.map((id) => people.get_by_user_id(id).email).join(",");
return emails;
};
diff --git a/static/js/compose_ui.js b/static/js/compose_ui.js
index 89efdc4135..429aa33416 100644
--- a/static/js/compose_ui.js
+++ b/static/js/compose_ui.js
@@ -63,13 +63,13 @@ exports.replace_syntax = function (old_syntax, new_syntax, textarea) {
textarea = $('#compose-textarea');
}
- textarea.val(textarea.val().replace(old_syntax, function () {
+ textarea.val(textarea.val().replace(old_syntax, () =>
// We need this anonymous function to avoid JavaScript's
// replace() function treating `$`s in new_syntax as special syntax. See
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Description
// for details.
- return new_syntax;
- }));
+ new_syntax
+ ));
};
exports.compute_placeholder_text = function (opts) {
diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js
index 1a3a3b1674..3497a41aef 100644
--- a/static/js/composebox_typeahead.js
+++ b/static/js/composebox_typeahead.js
@@ -257,12 +257,12 @@ function select_on_focus(field_id) {
// conditions in Chrome so we need to protect against infinite
// recursion.
let in_handler = false;
- $("#" + field_id).focus(function () {
+ $("#" + field_id).focus(() => {
if (in_handler) {
return;
}
in_handler = true;
- $("#" + field_id).select().one('mouseup', function (e) {
+ $("#" + field_id).select().one('mouseup', (e) => {
e.preventDefault();
});
in_handler = false;
@@ -907,7 +907,7 @@ exports.content_typeahead_selected = function (item, event) {
// Keep the cursor after the newly inserted text, as Bootstrap will call textbox.change() to
// overwrite the text in the textbox.
- setTimeout(function () {
+ setTimeout(() => {
textbox.caret(beginning.length, beginning.length);
// Also, trigger autosize to check if compose box needs to be resized.
compose_ui.autosize_textarea();
@@ -954,7 +954,7 @@ exports.sort_results = function (completing, matches, token) {
// topic_jump doesn't actually have a typeahead popover, so we return quickly here.
return matches;
case 'topic_list':
- return typeahead_helper.sorter(token, matches, function (x) {return x;});
+ return typeahead_helper.sorter(token, matches, (x) => x);
}
};
@@ -1044,7 +1044,7 @@ exports.initialize = function () {
$("form#send_message_form").keydown(handle_keydown);
$("form#send_message_form").keyup(handle_keyup);
- $("#enter_sends").click(function () {
+ $("#enter_sends").click(() => {
const send_button = $("#compose-send-button");
page_params.enter_sends = $("#enter_sends").is(":checked");
if (page_params.enter_sends) {
@@ -1097,7 +1097,7 @@ exports.initialize = function () {
return typeahead_helper.render_typeahead_item({ primary: item });
},
sorter: function (items) {
- const sorted = typeahead_helper.sorter(this.query, items, function (x) {return x;});
+ const sorted = typeahead_helper.sorter(this.query, items, (x) => x);
if (sorted.length > 0 && !sorted.includes(this.query)) {
sorted.unshift(this.query);
}
diff --git a/static/js/confirm_dialog.js b/static/js/confirm_dialog.js
index f347738bc6..62374ec41d 100644
--- a/static/js/confirm_dialog.js
+++ b/static/js/confirm_dialog.js
@@ -62,12 +62,12 @@ exports.launch = function (conf) {
yes_button.html(conf.html_yes_button);
// Set up handlers.
- yes_button.on('click', function () {
+ yes_button.on('click', () => {
overlays.close_modal('#confirm_dialog_modal');
conf.on_click();
});
- confirm_dialog.on('hide', function () {
+ confirm_dialog.on('hide', () => {
confirm_dialog.remove();
});
diff --git a/static/js/copy_and_paste.js b/static/js/copy_and_paste.js
index edd2a142a0..b888d61e0b 100644
--- a/static/js/copy_and_paste.js
+++ b/static/js/copy_and_paste.js
@@ -108,7 +108,7 @@ function select_div(div, selection) {
}
function remove_div(div, ranges, selection) {
- window.setTimeout(function () {
+ window.setTimeout(() => {
selection = window.getSelection();
selection.removeAllRanges();
@@ -210,9 +210,7 @@ exports.analyze_selection = function (selection) {
ranges.push(range);
startc = $(range.startContainer);
- start_data = find_boundary_tr($(startc.parents('.selectable_row, .message_header')[0]), function (row) {
- return row.next();
- });
+ start_data = find_boundary_tr($(startc.parents('.selectable_row, .message_header')[0]), (row) => row.next());
if (start_data === undefined) {
// Skip any selection sections that don't intersect a message.
continue;
@@ -237,9 +235,7 @@ exports.analyze_selection = function (selection) {
} else {
initial_end_tr = $(endc.parents('.selectable_row')[0]);
}
- end_data = find_boundary_tr(initial_end_tr, function (row) {
- return row.prev();
- });
+ end_data = find_boundary_tr(initial_end_tr, (row) => row.prev());
if (end_data === undefined) {
// Skip any selection sections that don't intersect a message.
diff --git a/static/js/csrf.js b/static/js/csrf.js
index 230b55826b..7a69d9133d 100644
--- a/static/js/csrf.js
+++ b/static/js/csrf.js
@@ -1,5 +1,5 @@
let csrf_token;
-$(function () {
+$(() => {
// This requires that we used Jinja2's {% csrf_input %} somewhere on the page.
const csrf_input = $('input[name="csrfmiddlewaretoken"]');
if (csrf_input.length > 0) {
diff --git a/static/js/debug.js b/static/js/debug.js
index b028215eec..167b4856f1 100644
--- a/static/js/debug.js
+++ b/static/js/debug.js
@@ -30,11 +30,9 @@ export function check_duplicate_ids() {
const collisions = [];
let total_collisions = 0;
- Array.prototype.slice.call(document.querySelectorAll("*")).forEach(function (o) {
+ Array.prototype.slice.call(document.querySelectorAll("*")).forEach((o) => {
if (o.id && ids.has(o.id)) {
- const el = collisions.find(function (c) {
- return c.id === o.id;
- });
+ const el = collisions.find((c) => c.id === o.id);
ids.add(o.id);
total_collisions += 1;
diff --git a/static/js/drafts.js b/static/js/drafts.js
index a58f176393..6e510fcb99 100644
--- a/static/js/drafts.js
+++ b/static/js/drafts.js
@@ -318,9 +318,9 @@ exports.launch = function () {
const unsorted_raw_drafts = Object.values(data);
- const sorted_raw_drafts = unsorted_raw_drafts.sort(function (draft_a, draft_b) {
- return draft_b.updatedAt - draft_a.updatedAt;
- });
+ const sorted_raw_drafts = unsorted_raw_drafts.sort(
+ (draft_a, draft_b) => draft_b.updatedAt - draft_a.updatedAt
+ );
const sorted_formatted_drafts = sorted_raw_drafts.map(exports.format_draft).filter(Boolean);
@@ -514,7 +514,7 @@ exports.set_initial_element = function (drafts) {
};
exports.initialize = function () {
- window.addEventListener("beforeunload", function () {
+ window.addEventListener("beforeunload", () => {
exports.update_draft();
});
@@ -522,7 +522,7 @@ exports.initialize = function () {
$("#compose-textarea").focusout(exports.update_draft);
- $('body').on('focus', '.draft-info-box', function (e) {
+ $('body').on('focus', '.draft-info-box', (e) => {
activate_element(e.target);
});
};
diff --git a/static/js/dropdown_list_widget.js b/static/js/dropdown_list_widget.js
index ca6ee5df14..bf7862f6f0 100644
--- a/static/js/dropdown_list_widget.js
+++ b/static/js/dropdown_list_widget.js
@@ -55,7 +55,7 @@ const DropdownListWidget = function (opts) {
const value = $(this).attr('data-value');
update(value);
});
- $(`#${opts.container_id} .dropdown_list_reset_button`).click(function (e) {
+ $(`#${opts.container_id} .dropdown_list_reset_button`).click((e) => {
update(opts.null_value);
e.preventDefault();
});
@@ -79,22 +79,22 @@ const DropdownListWidget = function (opts) {
},
},
});
- $(`#${opts.container_id} .dropdown-search`).click(function (e) {
+ $(`#${opts.container_id} .dropdown-search`).click((e) => {
e.stopPropagation();
});
- dropdown_toggle.click(function () {
+ dropdown_toggle.click(() => {
search_input.val("").trigger("input");
});
- dropdown_toggle.focus(function (e) {
+ dropdown_toggle.focus((e) => {
// On opening a Bootstrap Dropdown, the parent element recieves focus.
// Here, we want our search input to have focus instead.
e.preventDefault();
search_input.focus();
});
- search_input.keydown(function (e) {
+ search_input.keydown((e) => {
if (!/(38|40|27)/.test(e.keyCode)) {
return;
}
diff --git a/static/js/echo.js b/static/js/echo.js
index 6b9ee72c9e..9d2e2f0494 100644
--- a/static/js/echo.js
+++ b/static/js/echo.js
@@ -30,7 +30,7 @@ function resend_message(message, row) {
function on_error(response) {
exports.message_send_error(message.id, response);
- setTimeout(function () {
+ setTimeout(() => {
retry_spinner.toggleClass('rotating', false);
}, 300);
blueslip.log("Manual resend of message failed");
diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js
index a19f370faf..20988b2d67 100644
--- a/static/js/emoji_picker.js
+++ b/static/js/emoji_picker.js
@@ -505,7 +505,7 @@ exports.emoji_select_tab = function (elt) {
const scrollheight = elt.prop('scrollHeight');
const elt_height = elt.height();
let currently_selected = "";
- section_head_offsets.forEach(function (o) {
+ section_head_offsets.forEach((o) => {
if (scrolltop + elt_height / 2 >= o.position_y) {
currently_selected = o.section;
}
@@ -528,14 +528,14 @@ exports.emoji_select_tab = function (elt) {
function register_popover_events(popover) {
const $emoji_map = popover.find('.emoji-popover-emoji-map');
- ui.get_scroll_element($emoji_map).on("scroll", function () {
+ ui.get_scroll_element($emoji_map).on("scroll", () => {
exports.emoji_select_tab(ui.get_scroll_element($emoji_map));
});
$('.emoji-popover-filter').on('input', filter_emojis);
$('.emoji-popover-filter').keydown(maybe_select_emoji);
$('.emoji-popover').keypress(process_keypress);
- $('.emoji-popover').keydown(function (e) {
+ $('.emoji-popover').keydown((e) => {
// Because of cross-browser issues we need to handle backspace
// key separately. Firefox fires `keypress` event for backspace
// key but chrome doesn't so we need to trigger the logic for
@@ -670,7 +670,7 @@ exports.register_click_handlers = function () {
exports.toggle_emoji_popover(this, message_id);
});
- $("#main_div").on("mouseenter", ".reaction_button", function (e) {
+ $("#main_div").on("mouseenter", ".reaction_button", (e) => {
e.stopPropagation();
const elem = $(e.currentTarget);
@@ -685,12 +685,12 @@ exports.register_click_handlers = function () {
$(".tooltip-arrow").remove();
});
- $('#main_div').on('mouseleave', '.reaction_button', function (e) {
+ $('#main_div').on('mouseleave', '.reaction_button', (e) => {
e.stopPropagation();
$(e.currentTarget).tooltip('hide');
});
- $("body").on("click", ".actions_popover .reaction_button", function (e) {
+ $("body").on("click", ".actions_popover .reaction_button", (e) => {
const message_id = $(e.currentTarget).data('message-id');
e.preventDefault();
e.stopPropagation();
@@ -710,20 +710,18 @@ exports.register_click_handlers = function () {
const $popover = $(e.currentTarget).closest('.emoji-info-popover').expectOne();
const $emoji_map = $popover.find(".emoji-popover-emoji-map");
- const offset = section_head_offsets.find(function (o) {
- return o.section === $(this).attr("data-tab-name");
- }.bind(this));
+ const offset = section_head_offsets.find((o) => o.section === $(this).attr("data-tab-name"));
if (offset) {
ui.get_scroll_element($emoji_map).scrollTop(offset.position_y);
}
});
- $("body").on("click", ".emoji-popover-filter", function () {
+ $("body").on("click", ".emoji-popover-filter", () => {
reset_emoji_showcase();
});
- $("body").on("mouseenter", ".emoji-popover-emoji", function (e) {
+ $("body").on("mouseenter", ".emoji-popover-emoji", (e) => {
const emoji_id = $(e.currentTarget).data("emoji-id");
const emoji_coordinates = get_emoji_coordinates(emoji_id);
diff --git a/static/js/feedback_widget.js b/static/js/feedback_widget.js
index d3d3716a20..2ac5e0ffb7 100644
--- a/static/js/feedback_widget.js
+++ b/static/js/feedback_widget.js
@@ -71,7 +71,7 @@ function set_up_handlers() {
meta.handlers_set = true;
// if the user mouses over the notification, don't hide it.
- meta.$container.mouseenter(function () {
+ meta.$container.mouseenter(() => {
if (!meta.opened) {
return;
}
@@ -80,7 +80,7 @@ function set_up_handlers() {
});
// once the user's mouse leaves the notification, restart the countdown.
- meta.$container.mouseleave(function () {
+ meta.$container.mouseleave(() => {
if (!meta.opened) {
return;
}
@@ -91,11 +91,11 @@ function set_up_handlers() {
meta.hide_me_time = Math.max(meta.hide_me_time, new Date().getTime() + 2000);
});
- meta.$container.on('click', '.exit-me', function () {
+ meta.$container.on('click', '.exit-me', () => {
animate.fadeOut();
});
- meta.$container.on('click', '.feedback_undo', function () {
+ meta.$container.on('click', '.feedback_undo', () => {
if (meta.undo) {
meta.undo();
}
diff --git a/static/js/filter.js b/static/js/filter.js
index 7ff32e64be..4d68156a33 100644
--- a/static/js/filter.js
+++ b/static/js/filter.js
@@ -369,8 +369,8 @@ Filter.prototype = {
operands: function (operator) {
return _.chain(this._operators)
- .filter(function (elem) { return !elem.negated && elem.operator === operator; })
- .map(function (elem) { return elem.operand; })
+ .filter((elem) => !elem.negated && elem.operator === operator)
+ .map((elem) => elem.operand)
.value();
},
diff --git a/static/js/gear_menu.js b/static/js/gear_menu.js
index aefa02d21a..a8cc808d0a 100644
--- a/static/js/gear_menu.js
+++ b/static/js/gear_menu.js
@@ -86,12 +86,12 @@ exports.update_org_settings_menu_item = function () {
exports.initialize = function () {
exports.update_org_settings_menu_item();
- $('#gear-menu a[data-toggle="tab"]').on('show', function (e) {
+ $('#gear-menu a[data-toggle="tab"]').on('show', (e) => {
// Save the position of our old tab away, before we switch
const old_tab = $(e.relatedTarget).attr('href');
scroll_positions.set(old_tab, message_viewport.scrollTop());
});
- $('#gear-menu a[data-toggle="tab"]').on('shown', function (e) {
+ $('#gear-menu a[data-toggle="tab"]').on('shown', (e) => {
const target_tab = $(e.target).attr('href');
// Hide all our error messages when switching tabs
$('.alert').removeClass("show");
diff --git a/static/js/hashchange.js b/static/js/hashchange.js
index df8c264743..8014fcf670 100644
--- a/static/js/hashchange.js
+++ b/static/js/hashchange.js
@@ -281,7 +281,7 @@ exports.go_to_location = function (hash) {
};
exports.initialize = function () {
- $(window).on('hashchange', function (e) {
+ $(window).on('hashchange', (e) => {
hashchanged(false, e.originalEvent);
});
hashchanged(true);
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index 90cd1ee256..1e21ddd545 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -634,7 +634,7 @@ exports.process_hotkey = function (e, hotkey) {
compose_actions.start('private', {trigger: "compose_hotkey"});
return true;
case 'narrow_private':
- return do_narrow_action(function (target, opts) {
+ return do_narrow_action((target, opts) => {
narrow.by('is', 'private', opts);
});
case 'query_streams':
@@ -792,7 +792,7 @@ exports.process_keydown = function (e) {
return exports.process_hotkey(e, hotkey);
};
-$(document).keydown(function (e) {
+$(document).keydown((e) => {
if (exports.process_keydown(e)) {
e.preventDefault();
}
@@ -806,7 +806,7 @@ exports.process_keypress = function (e) {
return exports.process_hotkey(e, hotkey);
};
-$(document).keypress(function (e) {
+$(document).keypress((e) => {
if (exports.process_keypress(e)) {
e.preventDefault();
}
diff --git a/static/js/hotspots.js b/static/js/hotspots.js
index 8586a1294b..67bd8d44f5 100644
--- a/static/js/hotspots.js
+++ b/static/js/hotspots.js
@@ -203,7 +203,7 @@ function insert_hotspot_into_DOM(hotspot) {
'
?
' +
'
';
- setTimeout(function () {
+ setTimeout(() => {
$('body').prepend(hotspot_icon_HTML);
$('body').prepend(hotspot_overlay_HTML);
if (place_icon(hotspot)) {
@@ -211,8 +211,8 @@ function insert_hotspot_into_DOM(hotspot) {
}
// reposition on any event that might update the UI
- ['resize', 'scroll', 'onkeydown', 'click'].forEach(function (event_name) {
- window.addEventListener(event_name, _.debounce(function () {
+ ['resize', 'scroll', 'onkeydown', 'click'].forEach((event_name) => {
+ window.addEventListener(event_name, _.debounce(() => {
if (place_icon(hotspot)) {
place_popover(hotspot);
}
@@ -247,7 +247,7 @@ function close_read_hotspots(new_hotspots) {
exports.load_new = function (new_hotspots) {
close_read_hotspots(new_hotspots);
- new_hotspots.forEach(function (hotspot) {
+ new_hotspots.forEach((hotspot) => {
hotspot.location = HOTSPOT_LOCATIONS.get(hotspot.name);
});
new_hotspots.forEach(insert_hotspot_into_DOM);
diff --git a/static/js/huddle_data.js b/static/js/huddle_data.js
index 4b6e1cd9e7..e3a07f30f6 100644
--- a/static/js/huddle_data.js
+++ b/static/js/huddle_data.js
@@ -16,9 +16,7 @@ exports.process_loaded_messages = function (messages) {
exports.get_huddles = function () {
let huddles = Array.from(huddle_timestamps.keys());
- huddles = _.sortBy(huddles, function (huddle) {
- return huddle_timestamps.get(huddle);
- });
+ huddles = _.sortBy(huddles, (huddle) => huddle_timestamps.get(huddle));
return huddles.reverse();
};
diff --git a/static/js/input_pill.js b/static/js/input_pill.js
index 1468187733..d5f9405775 100644
--- a/static/js/input_pill.js
+++ b/static/js/input_pill.js
@@ -187,16 +187,14 @@ exports.create = function (opts) {
insertManyPills: function (pills) {
if (typeof pills === "string") {
- pills = pills.split(/,/g).map(function (pill) {
- return pill.trim();
- });
+ pills = pills.split(/,/g).map((pill) => pill.trim());
}
// this is an array to push all the errored values to, so it's drafts
// of pills for the user to fix.
const drafts = [];
- pills.forEach(function (pill) {
+ pills.forEach((pill) => {
// if this returns `false`, it erroed and we should push it to
// the draft pills.
if (funcs.appendPill(pill) === false) {
@@ -235,7 +233,7 @@ exports.create = function (opts) {
};
(function events() {
- store.$parent.on("keydown", ".input", function (e) {
+ store.$parent.on("keydown", ".input", (e) => {
const char = e.keyCode || e.charCode;
if (char === KEY.ENTER) {
@@ -300,7 +298,7 @@ exports.create = function (opts) {
// handle events while hovering on ".pill" elements.
// the three primary events are next, previous, and delete.
- store.$parent.on("keydown", ".pill", function (e) {
+ store.$parent.on("keydown", ".pill", (e) => {
const char = e.keyCode || e.charCode;
const $pill = store.$parent.find(".pill:focus");
@@ -328,7 +326,7 @@ exports.create = function (opts) {
// replace formatted input with plaintext to allow for sane copy-paste
// actions.
- store.$parent.on("paste", ".input", function (e) {
+ store.$parent.on("paste", ".input", (e) => {
e.preventDefault();
// get text representation of clipboard
@@ -360,7 +358,7 @@ exports.create = function (opts) {
}
});
- store.$parent.on("copy", ".pill", function (e) {
+ store.$parent.on("copy", ".pill", (e) => {
const id = store.$parent.find(":focus").data("id");
const data = funcs.getByID(id);
e.originalEvent.clipboardData.setData("text/plain", store.get_text_from_item(data.item));
diff --git a/static/js/invite.js b/static/js/invite.js
index 37eaa0fcef..ef1ec0d51d 100644
--- a/static/js/invite.js
+++ b/static/js/invite.js
@@ -73,7 +73,7 @@ function submit_invitation_form() {
const invitee_emails_errored = [];
const error_list = [];
let is_invitee_deactivated = false;
- arr.errors.forEach(function (value) {
+ arr.errors.forEach((value) => {
const [email, error_message, deactivated] = value;
error_list.push(`${email}: ${error_message}`);
if (deactivated) {
@@ -161,17 +161,17 @@ exports.launch = function () {
};
exports.initialize = function () {
- $(document).on('click', '.invite_check_all_button', function (e) {
+ $(document).on('click', '.invite_check_all_button', (e) => {
$('#streams_to_add :checkbox').prop('checked', true);
e.preventDefault();
});
- $(document).on('click', '.invite_uncheck_all_button', function (e) {
+ $(document).on('click', '.invite_uncheck_all_button', (e) => {
$('#streams_to_add :checkbox').prop('checked', false);
e.preventDefault();
});
- $("#submit-invitation").on("click", function () {
+ $("#submit-invitation").on("click", () => {
const is_generate_invite_link = $('#generate_multiuse_invite_radio').prop('checked');
if (is_generate_invite_link) {
generate_multiuse_invite();
@@ -180,7 +180,7 @@ exports.initialize = function () {
}
});
- $("#generate_multiuse_invite_button").on("click", function () {
+ $("#generate_multiuse_invite_button").on("click", () => {
$("#generate_multiuse_invite_radio").prop("checked", true);
$("#multiuse_radio_section").show();
$("#invite-method-choice").hide();
@@ -190,7 +190,7 @@ exports.initialize = function () {
reset_error_messages();
});
- $('#invite-user').on('change', '#generate_multiuse_invite_radio', function () {
+ $('#invite-user').on('change', '#generate_multiuse_invite_radio', () => {
$('#invitee_emails').prop('disabled', false);
$('#submit-invitation').text(i18n.t('Invite'));
$('#submit-invitation').data('loading-text', i18n.t('Inviting...'));
diff --git a/static/js/keydown_util.js b/static/js/keydown_util.js
index edd1d000ea..e1c1bc793a 100644
--- a/static/js/keydown_util.js
+++ b/static/js/keydown_util.js
@@ -11,7 +11,7 @@ const keys = {
};
exports.handle = function (opts) {
- opts.elem.keydown(function (e) {
+ opts.elem.keydown((e) => {
const key = e.which || e.keyCode;
if (e.altKey || e.ctrlKey || e.shiftKey) {
diff --git a/static/js/lightbox.js b/static/js/lightbox.js
index 13abd06529..95a821991f 100644
--- a/static/js/lightbox.js
+++ b/static/js/lightbox.js
@@ -8,7 +8,7 @@ function render_lightbox_list_images(preview_source) {
const images = Array.prototype.slice.call($(".focused_table .message_inline_image img"));
const $image_list = $("#lightbox_overlay .image-list").html("");
- images.forEach(function (img) {
+ images.forEach((img) => {
const src = img.getAttribute("src");
const className = preview_source === src ? "image selected" : "image";
@@ -321,7 +321,7 @@ exports.initialize = function () {
}
});
- $("#lightbox_overlay .image-preview").on("dblclick", "img, canvas", function (e) {
+ $("#lightbox_overlay .image-preview").on("dblclick", "img, canvas", (e) => {
$("#lightbox_overlay .lightbox-canvas-trigger").click();
e.preventDefault();
});
@@ -332,7 +332,7 @@ exports.initialize = function () {
}
});
- $("#lightbox_overlay").on("click", ".image-info-wrapper, .center", function (e) {
+ $("#lightbox_overlay").on("click", ".image-info-wrapper, .center", (e) => {
if ($(e.target).is(".image-info-wrapper, .center")) {
overlays.close_overlay("lightbox");
}
diff --git a/static/js/lightbox_canvas.js b/static/js/lightbox_canvas.js
index fbee2359f0..3f21ad1911 100644
--- a/static/js/lightbox_canvas.js
+++ b/static/js/lightbox_canvas.js
@@ -4,7 +4,7 @@ const events = {
};
window.onload = function () {
- document.body.addEventListener("mouseup", function (e) {
+ document.body.addEventListener("mouseup", (e) => {
events.documentMouseup = events.documentMouseup.filter(function (event) {
// go through automatic cleanup when running events.
if (!document.body.contains(event.canvas)) {
@@ -17,7 +17,7 @@ window.onload = function () {
});
window.addEventListener("resize", function (e) {
- events.windowResize = events.windowResize.filter(function (event) {
+ events.windowResize = events.windowResize.filter((event) => {
if (!document.body.contains(event.canvas)) {
return false;
}
@@ -25,7 +25,7 @@ window.onload = function () {
event.callback.call(this, e);
return true;
- }.bind(this));
+ });
});
};
@@ -76,7 +76,7 @@ const funcs = {
// actually an element that can scroll. The wheel event will
// detect the *gesture* of scrolling over an element, without actually
// worrying about scrollable content.
- canvas.addEventListener("wheel", function (e) {
+ canvas.addEventListener("wheel", (e) => {
e.preventDefault();
// this is to reverse scrolling directions for the image.
@@ -111,12 +111,12 @@ const funcs = {
// the only valid mousedown events should originate inside of the
// canvas.
- canvas.addEventListener("mousedown", function () {
+ canvas.addEventListener("mousedown", () => {
mousedown = true;
});
// on mousemove, actually run the pan events.
- canvas.addEventListener("mousemove", function (e) {
+ canvas.addEventListener("mousemove", (e) => {
// to pan, there must be mousedown and mousemove, check if valid.
if (mousedown === true) {
polyfillMouseMovement(e);
@@ -145,7 +145,7 @@ const funcs = {
// that the LightboxCanvas instance created in lightbox.js can be
// accessed from hotkey.js. Major code refactoring is required in lightbox.js
// to implement these keyboard shortcuts in hotkey.js
- document.addEventListener('keydown', function (e) {
+ document.addEventListener('keydown', (e) => {
if (!overlays.lightbox_open()) {
return;
}
@@ -165,7 +165,7 @@ const funcs = {
// make sure that when the mousedown is lifted on