summaryrefslogtreecommitdiff
blob: 5b31df84b35a0c149b072dd9259fd6865712f7d7 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// from http://stackoverflow.com/questions/4399005/implementing-jquerys-shake-effect-with-animate
// replacement for broken Effect.Shake from JQuery UI
jQuery.fn.shake = function (steps, duration, amount, vertical) {
    var s = steps || 3;
    var d = duration || 120;
    var a = amount || 3;
    var v = vertical || false;
    this.css('position', 'relative');
    var cur = parseInt(this.css(v ? "top" : "left"), 10);
    if (isNaN(cur))
        cur = 0;

    var ds = d / s;

    if (v) {
        for (i = 0; i < s; i++)
            this.animate({ "top": cur + a + "px" }, ds).animate({ "top": cur - a + "px" }, ds);
        this.animate({ "top": cur }, 20);
    }
    else {
        for (i = 0; i < s; i++)
            this.animate({ "left": cur + a }, ds).animate({ "left": cur - a + "px" }, ds);
        this.animate({ "left": cur }, 20);
    }

    return this;
}

jQuery(function($) {
    $('.has-tooltip').tooltip();
    $('.share-btn').popover({html: true, placement: 'left', title: 'Share'});

    $('a.notice-link').click(function() {
        if ($(this).hasClass('active')) {
            $('div.notice').show(400);
            $(this).removeClass('active');
            $('#notices-for').html('');

            return false;
        } else {
            var affected_notices = $("div.notice[data-services~='" + $(this).data('service') +"']");

            if (affected_notices.length > 0) {
                $("div.notice:not([data-services~='" + $(this).data('service') +"'])").hide(400);
                affected_notices.show(400);
                $('#notices-for').html('for ' + $(this).data('service-name'));
                $('a.notice-link.active').removeClass('active');
                $(this).addClass('active');
            } else {
                $(this).shake();
                return false;
            }
        }

        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
            var target = $(this.hash);
            target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
            if (target.length) {
                $('html,body').animate({
                    scrollTop: target.offset().top
                }, 200);
                return false;
            }
        }
    });
});

InfraStatus = {
    share: function(obj) {
        var url = $(obj).parents('.notice').data('url');

        if ($(obj).hasClass('btn-facebook')) {
            window.open('https://www.facebook.com/sharer/sharer.php?u=' + url);
        } else if ($(obj).hasClass('btn-google-plus')) {
            window.open('https://plus.google.com/share?url=' + url);
        } else if ($(obj).hasClass('btn-twitter')) {
            window.open('https://twitter.com/home?status=' + url);
        }
    }
};