aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/fixmystreet-admin.js
blob: a65fa36504497510e1146e61ccde708b33b136de (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
$(function(){
    // available for admin pages

    // hide the open311_only section and reveal it only when send_method is relevant
    var $open311_only = $('.admin-open311-only');
    if ($open311_only) {
        function hide_or_show_open311(hide_fast) {
            var send_method = $('#send_method').val();
            var show_open311 = false;
            if ($('#endpoint').val()) {
                show_open311 = true; // always show the form if there is an endpoint value
            } else if (send_method && send_method.toLowerCase() != 'email') {
                show_open311 = true;
            }
            if (show_open311) {
                $open311_only.slideDown();
            } else {
                if (hide_fast) {
                    $open311_only.hide();
                } else {
                    $open311_only.slideUp();
                }
            }
        }
        $('#send_method').on('change', hide_or_show_open311);
        hide_or_show_open311(true);
    }

    // admin hints: maybe better implemented as tooltips?
    $(".admin-hint").on('click', function(){
        if ($(this).hasClass('admin-hint-show')) {
            $(this).removeClass('admin-hint-show');
        } else {
            $(this).addClass('admin-hint-show');
        }
    });

});