summaryrefslogtreecommitdiff
path: root/javas/bidding.js
blob: 5165aa8410ea63b8565f9f91d630e35e58481442 (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
var display_bidding = function(element, bidding) {
    var popup = $('<div id="bidding_popup"></div>');
    popup.css({
        'position': 'absolute',
        'width': '250px',
        'left': element.position().left + element.width(),
        'top': element.position().top
    });
    popup.html(bidding);
    element.after(popup);
}

var load_bidding = function() {
    $('#bidding_popup').remove();
    var elem = $(this);
    $.ajax(
        {
            url: elem.attr('data-bidding-link'),
            complete: function(xhr, status) {
                if (status == 'success') {
                    display_bidding(elem, xhr.responseText);
                }
                else {
                    display_bidding(elem, 'Brak danych');
                }
            }
        }
    );
    return false;
};

var bind_bidding_links = function() {
    $('a.biddingLink').each(function() {
        $(this).unbind('click').click(load_bidding);
    });
    $(document).click(function() {
        $('#bidding_popup').remove();
    });
};

$(document).ready(function() {
    setInterval(bind_bidding_links, 1000);
});