From b0793ec34c7b4665b04d80694709869e2e197727 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 7 Oct 2013 14:45:06 -0400 Subject: [PATCH] Bug 10309: (follow-up) Update for Bug 10856, improve shelf browser This patch updates this theme with the changes made in Bug 10856. Because of the way JavaScript is loaded in the new theme, the JS in the shelfbrowser include had to be moved to the opac-detail template. Test plan from that bug: - On a detail biblio page, click on a "Browse shelf" link. - Play with the next and previous links. - Deactivate Javascript (using NoScript for example) and check that you get the same behavior (but the page is reloaded). - Launch the unit tests: prove t/db_dependent/ShelfBrowser.t Signed-off-by: Bernardo Gonzalez Kriegel Works well. No errors Disabled JavaScript on Firefox (about:config, javascript.enable -> false) Browse shelf works by reloading. Unit test report success. Signed-off-by: Galen Charlton --- koha-tmpl/opac-tmpl/bootstrap/css/opac.css | 44 ++++ .../bootstrap/en/includes/shelfbrowser.inc | 86 ++++++++ .../bootstrap/en/modules/opac-detail.tt | 195 ++++++------------ .../bootstrap/en/modules/svc/shelfbrowser.tt | 2 + koha-tmpl/opac-tmpl/bootstrap/less/opac.less | 46 +++++ 5 files changed, 238 insertions(+), 135 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/svc/shelfbrowser.tt diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/opac.css b/koha-tmpl/opac-tmpl/bootstrap/css/opac.css index 15cfbc91cf..a56dbc3172 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/css/opac.css +++ b/koha-tmpl/opac-tmpl/bootstrap/css/opac.css @@ -2146,6 +2146,50 @@ td img { display: block; overflow: auto; } +#shelfbrowser table { + margin: 0; +} +#shelfbrowser table, +#shelfbrowser td, +#shelfbrowser th { + border: 0; + font-size: 90%; + text-align: center; +} +#shelfbrowser td, +#shelfbrowser th { + padding: 3px 5px; + width: 20%; +} +#shelfbrowser a { + display: block; + font-size: 110%; + font-weight: bold; + text-decoration: none; +} +#shelfbrowser #browser_next, +#shelfbrowser #browser_previous { + background-image: url("../images/sprite.png"); + background-repeat: no-repeat; + width: 16px; +} +#shelfbrowser #browser_next a, +#shelfbrowser #browser_previous a { + cursor: pointer; + display: block; + height: 0 !important; + margin: 0; + overflow: hidden; + padding: 50px 0 0; + text-decoration: none; + width: 16px; +} +#shelfbrowser #browser_previous { + background-position: -9px -1007px; +} +#shelfbrowser #browser_next { + background-position: -9px -1057px; +} .shadowed { -webkit-box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.2); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc new file mode 100644 index 0000000000..bc5ef2c2a8 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc @@ -0,0 +1,86 @@ +[% BLOCK shelfbrowser %] + [% IF OpenOPACShelfBrowser %] +
+
+ [% IF ( starting_homebranch ) %]Browsing [% starting_homebranch %] Shelves[% END %] + [% IF ( starting_location ) %], Shelving location: [% starting_location %][% END %] + [% IF ( starting_ccode ) %], Collection code: [% starting_ccode %][% END %] + Close shelf browser +
+ + + + + + [% FOREACH item IN shelfbrowser_items %] + + [% END %] + + + + + [% FOREACH item IN shelfbrowser_items %] + + [% END %] + +
+ [% IF shelfbrowser_prev_item %] +
+ Previous +
+ [% END %] +
+ + [% IF ( OPACLocalCoverImages ) %] +
+ [% END %] + [% IF ( OPACAmazonCoverImages ) %] + [% IF ( item.browser_normalized_isbn ) %] + + [% ELSE %] + No cover image available + [% END %] + [% END %] + + [% IF ( SyndeticsEnabled ) %] + [% IF ( SyndeticsCoverImages ) %] + [% IF ( content_identifier_exists ) %] + [% IF ( using_https ) %] + + [% ELSE %] + + [% END %] + [% ELSE %] + No cover image available + [% END %] + [% END %] + [% END %] + + [% IF ( GoogleJackets ) %] + [% IF ( item.browser_normalized_isbn ) %] +
+ [% ELSE %] + No cover image available + [% END %] + [% END %] + [% IF ( BakerTaylorEnabled ) %] + [% IF ( item.browser_normalized_isbn ) %] + See Baker & Taylor + [% ELSE %] + No cover image available + [% END %] + [% END %] +
+
+ [% IF shelfbrowser_next_item %] +
+ Next +
+ [% END %] +
+ [% item.itemcallnumber %] + [% item.title |html %] +
+
+ [% END # /IF OpenOPACShelfBrowser %] +[% END # end of shelfbrowser block %] \ No newline at end of file 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 5e03941f84..8b7cfddf0e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -647,7 +647,7 @@
No physical items for this record
[% END %] [% END # IF itemloop.size %] - + [% PROCESS 'shelfbrowser.inc' %] [% INCLUDE shelfbrowser tab='holdings' %]
@@ -1170,7 +1170,11 @@ [% IF ( ITEM_RESULT.itemcallnumber ) %] [% ITEM_RESULT.itemcallnumber %] [% IF ( OPACShelfBrowser ) %] - (Browse shelf) + [% IF ( ITEM_RESULT.itemnumber == starting_itemnumber ) %] + (Browse shelf) + [% ELSE %] + (Browse shelf) + [% END %] [% END %] [% END %] @@ -1227,139 +1231,6 @@ [% END %][%# end of items_table block %] -[% BLOCK shelfbrowser %] - [% IF ( OpenOPACShelfBrowser and shelfbrowser_tab == tab) %] -
-
- [% IF ( starting_homebranch ) %]Browsing [% starting_homebranch %] Shelves[% END %] - [% IF ( starting_location ) %], Shelving location: [% starting_location %][% END %] - [% IF ( starting_ccode ) %], Collection code: [% starting_ccode %][% END %] - Close shelf browser -
- - - - - [% FOREACH PREVIOUS_SHELF_BROWS IN PREVIOUS_SHELF_BROWSE %] - - [% END %] - - [% FOREACH NEXT_SHELF_BROWS IN NEXT_SHELF_BROWSE %] - - [% END %] - - - - - - [% FOREACH PREVIOUS_SHELF_BROWS IN PREVIOUS_SHELF_BROWSE %] - - [% END %] - - [% FOREACH NEXT_SHELF_BROWS IN NEXT_SHELF_BROWSE %] - - [% END %] - -
-
- Previous -
-
- - [% IF ( OPACLocalCoverImages ) %] -
- [% END %] - [% IF ( OPACAmazonCoverImages ) %] - [% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_isbn ) %] - - [% ELSE %] - No cover image available - [% END %] - [% END %] - [% IF ( SyndeticsEnabled ) %] - [% IF ( SyndeticsCoverImages ) %] - [% IF ( content_identifier_exists ) %] - [% IF ( using_https ) %] - - [% ELSE %] - - [% END %] - [% ELSE %] - No cover image available - [% END %] - [% END %] - [% END %] - [% IF ( GoogleJackets ) %] - [% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_isbn ) %] -
- [% ELSE %] - No cover image available - [% END %] - [% END %] - [% IF ( BakerTaylorEnabled ) %] - [% IF ( PREVIOUS_SHELF_BROWS.browser_normalized_isbn ) %] - See Baker & Taylor - [% ELSE %] - No cover image available - [% END %] - [% END %] -
-
- - [% IF ( OPACLocalCoverImages ) %] -
- [% END %] - [% IF ( OPACAmazonCoverImages ) %] - [% IF ( NEXT_SHELF_BROWS.browser_normalized_isbn ) %] - - [% ELSE %] - No cover image available - [% END %] - [% END %] - - [% IF ( SyndeticsEnabled ) %] - [% IF ( SyndeticsCoverImages ) %] - [% IF ( content_identifier_exists ) %] - [% IF ( using_https ) %] - - [% ELSE %] - - [% END %] - [% ELSE %] - No cover image available - [% END %] - [% END %] - [% END %] - - [% IF ( GoogleJackets ) %] - [% IF ( NEXT_SHELF_BROWS.browser_normalized_isbn ) %] -
- [% ELSE %] - No cover image available - [% END %] - [% END %] - [% IF ( BakerTaylorEnabled ) %] - [% IF ( NEXT_SHELF_BROWS.browser_normalized_isbn ) %] - See Baker & Taylor - [% ELSE %] - No cover image available - [% END %] - [% END %] -
-
-
- Next -
-
- [% PREVIOUS_SHELF_BROWS.itemcallnumber %] - [% PREVIOUS_SHELF_BROWS.title |html %] - - [% NEXT_SHELF_BROWS.itemcallnumber %] - [% NEXT_SHELF_BROWS.title |html %] -
-
- [% END %] -[% END # end of shelfbrowser block %] [% BLOCK jsinclude %] [% INCLUDE 'datatables.inc' %] [% IF ( SocialNetworks ) %] @@ -1514,7 +1385,61 @@ navigation.hide(); }); [% END %] +[% IF ( OPACShelfBrowser ) %] + + (function prepareShelfBrowser(){ + + $(".main").on("click",".close_shelf",function(e){ + e.preventDefault(); + $("#shelfbrowser").toggle(); + }); + $(".main").on("click", "#browser_previous a", function(e){ + e.preventDefault(); + $.ajax({ + url: "/cgi-bin/koha/svc/shelfbrowser.pl", + type: "POST", + data: { + "shelfbrowse_itemnumber": $("#browser_previous a").data( "prev-itemnumber" ) + }, + success: function(data){ + $("#shelfbrowser").replaceWith(data); + [% IF ( GoogleJackets ) %] + KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); + [% END %] + [% IF OpenLibraryCovers %] + KOHA.OpenLibrary.GetCoverFromIsbn(); + [% END %] + [% IF OPACLocalCoverImages %] + KOHA.LocalCover.GetCoverFromBibnumber(true); + [% END %] + } + }); + }); + $(".main").on("click", "#browser_next a", function(e){ + e.preventDefault(); + $.ajax({ + url: "/cgi-bin/koha/svc/shelfbrowser.pl", + type: "POST", + data: { + "shelfbrowse_itemnumber": $("#browser_next a").data( "next-itemnumber" ) + }, + success: function(data){ + $("#shelfbrowser").replaceWith(data); + [% IF ( GoogleJackets ) %] + KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); + [% END %] + [% IF OpenLibraryCovers %] + KOHA.OpenLibrary.GetCoverFromIsbn(); + [% END %] + [% IF OPACLocalCoverImages %] + KOHA.LocalCover.GetCoverFromBibnumber(true); + [% END %] + } + }); + }); + }()); +[% END %] [% IF ( OpacStarRatings != 'disable' ) %] // ----------------------------------------------------- // star-ratings code diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/svc/shelfbrowser.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/svc/shelfbrowser.tt new file mode 100644 index 0000000000..50e2b40671 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/svc/shelfbrowser.tt @@ -0,0 +1,2 @@ +[% PROCESS 'shelfbrowser.inc' %] +[% INCLUDE shelfbrowser %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less index d3da6b883d..7424d67f26 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less +++ b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less @@ -2173,4 +2173,50 @@ td img { overflow: auto; } +#shelfbrowser { + table { + margin : 0; + } + table, + td, + th { + border : 0; + font-size : 90%; + text-align : center; + } + td, + th { + padding: 3px 5px; + width : 20%; + } + a { + display : block; + font-size : 110%; + font-weight : bold; + text-decoration : none; + } + #browser_next, + #browser_previous { + background-image : url("../images/sprite.png"); + background-repeat: no-repeat; + width : 16px; + a { + cursor: pointer; + display : block; + height: 0 !important; + margin: 0; + overflow: hidden; + padding: 50px 0 0; + text-decoration: none; + width: 16px; + } + } + #browser_previous { + background-position: -9px -1007px; + } + #browser_next { + background-position: -9px -1057px; + } +} + @import "responsive.less"; -- 2.39.5