From ea4288b064fe38c5eef70e61604b44cce9ef6f47 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 29 Jul 2020 20:06:28 +0200 Subject: [PATCH 1/3] #12 Fixed issue that last dropdown will pop in wrong position --- enhancements/quickSearch.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/enhancements/quickSearch.js b/enhancements/quickSearch.js index 212e7aa..8468276 100644 --- a/enhancements/quickSearch.js +++ b/enhancements/quickSearch.js @@ -33,6 +33,9 @@ function initSearch() { // register focus hotkey document.addEventListener('keypress', event => handleSearchForShiftF(event)); + + // additionally, the last dropdown ul has a "right: 0px" style, which has to be fixed with auto, otherwhise it will pop up in the wrong position + Array.from(menu.querySelectorAll('ul.dropdown')).slice(-1)[0].style.right = 'auto'; } function handleQuickSearch(event) { @@ -44,6 +47,7 @@ function handleQuickSearch(event) { url.pathname = '/search'; url.searchParams.append('q', quickSearchElement.value); + // clicking the link; we are not setting window.location because this will trigger a complete reload of the site linkElement.href = `${url.pathname}${url.search}`; linkElement.click(); -- 2.43.4 From 5f63ecb33620234aca0e357ffd2a0a2f69d60d89 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Tue, 4 Aug 2020 11:36:17 +0200 Subject: [PATCH 2/3] #23 Run script directly if page already loaded (cherry picked from commit 8460c862e97866e43e06e7624b2ce4f38d0ecd0d) --- utils/aniwatchCore.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/utils/aniwatchCore.js b/utils/aniwatchCore.js index 4552c98..1a6d3b1 100644 --- a/utils/aniwatchCore.js +++ b/utils/aniwatchCore.js @@ -27,16 +27,33 @@ observer.observe(document.documentElement || document.body, { attributes: true }); +function findPreloader() { + return document.getElementById('preloader'); +} + function runAfterLoad(func, pattern = '.*') { - __afterLoadScripts.push({ "function": func, "pattern": pattern }); + if (findPreloader()) { + __afterLoadScripts.push({ "function": func, "pattern": pattern }); + } else { + func(); + } } document.addEventListener("DOMContentLoaded", event => awaitPageLoaded(), false); function awaitPageLoaded() { - let preLoader = document.getElementById('preloader'); + let preLoader = findPreloader(); + + let runScripts = () => { + __afterLoadScripts.forEach(script => { + if (window.location.pathname.match(script.pattern)) { + script.function(); + } + }); + }; if (typeof preLoader === 'undefined') { + runScripts(); return; } @@ -44,11 +61,7 @@ function awaitPageLoaded() { if (preLoader.style.display === "none") { clearInterval(loop); - __afterLoadScripts.forEach(script => { - if (window.location.pathname.match(script.pattern)) { - script.function(); - } - }) + runScripts(); } }, 100); } \ No newline at end of file -- 2.43.4 From 324b3f5c76f7580c1586e23c83a308495fe61b37 Mon Sep 17 00:00:00 2001 From: Serraniel Date: Wed, 5 Aug 2020 12:25:08 +0200 Subject: [PATCH 3/3] #23 Fix if preloader always hidden Previous if statement did not work because it still was found in DOM so it only was pushed into the array but not executed. --- utils/aniwatchCore.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/aniwatchCore.js b/utils/aniwatchCore.js index 1a6d3b1..1951dc7 100644 --- a/utils/aniwatchCore.js +++ b/utils/aniwatchCore.js @@ -32,7 +32,8 @@ function findPreloader() { } function runAfterLoad(func, pattern = '.*') { - if (findPreloader()) { + let preloader = findPreloader(); + if (typeof preloader !== undefined && preloader.style.display !== "none") { __afterLoadScripts.push({ "function": func, "pattern": pattern }); } else { func(); -- 2.43.4