mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
js: Skip redundant jQuery object reconstruction.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
33c790e2fc
commit
b0dba411d9
@@ -51,7 +51,7 @@ run_test("copy_data_attribute_value", ({override}) => {
|
|||||||
override(document, "execCommand", noop);
|
override(document, "execCommand", noop);
|
||||||
|
|
||||||
$("body").append = noop;
|
$("body").append = noop;
|
||||||
$($input).val = (arg) => {
|
$input.val = (arg) => {
|
||||||
assert.equal(arg, admin_emails_val);
|
assert.equal(arg, admin_emails_val);
|
||||||
return {
|
return {
|
||||||
trigger: noop,
|
trigger: noop,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ test("pan_and_zoom", ({override}) => {
|
|||||||
const $link = $.create("link-stub");
|
const $link = $.create("link-stub");
|
||||||
const $msg = $.create("msg-stub");
|
const $msg = $.create("msg-stub");
|
||||||
|
|
||||||
$($img).closest = () => [];
|
$img.closest = () => [];
|
||||||
|
|
||||||
$img.set_parent($link);
|
$img.set_parent($link);
|
||||||
$link.closest = () => $msg;
|
$link.closest = () => $msg;
|
||||||
@@ -71,9 +71,9 @@ test("youtube", ({override}) => {
|
|||||||
return 4321;
|
return 4321;
|
||||||
});
|
});
|
||||||
|
|
||||||
$($img).attr("src", href);
|
$img.attr("src", href);
|
||||||
|
|
||||||
$($img).closest = (sel) => {
|
$img.closest = (sel) => {
|
||||||
if (sel === ".youtube-video") {
|
if (sel === ".youtube-video") {
|
||||||
// We just need a nonempty array to
|
// We just need a nonempty array to
|
||||||
// set is_youtube_video to true.
|
// set is_youtube_video to true.
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ export function initialize() {
|
|||||||
$(".message_edit_form .send-status-close").on("click", function () {
|
$(".message_edit_form .send-status-close").on("click", function () {
|
||||||
const row_id = rows.id($(this).closest(".message_row"));
|
const row_id = rows.id($(this).closest(".message_row"));
|
||||||
const $send_status = $(`#message-edit-send-status-${CSS.escape(row_id)}`);
|
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) {
|
$("body").on("click", ".message_edit_form .compose_upload_file", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -493,8 +493,8 @@ export function initialize() {
|
|||||||
|
|
||||||
const $invite_row = $(event.target).parents(".compose_invite_user");
|
const $invite_row = $(event.target).parents(".compose_invite_user");
|
||||||
|
|
||||||
const user_id = Number.parseInt($($invite_row).data("user-id"), 10);
|
const user_id = Number.parseInt($invite_row.data("user-id"), 10);
|
||||||
const stream_id = Number.parseInt($($invite_row).data("stream-id"), 10);
|
const stream_id = Number.parseInt($invite_row.data("stream-id"), 10);
|
||||||
|
|
||||||
function success() {
|
function success() {
|
||||||
const $all_invites = $("#compose_invite_users");
|
const $all_invites = $("#compose_invite_users");
|
||||||
|
|||||||
@@ -538,7 +538,7 @@ export function quote_and_reply(opts) {
|
|||||||
const fence = fenced_code.get_unused_fence(message.raw_content);
|
const fence = fenced_code.get_unused_fence(message.raw_content);
|
||||||
content += `${fence}quote\n${message.raw_content}\n${fence}`;
|
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.replace_syntax(quoting_placeholder, content, $textarea);
|
||||||
compose_ui.autosize_textarea($("#compose-textarea"));
|
compose_ui.autosize_textarea($("#compose-textarea"));
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ export function warn_if_mentioning_unsubscribed_user(mentioned) {
|
|||||||
const $error_area = $("#compose_invite_users");
|
const $error_area = $("#compose_invite_users");
|
||||||
const $existing_invites_area = $("#compose_invite_users .compose_invite_user");
|
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),
|
Number.parseInt($(user_row).data("user-id"), 10),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ export function launch(conf) {
|
|||||||
conf.on_click(e);
|
conf.on_click(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
$($send_email_checkbox).on("change", () => {
|
$send_email_checkbox.on("change", () => {
|
||||||
if ($($send_email_checkbox).is(":checked")) {
|
if ($send_email_checkbox.is(":checked")) {
|
||||||
$email_field.show();
|
$email_field.show();
|
||||||
} else {
|
} else {
|
||||||
$email_field.hide();
|
$email_field.hide();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export function show_flatpickr(element, callback, default_timestamp, options = {
|
|||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
|
||||||
const $container = $($(instance.innerContainer).parent());
|
const $container = $(instance.innerContainer).parent();
|
||||||
|
|
||||||
$container.on("keydown", (e) => {
|
$container.on("keydown", (e) => {
|
||||||
if (is_numeric_key(e.key)) {
|
if (is_numeric_key(e.key)) {
|
||||||
|
|||||||
@@ -822,9 +822,10 @@ export class MessageListView {
|
|||||||
|
|
||||||
for (const message_container of targets) {
|
for (const message_container of targets) {
|
||||||
const $row = this.get_row(message_container.msg.id);
|
const $row = this.get_row(message_container.msg.id);
|
||||||
$($row)
|
$row.find("div.messagebox").toggleClass(
|
||||||
.find("div.messagebox")
|
"next_is_same_sender",
|
||||||
.toggleClass("next_is_same_sender", message_container.next_is_same_sender);
|
message_container.next_is_same_sender,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ function make_dimen_wrapper(dimen_name, dimen_func) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const height = make_dimen_wrapper("height", $($message_pane).height);
|
export const height = make_dimen_wrapper("height", $.fn.height);
|
||||||
export const width = make_dimen_wrapper("width", $($message_pane).width);
|
export const width = make_dimen_wrapper("width", $.fn.width);
|
||||||
|
|
||||||
// Includes both scroll and arrow events. Negative means scroll up,
|
// Includes both scroll and arrow events. Negative means scroll up,
|
||||||
// positive means scroll down.
|
// positive means scroll down.
|
||||||
|
|||||||
@@ -311,8 +311,8 @@ function integration_events() {
|
|||||||
for (const integration_element of $(".integration-lozenges").children()) {
|
for (const integration_element of $(".integration-lozenges").children()) {
|
||||||
const $integration = $(integration_element).find(".integration-lozenge");
|
const $integration = $(integration_element).find(".integration-lozenge");
|
||||||
|
|
||||||
if ($($integration).css("display") !== "none") {
|
if ($integration.css("display") !== "none") {
|
||||||
$($integration).closest("a")[0].click();
|
$integration.closest("a")[0].click();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -523,9 +523,9 @@ function topic_offset_to_visible_area(topic_row) {
|
|||||||
const thead_height = 30;
|
const thead_height = 30;
|
||||||
const under_closed_compose_region_height = 50;
|
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 =
|
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_top = $(topic_row).offset().top;
|
||||||
const topic_row_bottom = topic_row_top + $(topic_row).height();
|
const topic_row_bottom = topic_row_top + $(topic_row).height();
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function next_visible($message_row) {
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
const $recipient_row = get_message_recipient_row($message_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) {
|
if ($next_recipient_rows.length === 0) {
|
||||||
return $();
|
return $();
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ export function prev_visible($message_row) {
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
const $recipient_row = get_message_recipient_row($message_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) {
|
if ($prev_recipient_rows.length === 0) {
|
||||||
return $();
|
return $();
|
||||||
}
|
}
|
||||||
@@ -151,11 +151,11 @@ export function first_message_in_group(message_group) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function get_message_recipient_row($message_row) {
|
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) {
|
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) {
|
export function recipient_from_group(message_group) {
|
||||||
|
|||||||
@@ -643,7 +643,7 @@ export function set_up() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const $field = $(e.target).closest(".custom_user_field").expectOne();
|
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);
|
update_user_custom_profile_fields([field_id], channel.del);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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)}']`,
|
`#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) {
|
if (sub.is_muted) {
|
||||||
$($row).find(".unmute_stream").show();
|
$row.find(".unmute_stream").show();
|
||||||
} else {
|
} else {
|
||||||
$($row).find(".unmute_stream").hide();
|
$row.find(".unmute_stream").hide();
|
||||||
}
|
}
|
||||||
$($row).find("input").prop("disabled", sub.is_muted);
|
$row.find("input").prop("disabled", sub.is_muted);
|
||||||
$($row)
|
$row.find('[name="push_notifications"]').prop(
|
||||||
.find('[name="push_notifications"]')
|
"disabled",
|
||||||
.prop("disabled", !page_params.realm_push_notifications_enabled || sub.is_muted);
|
!page_params.realm_push_notifications_enabled || sub.is_muted,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initialize() {
|
export function initialize() {
|
||||||
|
|||||||
Reference in New Issue
Block a user