From b4af716bcbab820117cbf1c5e9e6c88c340a5e42 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 24 Apr 2015 12:12:57 +0200 Subject: [PATCH] Bug 11890: Click events on titles does not work as expected The browse results feature (bug 10404) modified the click events on titles on the search result page (intranet). It introduced bad behaviors: 1/ ctrl+click on a title does not open a new tab 2/ middle click on a title does open a new tab but the browser is not displayed. Note that this patch is not perfect, it fixes the 2 bad behaviors but the ctrl+click gives the focus to the new tab (could go against the preferences of the users). Test plan: 1/ On the staff interface, launch a search (catalogue/search.pl?q=XXX) 2/ When middle-clicking on a title, a new tab should open. On this tab the browse result feature should be displayed 3/ Same for cltr+click --- koha-tmpl/intranet-tmpl/js/browser.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/js/browser.js b/koha-tmpl/intranet-tmpl/js/browser.js index b0676a5..81033ea 100644 --- a/koha-tmpl/intranet-tmpl/js/browser.js +++ b/koha-tmpl/intranet-tmpl/js/browser.js @@ -60,9 +60,19 @@ KOHA.browser = function (searchid, biblionumber) { } $.cookie(me.searchid, JSON.stringify(me.searchCookie), { path: '/' }); $(document).ready(function () { - $('#searchresults table tr a[href*="detail.pl"]').click(function (ev) { - ev.preventDefault(); - window.location = $(this).attr('href') + '&searchid=' + me.searchid; + //FIXME It's not a good idea to modify the click events + $('#searchresults table tr a[href*="detail.pl"]').on('mousedown', function (ev) { + if ( ev.which == 2 || ev.which == 1 && ev.ctrlKey ) { + // Middle click or ctrl + click + ev.preventDefault(); + var newwindow = window.open( $(this).attr('href') + '&searchid=' + me.searchid, '_blank' ) + newwindow.blur(); + window.focus(); + } else if ( ev.which == 1 ) { + // Left click + ev.preventDefault(); + window.location = $(this).attr('href') + '&searchid=' + me.searchid; + } }); }); }; -- 2.1.0