From e834b6e1bc46faefc09f527884d0729d68133ccb Mon Sep 17 00:00:00 2001 From: Laura_Escamilla Date: Fri, 29 Aug 2025 15:56:49 +0000 Subject: [PATCH] Bug 38643: Added JS for the dynamic placeholders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To test: 1. Visit http://localhost:8080/cgi-bin/koha/opac-main.pl — notice that the main search bar has a placeholder. 2. Visit the advanced search page. Notice that the search bars in the advanced search do not have placeholders. 3. Apply this patch. restart_all 4. Refresh the page on the advanced search. Notice that the search bars now have placeholders. Try switching out the dropdown options and notice that the placeholder text changes depending on what you select. 5. Test searches and make sure everything works as expected. 6. Sign off — have an amazing day! :D Signed-off-by: Ludovic Signed-off-by: Owen Leonard Signed-off-by: Nick Clemens --- koha-tmpl/opac-tmpl/bootstrap/js/global.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/global.js b/koha-tmpl/opac-tmpl/bootstrap/js/global.js index 15fc44db361..1c980d7d405 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/global.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/global.js @@ -265,6 +265,22 @@ function setPlaceholder() { $("#translControl1").attr("placeholder", search_placeholder); } +function setAdvancedPlaceholder(selectEl) { + var $select = $(selectEl); + var $row = $select.closest(".search-term-row"); + var $input = $row.find("input[name='q']"); + var ph = $select.find("option:selected").data("placeholder"); + $input.attr("placeholder", ph || _("Enter search terms")); +} + +$(".advanced-search-terms select[name='idx']").each(function () { + setAdvancedPlaceholder(this); +}); + +$(".advanced-search-terms").on("change", "select[name='idx']", function () { + setAdvancedPlaceholder(this); +}); + $(document).ready(function () { //check if sticky element is stuck, if so add floating class if ($(".sticky").length) { -- 2.39.5