From e359f8d88fe75af26f2ae5de83ce77d581015aa9 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 12 Jun 2017 11:49:37 +0000 Subject: [PATCH] Bug 17893 - Move JavaScript to the footer on staff client catalog pages This patch modifies multiple catalog-related pages in order to move embedded JavaScript to the footer. The JavaScript previously embedded in cat-toolbar.inc is moved to a separate file (catalog.js). To test, apply the patch and test JavaScript-driven interactions on all modified pages, including JS which isn't page-specific (menus, help, etc). The functionality of the catalog toolbar should be tested on each page. - Bibliographic detail pages (standard, MARC, labeled MARC, ISBD). - Advanced search page - Local cover image viewer - Item search page - Item detail page - Search history page - Checkout history page https://bugs.koha-community.org/show_bug.cgi?id=17839 --- .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 129 +---- .../prog/en/includes/catalog-strings.inc | 30 + .../prog/en/modules/catalogue/ISBDdetail.tt | 29 +- .../prog/en/modules/catalogue/MARCdetail.tt | 48 +- .../prog/en/modules/catalogue/advsearch.tt | 52 +- .../prog/en/modules/catalogue/detail.tt | 606 ++++++++++----------- .../prog/en/modules/catalogue/imageviewer.tt | 42 +- .../prog/en/modules/catalogue/issuehistory.tt | 30 +- .../prog/en/modules/catalogue/itemsearch.tt | 474 ++++++++-------- .../prog/en/modules/catalogue/labeledMARCdetail.tt | 49 +- .../prog/en/modules/catalogue/moredetail.tt | 22 +- .../prog/en/modules/catalogue/search-history.tt | 218 ++++---- koha-tmpl/intranet-tmpl/prog/js/catalog.js | 112 ++++ 13 files changed, 937 insertions(+), 904 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc create mode 100644 koha-tmpl/intranet-tmpl/prog/js/catalog.js diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index 3d6b23b..5833978 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -1,130 +1,3 @@ - -
[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || @@ -195,7 +68,7 @@ CAN_user_serials_create_subscription ) %] [% IF ( count ) %]
  • Delete record
  • [% ELSE %] -
  • Delete record
  • +
  • Delete record
  • [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc new file mode 100644 index 0000000..5e92ac0 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc @@ -0,0 +1,30 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt index abe3ea2..eb76911 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/ISBDdetail.tt @@ -1,23 +1,13 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Catalog › [% IF ( unknownbiblionumber ) %] Unknown record [% ELSE %] - ISBD details for [% title | html %] + ISBD details [% END %] [% INCLUDE 'doc-head-close.inc' %] -[% INCLUDE 'browser-strings.inc' %] - - - @@ -28,7 +18,7 @@ [% IF ( unknownbiblionumber ) %] Unknown record [% ELSE %] - ISBD details for [% biblionumber %] + ISBD details [% END %]
    @@ -55,5 +45,16 @@ [% END %] - + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'catalog-strings.inc' %] + + [% INCLUDE 'browser-strings.inc' %] + + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt index 004d77f..abc6266 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/MARCdetail.tt @@ -1,3 +1,4 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Catalog › [% IF ( unknownbiblionumber ) %] @@ -7,31 +8,8 @@ [% END %] [% INCLUDE 'doc-head-close.inc' %] -[% INCLUDE 'browser-strings.inc' %] - - - + [% INCLUDE 'header.inc' %] @@ -197,4 +175,26 @@ function Changefwk(FwkList) { [% END %] +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'catalog-strings.inc' %] + + [% INCLUDE 'browser-strings.inc' %] + + +[% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index 6a7e045..8425f59 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -1,27 +1,10 @@ [% USE Branches %] +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Catalog › Advanced search [% INCLUDE 'doc-head-close.inc' %] - - + [% INCLUDE 'header.inc' %] [% INCLUDE 'adv-search.inc' %] @@ -253,7 +236,7 @@
    -

    [%# FIXME Should not we filter the libraries displayed? %] [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %] @@ -286,4 +269,33 @@ +[% MACRO jsinclude BLOCK %] + + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 1c26c37..be5932b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -23,8 +23,8 @@ [% END %] [% END %] +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] -[% INCLUDE 'greybox.inc' %] Koha › Catalog › [% IF ( unknownbiblionumber ) %] Unknown record @@ -32,316 +32,8 @@ Details for [% title |html %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield | html %][% END %] [% END %] - -[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && ( normalized_isbn || normalized_upc ) ) %] - -[% END %] - -[% INCLUDE 'doc-head-close.inc' %] +[% INCLUDE 'doc-head-close.inc' %] -[% INCLUDE 'datatables.inc' %] - -[% INCLUDE 'browser-strings.inc' %] - - - @@ -1154,4 +846,298 @@ function verify_images() { [% END %] +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'catalog-strings.inc' %] + + [% INCLUDE 'greybox.inc' %] + + [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectProfile') && ( normalized_isbn || normalized_upc ) ) %] + + [% END %] + [% INCLUDE 'datatables.inc' %] + + [% INCLUDE 'browser-strings.inc' %] + + +[% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt index 7e6fffd..09ea60f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt @@ -1,26 +1,8 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Catalog › Details for [% biblio.title |html %] [% FOREACH subtitl IN subtitle %] [% subtitl.subfield %][% END %] [% INCLUDE 'doc-head-close.inc' %] [% IF ( LocalCoverImages == 1 ) %] - -[% INCLUDE 'browser-strings.inc' %] - - - [% USE KohaDates %] @@ -282,4 +272,14 @@ [% INCLUDE 'biblio-view-menu.inc' %] +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'catalog-strings.inc' %] + + [% INCLUDE 'browser-strings.inc' %] + + +[% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt index f55d4fc..a1bcd46 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt @@ -1,117 +1,12 @@ +[% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] [% USE Koha %] [% USE KohaDates %] Koha › Catalog › Search history [% INCLUDE 'doc-head-close.inc' %] -[% INCLUDE 'datatables.inc' %] - - + [% INCLUDE 'header.inc' %] @@ -295,4 +190,113 @@ function enableCheckboxActions(form){ + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'datatables.inc' %] + + +[% END %] + [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/catalog.js b/koha-tmpl/intranet-tmpl/prog/js/catalog.js new file mode 100644 index 0000000..19ccd52 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/catalog.js @@ -0,0 +1,112 @@ +/* IF ( CAN_user_editcatalogue_edit_catalogue ) */ + /* this function open a popup to search on z3950 server. */ + function PopupZ3950() { + var strQuery = GetZ3950Terms(); + if(strQuery){ + window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=" + biblionumber + strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes'); + } + } + function PopupZ3950Confirmed() { + if (confirm( MSG_REPLACE_RECORD )){ + PopupZ3950(); + } + } +/* END IF( CAN_user_editcatalogue_edit_catalogue ) */ + +function addToCart() { addRecord( biblionumber ); } +function addToShelf() { window.open('/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=' + biblionumber,'Add_to_virtualshelf','width=500,height=400,toolbar=false,scrollbars=yes'); +} +function printBiblio() {window.print(); } + +/* IF CAN_user_editcatalogue_edit_catalogue or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) */ + +function confirm_deletion() { + var order_manage_permission = $(this).data("order-manage"); + var is_confirmed; + if (count > 0){ + is_confirmed = alert( MSG_DELETE_ALL_ITEMS.format(count) ); + } else if (countorders > 0){ + if( order_manage_permission ){ + is_confirmed = confirm( CONFIRM_RECORD_USED_IN_ORDERS.format(countorders) ); + } else { + is_confirmed = alert( MSG_RECORD_USED_IN_ORDERS.format(countorders) ); + } + } else if (countdeletedorders > 0){ + if( order_manage_permission ){ + is_confirmed = confirm( CONFIRM_IN_DELETED_ORDERS.format(countdeletedorders) ); + } else { + is_confirmed = alert( MSG_IN_DELTED_ORDERS.format(countdeletedorders) ); + } + } else if ( holdcount > 0 ) { + is_confirmed = confirm( CONFIRM_DELETION_HOLDS.format(holdcount) ); + } else { + is_confirmed = confirm( CONFIRM_RECORD_DELETION ); + } + if (is_confirmed) { + window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&biblionumber=" + biblionumber; + } else { + return false; + } +} + +/* END IF CAN_user_editcatalogue_edit_catalogue or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) */ + +/* IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) */ + +function confirm_items_deletion() { + if ( holdcount > 0 ) { + alert( MSG_DELETE_ALL_HOLDS.format(holdcount) ); + } else if ( count > 0 ) { + if( confirm( CONFIRM_DELETE_ITEMS.format(count) ) ) { + window.location="/cgi-bin/koha/cataloguing/additem.pl?op=delallitems&biblionumber=" + biblionumber; + } else { + return false; + } + } else { + alertNoItems(); + return false; + } +} + +function alertNoItems(){ + alert( MSG_NO_ITEMS ); +} + +/* END IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) */ + +$(document).ready(function() { + $("#z3950copy").click(function(){ + PopupZ3950(); + return false; + }); + $("#deletebiblio").click(function(){ + confirm_deletion(); + return false; + }); + $("#deleteallitems").click(function(){ + confirm_items_deletion(); + return false; + }); + $("#printbiblio").click(function(){ + printBiblio(); + return false; + }); + $("#addtocart").click(function(){ + addToCart(); + $(".btn-group").removeClass("open"); + return false; + }); + $("#addtoshelf").click(function(){ + addToShelf(); + $(".btn-group").removeClass("open"); + return false; + }); + $("#export").remove(); // Hide embedded export form if JS menus available + $("#deletebiblio").tooltip(); + $("#batchedit-disabled,#batchdelete-disabled,#deleteallitems-disabled") + .on("click",function(e){ + e.preventDefault(); + alertNoItems(); + }) + .tooltip(); + }); -- 2.1.4