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@108
|
28 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
|
bgneal@108
|
29 xhr.responseText);
|
bgneal@89
|
30 postButton.removeAttr('disabled').val('Submit Reply');
|
bgneal@89
|
31 }
|
bgneal@89
|
32 });
|
bgneal@89
|
33 return false;
|
bgneal@89
|
34 });
|
bgneal@98
|
35 $('a.post-flag').click(function () {
|
bgneal@98
|
36 var id = this.id;
|
bgneal@107
|
37 if (id.match(/fp-(\d+)/)) {
|
bgneal@98
|
38 id = RegExp.$1;
|
bgneal@98
|
39 if (confirm('Only flag a post if you feel it is spam, abuse, violates site rules, ' +
|
bgneal@98
|
40 'or is not appropriate. ' +
|
bgneal@98
|
41 'A moderator will be notified and will review the post. ' +
|
bgneal@98
|
42 'Are you sure you want to flag this post?')) {
|
bgneal@99
|
43 $.ajax({
|
bgneal@99
|
44 url: '/forums/flag-post/',
|
bgneal@99
|
45 type: 'POST',
|
bgneal@99
|
46 data: {id: id},
|
bgneal@99
|
47 dataType: 'text',
|
bgneal@99
|
48 success: function (response, textStatus) {
|
bgneal@99
|
49 alert(response);
|
bgneal@99
|
50 },
|
bgneal@99
|
51 error: function (xhr, textStatus, ex) {
|
bgneal@99
|
52 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@99
|
53 }
|
bgneal@99
|
54 });
|
bgneal@98
|
55 }
|
bgneal@98
|
56 }
|
bgneal@98
|
57 return false;
|
bgneal@98
|
58 });
|
bgneal@107
|
59 $('a.post-delete').click(function () {
|
bgneal@107
|
60 var id = this.id;
|
bgneal@107
|
61 if (id.match(/dp-(\d+)/)) {
|
bgneal@107
|
62 id = RegExp.$1;
|
bgneal@107
|
63 if (confirm('Are you sure you want to delete this post?')) {
|
bgneal@107
|
64 $.ajax({
|
bgneal@107
|
65 url: '/forums/delete-post/',
|
bgneal@107
|
66 type: 'POST',
|
bgneal@107
|
67 data: {id: id},
|
bgneal@107
|
68 dataType: 'text',
|
bgneal@107
|
69 success: function (response, textStatus) {
|
bgneal@107
|
70 alert(response);
|
bgneal@107
|
71 $('#post-' + id).fadeOut(3000);
|
bgneal@107
|
72 },
|
bgneal@107
|
73 error: function (xhr, textStatus, ex) {
|
bgneal@107
|
74 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@107
|
75 }
|
bgneal@107
|
76 });
|
bgneal@107
|
77 }
|
bgneal@107
|
78 }
|
bgneal@107
|
79 return false;
|
bgneal@107
|
80 });
|
bgneal@109
|
81 $('#forum-mod-del-topic').click(function () {
|
bgneal@109
|
82 return confirm('Are you sure you want to delete this topic?\n' +
|
bgneal@109
|
83 'WARNING: all posts will be lost.');
|
bgneal@109
|
84 });
|
bgneal@95
|
85 $('#id_body').markItUp(mySettings);
|
bgneal@123
|
86 $('#smileys_dialog').dialog({autoOpen:false});
|
bgneal@123
|
87 var firstTime = true;
|
bgneal@123
|
88 $('#more_smileys').click(function () {
|
bgneal@123
|
89 $('#smileys_dialog').dialog('open');
|
bgneal@123
|
90 var postBox = $('#id_body')[0];
|
bgneal@123
|
91 if (firstTime) {
|
bgneal@123
|
92 $.ajax({
|
bgneal@123
|
93 url: '/smiley/farm/extra/',
|
bgneal@123
|
94 type: 'GET',
|
bgneal@123
|
95 dataType: 'html',
|
bgneal@123
|
96 success: function(data, textStatus) {
|
bgneal@123
|
97 var img = $('#smiley_busy');
|
bgneal@123
|
98 img.hide();
|
bgneal@123
|
99 img.after(data);
|
bgneal@123
|
100 $('#smileys_dialog .smiley_farm img').click(function() {
|
bgneal@123
|
101 postBox.value += ' ' + this.alt + ' ';
|
bgneal@123
|
102 postBox.focus();
|
bgneal@123
|
103 });
|
bgneal@123
|
104 firstTime = false;
|
bgneal@123
|
105 },
|
bgneal@123
|
106 error: function (xhr, textStatus, ex) {
|
bgneal@123
|
107 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@123
|
108 }
|
bgneal@123
|
109 });
|
bgneal@123
|
110 }
|
bgneal@123
|
111 return false;
|
bgneal@123
|
112 });
|
bgneal@89
|
113 });
|