Bug 9783 - can hit submit twice when adding patrons
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / js / staff-global.js
1 // staff-global.js
2 if ( KOHA === undefined ) var KOHA = {};
3
4 function _(s) { return s; } // dummy function for gettext
5
6  $(document).ready(function() {
7     $('#header_search').tabs().bind('tabsshow', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
8         $(".close").click(function(){ window.close(); });
9     if($("#header_search #checkin_search").length > 0){ $(document).bind('keydown','Alt+r',function (){ $("#header_search").tabs("select","#checkin_search"); $("#ret_barcode").focus(); }); } else { $(document).bind('keydown','Alt+r',function (){ location.href="/cgi-bin/koha/circ/returns.pl"; }); }
10     if($("#header_search #circ_search").length > 0){ $(document).bind('keydown','Alt+u',function (){ $("#header_search").tabs("select","#circ_search"); $("#findborrower").focus(); }); } else { $(document).bind('keydown','Alt+u',function(){ location.href="/cgi-bin/koha/circ/circulation.pl"; }); }
11     if($("#header_search #catalog_search").length > 0){ $(document).bind('keydown','Alt+q',function (){ $("#header_search").tabs("select","#catalog_search"); $("#search-form").focus(); }); } else { $(document).bind('keydown','Alt+q',function(){ location.href="/cgi-bin/koha/catalogue/search.pl"; }); }
12     $(".focus").focus();
13     $(".validated").validate();
14 });
15
16
17
18 // http://jennifermadden.com/javascript/stringEnterKeyDetector.html
19 function checkEnter(e){ //e is event object passed from function invocation
20         var characterCode; // literal character code will be stored in this variable
21         if(e && e.which){ //if which property of event object is supported (NN4)
22                 e = e;
23                 characterCode = e.which; //character code is contained in NN4's which property
24         } else {
25                 e = event;
26                 characterCode = e.keyCode; //character code is contained in IE's keyCode property
27         }
28
29         if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
30                 return false;
31         } else {
32                 return true;
33         }
34 }
35
36 function clearHoldFor(){
37         $.cookie("holdfor",null, { path: "/", expires: 0 });
38 }
39
40 jQuery.fn.preventDoubleFormSubmit = function() {
41     jQuery(this).submit(function() {
42     $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting');
43         if (this.beenSubmitted)
44             return false;
45         else
46             this.beenSubmitted = true;
47     });
48 };
49
50 function openWindow(link,name,width,height) {
51     name = (typeof name == "undefined")?'popup':name;
52     width = (typeof width == "undefined")?'600':width;
53     height = (typeof height == "undefined")?'400':height;
54     var newin=window.open(link,name,'width='+width+',height='+height+',resizable=yes,toolbar=false,scrollbars=yes,top');
55 }