From caae5539388594f3d50bf87bbc1b9cc82cfa92f7 Mon Sep 17 00:00:00 2001 From: anapnoe <124302297+anapnoe@users.noreply.github.com> Date: Tue, 16 May 2023 16:04:14 +0300 Subject: [PATCH] feature request The aside off-canvas view and can automatically hide #130 --- javascript/ui.js | 10 +++++++++- modules/ui_extra_networks.py | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/javascript/ui.js b/javascript/ui.js index e0d94cc3..6e3795f7 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -672,6 +672,8 @@ onUiLoaded(function () { } } + + // close aside views function closeAsideViews(menu) { if (quick_menu != menu && quick_menu_open) quick_menu.click(); @@ -742,12 +744,18 @@ onUiLoaded(function () { quick_menu.addEventListener("click", toggleQuickMenu); // extra networks nav menu + function clickedOutside(e) { + //console.log(e.target.getAttribute('data-testid')); + if(e.target.getAttribute('data-testid') != "textbox" && e.target.getAttribute('data-testid')){ + if (net_menu_open && e.target.closest('[id$="2img_settings_scroll"]')) net_menu.click(); + } + } function toggleNetMenu(e) { closeAsideViews(net_menu); net_menu_open = !net_menu_open; e.preventDefault(); e.stopPropagation(); - toggleMenu(net_menu_open, net_menu, net_container, null); + toggleMenu(net_menu_open, net_menu, net_container, clickedOutside); } net_menu.addEventListener("click", toggleNetMenu); gradioApp() diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index e5243903..385ad8d6 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -30,8 +30,8 @@ def fetch_file(filename: str = ""): if not any([Path(x).absolute() in Path(filename).absolute().parents for x in allowed_dirs]): raise ValueError(f"File cannot be fetched: {filename}. Must be in one of directories registered by extra pages.") - - ext = os.path.splitext(filename)[1].lower() + extbase = os.path.basename(filename) + ext = os.path.splitext(extbase).lower() if ext not in (".png", ".jpg", ".webp"): raise ValueError(f"File cannot be fetched: {filename}. Only png and jpg and webp.")