From 0b1df4fe48e00b40e9abd2180a064ec80277b188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Ba=C3=B1ados=20Schwerter?= Date: Tue, 17 Dec 2024 22:49:09 +0000 Subject: [PATCH] Added refocusing after clicking on next wordnet sense --- frontend/index.js | 15 +++++++++++++++ .../templates/morphodict/wordnet-results.html | 10 ++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/frontend/index.js b/frontend/index.js index 0cf9dbd03..14a5a586a 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -70,6 +70,7 @@ document.addEventListener("DOMContentLoaded", () => { } else if (route === "/search") { // Search page prepareSearchResults(getSearchResultList()); + setupRefocus(); } else if (route.match(/^[/]word[/].+/)) { // Word detail/paradigm page. This one has the 🔊 button. setSubtitle(getEntryHead()); @@ -330,3 +331,17 @@ function createAudioButton(recordingURL, element) { function getSearchResultList() { return document.getElementById("search-result-list"); } + +function setupRefocus(){ + // add an action on click to refocus when data-md-focus is available + document.querySelectorAll("[data-md-focus]").forEach((object) => { + let focus_obj = document.getElementById(object.getAttribute("data-md-focus")) + focus_obj.addEventListener("shown.bs.collapse", function(){ + focus_obj.scrollIntoView({ + beahior:"smooth", + block:"start", + inline:"start" + }); + }) + }) +} \ No newline at end of file diff --git a/src/morphodict/frontend/templates/morphodict/wordnet-results.html b/src/morphodict/frontend/templates/morphodict/wordnet-results.html index 8534059a4..1fb0db67e 100644 --- a/src/morphodict/frontend/templates/morphodict/wordnet-results.html +++ b/src/morphodict/frontend/templates/morphodict/wordnet-results.html @@ -7,12 +7,12 @@

Messages from search run

{{ verbose_messages }}
{% endif %} -
+
{% for result in search_results %} {% with has_more=search_results|has_next:forloop.counter0 %} {% with has_previous=search_results|has_previous:forloop.counter0 %} -
+

{{result.wn_entry.numbering}}. {{result.wn_entry.original_str}} ({% relabel_one result.wn_entry.paren_pos %})

@@ -27,13 +27,15 @@

{{result.wn_entry.numbering}}. {{result.wn_entr
{% if has_previous %} {% with previous_element=search_results|previous:forloop.counter0 %} - + {% endwith %} {% endif %} {% if has_more %} {% with next_element=search_results|next:forloop.counter0 %} - + {% endwith %} {% endif %}