gremmie@1
|
1 $(document).ready(function() {
|
bgneal@126
|
2 var postText = $('#id_comment');
|
bgneal@126
|
3 var postButton = $('#comment-form-post');
|
bgneal@126
|
4 postButton.click(function () {
|
bgneal@126
|
5 var text = $.trim(postText.val());
|
bgneal@126
|
6 if (text.length == 0) {
|
bgneal@126
|
7 alert('Please enter some text.');
|
bgneal@126
|
8 return false;
|
bgneal@126
|
9 }
|
bgneal@126
|
10 postButton.attr('disabled', 'disabled').val('Posting Comment...');
|
bgneal@126
|
11 $.ajax({
|
bgneal@126
|
12 url: '/comments/post/',
|
bgneal@126
|
13 type: 'POST',
|
bgneal@126
|
14 data: {
|
bgneal@126
|
15 comment : text,
|
bgneal@126
|
16 content_type : $('#id_content_type').val(),
|
bgneal@126
|
17 object_pk : $('#id_object_pk').val()
|
gremmie@1
|
18 },
|
bgneal@126
|
19 dataType: 'html',
|
bgneal@126
|
20 success: function (data, textStatus) {
|
bgneal@126
|
21 postText.val('');
|
gremmie@1
|
22 $('#comment-list').append(data);
|
gremmie@1
|
23 var lastLi = $('#comment-list > li:last');
|
gremmie@1
|
24 lastLi.hide();
|
gremmie@1
|
25 lastLi.fadeIn(3000);
|
bgneal@126
|
26 postButton.removeAttr('disabled').val('Post Comment');
|
gremmie@1
|
27 var count = $('#comment-count');
|
gremmie@1
|
28 if (count.length) {
|
gremmie@1
|
29 count.html(parseInt(count.html()) + 1);
|
gremmie@1
|
30 }
|
gremmie@1
|
31 },
|
bgneal@126
|
32 error: function (xhr, textStatus, ex) {
|
bgneal@126
|
33 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
|
bgneal@126
|
34 xhr.responseText);
|
bgneal@126
|
35 postButton.removeAttr('disabled').val('Post Comment');
|
bgneal@126
|
36 }
|
bgneal@126
|
37 });
|
gremmie@1
|
38 return false;
|
gremmie@1
|
39 });
|
gremmie@1
|
40 $('a.comment-flag').click(function () {
|
gremmie@1
|
41 var id = this.id;
|
gremmie@1
|
42 if (id.match(/fc-(\d+)/)) {
|
gremmie@1
|
43 id = RegExp.$1;
|
gremmie@1
|
44 if (confirm('Only flag a comment if you feel it is spam, abuse, violates site rules, ' +
|
gremmie@1
|
45 'or is not appropriate. ' +
|
gremmie@1
|
46 'A moderator will be notified and will review the comment. ' +
|
gremmie@1
|
47 'Are you sure you want to flag this comment?')) {
|
bgneal@99
|
48 $.ajax({
|
bgneal@99
|
49 url: '/comments/flag/',
|
bgneal@99
|
50 type: 'POST',
|
bgneal@99
|
51 data: {id: id},
|
bgneal@99
|
52 dataType: 'text',
|
bgneal@99
|
53 success: function (response, textStatus) {
|
bgneal@99
|
54 alert(response);
|
bgneal@99
|
55 },
|
bgneal@99
|
56 error: function (xhr, textStatus, ex) {
|
bgneal@99
|
57 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@99
|
58 }
|
bgneal@99
|
59 });
|
gremmie@1
|
60 }
|
gremmie@1
|
61 }
|
gremmie@1
|
62 return false;
|
gremmie@1
|
63 });
|
bgneal@126
|
64 postText.markItUp(mySettings);
|
gremmie@1
|
65 });
|