diff --git a/web/src/navbar_menus.js b/web/src/navbar_menus.js index fae1ca85d4..a300432bc7 100644 --- a/web/src/navbar_menus.js +++ b/web/src/navbar_menus.js @@ -2,9 +2,9 @@ import $ from "jquery"; import * as gear_menu from "./gear_menu.js"; import * as navbar_help_menu from "./navbar_help_menu.ts"; -import {page_params} from "./page_params.ts"; import * as personal_menu_popover from "./personal_menu_popover.ts"; import * as popover_menus from "./popover_menus.ts"; +import * as popovers from "./popovers.ts"; export function is_navbar_menus_displayed() { return ( @@ -34,44 +34,20 @@ export function handle_keyboard_events(event_name) { } function change_active_navbar_menu(target_menu) { - // We don't need to process arrow keys in navbar menus for spectators - // since they only have gear menu present. - if ( - popover_menus.is_personal_menu_popover_displayed() && - target_menu === "gear-menu" && - !page_params.is_spectator - ) { - // Open gear menu popover on left arrow. - personal_menu_popover.toggle(); - gear_menu.toggle(); - return true; - } - - if (popover_menus.is_help_menu_popover_displayed() && target_menu === "gear-menu") { - // Open gear menu popover on right arrow. - navbar_help_menu.toggle(); - gear_menu.toggle(); - return true; - } - - if (popover_menus.is_gear_menu_popover_displayed()) { - if (target_menu === "gear-menu") { + popovers.hide_all(); + switch (target_menu) { + case "gear-menu": gear_menu.toggle(); return true; - } else if (target_menu === "personal-menu" && !page_params.is_spectator) { - // Open personal menu popover on g + right arrow. - gear_menu.toggle(); - personal_menu_popover.toggle(); - return true; - } else if (target_menu === "help-menu") { - // Open help menu popover on g + left arrow. - gear_menu.toggle(); + case "help-menu": navbar_help_menu.toggle(); return true; - } + case "personal-menu": + personal_menu_popover.toggle(); + return true; + default: + return false; } - - return false; } function get_target_navbar_menu(event_name, $current_navbar_menu) {