From fed3353a364b529c0304c00b4ab2915cd455571b Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 30 Apr 2024 17:56:13 +0000 Subject: [PATCH] Bug 36651: Add placeholder text to the search bar in the OPAC This patch adds placeholder text to the OPAC search bar, with JavaScript to change the placeholder based on the user's search type selection. To test, apply the patch and go to the OPAC. - The search bar should by default have the placeholder "Search the catalog by keyword" - Change the search type (Author, Title, etc). The placeholder text should change accordingly. Signed-off-by: Pedro Amorim --- .../bootstrap/en/includes/masthead.inc | 41 ++++++++++--------- koha-tmpl/opac-tmpl/bootstrap/js/global.js | 12 +++++- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 682a0656a8..624b5a4df0 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -4,6 +4,7 @@ [% USE Categories %] [% USE AuthClient %] [% USE AdditionalContents %] +[% PROCESS 'i18n.inc' %] [% PROCESS 'html_helpers.inc' %] [% IF Koha.Preference( 'CookieConsent' ) %] [% USE JSConsents %] @@ -192,51 +193,51 @@
@@ -244,9 +245,9 @@
[% IF ( !Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 && mylibraryfirst ) %] - + [% ELSE %] - + [% END # /ms_value %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/global.js b/koha-tmpl/opac-tmpl/bootstrap/js/global.js index 9a48e3a8f5..694239e95a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/global.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/global.js @@ -249,7 +249,12 @@ var facetHandler = function (e) { $(".menu-collapse").toggle(); }; -$(document).ready(function () { +function setPlaceholder(){ + let search_placeholder = $("#masthead_search option:selected").data("placeholder"); + $("#translControl1").attr("placeholder", search_placeholder ); +} + +$(document).ready(function(){ $("html").removeClass("no-js").addClass("js"); $(".close").click(function () { window.close(); @@ -337,4 +342,9 @@ $(document).ready(function () { e.preventDefault(); $("html,body").animate({ scrollTop: 0 }, "slow"); }); + + setPlaceholder(); + $("#masthead_search").on("change", function(){ + setPlaceholder(); + }); }); -- 2.34.1