From 35f35c629f593a787fc9cf4d35fd432327fccef5 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 1 Dec 2021 17:47:51 +0000 Subject: [PATCH] Bug 29616: Replace library information popup in the OPAC with a modal This patch modifies the OPAC bibliographic detail page so that information stored in libraries' "OPAC info" field can be displayed in a modal window instead of in a tooltip. This will make it more readable, especially for libraries with so much info content that the popup can disappear off the bottom of the page. To test, apply the patch and make sure you have at least one library configured according to each of these: A. One with both branches.branchurl and branches.opac_info B. One with branches.branchurl but not branches.opac_info C. One with branches.opac_info but not branches.branchurl D. One with neither branches.branchurl nor branches.opac_info View the bibliographic detail page in the OPAC for title(s) which have holdings from the libraries you configured above. In the holdings table, check the behavior of the library name in the "Current library" or "Home library" columns * - Case A: The library name appears as a link with an "info" icon. Clicking it shows the library information in a modal window. In the modal footer, a "Visit web site" button should take you to the correct URL. - Case B: The library name appears as a link without an icon. Clicking the link takes you to the correct URL. - Case C: The library name appears as a link with an "info" icon. Clicking it shows the library information in a modal window. In the modal footer there is no "Visit web site" button. - Case D: The library name is plain text. * Display of "Current library" and/or "Home library" is controlled by the OpacLocationBranchToDisplay system preference. Signed-off-by: Lucas Gass Signed-off-by: The Minh Luong Signed-off-by: Katrin Fischer Signed-off-by: Fridolin Somers --- .../bootstrap/en/modules/opac-detail.tt | 108 +++++++++++++----- 1 file changed, 77 insertions(+), 31 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index c226da6dd0..70df935b51 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1195,17 +1195,21 @@ [% END %] [% IF ( OpacLocationBranchToDisplay == 'holding' || OpacLocationBranchToDisplay == 'both' ) %] - + - - [% IF ( ITEM_RESULT.branchurl ) %] - [% ITEM_RESULT.branchname | html %] - [% ELSE %] - [% ITEM_RESULT.branchname | html %] - [% END %] - -
[% ITEM_RESULT.holding_branch_opac_info | $raw %]
+ + [% IF ( ITEM_RESULT.holding_branch_opac_info ) %] + + [% ITEM_RESULT.branchname | html %] + + [% ELSIF ( ITEM_RESULT.branchurl ) %] + + [% ITEM_RESULT.branchname | html %] + + [% ELSE %] + [% ITEM_RESULT.branchname | html %] + [% END %] [% IF ( Koha.Preference('OpacLocationOnDetail') == 'holding' || Koha.Preference('OpacLocationOnDetail') == 'both' ) %] [% ITEM_RESULT.location_description | html %] @@ -1218,19 +1222,18 @@ - - [% IF Branches.GetURL( ITEM_RESULT.homebranch ) %] - [% home_branch_url = Branches.GetURL( ITEM_RESULT.homebranch ) %] - [% IF ( home_branch_url ) %] - [% Branches.GetName( ITEM_RESULT.homebranch ) | html %] - [% ELSE %] - [% Branches.GetName( ITEM_RESULT.homebranch ) | html %] - [% END %] - [% ELSE %] - [% Branches.GetName( ITEM_RESULT.homebranch ) | html %] - [% END %] - -
[% ITEM_RESULT.home_branch_opac_info | $raw %]
+ + [% IF ( ITEM_RESULT.holding_branch_opac_info ) %] + + [% Branches.GetName( ITEM_RESULT.homebranch ) | html %] + + [% ELSIF ( Branches.GetURL( ITEM_RESULT.homebranch ) ) %] + + [% Branches.GetName( ITEM_RESULT.homebranch ) | html %] + + [% ELSE %] + [% Branches.GetName( ITEM_RESULT.homebranch ) | html %] + [% END %] [% IF ( Koha.Preference('OpacLocationOnDetail') == 'home' || Koha.Preference('OpacLocationOnDetail') == 'both' ) %] [% ITEM_RESULT.location_description | html %] @@ -1351,6 +1354,27 @@ [% END %][%# end of items_table block %] + + + [% BLOCK jsinclude %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -1596,15 +1620,6 @@ [% END # /IF OPACDetailQRCode %] $('#bibliodescriptions').tabs(); - $(".branch-info-tooltip-trigger").uitooltip({ - position: { my: "left+15 center", at: "right center" }, - show: 50, - hide: 50, - content: function(){ - var element = $(this).next("div"); - return element.html(); - } - }); [% IF ( Koha.Preference('OpacBrowseResults') && busc ) %] $(".l_Results").show(); @@ -1908,6 +1923,37 @@ multiSearchRequest(); }); } /* if( OPACPopupAuthorsSearch == "1" ) */ + + $(".library_info").on("click", function(e){ + e.preventDefault(); + var branchcode = $(this).data("branchcode"); + var url = $(this).attr("href"); + $.ajax({ + url: "/api/v1/libraries/" + branchcode, + type: 'GET', + dataType: 'json', + success: function(result) { + $("#libraryInfoModalLabel").html( result.name ); + $("#libraryInfo").html( result.opac_info ); + if( result.url ){ + $("#libraryInfoLink").attr("href", result.url ); + $("#libraryInfoLink").show(); + } else { + $("#libraryInfoLink").hide(); + } + $("#libraryInfoModal").modal("show"); + }, + error: function(xhr, status, error) { + if( url ){ + location.href = url; + } + } + }); + }); + $("#libraryInfoModal").on("hide.bs.modal", function(){ + $("#libraryInfoModalLabel, #libraryInfo").html(""); + $("#libraryInfoLink").attr("href", ""); + }); }); function multiSearchRequest(){ -- 2.39.5