aboutsummaryrefslogtreecommitdiff
path: root/web/scripts3.js
blob: 580546d2bd0db4b815db34ea45b67395c5332aa0 (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function inlinevideo(mid) {
    var flashvars={
        file:'http://i.juick.com/video/'+mid+'.mp4',
        image:'http://i.juick.com/thumbs/'+mid+'.jpg',
        skin:'http://static.juick.com/glow.zip'
    };
    var params={
        allowfullscreen:'true'
    };
    swfobject.embedSWF('http://static.juick.com/player.swf','video-'+mid,'640','390','9.0.115','false',flashvars,params,null);
}

function postformListener(formEl,ev) {
    if(ev.ctrlKey && (ev.keyCode==10 || ev.keyCode==13)) formEl.submit();
}

function showMoreReplies(id) {
    $('#'+id+' .msg-comments').hide();

    var replies=$('#replies>li');
    var flagshow=0;
    for(var i=0; i<replies.length; i++) {
        if(flagshow==1) {
            if(replies[i].style.display=="none") {
                replies[i].style.display="block";
            } else {
                break;
            }
        }
        if(replies[i].id==id) {
            flagshow=1;
        }
    }
    return false;
}

function showCommentForm(mid,rid) {
    if($('#replies #'+rid+' textarea').length==0) {
        var c=$('#replies #'+rid+' .msg-comment');
        c.wrap('<form action="/post" method="POST" enctype="multipart/form-data"/>');
        c.before('<input type="hidden" name="mid" value="'+mid+'"/><input type="hidden" name="rid" value="'+rid+'"/>');
        c.append('<textarea name="body" rows="1" class="reply narrow" placeholder="Add a comment..." onkeypress="postformListener(this.form,event)"></textarea><input type="submit" value="OK"/>');
    }
    //    $('#replies #'+rid+' .msg-links').hide();
    $('#replies #'+rid+' .msg-comment').show();
    $('#replies #'+rid+' textarea')[0].focus();
    $('#replies #'+rid+' textarea').autoResize({
        extraSpace: 0,
        minHeight: 1
    });
    return false;
}

function unfoldReply() {
    if((0+window.location.hash.substring(1))>0) {
        var el=$(window.location.hash);
        while(el.is(":hidden")) {
            el=el.prev();
        }
        showMoreReplies(el.attr('id'));
        window.location.replace(window.location.hash);
    }
}

$(document).ready(function() {
    var tareply=$('textarea.reply');
    tareply.autoResize({
        extraSpace: 0,
        minHeight: 1
    });
    tareply.click(function () {
        $(this).addClass("narrow");
        $(this).after('<input type="submit" value="OK"/>');
        $(this).off('click');
    });
    
    if(!!$('.stickya').offset()) {
        var stickyTop = $('.stickya').offset().top;
        $(window).scroll(function() {
            var windowTop = $(window).scrollTop();
            if (stickyTop < windowTop) {
                $('.stickya').css({
                    position:'fixed'
                });
            } else {
                $('.stickya').css('position','absolute');
            }
        });
    }
});