Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

js: Skip redundant jQuery object reconstruction.

Anders Kaseorgb0dba411d9fc
diff --git a/frontend_tests/node_tests/common.js b/frontend_tests/node_tests/common.js
index 33a379d3246..02ba05a7f7c 100644
--- a/frontend_tests/node_tests/common.js
+++ b/frontend_tests/node_tests/common.js
@@ -51,7 +51,7 @@ run_test("copy_data_attribute_value", ({override}) => {
override(document, "execCommand", noop);
$("body").append = noop;
- $($input).val = (arg) => {
+ $input.val = (arg) => {
assert.equal(arg, admin_emails_val);
return {
trigger: noop,
diff --git a/frontend_tests/node_tests/lightbox.js b/frontend_tests/node_tests/lightbox.js
index fb7eefa9369..a11babc215c 100644
--- a/frontend_tests/node_tests/lightbox.js
+++ b/frontend_tests/node_tests/lightbox.js
@@ -34,7 +34,7 @@ test("pan_and_zoom", ({override}) => {
const $link = $.create("link-stub");
const $msg = $.create("msg-stub");
- $($img).closest = () => [];
+ $img.closest = () => [];
$img.set_parent($link);
$link.closest = () => $msg;
@@ -71,9 +71,9 @@ test("youtube", ({override}) => {
return 4321;
});
- $($img).attr("src", href);
+ $img.attr("src", href);
- $($img).closest = (sel) => {
+ $img.closest = (sel) => {
if (sel === ".youtube-video") {
// We just need a nonempty array to
// set is_youtube_video to true.
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index e3c06b14be0..1ab0c0b1120 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -324,7 +324,7 @@ export function initialize() {
$(".message_edit_form .send-status-close").on("click", function () {
const row_id = rows.id($(this).closest(".message_row"));
const $send_status = $(`#message-edit-send-status-${CSS.escape(row_id)}`);
- $($send_status).stop(true).fadeOut(200);
+ $send_status.stop(true).fadeOut(200);
});
$("body").on("click", ".message_edit_form .compose_upload_file", function (e) {
e.preventDefault();
diff --git a/static/js/compose.js b/static/js/compose.js
index 5c1c10bfa47..623f60a7b70 100644
--- a/static/js/compose.js
+++ b/static/js/compose.js
@@ -493,8 +493,8 @@ export function initialize() {
const $invite_row = $(event.target).parents(".compose_invite_user");
- const user_id = Number.parseInt($($invite_row).data("user-id"), 10);
- const stream_id = Number.parseInt($($invite_row).data("stream-id"), 10);
+ const user_id = Number.parseInt($invite_row.data("user-id"), 10);
+ const stream_id = Number.parseInt($invite_row.data("stream-id"), 10);
function success() {
const $all_invites = $("#compose_invite_users");
diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js
index 378b7bf4a53..74761cb1bf9 100644
--- a/static/js/compose_actions.js
+++ b/static/js/compose_actions.js
@@ -538,7 +538,7 @@ export function quote_and_reply(opts) {
const fence = fenced_code.get_unused_fence(message.raw_content);
content += `${fence}quote\n${message.raw_content}\n${fence}`;
- const placeholder_offset = $($textarea).val().indexOf(quoting_placeholder);
+ const placeholder_offset = $textarea.val().indexOf(quoting_placeholder);
compose_ui.replace_syntax(quoting_placeholder, content, $textarea);
compose_ui.autosize_textarea($("#compose-textarea"));
diff --git a/static/js/compose_validate.js b/static/js/compose_validate.js
index 887d7615592..4c2da5b7e57 100644
--- a/static/js/compose_validate.js
+++ b/static/js/compose_validate.js
@@ -143,7 +143,7 @@ export function warn_if_mentioning_unsubscribed_user(mentioned) {
const $error_area = $("#compose_invite_users");
const $existing_invites_area = $("#compose_invite_users .compose_invite_user");
- const existing_invites = Array.from($($existing_invites_area), (user_row) =>
+ const existing_invites = Array.from($existing_invites_area, (user_row) =>
Number.parseInt($(user_row).data("user-id"), 10),
);
diff --git a/static/js/dialog_widget.js b/static/js/dialog_widget.js
index c7a34dc7abe..a9277e8bfb9 100644
--- a/static/js/dialog_widget.js
+++ b/static/js/dialog_widget.js
@@ -138,8 +138,8 @@ export function launch(conf) {
conf.on_click(e);
});
- $($send_email_checkbox).on("change", () => {
- if ($($send_email_checkbox).is(":checked")) {
+ $send_email_checkbox.on("change", () => {
+ if ($send_email_checkbox.is(":checked")) {
$email_field.show();
} else {
$email_field.hide();
diff --git a/static/js/flatpickr.js b/static/js/flatpickr.js
index 8dee13bbf58..f8361ec36d0 100644
--- a/static/js/flatpickr.js
+++ b/static/js/flatpickr.js
@@ -61,7 +61,7 @@ export function show_flatpickr(element, callback, default_timestamp, options = {
...options,
});
- const $container = $($(instance.innerContainer).parent());
+ const $container = $(instance.innerContainer).parent();
$container.on("keydown", (e) => {
if (is_numeric_key(e.key)) {
diff --git a/static/js/message_list_view.js b/static/js/message_list_view.js
index b5ffd59ab6e..238c2bbc0f3 100644
--- a/static/js/message_list_view.js
+++ b/static/js/message_list_view.js
@@ -822,9 +822,10 @@ export class MessageListView {
for (const message_container of targets) {
const $row = this.get_row(message_container.msg.id);
- $($row)
- .find("div.messagebox")
- .toggleClass("next_is_same_sender", message_container.next_is_same_sender);
+ $row.find("div.messagebox").toggleClass(
+ "next_is_same_sender",
+ message_container.next_is_same_sender,
+ );
}
}
diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js
index d0366399a45..aad68bb74fd 100644
--- a/static/js/message_viewport.js
+++ b/static/js/message_viewport.js
@@ -30,8 +30,8 @@ function make_dimen_wrapper(dimen_name, dimen_func) {
};
}
-export const height = make_dimen_wrapper("height", $($message_pane).height);
-export const width = make_dimen_wrapper("width", $($message_pane).width);
+export const height = make_dimen_wrapper("height", $.fn.height);
+export const width = make_dimen_wrapper("width", $.fn.width);
// Includes both scroll and arrow events. Negative means scroll up,
// positive means scroll down.
diff --git a/static/js/portico/integrations.js b/static/js/portico/integrations.js
index 21a888fc7d8..1f5ccb0b445 100644
--- a/static/js/portico/integrations.js
+++ b/static/js/portico/integrations.js
@@ -311,8 +311,8 @@ function integration_events() {
for (const integration_element of $(".integration-lozenges").children()) {
const $integration = $(integration_element).find(".integration-lozenge");
- if ($($integration).css("display") !== "none") {
- $($integration).closest("a")[0].click();
+ if ($integration.css("display") !== "none") {
+ $integration.closest("a")[0].click();
break;
}
}
diff --git a/static/js/recent_topics_ui.js b/static/js/recent_topics_ui.js
index 919273d1ae9..53c4794fd03 100644
--- a/static/js/recent_topics_ui.js
+++ b/static/js/recent_topics_ui.js
@@ -523,9 +523,9 @@ function topic_offset_to_visible_area(topic_row) {
const thead_height = 30;
const under_closed_compose_region_height = 50;
- const scroll_container_top = $($scroll_container).offset().top + thead_height;
+ const scroll_container_top = $scroll_container.offset().top + thead_height;
const scroll_container_bottom =
- scroll_container_top + $($scroll_container).height() - under_closed_compose_region_height;
+ scroll_container_top + $scroll_container.height() - under_closed_compose_region_height;
const topic_row_top = $(topic_row).offset().top;
const topic_row_bottom = topic_row_top + $(topic_row).height();
diff --git a/static/js/rows.js b/static/js/rows.js
index 49049b5547c..15f62960a73 100644
--- a/static/js/rows.js
+++ b/static/js/rows.js
@@ -15,7 +15,7 @@ export function next_visible($message_row) {
return $row;
}
const $recipient_row = get_message_recipient_row($message_row);
- const $next_recipient_rows = $($recipient_row).nextAll(".recipient_row");
+ const $next_recipient_rows = $recipient_row.nextAll(".recipient_row");
if ($next_recipient_rows.length === 0) {
return $();
}
@@ -31,7 +31,7 @@ export function prev_visible($message_row) {
return $row;
}
const $recipient_row = get_message_recipient_row($message_row);
- const $prev_recipient_rows = $($recipient_row).prevAll(".recipient_row");
+ const $prev_recipient_rows = $recipient_row.prevAll(".recipient_row");
if ($prev_recipient_rows.length === 0) {
return $();
}
@@ -151,11 +151,11 @@ export function first_message_in_group(message_group) {
}
export function get_message_recipient_row($message_row) {
- return $($message_row).parent(".recipient_row").expectOne();
+ return $message_row.parent(".recipient_row").expectOne();
}
export function get_message_recipient_header($message_row) {
- return $($message_row).parent(".recipient_row").find(".message_header").expectOne();
+ return $message_row.parent(".recipient_row").find(".message_header").expectOne();
}
export function recipient_from_group(message_group) {
diff --git a/static/js/settings_account.js b/static/js/settings_account.js
index 9e9cc04501b..2a4d20b57d8 100644
--- a/static/js/settings_account.js
+++ b/static/js/settings_account.js
@@ -643,7 +643,7 @@ export function set_up() {
e.preventDefault();
e.stopPropagation();
const $field = $(e.target).closest(".custom_user_field").expectOne();
- const field_id = Number.parseInt($($field).attr("data-field-id"), 10);
+ const field_id = Number.parseInt($field.attr("data-field-id"), 10);
update_user_custom_profile_fields([field_id], channel.del);
});
diff --git a/static/js/settings_notifications.js b/static/js/settings_notifications.js
index 67696cba649..084386b66c0 100644
--- a/static/js/settings_notifications.js
+++ b/static/js/settings_notifications.js
@@ -252,16 +252,17 @@ export function update_muted_stream_state(sub) {
`#stream-specific-notify-table .stream-row[data-stream-id='${CSS.escape(sub.stream_id)}']`,
);
- $($row).toggleClass("control-label-disabled", sub.is_muted);
+ $row.toggleClass("control-label-disabled", sub.is_muted);
if (sub.is_muted) {
- $($row).find(".unmute_stream").show();
+ $row.find(".unmute_stream").show();
} else {
- $($row).find(".unmute_stream").hide();
+ $row.find(".unmute_stream").hide();
}
- $($row).find("input").prop("disabled", sub.is_muted);
- $($row)
- .find('[name="push_notifications"]')
- .prop("disabled", !page_params.realm_push_notifications_enabled || sub.is_muted);
+ $row.find("input").prop("disabled", sub.is_muted);
+ $row.find('[name="push_notifications"]').prop(
+ "disabled",
+ !page_params.realm_push_notifications_enabled || sub.is_muted,
+ );
}
export function initialize() {