bgneal@89
|
1 $(document).ready(function() {
|
bgneal@89
|
2 var postText = $('#id_body');
|
bgneal@89
|
3 var postButton = $('#forums-reply-post');
|
bgneal@89
|
4 postButton.click(function () {
|
bgneal@89
|
5 var text = $.trim(postText.val());
|
bgneal@89
|
6 if (text.length == 0) {
|
bgneal@89
|
7 alert('Please enter some reply text.');
|
bgneal@89
|
8 return false;
|
bgneal@89
|
9 }
|
bgneal@89
|
10 $(this).attr('disabled', 'disabled').val('Posting reply...');
|
bgneal@89
|
11 $.ajax({
|
bgneal@89
|
12 url: '/forums/quick-reply/',
|
bgneal@89
|
13 type: 'POST',
|
bgneal@89
|
14 data: {
|
bgneal@89
|
15 body : postText.val(),
|
bgneal@89
|
16 topic_id : $('#id_topic_id').val()
|
bgneal@89
|
17 },
|
bgneal@89
|
18 dataType: 'html',
|
bgneal@89
|
19 success: function (data, textStatus) {
|
bgneal@89
|
20 postText.val('');
|
bgneal@89
|
21 $('#forum-topic tr:last').after(data);
|
bgneal@89
|
22 var lastTr = $('#forum-topic tr:last');
|
bgneal@89
|
23 lastTr.hide();
|
bgneal@89
|
24 lastTr.fadeIn(3000);
|
bgneal@89
|
25 postButton.removeAttr('disabled').val('Submit Reply');
|
bgneal@89
|
26 },
|
bgneal@89
|
27 error: function (xhr, textStatus, ex) {
|
bgneal@89
|
28 alert('Oops, an error occurred. Please reload the page and try again.');
|
bgneal@89
|
29 postButton.removeAttr('disabled').val('Submit Reply');
|
bgneal@89
|
30 }
|
bgneal@89
|
31 });
|
bgneal@89
|
32 return false;
|
bgneal@89
|
33 });
|
bgneal@98
|
34 $('a.post-flag').click(function () {
|
bgneal@98
|
35 var id = this.id;
|
bgneal@98
|
36 if (id.match(/fp-(\d)/)) {
|
bgneal@98
|
37 id = RegExp.$1;
|
bgneal@98
|
38 if (confirm('Only flag a post if you feel it is spam, abuse, violates site rules, ' +
|
bgneal@98
|
39 'or is not appropriate. ' +
|
bgneal@98
|
40 'A moderator will be notified and will review the post. ' +
|
bgneal@98
|
41 'Are you sure you want to flag this post?')) {
|
bgneal@98
|
42 $.post('/forums/flag-post/', { id : id }, function(response) {
|
bgneal@98
|
43 alert(response);
|
bgneal@98
|
44 }, 'text');
|
bgneal@98
|
45 }
|
bgneal@98
|
46 }
|
bgneal@98
|
47 return false;
|
bgneal@98
|
48 });
|
bgneal@95
|
49 $('#id_body').markItUp(mySettings);
|
bgneal@89
|
50 });
|