[Koha-devel] MARC tab shortcuts

Stefano Bargioni bargioni at pusc.it
Fri Mar 30 18:23:05 CEST 2012


Something similar was discussed some years ago in
http://koha.1045719.n5.nabble.com/Staff-client-keyboard-shortcuts-td3066327.html

Koha Staff has four pages where MARC tags are grouped under tabs:

catalogue/MARCdetail.pl
cataloguing/addbiblio.pl
authorities/detail.pl
authorities/authorities.pl

I successfully proposed to my cataloguers a way to pass from tab to tab pressing numbers (keyboard or keypad).
The solution (this is for catalogue/MARCdetail.pl):

$(document).ready(function() {

if (location.pathname.indexOf('catalogue/MARCdetail.pl')>-1) {
 $(document).keydown(function(e) {
  if (e.target.tagName == 'INPUT') return;
  if (e.target.tagName == 'TEXTAREA') return;
  var f = 0; // flag
  var c = e.which; // code key pressed
  if (c >= 48 && c <= 57)  {f=1; c -= 48;} // 0..9 keyboard
  if (c >= 96 && c <= 105) {f=1; c -= 96;} // 0..9 keypad
  if (f == 0) return;
  var marc_sections = $('#bibliotabs ul li a').text().replace(/[^0-9]/g,'');
  var marc_section = marc_sections.indexOf(c);
  if (marc_section == -1) return;
  $($('#bibliotabs ul li a')[marc_section]).click();
 });
};

});

We tested it in a lot of Mac browsers, also a very old one like Firefox 3.6.6. It works fine with Koha 3.2.7 and Koha 3.6.1.
I'd like to share the code but I think that we need more testing on Linux and Windows -- keyboard events are managed in a lot of manners by browsers.
To test it, open a record like
http://your_koha.org:8080/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=12345
open the Firebug console, paste the code and try to skip from tab to tab pressing numbers. 
Changing or reloading the record will lose the event capture: paste the code again.
And please let me know.
Thanks. Stefano


More information about the Koha-devel mailing list