From 04a7c93f26ec006039571683dd649cc60474ebec Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Sun, 22 Oct 2023 14:01:29 +0100 Subject: [PATCH] Open menu item modal when query string is present --- assets/js/local.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/assets/js/local.js b/assets/js/local.js index edad393..150942a 100644 --- a/assets/js/local.js +++ b/assets/js/local.js @@ -60,4 +60,24 @@ window.location.href = pageUrl+$input.attr('name')+'='+$input.val() }) + $(document).render(function () { + setTimeout(function () { + const $body = $('body'), + params = new Proxy(new URLSearchParams(window.location.search), { + get: (searchParams, prop) => searchParams.get(prop), + }); + + if (!params || !params.menuId) return; + + const $button = $(''); + + $body.prepend($button); + $button.trigger('click'); + + const uri = window.location.href.toString(), + cleanUri = uri.substring(0, uri.indexOf("?")); + + window.history.replaceState({}, document.title, cleanUri); + }, 500); + }); }(jQuery)