aboutsummaryrefslogtreecommitdiff
path: root/www/js/phorkie.js
blob: 92616fd3f806776871ccee60c9b4dd0ab151a4b9 (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
function filenameChange(elem, id) {
    var filename = elem.value;
    var hasExt = filename.indexOf(".") != -1;
    if (hasExt) {
        $('#typeselect_' + id).hide();
        $('#typetext_' + id).show();
    } else {
        $('#typeselect_' + id).show();
        $('#typetext_' + id).hide();
    }
}

function initEdit()
{
    initFilenames();
    initAdditionals();
    $('.filegroup:visible:last textarea').focus();
}
function initFilenames()
{
    $('input.filename').each(
        function(num, elem) {
            var id = elem.id;
            var pos = id.indexOf('_');
            if (pos != -1) {
                var elemNum = id.substr(pos + 1);
                if (elemNum != 'new') {
                    filenameChange(elem, elemNum);
                }
            }
        }
    );
}
function initAdditionals()
{
    $('a.additional-btn').each(
        function(num, elem) {
            toggleAdditional(elem, 0);
            $(elem).show();
        }
    );
}

function toggleAdditional(elem, time)
{
    if (undefined == time) {
        time = 'fast';
    }
    var jt = jQuery(elem);
    jt.children('i').toggleClass('icon-chevron-down')
        .toggleClass('icon-chevron-up');
    jt.parents('.row-fluid').children('.additional').slideToggle(time);
    //jt.parents('.row-fluid').children('.additional').animate(time);
}