aboutsummaryrefslogtreecommitdiffstats
path: root/schedule/static/js/schedule.js
blob: 3714b19ae77355ff97f3565fa375e1fe269b3341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * schedule.js
 * used with 'schedule.html' page
 *
 * 2014/06/24
 */

/* animated slidedown and slideup div */
$(document).ready(function() {
    /* hide() all .event-contents and .event-attchments body */
    $(".event-contents .panel-body").hide().removeClass('shown').addClass('hidden');
    $(".event-attachments .panel-body").hide().removeClass('shown').addClass('hidden');

    /* click .event-contents heading to toggle its body contents */
    $(".event-contents .panel-heading").on("click", function(e) {
        e.stopPropagation();
        ec_body = $(this).siblings(".panel-body");
        if ($(ec_body).hasClass('hidden')) {
            $(ec_body).show().removeClass('hidden').addClass('shown');
            // update heading icon and text
            span_icon = $(this).children("span.glyphicon");
            $(span_icon).removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
            span_action = $(this).children("span.action");
            $(span_action).html('隐藏');
        }
        else {
            $(ec_body).hide().removeClass('shown').addClass('hidden');
            // update heading icon and text
            span_icon = $(this).children("span.glyphicon");
            $(span_icon).removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
            span_action = $(this).children("span.action");
            $(span_action).html('显示');
        }
    });

    /* click .event-attachments heading to toggle its body attachments */
    $(".event-attachments .panel-heading").on("click", function(e) {
        e.stopPropagation();
        ec_body = $(this).siblings(".panel-body");
        if ($(ec_body).hasClass('hidden')) {
            $(ec_body).show().removeClass('hidden').addClass('shown');
            // update heading icon and text
            span_icon = $(this).children("span.glyphicon");
            $(span_icon).removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
            span_action = $(this).children("span.action");
            $(span_action).html('隐藏');
        }
        else {
            $(ec_body).hide().removeClass('shown').addClass('hidden');
            // update heading icon and text
            span_icon = $(this).children("span.glyphicon");
            $(span_icon).removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
            span_action = $(this).children("span.action");
            $(span_action).html('显示');
        }
    });
});