js: Use ES6 object literal shorthand syntax.

Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-20 13:18:43 -07:00
parent b2745f6e41
commit 96dcc0ce6e
189 changed files with 1328 additions and 1326 deletions

View File

@ -70,6 +70,7 @@
"no-use-before-define": "error",
"no-useless-constructor": "error",
"no-var": "error",
"object-shorthand": "error",
"one-var": [ "error", "never" ],
"prefer-arrow-callback": "error",
"prefer-const": [ "error",
@ -307,6 +308,7 @@
"rules": {
// Dont require ES features that PhantomJS doesnt support
"no-var": "off",
"object-shorthand": "off",
"prefer-arrow-callback": "off"
}
},

View File

@ -13,7 +13,7 @@ const _page_params = {
};
const _document = {
hasFocus: function () {
hasFocus() {
return true;
},
};
@ -41,15 +41,15 @@ const _pm_list = {
};
const _popovers = {
hide_all_except_sidebars: function () {},
hide_all: function () {},
show_userlist_sidebar: function () {
hide_all_except_sidebars() {},
hide_all() {},
show_userlist_sidebar() {
$(".column-right").addClass("expanded");
},
};
const _stream_popover = {
show_streamlist_sidebar: function () {
show_streamlist_sidebar() {
$(".column-left").addClass("expanded");
},
};
@ -681,7 +681,7 @@ run_test("initialize", () => {
clear();
$.stub_selector("html", {
on: function (name, func) {
on(name, func) {
func();
},
});
@ -690,7 +690,7 @@ run_test("initialize", () => {
payload.success({});
};
global.server_events = {
check_for_unsuspend: function () {},
check_for_unsuspend() {},
};
let scroll_handler_started;

View File

@ -138,7 +138,7 @@ function activate_people() {
function set_presence(user_id, status) {
presence.presence_info.set(user_id, {
status: status,
status,
last_active: 9999,
});
}

View File

@ -168,13 +168,13 @@ run_test("find_li w/force_render", () => {
};
const empty_li = buddy_list.find_li({
key: key,
key,
});
assert.equal(empty_li, stub_li);
assert(!shown);
const li = buddy_list.find_li({
key: key,
key,
force_render: true,
});

View File

@ -34,11 +34,11 @@ function test_with_mock_ajax(test_params) {
run_test("basics", () => {
test_with_mock_ajax({
run_code: function () {
run_code() {
channel.post({});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.type, "POST");
assert.equal(options.dataType, "json");
@ -49,11 +49,11 @@ run_test("basics", () => {
});
test_with_mock_ajax({
run_code: function () {
run_code() {
channel.patch({});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.type, "POST");
assert.equal(options.data.method, "PATCH");
assert.equal(options.dataType, "json");
@ -65,11 +65,11 @@ run_test("basics", () => {
});
test_with_mock_ajax({
run_code: function () {
run_code() {
channel.put({});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.type, "PUT");
assert.equal(options.dataType, "json");
@ -80,11 +80,11 @@ run_test("basics", () => {
});
test_with_mock_ajax({
run_code: function () {
run_code() {
channel.del({});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.type, "DELETE");
assert.equal(options.dataType, "json");
@ -95,11 +95,11 @@ run_test("basics", () => {
});
test_with_mock_ajax({
run_code: function () {
run_code() {
channel.get({});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.type, "GET");
assert.equal(options.dataType, "json");
@ -124,23 +124,23 @@ run_test("normal_post", () => {
test_with_mock_ajax({
xhr: stub_xhr,
run_code: function () {
run_code() {
channel.post({
data: data,
data,
url: "/json/endpoint",
success: function (data, text_status, xhr) {
success(data, text_status, xhr) {
orig_success_called = true;
assert.equal(data, "response data");
assert.equal(text_status, "success");
assert.equal(xhr, stub_xhr);
},
error: function () {
error() {
orig_error_called = true;
},
});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.type, "POST");
assert.equal(options.dataType, "json");
assert.deepEqual(options.data, data);
@ -159,7 +159,7 @@ run_test("patch_with_form_data", () => {
let appended;
const data = {
append: function (k, v) {
append(k, v) {
assert.equal(k, "method");
assert.equal(v, "PATCH");
appended = true;
@ -167,15 +167,15 @@ run_test("patch_with_form_data", () => {
};
test_with_mock_ajax({
run_code: function () {
run_code() {
channel.patch({
data: data,
data,
processData: false,
});
assert(appended);
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.type, "POST");
assert.equal(options.dataType, "json");
@ -193,11 +193,11 @@ run_test("reload_on_403_error", () => {
responseText: '{"msg": "CSRF Fehler: etwas", "code": "CSRF_FAILED"}',
},
run_code: function () {
run_code() {
channel.post({});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
let reload_initiated;
reload.initiate = function (options) {
reload_initiated = true;
@ -222,11 +222,11 @@ run_test("unexpected_403_response", () => {
responseText: "unexpected",
},
run_code: function () {
run_code() {
channel.post({});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
blueslip.expect("error", "Unexpected 403 response from server");
options.simulate_error();
},
@ -235,14 +235,14 @@ run_test("unexpected_403_response", () => {
run_test("retry", () => {
test_with_mock_ajax({
run_code: function () {
run_code() {
channel.post({
idempotent: true,
data: 42,
});
},
check_ajax_options: function (options) {
check_ajax_options(options) {
global.patch_builtin("setTimeout", (f, delay) => {
assert.equal(delay, 0);
f();
@ -250,11 +250,11 @@ run_test("retry", () => {
blueslip.expect("log", "Retrying idempotent[object Object]");
test_with_mock_ajax({
run_code: function () {
run_code() {
options.simulate_success();
},
check_ajax_options: function (options) {
check_ajax_options(options) {
assert.equal(options.data, 42);
},
});

View File

@ -142,7 +142,7 @@ run_test("basics", () => {
{label: i18n.t("Search operators"), key: "search-operators"},
],
html_class: "stream_sorter_toggle",
callback: function (name, key) {
callback(name, key) {
assert.equal(callback_args, undefined);
callback_args = [name, key];

View File

@ -15,10 +15,10 @@ const _navigator = {
};
const _document = {
getElementById: function () {
getElementById() {
return $("#compose-textarea");
},
execCommand: function () {
execCommand() {
return false;
},
location: {},
@ -626,7 +626,7 @@ run_test("send_message", () => {
func();
});
global.server_events = {
assert_get_events_running: function () {
assert_get_events_running() {
stub_state.get_events_running_called += 1;
},
};
@ -994,7 +994,7 @@ run_test("initialize", () => {
compose_actions_start_checked = false;
global.compose_actions = {
start: function (msg_type, opts) {
start(msg_type, opts) {
assert.equal(msg_type, "stream");
assert.deepEqual(opts, expected_opts);
compose_actions_start_checked = true;
@ -1049,11 +1049,11 @@ run_test("update_fade", () => {
let update_all_called = false;
global.compose_fade = {
set_focused_recipient: function (msg_type) {
set_focused_recipient(msg_type) {
assert.equal(msg_type, "private");
set_focused_recipient_checked = true;
},
update_all: function () {
update_all() {
update_all_called = true;
},
};
@ -1073,7 +1073,7 @@ run_test("trigger_submit_compose_form", () => {
let prevent_default_checked = false;
let compose_finish_checked = false;
const e = {
preventDefault: function () {
preventDefault() {
prevent_default_checked = true;
},
};
@ -1262,13 +1262,13 @@ run_test("on_events", () => {
const event = {
preventDefault: noop,
target: target,
target,
};
const helper = {
event: event,
container: container,
target: target,
event,
container,
target,
container_was_removed: () => container_removed,
};
@ -1679,7 +1679,7 @@ run_test("create_message_object", () => {
global.$ = function (selector) {
return {
val: function () {
val() {
return page[selector];
},
};

View File

@ -79,10 +79,10 @@ set_global("common", {
function stub_selected_message(msg) {
set_global("current_msg_list", {
selected_message: function () {
selected_message() {
return msg;
},
can_mark_messages_read: function () {
can_mark_messages_read() {
return true;
},
});
@ -90,7 +90,7 @@ function stub_selected_message(msg) {
function stub_channel_get(success_value) {
set_global("channel", {
get: function (opts) {
get(opts) {
opts.success(success_value);
},
});

View File

@ -40,13 +40,13 @@ run_test("set_focused_recipient", () => {
switch (selector) {
case "#stream_message_recipient_stream":
return {
val: function () {
val() {
return "social";
},
};
case "#stream_message_recipient_topic":
return {
val: function () {
val() {
return "lunch";
},
};

View File

@ -1,7 +1,7 @@
set_global("$", global.make_zjquery());
const _people = {
small_avatar_url_for_person: function () {
small_avatar_url_for_person() {
return "http://example.com/example.png";
},
};

View File

@ -3,7 +3,7 @@ zrequire("people");
zrequire("user_status");
set_global("document", {
execCommand: function () {
execCommand() {
return false;
},
});

View File

@ -316,7 +316,7 @@ run_test("content_typeahead_selected", () => {
};
let autosize_called = false;
set_global("compose_ui", {
autosize_textarea: function () {
autosize_textarea() {
autosize_called = true;
},
});

View File

@ -15,7 +15,7 @@ global.patch_builtin("setTimeout", (func) => func());
set_global("home_msg_list", {
rerender: noop,
select_id: noop,
selected_id: function () {
selected_id() {
return 1;
},
});
@ -62,7 +62,7 @@ set_global("compose", {
});
set_global("settings_exports", {
populate_exports_table: function (exports) {
populate_exports_table(exports) {
return exports;
},
clear_success_banner: noop,
@ -82,13 +82,13 @@ set_global("current_msg_list", {rerender: noop});
// We use blueslip to print the traceback
set_global("blueslip", {
info: noop,
error: function (msg, more_info, stack) {
error(msg, more_info, stack) {
console.log("\nFailed to process an event:\n", more_info.event, "\n");
const error = new Error();
error.stack = stack;
throw error;
},
exception_msg: function (ex) {
exception_msg(ex) {
return ex.message;
},
});

View File

@ -27,7 +27,7 @@ test("add", (override) => {
const stream_id = sub.stream_id;
stream_data.add_sub({
stream_id: stream_id,
stream_id,
name: sub.name,
});
@ -70,7 +70,7 @@ test("remove", (override) => {
const stream_id = event_sub.stream_id;
const sub = {
stream_id: stream_id,
stream_id,
name: event_sub.name,
};

View File

@ -14,30 +14,30 @@ const noop = function () {
};
set_global("localStorage", {
getItem: function (key) {
getItem(key) {
return ls_container.get(key);
},
setItem: function (key, val) {
setItem(key, val) {
ls_container.set(key, val);
},
removeItem: function (key) {
removeItem(key) {
ls_container.delete(key);
},
clear: function () {
clear() {
ls_container.clear();
},
});
set_global("compose", {});
set_global("compose_state", {});
set_global("stream_data", {
get_color: function () {
get_color() {
return "#FFFFFF";
},
});
set_global("people", {
// Mocking get_by_email function, here we are
// just returning string before `@` in email
get_by_email: function (email) {
get_by_email(email) {
return {
full_name: email.split("@")[0],
};

View File

@ -42,7 +42,7 @@ function assert_same_operators(result, terms) {
negated = false;
}
return {
negated: negated,
negated,
operator: term.operator,
operand: term.operand,
};
@ -524,8 +524,8 @@ function get_predicate(operators) {
function make_sub(name, stream_id) {
const sub = {
name: name,
stream_id: stream_id,
name,
stream_id,
};
global.stream_data.add_sub(sub);
}
@ -546,8 +546,8 @@ run_test("predicate_basics", () => {
["topic", "Bar"],
]);
assert(predicate({type: "stream", stream_id: stream_id, topic: "bar"}));
assert(!predicate({type: "stream", stream_id: stream_id, topic: "whatever"}));
assert(predicate({type: "stream", stream_id, topic: "bar"}));
assert(!predicate({type: "stream", stream_id, topic: "whatever"}));
assert(!predicate({type: "stream", stream_id: 9999999}));
assert(!predicate({type: "private"}));
@ -1175,9 +1175,9 @@ run_test("term_type", () => {
function term(operator, operand, negated) {
return {
operator: operator,
operand: operand,
negated: negated,
operator,
operand,
negated,
};
}
@ -1277,8 +1277,8 @@ run_test("update_email", () => {
function make_private_sub(name, stream_id) {
const sub = {
name: name,
stream_id: stream_id,
name,
stream_id,
invite_only: true,
};
global.stream_data.add_sub(sub);
@ -1286,8 +1286,8 @@ function make_private_sub(name, stream_id) {
function make_web_public_sub(name, stream_id) {
const sub = {
name: name,
stream_id: stream_id,
name,
stream_id,
is_web_public: true,
};
global.stream_data.add_sub(sub);

View File

@ -381,7 +381,7 @@ function test_helper() {
events.push(full_name);
};
},
events: events,
events,
};
}

View File

@ -32,17 +32,17 @@ zrequire("common");
set_global("list_util", {});
set_global("current_msg_list", {
selected_id: function () {
selected_id() {
return 42;
},
selected_message: function () {
selected_message() {
return {
sent_by_me: true,
flags: ["read", "starred"],
};
},
selected_row: function () {},
get_row: function () {
selected_row() {},
get_row() {
return 101;
},
});
@ -66,17 +66,17 @@ function stubbing(func_name_to_stub, test_function) {
run_test("mappings", () => {
function map_press(which, shiftKey) {
return hotkey.get_keypress_hotkey({
which: which,
shiftKey: shiftKey,
which,
shiftKey,
});
}
function map_down(which, shiftKey, ctrlKey, metaKey) {
return hotkey.get_keydown_hotkey({
which: which,
shiftKey: shiftKey,
ctrlKey: ctrlKey,
metaKey: metaKey,
which,
shiftKey,
ctrlKey,
metaKey,
});
}
@ -211,9 +211,9 @@ run_test("basic_chars", () => {
for (const is_active of [return_true, return_false]) {
for (const info_overlay_open of [return_true, return_false]) {
set_global("overlays", {
is_active: is_active,
settings_open: settings_open,
info_overlay_open: info_overlay_open,
is_active,
settings_open,
info_overlay_open,
});
test_normal_typing();
}
@ -345,8 +345,8 @@ run_test("motion_keys", () => {
function process(name, shiftKey, ctrlKey) {
const e = {
which: codes[name],
shiftKey: shiftKey,
ctrlKey: ctrlKey,
shiftKey,
ctrlKey,
};
try {

View File

@ -34,7 +34,7 @@ function pill_html(value, data_id, img_src) {
const opts = {
id: data_id,
display_value: value,
has_image: has_image,
has_image,
};
if (has_image) {
@ -117,18 +117,18 @@ function set_up() {
container.set_find_results(".input", pill_input);
const config = {
container: container,
create_item_from_text: create_item_from_text,
container,
create_item_from_text,
get_text_from_item: (item) => item.display_value,
};
id_seq = 0;
return {
config: config,
pill_input: pill_input,
items: items,
container: container,
config,
pill_input,
items,
container,
};
}

View File

@ -15,7 +15,7 @@ function basic_conf() {
};
const conf = {
list: list,
list,
highlight_class: "highlight",
};

View File

@ -269,7 +269,7 @@ function sort_button(opts) {
const classList = new Set();
const button = {
data: data,
data,
closest: lookup(".progressive-table-wrapper", {
data: lookup("list-render", opts.list_name),
}),
@ -637,7 +637,7 @@ run_test("opts.get_item", () => {
const predicate_opts = {
get_item: (n) => items[n],
filter: {
predicate: predicate,
predicate,
},
};
@ -691,7 +691,7 @@ run_test("render item", () => {
const widget = list_render.create(container, list, {
name: "replace-list",
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
get_item: get_item,
get_item,
html_selector: (item) => `tr[data-item='${item}']`,
simplebar_container: scroll_container,
});
@ -726,7 +726,7 @@ run_test("render item", () => {
list_render.create(container, list, {
name: "replace-list",
modifier: (item) => `<tr data-item=${item.value}>${item.text}</tr>\n`,
get_item: get_item,
get_item,
html_selector: "hello world",
simplebar_container: scroll_container,
});
@ -751,7 +751,7 @@ run_test("render item", () => {
const widget_3 = list_render.create(container, list, {
name: "replace-list",
modifier: (item) => (rendering_item ? undefined : `${item}\n`),
get_item: get_item,
get_item,
html_selector: (item) => `tr[data-item='${item}']`,
simplebar_container: scroll_container,
});

View File

@ -63,8 +63,8 @@ function make_home_msg_list() {
const filter = new Filter();
const list = new message_list.MessageList({
table_name: table_name,
filter: filter,
table_name,
filter,
});
return list;
}
@ -205,8 +205,8 @@ function initial_fetch_step() {
self.finish = function () {
test_fetch_success({
fetch: fetch,
response: response,
fetch,
response,
});
};
@ -233,8 +233,8 @@ function forward_fill_step() {
};
test_fetch_success({
fetch: fetch,
response: response,
fetch,
response,
});
assert.equal(idle_config.idle, 10000);
@ -255,8 +255,8 @@ function test_backfill_idle(idle_config) {
idle_config.onIdle();
test_fetch_success({
fetch: fetch,
response: response,
fetch,
response,
});
}
@ -291,7 +291,7 @@ function simulate_narrow() {
const msg_list = new message_list.MessageList({
table_name: "zfilt",
filter: filter,
filter,
});
set_global("current_msg_list", msg_list);
@ -302,7 +302,7 @@ run_test("loading_newer", () => {
function test_dup_new_fetch(msg_list) {
assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), false);
message_fetch.maybe_load_newer_messages({
msg_list: msg_list,
msg_list,
});
}
@ -321,7 +321,7 @@ run_test("loading_newer", () => {
assert.throws(
() => {
message_fetch.maybe_load_newer_messages({
msg_list: msg_list,
msg_list,
show_loading: noop,
hide_loading: noop,
});
@ -333,7 +333,7 @@ run_test("loading_newer", () => {
);
} else {
message_fetch.maybe_load_newer_messages({
msg_list: msg_list,
msg_list,
show_loading: noop,
hide_loading: noop,
});
@ -341,7 +341,7 @@ run_test("loading_newer", () => {
test_dup_new_fetch(msg_list);
test_fetch_success({
fetch: fetch,
fetch,
response: data.resp,
});
}
@ -365,8 +365,8 @@ run_test("loading_newer", () => {
};
test_happy_path({
msg_list: msg_list,
data: data,
msg_list,
data,
empty_msg_list: true,
});
@ -376,8 +376,8 @@ run_test("loading_newer", () => {
msg_list.append(message_range(444, 445), false);
test_happy_path({
msg_list: msg_list,
data: data,
msg_list,
data,
empty_msg_list: false,
});
@ -392,8 +392,8 @@ run_test("loading_newer", () => {
msg_list.data.fetch_status.update_expected_max_message_id([{id: 600}]);
test_happy_path({
msg_list: msg_list,
data: data,
msg_list,
data,
});
// To handle this special case we should allow another fetch to occur,
@ -434,7 +434,7 @@ run_test("loading_newer", () => {
];
test_happy_path({
msg_list: msg_list,
msg_list,
data: data[0],
empty_msg_list: true,
});
@ -443,7 +443,7 @@ run_test("loading_newer", () => {
message_list.all.append(message_range(444, 445), false);
test_happy_path({
msg_list: msg_list,
msg_list,
data: data[0],
empty_msg_list: false,
});
@ -451,7 +451,7 @@ run_test("loading_newer", () => {
assert.equal(msg_list.data.fetch_status.can_load_newer_messages(), true);
test_happy_path({
msg_list: msg_list,
msg_list,
data: data[1],
});

View File

@ -29,7 +29,7 @@ run_test("basics", () => {
const filter = accept_all_filter();
const list = new MessageList({
filter: filter,
filter,
});
const messages = [
@ -438,7 +438,7 @@ run_test("unmuted_messages", () => {
run_test("add_remove_rerender", () => {
const filter = accept_all_filter();
const list = new MessageList({filter: filter});
const list = new MessageList({filter});
const messages = [{id: 1}, {id: 2}, {id: 3}];

View File

@ -15,20 +15,20 @@ set_global("page_params", {
});
set_global("home_msg_list", null);
set_global("people", {
small_avatar_url: function () {
small_avatar_url() {
return "";
},
});
set_global("unread", {message_unread: function () {}});
set_global("unread", {message_unread() {}});
// timerender calls setInterval when imported
set_global("timerender", {
render_date: function (time1, time2) {
render_date(time1, time2) {
if (time2 === undefined) {
return [{outerHTML: String(time1.getTime())}];
}
return [{outerHTML: String(time1.getTime()) + " - " + String(time2.getTime())}];
},
stringify_time: function (time) {
stringify_time(time) {
if (page_params.twenty_four_hour_time) {
return time.toString("HH:mm");
}
@ -37,9 +37,9 @@ set_global("timerender", {
});
set_global("rows", {
get_table: function () {
get_table() {
return {
children: function () {
children() {
return {
detach: noop,
};
@ -166,8 +166,8 @@ run_test("merge_message_groups", () => {
const list = new MessageListView(undefined, undefined, true);
list._message_groups = message_groups;
list.list = {
unsubscribed_bookend_content: function () {},
subscribed_bookend_content: function () {},
unsubscribed_bookend_content() {},
subscribed_bookend_content() {},
};
return list;
}
@ -440,8 +440,8 @@ run_test("render_windows", () => {
const filter = new Filter();
const list = new message_list.MessageList({
table_name: table_name,
filter: filter,
table_name,
filter,
});
const view = list.view;

View File

@ -145,7 +145,7 @@ run_test("message_booleans_parity", () => {
// This test asserts that both have identical behavior for the
// flags common between them.
const assert_bool_match = (flags, expected_message) => {
const set_message = {topic: "set_message_booleans", flags: flags};
const set_message = {topic: "set_message_booleans", flags};
const update_message = {topic: "update_booleans"};
message_store.set_message_booleans(set_message);
message_store.update_booleans(update_message, flags);
@ -206,7 +206,7 @@ run_test("errors", () => {
// This should early return and not run pm_conversation.set_partner
let num_partner = 0;
set_global("pm_conversation", {
set_partner: function () {
set_partner() {
num_partner += 1;
},
});
@ -270,7 +270,7 @@ run_test("message_id_change", () => {
set_global("pointer", {
furthest_read: 401,
set_furthest_read: function (value) {
set_furthest_read(value) {
this.furthest_read = value;
},
});

View File

@ -21,7 +21,7 @@ set_global("hashchange", {});
set_global("home_msg_list", {});
set_global("message_fetch", {});
set_global("message_list", {
set_narrowed: function (value) {
set_narrowed(value) {
this.narrowed = value;
},
});
@ -38,10 +38,10 @@ set_global("ui_util", {});
set_global("unread_ops", {});
set_global("search_pill_widget", {
widget: {
clear: function () {
clear() {
return true;
},
appendValue: function () {
appendValue() {
return true;
},
},
@ -112,7 +112,7 @@ function stub_message_list() {
const list = this;
this.data = opts.data;
this.view = {
set_message_offset: function (offset) {
set_message_offset(offset) {
list.view.offset = offset;
},
};
@ -121,15 +121,15 @@ function stub_message_list() {
};
message_list.MessageList.prototype = {
get: function (msg_id) {
get(msg_id) {
return this.data.get(msg_id);
},
empty: function () {
empty() {
return this.data.empty();
},
select_id: function (msg_id) {
select_id(msg_id) {
this.selected_id = msg_id;
},
};

View File

@ -28,7 +28,7 @@ function test_with(fixture) {
const muting_enabled = narrow_state.muting_enabled();
const msg_data = new MessageListData({
filter: narrow_state.filter(),
muting_enabled: muting_enabled,
muting_enabled,
});
const id_info = {
target_id: fixture.target_id,
@ -60,8 +60,8 @@ function test_with(fixture) {
narrow_state.get_first_unread_info = () => fixture.unread_info;
narrow.maybe_add_local_messages({
id_info: id_info,
msg_data: msg_data,
id_info,
msg_data,
});
assert.deepEqual(id_info, fixture.expected_id_info);

View File

@ -6,7 +6,7 @@ set_global(
}),
);
set_global("document", {
hasFocus: function () {
hasFocus() {
return true;
},
});

View File

@ -486,10 +486,10 @@ initialize();
run_test("recipient_counts", () => {
const user_id = 99;
assert.equal(people.get_recipient_count({user_id: user_id}), 0);
assert.equal(people.get_recipient_count({user_id}), 0);
people.incr_recipient_count(user_id);
people.incr_recipient_count(user_id);
assert.equal(people.get_recipient_count({user_id: user_id}), 2);
assert.equal(people.get_recipient_count({user_id}), 2);
assert.equal(people.get_recipient_count({pm_recipient_count: 5}), 5);
});
@ -852,7 +852,7 @@ run_test("updates", () => {
let person = {
email: old_email,
user_id: user_id,
user_id,
full_name: "Foo Barson",
};
people.add_active_user(person);

View File

@ -5,7 +5,7 @@ set_global("ui", {
get_content_element: (element) => element,
});
set_global("stream_popover", {
hide_topic_popover: function () {},
hide_topic_popover() {},
});
set_global("unread", {});
set_global("unread_ui", {});

View File

@ -152,7 +152,7 @@ run_test("activate another person poll", () => {
const opts = {
elem: widget_elem,
callback: callback,
callback,
message: {
sender_id: 100,
},
@ -298,7 +298,7 @@ run_test("activate own poll", () => {
};
const opts = {
elem: widget_elem,
callback: callback,
callback,
message: {
sender_id: 100,
},

View File

@ -33,7 +33,7 @@ emoji.initialize();
set_global("channel", {});
set_global("emoji_picker", {
hide_emoji_popover: function () {},
hide_emoji_popover() {},
});
const alice = {
@ -75,20 +75,20 @@ const message = {
};
set_global("message_store", {
get: function (message_id) {
get(message_id) {
assert.equal(message_id, 1001);
return message;
},
});
set_global("current_msg_list", {
selected_message: function () {
selected_message() {
return {sent_by_me: true};
},
selected_row: function () {
selected_row() {
return $(".selected-row");
},
selected_id: function () {
selected_id() {
return 42;
},
});
@ -461,8 +461,8 @@ run_test("with_view_stubs", () => {
function add_call_func(name) {
return function (opts) {
calls.push({
name: name,
opts: opts,
name,
opts,
});
};
}
@ -503,7 +503,7 @@ run_test("with_view_stubs", () => {
};
test_view_calls({
run_code: function () {
run_code() {
reactions.add_reaction(alice_8ball_event);
},
expected_view_calls: [
@ -521,7 +521,7 @@ run_test("with_view_stubs", () => {
});
test_view_calls({
run_code: function () {
run_code() {
reactions.add_reaction(bob_8ball_event);
},
expected_view_calls: [
@ -540,7 +540,7 @@ run_test("with_view_stubs", () => {
});
test_view_calls({
run_code: function () {
run_code() {
reactions.add_reaction(cali_airplane_event);
},
expected_view_calls: [
@ -558,7 +558,7 @@ run_test("with_view_stubs", () => {
});
test_view_calls({
run_code: function () {
run_code() {
reactions.remove_reaction(bob_8ball_event);
},
expected_view_calls: [
@ -577,7 +577,7 @@ run_test("with_view_stubs", () => {
});
test_view_calls({
run_code: function () {
run_code() {
reactions.remove_reaction(alice_8ball_event);
},
expected_view_calls: [

View File

@ -17,7 +17,7 @@ set_global("overlays", {
recent_topics_open: () => true,
});
set_global("people", {
is_my_user_id: function (id) {
is_my_user_id(id) {
return id === 1;
},
sender_info_with_small_avatar_urls_for_sender_ids: (ids) => ids,
@ -112,7 +112,7 @@ const messages = [];
set_global("message_list", {
all: {
all_messages: function () {
all_messages() {
return messages;
},
},
@ -256,8 +256,8 @@ function generate_topic_data(topic_info_array) {
const topic_selector = $.create("#recent_topic:" + get_topic_key(stream_id, topic));
topic_selector.data = function () {
return {
participated: participated,
muted: muted,
participated,
muted,
unreadCount: unread_count,
};
};
@ -272,15 +272,15 @@ function generate_topic_data(topic_info_array) {
senders: [1, 2],
stream: "stream" + stream_id,
stream_color: "",
stream_id: stream_id,
stream_id,
stream_url: "https://www.example.com",
topic: topic,
topic,
topic_key: get_topic_key(stream_id, topic),
topic_url: "https://www.example.com",
unread_count: unread_count,
muted: muted,
unread_count,
muted,
topic_muted: muted,
participated: participated,
participated,
});
}
return data;
@ -638,7 +638,7 @@ run_test("test_delete_messages", () => {
set_global("message_list", {
all: {
all_messages: function () {
all_messages() {
// messages[0] was removed.
const reduced_msgs = [...messages];
reduced_msgs.splice(0, 1);
@ -662,7 +662,7 @@ run_test("test_delete_messages", () => {
set_global("message_list", {
all: {
all_messages: function () {
all_messages() {
// messages[0], messages[1] and message[2] were removed.
const reduced_msgs = [...messages];
reduced_msgs.splice(0, 3);
@ -683,7 +683,7 @@ run_test("test_delete_messages", () => {
run_test("test_topic_edit", () => {
set_global("message_list", {
all: {
all_messages: function () {
all_messages() {
return messages;
},
},

View File

@ -54,7 +54,7 @@ run_test("get_items", () => {
const items = [is_starred_item, is_private_item];
const pill_widget = {
items: function () {
items() {
return items;
},
};

View File

@ -326,9 +326,9 @@ run_test("group_suggestions", () => {
return {
type: "private",
display_recipient: user_ids.map((id) => ({
id: id,
id,
})),
timestamp: timestamp,
timestamp,
};
}
@ -713,7 +713,7 @@ run_test("topic_suggestions", () => {
for (const topic_name of ["team", "ignore", "test"]) {
stream_topic_history.add_message({
stream_id: office_id,
topic_name: topic_name,
topic_name,
});
}

View File

@ -330,9 +330,9 @@ run_test("group_suggestions", () => {
return {
type: "private",
display_recipient: user_ids.map((id) => ({
id: id,
id,
})),
timestamp: timestamp,
timestamp,
};
}
@ -680,7 +680,7 @@ run_test("topic_suggestions", () => {
for (const topic_name of ["team", "ignore", "test"]) {
stream_topic_history.add_message({
stream_id: office_id,
topic_name: topic_name,
topic_name,
});
}

View File

@ -12,13 +12,13 @@ zrequire("sent_messages");
set_global("channel", {});
set_global("home_msg_list", {
select_id: noop,
selected_id: function () {
selected_id() {
return 1;
},
});
set_global("page_params", {test_suite: false});
set_global("reload_state", {
is_in_progress: function () {
is_in_progress() {
return false;
},
});
@ -27,16 +27,16 @@ set_global("reload_state", {
set_global("pointer", {});
set_global("echo", {
process_from_server: function (messages) {
process_from_server(messages) {
return messages;
},
update_realm_filter_rules: noop,
});
set_global("ui_report", {
hide_error: function () {
hide_error() {
return false;
},
show_error: function () {
show_error() {
return false;
},
});
@ -54,7 +54,7 @@ run_test("message_event", () => {
let inserted;
set_global("message_events", {
insert_new_messages: function (messages) {
insert_new_messages(messages) {
assert.equal(messages[0].content, event.message.content);
inserted = true;
},
@ -69,15 +69,15 @@ run_test("message_event", () => {
const setup = function () {
server_events.home_view_loaded();
set_global("message_events", {
insert_new_messages: function () {
insert_new_messages() {
throw Error("insert error");
},
update_messages: function () {
update_messages() {
throw Error("update error");
},
});
set_global("stream_events", {
update_property: function () {
update_property() {
throw Error("subs update error");
},
});

View File

@ -5,7 +5,7 @@ const noop = () => {};
let form_data;
const _jQuery = {
each: function (lst, f) {
each(lst, f) {
for (const [k, v] of lst.entries()) {
f(k, v);
}
@ -43,11 +43,11 @@ global.stub_templates((name, data) => {
const _overlays = {};
const _ui_report = {
success: function (msg, elem) {
success(msg, elem) {
elem.val(msg);
},
error: function (msg, xhr, elem) {
error(msg, xhr, elem) {
elem.val(msg);
},
};
@ -165,11 +165,11 @@ function createSaveButtons(subsection) {
props.hidden = true;
};
return {
props: props,
props,
save_button: stub_save_button,
discard_button: stub_discard_button,
save_button_header: stub_save_button_header,
save_button_controls: save_button_controls,
save_button_controls,
save_button_text: stub_save_button_text,
};
}
@ -348,7 +348,7 @@ function test_change_save_button_state() {
function test_upload_realm_icon(upload_realm_logo_or_icon) {
form_data = {
append: function (field, val) {
append(field, val) {
form_data[field] = val;
},
};

View File

@ -165,8 +165,8 @@ run_test("populate_profile_fields", () => {
];
test_populate({
fields_data: fields_data,
expected_template_data: expected_template_data,
fields_data,
expected_template_data,
is_admin: true,
});
});

View File

@ -23,7 +23,7 @@ set_global("user_groups", {
set_global("ui_report", {});
set_global("people", {
my_current_user_id: noop,
small_avatar_url_for_person: function () {
small_avatar_url_for_person() {
return "http://example.com/example.png";
},
});
@ -620,7 +620,7 @@ run_test("on_events", () => {
let default_action_for_enter_stopped = false;
const event = {
which: 13,
preventDefault: function () {
preventDefault() {
default_action_for_enter_stopped = true;
},
};

View File

@ -950,10 +950,10 @@ run_test("filter inactives", () => {
const stream_id = 100 + i;
const sub = {
name: name,
name,
subscribed: true,
newly_subscribed: false,
stream_id: stream_id,
stream_id,
};
stream_data.add_sub(sub);
});

View File

@ -210,7 +210,7 @@ run_test("marked_subscribed", () => {
set_global("message_list", {
all: {
all_messages: function () {
all_messages() {
return ["msg"];
},
},

View File

@ -228,8 +228,8 @@ set_global("$", global.make_zjquery());
function add_row(sub) {
global.stream_data.add_sub(sub);
const row = {
update_whether_active: function () {},
get_li: function () {
update_whether_active() {},
get_li() {
const html = "<" + sub.name + " sidebar row html>";
const obj = $(html);
@ -383,7 +383,7 @@ run_test("narrowing", () => {
initialize_stream_data();
set_global("narrow_state", {
stream: function () {
stream() {
return "devel";
},
topic: noop,
@ -445,7 +445,7 @@ run_test("focusout_user_filter", () => {
run_test("focus_user_filter", () => {
const e = {
stopPropagation: function () {},
stopPropagation() {},
};
const click_handler = $(".stream-list-filter").get_on_handler("click");
click_handler(e);
@ -631,7 +631,7 @@ run_test("update_count_in_dom", () => {
const stream_id = 11;
const stream_row = {
get_li: function () {
get_li() {
return stream_li;
},
};
@ -640,7 +640,7 @@ run_test("update_count_in_dom", () => {
stream_count.set(stream_id, 0);
const counts = {
stream_count: stream_count,
stream_count,
topic_count: new Map(),
};
@ -736,7 +736,7 @@ run_test("create_initial_sidebar_rows", () => {
stream_list.stream_sidebar = {
has_row_for: return_false,
set_row: function (stream_id, widget) {
set_row(stream_id, widget) {
html_dict.set(stream_id, widget.get_li().html());
},
};

View File

@ -31,7 +31,7 @@ function make_cursor_helper() {
};
return {
events: events,
events,
};
}

View File

@ -9,7 +9,7 @@ run_test("basics", () => {
const stream_id = 55;
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 101,
topic_name: "toPic1",
});
@ -20,7 +20,7 @@ run_test("basics", () => {
assert.deepEqual(max_message_id, 101);
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 102,
topic_name: "Topic1",
});
@ -30,7 +30,7 @@ run_test("basics", () => {
assert.deepEqual(max_message_id, 102);
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 103,
topic_name: "topic2",
});
@ -41,7 +41,7 @@ run_test("basics", () => {
// Removing first topic1 message has no effect.
stream_topic_history.remove_messages({
stream_id: stream_id,
stream_id,
topic_name: "toPic1",
num_messages: 1,
});
@ -53,7 +53,7 @@ run_test("basics", () => {
// Removing second topic1 message removes the topic.
stream_topic_history.remove_messages({
stream_id: stream_id,
stream_id,
topic_name: "Topic1",
num_messages: 1,
});
@ -62,7 +62,7 @@ run_test("basics", () => {
// Test that duplicate remove does not crash us.
stream_topic_history.remove_messages({
stream_id: stream_id,
stream_id,
topic_name: "Topic1",
num_messages: 1,
});
@ -123,7 +123,7 @@ run_test("server_history", () => {
assert.equal(stream_topic_history.is_complete_for_stream_id(stream_id), false);
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 501,
topic_name: "local",
});
@ -148,7 +148,7 @@ run_test("server_history", () => {
// If new activity comes in for historical messages,
// they can bump to the front of the list.
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 502,
topic_name: "hist1",
});
@ -163,7 +163,7 @@ run_test("server_history", () => {
// Removing a local message removes the topic if we have
// our counts right.
stream_topic_history.remove_messages({
stream_id: stream_id,
stream_id,
topic_name: "local",
num_messages: 1,
});
@ -173,7 +173,7 @@ run_test("server_history", () => {
// We can try to remove a historical message, but it should
// have no effect.
stream_topic_history.remove_messages({
stream_id: stream_id,
stream_id,
topic_name: "hist2",
num_messages: 1,
});
@ -196,13 +196,13 @@ run_test("test_unread_logic", () => {
const stream_id = 77;
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 201,
topic_name: "toPic1",
});
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 45,
topic_name: "topic2",
});
@ -241,7 +241,7 @@ run_test("test_stream_has_topics", () => {
assert.equal(stream_topic_history.stream_has_topics(stream_id), false);
stream_topic_history.add_message({
stream_id: stream_id,
stream_id,
message_id: 888,
topic_name: "whatever",
});
@ -273,7 +273,7 @@ run_test("server_history_end_to_end", () => {
on_success_called = true;
});
get_success_callback({topics: topics});
get_success_callback({topics});
assert(on_success_called);

View File

@ -21,12 +21,12 @@ run_test("get_message_events", () => {
msg = {
locally_echoed: true,
submessages: submessages,
submessages,
};
assert.equal(submessage.get_message_events(msg), undefined);
msg = {
submessages: submessages,
submessages,
};
assert.deepEqual(submessage.get_message_events(msg), [
{sender_id: 33, data: 42},
@ -44,7 +44,7 @@ run_test("make_server_callback", () => {
assert.deepEqual(opts, {
url: "/json/submessage",
data: {
message_id: message_id,
message_id,
msg_type: "whatever",
content: '{"foo":32}',
},

View File

@ -13,10 +13,10 @@ run_test("narrowing", () => {
let pm_closed;
set_global("pm_list", {
close: function () {
close() {
pm_closed = true;
},
expand: function () {
expand() {
pm_expanded = true;
},
});

View File

@ -150,7 +150,7 @@ run_test("fchain", () => {
const mults = function (n) {
let ret = 0;
return {
next: function () {
next() {
ret += n;
return ret <= 100 ? ret : undefined;
},

View File

@ -43,7 +43,7 @@ run_test("get_list_info w/real stream_topic_history", () => {
const topic_name = "topic " + i;
stream_topic_history.add_message({
stream_id: general.stream_id,
topic_name: topic_name,
topic_name,
message_id: 1000 + i,
});
}

View File

@ -116,7 +116,7 @@ run_test("reply_message_stream", () => {
transmit.reply_message({
message: stream_message,
content: content,
content,
});
assert.deepEqual(send_message_args, {
@ -159,7 +159,7 @@ run_test("reply_message_private", () => {
transmit.reply_message({
message: pm_message,
content: content,
content,
});
assert.deepEqual(send_message_args, {

View File

@ -61,8 +61,8 @@ run_test("basics", () => {
worker = {
get_current_time: returns_time(5),
notify_server_start: notify_server_start,
notify_server_stop: notify_server_stop,
notify_server_start,
notify_server_stop,
};
// Start talking to alice.

View File

@ -81,7 +81,7 @@ run_test("changing_topics", () => {
const message = {
id: 15,
type: "stream",
stream_id: stream_id,
stream_id,
topic: "luNch",
unread: true,
};
@ -89,7 +89,7 @@ run_test("changing_topics", () => {
const other_message = {
id: 16,
type: "stream",
stream_id: stream_id,
stream_id,
topic: "lunCH",
unread: true,
};
@ -163,7 +163,7 @@ run_test("changing_topics", () => {
const sticky_message = {
id: 17,
type: "stream",
stream_id: stream_id,
stream_id,
topic: "sticky",
unread: true,
};
@ -217,7 +217,7 @@ run_test("muting", () => {
const message = {
id: 15,
type: "stream",
stream_id: stream_id,
stream_id,
topic: "test_muting",
unread: true,
};
@ -262,7 +262,7 @@ run_test("num_unread_for_topic", () => {
const message = {
type: "stream",
stream_id: stream_id,
stream_id,
topic: "LuncH",
unread: true,
};
@ -288,8 +288,8 @@ run_test("num_unread_for_topic", () => {
const topic_dict = new FoldDict();
let missing_topics = unread.get_missing_topics({
stream_id: stream_id,
topic_dict: topic_dict,
stream_id,
topic_dict,
});
assert.deepEqual(missing_topics, [{pretty_name: "LuncH", message_id: 500}]);
@ -297,8 +297,8 @@ run_test("num_unread_for_topic", () => {
topic_dict.set("lUNCh", "whatever");
missing_topics = unread.get_missing_topics({
stream_id: stream_id,
topic_dict: topic_dict,
stream_id,
topic_dict,
});
assert.deepEqual(missing_topics, []);
@ -337,7 +337,7 @@ run_test("home_messages", () => {
const message = {
id: 15,
type: "stream",
stream_id: stream_id,
stream_id,
topic: "lunch",
unread: true,
};
@ -675,7 +675,7 @@ run_test("empty_cases", () => {
assert.deepEqual(unread.get_all_msg_ids(), []);
const missing_topics = unread.get_missing_topics({
stream_id: stream_id,
stream_id,
topic_dict: "should-never-be-referenced",
});
assert.deepEqual(missing_topics, []);

View File

@ -348,7 +348,7 @@ run_test("file_input", () => {
const files = ["file1", "file2"];
const event = {
target: {
files: files,
files,
value: "C:\\fakepath\\portland.png",
},
};
@ -388,7 +388,7 @@ run_test("file_drop", () => {
},
originalEvent: {
dataTransfer: {
files: files,
files,
},
},
};

View File

@ -5,47 +5,47 @@ const settings_config = zrequire("settings_config");
zrequire("user_events");
set_global("activity", {
redraw: function () {},
redraw() {},
});
set_global("settings_linkifiers", {
maybe_disable_widgets: function () {},
maybe_disable_widgets() {},
});
set_global("settings_org", {
maybe_disable_widgets: function () {},
maybe_disable_widgets() {},
});
set_global("settings_profile_fields", {
maybe_disable_widgets: function () {},
maybe_disable_widgets() {},
});
set_global("settings_streams", {
maybe_disable_widgets: function () {},
maybe_disable_widgets() {},
});
set_global("settings_users", {
update_user_data: function () {},
update_user_data() {},
});
set_global("gear_menu", {
update_org_settings_menu_item: function () {},
update_org_settings_menu_item() {},
});
set_global("page_params", {
is_admin: true,
});
set_global("pm_list", {
update_private_messages: function () {},
update_private_messages() {},
});
set_global("narrow_state", {
update_email: function () {},
update_email() {},
});
set_global("compose", {
update_email: function () {},
update_email() {},
});
set_global("settings_account", {
update_email: function () {},
update_full_name: function () {},
update_email() {},
update_full_name() {},
});
set_global("message_live_update", {});

View File

@ -81,7 +81,7 @@ run_test("append", () => {
user_pill.append_person({
person: isaac,
pill_widget: pill_widget,
pill_widget,
});
assert(appended);
@ -92,7 +92,7 @@ run_test("get_items", () => {
const items = [isaac_item, bogus_item];
const pill_widget = {
items: function () {
items() {
return items;
},
};
@ -104,7 +104,7 @@ run_test("typeahead", () => {
const items = [isaac_item, bogus_item];
const pill_widget = {
items: function () {
items() {
return items;
},
};

View File

@ -9,7 +9,7 @@ run_test("CachedValue", () => {
let x = 5;
const cv = new util.CachedValue({
compute_value: function () {
compute_value() {
return x * 2;
},
});

View File

@ -103,9 +103,9 @@ function make_child(i, name) {
return {
key: i,
render: render,
name: name,
eq: eq,
render,
name,
eq,
};
}

View File

@ -58,7 +58,7 @@ run_test("activate", () => {
assert.equal(data.msg_type, "widget");
assert.equal(data.data, "test_data");
},
row: row,
row,
widget_type: "poll",
};

View File

@ -168,7 +168,7 @@ run_test("events", () => {
// Set up a stub event so that stopPropagation doesn't explode on us.
const stub_event = {
stopPropagation: function () {},
stopPropagation() {},
};
// Now call the handler.

View File

@ -58,10 +58,10 @@ exports.restore = function () {
exports.stub_out_jquery = function () {
set_global("$", () => ({
on: function () {},
trigger: function () {},
hide: function () {},
removeClass: function () {},
on() {},
trigger() {},
hide() {},
removeClass() {},
}));
$.fn = {};
$.now = function () {};

View File

@ -26,7 +26,7 @@ exports.make_event_store = (selector) => {
let focused = false;
const self = {
get_on_handler: function (name, child_selector) {
get_on_handler(name, child_selector) {
let handler;
if (child_selector === undefined) {
@ -49,7 +49,7 @@ exports.make_event_store = (selector) => {
return handler;
},
off: function (event_name, ...args) {
off(event_name, ...args) {
if (args.length === 0) {
on_functions.delete(event_name);
return;
@ -62,7 +62,7 @@ exports.make_event_store = (selector) => {
throw Error("zjquery does not support this call sequence");
},
on: function (event_name, ...args) {
on(event_name, ...args) {
// parameters will either be
// (event_name, handler) or
// (event_name, sel, handler)
@ -106,7 +106,7 @@ exports.make_event_store = (selector) => {
});
},
trigger: function ($element, ev, data) {
trigger($element, ev, data) {
if (typeof ev === "string") {
ev = new Event(ev, data);
}
@ -151,22 +151,22 @@ exports.make_new_elem = function (selector, opts) {
const event_store = exports.make_event_store(selector);
const self = {
addClass: function (class_name) {
addClass(class_name) {
classes.set(class_name, true);
return self;
},
append: function (arg) {
append(arg) {
html = html + arg;
return self;
},
attr: function (name, val) {
attr(name, val) {
if (val === undefined) {
return attrs.get(name);
}
attrs.set(name, val);
return self;
},
data: function (name, val) {
data(name, val) {
if (val === undefined) {
const data_val = attrs.get("data-" + name);
if (data_val === undefined) {
@ -177,31 +177,31 @@ exports.make_new_elem = function (selector, opts) {
attrs.set("data-" + name, val);
return self;
},
delay: function () {
delay() {
return self;
},
debug: function () {
debug() {
return {
value: value,
shown: shown,
selector: selector,
value,
shown,
selector,
};
},
empty: function (arg) {
empty(arg) {
if (arg === undefined) {
find_results.clear();
}
return self;
},
eq: function () {
eq() {
return self;
},
expectOne: function () {
expectOne() {
// silently do nothing
return self;
},
fadeTo: noop,
find: function (child_selector) {
find(child_selector) {
const child = find_results.get(child_selector);
if (child) {
return child;
@ -217,30 +217,30 @@ exports.make_new_elem = function (selector, opts) {
}
throw Error("Cannot find " + child_selector + " in " + selector);
},
get: function (idx) {
get(idx) {
// We have some legacy code that does $('foo').get(0).
assert.equal(idx, 0);
return selector;
},
get_on_handler: function (name, child_selector) {
get_on_handler(name, child_selector) {
return event_store.get_on_handler(name, child_selector);
},
hasClass: function (class_name) {
hasClass(class_name) {
return classes.has(class_name);
},
height: noop,
hide: function () {
hide() {
shown = false;
return self;
},
html: function (arg) {
html(arg) {
if (arg !== undefined) {
html = arg;
return self;
}
return html;
},
is: function (arg) {
is(arg) {
if (arg === ":visible") {
return shown;
}
@ -249,27 +249,27 @@ exports.make_new_elem = function (selector, opts) {
}
return self;
},
is_focused: function () {
is_focused() {
// is_focused is not a jQuery thing; this is
// for our testing
return event_store.is_focused();
},
off: function (...args) {
off(...args) {
event_store.off(...args);
return self;
},
on: function (...args) {
on(...args) {
event_store.on(...args);
return self;
},
one: function (...args) {
one(...args) {
event_store.one(...args);
return self;
},
parent: function () {
parent() {
return my_parent;
},
parents: function (parents_selector) {
parents(parents_selector) {
const result = parents_result.get(parents_selector);
assert(
result,
@ -277,58 +277,58 @@ exports.make_new_elem = function (selector, opts) {
);
return result;
},
prepend: function (arg) {
prepend(arg) {
html = arg + html;
return self;
},
prop: function (name, val) {
prop(name, val) {
if (val === undefined) {
return properties.get(name);
}
properties.set(name, val);
return self;
},
removeAttr: function (name) {
removeAttr(name) {
attrs.delete(name);
return self;
},
removeClass: function (class_names) {
removeClass(class_names) {
class_names = class_names.split(" ");
class_names.forEach((class_name) => {
classes.delete(class_name);
});
return self;
},
remove: function () {
remove() {
return self;
},
removeData: noop,
replaceWith: function () {
replaceWith() {
return self;
},
scrollTop: function () {
scrollTop() {
return self;
},
set_find_results: function (find_selector, jquery_object) {
set_find_results(find_selector, jquery_object) {
find_results.set(find_selector, jquery_object);
},
show: function () {
show() {
shown = true;
return self;
},
serializeArray: function () {
serializeArray() {
return self;
},
set_parent: function (parent_elem) {
set_parent(parent_elem) {
my_parent = parent_elem;
},
set_parents_result: function (selector, result) {
set_parents_result(selector, result) {
parents_result.set(selector, result);
},
stop: function () {
stop() {
return self;
},
text: function (...args) {
text(...args) {
if (args.length !== 0) {
if (args[0] !== undefined) {
text = args[0].toString();
@ -337,28 +337,28 @@ exports.make_new_elem = function (selector, opts) {
}
return text;
},
trigger: function (ev) {
trigger(ev) {
event_store.trigger(self, ev);
return self;
},
val: function (...args) {
val(...args) {
if (args.length === 0) {
return value || "";
}
[value] = args;
return self;
},
css: function (...args) {
css(...args) {
if (args.length === 0) {
return css || {};
}
[css] = args;
return self;
},
visible: function () {
visible() {
return shown;
},
slice: function () {
slice() {
return self;
},
};

View File

@ -178,7 +178,7 @@ function send_presence_to_server(want_redraw) {
slim_presence: true,
},
idempotent: true,
success: function (data) {
success(data) {
// Update Zephyr mirror activity warning
if (data.zephyr_mirror_active === false) {
$("#zephyr-mirror-error").addClass("show");
@ -265,7 +265,7 @@ exports.reset_users = function () {
exports.narrow_for_user = function (opts) {
const user_id = buddy_list.get_key_from_li({li: opts.li});
return exports.narrow_for_user_id({user_id: user_id});
return exports.narrow_for_user_id({user_id});
};
exports.narrow_for_user_id = function (opts) {
@ -282,7 +282,7 @@ function keydown_enter_key() {
return;
}
exports.narrow_for_user_id({user_id: user_id});
exports.narrow_for_user_id({user_id});
popovers.hide_all();
}
@ -305,15 +305,15 @@ exports.set_cursor_and_filter = function () {
keydown_util.handle({
elem: $input,
handlers: {
enter_key: function () {
enter_key() {
keydown_enter_key();
return true;
},
up_arrow: function () {
up_arrow() {
exports.user_cursor.prev();
return true;
},
down_arrow: function () {
down_arrow() {
exports.user_cursor.next();
return true;
},

View File

@ -44,14 +44,14 @@ function add_alert_word(alert_word) {
channel.post({
url: "/json/users/me/alert_words",
data: {alert_words: JSON.stringify(words_to_be_added)},
success: function () {
success() {
const message = i18n.t('Alert word "__word__" added successfully!', {
word: words_to_be_added[0],
});
update_alert_word_status(message, false);
$("#create_alert_word_name").val("");
},
error: function () {
error() {
update_alert_word_status(i18n.t("Error adding alert word!"), true);
},
});
@ -63,10 +63,10 @@ function remove_alert_word(alert_word) {
channel.del({
url: "/json/users/me/alert_words",
data: {alert_words: JSON.stringify(words_to_be_removed)},
success: function () {
success() {
update_alert_word_status(i18n.t("Alert word removed successfully!"), false);
},
error: function () {
error() {
update_alert_word_status(i18n.t("Error removing alert word!"), true);
},
});

View File

@ -100,18 +100,18 @@ exports.initialize = function () {
};
exports.current_msg_list = {
selected_row: function () {
selected_row() {
return $(".message_row").last();
},
};
exports.rows = {
get_message_recipient_row: function (message_row) {
get_message_recipient_row(message_row) {
return $(message_row).parent(".recipient_row");
},
first_message_in_group: function (message_group) {
first_message_in_group(message_group) {
return $("div.message_row", message_group).first();
},
id: function (message_row) {
id(message_row) {
return parseFloat(message_row.attr("zid"));
},
};

View File

@ -46,10 +46,10 @@ function delete_attachments(attachment) {
channel.del({
url: "/json/attachments/" + attachment,
idempotent: true,
error: function (xhr) {
error(xhr) {
ui_report.error(i18n.t("Failed"), xhr, status);
},
success: function () {
success() {
ui_report.success(i18n.t("Attachment deleted"), status);
},
});
@ -83,15 +83,15 @@ function render_attachments_ui() {
list_render.create(uploaded_files_table, attachments, {
name: "uploaded-files-list",
modifier: function (attachment) {
return render_uploaded_files_list({attachment: attachment});
modifier(attachment) {
return render_uploaded_files_list({attachment});
},
filter: {
element: $search_input,
predicate: function (item, value) {
predicate(item, value) {
return item.name.toLocaleLowerCase().includes(value);
},
onupdate: function () {
onupdate() {
ui.reset_scrollbar(uploaded_files_table.closest(".progressive-table-wrapper"));
},
},
@ -145,14 +145,14 @@ exports.set_up_attachments = function () {
channel.get({
url: "/json/attachments",
idempotent: true,
success: function (data) {
success(data) {
loading.destroy_indicator($("#attachments_loading_indicator"));
format_attachment_data(data.attachments);
attachments = data.attachments;
upload_space_used = data.upload_space_used;
render_attachments_ui();
},
error: function (xhr) {
error(xhr) {
loading.destroy_indicator($("#attachments_loading_indicator"));
ui_report.error(i18n.t("Failed"), xhr, status);
},

View File

@ -56,7 +56,7 @@ exports.build_user_avatar_widget = function (upload_function) {
e.stopPropagation();
channel.del({
url: "/json/users/me/avatar",
success: function () {
success() {
$("#user-avatar-upload-widget .settings-page-delete-button").hide();
$("#user-avatar-source").show();
// Need to clear input because of a small edge case

View File

@ -7,7 +7,7 @@ exports.initialize = function () {
key: stripe_key,
image: "/static/images/logo/zulip-icon-128x128.png",
locale: "auto",
token: function (stripe_token) {
token(stripe_token) {
helpers.create_ajax_request("/json/billing/sources/change", "cardchange", stripe_token);
},
});
@ -19,7 +19,7 @@ exports.initialize = function () {
zipCode: true,
billingAddress: true,
panelLabel: "Update card",
email: email,
email,
label: "Update card",
allowRememberMe: false,
});

View File

@ -39,9 +39,9 @@ exports.create_ajax_request = function (
});
$.post({
url: url,
data: data,
success: function () {
url,
data,
success() {
$(form_loading).hide();
$(form_error).hide();
$(form_success).show();
@ -54,7 +54,7 @@ exports.create_ajax_request = function (
}
window.location.replace(redirect_to);
},
error: function (xhr) {
error(xhr) {
$(form_loading).hide();
$(form_error).show().text(JSON.parse(xhr.responseText).msg);
$(form_input_section).show();

View File

@ -6,7 +6,7 @@ exports.initialize = () => {
key: $("#autopay-form").data("key"),
image: "/static/images/logo/zulip-icon-128x128.png",
locale: "auto",
token: function (stripe_token) {
token(stripe_token) {
helpers.create_ajax_request("/json/billing/upgrade", "autopay", stripe_token, [
"licenses",
]);

View File

@ -131,7 +131,7 @@ function report_error(msg, stack, opts) {
log: logger.get_log().join("\n"),
},
timeout: 3 * 1000,
success: function () {
success() {
reported_errors.add(key);
if (opts.show_ui_msg && ui_report !== undefined) {
// There are a few races here (and below in the error
@ -163,7 +163,7 @@ function report_error(msg, stack, opts) {
);
}
},
error: function () {
error() {
if (opts.show_ui_msg && ui_report !== undefined) {
ui_report.message(
"Oops. It seems something has gone wrong. " + "Please try reloading the page.",
@ -259,7 +259,7 @@ exports.error = function blueslip_error(msg, more_info, stack) {
}
const args = build_arg_list(msg, more_info);
logger.error(...args);
report_error(msg, stack, {more_info: more_info});
report_error(msg, stack, {more_info});
if (page_params.debug_mode) {
throw new BlueslipError(msg, more_info);
@ -267,7 +267,7 @@ exports.error = function blueslip_error(msg, more_info, stack) {
};
exports.fatal = function blueslip_fatal(msg, more_info) {
report_error(msg, Error().stack, {more_info: more_info});
report_error(msg, Error().stack, {more_info});
throw new BlueslipError(msg, more_info);
};

View File

@ -11,13 +11,13 @@ const util = require("./util");
exports.max_size_before_shrinking = 600;
const fade_config = {
get_user_id: function (item) {
get_user_id(item) {
return item.user_id;
},
fade: function (item) {
fade(item) {
item.faded = true;
},
unfade: function (item) {
unfade(item) {
item.faded = false;
},
};
@ -182,12 +182,12 @@ exports.info_for = function (user_id) {
return {
href: hash_util.pm_with_uri(person.email),
name: person.full_name,
user_id: user_id,
my_user_status: my_user_status,
user_id,
my_user_status,
is_current_user: people.is_my_user_id(user_id),
num_unread: get_num_unread(user_id),
user_circle_class: user_circle_class,
user_circle_status: user_circle_status,
user_circle_class,
user_circle_status,
};
};
@ -196,7 +196,7 @@ function get_last_seen(active_status, last_seen) {
return last_seen;
}
const last_seen_text = i18n.t("Last active: __last_seen__", {last_seen: last_seen});
const last_seen_text = i18n.t("Last active: __last_seen__", {last_seen});
return last_seen_text;
}

View File

@ -106,7 +106,7 @@ function buddy_list_create() {
});
const html = self.items_to_html({
items: items,
items,
});
self.container = $(self.container_sel);
self.container.append(html);
@ -194,7 +194,7 @@ function buddy_list_create() {
}
self.render_more({
chunk_size: chunk_size,
chunk_size,
});
};
@ -203,7 +203,7 @@ function buddy_list_create() {
// Try direct DOM lookup first for speed.
let li = self.get_li_from_key({
key: key,
key,
});
if (li.length === 1) {
@ -225,11 +225,11 @@ function buddy_list_create() {
}
self.force_render({
pos: pos,
pos,
});
li = self.get_li_from_key({
key: key,
key,
});
return li;
@ -261,10 +261,10 @@ function buddy_list_create() {
const key = opts.key;
const item = opts.item;
self.maybe_remove_key({key: key});
self.maybe_remove_key({key});
const pos = self.find_position({
key: key,
key,
});
// Order is important here--get the other_key
@ -274,11 +274,11 @@ function buddy_list_create() {
self.keys.splice(pos, 0, key);
const html = self.item_to_html({item: item});
const html = self.item_to_html({item});
self.insert_new_html({
pos: pos,
html: html,
other_key: other_key,
pos,
html,
other_key,
});
};
@ -301,7 +301,7 @@ function buddy_list_create() {
const chunk_size = 20;
self.render_more({
chunk_size: chunk_size,
chunk_size,
});
}
};

View File

@ -56,7 +56,7 @@ function call(args, idempotent) {
} catch (ex) {
blueslip.error(
"Unexpected 403 response from server",
{xhr: xhr.responseText, args: args},
{xhr: xhr.responseText, args},
ex.stack,
);
}

View File

@ -216,7 +216,7 @@ exports.initialize = function () {
const title = reactions.get_reaction_title_data(message_id, local_id);
elem.tooltip({
title: title,
title,
trigger: "hover",
placement: "bottom",
animation: false,
@ -495,7 +495,7 @@ exports.initialize = function () {
.on("click", ".selectable_sidebar_block", (e) => {
const li = $(e.target).parents("li");
activity.narrow_for_user({li: li});
activity.narrow_for_user({li});
e.preventDefault();
e.stopPropagation();
@ -724,7 +724,7 @@ exports.initialize = function () {
relay_url: "https://webathena.mit.edu/relay.html",
params: {
realm: "ATHENA.MIT.EDU",
principal: principal,
principal,
},
},
(err, r) => {
@ -740,10 +740,10 @@ exports.initialize = function () {
channel.post({
url: "/accounts/webathena_kerberos_login/",
data: {cred: JSON.stringify(r.session)},
success: function () {
success() {
$("#zephyr-mirror-error").removeClass("show");
},
error: function () {
error() {
$("#zephyr-mirror-error").addClass("show");
},
});

View File

@ -104,28 +104,28 @@ exports.toggle = function (opts) {
})();
const prototype = {
maybe_go_left: maybe_go_left,
maybe_go_right: maybe_go_right,
maybe_go_left,
maybe_go_right,
disable_tab: function (name) {
disable_tab(name) {
const value = opts.values.find((o) => o.key === name);
const idx = opts.values.indexOf(value);
meta.$ind_tab.eq(idx).addClass("disabled");
},
value: function () {
value() {
if (meta.idx >= 0) {
return opts.values[meta.idx].label;
}
},
get: function () {
get() {
return component;
},
// go through the process of finding the correct tab for a given name,
// and when found, select that one and provide the proper callback.
goto: function (name) {
goto(name) {
const value = opts.values.find((o) => o.label === name || o.key === name);
const idx = opts.values.indexOf(value);

View File

@ -203,7 +203,7 @@ function create_message_object() {
// Changes here must also be kept in sync with echo.try_deliver_locally
const message = {
type: compose_state.get_message_type(),
content: content,
content,
sender_id: page_params.user_id,
queue_id: page_params.queue_id,
stream: "",
@ -342,8 +342,8 @@ exports.send_message = function send_message(request) {
request.local_id = local_id;
sent_messages.start_tracking_message({
local_id: local_id,
locally_echoed: locally_echoed,
local_id,
locally_echoed,
});
request.locally_echoed = locally_echoed;
@ -457,14 +457,14 @@ function check_unsubscribed_stream_for_send(stream_name, autosubscribe) {
url: "/json/subscriptions/exists",
data: {stream: stream_name, autosubscribe: true},
async: false,
success: function (data) {
success(data) {
if (data.subscribed) {
result = "subscribed";
} else {
result = "not-subscribed";
}
},
error: function (xhr) {
error(xhr) {
if (xhr.status === 404) {
result = "does-not-exist";
} else {
@ -546,7 +546,7 @@ function validate_stream_message_post_policy(sub) {
) {
error_text = i18n.t(
"New members are not allowed to post to this stream.<br>Permission will be granted in __days__ days.",
{days: days},
{days},
);
compose_error(error_text);
return false;
@ -867,14 +867,14 @@ exports.render_and_show_preview = function (preview_spinner, preview_content_box
channel.post({
url: "/json/messages/render",
idempotent: true,
data: {content: content},
success: function (response_data) {
data: {content},
success(response_data) {
if (markdown.contains_backend_only_syntax(content)) {
loading.destroy_indicator(preview_spinner);
}
show_preview(response_data.rendered, content);
},
error: function () {
error() {
if (markdown.contains_backend_only_syntax(content)) {
loading.destroy_indicator(preview_spinner);
}
@ -923,7 +923,7 @@ exports.warn_if_private_stream_is_linked = function (linked_stream) {
const stream_name = linked_stream.name;
const warning_area = $("#compose_private_stream_alert");
const context = {stream_name: stream_name};
const context = {stream_name};
const new_row = render_compose_private_stream_alert(context);
warning_area.append(new_row);
@ -968,7 +968,7 @@ exports.warn_if_mentioning_unsubscribed_user = function (mentioned) {
if (!existing_invites.includes(user_id)) {
const context = {
user_id: user_id,
user_id,
stream_id: sub.stream_id,
name: mentioned.full_name,
can_subscribe_other_users: page_params.can_subscribe_other_users,
@ -1182,7 +1182,7 @@ exports.initialize = function () {
) {
channel.get({
url: "/json/calls/bigbluebutton/create",
success: function (response) {
success(response) {
insert_video_call_url(response.url, target_textarea);
},
});

View File

@ -92,7 +92,7 @@ function clear_box() {
exports.autosize_message_content = function () {
autosize($("#compose-textarea"), {
callback: function () {
callback() {
exports.maybe_scroll_up_selected_message();
},
});
@ -328,8 +328,8 @@ exports.respond_to_message = function (opts) {
}
exports.start(msg_type, {
stream: stream,
topic: topic,
stream,
topic,
private_message_recipient: pm_recipient,
trigger: opts.trigger,
});
@ -438,7 +438,7 @@ exports.quote_and_reply = function (opts) {
channel.get({
url: "/json/messages/" + message_id,
idempotent: true,
success: function (data) {
success(data) {
message.raw_content = data.raw_content;
replace_content(message);
},

View File

@ -119,13 +119,13 @@ exports.would_receive_message = function (user_id) {
};
const user_fade_config = {
get_user_id: function (li) {
return buddy_list.get_key_from_li({li: li});
get_user_id(li) {
return buddy_list.get_key_from_li({li});
},
fade: function (li) {
fade(li) {
return li.addClass("user-fade");
},
unfade: function (li) {
unfade(li) {
return li.removeClass("user-fade");
},
};

View File

@ -3,7 +3,7 @@ exports.initialize_pill = function () {
const container = $("#private_message_recipient").parent();
const pill = input_pill.create({
container: container,
container,
create_item_from_text: user_pill.create_item_from_email,
get_text_from_item: user_pill.get_email_from_item,
});
@ -23,7 +23,7 @@ exports.set_from_typeahead = function (person) {
// We expect person to be an object returned from people.js.
user_pill.append_person({
pill_widget: exports.widget,
person: person,
person,
});
};

View File

@ -119,7 +119,7 @@ exports.compute_placeholder_text = function (opts) {
});
}
}
return i18n.t("Message __- recipient_names__", {recipient_names: recipient_names});
return i18n.t("Message __- recipient_names__", {recipient_names});
}
return i18n.t("Compose your message here");
};

View File

@ -99,7 +99,7 @@ function get_topic_matcher(query) {
return function (topic) {
const obj = {
topic: topic,
topic,
};
return typeahead.query_matches_source_attrs(query, obj, ["topic"], " ");
@ -366,7 +366,7 @@ exports.broadcast_mentions = function () {
is_broadcast: true,
// used for sorting
idx: idx,
idx,
}));
};
@ -677,7 +677,7 @@ exports.get_candidates = function (query) {
return false;
}
this.token = current_token;
return {is_silent: is_silent};
return {is_silent};
}
function get_slash_commands_data() {
@ -1041,15 +1041,15 @@ exports.initialize_compose_typeahead = function (selector) {
// inside the typeahead library.
source: exports.get_sorted_filtered_items,
highlighter: exports.content_highlighter,
matcher: function () {
matcher() {
return true;
},
sorter: function (items) {
sorter(items) {
return items;
},
updater: exports.content_typeahead_selected,
stopAdvance: true, // Do not advance to the next field on a tab or enter
completions: completions,
completions,
automated: exports.compose_automated_selection,
trigger_selection: exports.compose_trigger_selection,
header: get_header_text,
@ -1092,15 +1092,15 @@ exports.initialize = function () {
// limit number of items so the list doesn't fall off the screen
$("#stream_message_recipient_stream").typeahead({
source: function () {
source() {
return stream_data.subscribed_streams();
},
items: 3,
fixed: true,
highlighter: function (item) {
highlighter(item) {
return typeahead_helper.render_typeahead_item({primary: item});
},
matcher: function (item) {
matcher(item) {
// The matcher for "stream" is strictly prefix-based,
// because we want to avoid mixing up streams.
const q = this.query.trim().toLowerCase();
@ -1109,16 +1109,16 @@ exports.initialize = function () {
});
$("#stream_message_recipient_topic").typeahead({
source: function () {
source() {
const stream_name = compose_state.stream_name();
return exports.topics_seen_for(stream_name);
},
items: 3,
fixed: true,
highlighter: function (item) {
highlighter(item) {
return typeahead_helper.render_typeahead_item({primary: item});
},
sorter: function (items) {
sorter(items) {
const sorted = typeahead_helper.sorter(this.query, items, (x) => x);
if (sorted.length > 0 && !sorted.includes(this.query)) {
sorted.unshift(this.query);
@ -1132,16 +1132,16 @@ exports.initialize = function () {
items: exports.max_num_items,
dropup: true,
fixed: true,
highlighter: function (item) {
highlighter(item) {
return typeahead_helper.render_person_or_user_group(item);
},
matcher: function () {
matcher() {
return true;
},
sorter: function (items) {
sorter(items) {
return items;
},
updater: function (item) {
updater(item) {
if (user_groups.is_user_group(item)) {
for (const user_id of item.members) {
const user = people.get_by_user_id(user_id);

View File

@ -257,10 +257,10 @@ exports.analyze_selection = function (selection) {
}
return {
ranges: ranges,
start_id: start_id,
end_id: end_id,
skip_same_td_check: skip_same_td_check,
ranges,
start_id,
end_id,
skip_same_td_check,
};
};
@ -268,24 +268,24 @@ exports.paste_handler_converter = function (paste_html) {
const turndownService = new TurndownService();
turndownService.addRule("headings", {
filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
replacement: function (content) {
replacement(content) {
return content;
},
});
turndownService.addRule("emphasis", {
filter: ["em", "i"],
replacement: function (content) {
replacement(content) {
return "*" + content + "*";
},
});
// Checks for raw links without custom text or title.
turndownService.addRule("links", {
filter: function (node) {
filter(node) {
return (
node.nodeName === "A" && node.href === node.innerHTML && node.href === node.title
);
},
replacement: function (content) {
replacement(content) {
return content;
},
});

View File

@ -14,7 +14,7 @@ $(() => {
}
$.ajaxSetup({
beforeSend: function (xhr, settings) {
beforeSend(xhr, settings) {
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
// Only send the token to relative URLs i.e. locally.
xhr.setRequestHeader("X-CSRFToken", csrf_token);

View File

@ -63,8 +63,8 @@ export function check_duplicate_ids() {
});
return {
collisions: collisions,
total_collisions: total_collisions,
collisions,
total_collisions,
};
}
@ -104,11 +104,11 @@ export function IterationProfiler() {
}
IterationProfiler.prototype = {
iteration_start: function () {
iteration_start() {
this.section("_iteration_overhead");
},
iteration_stop: function () {
iteration_stop() {
const now = window.performance.now();
const diff = now - this.last_time;
if (diff > 1) {
@ -120,13 +120,13 @@ IterationProfiler.prototype = {
this.last_time = now;
},
section: function (label) {
section(label) {
const now = window.performance.now();
this.sections.set(label, (this.sections.get(label) || 0) + (now - this.last_time));
this.last_time = now;
},
done: function () {
done() {
this.section("_iteration_overhead");
for (const [prop, cost] of this.sections) {

View File

@ -3,7 +3,7 @@ const render_draft_table_body = require("../templates/draft_table_body.hbs");
function set_count(count) {
const draft_count = count.toString();
const text = i18n.t("Drafts (__draft_count__)", {draft_count: draft_count});
const text = i18n.t("Drafts (__draft_count__)", {draft_count});
$(".compose_drafts_button").text(text);
}
@ -233,12 +233,12 @@ exports.format_draft = function (draft) {
formatted = {
draft_id: draft.id,
is_stream: true,
stream: stream,
stream,
stream_color: draft_stream_color,
dark_background: stream_color.get_color_class(draft_stream_color),
topic: draft_topic,
raw_content: draft.content,
time_stamp: time_stamp,
time_stamp,
};
} else {
const emails = util.extract_pm_recipients(draft.private_message_recipient);
@ -256,9 +256,9 @@ exports.format_draft = function (draft) {
formatted = {
draft_id: draft.id,
is_stream: false,
recipients: recipients,
recipients,
raw_content: draft.content,
time_stamp: time_stamp,
time_stamp,
};
}
@ -333,7 +333,7 @@ exports.launch = function () {
function render_widgets(drafts) {
$("#drafts_table").empty();
const rendered = render_draft_table_body({
drafts: drafts,
drafts,
draft_lifetime: DRAFT_LIFETIME,
});
$("#drafts_table").append(rendered);
@ -508,7 +508,7 @@ exports.open_overlay = function () {
overlays.open_overlay({
name: "drafts",
overlay: $("#draft_overlay"),
on_close: function () {
on_close() {
hashchange.exit_overlay();
},
});

View File

@ -74,12 +74,12 @@ const DropdownListWidget = function (opts) {
list_render.create(dropdown_list_body, opts.data, {
name: `${opts.widget_name}_list`,
modifier: function (item) {
return render_dropdown_list({item: item});
modifier(item) {
return render_dropdown_list({item});
},
filter: {
element: search_input,
predicate: function (item, value) {
predicate(item, value) {
return item.name.toLowerCase().includes(value);
},
},

View File

@ -72,7 +72,7 @@ exports.build_display_recipient = function (message) {
// the requirement that we have an actual user object in
// `people.js` when sending messages.
return {
email: email,
email,
full_name: email,
unknown_local_echo_user: true,
};

View File

@ -39,8 +39,8 @@ const emoticon_translations = (() => {
const regex = new RegExp("(" + util.escape_regexp(emoticon) + ")", "g");
translations.push({
regex: regex,
replacement_text: replacement_text,
regex,
replacement_text,
});
}

View File

@ -225,7 +225,7 @@ function filter_emojis() {
const sorted_search_results = typeahead.sort_emojis(search_results, query);
const rendered_search_results = render_emoji_popover_search_results({
search_results: sorted_search_results,
message_id: message_id,
message_id,
});
$(".emoji-search-results").html(rendered_search_results);
ui.reset_scrollbar($(".emoji-search-results-container"));
@ -306,7 +306,7 @@ function update_emoji_showcase($focused_emoji) {
name: focused_emoji_name.replace(/_/g, " "),
};
const rendered_showcase = render_emoji_showcase({
emoji_dict: emoji_dict,
emoji_dict,
});
$(".emoji-showcase-container").html(rendered_showcase);
@ -596,9 +596,9 @@ exports.render_emoji_popover = function (elt, id) {
elt.popover({
// temporary patch for handling popover placement of `viewport_center`
placement: placement,
placement,
fix_positions: true,
template: template,
template,
title: "",
content: generate_emoji_picker_content(id),
html: true,

View File

@ -26,7 +26,7 @@ const meta = {
};
const animate = {
maybe_close: function () {
maybe_close() {
if (!meta.opened) {
return;
}
@ -38,7 +38,7 @@ const animate = {
setTimeout(animate.maybe_close, 100);
},
fadeOut: function () {
fadeOut() {
if (!meta.opened) {
return;
}
@ -49,7 +49,7 @@ const animate = {
meta.alert_hover_state = false;
}
},
fadeIn: function () {
fadeIn() {
if (meta.opened) {
return;
}

View File

@ -97,7 +97,7 @@ exports.process_fenced_code = function (content) {
const lines = [];
if (lang === "quote") {
return {
handle_line: function (line) {
handle_line(line) {
if (line === fence) {
this.done();
} else {
@ -105,7 +105,7 @@ exports.process_fenced_code = function (content) {
}
},
done: function () {
done() {
const text = wrap_quote(lines.join("\n"));
output_lines.push("");
output_lines.push(text);
@ -117,7 +117,7 @@ exports.process_fenced_code = function (content) {
if (lang === "math") {
return {
handle_line: function (line) {
handle_line(line) {
if (line === fence) {
this.done();
} else {
@ -125,7 +125,7 @@ exports.process_fenced_code = function (content) {
}
},
done: function () {
done() {
const text = wrap_tex(lines.join("\n"));
const placeholder = stash_func(text, true);
output_lines.push("");
@ -138,7 +138,7 @@ exports.process_fenced_code = function (content) {
if (lang === "spoiler") {
return {
handle_line: function (line) {
handle_line(line) {
if (line === fence) {
this.done();
} else {
@ -146,7 +146,7 @@ exports.process_fenced_code = function (content) {
}
},
done: function () {
done() {
const text = wrap_spoiler(header, lines.join("\n"), stash_func);
output_lines.push("");
output_lines.push(text);
@ -157,7 +157,7 @@ exports.process_fenced_code = function (content) {
}
return {
handle_line: function (line) {
handle_line(line) {
if (line === fence) {
this.done();
} else {
@ -165,7 +165,7 @@ exports.process_fenced_code = function (content) {
}
},
done: function () {
done() {
const text = exports.wrap_code(lines.join("\n"));
// insert safe HTML that is passed through the parsing
const placeholder = stash_func(text, true);
@ -180,10 +180,10 @@ exports.process_fenced_code = function (content) {
function default_hander() {
return {
handle_line: function (line) {
handle_line(line) {
consume_line(output, line);
},
done: function () {
done() {
handler_stack.pop();
},
};

View File

@ -243,9 +243,9 @@ Filter.canonicalize_term = function (opts) {
// We may want to consider allowing mixed-case operators at some point
return {
negated: negated,
operator: operator,
operand: operand,
negated,
operator,
operand,
};
};
@ -313,7 +313,7 @@ Filter.parse = function (str) {
search_term.push(token);
continue;
}
term = {negated: negated, operator: operator, operand: operand};
term = {negated, operator, operand};
operators.push(term);
}
}
@ -322,7 +322,7 @@ Filter.parse = function (str) {
if (search_term.length > 0) {
operator = "search";
operand = search_term.join(" ");
term = {operator: operator, operand: operand, negated: false};
term = {operator, operand, negated: false};
operators.push(term);
}
return operators;
@ -354,18 +354,18 @@ Filter.unparse = function (operators) {
};
Filter.prototype = {
predicate: function () {
predicate() {
if (this._predicate === undefined) {
this._predicate = this._build_predicate();
}
return this._predicate;
},
operators: function () {
operators() {
return this._operators;
},
public_operators: function () {
public_operators() {
const safe_to_return = this._operators.filter(
// Filter out the embedded narrow (if any).
(value) =>
@ -378,26 +378,26 @@ Filter.prototype = {
return safe_to_return;
},
operands: function (operator) {
operands(operator) {
return _.chain(this._operators)
.filter((elem) => !elem.negated && elem.operator === operator)
.map((elem) => elem.operand)
.value();
},
has_negated_operand: function (operator, operand) {
has_negated_operand(operator, operand) {
return this._operators.some(
(elem) => elem.negated && elem.operator === operator && elem.operand === operand,
);
},
has_operand: function (operator, operand) {
has_operand(operator, operand) {
return this._operators.some(
(elem) => !elem.negated && elem.operator === operator && elem.operand === operand,
);
},
has_operator: function (operator) {
has_operator(operator) {
return this._operators.some((elem) => {
if (elem.negated && !["search", "has"].includes(elem.operator)) {
return false;
@ -406,11 +406,11 @@ Filter.prototype = {
});
},
is_search: function () {
is_search() {
return this.has_operator("search");
},
calc_can_mark_messages_read: function () {
calc_can_mark_messages_read() {
const term_types = this.sorted_term_types();
if (_.isEqual(term_types, ["stream", "topic"])) {
@ -450,7 +450,7 @@ Filter.prototype = {
return false;
},
can_mark_messages_read: function () {
can_mark_messages_read() {
if (this._can_mark_messages_read === undefined) {
this._can_mark_messages_read = this.calc_can_mark_messages_read();
}
@ -467,7 +467,7 @@ Filter.prototype = {
// TODO: We likely will want to rewrite this to not piggy-back on
// can_mark_messages_read, since that might gain some more complex behavior
// with near: narrows.
is_common_narrow: function () {
is_common_narrow() {
// can_mark_messages_read tests the following filters:
// stream, stream + topic,
// is: private, pm-with:,
@ -496,7 +496,7 @@ Filter.prototype = {
//
// Note from tabbott: The slug-based approach may not be ideal; we
// may be able to do better another way.
generate_redirect_url: function () {
generate_redirect_url() {
const term_types = this.sorted_term_types();
// this comes first because it has 3 term_types but is not a "complex filter"
@ -551,7 +551,7 @@ Filter.prototype = {
return "#"; // redirect to All
},
get_icon: function () {
get_icon() {
// We have special icons for the simple narrows available for the via sidebars.
const term_types = this.sorted_term_types();
switch (term_types[0]) {
@ -580,7 +580,7 @@ Filter.prototype = {
}
},
get_title: function () {
get_title() {
// Nice explanatory titles for common views.
const term_types = this.sorted_term_types();
if (
@ -629,11 +629,11 @@ Filter.prototype = {
}
},
allow_use_first_unread_when_narrowing: function () {
allow_use_first_unread_when_narrowing() {
return this.can_mark_messages_read() || this.has_operator("is");
},
contains_only_private_messages: function () {
contains_only_private_messages() {
return (
(this.has_operator("is") && this.operands("is")[0] === "private") ||
this.has_operator("pm-with") ||
@ -641,11 +641,11 @@ Filter.prototype = {
);
},
includes_full_stream_history: function () {
includes_full_stream_history() {
return this.has_operator("stream") || this.has_operator("streams");
},
is_personal_filter: function () {
is_personal_filter() {
// Whether the filter filters for user-specific data in the
// UserMessage table, such as stars or mentions.
//
@ -654,7 +654,7 @@ Filter.prototype = {
return this.has_operand("is", "mentioned") || this.has_operand("is", "starred");
},
can_apply_locally: function (is_local_echo) {
can_apply_locally(is_local_echo) {
// Since there can be multiple operators, each block should
// just return false here.
@ -682,13 +682,13 @@ Filter.prototype = {
return true;
},
fix_operators: function (operators) {
fix_operators(operators) {
operators = this._canonicalize_operators(operators);
operators = this._fix_redundant_is_private(operators);
return operators;
},
_fix_redundant_is_private: function (terms) {
_fix_redundant_is_private(terms) {
const is_pm_with = (term) => Filter.term_type(term) === "pm-with";
if (!terms.some(is_pm_with)) {
@ -698,11 +698,11 @@ Filter.prototype = {
return terms.filter((term) => Filter.term_type(term) !== "is-private");
},
_canonicalize_operators: function (operators_mixed_case) {
_canonicalize_operators(operators_mixed_case) {
return operators_mixed_case.map((tuple) => Filter.canonicalize_term(tuple));
},
filter_with_new_params: function (params) {
filter_with_new_params(params) {
const terms = this._operators.map((term) => {
const new_term = {...term};
if (new_term.operator === params.operator && !new_term.negated) {
@ -713,25 +713,25 @@ Filter.prototype = {
return new Filter(terms);
},
has_topic: function (stream_name, topic) {
has_topic(stream_name, topic) {
return this.has_operand("stream", stream_name) && this.has_operand("topic", topic);
},
sorted_term_types: function () {
sorted_term_types() {
if (this._sorted_term_types === undefined) {
this._sorted_term_types = this._build_sorted_term_types();
}
return this._sorted_term_types;
},
_build_sorted_term_types: function () {
_build_sorted_term_types() {
const terms = this._operators;
const term_types = terms.map(Filter.term_type);
const sorted_terms = Filter.sorted_term_types(term_types);
return sorted_terms;
},
can_bucket_by: function (...wanted_term_types) {
can_bucket_by(...wanted_term_types) {
// Examples call:
// filter.can_bucket_by('stream', 'topic')
//
@ -748,7 +748,7 @@ Filter.prototype = {
return _.isEqual(term_types, wanted_term_types);
},
first_valid_id_from: function (msg_ids) {
first_valid_id_from(msg_ids) {
const predicate = this.predicate();
const first_id = msg_ids.find((msg_id) => {
@ -764,7 +764,7 @@ Filter.prototype = {
return first_id;
},
update_email: function (user_id, new_email) {
update_email(user_id, new_email) {
for (const term of this._operators) {
switch (term.operator) {
case "group-pm-with":
@ -781,7 +781,7 @@ Filter.prototype = {
},
// Build a filter function from a list of operators.
_build_predicate: function () {
_build_predicate() {
const operators = this._operators;
if (!this.can_apply_locally()) {

View File

@ -192,11 +192,11 @@ exports.relevant_recipient_bars = function () {
const title = elem.find(".message_label_clickable").last().attr("title");
const item = {
elem: elem,
title: title,
date_html: date_html,
date_text: date_text,
need_frb: need_frb,
elem,
title,
date_html,
date_text,
need_frb,
};
return item;

View File

@ -198,7 +198,7 @@ exports.parse_narrow = function (hash) {
}
const operand = exports.decode_operand(operator, raw_operand);
operators.push({negated: negated, operator: operator, operand: operand});
operators.push({negated, operator, operand});
}
return operators;
};

View File

@ -63,7 +63,7 @@ exports.post_hotspot_as_read = function (hotspot_name) {
channel.post({
url: "/json/users/me/hotspots",
data: {hotspot: JSON.stringify(hotspot_name)},
error: function (err) {
error(err) {
blueslip.error(err.responseText);
},
});

View File

@ -11,7 +11,7 @@ exports.set_up_toggler = function () {
{label: i18n.t("Message formatting"), key: "message-formatting"},
{label: i18n.t("Search operators"), key: "search-operators"},
],
callback: function (name, key) {
callback(name, key) {
$(".overlay-modal").hide();
$("#" + key).show();
ui.get_scroll_element($("#" + key).find(".modal-body")).trigger("focus");
@ -55,8 +55,8 @@ exports.show = function (target) {
if (!overlay.hasClass("show")) {
overlays.open_overlay({
name: "informationalOverlays",
overlay: overlay,
on_close: function () {
overlay,
on_close() {
hashchange.changehash("");
},
});

View File

@ -46,20 +46,20 @@ exports.create = function (opts) {
// of the `this` arg in the `Function.prototype.bind` use in the prototype.
const funcs = {
// return the value of the contenteditable input form.
value: function (input_elem) {
value(input_elem) {
return input_elem.innerText;
},
// clear the value of the input form.
clear: function (input_elem) {
clear(input_elem) {
input_elem.innerText = "";
},
clear_text: function () {
clear_text() {
store.$input.text("");
},
is_pending: function () {
is_pending() {
// This function returns true if we have text
// in out widget that hasn't been turned into
// pills. We use it to decide things like
@ -67,7 +67,7 @@ exports.create = function (opts) {
return store.$input.text().trim() !== "";
},
create_item: function (text) {
create_item(text) {
const existing_items = funcs.items();
const item = store.create_item_from_text(text, existing_items);
@ -85,7 +85,7 @@ exports.create = function (opts) {
// This is generally called by typeahead logic, where we have all
// the data we need (as opposed to, say, just a user-typed email).
appendValidatedData: function (item) {
appendValidatedData(item) {
const id = exports.random_id();
if (!item.display_value) {
@ -94,8 +94,8 @@ exports.create = function (opts) {
}
const payload = {
id: id,
item: item,
id,
item,
};
store.pills.push(payload);
@ -105,7 +105,7 @@ exports.create = function (opts) {
const opts = {
id: payload.id,
display_value: item.display_value,
has_image: has_image,
has_image,
};
if (has_image) {
@ -119,7 +119,7 @@ exports.create = function (opts) {
// this appends a pill to the end of the container but before the
// input block.
appendPill: function (value) {
appendPill(value) {
if (value.length === 0) {
return;
}
@ -142,7 +142,7 @@ exports.create = function (opts) {
// from the DOM, removes it from the array and returns it.
// this would generally be used for DOM-provoked actions, such as a user
// clicking on a pill to remove it.
removePill: function (id) {
removePill(id) {
let idx;
for (let x = 0; x < store.pills.length; x += 1) {
if (store.pills[x].id === id) {
@ -166,7 +166,7 @@ exports.create = function (opts) {
// If quiet is a truthy value, the event handler associated with the
// pill will not be evaluated. This is useful when using clear to reset
// the pills.
removeLastPill: function (quiet) {
removeLastPill(quiet) {
const pill = store.pills.pop();
if (pill) {
@ -177,7 +177,7 @@ exports.create = function (opts) {
}
},
removeAllPills: function (quiet) {
removeAllPills(quiet) {
while (store.pills.length > 0) {
this.removeLastPill(quiet);
}
@ -185,7 +185,7 @@ exports.create = function (opts) {
this.clear(store.$input[0]);
},
insertManyPills: function (pills) {
insertManyPills(pills) {
if (typeof pills === "string") {
pills = pills.split(/,/g).map((pill) => pill.trim());
}
@ -216,15 +216,15 @@ exports.create = function (opts) {
}
},
getByID: function (id) {
getByID(id) {
return store.pills.find((pill) => pill.id === id);
},
items: function () {
items() {
return store.pills.map((pill) => pill.item);
},
createPillonPaste: function () {
createPillonPaste() {
if (typeof store.createPillonPaste === "function") {
return store.createPillonPaste();
}
@ -379,15 +379,15 @@ exports.create = function (opts) {
getByID: funcs.getByID,
items: funcs.items,
onPillCreate: function (callback) {
onPillCreate(callback) {
store.onPillCreate = callback;
},
onPillRemove: function (callback) {
onPillRemove(callback) {
store.removePillFunction = callback;
},
createPillonPaste: function (callback) {
createPillonPaste(callback) {
store.createPillonPaste = callback;
},

View File

@ -24,7 +24,7 @@ function get_common_invitation_data() {
});
const data = {
csrfmiddlewaretoken: $('input[name="csrfmiddlewaretoken"]').attr("value"),
invite_as: invite_as,
invite_as,
stream_ids: JSON.stringify(stream_ids),
};
return data;
@ -50,9 +50,9 @@ function submit_invitation_form() {
channel.post({
url: "/json/invites",
data: data,
beforeSend: beforeSend,
success: function () {
data,
beforeSend,
success() {
ui_report.success(i18n.t("User(s) invited successfully."), invite_status);
invitee_emails_group.removeClass("warning");
invitee_emails.val("");
@ -62,7 +62,7 @@ function submit_invitation_form() {
$("#dev_env_msg").html(rendered_email_msg).addClass("alert-info").show();
}
},
error: function (xhr) {
error(xhr) {
const arr = JSON.parse(xhr.responseText);
if (arr.errors === undefined) {
// There was a fatal error, no partial processing occurred.
@ -83,9 +83,9 @@ function submit_invitation_form() {
const error_response = render_invitation_failed_error({
error_message: arr.msg,
error_list: error_list,
error_list,
is_admin: page_params.is_admin,
is_invitee_deactivated: is_invitee_deactivated,
is_invitee_deactivated,
});
ui_report.message(error_response, invite_status, "alert-warning");
invitee_emails_group.addClass("warning");
@ -95,7 +95,7 @@ function submit_invitation_form() {
}
}
},
complete: function () {
complete() {
$("#submit-invitation").button("reset");
},
});
@ -106,9 +106,9 @@ function generate_multiuse_invite() {
const data = get_common_invitation_data();
channel.post({
url: "/json/invites/multiuse",
data: data,
beforeSend: beforeSend,
success: function (data) {
data,
beforeSend,
success(data) {
ui_report.success(
i18n.t('Invitation link: <a href="__link__">__link__</a>', {
link: data.invite_link,
@ -116,10 +116,10 @@ function generate_multiuse_invite() {
invite_status,
);
},
error: function (xhr) {
error(xhr) {
ui_report.error("", xhr, invite_status);
},
complete: function () {
complete() {
$("#submit-invitation").button("reset");
},
});
@ -157,7 +157,7 @@ exports.launch = function () {
overlays.open_overlay({
name: "invite",
overlay: $("#invite-user"),
on_close: function () {
on_close() {
hashchange.exit_overlay();
},
});

View File

@ -30,7 +30,7 @@ window.onload = function () {
};
const funcs = {
setZoom: function (meta, zoom) {
setZoom(meta, zoom) {
// condition to handle zooming event by zoom hotkeys
if (zoom === "+") {
zoom = meta.zoom * 1.2;
@ -43,7 +43,7 @@ const funcs = {
// this is a function given a canvas that attaches all of the events
// required to pan and zoom.
attachEvents: function (canvas, context, meta) {
attachEvents(canvas, context, meta) {
let mousedown = false;
// wheelEvent.deltaMode is a value that describes what the unit is
@ -174,28 +174,28 @@ const funcs = {
// these are less reliable as preventDefault may prevent these events
// from propagating all the way to the <body>.
events.documentMouseup.push({
canvas: canvas,
meta: meta,
callback: function () {
canvas,
meta,
callback() {
mousedown = false;
},
});
events.windowResize.push({
canvas: canvas,
meta: meta,
callback: function () {
canvas,
meta,
callback() {
funcs.sizeCanvas(canvas, meta);
funcs.displayImage(canvas, context, meta);
},
});
},
imageRatio: function (image) {
imageRatio(image) {
return image.naturalWidth / image.naturalHeight;
},
displayImage: function (canvas, context, meta) {
displayImage(canvas, context, meta) {
meta.coords.x = Math.max(1 / (meta.zoom * 2), meta.coords.x);
meta.coords.x = Math.min(1 - 1 / (meta.zoom * 2), meta.coords.x);
@ -225,7 +225,7 @@ const funcs = {
// as we can, which means that we check if having the photo width = 100%
// means that the height is less than 100% of the parent height. If so,
// then we size the photo as w = 100%, h = 100% / 1.5.
sizeCanvas: function (canvas, meta) {
sizeCanvas(canvas, meta) {
if (canvas.parentNode === null) {
return;
}
@ -303,25 +303,25 @@ const LightboxCanvas = function (el) {
LightboxCanvas.prototype = {
// set the speed at which scrolling zooms in on a photo.
speed: function (speed) {
speed(speed) {
this.meta.speed = speed;
},
// set the max zoom of the `LightboxCanvas` canvas as a mult of the total width.
maxZoom: function (maxZoom) {
maxZoom(maxZoom) {
this.meta.maxZoom = maxZoom;
},
reverseScrollDirection: function () {
reverseScrollDirection() {
this.meta.direction = 1;
},
setZoom: function (zoom) {
setZoom(zoom) {
funcs.setZoom(this.meta, zoom);
funcs.displayImage(this.canvas, this.context, this.meta);
},
resize: function (callback) {
resize(callback) {
this.meta.onresize = callback;
},
};

View File

@ -42,7 +42,7 @@ const list_cursor = function (opts) {
}
const li = opts.list.find_li({
key: key,
key,
force_render: true,
});
@ -51,11 +51,11 @@ const list_cursor = function (opts) {
}
return {
highlight: function () {
highlight() {
li.addClass(opts.highlight_class);
self.adjust_scroll(li);
},
clear: function () {
clear() {
li.removeClass(opts.highlight_class);
},
};

Some files were not shown because too many files have changed in this diff Show More