e30375aec51e53e1cfe20678e52cd337c4309875
[edumed.git] / curriculum / static / curriculum / curriculum.js
1 $(function() {
2     if (curriculum_hide_form) {
3         $('.curriculum-form form').hide();
4         $('.curriculum-form h2 a span').show();
5     }
6     $('.curriculum-form h2 a').click(function() {
7         $('.curriculum-form form').toggle('fast');
8         $('span', this).toggle();
9     });
10
11     /* show togglers */
12     $('.curriculum-section-toggler').show();
13
14     $('.curriculum-section').each(function() {
15         var category = this;
16
17         /* set up togglers */
18         $('.curriculum-section-toggler', this).click(function() {
19             $('ul', category).toggle('fast');
20         });
21
22         /* set up section checkboxes */
23         $('.s', category).change(function() {
24             if ($(this).attr('checked')) {
25                 $('ul input', category).attr('checked', 'checked');
26             }
27             else {
28                 $('ul input', category).removeAttr('checked');
29             }
30         });
31
32         /* unset section checkbox on unselect single competence */
33         $('ul input', category).change(function() {
34             if (!$(this).attr('checked')) {
35                 $('.s', category).removeAttr('checked', 'checked');
36             }
37         });
38
39         /* hide unused section details on start */
40         if ($('.s', category).attr('checked') || !$('ul input[checked]', category).length)
41             $('ul', category).hide();
42     });
43 });