mirror of https://github.com/zulip/zulip.git
eslint: Enable prefer-arrow-callback.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
960174408f
commit
a79322bc94
|
@ -118,6 +118,7 @@
|
||||||
"space-unary-ops": "error",
|
"space-unary-ops": "error",
|
||||||
"no-whitespace-before-property": "error",
|
"no-whitespace-before-property": "error",
|
||||||
"one-var": [ "error", "never" ],
|
"one-var": [ "error", "never" ],
|
||||||
|
"prefer-arrow-callback": "error",
|
||||||
"prefer-const": [ "error",
|
"prefer-const": [ "error",
|
||||||
{
|
{
|
||||||
"ignoreReadBeforeAssign": true
|
"ignoreReadBeforeAssign": true
|
||||||
|
@ -366,7 +367,9 @@
|
||||||
"frontend_tests/casper_lib/*.js"
|
"frontend_tests/casper_lib/*.js"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-var": "off" // PhantomJS doesn’t support let, const
|
// Don’t require ES features that PhantomJS doesn’t support
|
||||||
|
"no-var": "off",
|
||||||
|
"prefer-arrow-callback": "off"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -248,7 +248,7 @@ run_test('retry', () => {
|
||||||
},
|
},
|
||||||
|
|
||||||
check_ajax_options: function (options) {
|
check_ajax_options: function (options) {
|
||||||
global.patch_builtin('setTimeout', function (f, delay) {
|
global.patch_builtin('setTimeout', (f, delay) => {
|
||||||
assert.equal(delay, 0);
|
assert.equal(delay, 0);
|
||||||
f();
|
f();
|
||||||
});
|
});
|
||||||
|
@ -276,7 +276,7 @@ run_test('too_many_pending', () => {
|
||||||
blueslip.expect('warn',
|
blueslip.expect('warn',
|
||||||
'The length of pending_requests is over 50. ' +
|
'The length of pending_requests is over 50. ' +
|
||||||
'Most likely they are not being correctly removed.');
|
'Most likely they are not being correctly removed.');
|
||||||
_.times(50, function () {
|
_.times(50, () => {
|
||||||
channel.post({});
|
channel.post({});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,20 +91,20 @@ run_test('adjust_mac_shortcuts', () => {
|
||||||
|
|
||||||
common.has_mac_keyboard = function () { return false; };
|
common.has_mac_keyboard = function () { return false; };
|
||||||
key_no = 1;
|
key_no = 1;
|
||||||
keys_to_test_non_mac.forEach(function (value, key) {
|
keys_to_test_non_mac.forEach((value, key) => {
|
||||||
keys_elem_list.push(get_key_stub_html(key, value, "hotkey_non_mac_" + key_no));
|
keys_elem_list.push(get_key_stub_html(key, value, "hotkey_non_mac_" + key_no));
|
||||||
key_no += 1;
|
key_no += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
common.adjust_mac_shortcuts(".markdown_content");
|
common.adjust_mac_shortcuts(".markdown_content");
|
||||||
keys_elem_list.forEach(function (key_elem) {
|
keys_elem_list.forEach((key_elem) => {
|
||||||
assert(key_elem.text(), key_elem.expected_key());
|
assert(key_elem.text(), key_elem.expected_key());
|
||||||
});
|
});
|
||||||
|
|
||||||
keys_elem_list = [];
|
keys_elem_list = [];
|
||||||
key_no = 1;
|
key_no = 1;
|
||||||
common.has_mac_keyboard = function () { return true; };
|
common.has_mac_keyboard = function () { return true; };
|
||||||
keys_to_test_mac.forEach(function (value, key) {
|
keys_to_test_mac.forEach((value, key) => {
|
||||||
keys_elem_list.push(get_key_stub_html(key, value, "hotkey_" + key_no));
|
keys_elem_list.push(get_key_stub_html(key, value, "hotkey_" + key_no));
|
||||||
key_no += 1;
|
key_no += 1;
|
||||||
});
|
});
|
||||||
|
@ -115,7 +115,7 @@ run_test('adjust_mac_shortcuts', () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
common.adjust_mac_shortcuts(".markdown_content");
|
common.adjust_mac_shortcuts(".markdown_content");
|
||||||
keys_elem_list.forEach(function (key_elem) {
|
keys_elem_list.forEach((key_elem) => {
|
||||||
assert.equal(key_elem.text(), key_elem.expected_key());
|
assert.equal(key_elem.text(), key_elem.expected_key());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ run_test('basics', () => {
|
||||||
return self;
|
return self;
|
||||||
}());
|
}());
|
||||||
|
|
||||||
set_global('$', function (sel) {
|
set_global('$', (sel) => {
|
||||||
if (sel.stub) {
|
if (sel.stub) {
|
||||||
// The component often redundantly re-wraps objects.
|
// The component often redundantly re-wraps objects.
|
||||||
return sel;
|
return sel;
|
||||||
|
|
|
@ -142,7 +142,7 @@ run_test('validate_stream_message_address_info', () => {
|
||||||
|
|
||||||
sub.subscribed = false;
|
sub.subscribed = false;
|
||||||
stream_data.add_sub(sub);
|
stream_data.add_sub(sub);
|
||||||
global.stub_templates(function (template_name) {
|
global.stub_templates((template_name) => {
|
||||||
assert.equal(template_name, 'compose_not_subscribed');
|
assert.equal(template_name, 'compose_not_subscribed');
|
||||||
return 'compose_not_subscribed_stub';
|
return 'compose_not_subscribed_stub';
|
||||||
});
|
});
|
||||||
|
@ -204,7 +204,7 @@ run_test('validate', () => {
|
||||||
$("#zephyr-mirror-error").is = noop;
|
$("#zephyr-mirror-error").is = noop;
|
||||||
$("#private_message_recipient").select(noop);
|
$("#private_message_recipient").select(noop);
|
||||||
|
|
||||||
global.stub_templates(function (fn) {
|
global.stub_templates((fn) => {
|
||||||
assert.equal(fn, 'input_pill');
|
assert.equal(fn, 'input_pill');
|
||||||
return '<div>pill-html</div>';
|
return '<div>pill-html</div>';
|
||||||
});
|
});
|
||||||
|
@ -325,7 +325,7 @@ run_test('validate_stream_message', () => {
|
||||||
assert.equal(stream_name, 'social');
|
assert.equal(stream_name, 'social');
|
||||||
return 16;
|
return 16;
|
||||||
};
|
};
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'compose_all_everyone');
|
assert.equal(template_name, 'compose_all_everyone');
|
||||||
assert.equal(data.count, 16);
|
assert.equal(data.count, 16);
|
||||||
return 'compose_all_everyone_stub';
|
return 'compose_all_everyone_stub';
|
||||||
|
@ -601,7 +601,7 @@ run_test('send_message', () => {
|
||||||
return stub_state;
|
return stub_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
global.patch_builtin('setTimeout', function (func) {
|
global.patch_builtin('setTimeout', (func) => {
|
||||||
func();
|
func();
|
||||||
});
|
});
|
||||||
global.server_events = {
|
global.server_events = {
|
||||||
|
@ -868,7 +868,7 @@ run_test('warn_if_private_stream_is_linked', () => {
|
||||||
const checks = [
|
const checks = [
|
||||||
(function () {
|
(function () {
|
||||||
let called;
|
let called;
|
||||||
global.stub_templates(function (template_name, context) {
|
global.stub_templates((template_name, context) => {
|
||||||
called = true;
|
called = true;
|
||||||
assert.equal(template_name, 'compose_private_stream_alert');
|
assert.equal(template_name, 'compose_private_stream_alert');
|
||||||
assert.equal(context.stream_name, 'Denmark');
|
assert.equal(context.stream_name, 'Denmark');
|
||||||
|
@ -1144,7 +1144,7 @@ run_test('warn_if_mentioning_unsubscribed_user', () => {
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
let called;
|
let called;
|
||||||
global.stub_templates(function (template_name, context) {
|
global.stub_templates((template_name, context) => {
|
||||||
called = true;
|
called = true;
|
||||||
assert.equal(template_name, 'compose_invite_users');
|
assert.equal(template_name, 'compose_invite_users');
|
||||||
assert.equal(context.user_id, 34);
|
assert.equal(context.user_id, 34);
|
||||||
|
|
|
@ -14,9 +14,7 @@ zrequire('composebox_typeahead');
|
||||||
zrequire('recent_senders');
|
zrequire('recent_senders');
|
||||||
zrequire('settings_org');
|
zrequire('settings_org');
|
||||||
const settings_config = zrequire('settings_config');
|
const settings_config = zrequire('settings_config');
|
||||||
set_global('md5', function (s) {
|
set_global('md5', (s) => 'md5-' + s);
|
||||||
return 'md5-' + s;
|
|
||||||
});
|
|
||||||
|
|
||||||
// To be eliminated in next commit:
|
// To be eliminated in next commit:
|
||||||
stream_data.update_calculated_fields = () => {};
|
stream_data.update_calculated_fields = () => {};
|
||||||
|
@ -320,7 +318,7 @@ run_test('content_typeahead_selected', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
let set_timeout_called = false;
|
let set_timeout_called = false;
|
||||||
global.patch_builtin('setTimeout', function (f, time) {
|
global.patch_builtin('setTimeout', (f, time) => {
|
||||||
f();
|
f();
|
||||||
assert.equal(time, 0);
|
assert.equal(time, 0);
|
||||||
set_timeout_called = true;
|
set_timeout_called = true;
|
||||||
|
|
|
@ -129,7 +129,7 @@ function assert_same(actual, expected) {
|
||||||
|
|
||||||
const with_overrides = global.with_overrides; // make lint happy
|
const with_overrides = global.with_overrides; // make lint happy
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// alert_words
|
// alert_words
|
||||||
assert(!alert_words.has_alert_word('fire'));
|
assert(!alert_words.has_alert_word('fire'));
|
||||||
assert(!alert_words.has_alert_word('lunch'));
|
assert(!alert_words.has_alert_word('lunch'));
|
||||||
|
@ -146,21 +146,21 @@ with_overrides(function (override) {
|
||||||
assert(alert_words.has_alert_word('lunch'));
|
assert(alert_words.has_alert_word('lunch'));
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// attachments
|
// attachments
|
||||||
const event = event_fixtures.attachment;
|
const event = event_fixtures.attachment;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('attachments_ui.update_attachments', stub.f);
|
override('attachments_ui.update_attachments', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(stub.get_args('event').event, event);
|
assert_same(stub.get_args('event').event, event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// User groups
|
// User groups
|
||||||
let event = event_fixtures.user_group__add;
|
let event = event_fixtures.user_group__add;
|
||||||
override('settings_user_groups.reload', noop);
|
override('settings_user_groups.reload', noop);
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('user_groups.add', stub.f);
|
override('user_groups.add', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('group');
|
const args = stub.get_args('group');
|
||||||
|
@ -168,7 +168,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.user_group__add_members;
|
event = event_fixtures.user_group__add_members;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('user_groups.add_members', stub.f);
|
override('user_groups.add_members', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('group_id', 'user_ids');
|
const args = stub.get_args('group_id', 'user_ids');
|
||||||
|
@ -177,7 +177,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.user_group__remove_members;
|
event = event_fixtures.user_group__remove_members;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('user_groups.remove_members', stub.f);
|
override('user_groups.remove_members', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('group_id', 'user_ids');
|
const args = stub.get_args('group_id', 'user_ids');
|
||||||
|
@ -186,7 +186,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.user_group__update;
|
event = event_fixtures.user_group__update;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('user_groups.update', stub.f);
|
override('user_groups.update', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('event');
|
const args = stub.get_args('event');
|
||||||
|
@ -196,7 +196,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// custom profile fields
|
// custom profile fields
|
||||||
const event = event_fixtures.custom_profile_fields;
|
const event = event_fixtures.custom_profile_fields;
|
||||||
override('settings_profile_fields.populate_profile_fields', noop);
|
override('settings_profile_fields.populate_profile_fields', noop);
|
||||||
|
@ -206,11 +206,11 @@ with_overrides(function (override) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// default_streams
|
// default_streams
|
||||||
const event = event_fixtures.default_streams;
|
const event = event_fixtures.default_streams;
|
||||||
override('settings_streams.update_default_streams_table', noop);
|
override('settings_streams.update_default_streams_table', noop);
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_data.set_realm_default_streams', stub.f);
|
override('stream_data.set_realm_default_streams', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('realm_default_streams');
|
const args = stub.get_args('realm_default_streams');
|
||||||
|
@ -219,7 +219,7 @@ with_overrides(function (override) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// hotspots
|
// hotspots
|
||||||
const event = event_fixtures.hotspots;
|
const event = event_fixtures.hotspots;
|
||||||
override('hotspots.load_new', noop);
|
override('hotspots.load_new', noop);
|
||||||
|
@ -227,21 +227,21 @@ with_overrides(function (override) {
|
||||||
assert_same(page_params.hotspots, event.hotspots);
|
assert_same(page_params.hotspots, event.hotspots);
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// invites_changed
|
// invites_changed
|
||||||
const event = event_fixtures.invites_changed;
|
const event = event_fixtures.invites_changed;
|
||||||
$('#admin-invites-list').length = 1;
|
$('#admin-invites-list').length = 1;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('settings_invites.set_up', stub.f);
|
override('settings_invites.set_up', stub.f);
|
||||||
dispatch(event); // stub automatically checks if stub.f is called once
|
dispatch(event); // stub automatically checks if stub.f is called once
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// muted_topics
|
// muted_topics
|
||||||
const event = event_fixtures.muted_topics;
|
const event = event_fixtures.muted_topics;
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('muting_ui.handle_updates', stub.f);
|
override('muting_ui.handle_updates', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('muted_topics');
|
const args = stub.get_args('muted_topics');
|
||||||
|
@ -249,11 +249,11 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// presence
|
// presence
|
||||||
const event = event_fixtures.presence;
|
const event = event_fixtures.presence;
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('activity.update_presence_info', stub.f);
|
override('activity.update_presence_info', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('user_id', 'presence', 'server_time');
|
const args = stub.get_args('user_id', 'presence', 'server_time');
|
||||||
|
@ -263,10 +263,10 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// reaction
|
// reaction
|
||||||
let event = event_fixtures.reaction__add;
|
let event = event_fixtures.reaction__add;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('reactions.add_reaction', stub.f);
|
override('reactions.add_reaction', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('event');
|
const args = stub.get_args('event');
|
||||||
|
@ -275,7 +275,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.reaction__remove;
|
event = event_fixtures.reaction__remove;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('reactions.remove_reaction', stub.f);
|
override('reactions.remove_reaction', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('event');
|
const args = stub.get_args('event');
|
||||||
|
@ -284,7 +284,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// realm
|
// realm
|
||||||
function test_realm_boolean(event, parameter_name) {
|
function test_realm_boolean(event, parameter_name) {
|
||||||
page_params[parameter_name] = true;
|
page_params[parameter_name] = true;
|
||||||
|
@ -417,11 +417,11 @@ with_overrides(function (override) {
|
||||||
assert_same(window.location.href, "/accounts/deactivated/");
|
assert_same(window.location.href, "/accounts/deactivated/");
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// realm_bot
|
// realm_bot
|
||||||
let event = event_fixtures.realm_bot__add;
|
let event = event_fixtures.realm_bot__add;
|
||||||
global.with_stub(function (bot_stub) {
|
global.with_stub((bot_stub) => {
|
||||||
global.with_stub(function (admin_stub) {
|
global.with_stub((admin_stub) => {
|
||||||
override('bot_data.add', bot_stub.f);
|
override('bot_data.add', bot_stub.f);
|
||||||
override('settings_users.update_bot_data', admin_stub.f);
|
override('settings_users.update_bot_data', admin_stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
@ -433,8 +433,8 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.realm_bot__remove;
|
event = event_fixtures.realm_bot__remove;
|
||||||
global.with_stub(function (bot_stub) {
|
global.with_stub((bot_stub) => {
|
||||||
global.with_stub(function (admin_stub) {
|
global.with_stub((admin_stub) => {
|
||||||
override('bot_data.deactivate', bot_stub.f);
|
override('bot_data.deactivate', bot_stub.f);
|
||||||
override('settings_users.update_bot_data', admin_stub.f);
|
override('settings_users.update_bot_data', admin_stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
@ -450,8 +450,8 @@ with_overrides(function (override) {
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
|
||||||
event = event_fixtures.realm_bot__update;
|
event = event_fixtures.realm_bot__update;
|
||||||
global.with_stub(function (bot_stub) {
|
global.with_stub((bot_stub) => {
|
||||||
global.with_stub(function (admin_stub) {
|
global.with_stub((admin_stub) => {
|
||||||
override('bot_data.update', bot_stub.f);
|
override('bot_data.update', bot_stub.f);
|
||||||
override('settings_users.update_bot_data', admin_stub.f);
|
override('settings_users.update_bot_data', admin_stub.f);
|
||||||
|
|
||||||
|
@ -467,11 +467,11 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// realm_emoji
|
// realm_emoji
|
||||||
const event = event_fixtures.realm_emoji;
|
const event = event_fixtures.realm_emoji;
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('emoji.update_emojis', stub.f);
|
override('emoji.update_emojis', stub.f);
|
||||||
override('settings_emoji.populate_emoji', noop);
|
override('settings_emoji.populate_emoji', noop);
|
||||||
override('emoji_picker.generate_emoji_picker_data', noop);
|
override('emoji_picker.generate_emoji_picker_data', noop);
|
||||||
|
@ -482,7 +482,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// realm_filters
|
// realm_filters
|
||||||
const event = event_fixtures.realm_filters;
|
const event = event_fixtures.realm_filters;
|
||||||
page_params.realm_filters = [];
|
page_params.realm_filters = [];
|
||||||
|
@ -492,7 +492,7 @@ with_overrides(function (override) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// realm_domains
|
// realm_domains
|
||||||
let event = event_fixtures.realm_domains__add;
|
let event = event_fixtures.realm_domains__add;
|
||||||
page_params.realm_domains = [];
|
page_params.realm_domains = [];
|
||||||
|
@ -509,7 +509,7 @@ with_overrides(function (override) {
|
||||||
assert_same(page_params.realm_domains, []);
|
assert_same(page_params.realm_domains, []);
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// realm_user
|
// realm_user
|
||||||
let event = event_fixtures.realm_user__add;
|
let event = event_fixtures.realm_user__add;
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
@ -527,7 +527,7 @@ with_overrides(function (override) {
|
||||||
assert(!people.is_active_user_for_popover(event.person.user_id));
|
assert(!people.is_active_user_for_popover(event.person.user_id));
|
||||||
|
|
||||||
event = event_fixtures.realm_user__update;
|
event = event_fixtures.realm_user__update;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('user_events.update_person', stub.f);
|
override('user_events.update_person', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('person');
|
const args = stub.get_args('person');
|
||||||
|
@ -535,10 +535,10 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// restart
|
// restart
|
||||||
const event = event_fixtures.restart;
|
const event = event_fixtures.restart;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('reload.initiate', stub.f);
|
override('reload.initiate', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('options');
|
const args = stub.get_args('options');
|
||||||
|
@ -547,11 +547,11 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// stream update
|
// stream update
|
||||||
let event = event_fixtures.stream__update;
|
let event = event_fixtures.stream__update;
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_events.update_property', stub.f);
|
override('stream_events.update_property', stub.f);
|
||||||
override('settings_streams.update_default_streams_table', noop);
|
override('settings_streams.update_default_streams_table', noop);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
@ -563,7 +563,7 @@ with_overrides(function (override) {
|
||||||
|
|
||||||
// stream create
|
// stream create
|
||||||
event = event_fixtures.stream__create;
|
event = event_fixtures.stream__create;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_data.create_streams', stub.f);
|
override('stream_data.create_streams', stub.f);
|
||||||
override('stream_data.get_sub_by_id', noop);
|
override('stream_data.get_sub_by_id', noop);
|
||||||
override('stream_data.update_calculated_fields', noop);
|
override('stream_data.update_calculated_fields', noop);
|
||||||
|
@ -575,15 +575,13 @@ with_overrides(function (override) {
|
||||||
|
|
||||||
// stream delete
|
// stream delete
|
||||||
event = event_fixtures.stream__delete;
|
event = event_fixtures.stream__delete;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.remove_stream', noop);
|
override('subs.remove_stream', noop);
|
||||||
override('stream_data.delete_sub', noop);
|
override('stream_data.delete_sub', noop);
|
||||||
override('settings_streams.update_default_streams_table', noop);
|
override('settings_streams.update_default_streams_table', noop);
|
||||||
override('stream_data.remove_default_stream', noop);
|
override('stream_data.remove_default_stream', noop);
|
||||||
|
|
||||||
override('stream_data.get_sub_by_id', function (id) {
|
override('stream_data.get_sub_by_id', (id) => id === 42 ? {subscribed: true} : {subscribed: false});
|
||||||
return id === 42 ? {subscribed: true} : {subscribed: false};
|
|
||||||
});
|
|
||||||
override('stream_list.remove_sidebar_row', stub.f);
|
override('stream_list.remove_sidebar_row', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('stream_id');
|
const args = stub.get_args('stream_id');
|
||||||
|
@ -600,10 +598,10 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// submessage
|
// submessage
|
||||||
const event = event_fixtures.submessage;
|
const event = event_fixtures.submessage;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('submessage.handle_event', stub.f);
|
override('submessage.handle_event', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const submsg = stub.get_args('submsg').submsg;
|
const submsg = stub.get_args('submsg').submsg;
|
||||||
|
@ -619,10 +617,10 @@ with_overrides(function (override) {
|
||||||
|
|
||||||
// For subscriptions, see dispatch_subs.js
|
// For subscriptions, see dispatch_subs.js
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// typing
|
// typing
|
||||||
let event = event_fixtures.typing__start;
|
let event = event_fixtures.typing__start;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('typing_events.display_notification', stub.f);
|
override('typing_events.display_notification', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('event');
|
const args = stub.get_args('event');
|
||||||
|
@ -630,7 +628,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.typing__stop;
|
event = event_fixtures.typing__stop;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('typing_events.hide_notification', stub.f);
|
override('typing_events.hide_notification', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('event');
|
const args = stub.get_args('event');
|
||||||
|
@ -642,7 +640,7 @@ with_overrides(function (override) {
|
||||||
dispatch(event); // get line coverage
|
dispatch(event); // get line coverage
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// update_display_settings
|
// update_display_settings
|
||||||
let event = event_fixtures.update_display_settings__default_language;
|
let event = event_fixtures.update_display_settings__default_language;
|
||||||
page_params.default_language = 'en';
|
page_params.default_language = 'en';
|
||||||
|
@ -691,7 +689,7 @@ with_overrides(function (override) {
|
||||||
$("body").fadeOut = (secs) => { assert_same(secs, 300); };
|
$("body").fadeOut = (secs) => { assert_same(secs, 300); };
|
||||||
$("body").fadeIn = (secs) => { assert_same(secs, 300); };
|
$("body").fadeIn = (secs) => { assert_same(secs, 300); };
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
event = event_fixtures.update_display_settings__color_scheme_dark;
|
event = event_fixtures.update_display_settings__color_scheme_dark;
|
||||||
page_params.color_scheme = 1;
|
page_params.color_scheme = 1;
|
||||||
override('night_mode.enable', stub.f); // automatically checks if called
|
override('night_mode.enable', stub.f); // automatically checks if called
|
||||||
|
@ -700,7 +698,7 @@ with_overrides(function (override) {
|
||||||
assert(page_params.color_scheme, 2);
|
assert(page_params.color_scheme, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
event = event_fixtures.update_display_settings__color_scheme_light;
|
event = event_fixtures.update_display_settings__color_scheme_light;
|
||||||
page_params.color_scheme = 1;
|
page_params.color_scheme = 1;
|
||||||
override('night_mode.disable', stub.f); // automatically checks if called
|
override('night_mode.disable', stub.f); // automatically checks if called
|
||||||
|
@ -709,7 +707,7 @@ with_overrides(function (override) {
|
||||||
assert(page_params.color_scheme, 3);
|
assert(page_params.color_scheme, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
event = event_fixtures.update_display_settings__color_scheme_automatic;
|
event = event_fixtures.update_display_settings__color_scheme_automatic;
|
||||||
page_params.color_scheme = 2;
|
page_params.color_scheme = 2;
|
||||||
override('night_mode.default_preference_checker', stub.f); // automatically checks if called
|
override('night_mode.default_preference_checker', stub.f); // automatically checks if called
|
||||||
|
@ -718,7 +716,7 @@ with_overrides(function (override) {
|
||||||
assert(page_params.color_scheme, 1);
|
assert(page_params.color_scheme, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
event = event_fixtures.update_display_settings__emojiset;
|
event = event_fixtures.update_display_settings__emojiset;
|
||||||
called = false;
|
called = false;
|
||||||
override('settings_display.report_emojiset_change', stub.f);
|
override('settings_display.report_emojiset_change', stub.f);
|
||||||
|
@ -740,7 +738,7 @@ with_overrides(function (override) {
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(page_params.fluid_layout_width, true);
|
assert_same(page_params.fluid_layout_width, true);
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
event = event_fixtures.update_display_settings__demote_inactive_streams;
|
event = event_fixtures.update_display_settings__demote_inactive_streams;
|
||||||
override('stream_data.set_filter_out_inactives', noop);
|
override('stream_data.set_filter_out_inactives', noop);
|
||||||
override('stream_list.update_streams_sidebar', stub.f);
|
override('stream_list.update_streams_sidebar', stub.f);
|
||||||
|
@ -750,10 +748,10 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// update_global_notifications
|
// update_global_notifications
|
||||||
const event = event_fixtures.update_global_notifications;
|
const event = event_fixtures.update_global_notifications;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('notifications.handle_global_notification_updates', stub.f);
|
override('notifications.handle_global_notification_updates', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('name', 'setting');
|
const args = stub.get_args('name', 'setting');
|
||||||
|
@ -762,11 +760,11 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// update_message_flags__read
|
// update_message_flags__read
|
||||||
const event = event_fixtures.update_message_flags__read;
|
const event = event_fixtures.update_message_flags__read;
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('unread_ops.process_read_messages_event', stub.f);
|
override('unread_ops.process_read_messages_event', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('message_ids');
|
const args = stub.get_args('message_ids');
|
||||||
|
@ -774,13 +772,13 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// update_message_flags__starred
|
// update_message_flags__starred
|
||||||
|
|
||||||
override('starred_messages.rerender_ui', noop);
|
override('starred_messages.rerender_ui', noop);
|
||||||
|
|
||||||
let event = event_fixtures.update_message_flags__starred_add;
|
let event = event_fixtures.update_message_flags__starred_add;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('ui.update_starred_view', stub.f);
|
override('ui.update_starred_view', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('message_id', 'new_value');
|
const args = stub.get_args('message_id', 'new_value');
|
||||||
|
@ -791,7 +789,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.update_message_flags__starred_remove;
|
event = event_fixtures.update_message_flags__starred_remove;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('ui.update_starred_view', stub.f);
|
override('ui.update_starred_view', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('message_id', 'new_value');
|
const args = stub.get_args('message_id', 'new_value');
|
||||||
|
@ -802,25 +800,25 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// delete_message
|
// delete_message
|
||||||
const event = event_fixtures.delete_message;
|
const event = event_fixtures.delete_message;
|
||||||
|
|
||||||
override('stream_list.update_streams_sidebar', noop);
|
override('stream_list.update_streams_sidebar', noop);
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('unread_ops.process_read_messages_event', noop);
|
override('unread_ops.process_read_messages_event', noop);
|
||||||
override('ui.remove_messages', stub.f);
|
override('ui.remove_messages', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('message_ids');
|
const args = stub.get_args('message_ids');
|
||||||
assert_same(args.message_ids, [1337]);
|
assert_same(args.message_ids, [1337]);
|
||||||
});
|
});
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('unread_ops.process_read_messages_event', stub.f);
|
override('unread_ops.process_read_messages_event', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('message_ids');
|
const args = stub.get_args('message_ids');
|
||||||
assert_same(args.message_ids, [1337]);
|
assert_same(args.message_ids, [1337]);
|
||||||
});
|
});
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_topic_history.remove_messages', stub.f);
|
override('stream_topic_history.remove_messages', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('opts');
|
const args = stub.get_args('opts');
|
||||||
|
@ -830,10 +828,10 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
// attachments
|
// attachments
|
||||||
let event = event_fixtures.user_status__set_away;
|
let event = event_fixtures.user_status__set_away;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('activity.on_set_away', stub.f);
|
override('activity.on_set_away', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('user_id');
|
const args = stub.get_args('user_id');
|
||||||
|
@ -841,7 +839,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.user_status__revoke_away;
|
event = event_fixtures.user_status__revoke_away;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('activity.on_revoke_away', stub.f);
|
override('activity.on_revoke_away', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('user_id');
|
const args = stub.get_args('user_id');
|
||||||
|
@ -849,7 +847,7 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
|
|
||||||
event = event_fixtures.user_status__set_status_text;
|
event = event_fixtures.user_status__set_status_text;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('activity.redraw_user', stub.f);
|
override('activity.redraw_user', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('user_id');
|
const args = stub.get_args('user_id');
|
||||||
|
@ -859,11 +857,11 @@ with_overrides(function (override) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
const event = event_fixtures.realm_export;
|
const event = event_fixtures.realm_export;
|
||||||
override('settings_exports.populate_exports_table', noop);
|
override('settings_exports.populate_exports_table', noop);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('settings_exports.populate_exports_table', stub.f);
|
override('settings_exports.populate_exports_table', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ test('add', (override) => {
|
||||||
name: sub.name,
|
name: sub.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
global.with_stub(function (subscription_stub) {
|
global.with_stub((subscription_stub) => {
|
||||||
override('stream_events.mark_subscribed', subscription_stub.f);
|
override('stream_events.mark_subscribed', subscription_stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = subscription_stub.get_args('sub', 'subscribers');
|
const args = subscription_stub.get_args('sub', 'subscribers');
|
||||||
|
@ -77,7 +77,7 @@ test('remove', (override) => {
|
||||||
|
|
||||||
stream_data.add_sub(sub);
|
stream_data.add_sub(sub);
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_events.mark_unsubscribed', stub.f);
|
override('stream_events.mark_unsubscribed', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('sub');
|
const args = stub.get_args('sub');
|
||||||
|
@ -87,7 +87,7 @@ test('remove', (override) => {
|
||||||
|
|
||||||
test('update', (override) => {
|
test('update', (override) => {
|
||||||
const event = event_fixtures.subscription__update;
|
const event = event_fixtures.subscription__update;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_events.update_property', stub.f);
|
override('stream_events.update_property', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
const args = stub.get_args('stream_id', 'property', 'value');
|
const args = stub.get_args('stream_id', 'property', 'value');
|
||||||
|
@ -100,7 +100,7 @@ test('update', (override) => {
|
||||||
test('add error handling', (override) => {
|
test('add error handling', (override) => {
|
||||||
// test blueslip errors/warns
|
// test blueslip errors/warns
|
||||||
const event = event_fixtures.subscription__add;
|
const event = event_fixtures.subscription__add;
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('blueslip.error', stub.f);
|
override('blueslip.error', stub.f);
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert.deepEqual(stub.get_args('param').param, 'Subscribing to unknown stream with ID 42');
|
assert.deepEqual(stub.get_args('param').param, 'Subscribing to unknown stream with ID 42');
|
||||||
|
|
|
@ -119,7 +119,7 @@ run_test('draft_model', () => {
|
||||||
|
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
(function test_addDraft() {
|
(function test_addDraft() {
|
||||||
stub_timestamp(1, function () {
|
stub_timestamp(1, () => {
|
||||||
const expected = { ...draft_1 };
|
const expected = { ...draft_1 };
|
||||||
expected.updatedAt = 1;
|
expected.updatedAt = 1;
|
||||||
const id = draft_model.addDraft({ ...draft_1 });
|
const id = draft_model.addDraft({ ...draft_1 });
|
||||||
|
@ -130,7 +130,7 @@ run_test('draft_model', () => {
|
||||||
|
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
(function test_editDraft() {
|
(function test_editDraft() {
|
||||||
stub_timestamp(2, function () {
|
stub_timestamp(2, () => {
|
||||||
ls.set("drafts", { id1: draft_1 });
|
ls.set("drafts", { id1: draft_1 });
|
||||||
const expected = { ...draft_2 };
|
const expected = { ...draft_2 };
|
||||||
expected.updatedAt = 2;
|
expected.updatedAt = 2;
|
||||||
|
@ -313,7 +313,7 @@ run_test('format_drafts', () => {
|
||||||
return stub_render_now(time, new XDate(1549958107000));
|
return stub_render_now(time, new XDate(1549958107000));
|
||||||
};
|
};
|
||||||
|
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'draft_table_body');
|
assert.equal(template_name, 'draft_table_body');
|
||||||
// Tests formatting and sorting of drafts
|
// Tests formatting and sorting of drafts
|
||||||
assert.deepEqual(data.drafts, expected);
|
assert.deepEqual(data.drafts, expected);
|
||||||
|
|
|
@ -59,8 +59,8 @@ function return_true() { return true; }
|
||||||
function return_false() { return false; }
|
function return_false() { return false; }
|
||||||
|
|
||||||
function stubbing(func_name_to_stub, test_function) {
|
function stubbing(func_name_to_stub, test_function) {
|
||||||
global.with_overrides(function (override) {
|
global.with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override(func_name_to_stub, stub.f);
|
override(func_name_to_stub, stub.f);
|
||||||
test_function(stub);
|
test_function(stub);
|
||||||
});
|
});
|
||||||
|
@ -165,7 +165,7 @@ run_test('basic_chars', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function assert_mapping(c, func_name, shiftKey) {
|
function assert_mapping(c, func_name, shiftKey) {
|
||||||
stubbing(func_name, function () {
|
stubbing(func_name, () => {
|
||||||
assert(process(c, shiftKey));
|
assert(process(c, shiftKey));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -370,7 +370,7 @@ run_test('motion_keys', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function assert_mapping(key_name, func_name, shiftKey, ctrlKey) {
|
function assert_mapping(key_name, func_name, shiftKey, ctrlKey) {
|
||||||
stubbing(func_name, function () {
|
stubbing(func_name, () => {
|
||||||
assert(process(key_name, shiftKey, ctrlKey));
|
assert(process(key_name, shiftKey, ctrlKey));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ run_test('paste to input', () => {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let entered = false;
|
let entered = false;
|
||||||
widget.createPillonPaste(function () {
|
widget.createPillonPaste(() => {
|
||||||
entered = true;
|
entered = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -385,11 +385,11 @@ run_test('insert_remove', () => {
|
||||||
let created;
|
let created;
|
||||||
let removed;
|
let removed;
|
||||||
|
|
||||||
widget.onPillCreate(function () {
|
widget.onPillCreate(() => {
|
||||||
created = true;
|
created = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.onPillRemove(function () {
|
widget.onPillRemove(() => {
|
||||||
removed = true;
|
removed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -233,11 +233,11 @@ run_test('markdown_detection', () => {
|
||||||
"youtube url https://www.youtube.com/watch?v=HHZ8iqswiCw&feature=youtu.be&a",
|
"youtube url https://www.youtube.com/watch?v=HHZ8iqswiCw&feature=youtu.be&a",
|
||||||
];
|
];
|
||||||
|
|
||||||
no_markup.forEach(function (content) {
|
no_markup.forEach((content) => {
|
||||||
assert.equal(markdown.contains_backend_only_syntax(content), false);
|
assert.equal(markdown.contains_backend_only_syntax(content), false);
|
||||||
});
|
});
|
||||||
|
|
||||||
markup.forEach(function (content) {
|
markup.forEach((content) => {
|
||||||
assert.equal(markdown.contains_backend_only_syntax(content), true);
|
assert.equal(markdown.contains_backend_only_syntax(content), true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -245,7 +245,7 @@ run_test('markdown_detection', () => {
|
||||||
run_test('marked_shared', () => {
|
run_test('marked_shared', () => {
|
||||||
const tests = markdown_data.regular_tests;
|
const tests = markdown_data.regular_tests;
|
||||||
|
|
||||||
tests.forEach(function (test) {
|
tests.forEach((test) => {
|
||||||
|
|
||||||
// Ignore tests if specified
|
// Ignore tests if specified
|
||||||
if (test.ignore === true) {
|
if (test.ignore === true) {
|
||||||
|
@ -423,7 +423,7 @@ run_test('marked', () => {
|
||||||
// isn't present in emoji_codes.codepoint_to_name.
|
// isn't present in emoji_codes.codepoint_to_name.
|
||||||
delete emoji_codes.codepoint_to_name['1f6b2'];
|
delete emoji_codes.codepoint_to_name['1f6b2'];
|
||||||
|
|
||||||
test_cases.forEach(function (test_case) {
|
test_cases.forEach((test_case) => {
|
||||||
// Disable emoji conversion by default.
|
// Disable emoji conversion by default.
|
||||||
page_params.translate_emoticons = test_case.translate_emoticons || false;
|
page_params.translate_emoticons = test_case.translate_emoticons || false;
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ run_test('backend_only_realm_filters', () => {
|
||||||
'Here is the PR-#123.',
|
'Here is the PR-#123.',
|
||||||
'Function abc() was introduced in (PR)#123.',
|
'Function abc() was introduced in (PR)#123.',
|
||||||
];
|
];
|
||||||
backend_only_realm_filters.forEach(function (content) {
|
backend_only_realm_filters.forEach((content) => {
|
||||||
assert.equal(markdown.contains_backend_only_syntax(content), true);
|
assert.equal(markdown.contains_backend_only_syntax(content), true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -111,9 +111,7 @@ run_test('basics', () => {
|
||||||
list.view.clear_table = function () {};
|
list.view.clear_table = function () {};
|
||||||
|
|
||||||
list.remove_and_rerender([{id: 60}]);
|
list.remove_and_rerender([{id: 60}]);
|
||||||
const removed = list.all_messages().filter(function (msg) {
|
const removed = list.all_messages().filter((msg) => msg.id !== 60);
|
||||||
return msg.id !== 60;
|
|
||||||
});
|
|
||||||
assert.deepEqual(list.all_messages(), removed);
|
assert.deepEqual(list.all_messages(), removed);
|
||||||
|
|
||||||
list.clear();
|
list.clear();
|
||||||
|
@ -312,20 +310,16 @@ run_test('local_echo', () => {
|
||||||
run_test('bookend', () => {
|
run_test('bookend', () => {
|
||||||
const list = new MessageList({});
|
const list = new MessageList({});
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
let expected = "translated: You subscribed to stream IceCream";
|
let expected = "translated: You subscribed to stream IceCream";
|
||||||
list.view.clear_trailing_bookend = noop;
|
list.view.clear_trailing_bookend = noop;
|
||||||
list.narrowed = true;
|
list.narrowed = true;
|
||||||
|
|
||||||
override("narrow_state.stream", function () {
|
override("narrow_state.stream", () => "IceCream");
|
||||||
return "IceCream";
|
|
||||||
});
|
|
||||||
|
|
||||||
override("stream_data.is_subscribed", function () {
|
override("stream_data.is_subscribed", () => true);
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
list.view.render_trailing_bookend = stub.f;
|
list.view.render_trailing_bookend = stub.f;
|
||||||
list.update_trailing_bookend();
|
list.update_trailing_bookend();
|
||||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||||
|
@ -336,15 +330,11 @@ run_test('bookend', () => {
|
||||||
|
|
||||||
expected = "translated: You unsubscribed from stream IceCream";
|
expected = "translated: You unsubscribed from stream IceCream";
|
||||||
list.last_message_historical = false;
|
list.last_message_historical = false;
|
||||||
override("stream_data.is_subscribed", function () {
|
override("stream_data.is_subscribed", () => false);
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
override("stream_data.get_sub", function () {
|
override("stream_data.get_sub", () => ({invite_only: false}));
|
||||||
return {invite_only: false};
|
|
||||||
});
|
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
list.view.render_trailing_bookend = stub.f;
|
list.view.render_trailing_bookend = stub.f;
|
||||||
list.update_trailing_bookend();
|
list.update_trailing_bookend();
|
||||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||||
|
@ -355,15 +345,11 @@ run_test('bookend', () => {
|
||||||
|
|
||||||
// Test when the stream is privates (invite only)
|
// Test when the stream is privates (invite only)
|
||||||
expected = "translated: You unsubscribed from stream IceCream";
|
expected = "translated: You unsubscribed from stream IceCream";
|
||||||
override("stream_data.is_subscribed", function () {
|
override("stream_data.is_subscribed", () => false);
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
override("stream_data.get_sub", function () {
|
override("stream_data.get_sub", () => ({invite_only: true}));
|
||||||
return {invite_only: true};
|
|
||||||
});
|
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
list.view.render_trailing_bookend = stub.f;
|
list.view.render_trailing_bookend = stub.f;
|
||||||
list.update_trailing_bookend();
|
list.update_trailing_bookend();
|
||||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||||
|
@ -375,7 +361,7 @@ run_test('bookend', () => {
|
||||||
expected = "translated: You are not subscribed to stream IceCream";
|
expected = "translated: You are not subscribed to stream IceCream";
|
||||||
list.last_message_historical = true;
|
list.last_message_historical = true;
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
list.view.render_trailing_bookend = stub.f;
|
list.view.render_trailing_bookend = stub.f;
|
||||||
list.update_trailing_bookend();
|
list.update_trailing_bookend();
|
||||||
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
const bookend = stub.get_args('content', 'subscribed', 'show_button');
|
||||||
|
@ -414,10 +400,8 @@ run_test('unmuted_messages', () => {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
override('muting.is_topic_muted', function (stream_id) {
|
override('muting.is_topic_muted', (stream_id) => stream_id === muted_stream_id);
|
||||||
return stream_id === muted_stream_id;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Make sure unmuted_message filters out the "muted" entry,
|
// Make sure unmuted_message filters out the "muted" entry,
|
||||||
// which we mark as having a muted topic, and not mentioned.
|
// which we mark as having a muted topic, and not mentioned.
|
||||||
|
@ -437,7 +421,7 @@ run_test('add_remove_rerender', () => {
|
||||||
list.add_messages(messages);
|
list.add_messages(messages);
|
||||||
assert.equal(list.num_items(), 3);
|
assert.equal(list.num_items(), 3);
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
list.rerender = stub.f;
|
list.rerender = stub.f;
|
||||||
list.remove_and_rerender(messages);
|
list.remove_and_rerender(messages);
|
||||||
assert.equal(stub.num_calls, 1);
|
assert.equal(stub.num_calls, 1);
|
||||||
|
|
|
@ -279,7 +279,7 @@ run_test('message_id_change', () => {
|
||||||
new_id: 402,
|
new_id: 402,
|
||||||
};
|
};
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
home_msg_list.change_message_id = stub.f;
|
home_msg_list.change_message_id = stub.f;
|
||||||
message_store.reify_message_id(opts);
|
message_store.reify_message_id(opts);
|
||||||
const msg_id = stub.get_args('old', 'new');
|
const msg_id = stub.get_args('old', 'new');
|
||||||
|
@ -288,7 +288,7 @@ run_test('message_id_change', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
home_msg_list.view = {};
|
home_msg_list.view = {};
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
home_msg_list.view.change_message_id = stub.f;
|
home_msg_list.view.change_message_id = stub.f;
|
||||||
message_store.reify_message_id(opts);
|
message_store.reify_message_id(opts);
|
||||||
const msg_id = stub.get_args('old', 'new');
|
const msg_id = stub.get_args('old', 'new');
|
||||||
|
|
|
@ -2,9 +2,7 @@ zrequire('people');
|
||||||
set_global('message_store', {});
|
set_global('message_store', {});
|
||||||
set_global('page_params', {});
|
set_global('page_params', {});
|
||||||
set_global('settings_data', {});
|
set_global('settings_data', {});
|
||||||
set_global('md5', function (s) {
|
set_global('md5', (s) => 'md5-' + s);
|
||||||
return 'md5-' + s;
|
|
||||||
});
|
|
||||||
|
|
||||||
const settings_config = zrequire('settings_config');
|
const settings_config = zrequire('settings_config');
|
||||||
const visibility = settings_config.email_address_visibility_values;
|
const visibility = settings_config.email_address_visibility_values;
|
||||||
|
@ -401,7 +399,7 @@ run_test('user_timezone', () => {
|
||||||
assert.deepEqual(people.get_user_time_preferences(me.user_id), expected_pref);
|
assert.deepEqual(people.get_user_time_preferences(me.user_id), expected_pref);
|
||||||
|
|
||||||
const actual_moment = zrequire('actual_moment', 'moment-timezone');
|
const actual_moment = zrequire('actual_moment', 'moment-timezone');
|
||||||
set_global('moment', function () { return actual_moment('20130208T080910'); });
|
set_global('moment', () => actual_moment('20130208T080910'));
|
||||||
|
|
||||||
global.page_params.twenty_four_hour_time = true;
|
global.page_params.twenty_four_hour_time = true;
|
||||||
assert.equal(people.get_user_time(me.user_id), '0:09');
|
assert.equal(people.get_user_time(me.user_id), '0:09');
|
||||||
|
@ -1100,7 +1098,7 @@ run_test('is_valid_full_name_and_user_id', () => {
|
||||||
assert(people.is_valid_full_name_and_user_id(me.full_name, me.user_id));
|
assert(people.is_valid_full_name_and_user_id(me.full_name, me.user_id));
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('emails_strings_to_user_ids_array', function () {
|
run_test('emails_strings_to_user_ids_array', () => {
|
||||||
people.add_active_user(steven);
|
people.add_active_user(steven);
|
||||||
people.add_active_user(maria);
|
people.add_active_user(maria);
|
||||||
|
|
||||||
|
@ -1112,7 +1110,7 @@ run_test('emails_strings_to_user_ids_array', function () {
|
||||||
assert.equal(user_ids, undefined);
|
assert.equal(user_ids, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('get_visible_email', function () {
|
run_test('get_visible_email', () => {
|
||||||
people.add_active_user(steven);
|
people.add_active_user(steven);
|
||||||
people.add_active_user(maria);
|
people.add_active_user(maria);
|
||||||
|
|
||||||
|
@ -1123,7 +1121,7 @@ run_test('get_visible_email', function () {
|
||||||
assert.equal(email, maria.email);
|
assert.equal(email, maria.email);
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('get_active_message_people', function () {
|
run_test('get_active_message_people', () => {
|
||||||
message_store.user_ids = () => [
|
message_store.user_ids = () => [
|
||||||
steven.user_id,
|
steven.user_id,
|
||||||
maria.user_id,
|
maria.user_id,
|
||||||
|
|
|
@ -135,7 +135,7 @@ run_test('sender_hover', () => {
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
||||||
global.stub_templates(function (fn, opts) {
|
global.stub_templates((fn, opts) => {
|
||||||
switch (fn) {
|
switch (fn) {
|
||||||
case 'no_arrow_popover':
|
case 'no_arrow_popover':
|
||||||
assert.deepEqual(opts, {
|
assert.deepEqual(opts, {
|
||||||
|
@ -229,7 +229,7 @@ run_test('actions_popover', () => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
global.stub_templates(function (fn, opts) {
|
global.stub_templates((fn, opts) => {
|
||||||
// TODO: Test all the properties of the popover
|
// TODO: Test all the properties of the popover
|
||||||
switch (fn) {
|
switch (fn) {
|
||||||
case 'actions_popover_content':
|
case 'actions_popover_content':
|
||||||
|
|
|
@ -123,7 +123,7 @@ run_test('basics', () => {
|
||||||
assert(reactions.current_user_has_reacted_to_emoji(message, 'unicode_emoji,263a'));
|
assert(reactions.current_user_has_reacted_to_emoji(message, 'unicode_emoji,263a'));
|
||||||
assert(!reactions.current_user_has_reacted_to_emoji(message, 'bogus'));
|
assert(!reactions.current_user_has_reacted_to_emoji(message, 'bogus'));
|
||||||
|
|
||||||
result.sort(function (a, b) { return a.count - b.count; });
|
result.sort((a, b) => a.count - b.count);
|
||||||
|
|
||||||
const expected_result = [
|
const expected_result = [
|
||||||
{
|
{
|
||||||
|
@ -174,7 +174,7 @@ run_test('sending', () => {
|
||||||
reactions.remove_reaction = function () {};
|
reactions.remove_reaction = function () {};
|
||||||
reactions.add_reaction = function () {};
|
reactions.add_reaction = function () {};
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
global.channel.del = stub.f;
|
global.channel.del = stub.f;
|
||||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||||
const args = stub.get_args('args').args;
|
const args = stub.get_args('args').args;
|
||||||
|
@ -194,7 +194,7 @@ run_test('sending', () => {
|
||||||
args.error();
|
args.error();
|
||||||
});
|
});
|
||||||
emoji_name = 'alien'; // not set yet
|
emoji_name = 'alien'; // not set yet
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
global.channel.post = stub.f;
|
global.channel.post = stub.f;
|
||||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||||
const args = stub.get_args('args').args;
|
const args = stub.get_args('args').args;
|
||||||
|
@ -207,7 +207,7 @@ run_test('sending', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
emoji_name = 'inactive_realm_emoji';
|
emoji_name = 'inactive_realm_emoji';
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
// Test removing a deactivated realm emoji. An user can interact with a
|
// Test removing a deactivated realm emoji. An user can interact with a
|
||||||
// deactivated realm emoji only by clicking on a reaction, hence, only
|
// deactivated realm emoji only by clicking on a reaction, hence, only
|
||||||
// `process_reaction_click()` codepath supports deleting/adding a deactivated
|
// `process_reaction_click()` codepath supports deleting/adding a deactivated
|
||||||
|
@ -224,7 +224,7 @@ run_test('sending', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
emoji_name = 'zulip'; // Test adding zulip emoji.
|
emoji_name = 'zulip'; // Test adding zulip emoji.
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
global.channel.post = stub.f;
|
global.channel.post = stub.f;
|
||||||
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
reactions.toggle_emoji_reaction(message_id, emoji_name);
|
||||||
const args = stub.get_args('args').args;
|
const args = stub.get_args('args').args;
|
||||||
|
@ -298,7 +298,7 @@ run_test('add_and_remove_reaction', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
let template_called;
|
let template_called;
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
template_called = true;
|
template_called = true;
|
||||||
assert.equal(template_name, 'message_reaction');
|
assert.equal(template_name, 'message_reaction');
|
||||||
assert.equal(data.class, 'message_reaction reacted');
|
assert.equal(data.class, 'message_reaction reacted');
|
||||||
|
@ -386,7 +386,7 @@ run_test('add_and_remove_reaction', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
template_called = false;
|
template_called = false;
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(data.class, 'message_reaction');
|
assert.equal(data.class, 'message_reaction');
|
||||||
assert(data.is_realm_emoji);
|
assert(data.is_realm_emoji);
|
||||||
template_called = true;
|
template_called = true;
|
||||||
|
@ -674,7 +674,7 @@ run_test('process_reaction_click', () => {
|
||||||
emoji_name: 'smile',
|
emoji_name: 'smile',
|
||||||
emoji_code: '263a',
|
emoji_code: '263a',
|
||||||
};
|
};
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
global.channel.del = stub.f;
|
global.channel.del = stub.f;
|
||||||
reactions.process_reaction_click(message_id, 'unicode_emoji,263a');
|
reactions.process_reaction_click(message_id, 'unicode_emoji,263a');
|
||||||
const args = stub.get_args('args').args;
|
const args = stub.get_args('args').args;
|
||||||
|
|
|
@ -297,7 +297,7 @@ run_test("test_recent_topics_launch", () => {
|
||||||
search_val: '',
|
search_val: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
if (template_name === 'recent_topics_table') {
|
if (template_name === 'recent_topics_table') {
|
||||||
assert.deepEqual(data, expected);
|
assert.deepEqual(data, expected);
|
||||||
} else if (template_name === 'recent_topics_filters') {
|
} else if (template_name === 'recent_topics_filters') {
|
||||||
|
@ -330,7 +330,7 @@ run_test('test_filter_all', () => {
|
||||||
};
|
};
|
||||||
let row_data;
|
let row_data;
|
||||||
let i;
|
let i;
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
if (template_name === 'recent_topic_row') {
|
if (template_name === 'recent_topic_row') {
|
||||||
// All the row will be processed.
|
// All the row will be processed.
|
||||||
i -= 1;
|
i -= 1;
|
||||||
|
@ -386,14 +386,12 @@ run_test('test_filter_unread', () => {
|
||||||
|
|
||||||
const rt = zrequire('recent_topics');
|
const rt = zrequire('recent_topics');
|
||||||
|
|
||||||
global.stub_templates(function () {
|
global.stub_templates(() => '<recent_topics table stub>');
|
||||||
return '<recent_topics table stub>';
|
|
||||||
});
|
|
||||||
rt.process_messages(messages);
|
rt.process_messages(messages);
|
||||||
assert.equal(rt.inplace_rerender('1:topic-1'), true);
|
assert.equal(rt.inplace_rerender('1:topic-1'), true);
|
||||||
|
|
||||||
$('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
|
$('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'recent_topics_filters');
|
assert.equal(template_name, 'recent_topics_filters');
|
||||||
assert.equal(data.filter_unread, expected.filter_unread);
|
assert.equal(data.filter_unread, expected.filter_unread);
|
||||||
assert.equal(data.filter_participated, expected.filter_participated);
|
assert.equal(data.filter_participated, expected.filter_participated);
|
||||||
|
@ -403,7 +401,7 @@ run_test('test_filter_unread', () => {
|
||||||
rt.set_filter('unread');
|
rt.set_filter('unread');
|
||||||
rt.update_filters_view();
|
rt.update_filters_view();
|
||||||
|
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
if (template_name === 'recent_topic_row') {
|
if (template_name === 'recent_topic_row') {
|
||||||
// All the row will be processed.
|
// All the row will be processed.
|
||||||
assert.deepEqual(data, row_data[i]);
|
assert.deepEqual(data, row_data[i]);
|
||||||
|
@ -452,9 +450,7 @@ run_test('test_filter_participated', () => {
|
||||||
|
|
||||||
const rt = zrequire('recent_topics');
|
const rt = zrequire('recent_topics');
|
||||||
|
|
||||||
global.stub_templates(function () {
|
global.stub_templates(() => '<recent_topics table stub>');
|
||||||
return '<recent_topics table stub>';
|
|
||||||
});
|
|
||||||
rt.process_messages(messages);
|
rt.process_messages(messages);
|
||||||
assert.equal(rt.inplace_rerender('1:topic-4'), true);
|
assert.equal(rt.inplace_rerender('1:topic-4'), true);
|
||||||
|
|
||||||
|
@ -466,7 +462,7 @@ run_test('test_filter_participated', () => {
|
||||||
rt.set_filter('muted');
|
rt.set_filter('muted');
|
||||||
|
|
||||||
$('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
|
$('#recent_topics_filter_buttons').removeClass('btn-recent-selected');
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'recent_topics_filters');
|
assert.equal(template_name, 'recent_topics_filters');
|
||||||
assert.equal(data.filter_unread, expected.filter_unread);
|
assert.equal(data.filter_unread, expected.filter_unread);
|
||||||
assert.equal(data.filter_participated, expected.filter_participated);
|
assert.equal(data.filter_participated, expected.filter_participated);
|
||||||
|
@ -476,7 +472,7 @@ run_test('test_filter_participated', () => {
|
||||||
rt.update_filters_view();
|
rt.update_filters_view();
|
||||||
|
|
||||||
|
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
if (template_name === 'recent_topic_row') {
|
if (template_name === 'recent_topic_row') {
|
||||||
// All the row will be processed.
|
// All the row will be processed.
|
||||||
assert.deepEqual(data, row_data[i]);
|
assert.deepEqual(data, row_data[i]);
|
||||||
|
@ -495,9 +491,7 @@ run_test('test_filter_participated', () => {
|
||||||
run_test('test_update_unread_count', () => {
|
run_test('test_update_unread_count', () => {
|
||||||
const rt = zrequire('recent_topics');
|
const rt = zrequire('recent_topics');
|
||||||
rt.set_filter('all');
|
rt.set_filter('all');
|
||||||
global.stub_templates(function () {
|
global.stub_templates(() => '<recent_topics table stub>');
|
||||||
return '<recent_topics table stub>';
|
|
||||||
});
|
|
||||||
rt.process_messages(messages);
|
rt.process_messages(messages);
|
||||||
|
|
||||||
// update a message
|
// update a message
|
||||||
|
@ -506,9 +500,7 @@ run_test('test_update_unread_count', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// template rendering is tested in test_recent_topics_launch.
|
// template rendering is tested in test_recent_topics_launch.
|
||||||
global.stub_templates(function () {
|
global.stub_templates(() => '<recent_topics table stub>');
|
||||||
return '<recent_topics table stub>';
|
|
||||||
});
|
|
||||||
|
|
||||||
run_test('basic assertions', () => {
|
run_test('basic assertions', () => {
|
||||||
const rt = zrequire('recent_topics');
|
const rt = zrequire('recent_topics');
|
||||||
|
|
|
@ -33,7 +33,7 @@ const _page_params = {
|
||||||
const _realm_icon = {};
|
const _realm_icon = {};
|
||||||
const _channel = {};
|
const _channel = {};
|
||||||
|
|
||||||
global.stub_templates(function (name, data) {
|
global.stub_templates((name, data) => {
|
||||||
if (name === 'settings/admin_realm_domains_list') {
|
if (name === 'settings/admin_realm_domains_list') {
|
||||||
assert(data.realm_domain.domain);
|
assert(data.realm_domain.domain);
|
||||||
return 'stub-domains-list';
|
return 'stub-domains-list';
|
||||||
|
|
|
@ -126,7 +126,7 @@ run_test('populate_user_groups', () => {
|
||||||
|
|
||||||
let templates_render_called = false;
|
let templates_render_called = false;
|
||||||
const fake_rendered_temp = $.create('fake_admin_user_group_list_template_rendered');
|
const fake_rendered_temp = $.create('fake_admin_user_group_list_template_rendered');
|
||||||
global.stub_templates(function (template, args) {
|
global.stub_templates((template, args) => {
|
||||||
assert.equal(template, 'admin_user_group_list');
|
assert.equal(template, 'admin_user_group_list');
|
||||||
assert.equal(args.user_group.id, 1);
|
assert.equal(args.user_group.id, 1);
|
||||||
assert.equal(args.user_group.name, 'Mobile');
|
assert.equal(args.user_group.name, 'Mobile');
|
||||||
|
@ -326,7 +326,7 @@ run_test('populate_user_groups', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
pills.onPillRemove = function (handler) {
|
pills.onPillRemove = function (handler) {
|
||||||
global.patch_builtin('setTimeout', function (func) {
|
global.patch_builtin('setTimeout', (func) => {
|
||||||
func();
|
func();
|
||||||
});
|
});
|
||||||
realm_user_group.members = new Set([2, 31]);
|
realm_user_group.members = new Set([2, 31]);
|
||||||
|
@ -364,9 +364,7 @@ run_test('with_external_user', () => {
|
||||||
return noop;
|
return noop;
|
||||||
};
|
};
|
||||||
|
|
||||||
global.stub_templates(function () {
|
global.stub_templates(() => noop);
|
||||||
return noop;
|
|
||||||
});
|
|
||||||
|
|
||||||
people.get_by_user_id = function () {
|
people.get_by_user_id = function () {
|
||||||
return noop;
|
return noop;
|
||||||
|
@ -791,7 +789,7 @@ run_test('on_events', () => {
|
||||||
assert.equal(opts.data.description, 'translated: All mobile members');
|
assert.equal(opts.data.description, 'translated: All mobile members');
|
||||||
api_endpoint_called = true;
|
api_endpoint_called = true;
|
||||||
(function test_post_success() {
|
(function test_post_success() {
|
||||||
global.patch_builtin('setTimeout', function (func) {
|
global.patch_builtin('setTimeout', (func) => {
|
||||||
func();
|
func();
|
||||||
});
|
});
|
||||||
opts.success();
|
opts.success();
|
||||||
|
|
|
@ -4,7 +4,7 @@ set_global('page_params', {
|
||||||
is_guest: false,
|
is_guest: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
set_global('$', function () {
|
set_global('$', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
set_global('document', null);
|
set_global('document', null);
|
||||||
|
@ -954,7 +954,7 @@ run_test('filter inactives', () => {
|
||||||
stream_data.initialize(params);
|
stream_data.initialize(params);
|
||||||
assert(!stream_data.is_filtering_inactives());
|
assert(!stream_data.is_filtering_inactives());
|
||||||
|
|
||||||
_.times(30, function (i) {
|
_.times(30, (i) => {
|
||||||
const name = 'random' + i.toString();
|
const name = 'random' + i.toString();
|
||||||
const stream_id = 100 + i;
|
const stream_id = 100 + i;
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@ stream_data.add_sub(frontend);
|
||||||
|
|
||||||
run_test('update_property', () => {
|
run_test('update_property', () => {
|
||||||
// Invoke error for non-existent stream/property
|
// Invoke error for non-existent stream/property
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
let errors = 0;
|
let errors = 0;
|
||||||
override('blueslip.warn', function () {
|
override('blueslip.warn', () => {
|
||||||
errors += 1;
|
errors += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ run_test('update_property', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test update color
|
// Test update color
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_color.update_stream_color', stub.f);
|
override('stream_color.update_stream_color', stub.f);
|
||||||
stream_events.update_property(1, 'color', 'blue');
|
stream_events.update_property(1, 'color', 'blue');
|
||||||
const args = stub.get_args('sub', 'val');
|
const args = stub.get_args('sub', 'val');
|
||||||
|
@ -56,8 +56,8 @@ run_test('update_property', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test in home view
|
// Test in home view
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_muting.update_is_muted', stub.f);
|
override('stream_muting.update_is_muted', stub.f);
|
||||||
stream_events.update_property(1, 'in_home_view', false);
|
stream_events.update_property(1, 'in_home_view', false);
|
||||||
const args = stub.get_args('sub', 'val');
|
const args = stub.get_args('sub', 'val');
|
||||||
|
@ -97,8 +97,8 @@ run_test('update_property', () => {
|
||||||
assert.equal(checkbox.prop('checked'), true);
|
assert.equal(checkbox.prop('checked'), true);
|
||||||
|
|
||||||
// Test name change
|
// Test name change
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.update_stream_name', stub.f);
|
override('subs.update_stream_name', stub.f);
|
||||||
stream_events.update_property(1, 'name', 'the frontend');
|
stream_events.update_property(1, 'name', 'the frontend');
|
||||||
const args = stub.get_args('sub', 'val');
|
const args = stub.get_args('sub', 'val');
|
||||||
|
@ -108,8 +108,8 @@ run_test('update_property', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test description change
|
// Test description change
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.update_stream_description', stub.f);
|
override('subs.update_stream_description', stub.f);
|
||||||
stream_events.update_property(1, 'description', 'we write code', {rendered_description: 'we write code'});
|
stream_events.update_property(1, 'description', 'we write code', {rendered_description: 'we write code'});
|
||||||
const args = stub.get_args('sub', 'val');
|
const args = stub.get_args('sub', 'val');
|
||||||
|
@ -123,7 +123,7 @@ run_test('update_property', () => {
|
||||||
assert.equal(frontend.email_address, 'zooly@zulip.com');
|
assert.equal(frontend.email_address, 'zooly@zulip.com');
|
||||||
|
|
||||||
// Test pin to top
|
// Test pin to top
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
override('stream_list.refresh_pinned_or_unpinned_stream', noop);
|
override('stream_list.refresh_pinned_or_unpinned_stream', noop);
|
||||||
stream_events.update_property(1, 'pin_to_top', true);
|
stream_events.update_property(1, 'pin_to_top', true);
|
||||||
checkbox = $("#pin_to_top_1");
|
checkbox = $("#pin_to_top_1");
|
||||||
|
@ -131,8 +131,8 @@ run_test('update_property', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test stream privacy change event
|
// Test stream privacy change event
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.update_stream_privacy', stub.f);
|
override('subs.update_stream_privacy', stub.f);
|
||||||
stream_events.update_property(1, 'invite_only', true, {
|
stream_events.update_property(1, 'invite_only', true, {
|
||||||
history_public_to_subscribers: true,
|
history_public_to_subscribers: true,
|
||||||
|
@ -147,8 +147,8 @@ run_test('update_property', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test stream stream_post_policy change event
|
// Test stream stream_post_policy change event
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.update_stream_post_policy', stub.f);
|
override('subs.update_stream_post_policy', stub.f);
|
||||||
stream_events.update_property(1, 'stream_post_policy', stream_data.stream_post_policy_values.admins.code);
|
stream_events.update_property(1, 'stream_post_policy', stream_data.stream_post_policy_values.admins.code);
|
||||||
const args = stub.get_args('sub', 'val');
|
const args = stub.get_args('sub', 'val');
|
||||||
|
@ -158,8 +158,8 @@ run_test('update_property', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test stream message_retention_days change event
|
// Test stream message_retention_days change event
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.update_message_retention_setting', stub.f);
|
override('subs.update_message_retention_setting', stub.f);
|
||||||
stream_events.update_property(1, 'message_retention_days', 20);
|
stream_events.update_property(1, 'message_retention_days', 20);
|
||||||
const args = stub.get_args('sub', 'val');
|
const args = stub.get_args('sub', 'val');
|
||||||
|
@ -171,10 +171,10 @@ run_test('update_property', () => {
|
||||||
|
|
||||||
run_test('marked_subscribed', () => {
|
run_test('marked_subscribed', () => {
|
||||||
// Test undefined error
|
// Test undefined error
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
let errors = 0;
|
let errors = 0;
|
||||||
override('stream_color.update_stream_color', noop);
|
override('stream_color.update_stream_color', noop);
|
||||||
override('blueslip.error', function () {
|
override('blueslip.error', () => {
|
||||||
errors += 1;
|
errors += 1;
|
||||||
});
|
});
|
||||||
stream_events.mark_subscribed(undefined, [], 'yellow');
|
stream_events.mark_subscribed(undefined, [], 'yellow');
|
||||||
|
@ -182,9 +182,9 @@ run_test('marked_subscribed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test early return if subscribed
|
// Test early return if subscribed
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
let completed = false;
|
let completed = false;
|
||||||
override('message_util.do_unread_count_updates', function () {
|
override('message_util.do_unread_count_updates', () => {
|
||||||
completed = true; // This gets run if we continue and don't early return
|
completed = true; // This gets run if we continue and don't early return
|
||||||
});
|
});
|
||||||
const subscribed = {subscribed: true};
|
const subscribed = {subscribed: true};
|
||||||
|
@ -208,7 +208,7 @@ run_test('marked_subscribed', () => {
|
||||||
set_global('overlays', { streams_open: return_true });
|
set_global('overlays', { streams_open: return_true });
|
||||||
|
|
||||||
// Test basic dispatching and updating stream color
|
// Test basic dispatching and updating stream color
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
let args;
|
let args;
|
||||||
let list_updated = false;
|
let list_updated = false;
|
||||||
|
|
||||||
|
@ -218,10 +218,8 @@ run_test('marked_subscribed', () => {
|
||||||
override('stream_color.update_stream_color', noop);
|
override('stream_color.update_stream_color', noop);
|
||||||
override('stream_list.add_sidebar_row', stream_list_stub.f);
|
override('stream_list.add_sidebar_row', stream_list_stub.f);
|
||||||
override('message_util.do_unread_count_updates', message_util_stub.f);
|
override('message_util.do_unread_count_updates', message_util_stub.f);
|
||||||
override('narrow_state.is_for_stream_id', function () {
|
override('narrow_state.is_for_stream_id', () => true);
|
||||||
return true;
|
override('current_msg_list.update_trailing_bookend', () => {
|
||||||
});
|
|
||||||
override('current_msg_list.update_trailing_bookend', function () {
|
|
||||||
list_updated = true;
|
list_updated = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -239,17 +237,15 @@ run_test('marked_subscribed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test assigning generated color
|
// Test assigning generated color
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
frontend.color = undefined;
|
frontend.color = undefined;
|
||||||
override('color_data.pick_color', function () {
|
override('color_data.pick_color', () => 'green');
|
||||||
return 'green';
|
|
||||||
});
|
|
||||||
let warnings = 0;
|
let warnings = 0;
|
||||||
override('blueslip.warn', function () {
|
override('blueslip.warn', () => {
|
||||||
warnings += 1;
|
warnings += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('narrow_state.is_for_stream_id', noop);
|
override('narrow_state.is_for_stream_id', noop);
|
||||||
override('message_util.do_unread_count_updates', noop);
|
override('message_util.do_unread_count_updates', noop);
|
||||||
override('stream_list.add_sidebar_row', noop);
|
override('stream_list.add_sidebar_row', noop);
|
||||||
|
@ -266,12 +262,12 @@ run_test('marked_subscribed', () => {
|
||||||
narrow_state.is_for_stream_id = () => false;
|
narrow_state.is_for_stream_id = () => false;
|
||||||
|
|
||||||
// Test assigning subscriber emails
|
// Test assigning subscriber emails
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
override('stream_color.update_stream_color', noop);
|
override('stream_color.update_stream_color', noop);
|
||||||
override('message_util.do_unread_count_updates', noop);
|
override('message_util.do_unread_count_updates', noop);
|
||||||
override('stream_list.add_sidebar_row', noop);
|
override('stream_list.add_sidebar_row', noop);
|
||||||
|
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_data.set_subscribers', stub.f);
|
override('stream_data.set_subscribers', stub.f);
|
||||||
const user_ids = [15, 20, 25];
|
const user_ids = [15, 20, 25];
|
||||||
stream_events.mark_subscribed(frontend, user_ids, '');
|
stream_events.mark_subscribed(frontend, user_ids, '');
|
||||||
|
@ -281,7 +277,7 @@ run_test('marked_subscribed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// assign self as well
|
// assign self as well
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_data.subscribe_myself', stub.f);
|
override('stream_data.subscribe_myself', stub.f);
|
||||||
stream_events.mark_subscribed(frontend, [], '');
|
stream_events.mark_subscribed(frontend, [], '');
|
||||||
const args = stub.get_args('sub');
|
const args = stub.get_args('sub');
|
||||||
|
@ -289,7 +285,7 @@ run_test('marked_subscribed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// and finally update subscriber settings
|
// and finally update subscriber settings
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.update_settings_for_subscribed', stub.f);
|
override('subs.update_settings_for_subscribed', stub.f);
|
||||||
stream_events.mark_subscribed(frontend, [], '');
|
stream_events.mark_subscribed(frontend, [], '');
|
||||||
const args = stub.get_args('sub');
|
const args = stub.get_args('sub');
|
||||||
|
@ -299,7 +295,7 @@ run_test('marked_subscribed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test('mark_unsubscribed', () => {
|
run_test('mark_unsubscribed', () => {
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
let removed_sub = false;
|
let removed_sub = false;
|
||||||
override('stream_list.remove_sidebar_row', () => {
|
override('stream_list.remove_sidebar_row', () => {
|
||||||
removed_sub = true;
|
removed_sub = true;
|
||||||
|
@ -317,8 +313,8 @@ run_test('mark_unsubscribed', () => {
|
||||||
|
|
||||||
// Test unsubscribe
|
// Test unsubscribe
|
||||||
frontend.subscribed = true;
|
frontend.subscribed = true;
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('stream_data.unsubscribe_myself', stub.f);
|
override('stream_data.unsubscribe_myself', stub.f);
|
||||||
override('subs.update_settings_for_unsubscribed', noop);
|
override('subs.update_settings_for_unsubscribed', noop);
|
||||||
override('stream_list.remove_sidebar_row', noop);
|
override('stream_list.remove_sidebar_row', noop);
|
||||||
|
@ -329,8 +325,8 @@ run_test('mark_unsubscribed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test update settings after unsubscribe
|
// Test update settings after unsubscribe
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
global.with_stub(function (stub) {
|
global.with_stub((stub) => {
|
||||||
override('subs.update_settings_for_unsubscribed', stub.f);
|
override('subs.update_settings_for_unsubscribed', stub.f);
|
||||||
override('stream_data.unsubscribe_myself', noop);
|
override('stream_data.unsubscribe_myself', noop);
|
||||||
override('stream_list.remove_sidebar_row', noop);
|
override('stream_list.remove_sidebar_row', noop);
|
||||||
|
@ -341,15 +337,13 @@ run_test('mark_unsubscribed', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test update bookend and remove done event
|
// Test update bookend and remove done event
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
override('stream_data.unsubscribe_myself', noop);
|
override('stream_data.unsubscribe_myself', noop);
|
||||||
override('subs.update_settings_for_unsubscribed', noop);
|
override('subs.update_settings_for_unsubscribed', noop);
|
||||||
override('narrow_state.is_for_stream_id', function () {
|
override('narrow_state.is_for_stream_id', () => true);
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
let updated = false;
|
let updated = false;
|
||||||
override('current_msg_list.update_trailing_bookend', function () {
|
override('current_msg_list.update_trailing_bookend', () => {
|
||||||
updated = true;
|
updated = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ run_test('create_sidebar_row', () => {
|
||||||
devel_count.set_find_results('.value', devel_value);
|
devel_count.set_find_results('.value', devel_value);
|
||||||
devel_count.set_parent(sidebar_row);
|
devel_count.set_parent(sidebar_row);
|
||||||
|
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'stream_sidebar_row');
|
assert.equal(template_name, 'stream_sidebar_row');
|
||||||
assert.equal(data.uri, '#narrow/stream/100-devel');
|
assert.equal(data.uri, '#narrow/stream/100-devel');
|
||||||
return '<devel sidebar row>';
|
return '<devel sidebar row>';
|
||||||
|
@ -87,7 +87,7 @@ run_test('create_sidebar_row', () => {
|
||||||
social_count.set_find_results('.value', social_value);
|
social_count.set_find_results('.value', social_value);
|
||||||
social_count.set_parent(sidebar_row);
|
social_count.set_parent(sidebar_row);
|
||||||
|
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'stream_sidebar_row');
|
assert.equal(template_name, 'stream_sidebar_row');
|
||||||
assert.equal(data.uri, '#narrow/stream/200-social');
|
assert.equal(data.uri, '#narrow/stream/200-social');
|
||||||
return '<social sidebar row>';
|
return '<social sidebar row>';
|
||||||
|
@ -133,7 +133,7 @@ run_test('create_sidebar_row', () => {
|
||||||
|
|
||||||
social.invite_only = true;
|
social.invite_only = true;
|
||||||
social.color = '#222222';
|
social.color = '#222222';
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'stream_privacy');
|
assert.equal(template_name, 'stream_privacy');
|
||||||
assert.equal(data.invite_only, true);
|
assert.equal(data.invite_only, true);
|
||||||
assert.equal(data.dark_background, 'dark_background');
|
assert.equal(data.dark_background, 'dark_background');
|
||||||
|
@ -747,7 +747,7 @@ run_test('create_initial_sidebar_rows', () => {
|
||||||
|
|
||||||
stream_list.update_count_in_dom = noop;
|
stream_list.update_count_in_dom = noop;
|
||||||
|
|
||||||
global.stub_templates(function (template_name, data) {
|
global.stub_templates((template_name, data) => {
|
||||||
assert.equal(template_name, 'stream_sidebar_row');
|
assert.equal(template_name, 'stream_sidebar_row');
|
||||||
return '<div>stub-html-' + data.name;
|
return '<div>stub-html-' + data.name;
|
||||||
});
|
});
|
||||||
|
|
|
@ -50,10 +50,8 @@ function sort_groups(query) {
|
||||||
return stream_sort.sort_groups(streams, query);
|
return stream_sort.sort_groups(streams, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
with_overrides(function (override) {
|
with_overrides((override) => {
|
||||||
override('stream_data.is_active', function (sub) {
|
override('stream_data.is_active', (sub) => sub.name !== "pneumonia");
|
||||||
return sub.name !== "pneumonia";
|
|
||||||
});
|
|
||||||
|
|
||||||
// Test sorting into categories/alphabetized
|
// Test sorting into categories/alphabetized
|
||||||
let sorted = sort_groups("");
|
let sorted = sort_groups("");
|
||||||
|
|
|
@ -225,49 +225,49 @@ run_test('last_seen_status_from_date', () => {
|
||||||
assert.equal(actual_status, expected_status);
|
assert.equal(actual_status, expected_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_same(function (d) { return d.addSeconds(-20); },
|
assert_same((d) => d.addSeconds(-20),
|
||||||
i18n.t("Just now"));
|
i18n.t("Just now"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addMinutes(-1); },
|
assert_same((d) => d.addMinutes(-1),
|
||||||
i18n.t("Just now"));
|
i18n.t("Just now"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addMinutes(-2); },
|
assert_same((d) => d.addMinutes(-2),
|
||||||
i18n.t("Just now"));
|
i18n.t("Just now"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addMinutes(-30); },
|
assert_same((d) => d.addMinutes(-30),
|
||||||
i18n.t("30 minutes ago"));
|
i18n.t("30 minutes ago"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addHours(-1); },
|
assert_same((d) => d.addHours(-1),
|
||||||
i18n.t("An hour ago"));
|
i18n.t("An hour ago"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addHours(-2); },
|
assert_same((d) => d.addHours(-2),
|
||||||
i18n.t("2 hours ago"));
|
i18n.t("2 hours ago"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addHours(-20); },
|
assert_same((d) => d.addHours(-20),
|
||||||
i18n.t("20 hours ago"));
|
i18n.t("20 hours ago"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addDays(-1); },
|
assert_same((d) => d.addDays(-1),
|
||||||
i18n.t("Yesterday"));
|
i18n.t("Yesterday"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addDays(-2); },
|
assert_same((d) => d.addDays(-2),
|
||||||
i18n.t("2 days ago"));
|
i18n.t("2 days ago"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addDays(-61); },
|
assert_same((d) => d.addDays(-61),
|
||||||
i18n.t("61 days ago"));
|
i18n.t("61 days ago"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addDays(-300); },
|
assert_same((d) => d.addDays(-300),
|
||||||
i18n.t("May 06,\xa02015"));
|
i18n.t("May 06,\xa02015"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addDays(-366); },
|
assert_same((d) => d.addDays(-366),
|
||||||
i18n.t("Mar 01,\xa02015"));
|
i18n.t("Mar 01,\xa02015"));
|
||||||
|
|
||||||
assert_same(function (d) { return d.addYears(-3); },
|
assert_same((d) => d.addYears(-3),
|
||||||
i18n.t("Mar 01,\xa02013"));
|
i18n.t("Mar 01,\xa02013"));
|
||||||
|
|
||||||
// Set base_dateto to May 1 2016 12.30 AM (months are zero based)
|
// Set base_dateto to May 1 2016 12.30 AM (months are zero based)
|
||||||
base_date = new XDate(2016, 4, 1, 0, 30);
|
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"));
|
i18n.t("Jan\xa031"));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
set_global('page_params', {realm_is_zephyr_mirror_realm: false});
|
set_global('page_params', {realm_is_zephyr_mirror_realm: false});
|
||||||
set_global('md5', function (s) {
|
set_global('md5', (s) => 'md5-' + s);
|
||||||
return 'md5-' + s;
|
|
||||||
});
|
|
||||||
|
|
||||||
const settings_config = zrequire('settings_config');
|
const settings_config = zrequire('settings_config');
|
||||||
page_params.realm_email_address_visibility =
|
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
|
// Test render_person with regular person, under hidden email visibility case
|
||||||
page_params.is_admin = false;
|
page_params.is_admin = false;
|
||||||
let rendered = 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(template_name, 'typeahead_list_item');
|
||||||
assert.equal(args.primary, b_user_1.full_name);
|
assert.equal(args.primary, b_user_1.full_name);
|
||||||
assert.equal(args.secondary, undefined);
|
assert.equal(args.secondary, undefined);
|
||||||
|
@ -519,7 +517,7 @@ run_test('render_person', () => {
|
||||||
page_params.is_admin = true;
|
page_params.is_admin = true;
|
||||||
// Test render_person with regular person
|
// Test render_person with regular person
|
||||||
let rendered = 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(template_name, 'typeahead_list_item');
|
||||||
assert.equal(args.primary, a_user.full_name);
|
assert.equal(args.primary, a_user.full_name);
|
||||||
assert.equal(args.secondary, a_user.email);
|
assert.equal(args.secondary, a_user.email);
|
||||||
|
@ -539,7 +537,7 @@ run_test('render_person', () => {
|
||||||
special_item_text: "special_text",
|
special_item_text: "special_text",
|
||||||
};
|
};
|
||||||
rendered = false;
|
rendered = false;
|
||||||
global.stub_templates(function (template_name, args) {
|
global.stub_templates((template_name, args) => {
|
||||||
assert.equal(template_name, 'typeahead_list_item');
|
assert.equal(template_name, 'typeahead_list_item');
|
||||||
assert.equal(args.primary, special_person.special_item_text);
|
assert.equal(args.primary, special_person.special_item_text);
|
||||||
rendered = true;
|
rendered = true;
|
||||||
|
@ -551,7 +549,7 @@ run_test('render_person', () => {
|
||||||
|
|
||||||
run_test('clear_rendered_person', () => {
|
run_test('clear_rendered_person', () => {
|
||||||
let rendered = 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(template_name, 'typeahead_list_item');
|
||||||
assert.equal(args.primary, b_bot.full_name);
|
assert.equal(args.primary, b_bot.full_name);
|
||||||
assert.equal(args.secondary, b_bot.email);
|
assert.equal(args.secondary, b_bot.email);
|
||||||
|
@ -583,7 +581,7 @@ run_test('render_stream', () => {
|
||||||
stream_id: 42,
|
stream_id: 42,
|
||||||
name: 'Short Description',
|
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(template_name, 'typeahead_list_item');
|
||||||
assert.equal(args.primary, stream.name);
|
assert.equal(args.primary, stream.name);
|
||||||
assert.equal(args.secondary, stream.description);
|
assert.equal(args.secondary, stream.description);
|
||||||
|
@ -600,7 +598,7 @@ run_test('render_stream', () => {
|
||||||
stream_id: 43,
|
stream_id: 43,
|
||||||
name: 'Long Description',
|
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(template_name, 'typeahead_list_item');
|
||||||
assert.equal(args.primary, stream.name);
|
assert.equal(args.primary, stream.name);
|
||||||
const short_desc = stream.description.substring(0, 35);
|
const short_desc = stream.description.substring(0, 35);
|
||||||
|
@ -619,7 +617,7 @@ run_test('clear_rendered_stream', () => {
|
||||||
stream_id: 44,
|
stream_id: 44,
|
||||||
name: 'Stream To Be Cleared',
|
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(template_name, 'typeahead_list_item');
|
||||||
assert.equal(args.primary, stream.name);
|
assert.equal(args.primary, stream.name);
|
||||||
assert.equal(args.secondary, stream.description);
|
assert.equal(args.secondary, stream.description);
|
||||||
|
@ -650,7 +648,7 @@ run_test('render_emoji', () => {
|
||||||
realm_emoji: 'TBD',
|
realm_emoji: 'TBD',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
global.stub_templates(function (template_name, args) {
|
global.stub_templates((template_name, args) => {
|
||||||
assert.equal(template_name, 'typeahead_list_item');
|
assert.equal(template_name, 'typeahead_list_item');
|
||||||
assert.deepEqual(args, {
|
assert.deepEqual(args, {
|
||||||
primary: 'thumbs up',
|
primary: 'thumbs up',
|
||||||
|
@ -672,7 +670,7 @@ run_test('render_emoji', () => {
|
||||||
emoji_url: 'TBD',
|
emoji_url: 'TBD',
|
||||||
};
|
};
|
||||||
|
|
||||||
global.stub_templates(function (template_name, args) {
|
global.stub_templates((template_name, args) => {
|
||||||
assert.equal(template_name, 'typeahead_list_item');
|
assert.equal(template_name, 'typeahead_list_item');
|
||||||
assert.deepEqual(args, {
|
assert.deepEqual(args, {
|
||||||
primary: 'realm emoji',
|
primary: 'realm emoji',
|
||||||
|
|
|
@ -268,7 +268,7 @@ run_test('basics', () => {
|
||||||
|
|
||||||
// stub functions to see how may time they are called
|
// stub functions to see how may time they are called
|
||||||
for (const method of Object.keys(call_count)) {
|
for (const method of Object.keys(call_count)) {
|
||||||
typing_status.__Rewire__(method, function () {
|
typing_status.__Rewire__(method, () => {
|
||||||
call_count[method] += 1;
|
call_count[method] += 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
zrequire('people');
|
zrequire('people');
|
||||||
set_global('md5', function (s) {
|
set_global('md5', (s) => 'md5-' + s);
|
||||||
return 'md5-' + s;
|
|
||||||
});
|
|
||||||
zrequire('user_pill');
|
zrequire('user_pill');
|
||||||
|
|
||||||
set_global('page_params', {
|
set_global('page_params', {
|
||||||
|
|
|
@ -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%3Ayyy'), 'xxx:yyy');
|
||||||
assert.equal(util.robust_uri_decode('xxx%3'), 'xxx');
|
assert.equal(util.robust_uri_decode('xxx%3'), 'xxx');
|
||||||
|
|
||||||
set_global('decodeURIComponent', function () { throw 'foo'; });
|
set_global('decodeURIComponent', () => { throw 'foo'; });
|
||||||
try {
|
try {
|
||||||
util.robust_uri_decode('%E0%A4%A');
|
util.robust_uri_decode('%E0%A4%A');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -151,7 +151,7 @@ run_test('random_int', () => {
|
||||||
const min = 0;
|
const min = 0;
|
||||||
const max = 100;
|
const max = 100;
|
||||||
|
|
||||||
_.times(500, function () {
|
_.times(500, () => {
|
||||||
const val = util.random_int(min, max);
|
const val = util.random_int(min, max);
|
||||||
assert(min <= val);
|
assert(min <= val);
|
||||||
assert(val <= max);
|
assert(val <= max);
|
||||||
|
|
|
@ -117,11 +117,11 @@ run_test('clicks', () => {
|
||||||
const state = {};
|
const state = {};
|
||||||
|
|
||||||
function set_up_click_handlers() {
|
function set_up_click_handlers() {
|
||||||
$('#widget1').click(function () {
|
$('#widget1').click(() => {
|
||||||
state.clicked = true;
|
state.clicked = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.some-class').keydown(function () {
|
$('.some-class').keydown(() => {
|
||||||
state.keydown = true;
|
state.keydown = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -149,12 +149,12 @@ run_test('events', () => {
|
||||||
let value;
|
let value;
|
||||||
|
|
||||||
function initialize_handler() {
|
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
|
value = 'red'; // just a dummy side effect
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#my-parent').on('click', '.button-blue', function (e) {
|
$('#my-parent').on('click', '.button-blue', (e) => {
|
||||||
value = 'blue';
|
value = 'blue';
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,8 +8,8 @@ exports.find_files_to_run = function () {
|
||||||
if (process.argv[2]) {
|
if (process.argv[2]) {
|
||||||
oneFileFilter = process.argv
|
oneFileFilter = process.argv
|
||||||
.slice(2)
|
.slice(2)
|
||||||
.filter(function (filename) {return (/[.]js$/).test(filename);})
|
.filter((filename) => (/[.]js$/).test(filename))
|
||||||
.map(function (filename) {return filename.replace(/\.js$/i, '');});
|
.map((filename) => filename.replace(/\.js$/i, ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
// tests_dir is where we find our specific unit tests (as opposed
|
// 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');
|
const tests_dir = __dirname.replace(/zjsunit/, 'node_tests');
|
||||||
|
|
||||||
let tests = fs.readdirSync(tests_dir)
|
let tests = fs.readdirSync(tests_dir)
|
||||||
.filter(function (filename) {return !(/^\./i).test(filename);})
|
.filter((filename) => !(/^\./i).test(filename))
|
||||||
.filter(function (filename) {return (/\.js$/i).test(filename);})
|
.filter((filename) => (/\.js$/i).test(filename))
|
||||||
.map(function (filename) {return filename.replace(/\.js$/i, '');});
|
.map((filename) => filename.replace(/\.js$/i, ''));
|
||||||
|
|
||||||
if (oneFileFilter.length > 0) {
|
if (oneFileFilter.length > 0) {
|
||||||
tests = tests.filter(function (filename) {
|
tests = tests.filter((filename) => oneFileFilter.includes(filename));
|
||||||
return oneFileFilter.includes(filename);
|
|
||||||
});
|
|
||||||
testsDifference = _.difference(oneFileFilter, tests);
|
testsDifference = _.difference(oneFileFilter, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
testsDifference.forEach(function (filename) {
|
testsDifference.forEach((filename) => {
|
||||||
throw filename + ".js does not exist";
|
throw filename + ".js does not exist";
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.sort();
|
tests.sort();
|
||||||
|
|
||||||
const files = tests.map(function (fn) {
|
const files = tests.map((fn) => {
|
||||||
const obj = {};
|
const obj = {};
|
||||||
obj.name = fn;
|
obj.name = fn;
|
||||||
obj.full_name = path.join(tests_dir, fn);
|
obj.full_name = path.join(tests_dir, fn);
|
||||||
|
|
|
@ -104,7 +104,7 @@ global.run_test = (label, f) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
files.forEach(function (file) {
|
files.forEach((file) => {
|
||||||
set_global('location', {
|
set_global('location', {
|
||||||
hash: '#',
|
hash: '#',
|
||||||
});
|
});
|
||||||
|
|
|
@ -45,7 +45,7 @@ exports.clear_zulip_refs = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.restore = function () {
|
exports.restore = function () {
|
||||||
requires.forEach(function (fn) {
|
requires.forEach((fn) => {
|
||||||
delete require.cache[require.resolve(fn)];
|
delete require.cache[require.resolve(fn)];
|
||||||
});
|
});
|
||||||
Object.assign(global, old_globals);
|
Object.assign(global, old_globals);
|
||||||
|
@ -57,14 +57,12 @@ exports.restore = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.stub_out_jquery = function () {
|
exports.stub_out_jquery = function () {
|
||||||
set_global('$', function () {
|
set_global('$', () => ({
|
||||||
return {
|
|
||||||
on: function () {},
|
on: function () {},
|
||||||
trigger: function () {},
|
trigger: function () {},
|
||||||
hide: function () {},
|
hide: function () {},
|
||||||
removeClass: function () {},
|
removeClass: function () {},
|
||||||
};
|
}));
|
||||||
});
|
|
||||||
$.fn = {};
|
$.fn = {};
|
||||||
$.now = function () {};
|
$.now = function () {};
|
||||||
};
|
};
|
||||||
|
@ -86,7 +84,7 @@ exports.with_overrides = function (test_function) {
|
||||||
|
|
||||||
global[module][func_name] = f;
|
global[module][func_name] = f;
|
||||||
|
|
||||||
clobber_callbacks.push(function () {
|
clobber_callbacks.push(() => {
|
||||||
// If you get a failure from this, you probably just
|
// If you get a failure from this, you probably just
|
||||||
// need to have your test do its own overrides and
|
// need to have your test do its own overrides and
|
||||||
// not cherry-pick off of the prior test's setup.
|
// not cherry-pick off of the prior test's setup.
|
||||||
|
|
|
@ -33,7 +33,7 @@ exports.with_stub = function (f) {
|
||||||
};
|
};
|
||||||
|
|
||||||
(function test_ourselves() {
|
(function test_ourselves() {
|
||||||
exports.with_stub(function (stub) {
|
exports.with_stub((stub) => {
|
||||||
stub.f('blue', 42);
|
stub.f('blue', 42);
|
||||||
const args = stub.get_args('color', 'n');
|
const args = stub.get_args('color', 'n');
|
||||||
assert.equal(args.color, 'blue');
|
assert.equal(args.color, 'blue');
|
||||||
|
|
|
@ -305,7 +305,7 @@ exports.make_new_elem = function (selector, opts) {
|
||||||
},
|
},
|
||||||
removeClass: function (class_names) {
|
removeClass: function (class_names) {
|
||||||
class_names = class_names.split(' ');
|
class_names = class_names.split(' ');
|
||||||
class_names.forEach(function (class_name) {
|
class_names.forEach((class_name) => {
|
||||||
classes.delete(class_name);
|
classes.delete(class_name);
|
||||||
});
|
});
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -202,7 +202,7 @@ function mark_client_active() {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
$("html").on("mousemove", function () {
|
$("html").on("mousemove", () => {
|
||||||
exports.new_user_input = true;
|
exports.new_user_input = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ exports.process_message = function (message) {
|
||||||
const regex = new RegExp('(' + before_punctuation + ')' +
|
const regex = new RegExp('(' + before_punctuation + ')' +
|
||||||
'(' + clean + ')' +
|
'(' + clean + ')' +
|
||||||
'(' + after_punctuation + ')', 'ig');
|
'(' + after_punctuation + ')', 'ig');
|
||||||
message.content = message.content.replace(regex, function (match, before, word,
|
message.content = message.content.replace(regex, (match, before, word,
|
||||||
after, offset, content) {
|
after, offset, content) => {
|
||||||
// Logic for ensuring that we don't muck up rendered HTML.
|
// Logic for ensuring that we don't muck up rendered HTML.
|
||||||
const pre_match = content.substring(0, offset);
|
const pre_match = content.substring(0, offset);
|
||||||
// We want to find the position of the `<` and `>` only in the
|
// We want to find the position of the `<` and `>` only in the
|
||||||
|
|
|
@ -76,17 +76,17 @@ exports.set_up_alert_words = function () {
|
||||||
|
|
||||||
exports.render_alert_words_ui();
|
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();
|
const word = $('#create_alert_word_name').val();
|
||||||
add_alert_word(word);
|
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();
|
const word = $(event.currentTarget).parents('li').find('.value').text();
|
||||||
remove_alert_word(word);
|
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;
|
const key = event.which;
|
||||||
// Handle enter (13) as "add".
|
// Handle enter (13) as "add".
|
||||||
if (key === 13) {
|
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();
|
event.preventDefault();
|
||||||
const alert = $(event.currentTarget).parents('.alert');
|
const alert = $(event.currentTarget).parents('.alert');
|
||||||
alert.hide();
|
alert.hide();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
$(function () {
|
$(() => {
|
||||||
$('a.envelope-link').click(function () {
|
$('a.envelope-link').click(function () {
|
||||||
common.copy_data_attribute_value($(this), "admin-emails");
|
common.copy_data_attribute_value($(this), "admin-emails");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
$(function () {
|
$(() => {
|
||||||
$("body").on("click", ".scrub-realm-button", function (e) {
|
$("body").on("click", ".scrub-realm-button", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const string_id = $(this).data("string-id");
|
const string_id = $(this).data("string-id");
|
||||||
|
|
|
@ -117,14 +117,14 @@ function scroll_finish() {
|
||||||
scroll_timer = setTimeout(floating_recipient_bar.update, 100);
|
scroll_timer = setTimeout(floating_recipient_bar.update, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(() => {
|
||||||
$.fn.safeOuterHeight = function (...args) {
|
$.fn.safeOuterHeight = function (...args) {
|
||||||
return this.outerHeight(...args) || 0;
|
return this.outerHeight(...args) || 0;
|
||||||
};
|
};
|
||||||
$.fn.safeOuterWidth = function (...args) {
|
$.fn.safeOuterWidth = function (...args) {
|
||||||
return this.outerWidth(...args) || 0;
|
return this.outerWidth(...args) || 0;
|
||||||
};
|
};
|
||||||
$('.app').scroll(_.throttle(function () {
|
$('.app').scroll(_.throttle(() => {
|
||||||
scroll_finish();
|
scroll_finish();
|
||||||
}, 50));
|
}, 50));
|
||||||
exports.initialize();
|
exports.initialize();
|
||||||
|
|
|
@ -115,9 +115,7 @@ exports.update_attachments = function (event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.op === 'remove' || event.op === 'update') {
|
if (event.op === 'remove' || event.op === 'update') {
|
||||||
attachments = attachments.filter(function (a) {
|
attachments = attachments.filter((a) => a.id !== event.attachment.id);
|
||||||
return a.id !== event.attachment.id;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (event.op === 'add' || event.op === 'update') {
|
if (event.op === 'add' || event.op === 'update') {
|
||||||
format_attachment_data([event.attachment]);
|
format_attachment_data([event.attachment]);
|
||||||
|
@ -135,7 +133,7 @@ exports.set_up_attachments = function () {
|
||||||
const status = $('#delete-upload-status');
|
const status = $('#delete-upload-status');
|
||||||
loading.make_indicator($('#attachments_loading_indicator'), {text: 'Loading...'});
|
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'));
|
delete_attachments($(e.target).closest(".uploaded_file_row").attr('data-attachment-id'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ exports.build_user_avatar_widget = function (upload_function) {
|
||||||
$("#user-avatar-source").hide();
|
$("#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.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
channel.del({
|
channel.del({
|
||||||
|
|
|
@ -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");
|
const email = $("#payment-method").data("email");
|
||||||
card_change_handler.open({
|
card_change_handler.open({
|
||||||
name: 'Zulip',
|
name: 'Zulip',
|
||||||
|
@ -25,7 +25,7 @@ exports.initialize = function () {
|
||||||
e.preventDefault();
|
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"]);
|
helpers.create_ajax_request("/json/billing/plan/change", "planchange", undefined, ["status"]);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
@ -33,6 +33,6 @@ exports.initialize = function () {
|
||||||
|
|
||||||
window.billing = exports;
|
window.billing = exports;
|
||||||
|
|
||||||
$(function () {
|
$(() => {
|
||||||
exports.initialize();
|
exports.initialize();
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,7 +22,7 @@ exports.create_ajax_request = function (url, form_name, stripe_token = null, num
|
||||||
data.stripe_token = JSON.stringify(stripe_token.id);
|
data.stripe_token = JSON.stringify(stripe_token.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
form.serializeArray().forEach(function (item) {
|
form.serializeArray().forEach((item) => {
|
||||||
if (numeric_inputs.includes(item.name)) {
|
if (numeric_inputs.includes(item.name)) {
|
||||||
data[item.name] = item.value;
|
data[item.name] = item.value;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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();
|
const license_management = $('input[type=radio][name=license_management]:checked').val();
|
||||||
if (helpers.is_valid_input($("#" + license_management + "_license_count")) === false) {
|
if (helpers.is_valid_input($("#" + license_management + "_license_count")) === false) {
|
||||||
return;
|
return;
|
||||||
|
@ -28,7 +28,7 @@ exports.initialize = () => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#invoice-button").on("click", function (e) {
|
$("#invoice-button").on("click", (e) => {
|
||||||
if (helpers.is_valid_input($("#invoiced_licenses")) === false) {
|
if (helpers.is_valid_input($("#invoiced_licenses")) === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ exports.initialize = () => {
|
||||||
helpers.create_ajax_request("/json/billing/upgrade", "invoice", undefined, ["licenses"]);
|
helpers.create_ajax_request("/json/billing/upgrade", "invoice", undefined, ["licenses"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#sponsorship-button").on("click", function (e) {
|
$("#sponsorship-button").on("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
helpers.create_ajax_request("/json/billing/sponsorship", "sponsorship", undefined, undefined, "/");
|
helpers.create_ajax_request("/json/billing/sponsorship", "sponsorship", undefined, undefined, "/");
|
||||||
});
|
});
|
||||||
|
@ -69,6 +69,6 @@ exports.initialize = () => {
|
||||||
|
|
||||||
window.upgrade = exports;
|
window.upgrade = exports;
|
||||||
|
|
||||||
$(function () {
|
$(() => {
|
||||||
exports.initialize();
|
exports.initialize();
|
||||||
});
|
});
|
||||||
|
|
|
@ -200,7 +200,7 @@ exports.exception_msg = function blueslip_exception_msg(ex) {
|
||||||
return message;
|
return message;
|
||||||
};
|
};
|
||||||
|
|
||||||
$(window).on('error', function (event) {
|
$(window).on('error', (event) => {
|
||||||
const ex = event.originalEvent.error;
|
const ex = event.originalEvent.error;
|
||||||
if (!ex || ex instanceof BlueslipError) {
|
if (!ex || ex instanceof BlueslipError) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -19,7 +19,7 @@ const services = new Map();
|
||||||
const services_fields = ['base_url', 'interface',
|
const services_fields = ['base_url', 'interface',
|
||||||
'config_data', 'service_name', 'token'];
|
'config_data', 'service_name', 'token'];
|
||||||
|
|
||||||
const send_change_event = _.debounce(function () {
|
const send_change_event = _.debounce(() => {
|
||||||
settings_bots.render_bots();
|
settings_bots.render_bots();
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
|
|
|
@ -123,9 +123,7 @@ function buddy_list_create() {
|
||||||
|
|
||||||
self.get_items = function () {
|
self.get_items = function () {
|
||||||
const obj = self.container.find(self.item_sel);
|
const obj = self.container.find(self.item_sel);
|
||||||
return obj.map(function (i, elem) {
|
return obj.map((i, elem) => $(elem));
|
||||||
return $(elem);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.first_key = function () {
|
self.first_key = function () {
|
||||||
|
@ -317,7 +315,7 @@ function buddy_list_create() {
|
||||||
// sure everything's in place.
|
// sure everything's in place.
|
||||||
const scroll_container = ui.get_scroll_element($(self.scroll_container_sel));
|
const scroll_container = ui.get_scroll_element($(self.scroll_container_sel));
|
||||||
|
|
||||||
scroll_container.scroll(function () {
|
scroll_container.scroll(() => {
|
||||||
self.fill_screen_with_content();
|
self.fill_screen_with_content();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,7 +77,7 @@ function call(args, idempotent) {
|
||||||
if (!data && idempotent) {
|
if (!data && idempotent) {
|
||||||
// If idempotent, retry
|
// If idempotent, retry
|
||||||
blueslip.log("Retrying idempotent" + args);
|
blueslip.log("Retrying idempotent" + args);
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
const jqXHR = $.ajax(args);
|
const jqXHR = $.ajax(args);
|
||||||
add_pending_request(jqXHR);
|
add_pending_request(jqXHR);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
|
@ -32,7 +32,7 @@ exports.initialize = function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current_msg_list.select_id(id);
|
current_msg_list.select_id(id);
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
// The algorithm to trigger long tap is that first, we check
|
// The algorithm to trigger long tap is that first, we check
|
||||||
// whether the message is still touched after MS_DELAY ms and
|
// whether the message is still touched after MS_DELAY ms and
|
||||||
// the user isn't scrolling the messages(see other touch event
|
// the user isn't scrolling the messages(see other touch event
|
||||||
|
@ -45,18 +45,18 @@ exports.initialize = function () {
|
||||||
$(this).trigger("longtap");
|
$(this).trigger("longtap");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.bind(this), MS_DELAY);
|
}, MS_DELAY);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#main_div").on("touchend", ".messagebox", function () {
|
$("#main_div").on("touchend", ".messagebox", () => {
|
||||||
meta.touchdown = false;
|
meta.touchdown = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#main_div").on("touchmove", ".messagebox", function () {
|
$("#main_div").on("touchmove", ".messagebox", () => {
|
||||||
meta.invalid = true;
|
meta.invalid = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#main_div").on("contextmenu", ".messagebox", function (e) {
|
$("#main_div").on("contextmenu", ".messagebox", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -178,19 +178,19 @@ exports.initialize = function () {
|
||||||
$(".tooltip").remove();
|
$(".tooltip").remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('mouseenter', '.message_edit_notice', function (e) {
|
$('body').on('mouseenter', '.message_edit_notice', (e) => {
|
||||||
if (page_params.realm_allow_edit_history) {
|
if (page_params.realm_allow_edit_history) {
|
||||||
$(e.currentTarget).addClass("message_edit_notice_hover");
|
$(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) {
|
if (page_params.realm_allow_edit_history) {
|
||||||
$(e.currentTarget).removeClass("message_edit_notice_hover");
|
$(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();
|
popovers.hide_all();
|
||||||
const message_id = rows.id($(e.currentTarget).closest(".message_row"));
|
const message_id = rows.id($(e.currentTarget).closest(".message_row"));
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = current_msg_list.get_row(message_id);
|
||||||
|
@ -207,7 +207,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
// TOOLTIP FOR MESSAGE REACTIONS
|
// TOOLTIP FOR MESSAGE REACTIONS
|
||||||
|
|
||||||
$('#main_div').on('mouseenter', '.message_reaction', function (e) {
|
$('#main_div').on('mouseenter', '.message_reaction', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const elem = $(e.currentTarget);
|
const elem = $(e.currentTarget);
|
||||||
const local_id = elem.attr('data-reaction-id');
|
const local_id = elem.attr('data-reaction-id');
|
||||||
|
@ -226,14 +226,14 @@ exports.initialize = function () {
|
||||||
$(".tooltip-arrow").remove();
|
$(".tooltip-arrow").remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#main_div').on('mouseleave', '.message_reaction', function (e) {
|
$('#main_div').on('mouseleave', '.message_reaction', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$(e.currentTarget).tooltip('destroy');
|
$(e.currentTarget).tooltip('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// DESTROY PERSISTING TOOLTIPS ON HOVER
|
// DESTROY PERSISTING TOOLTIPS ON HOVER
|
||||||
|
|
||||||
$("body").on('mouseenter', '.tooltip', function (e) {
|
$("body").on('mouseenter', '.tooltip', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$(e.currentTarget).remove();
|
$(e.currentTarget).remove();
|
||||||
});
|
});
|
||||||
|
@ -252,7 +252,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
// USER STATUS MODAL
|
// USER STATUS MODAL
|
||||||
|
|
||||||
$(".user-status-value").on("click", function (e) {
|
$(".user-status-value").on("click", (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const user_status_value = $(e.currentTarget).attr("data-user-status-value");
|
const user_status_value = $(e.currentTarget).attr("data-user-status-value");
|
||||||
$("input.user_status").val(user_status_value);
|
$("input.user_status").val(user_status_value);
|
||||||
|
@ -373,7 +373,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
// MUTING
|
// MUTING
|
||||||
|
|
||||||
$('body').on('click', '.on_hover_topic_mute', function (e) {
|
$('body').on('click', '.on_hover_topic_mute', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
|
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
|
||||||
const topic = $(e.currentTarget).attr('data-topic-name');
|
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('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();
|
e.stopPropagation();
|
||||||
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
|
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
|
||||||
const topic = $(e.currentTarget).attr('data-topic-name');
|
const topic = $(e.currentTarget).attr('data-topic-name');
|
||||||
|
@ -393,12 +393,12 @@ exports.initialize = function () {
|
||||||
|
|
||||||
// RECENT TOPICS
|
// RECENT TOPICS
|
||||||
|
|
||||||
$('body').on('click', '#recent_topics_search', function (e) {
|
$('body').on('click', '#recent_topics_search', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
recent_topics.change_focused_element(e, 'click');
|
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();
|
e.stopPropagation();
|
||||||
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
|
const stream_id = parseInt($(e.currentTarget).attr('data-stream-id'), 10);
|
||||||
const topic = $(e.currentTarget).attr('data-topic-name');
|
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('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();
|
e.stopPropagation();
|
||||||
recent_topics.set_filter(e.currentTarget.dataset.filter);
|
recent_topics.set_filter(e.currentTarget.dataset.filter);
|
||||||
recent_topics.update_filters_view();
|
recent_topics.update_filters_view();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Search for all table rows (this combines stream & topic names)
|
// 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();
|
recent_topics.update_filters_view();
|
||||||
// Wait for user to go idle before initiating search.
|
// Wait for user to go idle before initiating search.
|
||||||
}, 300));
|
}, 300));
|
||||||
|
|
||||||
$('body').on('click', '#recent_topics_search_clear', function (e) {
|
$('body').on('click', '#recent_topics_search_clear', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$('#recent_topics_search').val("");
|
$('#recent_topics_search').val("");
|
||||||
recent_topics.update_filters_view();
|
recent_topics.update_filters_view();
|
||||||
|
@ -459,7 +459,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
// SIDEBARS
|
// SIDEBARS
|
||||||
|
|
||||||
$("#userlist-toggle-button").on("click", function (e) {
|
$("#userlist-toggle-button").on("click", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
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.preventDefault();
|
||||||
e.stopPropagation();
|
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');
|
const li = $(e.target).parents('li');
|
||||||
|
|
||||||
activity.narrow_for_user({li: li});
|
activity.narrow_for_user({li: li});
|
||||||
|
@ -508,7 +508,7 @@ exports.initialize = function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BUDDY LIST TOOLTIPS
|
// 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();
|
e.stopPropagation();
|
||||||
const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
|
const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
|
||||||
const user_id_string = elem.attr('data-user-id');
|
const user_id_string = elem.attr('data-user-id');
|
||||||
|
@ -516,14 +516,14 @@ exports.initialize = function () {
|
||||||
do_render_buddy_list_tooltip(elem, title_data);
|
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();
|
e.stopPropagation();
|
||||||
const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
|
const elem = $(e.currentTarget).closest(".user_sidebar_entry").find(".user-presence-link");
|
||||||
$(elem).tooltip('destroy');
|
$(elem).tooltip('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// PM LIST TOOLTIPS
|
// PM LIST TOOLTIPS
|
||||||
$("body").on('mouseenter', '#pm_user_status', function (e) {
|
$("body").on('mouseenter', '#pm_user_status', (e) => {
|
||||||
$(".tooltip").remove();
|
$(".tooltip").remove();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const elem = $(e.currentTarget);
|
const elem = $(e.currentTarget);
|
||||||
|
@ -535,14 +535,14 @@ exports.initialize = function () {
|
||||||
do_render_buddy_list_tooltip(elem, title_data);
|
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.stopPropagation();
|
||||||
$(e.currentTarget).tooltip('destroy');
|
$(e.currentTarget).tooltip('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// HOME
|
// HOME
|
||||||
|
|
||||||
$(document).on('click', ".top_left_all_messages", function (e) {
|
$(document).on('click', ".top_left_all_messages", (e) => {
|
||||||
ui_util.change_tab_to('#home');
|
ui_util.change_tab_to('#home');
|
||||||
narrow.deactivate();
|
narrow.deactivate();
|
||||||
search.update_button_visibility();
|
search.update_button_visibility();
|
||||||
|
@ -552,7 +552,7 @@ exports.initialize = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".brand").on('click', function (e) {
|
$(".brand").on('click', (e) => {
|
||||||
if (overlays.is_active()) {
|
if (overlays.is_active()) {
|
||||||
overlays.close_active();
|
overlays.close_active();
|
||||||
} else {
|
} else {
|
||||||
|
@ -577,11 +577,11 @@ exports.initialize = function () {
|
||||||
stream_popover.register_click_handlers();
|
stream_popover.register_click_handlers();
|
||||||
notifications.register_click_handlers();
|
notifications.register_click_handlers();
|
||||||
|
|
||||||
$('body').on('click', '.logout_button', function () {
|
$('body').on('click', '.logout_button', () => {
|
||||||
$('#logout_form').submit();
|
$('#logout_form').submit();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.restart_get_events_button').click(function () {
|
$('.restart_get_events_button').click(() => {
|
||||||
server_events.restart_get_events({dont_block: true});
|
server_events.restart_get_events({dont_block: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -589,12 +589,12 @@ exports.initialize = function () {
|
||||||
$("body").on("click", ".alert-box > div .exit", function () {
|
$("body").on("click", ".alert-box > div .exit", function () {
|
||||||
const $alert = $(this).closest(".alert-box > div");
|
const $alert = $(this).closest(".alert-box > div");
|
||||||
$alert.addClass("fade-out");
|
$alert.addClass("fade-out");
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
$alert.removeClass("fade-out show");
|
$alert.removeClass("fade-out show");
|
||||||
}, 300);
|
}, 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#settings_page").on("click", ".collapse-settings-btn", function () {
|
$("#settings_page").on("click", ".collapse-settings-btn", () => {
|
||||||
settings_toggle.toggle_org_setting_collapse();
|
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
|
// NB: This just binds to current elements, and won't bind to elements
|
||||||
// created after ready() is called.
|
// created after ready() is called.
|
||||||
$('#compose-send-status .compose-send-status-close').click(
|
$('#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(
|
$('#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();
|
popovers.hide_mobile_message_buttons_popover();
|
||||||
compose_actions.start('stream', {trigger: 'new topic button'});
|
compose_actions.start('stream', {trigger: 'new topic button'});
|
||||||
});
|
});
|
||||||
$('.compose_private_button').click(function () {
|
$('.compose_private_button').click(() => {
|
||||||
popovers.hide_mobile_message_buttons_popover();
|
popovers.hide_mobile_message_buttons_popover();
|
||||||
compose_actions.start('private');
|
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();
|
popovers.hide_mobile_message_buttons_popover();
|
||||||
compose_actions.start('stream', {trigger: 'new topic button'});
|
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();
|
popovers.hide_mobile_message_buttons_popover();
|
||||||
compose_actions.start('private');
|
compose_actions.start('private');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.compose_reply_button').click(function () {
|
$('.compose_reply_button').click(() => {
|
||||||
compose_actions.respond_to_message({trigger: 'reply button'});
|
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'});
|
compose_actions.start('stream', {trigger: 'empty feed message'});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$('.empty_feed_compose_private').click(function (e) {
|
$('.empty_feed_compose_private').click((e) => {
|
||||||
compose_actions.start('private', {trigger: 'empty feed message'});
|
compose_actions.start('private', {trigger: 'empty feed message'});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
@ -677,23 +677,23 @@ exports.initialize = function () {
|
||||||
$("#compose_buttons").click(handle_compose_click);
|
$("#compose_buttons").click(handle_compose_click);
|
||||||
$(".compose-content").click(handle_compose_click);
|
$(".compose-content").click(handle_compose_click);
|
||||||
|
|
||||||
$("#compose_close").click(function () {
|
$("#compose_close").click(() => {
|
||||||
compose_actions.cancel();
|
compose_actions.cancel();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#streams_inline_cog").click(function (e) {
|
$("#streams_inline_cog").click((e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
hashchange.go_to_location('streams/subscribed');
|
hashchange.go_to_location('streams/subscribed');
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#streams_filter_icon").click(function (e) {
|
$("#streams_filter_icon").click((e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
stream_list.toggle_filter_displayed(e);
|
stream_list.toggle_filter_displayed(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
// WEBATHENA
|
// WEBATHENA
|
||||||
|
|
||||||
$('body').on('click', '.webathena_login', function (e) {
|
$('body').on('click', '.webathena_login', (e) => {
|
||||||
$("#zephyr-mirror-error").removeClass("show");
|
$("#zephyr-mirror-error").removeClass("show");
|
||||||
const principal = ["zephyr", "zephyr"];
|
const principal = ["zephyr", "zephyr"];
|
||||||
WinChan.open({
|
WinChan.open({
|
||||||
|
@ -703,7 +703,7 @@ exports.initialize = function () {
|
||||||
realm: "ATHENA.MIT.EDU",
|
realm: "ATHENA.MIT.EDU",
|
||||||
principal: principal,
|
principal: principal,
|
||||||
},
|
},
|
||||||
}, function (err, r) {
|
}, (err, r) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
blueslip.warn(err);
|
blueslip.warn(err);
|
||||||
return;
|
return;
|
||||||
|
@ -731,9 +731,7 @@ exports.initialize = function () {
|
||||||
// End Webathena code
|
// End Webathena code
|
||||||
|
|
||||||
// disable the draggability for left-sidebar components
|
// disable the draggability for left-sidebar components
|
||||||
$('#stream_filters, #global_filters').on('dragstart', function () {
|
$('#stream_filters, #global_filters').on('dragstart', () => false);
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
const map = {
|
const map = {
|
||||||
|
@ -760,9 +758,7 @@ exports.initialize = function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("drop", ".editable-section", function () {
|
$(document).on("drop", ".editable-section", () => false);
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on("input", ".editable-section", function () {
|
$(document).on("input", ".editable-section", function () {
|
||||||
// if there are any child nodes, inclusive of <br> which means you
|
// if there are any child nodes, inclusive of <br> which means you
|
||||||
|
@ -863,7 +859,7 @@ exports.initialize = function () {
|
||||||
$('#hotspot_' + hotspot_name + '_icon').remove();
|
$('#hotspot_' + hotspot_name + '_icon').remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.hotspot-button', function (e) {
|
$('body').on('click', '.hotspot-button', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
@ -872,14 +868,14 @@ exports.initialize = function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// stop propagation
|
// stop propagation
|
||||||
$('body').on('click', '.hotspot.overlay .hotspot-popover', function (e) {
|
$('body').on('click', '.hotspot.overlay .hotspot-popover', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// MAIN CLICK HANDLER
|
// MAIN CLICK HANDLER
|
||||||
|
|
||||||
$(document).on('click', function (e) {
|
$(document).on('click', (e) => {
|
||||||
if (e.button !== 0 || $(e.target).is(".drag")) {
|
if (e.button !== 0 || $(e.target).is(".drag")) {
|
||||||
// Firefox emits right click events on the document, but not on
|
// Firefox emits right click events on the document, but not on
|
||||||
// the child nodes, so the #compose stopPropagation doesn't get a
|
// 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
|
// Workaround for Bootstrap issue #5900, which basically makes dropdowns
|
||||||
// unclickable on mobile devices.
|
// unclickable on mobile devices.
|
||||||
// https://github.com/twitter/bootstrap/issues/5900
|
// 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();
|
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();
|
settings_panel_menu.mobile_deactivate_section();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ if (module.hot) {
|
||||||
exports.status_classes = 'alert-error alert-success alert-info alert-warning';
|
exports.status_classes = 'alert-error alert-success alert-info alert-warning';
|
||||||
|
|
||||||
exports.autofocus = function (selector) {
|
exports.autofocus = function (selector) {
|
||||||
$(function () {
|
$(() => {
|
||||||
$(selector).focus();
|
$(selector).focus();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ exports.toggle = function (opts) {
|
||||||
// classes need to be added for correct alignment or other purposes
|
// classes need to be added for correct alignment or other purposes
|
||||||
_component.addClass(opts.html_class);
|
_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
|
// create a tab with a tab-id so they don't have to be referenced
|
||||||
// by text value which can be inconsistent.
|
// by text value which can be inconsistent.
|
||||||
const tab = $("<div class='ind-tab' data-tab-key='" + value.key + "' data-tab-id='" + i + "' tabindex='0'>" + value.label + "</div>");
|
const tab = $("<div class='ind-tab' data-tab-key='" + value.key + "' data-tab-id='" + i + "' tabindex='0'>" + value.label + "</div>");
|
||||||
|
|
|
@ -259,7 +259,7 @@ exports.compose_error = compose_error;
|
||||||
function nonexistent_stream_reply_error() {
|
function nonexistent_stream_reply_error() {
|
||||||
$("#nonexistent_stream_reply_error").show();
|
$("#nonexistent_stream_reply_error").show();
|
||||||
$("#compose-reply-error-msg").html("There are no messages to reply to yet.");
|
$("#compose-reply-error-msg").html("There are no messages to reply to yet.");
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
$("#nonexistent_stream_reply_error").hide();
|
$("#nonexistent_stream_reply_error").hide();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
|
@ -936,14 +936,14 @@ exports.initialize = function () {
|
||||||
$("#below-compose-content .video_link").toggle(exports.compute_show_video_chat_button());
|
$("#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('keyup', update_fade);
|
||||||
$('#stream_message_recipient_stream,#stream_message_recipient_topic,#private_message_recipient').on('change', 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());
|
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());
|
exports.handle_keyup(event, $("#compose-textarea").expectOne());
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#compose form").on("submit", function (e) {
|
$("#compose form").on("submit", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
exports.finish();
|
exports.finish();
|
||||||
});
|
});
|
||||||
|
@ -952,7 +952,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
upload.feature_check($("#compose #attach_files"));
|
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.preventDefault();
|
||||||
|
|
||||||
$(event.target).parents('.compose-all-everyone').remove();
|
$(event.target).parents('.compose-all-everyone').remove();
|
||||||
|
@ -961,7 +961,7 @@ exports.initialize = function () {
|
||||||
exports.finish();
|
exports.finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#compose-announce").on('click', '.compose-announce-confirm', function (event) {
|
$("#compose-announce").on('click', '.compose-announce-confirm', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
$(event.target).parents('.compose-announce').remove();
|
$(event.target).parents('.compose-announce').remove();
|
||||||
|
@ -970,7 +970,7 @@ exports.initialize = function () {
|
||||||
exports.finish();
|
exports.finish();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#compose-send-status").on('click', '.sub_unsub_button', function (event) {
|
$("#compose-send-status").on('click', '.sub_unsub_button', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const stream_name = $('#stream_message_recipient_stream').val();
|
const stream_name = $('#stream_message_recipient_stream').val();
|
||||||
|
@ -982,13 +982,13 @@ exports.initialize = function () {
|
||||||
$("#compose-send-status").hide();
|
$("#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();
|
event.preventDefault();
|
||||||
|
|
||||||
$("#compose-send-status").hide();
|
$("#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();
|
event.preventDefault();
|
||||||
|
|
||||||
const invite_row = $(event.target).parents('.compose_invite_user');
|
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);
|
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 invite_row = $(event.target).parents('.compose_invite_user');
|
||||||
const all_invites = $("#compose_invite_users");
|
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_row = $(event.target).parents('.compose_private_stream_alert');
|
||||||
const stream_alert = $("#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
|
// Click event binding for "Attach files" button
|
||||||
// Triggers a click on a hidden file input field
|
// Triggers a click on a hidden file input field
|
||||||
|
|
||||||
$("#compose").on("click", "#attach_files", function (e) {
|
$("#compose").on("click", "#attach_files", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$("#compose #file_input").trigger("click");
|
$("#compose #file_input").trigger("click");
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.video_link', function (e) {
|
$('body').on('click', '.video_link', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
let target_textarea;
|
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();
|
e.preventDefault();
|
||||||
const content = $("#compose-textarea").val();
|
const content = $("#compose-textarea").val();
|
||||||
$("#compose-textarea").hide();
|
$("#compose-textarea").hide();
|
||||||
|
@ -1149,7 +1149,7 @@ exports.initialize = function () {
|
||||||
exports.render_and_show_preview($("#markdown_preview_spinner"), $("#preview_content"), content);
|
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();
|
e.preventDefault();
|
||||||
exports.clear_preview_area();
|
exports.clear_preview_area();
|
||||||
});
|
});
|
||||||
|
@ -1158,7 +1158,7 @@ exports.initialize = function () {
|
||||||
mode: "compose",
|
mode: "compose",
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#compose-textarea").focus(function () {
|
$("#compose-textarea").focus(() => {
|
||||||
const opts = {
|
const opts = {
|
||||||
message_type: compose_state.get_message_type(),
|
message_type: compose_state.get_message_type(),
|
||||||
stream: $('#stream_message_recipient_stream').val(),
|
stream: $('#stream_message_recipient_stream').val(),
|
||||||
|
|
|
@ -69,7 +69,7 @@ function fade_messages() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Defer updating all message groups so that the compose box can open sooner
|
// 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");
|
const all_groups = rows.get_table(current_msg_list.table_name).find(".recipient_row");
|
||||||
|
|
||||||
if (current_msg_list !== expected_msg_list ||
|
if (current_msg_list !== expected_msg_list ||
|
||||||
|
|
|
@ -51,9 +51,7 @@ exports.get_user_ids_string = function () {
|
||||||
exports.get_emails = function () {
|
exports.get_emails = function () {
|
||||||
// return something like "alice@example.com,bob@example.com"
|
// return something like "alice@example.com,bob@example.com"
|
||||||
const user_ids = exports.get_user_ids();
|
const user_ids = exports.get_user_ids();
|
||||||
const emails = user_ids.map(function (id) {
|
const emails = user_ids.map((id) => people.get_by_user_id(id).email).join(",");
|
||||||
return people.get_by_user_id(id).email;
|
|
||||||
}).join(",");
|
|
||||||
return emails;
|
return emails;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,13 +63,13 @@ exports.replace_syntax = function (old_syntax, new_syntax, textarea) {
|
||||||
textarea = $('#compose-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
|
// We need this anonymous function to avoid JavaScript's
|
||||||
// replace() function treating `$`s in new_syntax as special syntax. See
|
// 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
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Description
|
||||||
// for details.
|
// for details.
|
||||||
return new_syntax;
|
new_syntax
|
||||||
}));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.compute_placeholder_text = function (opts) {
|
exports.compute_placeholder_text = function (opts) {
|
||||||
|
|
|
@ -257,12 +257,12 @@ function select_on_focus(field_id) {
|
||||||
// conditions in Chrome so we need to protect against infinite
|
// conditions in Chrome so we need to protect against infinite
|
||||||
// recursion.
|
// recursion.
|
||||||
let in_handler = false;
|
let in_handler = false;
|
||||||
$("#" + field_id).focus(function () {
|
$("#" + field_id).focus(() => {
|
||||||
if (in_handler) {
|
if (in_handler) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
in_handler = true;
|
in_handler = true;
|
||||||
$("#" + field_id).select().one('mouseup', function (e) {
|
$("#" + field_id).select().one('mouseup', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
in_handler = false;
|
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
|
// Keep the cursor after the newly inserted text, as Bootstrap will call textbox.change() to
|
||||||
// overwrite the text in the textbox.
|
// overwrite the text in the textbox.
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
textbox.caret(beginning.length, beginning.length);
|
textbox.caret(beginning.length, beginning.length);
|
||||||
// Also, trigger autosize to check if compose box needs to be resized.
|
// Also, trigger autosize to check if compose box needs to be resized.
|
||||||
compose_ui.autosize_textarea();
|
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.
|
// topic_jump doesn't actually have a typeahead popover, so we return quickly here.
|
||||||
return matches;
|
return matches;
|
||||||
case 'topic_list':
|
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").keydown(handle_keydown);
|
||||||
$("form#send_message_form").keyup(handle_keyup);
|
$("form#send_message_form").keyup(handle_keyup);
|
||||||
|
|
||||||
$("#enter_sends").click(function () {
|
$("#enter_sends").click(() => {
|
||||||
const send_button = $("#compose-send-button");
|
const send_button = $("#compose-send-button");
|
||||||
page_params.enter_sends = $("#enter_sends").is(":checked");
|
page_params.enter_sends = $("#enter_sends").is(":checked");
|
||||||
if (page_params.enter_sends) {
|
if (page_params.enter_sends) {
|
||||||
|
@ -1097,7 +1097,7 @@ exports.initialize = function () {
|
||||||
return typeahead_helper.render_typeahead_item({ primary: item });
|
return typeahead_helper.render_typeahead_item({ primary: item });
|
||||||
},
|
},
|
||||||
sorter: function (items) {
|
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)) {
|
if (sorted.length > 0 && !sorted.includes(this.query)) {
|
||||||
sorted.unshift(this.query);
|
sorted.unshift(this.query);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,12 +62,12 @@ exports.launch = function (conf) {
|
||||||
yes_button.html(conf.html_yes_button);
|
yes_button.html(conf.html_yes_button);
|
||||||
|
|
||||||
// Set up handlers.
|
// Set up handlers.
|
||||||
yes_button.on('click', function () {
|
yes_button.on('click', () => {
|
||||||
overlays.close_modal('#confirm_dialog_modal');
|
overlays.close_modal('#confirm_dialog_modal');
|
||||||
conf.on_click();
|
conf.on_click();
|
||||||
});
|
});
|
||||||
|
|
||||||
confirm_dialog.on('hide', function () {
|
confirm_dialog.on('hide', () => {
|
||||||
confirm_dialog.remove();
|
confirm_dialog.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ function select_div(div, selection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_div(div, ranges, selection) {
|
function remove_div(div, ranges, selection) {
|
||||||
window.setTimeout(function () {
|
window.setTimeout(() => {
|
||||||
selection = window.getSelection();
|
selection = window.getSelection();
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
|
|
||||||
|
@ -210,9 +210,7 @@ exports.analyze_selection = function (selection) {
|
||||||
ranges.push(range);
|
ranges.push(range);
|
||||||
|
|
||||||
startc = $(range.startContainer);
|
startc = $(range.startContainer);
|
||||||
start_data = find_boundary_tr($(startc.parents('.selectable_row, .message_header')[0]), function (row) {
|
start_data = find_boundary_tr($(startc.parents('.selectable_row, .message_header')[0]), (row) => row.next());
|
||||||
return row.next();
|
|
||||||
});
|
|
||||||
if (start_data === undefined) {
|
if (start_data === undefined) {
|
||||||
// Skip any selection sections that don't intersect a message.
|
// Skip any selection sections that don't intersect a message.
|
||||||
continue;
|
continue;
|
||||||
|
@ -237,9 +235,7 @@ exports.analyze_selection = function (selection) {
|
||||||
} else {
|
} else {
|
||||||
initial_end_tr = $(endc.parents('.selectable_row')[0]);
|
initial_end_tr = $(endc.parents('.selectable_row')[0]);
|
||||||
}
|
}
|
||||||
end_data = find_boundary_tr(initial_end_tr, function (row) {
|
end_data = find_boundary_tr(initial_end_tr, (row) => row.prev());
|
||||||
return row.prev();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (end_data === undefined) {
|
if (end_data === undefined) {
|
||||||
// Skip any selection sections that don't intersect a message.
|
// Skip any selection sections that don't intersect a message.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let csrf_token;
|
let csrf_token;
|
||||||
$(function () {
|
$(() => {
|
||||||
// This requires that we used Jinja2's {% csrf_input %} somewhere on the page.
|
// This requires that we used Jinja2's {% csrf_input %} somewhere on the page.
|
||||||
const csrf_input = $('input[name="csrfmiddlewaretoken"]');
|
const csrf_input = $('input[name="csrfmiddlewaretoken"]');
|
||||||
if (csrf_input.length > 0) {
|
if (csrf_input.length > 0) {
|
||||||
|
|
|
@ -30,11 +30,9 @@ export function check_duplicate_ids() {
|
||||||
const collisions = [];
|
const collisions = [];
|
||||||
let total_collisions = 0;
|
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)) {
|
if (o.id && ids.has(o.id)) {
|
||||||
const el = collisions.find(function (c) {
|
const el = collisions.find((c) => c.id === o.id);
|
||||||
return c.id === o.id;
|
|
||||||
});
|
|
||||||
|
|
||||||
ids.add(o.id);
|
ids.add(o.id);
|
||||||
total_collisions += 1;
|
total_collisions += 1;
|
||||||
|
|
|
@ -318,9 +318,9 @@ exports.launch = function () {
|
||||||
|
|
||||||
const unsorted_raw_drafts = Object.values(data);
|
const unsorted_raw_drafts = Object.values(data);
|
||||||
|
|
||||||
const sorted_raw_drafts = unsorted_raw_drafts.sort(function (draft_a, draft_b) {
|
const sorted_raw_drafts = unsorted_raw_drafts.sort(
|
||||||
return draft_b.updatedAt - draft_a.updatedAt;
|
(draft_a, draft_b) => draft_b.updatedAt - draft_a.updatedAt
|
||||||
});
|
);
|
||||||
|
|
||||||
const sorted_formatted_drafts = sorted_raw_drafts.map(exports.format_draft).filter(Boolean);
|
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 () {
|
exports.initialize = function () {
|
||||||
window.addEventListener("beforeunload", function () {
|
window.addEventListener("beforeunload", () => {
|
||||||
exports.update_draft();
|
exports.update_draft();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -522,7 +522,7 @@ exports.initialize = function () {
|
||||||
|
|
||||||
$("#compose-textarea").focusout(exports.update_draft);
|
$("#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);
|
activate_element(e.target);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@ const DropdownListWidget = function (opts) {
|
||||||
const value = $(this).attr('data-value');
|
const value = $(this).attr('data-value');
|
||||||
update(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);
|
update(opts.null_value);
|
||||||
e.preventDefault();
|
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();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
dropdown_toggle.click(function () {
|
dropdown_toggle.click(() => {
|
||||||
search_input.val("").trigger("input");
|
search_input.val("").trigger("input");
|
||||||
});
|
});
|
||||||
|
|
||||||
dropdown_toggle.focus(function (e) {
|
dropdown_toggle.focus((e) => {
|
||||||
// On opening a Bootstrap Dropdown, the parent element recieves focus.
|
// On opening a Bootstrap Dropdown, the parent element recieves focus.
|
||||||
// Here, we want our search input to have focus instead.
|
// Here, we want our search input to have focus instead.
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
search_input.focus();
|
search_input.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
search_input.keydown(function (e) {
|
search_input.keydown((e) => {
|
||||||
if (!/(38|40|27)/.test(e.keyCode)) {
|
if (!/(38|40|27)/.test(e.keyCode)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ function resend_message(message, row) {
|
||||||
|
|
||||||
function on_error(response) {
|
function on_error(response) {
|
||||||
exports.message_send_error(message.id, response);
|
exports.message_send_error(message.id, response);
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
retry_spinner.toggleClass('rotating', false);
|
retry_spinner.toggleClass('rotating', false);
|
||||||
}, 300);
|
}, 300);
|
||||||
blueslip.log("Manual resend of message failed");
|
blueslip.log("Manual resend of message failed");
|
||||||
|
|
|
@ -505,7 +505,7 @@ exports.emoji_select_tab = function (elt) {
|
||||||
const scrollheight = elt.prop('scrollHeight');
|
const scrollheight = elt.prop('scrollHeight');
|
||||||
const elt_height = elt.height();
|
const elt_height = elt.height();
|
||||||
let currently_selected = "";
|
let currently_selected = "";
|
||||||
section_head_offsets.forEach(function (o) {
|
section_head_offsets.forEach((o) => {
|
||||||
if (scrolltop + elt_height / 2 >= o.position_y) {
|
if (scrolltop + elt_height / 2 >= o.position_y) {
|
||||||
currently_selected = o.section;
|
currently_selected = o.section;
|
||||||
}
|
}
|
||||||
|
@ -528,14 +528,14 @@ exports.emoji_select_tab = function (elt) {
|
||||||
function register_popover_events(popover) {
|
function register_popover_events(popover) {
|
||||||
const $emoji_map = popover.find('.emoji-popover-emoji-map');
|
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));
|
exports.emoji_select_tab(ui.get_scroll_element($emoji_map));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.emoji-popover-filter').on('input', filter_emojis);
|
$('.emoji-popover-filter').on('input', filter_emojis);
|
||||||
$('.emoji-popover-filter').keydown(maybe_select_emoji);
|
$('.emoji-popover-filter').keydown(maybe_select_emoji);
|
||||||
$('.emoji-popover').keypress(process_keypress);
|
$('.emoji-popover').keypress(process_keypress);
|
||||||
$('.emoji-popover').keydown(function (e) {
|
$('.emoji-popover').keydown((e) => {
|
||||||
// Because of cross-browser issues we need to handle backspace
|
// Because of cross-browser issues we need to handle backspace
|
||||||
// key separately. Firefox fires `keypress` event for backspace
|
// key separately. Firefox fires `keypress` event for backspace
|
||||||
// key but chrome doesn't so we need to trigger the logic for
|
// 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);
|
exports.toggle_emoji_popover(this, message_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#main_div").on("mouseenter", ".reaction_button", function (e) {
|
$("#main_div").on("mouseenter", ".reaction_button", (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
const elem = $(e.currentTarget);
|
const elem = $(e.currentTarget);
|
||||||
|
@ -685,12 +685,12 @@ exports.register_click_handlers = function () {
|
||||||
$(".tooltip-arrow").remove();
|
$(".tooltip-arrow").remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#main_div').on('mouseleave', '.reaction_button', function (e) {
|
$('#main_div').on('mouseleave', '.reaction_button', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
$(e.currentTarget).tooltip('hide');
|
$(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');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -710,20 +710,18 @@ exports.register_click_handlers = function () {
|
||||||
const $popover = $(e.currentTarget).closest('.emoji-info-popover').expectOne();
|
const $popover = $(e.currentTarget).closest('.emoji-info-popover').expectOne();
|
||||||
const $emoji_map = $popover.find(".emoji-popover-emoji-map");
|
const $emoji_map = $popover.find(".emoji-popover-emoji-map");
|
||||||
|
|
||||||
const offset = section_head_offsets.find(function (o) {
|
const offset = section_head_offsets.find((o) => o.section === $(this).attr("data-tab-name"));
|
||||||
return o.section === $(this).attr("data-tab-name");
|
|
||||||
}.bind(this));
|
|
||||||
|
|
||||||
if (offset) {
|
if (offset) {
|
||||||
ui.get_scroll_element($emoji_map).scrollTop(offset.position_y);
|
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();
|
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_id = $(e.currentTarget).data("emoji-id");
|
||||||
const emoji_coordinates = get_emoji_coordinates(emoji_id);
|
const emoji_coordinates = get_emoji_coordinates(emoji_id);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ function set_up_handlers() {
|
||||||
meta.handlers_set = true;
|
meta.handlers_set = true;
|
||||||
|
|
||||||
// if the user mouses over the notification, don't hide it.
|
// if the user mouses over the notification, don't hide it.
|
||||||
meta.$container.mouseenter(function () {
|
meta.$container.mouseenter(() => {
|
||||||
if (!meta.opened) {
|
if (!meta.opened) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ function set_up_handlers() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// once the user's mouse leaves the notification, restart the countdown.
|
// once the user's mouse leaves the notification, restart the countdown.
|
||||||
meta.$container.mouseleave(function () {
|
meta.$container.mouseleave(() => {
|
||||||
if (!meta.opened) {
|
if (!meta.opened) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -91,11 +91,11 @@ function set_up_handlers() {
|
||||||
meta.hide_me_time = Math.max(meta.hide_me_time, new Date().getTime() + 2000);
|
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();
|
animate.fadeOut();
|
||||||
});
|
});
|
||||||
|
|
||||||
meta.$container.on('click', '.feedback_undo', function () {
|
meta.$container.on('click', '.feedback_undo', () => {
|
||||||
if (meta.undo) {
|
if (meta.undo) {
|
||||||
meta.undo();
|
meta.undo();
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,8 +369,8 @@ Filter.prototype = {
|
||||||
|
|
||||||
operands: function (operator) {
|
operands: function (operator) {
|
||||||
return _.chain(this._operators)
|
return _.chain(this._operators)
|
||||||
.filter(function (elem) { return !elem.negated && elem.operator === operator; })
|
.filter((elem) => !elem.negated && elem.operator === operator)
|
||||||
.map(function (elem) { return elem.operand; })
|
.map((elem) => elem.operand)
|
||||||
.value();
|
.value();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -86,12 +86,12 @@ exports.update_org_settings_menu_item = function () {
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
exports.update_org_settings_menu_item();
|
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
|
// Save the position of our old tab away, before we switch
|
||||||
const old_tab = $(e.relatedTarget).attr('href');
|
const old_tab = $(e.relatedTarget).attr('href');
|
||||||
scroll_positions.set(old_tab, message_viewport.scrollTop());
|
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');
|
const target_tab = $(e.target).attr('href');
|
||||||
// Hide all our error messages when switching tabs
|
// Hide all our error messages when switching tabs
|
||||||
$('.alert').removeClass("show");
|
$('.alert').removeClass("show");
|
||||||
|
|
|
@ -281,7 +281,7 @@ exports.go_to_location = function (hash) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
$(window).on('hashchange', function (e) {
|
$(window).on('hashchange', (e) => {
|
||||||
hashchanged(false, e.originalEvent);
|
hashchanged(false, e.originalEvent);
|
||||||
});
|
});
|
||||||
hashchanged(true);
|
hashchanged(true);
|
||||||
|
|
|
@ -634,7 +634,7 @@ exports.process_hotkey = function (e, hotkey) {
|
||||||
compose_actions.start('private', {trigger: "compose_hotkey"});
|
compose_actions.start('private', {trigger: "compose_hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case 'narrow_private':
|
case 'narrow_private':
|
||||||
return do_narrow_action(function (target, opts) {
|
return do_narrow_action((target, opts) => {
|
||||||
narrow.by('is', 'private', opts);
|
narrow.by('is', 'private', opts);
|
||||||
});
|
});
|
||||||
case 'query_streams':
|
case 'query_streams':
|
||||||
|
@ -792,7 +792,7 @@ exports.process_keydown = function (e) {
|
||||||
return exports.process_hotkey(e, hotkey);
|
return exports.process_hotkey(e, hotkey);
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).keydown(function (e) {
|
$(document).keydown((e) => {
|
||||||
if (exports.process_keydown(e)) {
|
if (exports.process_keydown(e)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
@ -806,7 +806,7 @@ exports.process_keypress = function (e) {
|
||||||
return exports.process_hotkey(e, hotkey);
|
return exports.process_hotkey(e, hotkey);
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).keypress(function (e) {
|
$(document).keypress((e) => {
|
||||||
if (exports.process_keypress(e)) {
|
if (exports.process_keypress(e)) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ function insert_hotspot_into_DOM(hotspot) {
|
||||||
'<div class="bounce"><span class="bounce-icon">?</span></div>' +
|
'<div class="bounce"><span class="bounce-icon">?</span></div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
$('body').prepend(hotspot_icon_HTML);
|
$('body').prepend(hotspot_icon_HTML);
|
||||||
$('body').prepend(hotspot_overlay_HTML);
|
$('body').prepend(hotspot_overlay_HTML);
|
||||||
if (place_icon(hotspot)) {
|
if (place_icon(hotspot)) {
|
||||||
|
@ -211,8 +211,8 @@ function insert_hotspot_into_DOM(hotspot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reposition on any event that might update the UI
|
// reposition on any event that might update the UI
|
||||||
['resize', 'scroll', 'onkeydown', 'click'].forEach(function (event_name) {
|
['resize', 'scroll', 'onkeydown', 'click'].forEach((event_name) => {
|
||||||
window.addEventListener(event_name, _.debounce(function () {
|
window.addEventListener(event_name, _.debounce(() => {
|
||||||
if (place_icon(hotspot)) {
|
if (place_icon(hotspot)) {
|
||||||
place_popover(hotspot);
|
place_popover(hotspot);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ function close_read_hotspots(new_hotspots) {
|
||||||
|
|
||||||
exports.load_new = function (new_hotspots) {
|
exports.load_new = function (new_hotspots) {
|
||||||
close_read_hotspots(new_hotspots);
|
close_read_hotspots(new_hotspots);
|
||||||
new_hotspots.forEach(function (hotspot) {
|
new_hotspots.forEach((hotspot) => {
|
||||||
hotspot.location = HOTSPOT_LOCATIONS.get(hotspot.name);
|
hotspot.location = HOTSPOT_LOCATIONS.get(hotspot.name);
|
||||||
});
|
});
|
||||||
new_hotspots.forEach(insert_hotspot_into_DOM);
|
new_hotspots.forEach(insert_hotspot_into_DOM);
|
||||||
|
|
|
@ -16,9 +16,7 @@ exports.process_loaded_messages = function (messages) {
|
||||||
|
|
||||||
exports.get_huddles = function () {
|
exports.get_huddles = function () {
|
||||||
let huddles = Array.from(huddle_timestamps.keys());
|
let huddles = Array.from(huddle_timestamps.keys());
|
||||||
huddles = _.sortBy(huddles, function (huddle) {
|
huddles = _.sortBy(huddles, (huddle) => huddle_timestamps.get(huddle));
|
||||||
return huddle_timestamps.get(huddle);
|
|
||||||
});
|
|
||||||
return huddles.reverse();
|
return huddles.reverse();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -187,16 +187,14 @@ exports.create = function (opts) {
|
||||||
|
|
||||||
insertManyPills: function (pills) {
|
insertManyPills: function (pills) {
|
||||||
if (typeof pills === "string") {
|
if (typeof pills === "string") {
|
||||||
pills = pills.split(/,/g).map(function (pill) {
|
pills = pills.split(/,/g).map((pill) => pill.trim());
|
||||||
return pill.trim();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is an array to push all the errored values to, so it's drafts
|
// this is an array to push all the errored values to, so it's drafts
|
||||||
// of pills for the user to fix.
|
// of pills for the user to fix.
|
||||||
const drafts = [];
|
const drafts = [];
|
||||||
|
|
||||||
pills.forEach(function (pill) {
|
pills.forEach((pill) => {
|
||||||
// if this returns `false`, it erroed and we should push it to
|
// if this returns `false`, it erroed and we should push it to
|
||||||
// the draft pills.
|
// the draft pills.
|
||||||
if (funcs.appendPill(pill) === false) {
|
if (funcs.appendPill(pill) === false) {
|
||||||
|
@ -235,7 +233,7 @@ exports.create = function (opts) {
|
||||||
};
|
};
|
||||||
|
|
||||||
(function events() {
|
(function events() {
|
||||||
store.$parent.on("keydown", ".input", function (e) {
|
store.$parent.on("keydown", ".input", (e) => {
|
||||||
const char = e.keyCode || e.charCode;
|
const char = e.keyCode || e.charCode;
|
||||||
|
|
||||||
if (char === KEY.ENTER) {
|
if (char === KEY.ENTER) {
|
||||||
|
@ -300,7 +298,7 @@ exports.create = function (opts) {
|
||||||
|
|
||||||
// handle events while hovering on ".pill" elements.
|
// handle events while hovering on ".pill" elements.
|
||||||
// the three primary events are next, previous, and delete.
|
// 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 char = e.keyCode || e.charCode;
|
||||||
|
|
||||||
const $pill = store.$parent.find(".pill:focus");
|
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
|
// replace formatted input with plaintext to allow for sane copy-paste
|
||||||
// actions.
|
// actions.
|
||||||
store.$parent.on("paste", ".input", function (e) {
|
store.$parent.on("paste", ".input", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// get text representation of clipboard
|
// 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 id = store.$parent.find(":focus").data("id");
|
||||||
const data = funcs.getByID(id);
|
const data = funcs.getByID(id);
|
||||||
e.originalEvent.clipboardData.setData("text/plain", store.get_text_from_item(data.item));
|
e.originalEvent.clipboardData.setData("text/plain", store.get_text_from_item(data.item));
|
||||||
|
|
|
@ -73,7 +73,7 @@ function submit_invitation_form() {
|
||||||
const invitee_emails_errored = [];
|
const invitee_emails_errored = [];
|
||||||
const error_list = [];
|
const error_list = [];
|
||||||
let is_invitee_deactivated = false;
|
let is_invitee_deactivated = false;
|
||||||
arr.errors.forEach(function (value) {
|
arr.errors.forEach((value) => {
|
||||||
const [email, error_message, deactivated] = value;
|
const [email, error_message, deactivated] = value;
|
||||||
error_list.push(`${email}: ${error_message}`);
|
error_list.push(`${email}: ${error_message}`);
|
||||||
if (deactivated) {
|
if (deactivated) {
|
||||||
|
@ -161,17 +161,17 @@ exports.launch = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.initialize = 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);
|
$('#streams_to_add :checkbox').prop('checked', true);
|
||||||
e.preventDefault();
|
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);
|
$('#streams_to_add :checkbox').prop('checked', false);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#submit-invitation").on("click", function () {
|
$("#submit-invitation").on("click", () => {
|
||||||
const is_generate_invite_link = $('#generate_multiuse_invite_radio').prop('checked');
|
const is_generate_invite_link = $('#generate_multiuse_invite_radio').prop('checked');
|
||||||
if (is_generate_invite_link) {
|
if (is_generate_invite_link) {
|
||||||
generate_multiuse_invite();
|
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);
|
$("#generate_multiuse_invite_radio").prop("checked", true);
|
||||||
$("#multiuse_radio_section").show();
|
$("#multiuse_radio_section").show();
|
||||||
$("#invite-method-choice").hide();
|
$("#invite-method-choice").hide();
|
||||||
|
@ -190,7 +190,7 @@ exports.initialize = function () {
|
||||||
reset_error_messages();
|
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);
|
$('#invitee_emails').prop('disabled', false);
|
||||||
$('#submit-invitation').text(i18n.t('Invite'));
|
$('#submit-invitation').text(i18n.t('Invite'));
|
||||||
$('#submit-invitation').data('loading-text', i18n.t('Inviting...'));
|
$('#submit-invitation').data('loading-text', i18n.t('Inviting...'));
|
||||||
|
|
|
@ -11,7 +11,7 @@ const keys = {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.handle = function (opts) {
|
exports.handle = function (opts) {
|
||||||
opts.elem.keydown(function (e) {
|
opts.elem.keydown((e) => {
|
||||||
const key = e.which || e.keyCode;
|
const key = e.which || e.keyCode;
|
||||||
|
|
||||||
if (e.altKey || e.ctrlKey || e.shiftKey) {
|
if (e.altKey || e.ctrlKey || e.shiftKey) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ function render_lightbox_list_images(preview_source) {
|
||||||
const images = Array.prototype.slice.call($(".focused_table .message_inline_image img"));
|
const images = Array.prototype.slice.call($(".focused_table .message_inline_image img"));
|
||||||
const $image_list = $("#lightbox_overlay .image-list").html("");
|
const $image_list = $("#lightbox_overlay .image-list").html("");
|
||||||
|
|
||||||
images.forEach(function (img) {
|
images.forEach((img) => {
|
||||||
const src = img.getAttribute("src");
|
const src = img.getAttribute("src");
|
||||||
const className = preview_source === src ? "image selected" : "image";
|
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();
|
$("#lightbox_overlay .lightbox-canvas-trigger").click();
|
||||||
e.preventDefault();
|
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")) {
|
if ($(e.target).is(".image-info-wrapper, .center")) {
|
||||||
overlays.close_overlay("lightbox");
|
overlays.close_overlay("lightbox");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ const events = {
|
||||||
};
|
};
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
document.body.addEventListener("mouseup", function (e) {
|
document.body.addEventListener("mouseup", (e) => {
|
||||||
events.documentMouseup = events.documentMouseup.filter(function (event) {
|
events.documentMouseup = events.documentMouseup.filter(function (event) {
|
||||||
// go through automatic cleanup when running events.
|
// go through automatic cleanup when running events.
|
||||||
if (!document.body.contains(event.canvas)) {
|
if (!document.body.contains(event.canvas)) {
|
||||||
|
@ -17,7 +17,7 @@ window.onload = function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("resize", function (e) {
|
window.addEventListener("resize", function (e) {
|
||||||
events.windowResize = events.windowResize.filter(function (event) {
|
events.windowResize = events.windowResize.filter((event) => {
|
||||||
if (!document.body.contains(event.canvas)) {
|
if (!document.body.contains(event.canvas)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ window.onload = function () {
|
||||||
event.callback.call(this, e);
|
event.callback.call(this, e);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}.bind(this));
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ const funcs = {
|
||||||
// actually an element that can scroll. The wheel event will
|
// actually an element that can scroll. The wheel event will
|
||||||
// detect the *gesture* of scrolling over an element, without actually
|
// detect the *gesture* of scrolling over an element, without actually
|
||||||
// worrying about scrollable content.
|
// worrying about scrollable content.
|
||||||
canvas.addEventListener("wheel", function (e) {
|
canvas.addEventListener("wheel", (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
// this is to reverse scrolling directions for the image.
|
// 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
|
// the only valid mousedown events should originate inside of the
|
||||||
// canvas.
|
// canvas.
|
||||||
canvas.addEventListener("mousedown", function () {
|
canvas.addEventListener("mousedown", () => {
|
||||||
mousedown = true;
|
mousedown = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// on mousemove, actually run the pan events.
|
// 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.
|
// to pan, there must be mousedown and mousemove, check if valid.
|
||||||
if (mousedown === true) {
|
if (mousedown === true) {
|
||||||
polyfillMouseMovement(e);
|
polyfillMouseMovement(e);
|
||||||
|
@ -145,7 +145,7 @@ const funcs = {
|
||||||
// that the LightboxCanvas instance created in lightbox.js can be
|
// that the LightboxCanvas instance created in lightbox.js can be
|
||||||
// accessed from hotkey.js. Major code refactoring is required in lightbox.js
|
// accessed from hotkey.js. Major code refactoring is required in lightbox.js
|
||||||
// to implement these keyboard shortcuts in hotkey.js
|
// to implement these keyboard shortcuts in hotkey.js
|
||||||
document.addEventListener('keydown', function (e) {
|
document.addEventListener('keydown', (e) => {
|
||||||
if (!overlays.lightbox_open()) {
|
if (!overlays.lightbox_open()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ const funcs = {
|
||||||
|
|
||||||
// make sure that when the mousedown is lifted on <canvas>to prevent
|
// make sure that when the mousedown is lifted on <canvas>to prevent
|
||||||
// panning events.
|
// panning events.
|
||||||
canvas.addEventListener("mouseup", function () {
|
canvas.addEventListener("mouseup", () => {
|
||||||
mousedown = false;
|
mousedown = false;
|
||||||
// reset this to be empty so that the values will `NaN` on first
|
// reset this to be empty so that the values will `NaN` on first
|
||||||
// mousemove and default to a change of (0, 0).
|
// mousemove and default to a change of (0, 0).
|
||||||
|
|
|
@ -62,11 +62,9 @@ const ls = {
|
||||||
// Remove keys which match a regex.
|
// Remove keys which match a regex.
|
||||||
removeDataRegex: function (version, regex) {
|
removeDataRegex: function (version, regex) {
|
||||||
const key_regex = new RegExp(this.formGetter(version, regex));
|
const key_regex = new RegExp(this.formGetter(version, regex));
|
||||||
const keys = Object.keys(localStorage).filter(function (key) {
|
const keys = Object.keys(localStorage).filter((key) => key_regex.test(key));
|
||||||
return key_regex.test(key);
|
|
||||||
});
|
|
||||||
|
|
||||||
keys.forEach(function (key) {
|
keys.forEach((key) => {
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -176,7 +176,7 @@ exports.apply_markdown = function (message) {
|
||||||
silencedMentionHandler: function (quote) {
|
silencedMentionHandler: function (quote) {
|
||||||
// Silence quoted mentions.
|
// Silence quoted mentions.
|
||||||
const user_mention_re = /<span.*user-mention.*data-user-id="(\d+|\*)"[^>]*>@/gm;
|
const user_mention_re = /<span.*user-mention.*data-user-id="(\d+|\*)"[^>]*>@/gm;
|
||||||
quote = quote.replace(user_mention_re, function (match) {
|
quote = quote.replace(user_mention_re, (match) => {
|
||||||
match = match.replace(/"user-mention"/g, '"user-mention silent"');
|
match = match.replace(/"user-mention"/g, '"user-mention silent"');
|
||||||
match = match.replace(/>@/g, '>');
|
match = match.replace(/>@/g, '>');
|
||||||
return match;
|
return match;
|
||||||
|
@ -502,9 +502,7 @@ exports.initialize = function (realm_filters, helper_config) {
|
||||||
|
|
||||||
// Tell our fenced code preprocessor how to insert arbitrary
|
// Tell our fenced code preprocessor how to insert arbitrary
|
||||||
// HTML into the output. This generated HTML is safe to not escape
|
// HTML into the output. This generated HTML is safe to not escape
|
||||||
fenced_code.set_stash_func(function (html) {
|
fenced_code.set_stash_func((html) => marked.stashHtml(html, true));
|
||||||
return marked.stashHtml(html, true);
|
|
||||||
});
|
|
||||||
|
|
||||||
marked.setOptions({
|
marked.setOptions({
|
||||||
gfm: true,
|
gfm: true,
|
||||||
|
|
|
@ -380,7 +380,7 @@ function edit_message(row, raw_content) {
|
||||||
// Do this right away, rather than waiting for the timer to do its first update,
|
// Do this right away, rather than waiting for the timer to do its first update,
|
||||||
// since otherwise there is a noticeable lag
|
// since otherwise there is a noticeable lag
|
||||||
message_edit_countdown_timer.text(timer_text(seconds_left));
|
message_edit_countdown_timer.text(timer_text(seconds_left));
|
||||||
const countdown_timer = setInterval(function () {
|
const countdown_timer = setInterval(() => {
|
||||||
seconds_left -= 1;
|
seconds_left -= 1;
|
||||||
if (seconds_left <= 0) {
|
if (seconds_left <= 0) {
|
||||||
clearInterval(countdown_timer);
|
clearInterval(countdown_timer);
|
||||||
|
@ -437,11 +437,11 @@ function edit_message(row, raw_content) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!message.locally_echoed) {
|
if (!message.locally_echoed) {
|
||||||
message_edit_topic.keyup(function () {
|
message_edit_topic.keyup(() => {
|
||||||
set_propagate_selector_display();
|
set_propagate_selector_display();
|
||||||
});
|
});
|
||||||
|
|
||||||
message_edit_stream.on('change', function () {
|
message_edit_stream.on('change', () => {
|
||||||
set_propagate_selector_display();
|
set_propagate_selector_display();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -781,7 +781,7 @@ exports.edit_last_sent_message = function () {
|
||||||
|
|
||||||
// Finally do the real work!
|
// Finally do the real work!
|
||||||
compose_actions.cancel();
|
compose_actions.cancel();
|
||||||
exports.start(msg_row, function () {
|
exports.start(msg_row, () => {
|
||||||
$('#message_edit_content').focus();
|
$('#message_edit_content').focus();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -807,7 +807,7 @@ exports.delete_message = function (msg_id) {
|
||||||
} else {
|
} else {
|
||||||
hide_delete_btn_show_spinner(false);
|
hide_delete_btn_show_spinner(false);
|
||||||
}
|
}
|
||||||
$('#do_delete_message_button').off().on('click', function (e) {
|
$('#do_delete_message_button').off().on('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
currently_deleting_messages.push(msg_id);
|
currently_deleting_messages.push(msg_id);
|
||||||
|
|
|
@ -45,7 +45,7 @@ function maybe_add_narrowed_messages(messages, msg_list) {
|
||||||
},
|
},
|
||||||
error: function () {
|
error: function () {
|
||||||
// We might want to be more clever here
|
// We might want to be more clever here
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
if (msg_list === current_msg_list) {
|
if (msg_list === current_msg_list) {
|
||||||
// Don't actually try again if we unnarrowed
|
// Don't actually try again if we unnarrowed
|
||||||
// while waiting
|
// while waiting
|
||||||
|
|
|
@ -109,7 +109,7 @@ function get_messages_success(data, opts) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
// The server occasionally returns no data during a
|
// The server occasionally returns no data during a
|
||||||
// restart. Ignore those responses and try again
|
// restart. Ignore those responses and try again
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
exports.load_messages(opts);
|
exports.load_messages(opts);
|
||||||
}, 0);
|
}, 0);
|
||||||
return;
|
return;
|
||||||
|
@ -239,7 +239,7 @@ exports.load_messages = function (opts) {
|
||||||
|
|
||||||
// We might want to be more clever here
|
// We might want to be more clever here
|
||||||
$('#connection-error').addClass("show");
|
$('#connection-error').addClass("show");
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
exports.load_messages(opts);
|
exports.load_messages(opts);
|
||||||
}, consts.error_retry_time);
|
}, consts.error_retry_time);
|
||||||
},
|
},
|
||||||
|
|
|
@ -445,7 +445,7 @@ exports.all = new exports.MessageList({
|
||||||
// doing something. Be careful, though, if you try to capture
|
// doing something. Be careful, though, if you try to capture
|
||||||
// mousemove, then you will have to contend with the autoscroll
|
// mousemove, then you will have to contend with the autoscroll
|
||||||
// itself generating mousemove events.
|
// itself generating mousemove events.
|
||||||
$(document).on('message_selected.zulip wheel', function () {
|
$(document).on('message_selected.zulip wheel', () => {
|
||||||
message_viewport.stop_auto_scrolling();
|
message_viewport.stop_auto_scrolling();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ MessageListData.prototype = {
|
||||||
let viewable_messages;
|
let viewable_messages;
|
||||||
if (this.muting_enabled) {
|
if (this.muting_enabled) {
|
||||||
this._all_items = messages.concat(this._all_items);
|
this._all_items = messages.concat(this._all_items);
|
||||||
this._all_items.sort(function (a, b) {return a.id - b.id;});
|
this._all_items.sort((a, b) => a.id - b.id);
|
||||||
|
|
||||||
viewable_messages = this.unmuted_messages(messages);
|
viewable_messages = this.unmuted_messages(messages);
|
||||||
this._items = viewable_messages.concat(this._items);
|
this._items = viewable_messages.concat(this._items);
|
||||||
|
@ -292,7 +292,7 @@ MessageListData.prototype = {
|
||||||
this._items = messages.concat(this._items);
|
this._items = messages.concat(this._items);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._items.sort(function (a, b) {return a.id - b.id;});
|
this._items.sort((a, b) => a.id - b.id);
|
||||||
this._add_to_hash(messages);
|
this._add_to_hash(messages);
|
||||||
return viewable_messages;
|
return viewable_messages;
|
||||||
},
|
},
|
||||||
|
@ -371,7 +371,7 @@ MessageListData.prototype = {
|
||||||
if (self._is_localonly_id(msg.id)) {
|
if (self._is_localonly_id(msg.id)) {
|
||||||
// First non-local message before this one
|
// First non-local message before this one
|
||||||
const effective = self._next_nonlocal_message(self._items, a_idx,
|
const effective = self._next_nonlocal_message(self._items, a_idx,
|
||||||
function (idx) { return idx - 1; });
|
(idx) => idx - 1);
|
||||||
if (effective) {
|
if (effective) {
|
||||||
// Turn the 10.02 in [11, 10.02, 12] into 11.02
|
// Turn the 10.02 in [11, 10.02, 12] into 11.02
|
||||||
const decimal = parseFloat((msg.id % 1).toFixed(0.02));
|
const decimal = parseFloat((msg.id % 1).toFixed(0.02));
|
||||||
|
@ -472,7 +472,7 @@ MessageListData.prototype = {
|
||||||
|
|
||||||
_add_to_hash: function (messages) {
|
_add_to_hash: function (messages) {
|
||||||
const self = this;
|
const self = this;
|
||||||
messages.forEach(function (elem) {
|
messages.forEach((elem) => {
|
||||||
const id = parseFloat(elem.id);
|
const id = parseFloat(elem.id);
|
||||||
if (isNaN(id)) {
|
if (isNaN(id)) {
|
||||||
blueslip.fatal("Bad message id");
|
blueslip.fatal("Bad message id");
|
||||||
|
@ -525,7 +525,7 @@ MessageListData.prototype = {
|
||||||
|
|
||||||
// If this message is now out of order, re-order and re-render
|
// If this message is now out of order, re-order and re-render
|
||||||
const self = this;
|
const self = this;
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
const current_message = self._hash.get(new_id);
|
const current_message = self._hash.get(new_id);
|
||||||
const index = self._items.indexOf(current_message);
|
const index = self._items.indexOf(current_message);
|
||||||
|
|
||||||
|
@ -537,9 +537,9 @@ MessageListData.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const next = self._next_nonlocal_message(self._items, index,
|
const next = self._next_nonlocal_message(self._items, index,
|
||||||
function (idx) { return idx + 1; });
|
(idx) => idx + 1);
|
||||||
const prev = self._next_nonlocal_message(self._items, index,
|
const prev = self._next_nonlocal_message(self._items, index,
|
||||||
function (idx) { return idx - 1; });
|
(idx) => idx - 1);
|
||||||
|
|
||||||
if (next !== undefined && current_message.id > next.id ||
|
if (next !== undefined && current_message.id > next.id ||
|
||||||
prev !== undefined && current_message.id < prev.id) {
|
prev !== undefined && current_message.id < prev.id) {
|
||||||
|
|
|
@ -153,13 +153,13 @@ function scroll_finish() {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
message_viewport.message_pane.scroll(_.throttle(function () {
|
message_viewport.message_pane.scroll(_.throttle(() => {
|
||||||
unread_ops.process_visible();
|
unread_ops.process_visible();
|
||||||
scroll_finish();
|
scroll_finish();
|
||||||
}, 50));
|
}, 50));
|
||||||
|
|
||||||
// Scroll handler that marks messages as read when you scroll past them.
|
// Scroll handler that marks messages as read when you scroll past them.
|
||||||
$(document).on('message_selected.zulip', function (event) {
|
$(document).on('message_selected.zulip', (event) => {
|
||||||
if (event.id === -1) {
|
if (event.id === -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,14 +419,14 @@ exports.initialize = function () {
|
||||||
jwindow = $(window);
|
jwindow = $(window);
|
||||||
exports.message_pane = $(".app");
|
exports.message_pane = $(".app");
|
||||||
// This handler must be placed before all resize handlers in our application
|
// This handler must be placed before all resize handlers in our application
|
||||||
jwindow.resize(function () {
|
jwindow.resize(() => {
|
||||||
dimensions.height.reset();
|
dimensions.height.reset();
|
||||||
dimensions.width.reset();
|
dimensions.width.reset();
|
||||||
top_of_feed.reset();
|
top_of_feed.reset();
|
||||||
bottom_of_feed.reset();
|
bottom_of_feed.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('compose_started compose_canceled compose_finished', function () {
|
$(document).on('compose_started compose_canceled compose_finished', () => {
|
||||||
bottom_of_feed.reset();
|
bottom_of_feed.reset();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -334,7 +334,7 @@ exports.activate = function (raw_operators, opts) {
|
||||||
tab_bar.initialize();
|
tab_bar.initialize();
|
||||||
|
|
||||||
msg_list.initial_core_time = new Date();
|
msg_list.initial_core_time = new Date();
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
resize.resize_stream_filters_container();
|
resize.resize_stream_filters_container();
|
||||||
msg_list.initial_free_time = new Date();
|
msg_list.initial_free_time = new Date();
|
||||||
maybe_report_narrow_time(msg_list);
|
maybe_report_narrow_time(msg_list);
|
||||||
|
@ -840,7 +840,7 @@ exports.deactivate = function () {
|
||||||
handle_post_narrow_deactivate_processes();
|
handle_post_narrow_deactivate_processes();
|
||||||
|
|
||||||
unnarrow_times.initial_core_time = new Date();
|
unnarrow_times.initial_core_time = new Date();
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
resize.resize_stream_filters_container();
|
resize.resize_stream_filters_container();
|
||||||
unnarrow_times.initial_free_time = new Date();
|
unnarrow_times.initial_free_time = new Date();
|
||||||
report_unnarrow_time();
|
report_unnarrow_time();
|
||||||
|
|
|
@ -63,7 +63,7 @@ function get_audio_file_path(audio_element, audio_file_without_extension) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
$(window).focus(function () {
|
$(window).focus(() => {
|
||||||
window_has_focus = true;
|
window_has_focus = true;
|
||||||
|
|
||||||
for (const notice_mem_entry of notice_memory.values()) {
|
for (const notice_mem_entry of notice_memory.values()) {
|
||||||
|
@ -75,7 +75,7 @@ exports.initialize = function () {
|
||||||
// counts.
|
// counts.
|
||||||
unread_ops.process_visible();
|
unread_ops.process_visible();
|
||||||
|
|
||||||
}).blur(function () {
|
}).blur(() => {
|
||||||
window_has_focus = false;
|
window_has_focus = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ if (window.electron_bridge !== undefined) {
|
||||||
if (window.electron_bridge.set_send_notification_reply_message_supported !== undefined) {
|
if (window.electron_bridge.set_send_notification_reply_message_supported !== undefined) {
|
||||||
window.electron_bridge.set_send_notification_reply_message_supported(true);
|
window.electron_bridge.set_send_notification_reply_message_supported(true);
|
||||||
}
|
}
|
||||||
window.electron_bridge.on_event('send_notification_reply_message', function (message_id, reply) {
|
window.electron_bridge.on_event('send_notification_reply_message', (message_id, reply) => {
|
||||||
const message = message_store.get(message_id);
|
const message = message_store.get(message_id);
|
||||||
const data = {
|
const data = {
|
||||||
type: message.type,
|
type: message.type,
|
||||||
|
@ -658,7 +658,7 @@ exports.notify_local_mixes = function (messages, need_user_to_scroll) {
|
||||||
if (need_user_to_scroll) {
|
if (need_user_to_scroll) {
|
||||||
reason = i18n.t("Sent! Scroll down to view your message.");
|
reason = i18n.t("Sent! Scroll down to view your message.");
|
||||||
exports.notify_above_composebox(reason, "", null, "");
|
exports.notify_above_composebox(reason, "", null, "");
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
$('#out-of-view-notification').hide();
|
$('#out-of-view-notification').hide();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
@ -716,20 +716,20 @@ exports.reify_message_id = function (opts) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.register_click_handlers = function () {
|
exports.register_click_handlers = function () {
|
||||||
$('#out-of-view-notification').on('click', '.compose_notification_narrow_by_topic', function (e) {
|
$('#out-of-view-notification').on('click', '.compose_notification_narrow_by_topic', (e) => {
|
||||||
const message_id = $(e.currentTarget).data('message-id');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
narrow.by_topic(message_id, {trigger: 'compose_notification'});
|
narrow.by_topic(message_id, {trigger: 'compose_notification'});
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$('#out-of-view-notification').on('click', '.compose_notification_scroll_to_message', function (e) {
|
$('#out-of-view-notification').on('click', '.compose_notification_scroll_to_message', (e) => {
|
||||||
const message_id = $(e.currentTarget).data('message-id');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
current_msg_list.select_id(message_id);
|
current_msg_list.select_id(message_id);
|
||||||
navigate.scroll_to_selected();
|
navigate.scroll_to_selected();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$('#out-of-view-notification').on('click', '.out-of-view-notification-close', function (e) {
|
$('#out-of-view-notification').on('click', '.out-of-view-notification-close', (e) => {
|
||||||
exports.clear_compose_notifications();
|
exports.clear_compose_notifications();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -221,7 +221,7 @@ exports.open_settings = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.initialize = function () {
|
exports.initialize = function () {
|
||||||
$("body").on("click", ".overlay, .overlay .exit", function (e) {
|
$("body").on("click", ".overlay, .overlay .exit", (e) => {
|
||||||
let $target = $(e.target);
|
let $target = $(e.target);
|
||||||
|
|
||||||
// if the target is not the .overlay element, search up the node tree
|
// if the target is not the .overlay element, search up the node tree
|
||||||
|
|
|
@ -139,9 +139,7 @@ exports.is_known_user_id = function (user_id) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function sort_numerically(user_ids) {
|
function sort_numerically(user_ids) {
|
||||||
user_ids.sort(function (a, b) {
|
user_ids.sort((a, b) => a - b);
|
||||||
return a - b;
|
|
||||||
});
|
|
||||||
|
|
||||||
return user_ids;
|
return user_ids;
|
||||||
}
|
}
|
||||||
|
@ -859,9 +857,9 @@ exports.get_message_people = function () {
|
||||||
|
|
||||||
exports.get_active_message_people = function () {
|
exports.get_active_message_people = function () {
|
||||||
const message_people = exports.get_message_people();
|
const message_people = exports.get_message_people();
|
||||||
const active_message_people = message_people.filter(function (item) {
|
const active_message_people = message_people.filter((item) =>
|
||||||
return active_user_dict.has(item.user_id);
|
active_user_dict.has(item.user_id)
|
||||||
});
|
);
|
||||||
return active_message_people;
|
return active_message_people;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,9 +53,7 @@ exports.recent = (function () {
|
||||||
conversation.max_message_id = message_id;
|
conversation.max_message_id = message_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
recent_private_messages.sort(function (a, b) {
|
recent_private_messages.sort((a, b) => b.max_message_id - a.max_message_id);
|
||||||
return b.max_message_id - a.max_message_id;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.get = function () {
|
self.get = function () {
|
||||||
|
|
|
@ -284,12 +284,12 @@ exports.activate = function (opts) {
|
||||||
const html = render_widgets_poll_widget();
|
const html = render_widgets_poll_widget();
|
||||||
elem.html(html);
|
elem.html(html);
|
||||||
|
|
||||||
elem.find('input.poll-question').on('keyup', function (e) {
|
elem.find('input.poll-question').on('keyup', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
update_edit_controls();
|
update_edit_controls();
|
||||||
});
|
});
|
||||||
|
|
||||||
elem.find('input.poll-question').on('keydown', function (e) {
|
elem.find('input.poll-question').on('keydown', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
|
@ -303,27 +303,27 @@ exports.activate = function (opts) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
elem.find('.poll-edit-question').on('click', function (e) {
|
elem.find('.poll-edit-question').on('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
start_editing();
|
start_editing();
|
||||||
});
|
});
|
||||||
|
|
||||||
elem.find("button.poll-question-check").on('click', function (e) {
|
elem.find("button.poll-question-check").on('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
submit_question();
|
submit_question();
|
||||||
});
|
});
|
||||||
|
|
||||||
elem.find("button.poll-question-remove").on('click', function (e) {
|
elem.find("button.poll-question-remove").on('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
abort_edit();
|
abort_edit();
|
||||||
});
|
});
|
||||||
|
|
||||||
elem.find("button.poll-option").on('click', function (e) {
|
elem.find("button.poll-option").on('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
submit_option();
|
submit_option();
|
||||||
});
|
});
|
||||||
|
|
||||||
elem.find('input.poll-option').on('keydown', function (e) {
|
elem.find('input.poll-option').on('keydown', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
|
@ -345,7 +345,7 @@ exports.activate = function (opts) {
|
||||||
const html = render_widgets_poll_widget_results(widget_data);
|
const html = render_widgets_poll_widget_results(widget_data);
|
||||||
elem.find('ul.poll-widget').html(html);
|
elem.find('ul.poll-widget').html(html);
|
||||||
|
|
||||||
elem.find("button.poll-vote").off('click').on('click', function (e) {
|
elem.find("button.poll-vote").off('click').on('click', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const key = $(e.target).attr('data-key');
|
const key = $(e.target).attr('data-key');
|
||||||
submit_vote(key);
|
submit_vote(key);
|
||||||
|
|
|
@ -56,7 +56,7 @@ function copy_email_handler(e) {
|
||||||
email_el.addClass('email_copied');
|
email_el.addClass('email_copied');
|
||||||
email_textnode.nodeValue = i18n.t('Email copied');
|
email_textnode.nodeValue = i18n.t('Email copied');
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
email_el.removeClass('email_copied');
|
email_el.removeClass('email_copied');
|
||||||
email_textnode.nodeValue = copy_icon.attr('data-clipboard-text');
|
email_textnode.nodeValue = copy_icon.attr('data-clipboard-text');
|
||||||
}, 1500);
|
}, 1500);
|
||||||
|
@ -306,8 +306,8 @@ exports.show_user_profile = function (user) {
|
||||||
const dateFormat = moment.localeData().longDateFormat('LL');
|
const dateFormat = moment.localeData().longDateFormat('LL');
|
||||||
const field_types = page_params.custom_profile_field_types;
|
const field_types = page_params.custom_profile_field_types;
|
||||||
const profile_data = page_params.custom_profile_fields
|
const profile_data = page_params.custom_profile_fields
|
||||||
.map(function (f) {return get_custom_profile_field_data(user, f, field_types, dateFormat);})
|
.map((f) => get_custom_profile_field_data(user, f, field_types, dateFormat))
|
||||||
.filter(function (f) {return f.name !== undefined;});
|
.filter((f) => f.name !== undefined);
|
||||||
|
|
||||||
const args = {
|
const args = {
|
||||||
full_name: user.full_name,
|
full_name: user.full_name,
|
||||||
|
@ -346,26 +346,18 @@ function get_user_info_popover_items() {
|
||||||
|
|
||||||
function fetch_group_members(member_ids) {
|
function fetch_group_members(member_ids) {
|
||||||
return member_ids
|
return member_ids
|
||||||
.map(function (m) {
|
.map((m) => people.get_by_user_id(m))
|
||||||
return people.get_by_user_id(m);
|
.filter((m) => m !== undefined)
|
||||||
})
|
.map((p) => Object.assign({}, p, {
|
||||||
.filter(function (m) {
|
|
||||||
return m !== undefined;
|
|
||||||
})
|
|
||||||
.map(function (p) {
|
|
||||||
return Object.assign({}, p, {
|
|
||||||
user_circle_class: buddy_data.get_user_circle_class(p.user_id),
|
user_circle_class: buddy_data.get_user_circle_class(p.user_id),
|
||||||
is_active: people.is_active_user_for_popover(p.user_id),
|
is_active: people.is_active_user_for_popover(p.user_id),
|
||||||
user_last_seen_time_status: buddy_data.user_last_seen_time_status(p.user_id),
|
user_last_seen_time_status: buddy_data.user_last_seen_time_status(p.user_id),
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_group_members(members) {
|
function sort_group_members(members) {
|
||||||
return members
|
return members
|
||||||
.sort(function (a, b) {
|
.sort((a, b) => a.full_name.localeCompare(b.full_name));
|
||||||
return a.full_name.localeCompare(b.full_name);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// exporting these functions for testing purposes
|
// exporting these functions for testing purposes
|
||||||
|
@ -762,7 +754,7 @@ exports.register_click_handlers = function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('body').on('click', '.info_popover_actions .narrow_to_private_messages', function (e) {
|
$('body').on('click', '.info_popover_actions .narrow_to_private_messages', (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
exports.hide_message_info_popover();
|
exports.hide_message_info_popover();
|
||||||
|
@ -771,7 +763,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.info_popover_actions .narrow_to_messages_sent', function (e) {
|
$('body').on('click', '.info_popover_actions .narrow_to_messages_sent', (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
exports.hide_message_info_popover();
|
exports.hide_message_info_popover();
|
||||||
|
@ -780,7 +772,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.user_popover .mention_user', function (e) {
|
$('body').on('click', '.user_popover .mention_user', (e) => {
|
||||||
if (!compose_state.composing()) {
|
if (!compose_state.composing()) {
|
||||||
compose_actions.start('stream', {trigger: 'sidebar user actions'});
|
compose_actions.start('stream', {trigger: 'sidebar user actions'});
|
||||||
}
|
}
|
||||||
|
@ -794,7 +786,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.message-info-popover .mention_user', function (e) {
|
$('body').on('click', '.message-info-popover .mention_user', (e) => {
|
||||||
if (!compose_state.composing()) {
|
if (!compose_state.composing()) {
|
||||||
compose_actions.respond_to_message({trigger: 'user sidebar popover'});
|
compose_actions.respond_to_message({trigger: 'user sidebar popover'});
|
||||||
}
|
}
|
||||||
|
@ -807,7 +799,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.info_popover_actions .view_user_profile', function (e) {
|
$('body').on('click', '.info_popover_actions .view_user_profile', (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
||||||
const user = people.get_by_user_id(user_id);
|
const user = people.get_by_user_id(user_id);
|
||||||
exports.show_user_profile(user);
|
exports.show_user_profile(user);
|
||||||
|
@ -815,7 +807,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.info_popover_actions .clear_status', function (e) {
|
$('body').on('click', '.info_popover_actions .clear_status', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const me = elem_to_user_id($(e.target).parents('ul'));
|
const me = elem_to_user_id($(e.target).parents('ul'));
|
||||||
user_status.server_update({
|
user_status.server_update({
|
||||||
|
@ -827,13 +819,13 @@ exports.register_click_handlers = function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.bot-owner-name', function (e) {
|
$('body').on('click', '.bot-owner-name', (e) => {
|
||||||
const user_id = parseInt($(e.target).attr('data-bot-owner-id'), 10);
|
const user_id = parseInt($(e.target).attr('data-bot-owner-id'), 10);
|
||||||
const user = people.get_by_user_id(user_id);
|
const user = people.get_by_user_id(user_id);
|
||||||
exports.show_user_profile(user);
|
exports.show_user_profile(user);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '#user-profile-modal #name #edit-button', function () {
|
$('body').on('click', '#user-profile-modal #name #edit-button', () => {
|
||||||
exports.hide_user_profile();
|
exports.hide_user_profile();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -843,21 +835,21 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.set_away_status', function (e) {
|
$('body').on('click', '.set_away_status', (e) => {
|
||||||
exports.hide_all();
|
exports.hide_all();
|
||||||
user_status.server_set_away();
|
user_status.server_set_away();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.revoke_away_status', function (e) {
|
$('body').on('click', '.revoke_away_status', (e) => {
|
||||||
exports.hide_all();
|
exports.hide_all();
|
||||||
user_status.server_revoke_away();
|
user_status.server_revoke_away();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.update_status_text', function (e) {
|
$('body').on('click', '.update_status_text', (e) => {
|
||||||
exports.hide_all();
|
exports.hide_all();
|
||||||
|
|
||||||
user_status_ui.open_overlay();
|
user_status_ui.open_overlay();
|
||||||
|
@ -909,7 +901,7 @@ exports.register_click_handlers = function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.respond_button', function (e) {
|
$('body').on('click', '.respond_button', (e) => {
|
||||||
// Arguably, we should fetch the message ID to respond to from
|
// Arguably, we should fetch the message ID to respond to from
|
||||||
// e.target, but that should always be the current selected
|
// e.target, but that should always be the current selected
|
||||||
// message in the current message list (and
|
// message in the current message list (and
|
||||||
|
@ -921,14 +913,14 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.reminder_button', function (e) {
|
$('body').on('click', '.reminder_button', (e) => {
|
||||||
const message_id = $(e.currentTarget).data('message-id');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
exports.render_actions_remind_popover($(".selected_message .actions_hover")[0], message_id);
|
exports.render_actions_remind_popover($(".selected_message .actions_hover")[0], message_id);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.remind.custom', function (e) {
|
$('body').on('click', '.remind.custom', (e) => {
|
||||||
$(e.currentTarget)[0]._flatpickr.toggle();
|
$(e.currentTarget)[0]._flatpickr.toggle();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -942,42 +934,42 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
$('body').on('click', '.remind.in_20m', function (e) {
|
$('body').on('click', '.remind.in_20m', (e) => {
|
||||||
const datestr = moment().add(20, 'm').format();
|
const datestr = moment().add(20, 'm').format();
|
||||||
reminder_click_handler(datestr, e);
|
reminder_click_handler(datestr, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.remind.in_1h', function (e) {
|
$('body').on('click', '.remind.in_1h', (e) => {
|
||||||
const datestr = moment().add(1, 'h').format();
|
const datestr = moment().add(1, 'h').format();
|
||||||
reminder_click_handler(datestr, e);
|
reminder_click_handler(datestr, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.remind.in_3h', function (e) {
|
$('body').on('click', '.remind.in_3h', (e) => {
|
||||||
const datestr = moment().add(3, 'h').format();
|
const datestr = moment().add(3, 'h').format();
|
||||||
reminder_click_handler(datestr, e);
|
reminder_click_handler(datestr, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.remind.tomo', function (e) {
|
$('body').on('click', '.remind.tomo', (e) => {
|
||||||
const datestr = moment().add(1, 'd').hour(9).minute(0).seconds(0).format();
|
const datestr = moment().add(1, 'd').hour(9).minute(0).seconds(0).format();
|
||||||
reminder_click_handler(datestr, e);
|
reminder_click_handler(datestr, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.remind.nxtw', function (e) {
|
$('body').on('click', '.remind.nxtw', (e) => {
|
||||||
const datestr = moment().add(1, 'w').day('monday').hour(9).minute(0).seconds(0).format();
|
const datestr = moment().add(1, 'w').day('monday').hour(9).minute(0).seconds(0).format();
|
||||||
reminder_click_handler(datestr, e);
|
reminder_click_handler(datestr, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.flatpickr-calendar', function (e) {
|
$('body').on('click', '.flatpickr-calendar', (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.flatpickr-confirm', function (e) {
|
$('body').on('click', '.flatpickr-confirm', (e) => {
|
||||||
const datestr = $(".remind.custom")[0].value;
|
const datestr = $(".remind.custom")[0].value;
|
||||||
reminder_click_handler(datestr, e);
|
reminder_click_handler(datestr, e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.respond_personal_button, .compose_private_message', function (e) {
|
$('body').on('click', '.respond_personal_button, .compose_private_message', (e) => {
|
||||||
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
const user_id = elem_to_user_id($(e.target).parents('ul'));
|
||||||
const email = people.get_by_user_id(user_id).email;
|
const email = people.get_by_user_id(user_id).email;
|
||||||
compose_actions.start('private', {
|
compose_actions.start('private', {
|
||||||
|
@ -987,7 +979,7 @@ exports.register_click_handlers = function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$('body').on('click', '.popover_toggle_collapse', function (e) {
|
$('body').on('click', '.popover_toggle_collapse', (e) => {
|
||||||
const message_id = $(e.currentTarget).data('message-id');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = current_msg_list.get_row(message_id);
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = current_msg_list.get(rows.id(row));
|
||||||
|
@ -1005,7 +997,7 @@ exports.register_click_handlers = function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$('body').on('click', '.popover_edit_message', function (e) {
|
$('body').on('click', '.popover_edit_message', (e) => {
|
||||||
const message_id = $(e.currentTarget).data('message-id');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = current_msg_list.get_row(message_id);
|
||||||
exports.hide_actions_popover();
|
exports.hide_actions_popover();
|
||||||
|
@ -1013,7 +1005,7 @@ exports.register_click_handlers = function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
$('body').on('click', '.view_edit_history', function (e) {
|
$('body').on('click', '.view_edit_history', (e) => {
|
||||||
const message_id = $(e.currentTarget).data('message-id');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = current_msg_list.get_row(message_id);
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = current_msg_list.get(rows.id(row));
|
||||||
|
@ -1026,7 +1018,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.popover_mute_topic', function (e) {
|
$('body').on('click', '.popover_mute_topic', (e) => {
|
||||||
const stream_id = parseInt($(e.currentTarget).attr('data-msg-stream-id'), 10);
|
const stream_id = parseInt($(e.currentTarget).attr('data-msg-stream-id'), 10);
|
||||||
const topic = $(e.currentTarget).attr('data-msg-topic');
|
const topic = $(e.currentTarget).attr('data-msg-topic');
|
||||||
|
|
||||||
|
@ -1036,7 +1028,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.popover_unmute_topic', function (e) {
|
$('body').on('click', '.popover_unmute_topic', (e) => {
|
||||||
const stream_id = parseInt($(e.currentTarget).attr('data-msg-stream-id'), 10);
|
const stream_id = parseInt($(e.currentTarget).attr('data-msg-stream-id'), 10);
|
||||||
const topic = $(e.currentTarget).attr('data-msg-topic');
|
const topic = $(e.currentTarget).attr('data-msg-topic');
|
||||||
|
|
||||||
|
@ -1046,7 +1038,7 @@ exports.register_click_handlers = function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('body').on('click', '.delete_message', function (e) {
|
$('body').on('click', '.delete_message', (e) => {
|
||||||
const message_id = $(e.currentTarget).data('message-id');
|
const message_id = $(e.currentTarget).data('message-id');
|
||||||
exports.hide_actions_popover();
|
exports.hide_actions_popover();
|
||||||
message_edit.delete_message(message_id);
|
message_edit.delete_message(message_id);
|
||||||
|
@ -1065,7 +1057,7 @@ exports.register_click_handlers = function () {
|
||||||
.css("display", "block")
|
.css("display", "block")
|
||||||
.delay(1000).fadeOut(300);
|
.delay(1000).fadeOut(300);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
// The Cliboard library works by focusing to a hidden textarea.
|
// The Cliboard library works by focusing to a hidden textarea.
|
||||||
// We unfocus this so keyboard shortcuts, etc., will work again.
|
// We unfocus this so keyboard shortcuts, etc., will work again.
|
||||||
$(":focus").blur();
|
$(":focus").blur();
|
||||||
|
@ -1078,7 +1070,7 @@ exports.register_click_handlers = function () {
|
||||||
(function () {
|
(function () {
|
||||||
let last_scroll = 0;
|
let last_scroll = 0;
|
||||||
|
|
||||||
$('.app').on('scroll', function () {
|
$('.app').on('scroll', () => {
|
||||||
if (suppress_scroll_hide) {
|
if (suppress_scroll_hide) {
|
||||||
suppress_scroll_hide = false;
|
suppress_scroll_hide = false;
|
||||||
return;
|
return;
|
||||||
|
@ -1125,7 +1117,7 @@ exports.hide_all_except_sidebars = function () {
|
||||||
exports.hide_user_profile();
|
exports.hide_user_profile();
|
||||||
|
|
||||||
// look through all the popovers that have been added and removed.
|
// look through all the popovers that have been added and removed.
|
||||||
list_of_popovers.forEach(function ($o) {
|
list_of_popovers.forEach(($o) => {
|
||||||
if (!document.body.contains($o.$element[0]) && $o.$tip) {
|
if (!document.body.contains($o.$element[0]) && $o.$tip) {
|
||||||
$o.$tip.remove();
|
$o.$tip.remove();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
$(function () {
|
$(() => {
|
||||||
$("#register").submit();
|
$("#register").submit();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
$(function () {
|
$(() => {
|
||||||
// This code will be executed when the user visits /login and
|
// This code will be executed when the user visits /login and
|
||||||
// dev_login.html is rendered.
|
// dev_login.html is rendered.
|
||||||
if ($("[data-page-id='dev-login']").length > 0) {
|
if ($("[data-page-id='dev-login']").length > 0) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(() => {
|
||||||
// This code will be executed when the user visits /emails in
|
// This code will be executed when the user visits /emails in
|
||||||
// development mode and email_log.html is rendered.
|
// development mode and email_log.html is rendered.
|
||||||
$('#toggle').change(function () {
|
$('#toggle').change(() => {
|
||||||
if ($('.email-text').css('display') === 'none') {
|
if ($('.email-text').css('display') === 'none') {
|
||||||
$(".email-text").each(function () {
|
$(".email-text").each(function () {
|
||||||
$(this).css("display", "block");
|
$(this).css("display", "block");
|
||||||
|
@ -25,7 +25,7 @@ $(function () {
|
||||||
$("#forward_address_sections").hide();
|
$("#forward_address_sections").hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#save_smptp_details").on("click", function () {
|
$("#save_smptp_details").on("click", () => {
|
||||||
const address = $('input[name=forward]:checked').val() === "enabled" ? $("#address").val() : "";
|
const address = $('input[name=forward]:checked').val() === "enabled" ? $("#address").val() : "";
|
||||||
const csrf_token = $('input[name="csrfmiddlewaretoken"]').attr('value');
|
const csrf_token = $('input[name="csrfmiddlewaretoken"]').attr('value');
|
||||||
const data = {forward_address: address, csrfmiddlewaretoken: csrf_token};
|
const data = {forward_address: address, csrfmiddlewaretoken: csrf_token};
|
||||||
|
@ -35,7 +35,7 @@ $(function () {
|
||||||
data: data,
|
data: data,
|
||||||
success: function () {
|
success: function () {
|
||||||
$("#smtp_form_status").show();
|
$("#smtp_form_status").show();
|
||||||
setTimeout(function () {
|
setTimeout(() => {
|
||||||
$("#smtp_form_status").hide();
|
$("#smtp_form_status").hide();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
$(function () {
|
$(() => {
|
||||||
$('.portico-header li.logout').on('click', function () {
|
$('.portico-header li.logout').on('click', () => {
|
||||||
$('#logout_form').submit();
|
$('#logout_form').submit();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").click(function (e) {
|
$("body").click((e) => {
|
||||||
const $this = $(e.target);
|
const $this = $(e.target);
|
||||||
|
|
||||||
if ($this.closest(".dropdown .dropdown-pill").length > 0 && !$(".dropdown").hasClass("show")) {
|
if ($this.closest(".dropdown .dropdown-pill").length > 0 && !$(".dropdown").hasClass("show")) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ const loading = {
|
||||||
const markdownSB = new SimpleBar($(".markdown")[0]);
|
const markdownSB = new SimpleBar($(".markdown")[0]);
|
||||||
|
|
||||||
const fetch_page = function (path, callback) {
|
const fetch_page = function (path, callback) {
|
||||||
$.get(path, function (res) {
|
$.get(path, (res) => {
|
||||||
const $html = $(res).find(".markdown .content");
|
const $html = $(res).find(".markdown .content");
|
||||||
|
|
||||||
callback($html.html().trim());
|
callback($html.html().trim());
|
||||||
|
@ -87,7 +87,7 @@ const update_page = function (html_map, path) {
|
||||||
scrollToHash(markdownSB);
|
scrollToHash(markdownSB);
|
||||||
} else {
|
} else {
|
||||||
loading.name = path;
|
loading.name = path;
|
||||||
fetch_page(path, function (res) {
|
fetch_page(path, (res) => {
|
||||||
html_map.set(path, res);
|
html_map.set(path, res);
|
||||||
$(".markdown .content").html(res);
|
$(".markdown .content").html(res);
|
||||||
loading.name = null;
|
loading.name = null;
|
||||||
|
@ -99,7 +99,7 @@ const update_page = function (html_map, path) {
|
||||||
|
|
||||||
new SimpleBar($(".sidebar")[0]);
|
new SimpleBar($(".sidebar")[0]);
|
||||||
|
|
||||||
$(".sidebar.slide h2").click(function (e) {
|
$(".sidebar.slide h2").click((e) => {
|
||||||
const $next = $(e.target).next();
|
const $next = $(e.target).next();
|
||||||
|
|
||||||
if ($next.is("ul")) {
|
if ($next.is("ul")) {
|
||||||
|
@ -146,11 +146,11 @@ $(document).on('click', '.markdown .content h1, .markdown .content h2, .markdown
|
||||||
scrollToHash(markdownSB);
|
scrollToHash(markdownSB);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".hamburger").click(function () {
|
$(".hamburger").click(() => {
|
||||||
$(".sidebar").toggleClass("show");
|
$(".sidebar").toggleClass("show");
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".markdown").click(function () {
|
$(".markdown").click(() => {
|
||||||
if ($(".sidebar.show").length) {
|
if ($(".sidebar.show").length) {
|
||||||
$(".sidebar.show").toggleClass("show");
|
$(".sidebar.show").toggleClass("show");
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ render_code_sections();
|
||||||
// to the right place.
|
// to the right place.
|
||||||
scrollToHash(markdownSB);
|
scrollToHash(markdownSB);
|
||||||
|
|
||||||
window.addEventListener("popstate", function () {
|
window.addEventListener("popstate", () => {
|
||||||
const path = window.location.pathname;
|
const path = window.location.pathname;
|
||||||
update_page(html_map, path);
|
update_page(html_map, path);
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,7 @@ const INTEGRATIONS = new Map();
|
||||||
const CATEGORIES = new Map();
|
const CATEGORIES = new Map();
|
||||||
|
|
||||||
function load_data() {
|
function load_data() {
|
||||||
$('.integration-lozenge').toArray().forEach(function (integration) {
|
$('.integration-lozenge').toArray().forEach((integration) => {
|
||||||
const name = $(integration).data('name');
|
const name = $(integration).data('name');
|
||||||
const display_name = $(integration).find('.integration-name').text().trim();
|
const display_name = $(integration).find('.integration-name').text().trim();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ function load_data() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.integration-category').toArray().forEach(function (category) {
|
$('.integration-category').toArray().forEach((category) => {
|
||||||
const name = $(category).data('category');
|
const name = $(category).data('category');
|
||||||
const display_name = $(category).text().trim();
|
const display_name = $(category).text().trim();
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ let state = Object.assign({}, INITIAL_STATE);
|
||||||
|
|
||||||
|
|
||||||
function adjust_font_sizing() {
|
function adjust_font_sizing() {
|
||||||
$('.integration-lozenge').toArray().forEach(function (integration) {
|
$('.integration-lozenge').toArray().forEach((integration) => {
|
||||||
const $integration_name = $(integration).find('.integration-name');
|
const $integration_name = $(integration).find('.integration-name');
|
||||||
const $integration_category = $(integration).find('.integration-category');
|
const $integration_category = $(integration).find('.integration-category');
|
||||||
|
|
||||||
|
@ -97,11 +97,11 @@ function update_categories() {
|
||||||
adjust_font_sizing();
|
adjust_font_sizing();
|
||||||
}
|
}
|
||||||
|
|
||||||
const update_integrations = _.debounce(function () {
|
const update_integrations = _.debounce(() => {
|
||||||
const max_scrollY = window.scrollY;
|
const max_scrollY = window.scrollY;
|
||||||
|
|
||||||
const integrations = $('.integration-lozenges').children().toArray();
|
const integrations = $('.integration-lozenges').children().toArray();
|
||||||
integrations.forEach(function (integration) {
|
integrations.forEach((integration) => {
|
||||||
const $integration = $(integration).find('.integration-lozenge');
|
const $integration = $(integration).find('.integration-lozenge');
|
||||||
const $integration_category = $integration.find('.integration-category');
|
const $integration_category = $integration.find('.integration-category');
|
||||||
|
|
||||||
|
@ -140,14 +140,12 @@ function hide_catalog_show_integration() {
|
||||||
const categories = $('.integration-' + state.integration).data('categories')
|
const categories = $('.integration-' + state.integration).data('categories')
|
||||||
.slice(1, -1)
|
.slice(1, -1)
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(function (category) {
|
.map((category) => category.trim().slice(1, -1));
|
||||||
return category.trim().slice(1, -1);
|
|
||||||
});
|
|
||||||
|
|
||||||
function show_integration(doc) {
|
function show_integration(doc) {
|
||||||
$('#integration-instructions-group .name').text(INTEGRATIONS.get(state.integration));
|
$('#integration-instructions-group .name').text(INTEGRATIONS.get(state.integration));
|
||||||
$('#integration-instructions-group .categories .integration-category').remove();
|
$('#integration-instructions-group .categories .integration-category').remove();
|
||||||
categories.forEach(function (category) {
|
categories.forEach((category) => {
|
||||||
let link;
|
let link;
|
||||||
for (const [name, display_name] of CATEGORIES) {
|
for (const [name, display_name] of CATEGORIES) {
|
||||||
if (display_name === category) {
|
if (display_name === category) {
|
||||||
|
@ -323,7 +321,7 @@ function toggle_categories_dropdown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function integration_events() {
|
function integration_events() {
|
||||||
$('#integration-search input[type="text"]').keypress(function (e) {
|
$('#integration-search input[type="text"]').keypress((e) => {
|
||||||
const integrations = $('.integration-lozenges').children().toArray();
|
const integrations = $('.integration-lozenges').children().toArray();
|
||||||
if (e.which === 13 && e.target.value !== '') {
|
if (e.which === 13 && e.target.value !== '') {
|
||||||
for (let i = 0; i < integrations.length; i += 1) {
|
for (let i = 0; i < integrations.length; i += 1) {
|
||||||
|
@ -337,24 +335,24 @@ function integration_events() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.integration-categories-dropdown .dropdown-toggle').click(function () {
|
$('.integration-categories-dropdown .dropdown-toggle').click(() => {
|
||||||
toggle_categories_dropdown();
|
toggle_categories_dropdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.integration-instruction-block').on('click', 'a .integration-category', function (e) {
|
$('.integration-instruction-block').on('click', 'a .integration-category', (e) => {
|
||||||
const category = $(e.target).data('category');
|
const category = $(e.target).data('category');
|
||||||
dispatch('SHOW_CATEGORY', { category: category });
|
dispatch('SHOW_CATEGORY', { category: category });
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.integrations a .integration-category').on('click', function (e) {
|
$('.integrations a .integration-category').on('click', (e) => {
|
||||||
const category = $(e.target).data('category');
|
const category = $(e.target).data('category');
|
||||||
dispatch('CHANGE_CATEGORY', { category: category });
|
dispatch('CHANGE_CATEGORY', { category: category });
|
||||||
toggle_categories_dropdown();
|
toggle_categories_dropdown();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.integrations a .integration-lozenge').on('click', function (e) {
|
$('.integrations a .integration-lozenge').on('click', (e) => {
|
||||||
if (!$(e.target).closest('.integration-lozenge').hasClass('integration-create-your-own')) {
|
if (!$(e.target).closest('.integration-lozenge').hasClass('integration-create-your-own')) {
|
||||||
const integration = $(e.target).closest('.integration-lozenge').data('name');
|
const integration = $(e.target).closest('.integration-lozenge').data('name');
|
||||||
dispatch('SHOW_INTEGRATION', { integration: integration });
|
dispatch('SHOW_INTEGRATION', { integration: integration });
|
||||||
|
@ -362,7 +360,7 @@ function integration_events() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a#integration-list-link span, a#integration-list-link i').on('click', function () {
|
$('a#integration-list-link span, a#integration-list-link i').on('click', () => {
|
||||||
dispatch('HIDE_INTEGRATION');
|
dispatch('HIDE_INTEGRATION');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
@ -371,11 +369,11 @@ function integration_events() {
|
||||||
// the input event.
|
// the input event.
|
||||||
$(".integrations .searchbar input[type='text']")
|
$(".integrations .searchbar input[type='text']")
|
||||||
.focus()
|
.focus()
|
||||||
.on('input', function (e) {
|
.on('input', (e) => {
|
||||||
dispatch('UPDATE_QUERY', { query: e.target.value.toLowerCase() });
|
dispatch('UPDATE_QUERY', { query: e.target.value.toLowerCase() });
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).scroll(function () {
|
$(window).scroll(() => {
|
||||||
if (document.body.scrollTop > 330) {
|
if (document.body.scrollTop > 330) {
|
||||||
$('.integration-categories-sidebar').addClass('sticky');
|
$('.integration-categories-sidebar').addClass('sticky');
|
||||||
} else {
|
} else {
|
||||||
|
@ -383,11 +381,11 @@ function integration_events() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('resize', function () {
|
$(window).on('resize', () => {
|
||||||
adjust_font_sizing();
|
adjust_font_sizing();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('popstate', function () {
|
$(window).on('popstate', () => {
|
||||||
if (window.location.pathname.startsWith('/integrations')) {
|
if (window.location.pathname.startsWith('/integrations')) {
|
||||||
dispatch('LOAD_PATH');
|
dispatch('LOAD_PATH');
|
||||||
} else {
|
} else {
|
||||||
|
@ -397,7 +395,7 @@ function integration_events() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init
|
// init
|
||||||
$(function () {
|
$(() => {
|
||||||
integration_events();
|
integration_events();
|
||||||
load_data();
|
load_data();
|
||||||
dispatch('LOAD_PATH');
|
dispatch('LOAD_PATH');
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue