2021-03-11 05:43:45 +01:00
|
|
|
import $ from "jquery";
|
|
|
|
|
2023-04-08 15:41:19 +02:00
|
|
|
import * as pm_list from "./pm_list";
|
2021-02-28 01:03:09 +01:00
|
|
|
import * as popovers from "./popovers";
|
2021-02-28 21:31:02 +01:00
|
|
|
import * as stream_list from "./stream_list";
|
2021-02-28 00:43:33 +01:00
|
|
|
import * as topic_list from "./topic_list";
|
|
|
|
|
2022-12-17 20:32:15 +01:00
|
|
|
let pending_stream_list_rerender = false;
|
2019-11-02 00:06:25 +01:00
|
|
|
let zoomed_in = false;
|
2018-09-10 23:26:12 +02:00
|
|
|
|
2021-02-10 16:51:01 +01:00
|
|
|
export function is_zoomed_in() {
|
2018-09-11 13:04:57 +02:00
|
|
|
return zoomed_in;
|
2021-02-10 16:51:01 +01:00
|
|
|
}
|
2018-09-11 13:04:57 +02:00
|
|
|
|
2018-09-10 14:52:58 +02:00
|
|
|
function zoom_in() {
|
2019-11-02 00:06:25 +01:00
|
|
|
const stream_id = topic_list.active_stream_id();
|
2018-09-10 14:52:58 +02:00
|
|
|
|
2019-07-10 01:54:39 +02:00
|
|
|
popovers.hide_all_except_sidebars();
|
2023-04-08 15:41:19 +02:00
|
|
|
pm_list.close();
|
2018-09-10 14:52:58 +02:00
|
|
|
topic_list.zoom_in();
|
|
|
|
stream_list.zoom_in_topics({
|
2020-07-20 22:18:43 +02:00
|
|
|
stream_id,
|
2018-09-10 14:52:58 +02:00
|
|
|
});
|
2018-09-10 23:26:12 +02:00
|
|
|
|
|
|
|
zoomed_in = true;
|
2018-09-10 14:52:58 +02:00
|
|
|
}
|
|
|
|
|
2022-12-17 20:32:15 +01:00
|
|
|
export function set_pending_stream_list_rerender(value) {
|
|
|
|
pending_stream_list_rerender = value;
|
|
|
|
}
|
|
|
|
|
2021-02-10 16:51:01 +01:00
|
|
|
export function zoom_out() {
|
2022-12-17 20:32:15 +01:00
|
|
|
if (pending_stream_list_rerender) {
|
|
|
|
stream_list.update_streams_sidebar(true);
|
|
|
|
}
|
2022-01-25 11:36:19 +01:00
|
|
|
const $stream_li = topic_list.get_stream_li();
|
2018-09-10 14:52:58 +02:00
|
|
|
|
2019-07-10 01:54:39 +02:00
|
|
|
popovers.hide_all_except_sidebars();
|
2018-09-10 14:52:58 +02:00
|
|
|
topic_list.zoom_out();
|
|
|
|
stream_list.zoom_out_topics();
|
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
if ($stream_li) {
|
|
|
|
stream_list.scroll_stream_into_view($stream_li);
|
2018-09-10 14:52:58 +02:00
|
|
|
}
|
2018-09-10 23:26:12 +02:00
|
|
|
|
|
|
|
zoomed_in = false;
|
2021-02-10 16:51:01 +01:00
|
|
|
}
|
2018-09-10 14:52:58 +02:00
|
|
|
|
2021-02-10 16:51:01 +01:00
|
|
|
export function clear_topics() {
|
2022-01-25 11:36:19 +01:00
|
|
|
const $stream_li = topic_list.get_stream_li();
|
2018-09-10 23:45:31 +02:00
|
|
|
|
2018-09-10 23:15:55 +02:00
|
|
|
topic_list.close();
|
2018-09-10 23:26:12 +02:00
|
|
|
|
|
|
|
if (zoomed_in) {
|
|
|
|
stream_list.zoom_out_topics();
|
2018-09-10 23:45:31 +02:00
|
|
|
|
2022-01-25 11:36:19 +01:00
|
|
|
if ($stream_li) {
|
|
|
|
stream_list.scroll_stream_into_view($stream_li);
|
2018-09-10 23:45:31 +02:00
|
|
|
}
|
2018-09-10 23:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
zoomed_in = false;
|
2021-02-10 16:51:01 +01:00
|
|
|
}
|
2018-09-10 23:15:55 +02:00
|
|
|
|
2021-02-10 16:51:01 +01:00
|
|
|
export function initialize() {
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#stream_filters").on("click", ".show-more-topics", (e) => {
|
2018-09-10 14:52:58 +02:00
|
|
|
zoom_in();
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$(".show-all-streams").on("click", (e) => {
|
2021-02-10 16:51:01 +01:00
|
|
|
zoom_out();
|
2018-09-10 14:52:58 +02:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2021-02-10 16:51:01 +01:00
|
|
|
}
|