Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

ts: Convert padded_widget module to TypeScript.

Priyank Patel35738e148b82
diff --git a/static/js/padded_widget.js b/static/js/padded_widget.ts
similarity index 71%
rename from static/js/padded_widget.js
rename to static/js/padded_widget.ts
index d6848332460..c6b180e38b3 100644
--- a/static/js/padded_widget.js
+++ b/static/js/padded_widget.ts
@@ -1,6 +1,11 @@
import $ from "jquery";
-export function update_padding(opts) {
+export function update_padding(opts: {
+ content_sel: string;
+ padding_sel: string;
+ total_rows: number;
+ shown_rows: number;
+}): void {
const content = $(opts.content_sel);
const padding = $(opts.padding_sel);
const total_rows = opts.total_rows;
@@ -15,6 +20,10 @@ export function update_padding(opts) {
const ratio = hidden_rows / shown_rows;
const content_height = content.height();
+ if (content_height === undefined) {
+ return;
+ }
+
const new_padding_height = ratio * content_height;
padding.height(new_padding_height);
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index d8fc22e0e65..747adcd74a6 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -99,7 +99,7 @@ EXEMPT_FILES = {
"static/js/night_mode.ts",
"static/js/notifications.js",
"static/js/overlays.js",
- "static/js/padded_widget.js",
+ "static/js/padded_widget.ts",
"static/js/page_params.ts",
"static/js/navbar_alerts.js",
"static/js/pm_list_dom.js",