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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-02-27 15:44:57 -08:00 committed by Tim Abbott
parent 1b151d0472
commit 16668904c1
13 changed files with 28 additions and 29 deletions

View File

@ -238,7 +238,6 @@
"subs": false, "subs": false,
"message_view_header": false, "message_view_header": false,
"timerender": false, "timerender": false,
"top_left_corner": false,
"transmit": false, "transmit": false,
"typeahead_helper": false, "typeahead_helper": false,
"typing_events": false, "typing_events": false,

View File

@ -34,7 +34,7 @@ const overlays = set_global("overlays", {});
const settings = set_global("settings", {}); const settings = set_global("settings", {});
const subs = set_global("subs", {}); const subs = set_global("subs", {});
const ui_util = set_global("ui_util", {}); const ui_util = set_global("ui_util", {});
set_global("top_left_corner", { rewiremock("../../static/js/top_left_corner").with({
handle_narrow_deactivated: () => {}, handle_narrow_deactivated: () => {},
}); });

View File

@ -31,7 +31,8 @@ set_global("page_params", {});
const search = set_global("search", {}); const search = set_global("search", {});
const stream_list = set_global("stream_list", {}); const stream_list = set_global("stream_list", {});
const message_view_header = set_global("message_view_header", {}); const message_view_header = set_global("message_view_header", {});
const top_left_corner = set_global("top_left_corner", {}); const top_left_corner = {__esModule: true};
rewiremock("../../static/js/top_left_corner").with(top_left_corner);
const typing_events = set_global("typing_events", {}); const typing_events = set_global("typing_events", {});
const ui_util = set_global("ui_util", {}); const ui_util = set_global("ui_util", {});
const unread_ops = set_global("unread_ops", {}); const unread_ops = set_global("unread_ops", {});

View File

@ -10,7 +10,7 @@ const {run_test} = require("../zjsunit/test");
const $ = require("../zjsunit/zjquery"); const $ = require("../zjsunit/zjquery");
const noop = () => {}; const noop = () => {};
set_global("top_left_corner", { rewiremock("../../static/js/top_left_corner").with({
narrow_to_recent_topics: noop, narrow_to_recent_topics: noop,
}); });
set_global("stream_list", { set_global("stream_list", {

View File

@ -131,7 +131,6 @@ zrequire("search");
zrequire("notifications"); zrequire("notifications");
zrequire("stream_list"); zrequire("stream_list");
zrequire("sent_messages"); zrequire("sent_messages");
zrequire("top_left_corner");
zrequire("starred_messages"); zrequire("starred_messages");
zrequire("recent_topics"); zrequire("recent_topics");

View File

@ -19,7 +19,6 @@ import "../input_pill";
import "../setup"; import "../setup";
import "../unread_ops"; import "../unread_ops";
import "../unread"; import "../unread";
import "../top_left_corner";
import "../stream_list"; import "../stream_list";
import "../filter"; import "../filter";
import "../poll_widget"; import "../poll_widget";

View File

@ -111,7 +111,6 @@ declare let subs: any;
declare let message_view_header: any; declare let message_view_header: any;
declare let timerender: any; declare let timerender: any;
declare let stream_topic_history: any; declare let stream_topic_history: any;
declare let top_left_corner: any;
declare let transmit: any; declare let transmit: any;
declare let typeahead_helper: any; declare let typeahead_helper: any;
declare let typing_events: any; declare let typing_events: any;

View File

@ -3,6 +3,7 @@
const drafts = require("./drafts"); const drafts = require("./drafts");
const invite = require("./invite"); const invite = require("./invite");
const message_viewport = require("./message_viewport"); const message_viewport = require("./message_viewport");
const top_left_corner = require("./top_left_corner");
// Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html // Read https://zulip.readthedocs.io/en/latest/subsystems/hashchange-system.html
// or locally: docs/subsystems/hashchange-system.md // or locally: docs/subsystems/hashchange-system.md

View File

@ -4,6 +4,7 @@ const channel = require("./channel");
const {MessageListData} = require("./message_list_data"); const {MessageListData} = require("./message_list_data");
const people = require("./people"); const people = require("./people");
const search_pill = require("./search_pill"); const search_pill = require("./search_pill");
const top_left_corner = require("./top_left_corner");
const topic_generator = require("./topic_generator"); const topic_generator = require("./topic_generator");
const util = require("./util"); const util = require("./util");

View File

@ -9,6 +9,7 @@ const {localstorage} = require("./localstorage");
const muting = require("./muting"); const muting = require("./muting");
const people = require("./people"); const people = require("./people");
const recent_senders = require("./recent_senders"); const recent_senders = require("./recent_senders");
const top_left_corner = require("./top_left_corner");
const topics = new Map(); // Key is stream-id:topic. const topics = new Map(); // Key is stream-id:topic.
let topics_widget; let topics_widget;

View File

@ -1,5 +1,7 @@
"use strict"; "use strict";
const top_left_corner = require("./top_left_corner");
exports.starred_ids = new Set(); exports.starred_ids = new Set();
exports.initialize = function () { exports.initialize = function () {

View File

@ -1,10 +1,8 @@
"use strict"; import * as people from "./people";
import * as pm_list from "./pm_list";
import * as unread_ui from "./unread_ui";
const people = require("./people"); export function update_count_in_dom(unread_count_elem, count) {
const pm_list = require("./pm_list");
const unread_ui = require("./unread_ui");
exports.update_count_in_dom = function (unread_count_elem, count) {
const count_span = unread_count_elem.find(".count"); const count_span = unread_count_elem.find(".count");
const value_span = count_span.find(".value"); const value_span = count_span.find(".value");
@ -16,25 +14,25 @@ exports.update_count_in_dom = function (unread_count_elem, count) {
count_span.show(); count_span.show();
value_span.text(count); value_span.text(count);
}; }
exports.update_starred_count = function (count) { export function update_starred_count(count) {
const starred_li = $(".top_left_starred_messages"); const starred_li = $(".top_left_starred_messages");
exports.update_count_in_dom(starred_li, count); update_count_in_dom(starred_li, count);
}; }
exports.update_dom_with_unread_counts = function (counts) { export function update_dom_with_unread_counts(counts) {
// Note that "Private messages" counts are handled in pm_list.js. // Note that "Private messages" counts are handled in pm_list.js.
// mentioned/home have simple integer counts // mentioned/home have simple integer counts
const mentioned_li = $(".top_left_mentions"); const mentioned_li = $(".top_left_mentions");
const home_li = $(".top_left_all_messages"); const home_li = $(".top_left_all_messages");
exports.update_count_in_dom(mentioned_li, counts.mentioned_message_count); update_count_in_dom(mentioned_li, counts.mentioned_message_count);
exports.update_count_in_dom(home_li, counts.home_unread_messages); update_count_in_dom(home_li, counts.home_unread_messages);
unread_ui.animate_mention_changes(mentioned_li, counts.mentioned_message_count); unread_ui.animate_mention_changes(mentioned_li, counts.mentioned_message_count);
}; }
function remove(elem) { function remove(elem) {
elem.removeClass("active-filter active-sub-filter"); elem.removeClass("active-filter active-sub-filter");
@ -69,7 +67,7 @@ function should_expand_pm_list(filter) {
return has_valid_emails; return has_valid_emails;
} }
exports.handle_narrow_activated = function (filter) { export function handle_narrow_activated(filter) {
deselect_top_left_corner_items(); deselect_top_left_corner_items();
let ops; let ops;
@ -102,17 +100,17 @@ exports.handle_narrow_activated = function (filter) {
} else { } else {
pm_list.close(); pm_list.close();
} }
}; }
exports.handle_narrow_deactivated = function () { export function handle_narrow_deactivated() {
deselect_top_left_corner_items(); deselect_top_left_corner_items();
pm_list.close(); pm_list.close();
const filter_li = $(".top_left_all_messages"); const filter_li = $(".top_left_all_messages");
filter_li.addClass("active-filter"); filter_li.addClass("active-filter");
}; }
exports.narrow_to_recent_topics = function () { export function narrow_to_recent_topics() {
remove($(".top_left_all_messages")); remove($(".top_left_all_messages"));
remove($(".top_left_private_messages")); remove($(".top_left_private_messages"));
remove($(".top_left_starred_messages")); remove($(".top_left_starred_messages"));
@ -122,6 +120,4 @@ exports.narrow_to_recent_topics = function () {
setTimeout(() => { setTimeout(() => {
resize.resize_stream_filters_container(); resize.resize_stream_filters_container();
}, 0); }, 0);
}; }
window.top_left_corner = exports;

View File

@ -1,4 +1,5 @@
import * as pm_list from "./pm_list"; import * as pm_list from "./pm_list";
import * as top_left_corner from "./top_left_corner";
import * as topic_list from "./topic_list"; import * as topic_list from "./topic_list";
let last_mention_count = 0; let last_mention_count = 0;