Merge remote-tracking branch 'origin/new/bug_6720'
[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  });
14
15  
16              YAHOO.util.Event.onContentReady("header", function () {
17                                 var oMoremenu = new YAHOO.widget.Menu("moremenu", { zindex: 2 });
18
19                                 function positionoMoremenu() {
20                                         oMoremenu.align("tl", "bl");
21                                 }
22
23                 oMoremenu.subscribe("beforeShow", function () {
24                     if (this.getRoot() == this) {
25                                                 positionoMoremenu();
26                     }
27                 });
28
29                                 oMoremenu.render();
30
31                 oMoremenu.cfg.setProperty("context", ["showmore", "tl", "bl"]);
32
33                                 function onShowMoreClick(p_oEvent) {
34                     // Position and display the menu        
35                     positionoMoremenu();
36                         $("#moremenu").show();
37                     oMoremenu.show();
38                     // Stop propagation and prevent the default "click" behavior
39                     YAHOO.util.Event.stopEvent(p_oEvent);       
40                                 }
41
42                                 YAHOO.util.Event.addListener("showmore", "click", onShowMoreClick);
43
44                 YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMoremenu);
45             });
46
47 // build Change Language menus
48 YAHOO.util.Event.onContentReady("changelanguage", function () {
49         $(".sublangs").each(function(){
50                 var menuid = $(this).attr("id");
51                 var menuid = menuid.replace("show","");
52
53                 var oMenu = new YAHOO.widget.Menu("sub"+menuid, { zindex: 2 });
54                 function positionoMenu() {
55                         oMenu.align("bl", "tl");
56                 }
57                 oMenu.subscribe("beforeShow", function () {
58                 if (this.getRoot() == this) {
59                         positionoMenu();
60                 }
61                 });
62                 oMenu.render();
63                 oMenu.cfg.setProperty("context", ["show"+menuid, "bl", "tl"]);
64                 function onYahooClick(p_oEvent) {
65                         // Position and display the menu
66                         positionoMenu();
67                         oMenu.show();
68                         // Stop propagation and prevent the default "click" behavior
69                         YAHOO.util.Event.stopEvent(p_oEvent);
70                 }
71                 YAHOO.util.Event.addListener("show"+menuid, "click", onYahooClick);
72                 YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMenu);
73         });
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 }
93
94 function clearHoldFor(){
95         $.cookie("holdfor",null, { path: "/", expires: 0 });
96 }
97
98 jQuery.fn.preventDoubleFormSubmit = function() {
99     jQuery(this).submit(function() {
100         if (this.beenSubmitted)
101             return false;
102         else
103             this.beenSubmitted = true;
104     });
105 };
106
107 function openWindow(link,name,width,height) {
108     name = (typeof name == "undefined")?'popup':name;
109     width = (typeof width == "undefined")?'600':width;
110     height = (typeof height == "undefined")?'400':height;
111     var newin=window.open(link,name,'width='+width+',height='+height+',resizable=yes,toolbar=false,scrollbars=yes,top');
112 }