local changes from server
[prawokultury.git] / prawokultury / static / js / promobox.js
1 $(document).ready(function(){
2
3 var $slides = $("ul.promobox li");
4 var $switchers = $("ul#promobox-switcher li");
5
6 var change_slide = function(slide_no) {
7     var $slide = $($slides.get(slide_no));
8     var $switcher = $($switchers.get(slide_no));
9
10     $slides.filter('.active').fadeOut();
11     $slides.filter('.active').removeClass('active');
12     $switchers.filter('.active').removeClass('active');
13     $slide.fadeIn();
14     $slide.addClass('active');
15     $switcher.addClass('active');
16     reset_timeout();
17 };
18
19
20 var timeout = null;
21 var cycle_slide = function() {
22     var current = $slides.filter('.active').index();
23     change_slide((current + 1) % $slides.length);
24 }
25
26
27 var reset_timeout = function() {
28     clearTimeout(timeout);
29     timeout = setTimeout(cycle_slide, 5000);
30 };
31
32
33 if ($slides.length > 1) {
34     $switchers.each(function(i, e) {
35         $(e).click(function(e) {
36             e.preventDefault();
37             change_slide(i);
38         });
39     });
40
41     timeout = setTimeout(cycle_slide, 3000);
42 }
43
44
45 /*
46 if (!$('#id_presentation').checked) {
47         $('[id^="id_presentation_"]').parent().parent().hide();
48 }
49 if (!$('#id_workshop').checked) {
50         $('[id^="id_workshop_"]').parent().parent().hide();
51 }
52
53 $('#id_presentation').change(function() {
54     if (this.checked) {
55         $('[id^="id_presentation_"]').parent().parent().show('slow');
56     } else {
57         $('[id^="id_presentation_"]').parent().parent().hide('slow');
58     }
59 });
60
61 $('#id_workshop').change(function() {
62     if (this.checked) {
63         $('[id^="id_workshop_"]').parent().parent().show('slow');
64     } else {
65         $('[id^="id_workshop_"]').parent().parent().hide('slow');
66     }
67 });
68 */
69
70
71
72 });