copied_tooltip: Convert module to TypeScript.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-02 15:06:31 -07:00 committed by Anders Kaseorg
parent 6e0f9df188
commit 919381e5e7
2 changed files with 7 additions and 3 deletions

View File

@ -74,7 +74,7 @@ EXEMPT_FILES = make_set(
"web/src/composebox_typeahead.js", "web/src/composebox_typeahead.js",
"web/src/condense.js", "web/src/condense.js",
"web/src/confirm_dialog.ts", "web/src/confirm_dialog.ts",
"web/src/copied_tooltip.js", "web/src/copied_tooltip.ts",
"web/src/copy_and_paste.js", "web/src/copy_and_paste.js",
"web/src/csrf.ts", "web/src/csrf.ts",
"web/src/css_variables.js", "web/src/css_variables.js",

View File

@ -2,7 +2,11 @@ import tippy from "tippy.js";
import {$t} from "./i18n"; import {$t} from "./i18n";
export function show_copied_confirmation(copy_button, on_hide_callback, timeout_in_ms = 1000) { export function show_copied_confirmation(
copy_button: HTMLElement,
on_hide_callback: () => void,
timeout_in_ms = 1000,
): void {
// Display a tooltip to notify the user the message or code was copied. // Display a tooltip to notify the user the message or code was copied.
const instance = tippy(copy_button, { const instance = tippy(copy_button, {
placement: "top", placement: "top",
@ -18,7 +22,7 @@ export function show_copied_confirmation(copy_button, on_hide_callback, timeout_
}); });
instance.setContent($t({defaultMessage: "Copied!"})); instance.setContent($t({defaultMessage: "Copied!"}));
instance.show(); instance.show();
function remove_instance() { function remove_instance(): void {
if (!instance.state.isDestroyed) { if (!instance.state.isDestroyed) {
instance.destroy(); instance.destroy();
} }