Merge commit 'pianohacker-koha/prefs-submit' into master
[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         $(".focus").focus();
8         $('#header_search > ul').tabs().bind('show.ui-tabs', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
9         $(".close").click(function(){ window.close(); });
10         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"; }); }
11         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"; }); }
12         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"; }); }
13  });
14  
15              YAHOO.util.Event.onContentReady("header", function () {
16                                 var oMoremenu = new YAHOO.widget.Menu("moremenu", { zindex: 2 });
17
18                                 function positionoMoremenu() {
19                                         oMoremenu.align("tl", "bl");
20                                 }
21
22                 oMoremenu.subscribe("beforeShow", function () {
23                     if (this.getRoot() == this) {
24                                                 positionoMoremenu();
25                     }
26                 });
27
28                                 oMoremenu.render();
29
30                 oMoremenu.cfg.setProperty("context", ["showmore", "tl", "bl"]);
31
32                                 function onShowMoreClick(p_oEvent) {
33                     // Position and display the menu        
34                     positionoMoremenu();
35                         $("#moremenu").show();
36                     oMoremenu.show();
37                     // Stop propagation and prevent the default "click" behavior
38                     YAHOO.util.Event.stopEvent(p_oEvent);       
39                                 }
40
41                                 YAHOO.util.Event.addListener("showmore", "click", onShowMoreClick);
42
43                 YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMoremenu);
44             });
45
46 YAHOO.util.Event.onContentReady("changelanguage", function () {
47                 var oMenu = new YAHOO.widget.Menu("sublangs", { zindex: 2 });
48
49                     function positionoMenu() {
50                     oMenu.align("bl", "tl");
51                 }
52
53                 oMenu.subscribe("beforeShow", function () {
54                     if (this.getRoot() == this) {
55                                                 positionoMenu();
56                     }
57                 });
58
59                 oMenu.render();
60
61                                 oMenu.cfg.setProperty("context", ["showlang", "bl", "tl"]);
62
63                                 function onYahooClick(p_oEvent) {
64                     // Position and display the menu        
65                     positionoMenu();
66                     oMenu.show();
67                     // Stop propagation and prevent the default "click" behavior
68                     YAHOO.util.Event.stopEvent(p_oEvent);
69                 }
70
71                                 YAHOO.util.Event.addListener("showlang", "click", onYahooClick);
72
73                                 YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMenu);
74             });
75                         
76 // http://jennifermadden.com/javascript/stringEnterKeyDetector.html
77 function checkEnter(e){ //e is event object passed from function invocation
78         var characterCode; // literal character code will be stored in this variable
79         if(e && e.which){ //if which property of event object is supported (NN4)
80                 e = e;
81                 characterCode = e.which; //character code is contained in NN4's which property
82         } else {
83                 e = event;
84                 characterCode = e.keyCode; //character code is contained in IE's keyCode property
85         }
86
87         if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
88                 return false;
89         } else {
90                 return true;
91         }
92 }