js: Convert static/js/resize.js to ES6 module.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2021-02-27 15:57:20 -08:00
committed by Tim Abbott
parent 5ba7153a3b
commit 9f881ebe34
23 changed files with 51 additions and 36 deletions

View File

@@ -1,10 +1,8 @@
"use strict";
import autosize from "autosize";
const autosize = require("autosize");
const condense = require("./condense");
const message_viewport = require("./message_viewport");
const util = require("./util");
import * as condense from "./condense";
import * as message_viewport from "./message_viewport";
import * as util from "./util";
let narrow_window = false;
@@ -115,7 +113,7 @@ function left_userlist_get_new_heights() {
return res;
}
exports.watch_manual_resize = function (element) {
export function watch_manual_resize(element) {
return (function on_box_resize(cb) {
const box = document.querySelector(element);
@@ -155,19 +153,19 @@ exports.watch_manual_resize = function (element) {
// will be re-enabled when this component is next opened.
autosize.destroy($(element)).height(height + "px");
});
};
}
exports.resize_bottom_whitespace = function (h) {
export function resize_bottom_whitespace(h) {
$("#bottom_whitespace").height(h.bottom_whitespace_height);
};
}
exports.resize_stream_filters_container = function (h) {
export function resize_stream_filters_container(h) {
h = narrow_window ? left_userlist_get_new_heights() : get_new_heights();
exports.resize_bottom_whitespace(h);
resize_bottom_whitespace(h);
$("#stream-filters-container").css("max-height", h.stream_filters_max_height);
};
}
exports.resize_sidebars = function () {
export function resize_sidebars() {
let sidebar;
if (page_params.left_side_userlist) {
@@ -204,17 +202,17 @@ exports.resize_sidebars = function () {
$("#stream-filters-container").css("max-height", h.stream_filters_max_height);
return h;
};
}
exports.resize_page_components = function () {
const h = exports.resize_sidebars();
exports.resize_bottom_whitespace(h);
export function resize_page_components() {
const h = resize_sidebars();
resize_bottom_whitespace(h);
panels.resize_app();
};
}
let _old_width = $(window).width();
exports.handler = function () {
export function handler() {
const new_width = $(window).width();
if (new_width !== _old_width) {
@@ -229,7 +227,7 @@ exports.handler = function () {
if (!mobile) {
popovers.hide_all();
}
exports.resize_page_components();
resize_page_components();
// Re-compute and display/remove [More] links to messages
condense.condense_and_collapse($(".message_table .message_row"));
@@ -244,6 +242,4 @@ exports.handler = function () {
navigate.scroll_to_selected();
}
};
window.resize = exports;
}