mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	js: Convert static/js/resize.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							5ba7153a3b
						
					
				
				
					commit
					9f881ebe34
				
			@@ -186,7 +186,6 @@
 | 
			
		||||
                "realm_night_logo": false,
 | 
			
		||||
                "recent_topics": false,
 | 
			
		||||
                "reminder": false,
 | 
			
		||||
                "resize": false,
 | 
			
		||||
                "scroll_bar": false,
 | 
			
		||||
                "search": false,
 | 
			
		||||
                "search_pill_widget": false,
 | 
			
		||||
 
 | 
			
		||||
@@ -62,6 +62,7 @@ const _stream_popover = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const _resize = {
 | 
			
		||||
    __esModule: true,
 | 
			
		||||
    resize_sidebars: () => {},
 | 
			
		||||
    resize_page_components: () => {},
 | 
			
		||||
};
 | 
			
		||||
@@ -75,7 +76,7 @@ set_global("document", _document);
 | 
			
		||||
rewiremock("../../static/js/keydown_util").with(_keydown_util);
 | 
			
		||||
rewiremock("../../static/js/pm_list").with(_pm_list);
 | 
			
		||||
set_global("popovers", _popovers);
 | 
			
		||||
set_global("resize", _resize);
 | 
			
		||||
rewiremock("../../static/js/resize").with(_resize);
 | 
			
		||||
rewiremock("../../static/js/scroll_util").with(_scroll_util);
 | 
			
		||||
set_global("stream_popover", _stream_popover);
 | 
			
		||||
set_global("ui", _ui);
 | 
			
		||||
 
 | 
			
		||||
@@ -72,7 +72,8 @@ rewiremock("../../static/js/markdown").with(markdown);
 | 
			
		||||
const loading = {__esModule: true};
 | 
			
		||||
rewiremock("../../static/js/loading").with(loading);
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
const resize = set_global("resize", {});
 | 
			
		||||
const resize = {__esModule: true};
 | 
			
		||||
rewiremock("../../static/js/resize").with(resize);
 | 
			
		||||
const subs = set_global("subs", {});
 | 
			
		||||
const ui_util = set_global("ui_util", {});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ const $ = require("../zjsunit/zjquery");
 | 
			
		||||
set_global("page_params", {
 | 
			
		||||
    stop_words: ["what", "about"],
 | 
			
		||||
});
 | 
			
		||||
set_global("resize", {
 | 
			
		||||
rewiremock("../../static/js/resize").with({
 | 
			
		||||
    resize_page_components: () => {},
 | 
			
		||||
    resize_stream_filters_container: () => {},
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ const rewiremock = require("rewiremock/node");
 | 
			
		||||
const {set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
set_global("resize", {
 | 
			
		||||
rewiremock("../../static/js/resize").with({
 | 
			
		||||
    resize_stream_filters_container: () => {},
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
const {strict: assert} = require("assert");
 | 
			
		||||
 | 
			
		||||
const rewiremock = require("rewiremock/node");
 | 
			
		||||
 | 
			
		||||
const {set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
@@ -11,7 +13,7 @@ const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
const noop = () => {};
 | 
			
		||||
 | 
			
		||||
set_global("resize", {
 | 
			
		||||
rewiremock("../../static/js/resize").with({
 | 
			
		||||
    resize_page_components: noop,
 | 
			
		||||
    resize_stream_filters_container: noop,
 | 
			
		||||
});
 | 
			
		||||
@@ -19,6 +21,8 @@ set_global("resize", {
 | 
			
		||||
const popovers = set_global("popovers", {});
 | 
			
		||||
const stream_popover = set_global("stream_popover", {});
 | 
			
		||||
 | 
			
		||||
rewiremock.enable();
 | 
			
		||||
 | 
			
		||||
const stream_list = zrequire("stream_list");
 | 
			
		||||
 | 
			
		||||
function expand_sidebar() {
 | 
			
		||||
@@ -189,3 +193,4 @@ run_test("expanding_sidebar", () => {
 | 
			
		||||
 | 
			
		||||
    assert.deepEqual(events, ["popovers.hide_all", "stream_popover.show_streamlist_sidebar"]);
 | 
			
		||||
});
 | 
			
		||||
rewiremock.disable();
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,7 @@ const {set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
const $ = require("../zjsunit/zjquery");
 | 
			
		||||
 | 
			
		||||
set_global("resize", {
 | 
			
		||||
rewiremock("../../static/js/resize").with({
 | 
			
		||||
    resize_stream_filters_container: () => {},
 | 
			
		||||
});
 | 
			
		||||
rewiremock.enable();
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,8 @@ const message_list = set_global("message_list", {});
 | 
			
		||||
const message_util = set_global("message_util", {});
 | 
			
		||||
const notifications = set_global("notifications", {});
 | 
			
		||||
const overlays = set_global("overlays", {});
 | 
			
		||||
const resize = set_global("resize", {});
 | 
			
		||||
const resize = {__esModule: true};
 | 
			
		||||
rewiremock("../../static/js/resize").with(resize);
 | 
			
		||||
let stream_list = set_global("stream_list", {});
 | 
			
		||||
let unread_ops = set_global("unread_ops", {});
 | 
			
		||||
const unread_ui = {__esModule: true};
 | 
			
		||||
 
 | 
			
		||||
@@ -36,9 +36,11 @@ set_global("document", {
 | 
			
		||||
 | 
			
		||||
set_global("csrf_token", "whatever");
 | 
			
		||||
 | 
			
		||||
const resize = set_global("resize", {
 | 
			
		||||
const resize = {
 | 
			
		||||
    __esModule: true,
 | 
			
		||||
    handler: () => {},
 | 
			
		||||
});
 | 
			
		||||
};
 | 
			
		||||
rewiremock("../../static/js/resize").with(resize);
 | 
			
		||||
const page_params = set_global("page_params", {});
 | 
			
		||||
 | 
			
		||||
page_params.realm_default_streams = [];
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,6 @@ import "../narrow";
 | 
			
		||||
import "../reload";
 | 
			
		||||
import "../compose_actions";
 | 
			
		||||
import "../subs";
 | 
			
		||||
import "../resize";
 | 
			
		||||
import "../list_widget";
 | 
			
		||||
import "../floating_recipient_bar";
 | 
			
		||||
import "../lightbox";
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ import * as markdown from "./markdown";
 | 
			
		||||
import * as peer_data from "./peer_data";
 | 
			
		||||
import * as people from "./people";
 | 
			
		||||
import * as rendered_markdown from "./rendered_markdown";
 | 
			
		||||
import * as resize from "./resize";
 | 
			
		||||
import * as rtl from "./rtl";
 | 
			
		||||
import * as sent_messages from "./sent_messages";
 | 
			
		||||
import * as settings_config from "./settings_config";
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								static/js/global.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								static/js/global.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -59,7 +59,6 @@ declare let realm_icon: any;
 | 
			
		||||
declare let realm_logo: any;
 | 
			
		||||
declare let recent_topics: any;
 | 
			
		||||
declare let reminder: any;
 | 
			
		||||
declare let resize: any;
 | 
			
		||||
declare let scroll_bar: any;
 | 
			
		||||
declare let search: any;
 | 
			
		||||
declare let search_pill_widget: any;
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ import * as echo from "./echo";
 | 
			
		||||
import * as loading from "./loading";
 | 
			
		||||
import * as markdown from "./markdown";
 | 
			
		||||
import * as message_viewport from "./message_viewport";
 | 
			
		||||
import * as resize from "./resize";
 | 
			
		||||
import * as rows from "./rows";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as upload from "./upload";
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,7 @@ const message_edit_history = require("./message_edit_history");
 | 
			
		||||
const narrow_state = require("./narrow_state");
 | 
			
		||||
const pm_list = require("./pm_list");
 | 
			
		||||
const recent_senders = require("./recent_senders");
 | 
			
		||||
const resize = require("./resize");
 | 
			
		||||
const stream_data = require("./stream_data");
 | 
			
		||||
const stream_topic_history = require("./stream_topic_history");
 | 
			
		||||
const unread_ui = require("./unread_ui");
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const loading = require("./loading");
 | 
			
		||||
const resize = require("./resize");
 | 
			
		||||
const unread_ui = require("./unread_ui");
 | 
			
		||||
 | 
			
		||||
exports.do_unread_count_updates = function do_unread_count_updates(messages) {
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ const message_edit = require("./message_edit");
 | 
			
		||||
const {MessageListData} = require("./message_list_data");
 | 
			
		||||
const narrow_state = require("./narrow_state");
 | 
			
		||||
const people = require("./people");
 | 
			
		||||
const resize = require("./resize");
 | 
			
		||||
const search_pill = require("./search_pill");
 | 
			
		||||
const stream_data = require("./stream_data");
 | 
			
		||||
const stream_topic_history = require("./stream_topic_history");
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ const muting = require("./muting");
 | 
			
		||||
const muting_ui = require("./muting_ui");
 | 
			
		||||
const narrow_state = require("./narrow_state");
 | 
			
		||||
const people = require("./people");
 | 
			
		||||
const resize = require("./resize");
 | 
			
		||||
const rows = require("./rows");
 | 
			
		||||
const settings_config = require("./settings_config");
 | 
			
		||||
const settings_data = require("./settings_data");
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,6 +8,7 @@ const render_stream_sidebar_row = require("../templates/stream_sidebar_row.hbs")
 | 
			
		||||
const keydown_util = require("./keydown_util");
 | 
			
		||||
const {ListCursor} = require("./list_cursor");
 | 
			
		||||
const narrow_state = require("./narrow_state");
 | 
			
		||||
const resize = require("./resize");
 | 
			
		||||
const scroll_util = require("./scroll_util");
 | 
			
		||||
const stream_color = require("./stream_color");
 | 
			
		||||
const stream_data = require("./stream_data");
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ const channel = require("./channel");
 | 
			
		||||
const message_edit = require("./message_edit");
 | 
			
		||||
const muting = require("./muting");
 | 
			
		||||
const muting_ui = require("./muting_ui");
 | 
			
		||||
const resize = require("./resize");
 | 
			
		||||
const stream_color = require("./stream_color");
 | 
			
		||||
const stream_data = require("./stream_data");
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
import * as people from "./people";
 | 
			
		||||
import * as pm_list from "./pm_list";
 | 
			
		||||
import * as resize from "./resize";
 | 
			
		||||
import * as unread_ui from "./unread_ui";
 | 
			
		||||
 | 
			
		||||
export function update_count_in_dom(unread_count_elem, count) {
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ const people = require("./people");
 | 
			
		||||
const pm_conversations = require("./pm_conversations");
 | 
			
		||||
const pm_list = require("./pm_list");
 | 
			
		||||
const reload = require("./reload");
 | 
			
		||||
const resize = require("./resize");
 | 
			
		||||
const rows = require("./rows");
 | 
			
		||||
const sent_messages = require("./sent_messages");
 | 
			
		||||
const spoilers = require("./spoilers");
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
import * as resize from "./resize";
 | 
			
		||||
 | 
			
		||||
export class UserSearch {
 | 
			
		||||
    // This is mostly view code to manage the user search widget
 | 
			
		||||
    // above the buddy list.  We rely on other code to manage the
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user