static/net.nehmer.comments/moderate.js   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1.5

Size

Lines of Code 23
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 16
mnd 2
bc 2
fnc 4
dl 0
loc 23
rs 10
bpm 0.5
cpm 1.5
noi 0
c 0
b 0
f 0
1
$(document).ready(function() {
2
    $('#net_nehmer_comments_admin').on('click', '.net_nehmer_comments_comment_toolbar .moderate-ajax', function(event) {
3
        event.preventDefault();
4
        var comment = $(this).closest('.net_nehmer_comments_comment'),
5
            toolbar = comment.find('.net_nehmer_comments_comment_toolbar');
6
7
        if (toolbar.hasClass('net_nehmer_comments_comment_toolbar_busy')) {
8
            return;
9
        }
10
        toolbar.addClass('net_nehmer_comments_comment_toolbar_busy');
11
        $.post(this.href, {guid: this.dataset.guid, action: this.dataset.action}, function(data) {
12
            var container = comment.parent();
13
            comment.slideUp('fast', function() {
14
                $(this).remove();
15
            });
16
            if ($('.net_nehmer_comments_comment').length > 0) {
17
                $('.net_nehmer_comments_comment').last().after($(data));
18
            } else {
19
                container.append($(data));
20
            }
21
        });
22
    });
23
});
24