1c24875edabb8e09f44c9816f049e591f395fe56
[fa-stable.git] / js / reports.js
1 /**********************************************************************
2     Copyright (C) FrontAccounting, LLC.
3         Released under the terms of the GNU General Public License, GPL, 
4         as published by the Free Software Foundation, either version 3 
5         of the License, or (at your option) any later version.
6     This program is distributed in the hope that it will be useful,
7     but WITHOUT ANY WARRANTY; without even the implied warranty of
8     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
9     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ***********************************************************************/
11 var replinks = {
12         'a, button': function(e) { // traverse menu
13                 e.onkeydown = function(ev) { 
14                         ev = ev||window.event;
15                         key = ev.keyCode||ev.which;
16                         if(key==37 || key==38 || key==39 || key==40) {
17                                 move_focus(key, e, document.links);
18                                 ev.returnValue = false;
19                                 return false;
20                         }
21                 }
22         },
23         'a.repopts_link':       function(e) {
24                 e.onclick = function() {
25                     save_focus(this);
26                     set_options(this);
27                         JsHttpRequest.request(this, null);
28                         return false;
29                 }
30         },
31         'a.repclass_link': function(e) {
32                 e.onclick = function() {
33                     save_focus(this);
34                         showClass(this.id.substring(5)); // id=classX
35                         return false;
36                 }
37         }
38 }
39
40 function set_options(e)
41 {
42     var replinks = document.getElementsBySelector('a.repopts_link');
43         for(var i in replinks)
44                 replinks[i].style.fontWeight = replinks[i]==e ? 'bold' : 'normal';
45 }
46
47 function showClass(pClass) {
48         var classes = document.getElementsBySelector('.repclass');
49         for(var i in  classes) {
50                 cl = classes[i];
51                 cl.style.display = (cl.id==('TAB_'+pClass)) ? "block" : "none";
52         }
53         var classlinks = document.getElementsBySelector('a.repclass_link');
54         for(var i in classlinks)
55                 classlinks[i].style.fontWeight = classlinks[i].id == ('class'+pClass) ?
56                         'bold' : 'normal';
57
58     set_options(); // clear optionset links
59         document.getElementById('rep_form').innerHTML = '';
60         return false;
61 }
62
63 Behaviour.register(replinks);