mirror of https://github.com/zulip/zulip.git
refactor: Create `compose_textarea` and extracted related handlers from `ui.js`.
Created the new `compose_textarea` and moved event handlers for `#compose_textarea` from `ui` to this new module so that it is now responsible for initializing event handlers for compose_textarea instead of `ui` module.
This commit is contained in:
parent
7e52509ee7
commit
e132a68193
|
@ -67,6 +67,7 @@ EXEMPT_FILES = make_set(
|
|||
"web/src/compose_fade.js",
|
||||
"web/src/compose_recipient.js",
|
||||
"web/src/compose_state.js",
|
||||
"web/src/compose_textarea.js",
|
||||
"web/src/compose_ui.js",
|
||||
"web/src/compose_validate.js",
|
||||
"web/src/composebox_typeahead.js",
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import $ from "jquery";
|
||||
|
||||
// Save the compose content cursor position and restore when we
|
||||
// shift-tab back in (see hotkey.js).
|
||||
let saved_compose_cursor = 0;
|
||||
|
||||
function set_compose_textarea_handlers() {
|
||||
$("#compose-textarea").on("blur", function () {
|
||||
saved_compose_cursor = $(this).caret();
|
||||
});
|
||||
|
||||
// on the end of the modified-message fade in, remove the fade-in-message class.
|
||||
const animationEnd = "webkitAnimationEnd oanimationend msAnimationEnd animationend";
|
||||
$("body").on(animationEnd, ".fade-in-message", function () {
|
||||
$(this).removeClass("fade-in-message");
|
||||
});
|
||||
}
|
||||
|
||||
export function restore_compose_cursor() {
|
||||
$("#compose-textarea").trigger("focus").caret(saved_compose_cursor);
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
set_compose_textarea_handlers();
|
||||
}
|
|
@ -8,6 +8,7 @@ import * as compose_actions from "./compose_actions";
|
|||
import * as compose_banner from "./compose_banner";
|
||||
import * as compose_recipient from "./compose_recipient";
|
||||
import * as compose_state from "./compose_state";
|
||||
import * as compose_textarea from "./compose_textarea";
|
||||
import * as condense from "./condense";
|
||||
import * as copy_and_paste from "./copy_and_paste";
|
||||
import * as deprecated_feature_notice from "./deprecated_feature_notice";
|
||||
|
@ -44,7 +45,6 @@ import * as stream_list from "./stream_list";
|
|||
import * as stream_popover from "./stream_popover";
|
||||
import * as stream_settings_ui from "./stream_settings_ui";
|
||||
import * as topic_zoom from "./topic_zoom";
|
||||
import * as ui from "./ui";
|
||||
import * as unread_ops from "./unread_ops";
|
||||
import {user_settings} from "./user_settings";
|
||||
|
||||
|
@ -557,7 +557,7 @@ export function process_shift_tab_key() {
|
|||
if ($("#compose-send-button").is(":focus")) {
|
||||
// Shift-Tab: go back to content textarea and restore
|
||||
// cursor position.
|
||||
ui.restore_compose_cursor();
|
||||
compose_textarea.restore_compose_cursor();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,27 +43,3 @@ export function reset_scrollbar($element) {
|
|||
element.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the compose content cursor position and restore when we
|
||||
// shift-tab back in (see hotkey.js).
|
||||
let saved_compose_cursor = 0;
|
||||
|
||||
export function set_compose_textarea_handlers() {
|
||||
$("#compose-textarea").on("blur", function () {
|
||||
saved_compose_cursor = $(this).caret();
|
||||
});
|
||||
|
||||
// on the end of the modified-message fade in, remove the fade-in-message class.
|
||||
const animationEnd = "webkitAnimationEnd oanimationend msAnimationEnd animationend";
|
||||
$("body").on(animationEnd, ".fade-in-message", function () {
|
||||
$(this).removeClass("fade-in-message");
|
||||
});
|
||||
}
|
||||
|
||||
export function restore_compose_cursor() {
|
||||
$("#compose-textarea").trigger("focus").caret(saved_compose_cursor);
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
set_compose_textarea_handlers();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import * as compose from "./compose";
|
|||
import * as compose_closed_ui from "./compose_closed_ui";
|
||||
import * as compose_pm_pill from "./compose_pm_pill";
|
||||
import * as compose_recipient from "./compose_recipient";
|
||||
import * as compose_textarea from "./compose_textarea";
|
||||
import * as composebox_typeahead from "./composebox_typeahead";
|
||||
import * as condense from "./condense";
|
||||
import * as copy_and_paste from "./copy_and_paste";
|
||||
|
@ -668,6 +669,7 @@ export function initialize_everything() {
|
|||
realm_playground.initialize(page_params.realm_playgrounds, generated_pygments_data);
|
||||
compose.initialize();
|
||||
composebox_typeahead.initialize(); // Must happen after compose.initialize()
|
||||
compose_textarea.initialize();
|
||||
search.initialize();
|
||||
tutorial.initialize();
|
||||
notifications.initialize();
|
||||
|
@ -694,7 +696,6 @@ export function initialize_everything() {
|
|||
drafts.initialize();
|
||||
sent_messages.initialize();
|
||||
hotspots.initialize();
|
||||
ui.initialize();
|
||||
typing.initialize();
|
||||
starred_messages.initialize();
|
||||
user_status_ui.initialize();
|
||||
|
|
Loading…
Reference in New Issue