mirror of https://github.com/zulip/zulip.git
overlays: Extract function checking if overlays or modals are open.
This commit is contained in:
parent
63c1c9a37a
commit
6713ad9d4d
|
@ -35,6 +35,7 @@ import * as narrow from "./narrow";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
|
import * as overlays_modals from "./overlays_modals";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as playground_links_popover from "./playground_links_popover";
|
import * as playground_links_popover from "./playground_links_popover";
|
||||||
import * as popover_menus from "./popover_menus";
|
import * as popover_menus from "./popover_menus";
|
||||||
|
@ -861,7 +862,7 @@ export function process_hotkey(e, hotkey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent navigation in the background when the overlays are active.
|
// Prevent navigation in the background when the overlays are active.
|
||||||
if (overlays.is_overlay_or_modal_open()) {
|
if (overlays_modals.any_active()) {
|
||||||
if (event_name === "view_selected_stream" && overlays.streams_open()) {
|
if (event_name === "view_selected_stream" && overlays.streams_open()) {
|
||||||
stream_settings_ui.view_stream();
|
stream_settings_ui.view_stream();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import * as keydown_util from "./keydown_util";
|
||||||
import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area";
|
import * as left_sidebar_navigation_area from "./left_sidebar_navigation_area";
|
||||||
import {localstorage} from "./localstorage";
|
import {localstorage} from "./localstorage";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as overlays from "./overlays";
|
import * as overlays_modals from "./overlays_modals";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as popovers from "./popovers";
|
import * as popovers from "./popovers";
|
||||||
|
@ -1191,7 +1191,7 @@ export function is_in_focus() {
|
||||||
!compose_state.composing() &&
|
!compose_state.composing() &&
|
||||||
!popovers.any_active() &&
|
!popovers.any_active() &&
|
||||||
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
|
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
|
||||||
!overlays.is_overlay_or_modal_open() &&
|
!overlays_modals.any_active() &&
|
||||||
!$(".home-page-input").is(":focus")
|
!$(".home-page-input").is(":focus")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,10 +61,6 @@ export function is_modal_open(): boolean {
|
||||||
return $(".micromodal").hasClass("modal--open");
|
return $(".micromodal").hasClass("modal--open");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function is_overlay_or_modal_open(): boolean {
|
|
||||||
return is_active() || is_modal_open();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function info_overlay_open(): boolean {
|
export function info_overlay_open(): boolean {
|
||||||
return open_overlay_name === "informationalOverlays";
|
return open_overlay_name === "informationalOverlays";
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
import * as overlays from './overlays';
|
||||||
|
|
||||||
|
export function any_active(): boolean {
|
||||||
|
return overlays.is_active() || overlays.is_modal_open();
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ import {localstorage} from "./localstorage";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as message_util from "./message_util";
|
import * as message_util from "./message_util";
|
||||||
import * as muted_users from "./muted_users";
|
import * as muted_users from "./muted_users";
|
||||||
import * as overlays from "./overlays";
|
import * as overlays_modals from "./overlays_modals";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as popovers from "./popovers";
|
import * as popovers from "./popovers";
|
||||||
|
@ -103,7 +103,7 @@ export function is_in_focus() {
|
||||||
!compose_state.composing() &&
|
!compose_state.composing() &&
|
||||||
!popovers.any_active() &&
|
!popovers.any_active() &&
|
||||||
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
|
!sidebar_ui.any_sidebar_expanded_as_overlay() &&
|
||||||
!overlays.is_overlay_or_modal_open() &&
|
!overlays_modals.any_active() &&
|
||||||
!$(".home-page-input").is(":focus")
|
!$(".home-page-input").is(":focus")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ import * as narrow_title from "./narrow_title";
|
||||||
import * as navbar_alerts from "./navbar_alerts";
|
import * as navbar_alerts from "./navbar_alerts";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
|
import * as overlays_modals from "./overlays_modals";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as playground_links_popover from "./playground_links_popover";
|
import * as playground_links_popover from "./playground_links_popover";
|
||||||
|
@ -249,7 +250,7 @@ export function initialize_kitchen_sink_stuff() {
|
||||||
|
|
||||||
message_viewport.$scroll_container.on("wheel", (e) => {
|
message_viewport.$scroll_container.on("wheel", (e) => {
|
||||||
const delta = e.originalEvent.deltaY;
|
const delta = e.originalEvent.deltaY;
|
||||||
if (!overlays.is_overlay_or_modal_open() && narrow_state.is_message_feed_visible()) {
|
if (!overlays_modals.any_active() && narrow_state.is_message_feed_visible()) {
|
||||||
// In the message view, we use a throttled mousewheel handler.
|
// In the message view, we use a throttled mousewheel handler.
|
||||||
throttled_mousewheelhandler(e, delta);
|
throttled_mousewheelhandler(e, delta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as overlays from "./overlays";
|
import * as overlays_modals from "./overlays_modals";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as recent_view_ui from "./recent_view_ui";
|
import * as recent_view_ui from "./recent_view_ui";
|
||||||
import * as ui_report from "./ui_report";
|
import * as ui_report from "./ui_report";
|
||||||
|
@ -471,7 +471,7 @@ export function mark_pm_as_read(user_ids_string) {
|
||||||
|
|
||||||
export function viewport_is_visible_and_focused() {
|
export function viewport_is_visible_and_focused() {
|
||||||
if (
|
if (
|
||||||
overlays.is_overlay_or_modal_open() ||
|
overlays_modals.any_active() ||
|
||||||
!is_window_focused() ||
|
!is_window_focused() ||
|
||||||
!$("#message_feed_container").is(":visible")
|
!$("#message_feed_container").is(":visible")
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -65,7 +65,6 @@ const overlays = mock_esm("../src/overlays", {
|
||||||
info_overlay_open: () => false,
|
info_overlay_open: () => false,
|
||||||
is_modal_open: () => false,
|
is_modal_open: () => false,
|
||||||
active_modal: () => undefined,
|
active_modal: () => undefined,
|
||||||
is_overlay_or_modal_open: () => overlays.is_modal_open() || overlays.is_active(),
|
|
||||||
});
|
});
|
||||||
const popovers = mock_esm("../src/user_card_popover", {
|
const popovers = mock_esm("../src/user_card_popover", {
|
||||||
manage_menu: {
|
manage_menu: {
|
||||||
|
|
Loading…
Reference in New Issue