More changes to implement jQuery upgrade.
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / js / staff-global.js
1 // staff-global.js
2
3 function _(s) { return s } // dummy function for gettext
4
5  $(document).ready(function() {
6         $(".focus").focus();
7         $('#header_search > ul').tabs().bind('show.ui-tabs', 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 > ul").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 > ul").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 > ul").tabs("select","#catalog_search"); $("#search-form").focus(); }); } else { $(document).bind('keydown','Alt+q',function(){ location.href="/cgi-bin/koha/catalogue/search.pl"; }); }
12  });
13  
14              YAHOO.util.Event.onContentReady("header", function () {
15                                 var oMoremenu = new YAHOO.widget.Menu("moremenu", { zindex: 2 });
16
17                                 function positionoMoremenu() {
18                                         oMoremenu.align("tl", "bl");
19                                 }
20
21                 oMoremenu.subscribe("beforeShow", function () {
22                     if (this.getRoot() == this) {
23                                                 positionoMoremenu();
24                     }
25                 });
26
27                                 oMoremenu.render();
28
29                 oMoremenu.cfg.setProperty("context", ["showmore", "tl", "bl"]);
30
31                                 function onShowMoreClick(p_oEvent) {
32                     // Position and display the menu        
33                     positionoMoremenu();
34                     oMoremenu.show();
35                     // Stop propagation and prevent the default "click" behavior
36                     YAHOO.util.Event.stopEvent(p_oEvent);       
37                                 }
38
39                                 YAHOO.util.Event.addListener("showmore", "click", onShowMoreClick);
40
41                 YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMoremenu);
42             });
43
44 YAHOO.util.Event.onContentReady("changelanguage", function () {
45                 var oMenu = new YAHOO.widget.Menu("sublangs", { zindex: 2 });
46
47                     function positionoMenu() {
48                     oMenu.align("bl", "tl");
49                 }
50
51                 oMenu.subscribe("beforeShow", function () {
52                     if (this.getRoot() == this) {
53                                                 positionoMenu();
54                     }
55                 });
56
57                 oMenu.render();
58
59                                 oMenu.cfg.setProperty("context", ["showlang", "bl", "tl"]);
60
61                                 function onYahooClick(p_oEvent) {
62                     // Position and display the menu        
63                     positionoMenu();
64                     oMenu.show();
65                     // Stop propagation and prevent the default "click" behavior
66                     YAHOO.util.Event.stopEvent(p_oEvent);
67                 }
68
69                                 YAHOO.util.Event.addListener("showlang", "click", onYahooClick);
70
71                                 YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMenu);
72             });
73                         
74 // http://jennifermadden.com/javascript/stringEnterKeyDetector.html
75 function checkEnter(e){ //e is event object passed from function invocation
76         var characterCode; // literal character code will be stored in this variable
77         if(e && e.which){ //if which property of event object is supported (NN4)
78                 e = e;
79                 characterCode = e.which; //character code is contained in NN4's which property
80         } else {
81                 e = event;
82                 characterCode = e.keyCode; //character code is contained in IE's keyCode property
83         }
84
85         if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
86                 return false;
87         } else {
88                 return true;
89         }
90 }