From 822a685cfaad4fa858693c7e4a54f2325b62aff4 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. --- .../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 52a7cec016..731ca2ecdf 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1201,17 +1201,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 %] @@ -1224,19 +1228,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 %] @@ -1357,6 +1360,27 @@ [% END %][%# end of items_table block %] + + + [% BLOCK jsinclude %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] @@ -1602,15 +1626,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(); @@ -1914,6 +1929,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.20.1