js: Replace deprecated $.trim method.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2020-07-21 18:39:41 -07:00 committed by Tim Abbott
parent 611f2a4321
commit a2a5871088
8 changed files with 10 additions and 14 deletions

View File

@ -1689,10 +1689,6 @@ run_test("create_message_object", () => {
return "stream";
};
global.$.trim = function (s) {
return s;
};
let message = compose.create_message_object();
assert.equal(message.to, sub.stream_id);
assert.equal(message.topic, "lunch");

View File

@ -30,7 +30,7 @@ function update_alert_word_status(status_text, is_error) {
}
function add_alert_word(alert_word) {
alert_word = $.trim(alert_word);
alert_word = alert_word.trim();
if (alert_word === "") {
update_alert_word_status(i18n.t("Alert word can't be empty!"), true);
return;

View File

@ -125,7 +125,7 @@ $(() => {
// check if it is the "focusout" or if it is a keydown, then check if
// the keycode was the one for "enter" (13).
if (e.type === "focusout" || e.which === 13) {
$(this).val($.trim($(this).val()));
$(this).val($(this).val().trim());
}
});

View File

@ -171,7 +171,7 @@ exports.update_elements = (content) => {
content.find("div.spoiler-header").each(function () {
// If a spoiler block has no header content, it should have a default header.
// We do this client side to allow for i18n by the client.
if ($.trim($(this).html()).length === 0) {
if ($(this).html().trim().length === 0) {
$(this).append(`<p>${i18n.t("Spoiler")}</p>`);
}

View File

@ -13,7 +13,7 @@ function update_table_stream_color(table, stream_name, color) {
for (const label of stream_labels) {
const $label = $(label);
if ($.trim($label.text()) === stream_name) {
if ($label.text().trim() === stream_name) {
const messages = $label.closest(".recipient_row").children(".message_row");
messages
.children(".messagebox")

View File

@ -139,8 +139,8 @@ function get_principals() {
function create_stream() {
const data = {};
const stream_name = $.trim($("#create_stream_name").val());
const description = $.trim($("#create_stream_description").val());
const stream_name = $("#create_stream_name").val().trim();
const description = $("#create_stream_description").val().trim();
created_stream = stream_name;
// Even though we already check to make sure that while typing the user cannot enter
@ -406,7 +406,7 @@ exports.set_up_handlers = function () {
e.preventDefault();
clear_error_display();
const stream_name = $.trim($("#create_stream_name").val());
const stream_name = $("#create_stream_name").val().trim();
const name_ok = stream_name_error.validate_for_submit(stream_name);
if (!name_ok) {
@ -444,7 +444,7 @@ exports.set_up_handlers = function () {
});
container.on("input", "#create_stream_name", () => {
const stream_name = $.trim($("#create_stream_name").val());
const stream_name = $("#create_stream_name").val().trim();
// This is an inexpensive check.
stream_name_error.pre_validate(stream_name);

View File

@ -533,7 +533,7 @@ exports.change_stream_name = function (e) {
const sub_settings = $(e.target).closest(".subscription_settings");
const stream_id = get_stream_id(e.target);
const new_name_box = sub_settings.find(".stream-name-editable");
const new_name = $.trim(new_name_box.text());
const new_name = new_name_box.text().trim();
$(".stream_change_property_info").hide();
channel.patch({

View File

@ -884,7 +884,7 @@ exports.do_open_create_stream = function () {
// Only call this directly for hash changes.
// Prefer open_create_stream().
const stream = $.trim($("#search_stream_name").val());
const stream = $("#search_stream_name").val().trim();
if (!should_list_all_streams()) {
// Realms that don't allow listing streams should simply be subscribed to.