Bug 11563: (follow-up) remove some tabs
[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().on( "tabsactivate", function(e, ui) { $(this).find("div:visible").find('input').eq(0).focus(); });
8
9     $(".close").click(function(){ window.close(); });
10
11     if($("#header_search #checkin_search").length > 0){ shortcut.add('Alt+r',function (){ $("#header_search").tabs("select","#checkin_search"); $("#ret_barcode").focus(); }); } else { shortcut.add('Alt+r',function (){ location.href="/cgi-bin/koha/circ/returns.pl"; }); }
12     if($("#header_search #circ_search").length > 0){ shortcut.add('Alt+u',function (){ $("#header_search").tabs("select","#circ_search"); $("#findborrower").focus(); }); } else { shortcut.add('Alt+u',function(){ location.href="/cgi-bin/koha/circ/circulation.pl"; }); }
13     if($("#header_search #catalog_search").length > 0){ shortcut.add('Alt+q',function (){ $("#header_search").tabs("select","#catalog_search"); $("#search-form").focus(); }); } else { shortcut.add('Alt+q',function(){ location.href="/cgi-bin/koha/catalogue/search.pl"; }); }
14
15     $(".focus").focus();
16     $(".validated").each(function() {
17         $(this).validate();
18     });
19
20     $("#logout").on("click",function(){
21         logOut();
22     });
23     $("#helper").on("click",function(){
24         openHelp();
25         return false;
26     });
27
28     $("body").on("keypress", ".noEnterSubmit", function(e){
29         return checkEnter(e);
30     });
31 });
32
33 // http://jennifermadden.com/javascript/stringEnterKeyDetector.html
34 function checkEnter(e){ //e is event object passed from function invocation
35     var characterCode; // literal character code will be stored in this variable
36     if(e && e.which){ //if which property of event object is supported (NN4)
37         e = e;
38         characterCode = e.which; //character code is contained in NN4's which property
39     } else {
40         e = window.event;
41         characterCode = e.keyCode; //character code is contained in IE's keyCode property
42     }
43
44     if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
45         return false;
46     } else {
47         return true;
48     }
49 }
50
51 function clearHoldFor(){
52         $.cookie("holdfor",null, { path: "/", expires: 0 });
53 }
54
55 function logOut(){
56     if( typeof delBasket == 'function' ){
57         delBasket('main', true);
58     }
59     clearHoldFor();
60 }
61
62 function openHelp(){
63     openWindow("/cgi-bin/koha/help.pl","Koha help",600,600);
64 }
65
66 jQuery.fn.preventDoubleFormSubmit = function() {
67     jQuery(this).submit(function() {
68     $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting');
69         if (this.beenSubmitted)
70             return false;
71         else
72             this.beenSubmitted = true;
73     });
74 };
75
76 function openWindow(link,name,width,height) {
77     name = (typeof name == "undefined")?'popup':name;
78     width = (typeof width == "undefined")?'600':width;
79     height = (typeof height == "undefined")?'400':height;
80     var newin=window.open(link,name,'width='+width+',height='+height+',resizable=yes,toolbar=false,scrollbars=yes,top');
81 }
82
83 // Use this function to remove the focus from any element for
84 // repeated scanning actions on errors so the librarian doesn't
85 // continue scanning and miss the error.
86 function removeFocus() {
87     $(':focus').blur();
88 }
89
90 function toUC(f) {
91     var x=f.value.toUpperCase();
92     f.value=x;
93     return true;
94 }
95
96 function confirmDelete(message) {
97     return (confirm(message) ? true : false);
98 }