From ab270c026be06f08745a14d1aea992877d20f812 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 30 Jul 2021 08:51:24 +0000 Subject: [PATCH] Bug 28773: (QA follow-up) Additional changes The work of the first patch was not yet finished. [1] Similar changes to template for Cataloging and Authorities [2] Made a better distinction now between short title on button and long title on menu and modal [3] The short title parameter removes need for previewed var [4] To keep related code closer, moved the dataPreview hidden code Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- .../modules/cataloguing/z3950_auth_search.tt | 4 +- .../en/modules/cataloguing/z3950_search.tt | 6 +-- .../intranet-tmpl/prog/js/z3950_search.js | 40 +++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt index c050f4dda2..d69a8d3e48 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_auth_search.tt @@ -92,8 +92,8 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt index 7c50932a3d..6b8323d5aa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt @@ -168,9 +168,9 @@ diff --git a/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js b/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js index 1e34fd0945..478c2ee21e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js +++ b/koha-tmpl/intranet-tmpl/prog/js/z3950_search.js @@ -1,7 +1,7 @@ /* global __ total_pages */ //z3950_search.js for Authorities, Bib records and Acquisitions module -var last_action, previewed = 0; +var last_action; function validate_goto_page() { var page = $('#goto_page').val(); @@ -108,28 +108,27 @@ $( document ).ready( function() { } }); + $( "#dataPreview" ).on( "hidden", function() { + $( "#dataPreviewLabel" ).html( "" ); + $( "#dataPreview .modal-body" ).html( "
" + __("Loading") + "
" ); + }); + $( "#resultst" ).on("click", ".previewData", function(e) { e.preventDefault(); - previewed = 1; - ChangeLastAction( $(this).attr('title'), 1 ); - var ltitle = $( this ).text(); + ChangeLastAction( $(this).data('action'), $(this).attr('title') ); + var long_title = $( this ).text(); var page = $( this ).attr( "href" ); - $( "#dataPreviewLabel" ).text( ltitle ); + $( "#dataPreviewLabel" ).text( long_title ); $( "#dataPreview .modal-body" ).load( page + " div" ); $( '#dataPreview' ).modal( {show:true} ); }); - $( "#dataPreview" ).on( "hidden", function() { - $( "#dataPreviewLabel" ).html( "" ); - $( "#dataPreview .modal-body" ).html( "
" + __("Loading") + "
" ); - }); - $( "#resultst" ).on("click", ".chosen", function(e) { e.preventDefault(); var action = $(this).data('action'); - ChangeLastAction( action, 0 ); + ChangeLastAction( action ); if( action == 'order' ) window.location = $(this).attr('href'); - else { + else { // import opener.document.location = $(this).attr('href'); window.close(); } @@ -140,18 +139,19 @@ function InitLastAction() { if( $("#resultst").length == 0 ) return; try { last_action = localStorage.getItem('z3950search_last_action'); } catch (err) {} if( last_action ) { - var z3950_action_li = $(".z3950actions:eq(0)").siblings(".dropdown-menu").find("a[data-action='"+last_action+"']"); - if( z3950_action_li.length == 0 ) return; - if( last_action != 'show_marc' ) { - $( ".z3950actions" ).text($(z3950_action_li).text()).data('action', last_action); + // get short title from attr + var short_title = $(".z3950actions:eq(0)").siblings(".dropdown-menu").find("a[data-action='"+last_action+"']").attr('title'); + if( short_title && last_action != 'show_marc' ) { + $( ".z3950actions" ).text( short_title ); } } } -function ChangeLastAction(action, change_text) { +function ChangeLastAction( action, short_title ) { if( last_action && last_action == action ) return; last_action = action; - if( change_text ) $( ".z3950actions" ).text( last_action ); - if( previewed == 0 || change_text == 1 ) - try { localStorage.setItem('z3950search_last_action', last_action); } catch(err) {} + if( short_title ) { // Save choice for preview (MARC or Card) + $( ".z3950actions" ).text( short_title ); + try { localStorage.setItem('z3950search_last_action', last_action ); } catch(err) {} + } } -- 2.39.5