2023-04-25 06:05:25 +02:00
|
|
|
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;
|
|
|
|
|
2023-05-25 10:34:37 +02:00
|
|
|
function set_compose_textarea_handlers(): void {
|
2023-11-02 19:29:54 +01:00
|
|
|
$("textarea#compose-textarea").on("blur", function () {
|
2023-04-25 06:05:25 +02:00
|
|
|
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");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-25 10:34:37 +02:00
|
|
|
export function restore_compose_cursor(): void {
|
2023-11-02 19:29:54 +01:00
|
|
|
$("textarea#compose-textarea").trigger("focus").caret(saved_compose_cursor);
|
2023-04-25 06:05:25 +02:00
|
|
|
}
|
|
|
|
|
2023-05-25 10:34:37 +02:00
|
|
|
export function initialize(): void {
|
2023-04-25 06:05:25 +02:00
|
|
|
set_compose_textarea_handlers();
|
|
|
|
}
|