Bug 24982: (follow-up) Retain checkbox selections after for submit
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / js / viewlog.js
1 function tickAll(section){
2     $("input[name='" + section + "']").prop("checked", true);
3     $("#" + section.slice(0,-1) + "ALL").prop("checked", true);
4     $("input[name='" + section + "']").prop("disabled", true);
5     $("#" + section.slice(0,-1) + "ALL").prop("disabled", false);
6 }
7
8 function untickAll(section){
9     $("input[name='" + section + "']").prop("checked", false);
10     $("input[name='" + section + "']").prop("disabled", false);
11 }
12
13 $(document).ready(function(){
14
15     if ( $('input[name="modules"]:checked').length == 0 ) {
16         tickAll('modules');
17     }
18     $("#moduleALL").change(function(){
19         if ( this.checked == true ){
20             tickAll('modules');
21         } else {
22             untickAll('modules');
23         }
24     });
25     $("input[name='modules']").change(function(){
26         if ( $("input[name='modules']:checked").length == $("input[name='modules']").length - 1 ){
27             tickAll('modules');
28         }
29     });
30
31     if ( $('input[name="actions"]:checked').length == 0 ) {
32         tickAll('actions');
33     }
34     $("#actionALL").change(function(){
35         if ( this.checked == true ){
36             tickAll('actions');
37         } else {
38             untickAll('actions');
39         }
40
41     });
42     $("input[name='actions']").change(function(){
43         if ( $("input[name='actions']:checked").length == $("input[name='actions']").length - 1 ){
44             tickAll('actions');
45         }
46     });
47
48     if ( $('input[name="interfaces"]:checked').length == 0 ) {
49         tickAll('interfaces');
50     }
51     $("#interfaceALL").change(function(){
52         if ( this.checked == true ){
53             tickAll('interfaces');
54         } else {
55             untickAll('interfaces');
56         }
57
58     });
59     $("input[name='interfaces']").change(function(){
60         if ( $("input[name='interfaces']:checked").length == $("input[name='interfaces']").length - 1 ){
61             tickAll('interfaces');
62         }
63     });
64 });