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@99
|
42 $.ajax({
|
bgneal@99
|
43 url: '/forums/flag-post/',
|
bgneal@99
|
44 type: 'POST',
|
bgneal@99
|
45 data: {id: id},
|
bgneal@99
|
46 dataType: 'text',
|
bgneal@99
|
47 success: function (response, textStatus) {
|
bgneal@99
|
48 alert(response);
|
bgneal@99
|
49 },
|
bgneal@99
|
50 error: function (xhr, textStatus, ex) {
|
bgneal@99
|
51 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@99
|
52 }
|
bgneal@99
|
53 });
|
bgneal@98
|
54 }
|
bgneal@98
|
55 }
|
bgneal@98
|
56 return false;
|
bgneal@98
|
57 });
|
bgneal@95
|
58 $('#id_body').markItUp(mySettings);
|
bgneal@89
|
59 });
|