2023-10-03 19:29:53 +02:00
|
|
|
import $ from "jquery";
|
|
|
|
|
|
|
|
import render_drafts_sidebar_actions from "../templates/drafts_sidebar_action.hbs";
|
2023-10-03 18:40:44 +02:00
|
|
|
import render_left_sidebar_inbox_popover from "../templates/left_sidebar_inbox_popover.hbs";
|
2023-10-03 19:29:53 +02:00
|
|
|
import render_starred_messages_sidebar_actions from "../templates/starred_messages_sidebar_actions.hbs";
|
|
|
|
|
|
|
|
import * as channel from "./channel";
|
|
|
|
import * as drafts from "./drafts";
|
|
|
|
import * as popover_menus from "./popover_menus";
|
|
|
|
import * as popovers from "./popovers";
|
|
|
|
import * as starred_messages from "./starred_messages";
|
|
|
|
import * as starred_messages_ui from "./starred_messages_ui";
|
|
|
|
import {parse_html} from "./ui_util";
|
|
|
|
import * as unread_ops from "./unread_ops";
|
|
|
|
import {user_settings} from "./user_settings";
|
|
|
|
|
|
|
|
export function initialize() {
|
|
|
|
// Starred messages popover
|
|
|
|
popover_menus.register_popover_menu(".starred-messages-sidebar-menu-icon", {
|
|
|
|
...popover_menus.left_sidebar_tippy_options,
|
|
|
|
onMount(instance) {
|
|
|
|
const $popper = $(instance.popper);
|
|
|
|
popover_menus.popover_instances.starred_messages = instance;
|
|
|
|
|
|
|
|
$popper.one("click", "#unstar_all_messages", () => {
|
|
|
|
starred_messages_ui.confirm_unstar_all_messages();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
$popper.one("click", "#toggle_display_starred_msg_count", () => {
|
|
|
|
const data = {};
|
|
|
|
const starred_msg_counts = user_settings.starred_message_counts;
|
|
|
|
data.starred_message_counts = JSON.stringify(!starred_msg_counts);
|
|
|
|
|
|
|
|
channel.patch({
|
|
|
|
url: "/json/settings",
|
|
|
|
data,
|
|
|
|
});
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onShow(instance) {
|
|
|
|
popovers.hide_all();
|
|
|
|
const show_unstar_all_button = starred_messages.get_count() > 0;
|
|
|
|
|
|
|
|
instance.setContent(
|
|
|
|
parse_html(
|
|
|
|
render_starred_messages_sidebar_actions({
|
|
|
|
show_unstar_all_button,
|
|
|
|
starred_message_counts: user_settings.starred_message_counts,
|
|
|
|
}),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
onHidden(instance) {
|
|
|
|
instance.destroy();
|
|
|
|
popover_menus.popover_instances.starred_messages = undefined;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Drafts popover
|
|
|
|
popover_menus.register_popover_menu(".drafts-sidebar-menu-icon", {
|
|
|
|
...popover_menus.left_sidebar_tippy_options,
|
|
|
|
onMount(instance) {
|
|
|
|
const $popper = $(instance.popper);
|
|
|
|
$popper.addClass("drafts-popover");
|
|
|
|
popover_menus.popover_instances.drafts = instance;
|
|
|
|
|
|
|
|
$popper.one("click", "#delete_all_drafts_sidebar", () => {
|
|
|
|
drafts.confirm_delete_all_drafts();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onShow(instance) {
|
|
|
|
popovers.hide_all();
|
|
|
|
|
|
|
|
instance.setContent(parse_html(render_drafts_sidebar_actions({})));
|
|
|
|
},
|
|
|
|
onHidden(instance) {
|
|
|
|
instance.destroy();
|
|
|
|
popover_menus.popover_instances.drafts = undefined;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2023-10-03 18:40:44 +02:00
|
|
|
// Inbox popover
|
|
|
|
popover_menus.register_popover_menu(".inbox-sidebar-menu-icon", {
|
2023-10-03 19:29:53 +02:00
|
|
|
...popover_menus.left_sidebar_tippy_options,
|
|
|
|
onMount(instance) {
|
|
|
|
const $popper = $(instance.popper);
|
2023-10-03 18:40:44 +02:00
|
|
|
popover_menus.popover_instances.left_sidebar_inbox_popover = instance;
|
2023-10-03 19:29:53 +02:00
|
|
|
|
|
|
|
$popper.one("click", "#mark_all_messages_as_read", () => {
|
|
|
|
unread_ops.confirm_mark_all_as_read();
|
|
|
|
instance.hide();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onShow(instance) {
|
|
|
|
popovers.hide_all();
|
2023-10-03 18:40:44 +02:00
|
|
|
instance.setContent(parse_html(render_left_sidebar_inbox_popover()));
|
2023-10-03 19:29:53 +02:00
|
|
|
},
|
|
|
|
onHidden(instance) {
|
|
|
|
instance.destroy();
|
2023-10-03 18:40:44 +02:00
|
|
|
popover_menus.popover_instances.left_sidebar_inbox_popover = undefined;
|
2023-10-03 19:29:53 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|