2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
2021-02-28 01:25:45 +01:00
|
|
|
import _ from "lodash";
|
|
|
|
|
|
|
|
import generated_emoji_codes from "../generated/emoji/emoji_codes.json";
|
|
|
|
import generated_pygments_data from "../generated/pygments_data.json";
|
|
|
|
import * as fenced_code from "../shared/js/fenced_code";
|
2022-01-29 02:14:20 +01:00
|
|
|
import render_compose from "../templates/compose.hbs";
|
2021-02-28 01:25:45 +01:00
|
|
|
import render_edit_content_button from "../templates/edit_content_button.hbs";
|
2021-06-29 09:48:40 +02:00
|
|
|
import render_left_sidebar from "../templates/left_sidebar.hbs";
|
2021-11-12 17:28:56 +01:00
|
|
|
import render_message_feed_bottom_whitespace from "../templates/message_feed_bottom_whitespace.hbs";
|
2022-01-19 11:03:00 +01:00
|
|
|
import render_message_feed_errors from "../templates/message_feed_errors.hbs";
|
2021-06-30 16:20:43 +02:00
|
|
|
import render_navbar from "../templates/navbar.hbs";
|
2021-06-29 12:47:35 +02:00
|
|
|
import render_right_sidebar from "../templates/right_sidebar.hbs";
|
2021-02-28 01:25:45 +01:00
|
|
|
|
2021-06-14 13:19:27 +02:00
|
|
|
import * as about_zulip from "./about_zulip";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as activity from "./activity";
|
|
|
|
import * as alert_words from "./alert_words";
|
2021-03-16 23:38:59 +01:00
|
|
|
import * as blueslip from "./blueslip";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as bot_data from "./bot_data";
|
2022-05-03 23:22:41 +02:00
|
|
|
import * as channel from "./channel";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as click_handlers from "./click_handlers";
|
2022-01-29 02:14:20 +01:00
|
|
|
import * as common from "./common";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as compose from "./compose";
|
2021-04-15 02:59:34 +02:00
|
|
|
import * as compose_closed_ui from "./compose_closed_ui";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as compose_pm_pill from "./compose_pm_pill";
|
2021-02-28 21:33:26 +01:00
|
|
|
import * as composebox_typeahead from "./composebox_typeahead";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as condense from "./condense";
|
|
|
|
import * as copy_and_paste from "./copy_and_paste";
|
2022-02-10 16:06:55 +01:00
|
|
|
import * as dark_theme from "./dark_theme";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as drafts from "./drafts";
|
|
|
|
import * as echo from "./echo";
|
2022-03-25 14:47:51 +01:00
|
|
|
import * as emoji from "./emoji";
|
2021-02-28 01:26:16 +01:00
|
|
|
import * as emoji_picker from "./emoji_picker";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as emojisets from "./emojisets";
|
|
|
|
import * as gear_menu from "./gear_menu";
|
2021-03-31 05:43:13 +02:00
|
|
|
import * as giphy from "./giphy";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as hashchange from "./hashchange";
|
2022-10-23 06:58:08 +02:00
|
|
|
import * as hotkey from "./hotkey";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as hotspots from "./hotspots";
|
2021-06-18 02:16:48 +02:00
|
|
|
import * as i18n from "./i18n";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as invite from "./invite";
|
|
|
|
import * as lightbox from "./lightbox";
|
2021-05-19 06:18:23 +02:00
|
|
|
import * as linkifiers from "./linkifiers";
|
2022-02-10 16:06:55 +01:00
|
|
|
import {localstorage} from "./localstorage";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as markdown from "./markdown";
|
|
|
|
import * as markdown_config from "./markdown_config";
|
|
|
|
import * as message_edit from "./message_edit";
|
2021-06-14 12:27:26 +02:00
|
|
|
import * as message_edit_history from "./message_edit_history";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as message_fetch from "./message_fetch";
|
2021-03-30 02:21:21 +02:00
|
|
|
import * as message_lists from "./message_lists";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as message_scroll from "./message_scroll";
|
|
|
|
import * as message_view_header from "./message_view_header";
|
|
|
|
import * as message_viewport from "./message_viewport";
|
2021-06-27 21:38:26 +02:00
|
|
|
import * as muted_users from "./muted_users";
|
2021-05-17 10:01:02 +02:00
|
|
|
import * as navbar_alerts from "./navbar_alerts";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as navigate from "./navigate";
|
|
|
|
import * as notifications from "./notifications";
|
|
|
|
import * as overlays from "./overlays";
|
2021-03-25 22:35:45 +01:00
|
|
|
import {page_params} from "./page_params";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as people from "./people";
|
|
|
|
import * as pm_conversations from "./pm_conversations";
|
2022-09-13 13:15:57 +02:00
|
|
|
import * as pm_list from "./pm_list";
|
2021-06-17 19:05:34 +02:00
|
|
|
import * as popover_menus from "./popover_menus";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as presence from "./presence";
|
2021-06-27 13:25:55 +02:00
|
|
|
import * as realm_logo from "./realm_logo";
|
2021-04-13 08:43:03 +02:00
|
|
|
import * as realm_playground from "./realm_playground";
|
2021-08-09 08:24:50 +02:00
|
|
|
import * as realm_user_settings_defaults from "./realm_user_settings_defaults";
|
2021-06-10 14:18:46 +02:00
|
|
|
import * as recent_topics_util from "./recent_topics_util";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as reload from "./reload";
|
2022-02-15 10:58:53 +01:00
|
|
|
import * as rendered_markdown from "./rendered_markdown";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as resize from "./resize";
|
|
|
|
import * as rows from "./rows";
|
|
|
|
import * as scroll_bar from "./scroll_bar";
|
|
|
|
import * as search from "./search";
|
2021-02-28 01:28:13 +01:00
|
|
|
import * as search_pill_widget from "./search_pill_widget";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as sent_messages from "./sent_messages";
|
|
|
|
import * as server_events from "./server_events";
|
2021-06-11 12:22:04 +02:00
|
|
|
import * as settings from "./settings";
|
2021-06-29 12:47:35 +02:00
|
|
|
import * as settings_data from "./settings_data";
|
2021-06-15 17:23:38 +02:00
|
|
|
import * as settings_display from "./settings_display";
|
2021-09-20 15:56:32 +02:00
|
|
|
import * as settings_notifications from "./settings_notifications";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as settings_panel_menu from "./settings_panel_menu";
|
2021-09-20 13:38:38 +02:00
|
|
|
import * as settings_realm_user_settings_defaults from "./settings_realm_user_settings_defaults";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as settings_sections from "./settings_sections";
|
|
|
|
import * as settings_toggle from "./settings_toggle";
|
|
|
|
import * as spoilers from "./spoilers";
|
|
|
|
import * as starred_messages from "./starred_messages";
|
2021-03-22 18:29:15 +01:00
|
|
|
import * as stream_bar from "./stream_bar";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as stream_data from "./stream_data";
|
|
|
|
import * as stream_edit from "./stream_edit";
|
2022-02-21 18:42:35 +01:00
|
|
|
import * as stream_edit_subscribers from "./stream_edit_subscribers";
|
2021-02-28 21:31:02 +01:00
|
|
|
import * as stream_list from "./stream_list";
|
2021-07-09 15:51:31 +02:00
|
|
|
import * as stream_settings_ui from "./stream_settings_ui";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as timerender from "./timerender";
|
2021-02-25 02:33:15 +01:00
|
|
|
import * as tippyjs from "./tippyjs";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as topic_list from "./topic_list";
|
|
|
|
import * as topic_zoom from "./topic_zoom";
|
|
|
|
import * as tutorial from "./tutorial";
|
|
|
|
import * as typing from "./typing";
|
2021-02-28 21:33:10 +01:00
|
|
|
import * as ui from "./ui";
|
2021-02-28 21:30:38 +01:00
|
|
|
import * as unread from "./unread";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as unread_ui from "./unread_ui";
|
2022-08-21 17:18:00 +02:00
|
|
|
import * as user_group_edit from "./user_group_edit";
|
2022-08-31 19:21:19 +02:00
|
|
|
import * as user_group_edit_members from "./user_group_edit_members";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as user_groups from "./user_groups";
|
2022-08-21 17:59:39 +02:00
|
|
|
import * as user_group_settings_ui from "./user_groups_settings_ui";
|
2021-07-28 16:00:58 +02:00
|
|
|
import {initialize_user_settings, user_settings} from "./user_settings";
|
2021-02-28 01:25:45 +01:00
|
|
|
import * as user_status from "./user_status";
|
|
|
|
import * as user_status_ui from "./user_status_ui";
|
2022-08-14 15:33:13 +02:00
|
|
|
import * as user_topics from "./user_topics";
|
markdown: Add helper configuration for mobile.
This refactoring is the first step toward sharing
our markdown code with mobile. This focuses on
the Zulip layer, not the underlying third party `marked`
library.
In this commit we do a one-time initialization to
wire up the markdown functions, but after further
discussions with Greg, it might make more sense
to just pass in helpers on every use of markdown
(which is generally only once per sent message).
I'll address that in follow-up commits.
Even though it looks like a pretty invasive change,
you will note that we barely needed to modify the
node tests to make this pass. And we have pretty
decent test coverage here.
All of the places where we used to depend on
other Zulip modules now use helper functions that
any client (e.g. mobile) can configure themselves.
Or course, in the webapp, we configure these from
modules like people/stream_data/hash_util/etc.
Even in places where markdown used to deal directly with
data structures from other modules, we now use functions.
We may revisit this in a future commit, and we might
just pass data directly for certain things.
I decided to keep the helpers data structure completely flat,
so we don't have ugly nested names like
`helpers.emoji.get_emoji_codepoint`. Because of this,
some of the names aren't 1:1, which I think is fine.
For example, we map `user_groups.is_member_of` to
`is_member_of_user_group`.
It's likely that mobile already has different names
for their versions of these functions, so trying for
fake consistency would only help the webapp. In some
cases, I think the webapp functions have names that
could be improved, but we can clean that up in future
commits, and since the names aren't coupled to markdown
itself (i.e. only the config), we will be less
constrained.
It's worth noting that `marked` has an `options`
data structure that it uses for configuration, but
I didn't piggyback onto it, since the `marked`
options are more at the lexing/parsing layer vs.
the app-data layer stuff that our helpers mostly
help with.
Hopefully it's obvious why I just put helpers in
the top-level namespace for the module rather than
passing it around through multiple layers of the
parser.
There were a couple places in markdown where we
were doing awkward `hasOwnProperty` checks for
emoji-related stuff. Now we use the Python
principle of ask-forgiveness-not-permission and
just handle the getters returning falsy data. (It
should be `undefined`, but any falsy value is
unworkable in the places I changed, so I use
the simpler, less brittle form.)
We also break our direct dependency on
`emoji_codes.json` (with some help from the
prior commit).
In one place I rename streamName to stream_name,
fixing up an ancient naming violation that goes
way back to before this code was even extracted
away from echo.js. I didn't bother to split this
out into a separate commit, since 2 of the 4
lines would be immediately re-modified in the
subsequent commit.
Note that we still depend on `fenced_code`
via the global namespace, instead of simply
requiring it directly or injecting it. The
reason I'm postponing any action there is that
we'll have to change things once we move
markdown into a shared library. (The most
likely outcome is that we'll rename/move both files
at the same time and fix the namespace/require
details as part of that commit.)
Also the markdown code still relies on `_` being
available in the global namespace. We aren't
quite ready to share code with mobile yet, but the
underscore dependency should not be problematic,
since mobile already uses underscore to use the
webapp's shared typing_status module.
2020-02-13 13:54:11 +01:00
|
|
|
|
2017-03-18 20:29:55 +01:00
|
|
|
// This is where most of our initialization takes place.
|
|
|
|
// TODO: Organize it a lot better. In particular, move bigger
|
|
|
|
// functions to other modules.
|
|
|
|
|
|
|
|
/* We use 'visibility' rather than 'display' and jQuery's show() / hide(),
|
|
|
|
because we want to reserve space for the email address. This avoids
|
|
|
|
things jumping around slightly when the email address is shown. */
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
let $current_message_hover;
|
2017-03-18 20:29:55 +01:00
|
|
|
function message_unhover() {
|
2022-01-25 11:36:19 +01:00
|
|
|
if ($current_message_hover === undefined) {
|
2017-03-18 20:29:55 +01:00
|
|
|
return;
|
|
|
|
}
|
2022-08-18 00:30:47 +02:00
|
|
|
$current_message_hover.find("span.edit_content").empty();
|
2022-01-25 11:36:19 +01:00
|
|
|
$current_message_hover = undefined;
|
2017-03-18 20:29:55 +01:00
|
|
|
}
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
function message_hover($message_row) {
|
|
|
|
const id = rows.id($message_row);
|
|
|
|
if ($current_message_hover && rows.id($current_message_hover) === id) {
|
2017-03-18 20:29:55 +01:00
|
|
|
return;
|
|
|
|
}
|
2021-03-17 02:50:55 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
const message = message_lists.current.get(rows.id($message_row));
|
2017-03-18 20:29:55 +01:00
|
|
|
message_unhover();
|
2022-01-25 11:36:19 +01:00
|
|
|
$current_message_hover = $message_row;
|
2017-03-18 20:29:55 +01:00
|
|
|
|
2022-10-08 10:21:18 +02:00
|
|
|
if (!message.sent_by_me) {
|
2017-03-18 20:29:55 +01:00
|
|
|
// The actions and reactions icon hover logic is handled entirely by CSS
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-26 20:55:18 +02:00
|
|
|
// But the message edit hover icon is determined by whether the message is still editable
|
2022-12-12 15:37:14 +01:00
|
|
|
const is_content_editable = message_edit.is_content_editable(message);
|
2022-10-13 14:04:14 +02:00
|
|
|
|
|
|
|
const can_move_message = message_edit.can_move_message(message);
|
2020-07-25 14:35:56 +02:00
|
|
|
const args = {
|
2022-10-03 12:15:07 +02:00
|
|
|
is_content_editable: is_content_editable && !message.status_message,
|
|
|
|
can_move_message,
|
2020-07-25 14:35:56 +02:00
|
|
|
msg_id: id,
|
|
|
|
};
|
2022-01-25 11:36:19 +01:00
|
|
|
$message_row.find(".edit_content").html(render_edit_content_button(args));
|
2017-03-18 20:29:55 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 17:28:56 +01:00
|
|
|
function initialize_bottom_whitespace() {
|
|
|
|
$("#bottom_whitespace").html(render_message_feed_bottom_whitespace());
|
|
|
|
}
|
|
|
|
|
2021-06-29 09:48:40 +02:00
|
|
|
function initialize_left_sidebar() {
|
|
|
|
const rendered_sidebar = render_left_sidebar({
|
|
|
|
is_guest: page_params.is_guest,
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#left-sidebar-container").html(rendered_sidebar);
|
|
|
|
}
|
|
|
|
|
2021-06-29 12:47:35 +02:00
|
|
|
function initialize_right_sidebar() {
|
|
|
|
const rendered_sidebar = render_right_sidebar({
|
|
|
|
can_invite_others_to_realm: settings_data.user_can_invite_others_to_realm(),
|
2022-05-05 06:50:20 +02:00
|
|
|
realm_rendered_description: page_params.realm_rendered_description,
|
2021-06-29 12:47:35 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#right-sidebar-container").html(rendered_sidebar);
|
2022-02-15 10:58:53 +01:00
|
|
|
if (page_params.is_spectator) {
|
|
|
|
rendered_markdown.update_elements(
|
|
|
|
$(".right-sidebar .realm-description .rendered_markdown"),
|
|
|
|
);
|
|
|
|
}
|
2021-08-12 10:20:50 +02:00
|
|
|
|
|
|
|
$("#user_presences").on("mouseenter", ".user_sidebar_entry", (e) => {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $status_emoji = $(e.target).closest(".user_sidebar_entry").find("img.status_emoji");
|
|
|
|
if ($status_emoji.length) {
|
|
|
|
const animated_url = $status_emoji.data("animated-url");
|
2021-08-12 10:20:50 +02:00
|
|
|
if (animated_url) {
|
2022-01-25 11:36:19 +01:00
|
|
|
$status_emoji.attr("src", animated_url);
|
2021-08-12 10:20:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#user_presences").on("mouseleave", ".user_sidebar_entry", (e) => {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $status_emoji = $(e.target).closest(".user_sidebar_entry").find("img.status_emoji");
|
|
|
|
if ($status_emoji.length) {
|
|
|
|
const still_url = $status_emoji.data("still-url");
|
2021-08-12 10:20:50 +02:00
|
|
|
if (still_url) {
|
2022-01-25 11:36:19 +01:00
|
|
|
$status_emoji.attr("src", still_url);
|
2021-08-12 10:20:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-06-29 12:47:35 +02:00
|
|
|
}
|
|
|
|
|
2021-06-30 16:20:43 +02:00
|
|
|
function initialize_navbar() {
|
|
|
|
const rendered_navbar = render_navbar({
|
|
|
|
embedded: page_params.narrow_stream !== undefined,
|
|
|
|
search_pills_enabled: page_params.search_pills_enabled,
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#navbar-container").html(rendered_navbar);
|
|
|
|
}
|
|
|
|
|
2022-01-29 02:14:20 +01:00
|
|
|
function initialize_compose_box() {
|
|
|
|
$("#compose-container").append(
|
|
|
|
render_compose({
|
|
|
|
embedded: $("#compose").attr("data-embedded") === "",
|
|
|
|
file_upload_enabled: page_params.max_file_upload_size_mib > 0,
|
|
|
|
giphy_enabled: giphy.is_giphy_enabled(),
|
2022-02-21 10:51:58 +01:00
|
|
|
scroll_to_bottom_key_html: common.has_mac_keyboard()
|
2022-02-21 09:56:30 +01:00
|
|
|
? "Fn + <span class='tooltip_right_arrow'>→</span>"
|
|
|
|
: "End",
|
2021-08-16 17:10:43 +02:00
|
|
|
narrow_to_compose_recipients_key_html:
|
|
|
|
(common.has_mac_keyboard() ? "⌘" : "Ctrl") + " + .",
|
2022-07-15 03:01:24 +02:00
|
|
|
max_stream_name_length: page_params.max_stream_name_length,
|
|
|
|
max_topic_length: page_params.max_topic_length,
|
2022-01-29 02:14:20 +01:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
$(`.enter_sends_${user_settings.enter_sends}`).show();
|
|
|
|
common.adjust_mac_shortcuts(".enter_sends kbd");
|
|
|
|
}
|
|
|
|
|
2022-01-19 11:03:00 +01:00
|
|
|
function initialize_message_feed_errors() {
|
|
|
|
$("#message_feed_errors_container").html(render_message_feed_errors());
|
|
|
|
}
|
|
|
|
|
2021-02-28 01:25:45 +01:00
|
|
|
export function initialize_kitchen_sink_stuff() {
|
2018-05-15 22:03:14 +02:00
|
|
|
// TODO:
|
|
|
|
// This function is a historical dumping ground
|
|
|
|
// for lots of miscellaneous setup. Almost all of
|
|
|
|
// the code here can probably be moved to more
|
|
|
|
// specific-purpose modules like message_viewport.js.
|
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
const throttled_mousewheelhandler = _.throttle((e, delta) => {
|
2017-03-18 20:29:55 +01:00
|
|
|
// Most of the mouse wheel's work will be handled by the
|
|
|
|
// scroll handler, but when we're at the top or bottom of the
|
|
|
|
// page, the pointer may still need to move.
|
|
|
|
|
2020-12-23 01:18:26 +01:00
|
|
|
if (delta < 0 && message_viewport.at_top()) {
|
|
|
|
navigate.up();
|
2020-12-22 11:26:39 +01:00
|
|
|
} else if (delta > 0 && message_viewport.at_bottom()) {
|
|
|
|
navigate.down();
|
2017-03-18 20:29:55 +01:00
|
|
|
}
|
|
|
|
|
2018-08-04 08:33:00 +02:00
|
|
|
message_viewport.set_last_movement_direction(delta);
|
2018-05-16 20:42:42 +02:00
|
|
|
}, 50);
|
2017-03-18 20:29:55 +01:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
message_viewport.$message_pane.on("wheel", (e) => {
|
2019-11-02 00:06:25 +01:00
|
|
|
const delta = e.originalEvent.deltaY;
|
2022-04-04 06:09:04 +02:00
|
|
|
if (!overlays.is_overlay_or_modal_open() && !recent_topics_util.is_visible()) {
|
2017-03-18 20:29:55 +01:00
|
|
|
// In the message view, we use a throttled mousewheel handler.
|
|
|
|
throttled_mousewheelhandler(e, delta);
|
|
|
|
}
|
|
|
|
// If in a modal, we neither handle the event nor
|
|
|
|
// preventDefault, allowing the modal to scroll normally.
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$(window).on("resize", _.throttle(resize.handler, 50));
|
2017-03-18 20:29:55 +01:00
|
|
|
|
2017-05-27 15:40:54 +02:00
|
|
|
// Scrolling in overlays. input boxes, and other elements that
|
2017-03-18 20:29:55 +01:00
|
|
|
// explicitly scroll should not scroll the main view. Stop
|
|
|
|
// propagation in all cases. Also, ignore the event if the
|
|
|
|
// element is already at the top or bottom. Otherwise we get a
|
|
|
|
// new scroll event on the parent (?).
|
2020-07-15 01:29:15 +02:00
|
|
|
$(".modal-body, .scrolling_list, input, textarea").on("wheel", function (e) {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $self = ui.get_scroll_element($(this));
|
|
|
|
const scroll = $self.scrollTop();
|
2019-11-02 00:06:25 +01:00
|
|
|
const delta = e.originalEvent.deltaY;
|
2017-03-18 20:29:55 +01:00
|
|
|
|
|
|
|
// The -1 fudge factor is important here due to rounding errors. Better
|
|
|
|
// to err on the side of not scrolling.
|
2022-01-25 11:36:19 +01:00
|
|
|
const max_scroll = $self.prop("scrollHeight") - $self.innerHeight() - 1;
|
2017-03-18 20:29:55 +01:00
|
|
|
|
|
|
|
e.stopPropagation();
|
2020-07-15 00:34:28 +02:00
|
|
|
if ((delta < 0 && scroll <= 0) || (delta > 0 && scroll >= max_scroll)) {
|
2017-03-18 20:29:55 +01:00
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Ignore wheel events in the compose area which weren't already handled above.
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#compose").on("wheel", (e) => {
|
2017-03-18 20:29:55 +01:00
|
|
|
e.stopPropagation();
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
// A little hackish, because it doesn't seem to totally get us the
|
|
|
|
// exact right width for the floating_recipient_bar and compose
|
|
|
|
// box, but, close enough for now.
|
|
|
|
resize.handler();
|
|
|
|
|
2021-06-15 16:13:15 +02:00
|
|
|
if (page_params.is_spectator) {
|
|
|
|
$("body").addClass("spectator-view");
|
|
|
|
}
|
|
|
|
|
2021-07-28 16:00:58 +02:00
|
|
|
if (user_settings.high_contrast_mode) {
|
2017-07-07 18:15:10 +02:00
|
|
|
$("body").addClass("high-contrast");
|
|
|
|
}
|
|
|
|
|
2021-07-28 16:00:58 +02:00
|
|
|
if (!user_settings.dense_mode) {
|
2018-05-24 20:53:26 +02:00
|
|
|
$("body").addClass("less_dense_mode");
|
|
|
|
} else {
|
|
|
|
$("body").addClass("more_dense_mode");
|
|
|
|
}
|
|
|
|
|
2020-04-02 21:55:54 +02:00
|
|
|
$("#main_div").on("mouseover", ".message_table .message_row", function () {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $row = $(this).closest(".message_row");
|
|
|
|
message_hover($row);
|
2017-03-18 20:29:55 +01:00
|
|
|
});
|
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
$("#main_div").on("mouseleave", ".message_table .message_row", () => {
|
2017-03-18 20:29:55 +01:00
|
|
|
message_unhover();
|
|
|
|
});
|
|
|
|
|
2019-03-08 19:14:15 +01:00
|
|
|
$("#main_div").on("mouseover", ".sender_info_hover", function () {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $row = $(this).closest(".message_row");
|
|
|
|
$row.addClass("sender_name_hovered");
|
2017-03-18 20:29:55 +01:00
|
|
|
});
|
|
|
|
|
2019-03-08 19:14:15 +01:00
|
|
|
$("#main_div").on("mouseout", ".sender_info_hover", function () {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $row = $(this).closest(".message_row");
|
|
|
|
$row.removeClass("sender_name_hovered");
|
2017-03-18 20:29:55 +01:00
|
|
|
});
|
|
|
|
|
2022-03-24 13:56:34 +01:00
|
|
|
function handle_video_preview_mouseenter($elem) {
|
2019-05-02 18:58:39 +02:00
|
|
|
// Set image height and css vars for play button position, if not done already
|
2022-01-25 11:36:19 +01:00
|
|
|
const setPosition = !$elem.data("entered-before");
|
2019-05-02 18:58:39 +02:00
|
|
|
if (setPosition) {
|
2022-01-25 11:36:19 +01:00
|
|
|
const imgW = $elem.find("img")[0].width;
|
|
|
|
const imgH = $elem.find("img")[0].height;
|
2019-05-02 18:58:39 +02:00
|
|
|
// Ensure height doesn't change on mouse enter
|
2022-01-25 11:36:19 +01:00
|
|
|
$elem.css("height", `${imgH}px`);
|
2019-05-02 18:58:39 +02:00
|
|
|
// variables to set play button position
|
2020-04-26 17:19:26 +02:00
|
|
|
const marginLeft = (imgW - 30) / 2;
|
|
|
|
const marginTop = (imgH - 26) / 2;
|
2022-01-25 11:36:19 +01:00
|
|
|
$elem.css("--margin-left", `${marginLeft}px`).css("--margin-top", `${marginTop}px`);
|
|
|
|
$elem.data("entered-before", true);
|
2019-05-02 18:58:39 +02:00
|
|
|
}
|
2022-01-25 11:36:19 +01:00
|
|
|
$elem.addClass("fa fa-play");
|
2022-03-24 13:56:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$("#main_div").on("mouseenter", ".youtube-video a", function () {
|
2022-03-24 14:02:50 +01:00
|
|
|
handle_video_preview_mouseenter($(this));
|
2022-03-24 13:56:34 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#main_div").on("mouseleave", ".youtube-video a", function () {
|
|
|
|
$(this).removeClass("fa fa-play");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#main_div").on("mouseenter", ".embed-video a", function () {
|
|
|
|
handle_video_preview_mouseenter($(this));
|
2019-05-02 18:58:39 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#main_div").on("mouseleave", ".embed-video a", function () {
|
|
|
|
$(this).removeClass("fa fa-play");
|
|
|
|
});
|
|
|
|
|
2022-01-22 11:03:21 +01:00
|
|
|
$("#stream_message_recipient_stream").on("change", function () {
|
2021-03-22 18:29:15 +01:00
|
|
|
stream_bar.decorate(this.value, $("#stream-message .message_header_stream"), true);
|
2018-11-13 17:16:02 +01:00
|
|
|
});
|
2017-03-18 20:29:55 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$(window).on("blur", () => {
|
|
|
|
$(document.body).addClass("window_blurred");
|
2017-03-18 20:29:55 +01:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$(window).on("focus", () => {
|
|
|
|
$(document.body).removeClass("window_blurred");
|
2017-03-18 20:29:55 +01:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$(document).on("message_selected.zulip", (event) => {
|
2021-03-30 02:21:21 +02:00
|
|
|
if (message_lists.current !== event.msg_list) {
|
2017-03-18 20:29:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (event.id === -1) {
|
|
|
|
// If the message list is empty, don't do anything
|
|
|
|
return;
|
|
|
|
}
|
2022-01-25 11:36:19 +01:00
|
|
|
const $row = event.msg_list.get_row(event.id);
|
2020-07-15 01:29:15 +02:00
|
|
|
$(".selected_message").removeClass("selected_message");
|
2022-01-25 11:36:19 +01:00
|
|
|
$row.addClass("selected_message");
|
2017-03-18 20:29:55 +01:00
|
|
|
|
|
|
|
if (event.then_scroll) {
|
2022-01-25 11:36:19 +01:00
|
|
|
if ($row.length === 0) {
|
|
|
|
const $row_from_dom = message_lists.current.get_row(event.id);
|
2019-11-02 00:06:25 +01:00
|
|
|
const messages = event.msg_list.all_messages();
|
2017-03-18 20:29:55 +01:00
|
|
|
blueslip.debug("message_selected missing selected row", {
|
2020-09-13 18:29:24 +02:00
|
|
|
previously_selected_id: event.previously_selected_id,
|
2017-03-18 20:29:55 +01:00
|
|
|
selected_id: event.id,
|
|
|
|
selected_idx: event.msg_list.selected_idx(),
|
2018-05-25 14:37:06 +02:00
|
|
|
selected_idx_exact: messages.indexOf(event.msg_list.get(event.id)),
|
2017-03-18 20:29:55 +01:00
|
|
|
render_start: event.msg_list.view._render_win_start,
|
|
|
|
render_end: event.msg_list.view._render_win_end,
|
2018-05-25 14:37:06 +02:00
|
|
|
selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
|
2017-03-18 20:29:55 +01:00
|
|
|
msg_list_sorted: _.isEqual(
|
2020-07-02 01:39:34 +02:00
|
|
|
messages.map((message) => message.id),
|
2021-03-30 02:21:21 +02:00
|
|
|
message_lists.current
|
2020-02-26 09:27:17 +01:00
|
|
|
.all_messages()
|
|
|
|
.map((message) => message.id)
|
|
|
|
.sort(),
|
2017-03-18 20:29:55 +01:00
|
|
|
),
|
2022-01-25 11:36:19 +01:00
|
|
|
found_in_dom: $row_from_dom.length,
|
2017-03-18 20:29:55 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if (event.target_scroll_offset !== undefined) {
|
2021-03-30 02:21:21 +02:00
|
|
|
message_lists.current.view.set_message_offset(event.target_scroll_offset);
|
2017-03-18 20:29:55 +01:00
|
|
|
} else {
|
|
|
|
// Scroll to place the message within the current view;
|
|
|
|
// but if this is the initial placement of the pointer,
|
|
|
|
// just place it in the very center
|
2022-01-25 11:36:19 +01:00
|
|
|
message_viewport.recenter_view($row, {
|
2020-07-15 00:34:28 +02:00
|
|
|
from_scroll: event.from_scroll,
|
2020-09-13 18:29:24 +02:00
|
|
|
force_center: event.previously_selected_id === -1,
|
2020-07-15 00:34:28 +02:00
|
|
|
});
|
2017-03-18 20:29:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-04-26 05:14:33 +02:00
|
|
|
$("body").on("mouseover", ".message_edit_content", function () {
|
2017-01-17 20:51:30 +01:00
|
|
|
$(this).closest(".message_row").find(".copy_message").show();
|
|
|
|
});
|
|
|
|
|
2017-04-26 05:14:33 +02:00
|
|
|
$("body").on("mouseout", ".message_edit_content", function () {
|
2017-01-17 20:51:30 +01:00
|
|
|
$(this).closest(".message_row").find(".copy_message").hide();
|
|
|
|
});
|
|
|
|
|
2017-03-26 12:15:50 +02:00
|
|
|
$("body").on("mouseenter", ".copy_message", function () {
|
2017-01-17 20:51:30 +01:00
|
|
|
$(this).show();
|
|
|
|
});
|
|
|
|
|
2017-03-18 20:29:55 +01:00
|
|
|
if (!page_params.realm_allow_message_editing) {
|
|
|
|
$("#edit-message-hotkey-help").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (page_params.realm_presence_disabled) {
|
|
|
|
$("#user-list").hide();
|
|
|
|
}
|
2021-02-28 01:25:45 +01:00
|
|
|
}
|
2017-03-18 20:29:55 +01:00
|
|
|
|
2021-02-28 01:25:45 +01:00
|
|
|
export function initialize_everything() {
|
2020-02-25 12:16:26 +01:00
|
|
|
/*
|
|
|
|
When we initialize our various modules, a lot
|
|
|
|
of them will consume data from the server
|
|
|
|
in the form of `page_params`.
|
|
|
|
|
2021-03-25 22:35:45 +01:00
|
|
|
The `page_params` variable is basically a
|
|
|
|
massive dictionary with all the information
|
2020-02-25 12:16:26 +01:00
|
|
|
that the client needs to run the app. Here
|
|
|
|
are some examples of what it includes:
|
|
|
|
|
|
|
|
- all of the user's user-specific settings
|
|
|
|
- all realm-specific settings that are
|
|
|
|
pertinent to the user
|
|
|
|
- info about streams/subscribers on the realm
|
|
|
|
- realm settings
|
|
|
|
- info about all the other users
|
|
|
|
- some fairly dynamic data, like which of
|
|
|
|
the other users are "present"
|
|
|
|
|
|
|
|
Except for the actual Zulip messages, basically
|
|
|
|
any data that you see in the app soon after page
|
|
|
|
load comes from `page_params`.
|
|
|
|
|
|
|
|
## Mostly static data
|
|
|
|
|
|
|
|
Now, we mostly leave `page_params` intact through
|
|
|
|
the duration of the app. Most of the data in
|
|
|
|
`page_params` is fairly static in nature, and we
|
|
|
|
will simply update it for basic changes like
|
|
|
|
the following (meant as examples, not gospel):
|
|
|
|
|
|
|
|
- I changed my 24-hour time preference.
|
|
|
|
- The realm admin changed who can edit topics.
|
|
|
|
- The team's realm icon has changed.
|
2021-11-26 10:29:05 +01:00
|
|
|
- I switched from light theme to dark theme.
|
2020-02-25 12:16:26 +01:00
|
|
|
|
|
|
|
Especially for things that are settings-related,
|
|
|
|
we rarely abstract away the data from `page_params`.
|
|
|
|
As of this writing, over 90 modules refer directly
|
|
|
|
to `page_params` for some reason or another.
|
|
|
|
|
|
|
|
## Dynamic data
|
|
|
|
|
|
|
|
Some of the data in `page_params` is either
|
|
|
|
more highly dynamic than settings data, or
|
|
|
|
has more performance requirements than
|
|
|
|
simple settings data, or both. Examples
|
|
|
|
include:
|
|
|
|
|
|
|
|
- tracking all users (we want to have
|
|
|
|
multiple Maps to find users, for example)
|
|
|
|
- tracking all streams
|
|
|
|
- tracking presence data
|
|
|
|
- tracking user groups and bots
|
|
|
|
- tracking recent PMs
|
|
|
|
|
|
|
|
Using stream data as an example, we use a
|
|
|
|
module called `stream_data` to actually track
|
|
|
|
all the info about the streams that a user
|
|
|
|
can know about. We populate this module
|
|
|
|
with data from `page_params`, but thereafter
|
|
|
|
`stream_data.js` "owns" the stream data:
|
|
|
|
|
|
|
|
- other modules should ask `stream_data`
|
|
|
|
for stuff (and not go to `page_params`)
|
|
|
|
- when server events come in, they should
|
|
|
|
be processed by stream_data to update
|
|
|
|
its own data structures
|
|
|
|
|
|
|
|
To help enforce this paradigm, we do the
|
|
|
|
following:
|
|
|
|
|
|
|
|
- only pass `stream_data` what it needs
|
|
|
|
from `page_params`
|
|
|
|
- delete the reference to data owned by
|
|
|
|
`stream_data` in `page_params` itself
|
|
|
|
*/
|
|
|
|
|
|
|
|
function pop_fields(...fields) {
|
|
|
|
const result = {};
|
|
|
|
|
|
|
|
for (const field of fields) {
|
|
|
|
result[field] = page_params[field];
|
|
|
|
delete page_params[field];
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const alert_words_params = pop_fields("alert_words");
|
2020-02-26 23:53:46 +01:00
|
|
|
|
2020-07-24 01:21:48 +02:00
|
|
|
const emoji_params = pop_fields("realm_emoji");
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const bot_params = pop_fields("realm_bots");
|
2020-02-25 12:16:26 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const people_params = pop_fields("realm_users", "realm_non_active_users", "cross_realm_bots");
|
2020-02-25 12:16:26 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const pm_conversations_params = pop_fields("recent_private_conversations");
|
2020-02-26 23:36:38 +01:00
|
|
|
|
2021-05-20 20:01:51 +02:00
|
|
|
const presence_params = pop_fields("presences", "server_timestamp");
|
2020-02-25 12:16:26 +01:00
|
|
|
|
|
|
|
const stream_data_params = pop_fields(
|
2020-07-15 01:29:15 +02:00
|
|
|
"subscriptions",
|
|
|
|
"unsubscribed",
|
|
|
|
"never_subscribed",
|
|
|
|
"realm_default_streams",
|
2020-02-25 12:16:26 +01:00
|
|
|
);
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const user_groups_params = pop_fields("realm_user_groups");
|
2020-02-25 12:16:26 +01:00
|
|
|
|
2022-10-27 06:15:43 +02:00
|
|
|
const unread_params = pop_fields("unread_msgs");
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const user_status_params = pop_fields("user_status");
|
2021-06-18 02:16:48 +02:00
|
|
|
const i18n_params = pop_fields("language_list");
|
2021-07-28 16:00:58 +02:00
|
|
|
const user_settings_params = pop_fields("user_settings");
|
2021-08-09 08:24:50 +02:00
|
|
|
const realm_settings_defaults_params = pop_fields("realm_user_settings_defaults");
|
2020-02-25 12:16:26 +01:00
|
|
|
|
2022-02-10 16:06:55 +01:00
|
|
|
if (page_params.is_spectator) {
|
|
|
|
const ls = localstorage();
|
|
|
|
const preferred_theme = ls.get("spectator-theme-preference");
|
|
|
|
if (preferred_theme === "dark") {
|
|
|
|
dark_theme.enable();
|
|
|
|
} else if (preferred_theme === "light") {
|
|
|
|
dark_theme.disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-18 02:16:48 +02:00
|
|
|
i18n.initialize(i18n_params);
|
2021-02-25 02:33:15 +01:00
|
|
|
tippyjs.initialize();
|
2021-06-17 19:05:34 +02:00
|
|
|
popover_menus.initialize();
|
2021-06-29 09:48:40 +02:00
|
|
|
|
2021-07-28 16:00:58 +02:00
|
|
|
initialize_user_settings(user_settings_params);
|
2021-08-09 08:24:50 +02:00
|
|
|
realm_user_settings_defaults.initialize(realm_settings_defaults_params);
|
2021-07-19 09:31:41 +02:00
|
|
|
people.initialize(page_params.user_id, people_params);
|
2021-07-22 08:00:06 +02:00
|
|
|
|
|
|
|
let date_joined;
|
|
|
|
if (!page_params.is_spectator) {
|
|
|
|
const user = people.get_by_user_id(page_params.user_id);
|
|
|
|
date_joined = user.date_joined;
|
|
|
|
} else {
|
|
|
|
// Spectators don't have an account, so we just prevent their
|
|
|
|
// date_joined is now.
|
|
|
|
date_joined = new Date();
|
|
|
|
}
|
|
|
|
|
|
|
|
settings_data.initialize(date_joined);
|
2021-07-19 09:31:41 +02:00
|
|
|
|
2021-08-02 14:00:09 +02:00
|
|
|
// The emoji module must be initialized before the right sidebar
|
|
|
|
// module, so that we can display custom emoji in statuses.
|
|
|
|
emoji.initialize({
|
|
|
|
realm_emoji: emoji_params.realm_emoji,
|
|
|
|
emoji_codes: generated_emoji_codes,
|
|
|
|
});
|
|
|
|
|
2021-06-29 09:48:40 +02:00
|
|
|
// These components must be initialized early, because other
|
|
|
|
// modules' initialization has not been audited for whether they
|
|
|
|
// expect DOM elements to always exist (As that did before these
|
2022-06-27 22:35:01 +02:00
|
|
|
// modules were migrated from Django templates to Handlebars).
|
2021-11-12 17:28:56 +01:00
|
|
|
initialize_bottom_whitespace();
|
2021-06-29 09:48:40 +02:00
|
|
|
initialize_left_sidebar();
|
2021-06-29 12:47:35 +02:00
|
|
|
initialize_right_sidebar();
|
2022-01-29 02:14:20 +01:00
|
|
|
initialize_compose_box();
|
2021-06-11 12:22:04 +02:00
|
|
|
settings.initialize();
|
2021-06-30 16:20:43 +02:00
|
|
|
initialize_navbar();
|
2022-01-19 11:03:00 +01:00
|
|
|
initialize_message_feed_errors();
|
2021-06-29 09:48:40 +02:00
|
|
|
|
2022-11-15 18:37:38 +01:00
|
|
|
realm_logo.initialize();
|
2021-03-30 02:21:21 +02:00
|
|
|
message_lists.initialize();
|
2020-02-26 23:53:46 +01:00
|
|
|
alert_words.initialize(alert_words_params);
|
2020-02-21 00:20:39 +01:00
|
|
|
emojisets.initialize();
|
2018-06-19 20:16:00 +02:00
|
|
|
scroll_bar.initialize();
|
2018-05-15 22:03:14 +02:00
|
|
|
message_viewport.initialize();
|
2021-05-17 10:01:02 +02:00
|
|
|
navbar_alerts.initialize();
|
2021-04-15 02:59:34 +02:00
|
|
|
compose_closed_ui.initialize();
|
2021-02-28 01:25:45 +01:00
|
|
|
initialize_kitchen_sink_stuff();
|
2018-05-15 22:03:14 +02:00
|
|
|
echo.initialize();
|
|
|
|
stream_edit.initialize();
|
2022-08-21 17:18:00 +02:00
|
|
|
user_group_edit.initialize();
|
2022-02-21 18:42:35 +01:00
|
|
|
stream_edit_subscribers.initialize();
|
2020-02-25 12:16:26 +01:00
|
|
|
stream_data.initialize(stream_data_params);
|
2022-08-31 19:21:19 +02:00
|
|
|
user_group_edit_members.initialize();
|
2020-02-26 23:36:38 +01:00
|
|
|
pm_conversations.recent.initialize(pm_conversations_params);
|
2022-08-14 15:33:13 +02:00
|
|
|
user_topics.initialize();
|
2021-06-27 21:38:26 +02:00
|
|
|
muted_users.initialize();
|
2021-07-09 15:51:31 +02:00
|
|
|
stream_settings_ui.initialize();
|
2022-08-21 17:59:39 +02:00
|
|
|
user_group_settings_ui.initialize();
|
2019-03-22 17:26:51 +01:00
|
|
|
stream_list.initialize();
|
2018-05-15 22:03:14 +02:00
|
|
|
condense.initialize();
|
2020-04-04 22:14:34 +02:00
|
|
|
spoilers.initialize();
|
2018-05-15 22:03:14 +02:00
|
|
|
lightbox.initialize();
|
|
|
|
click_handlers.initialize();
|
|
|
|
copy_and_paste.initialize();
|
|
|
|
overlays.initialize();
|
|
|
|
invite.initialize();
|
|
|
|
timerender.initialize();
|
2020-07-08 23:44:01 +02:00
|
|
|
message_view_header.initialize();
|
2017-07-04 03:14:24 +02:00
|
|
|
server_events.initialize();
|
2020-02-25 12:16:26 +01:00
|
|
|
user_status.initialize(user_status_params);
|
2018-03-06 15:07:55 +01:00
|
|
|
compose_pm_pill.initialize();
|
2018-06-08 14:24:17 +02:00
|
|
|
search_pill_widget.initialize();
|
2018-03-06 15:07:55 +01:00
|
|
|
reload.initialize();
|
2020-02-25 12:16:26 +01:00
|
|
|
user_groups.initialize(user_groups_params);
|
2022-10-27 06:15:43 +02:00
|
|
|
unread.initialize(unread_params);
|
2020-02-25 12:16:26 +01:00
|
|
|
bot_data.initialize(bot_params); // Must happen after people.initialize()
|
2021-03-28 16:43:58 +02:00
|
|
|
message_fetch.initialize(server_events.home_view_loaded);
|
2018-03-08 20:18:36 +01:00
|
|
|
message_scroll.initialize();
|
2021-05-19 06:18:23 +02:00
|
|
|
markdown.initialize(markdown_config.get_helpers());
|
|
|
|
linkifiers.initialize(page_params.realm_linkifiers);
|
2021-04-24 10:00:28 +02:00
|
|
|
realm_playground.initialize(page_params.realm_playgrounds, generated_pygments_data);
|
2022-01-29 02:14:20 +01:00
|
|
|
compose.initialize();
|
2018-03-06 15:07:55 +01:00
|
|
|
composebox_typeahead.initialize(); // Must happen after compose.initialize()
|
2017-03-18 20:29:55 +01:00
|
|
|
search.initialize();
|
|
|
|
tutorial.initialize();
|
|
|
|
notifications.initialize();
|
|
|
|
gear_menu.initialize();
|
2021-03-31 05:43:13 +02:00
|
|
|
giphy.initialize();
|
2020-06-19 21:47:39 +02:00
|
|
|
presence.initialize(presence_params);
|
2021-06-15 17:23:38 +02:00
|
|
|
settings_display.initialize();
|
2021-09-20 15:56:32 +02:00
|
|
|
settings_notifications.initialize();
|
2021-09-20 13:38:38 +02:00
|
|
|
settings_realm_user_settings_defaults.initialize();
|
2018-06-03 17:29:11 +02:00
|
|
|
settings_panel_menu.initialize();
|
2017-05-09 06:58:49 +02:00
|
|
|
settings_sections.initialize();
|
2018-04-14 16:06:51 +02:00
|
|
|
settings_toggle.initialize();
|
2021-06-14 13:19:27 +02:00
|
|
|
about_zulip.initialize();
|
|
|
|
|
|
|
|
// All overlays must be initialized before hashchange.js
|
2017-03-18 20:29:55 +01:00
|
|
|
hashchange.initialize();
|
2021-11-29 10:08:07 +01:00
|
|
|
|
2017-03-18 20:29:55 +01:00
|
|
|
unread_ui.initialize();
|
|
|
|
activity.initialize();
|
2017-08-16 23:54:26 +02:00
|
|
|
emoji_picker.initialize();
|
2022-09-13 13:15:57 +02:00
|
|
|
pm_list.initialize();
|
2018-09-10 14:52:58 +02:00
|
|
|
topic_list.initialize();
|
|
|
|
topic_zoom.initialize();
|
2017-06-02 23:12:15 +02:00
|
|
|
drafts.initialize();
|
sending messages: Extract sent_messages.js.
This commit extract send_messages.js to clean up code related
to the following things:
* sending data to /json/report_send_time
* restarting the event loop if events don't arrive on time
The code related to /json/report changes the following ways:
* We track the state almost completely in the new
send_messages.js module, with other modules just
making one-line calls.
* We no longer send "displayed" times to the servers, since
we were kind of lying about them anyway.
* We now explicitly track the state of each single sent
message in its own object.
* We now look up data related to the messages by local_id,
instead of message_id. The problem with message_id was
that is was mutable. Now we use local_id, and we extend
the local_id concept to messages that don't get rendered
client side. We no longer need to react to the
'message_id_changed' event to change our hash key.
* The code used to live in many places:
* various big chunks were scattered among compose.js,
and those were all moved or reduced to one-line
calls into the new module
* echo.js continues to make basically one-line calls,
but it no longer calls compose.report_as_received(),
nor does it set the "start" time.
* message_util.js used to report received events, but
only when they finally got drawn in the home view;
this code is gone now
The code related to restarting the event loop if events don't arrive
changes as follows:
* The timer now gets set up from within
send_messages.message_state.report_server_ack,
where we can easily inspect the current state of the
possibly-still-in-flight message.
* The code to confirm that an event was received happens now
in server_events.js, rather than later, so that we don't
falsely blame the event loop for a downstream bug. (Plus
it's easier to just do it one place.)
This change removes a fair amount of code from our node tests. Some
of the removal is good stuff related to us completing killing off
unnecessary code. Other removals are more expediency-driven, and
we should make another sweep at ramping up our coverage on compose.js,
with possibly a little more mocking of the new `send_messages` code
layer, since it's now abstracted better.
There is also some minor cleanup to echo.resend_message() in this
commit.
See #5968 for a detailed breakdown of the changes.
2017-07-30 12:56:46 +02:00
|
|
|
sent_messages.initialize();
|
2017-09-26 00:03:27 +02:00
|
|
|
hotspots.initialize();
|
2017-08-08 02:16:35 +02:00
|
|
|
ui.initialize();
|
2018-03-16 12:39:46 +01:00
|
|
|
typing.initialize();
|
2018-08-17 03:46:32 +02:00
|
|
|
starred_messages.initialize();
|
2019-01-26 21:14:33 +01:00
|
|
|
user_status_ui.initialize();
|
2020-09-26 06:02:29 +02:00
|
|
|
fenced_code.initialize(generated_pygments_data);
|
2021-06-14 12:27:26 +02:00
|
|
|
message_edit_history.initialize();
|
2022-10-23 06:58:08 +02:00
|
|
|
hotkey.initialize();
|
2022-05-05 02:27:05 +02:00
|
|
|
|
|
|
|
$("#app-loading").addClass("loaded");
|
2021-02-28 01:25:45 +01:00
|
|
|
}
|
2018-12-26 19:56:19 +01:00
|
|
|
|
2022-05-03 23:22:41 +02:00
|
|
|
$(async () => {
|
|
|
|
if (page_params.is_spectator) {
|
|
|
|
const data = {
|
|
|
|
apply_markdown: true,
|
|
|
|
client_capabilities: JSON.stringify({
|
|
|
|
notification_settings_null: true,
|
|
|
|
bulk_message_deletion: true,
|
|
|
|
user_avatar_url_field_optional: true,
|
|
|
|
// Set this to true when stream typing notifications are implemented.
|
|
|
|
stream_typing_notifications: false,
|
|
|
|
user_settings_object: true,
|
|
|
|
}),
|
|
|
|
client_gravatar: false,
|
|
|
|
};
|
|
|
|
const {result, msg, ...state} = await new Promise((success, error) => {
|
|
|
|
channel.post({url: "/json/register", data, success, error});
|
|
|
|
});
|
|
|
|
Object.assign(page_params, state);
|
|
|
|
}
|
2021-01-31 13:57:52 +01:00
|
|
|
blueslip.measure_time("initialize_everything", () => {
|
2021-02-28 01:25:45 +01:00
|
|
|
initialize_everything();
|
2021-01-31 13:57:52 +01:00
|
|
|
});
|
2017-03-18 20:29:55 +01:00
|
|
|
});
|