aboutsummaryrefslogtreecommitdiffstats
path: root/static/js/famille.js
blob: 9606d13bbf62b11d9c5db272d127f0e985745b6c (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
$.fn.wait = function(time, type) {
    time = time || 1000;
    type = type || "fx";
    return this.queue(type, function() {
	var self = this;
	setTimeout(function() {
	    $(self).dequeue();
	}, time);
    });
};

$(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip()
    $("div.infobox").wait(2000).slideUp("slow");
    $("div.errorbox").wait(2000).slideUp("slow");
    $("#add").click(function(){
    	$(".hidden").fadeIn("slow");
    	$(this).hide(0);
    	$("label.info").hide(0);
    	$(".tohide").hide(0);
    });
    $("#kadobutton").click(function(){
	    $(".kadoscope").animate({opacity:"1"},"5000");
    });
    $('span.timeago').timeago();
    var addr = $(location).attr('pathname');
    $("#"+addr.replace(/\//g,"")).addClass("active");

    $(".edit").click(function(e){
        e.preventDefault();
        var heading = $(this).parents(".media-heading");
        heading.siblings(".comment-content").hide();
        var textarea = heading.siblings(".comment-source").find("textarea");
        var row_count = textarea.val().split("\n").length;
        textarea.attr("rows", row_count);
        heading.siblings(".comment-source").show();
    });

    $(".comment-source").submit(function(e){
        e.preventDefault();
        var comment_id = $(this).data("id");
        var form = $(this);
        $.post("/comment/" + comment_id, {content: form.find("textarea").val()}, function(data) {
            var comment_content = form.parents(".media-body").find(".comment-content");
            comment_content.html(data.content_cache);
            comment_content.show();
            form.hide();
        });
    });
});