bgneal@89: $(document).ready(function() { bgneal@89: var postText = $('#id_body'); bgneal@89: var postButton = $('#forums-reply-post'); bgneal@89: postButton.click(function () { bgneal@89: var text = $.trim(postText.val()); bgneal@89: if (text.length == 0) { bgneal@89: alert('Please enter some reply text.'); bgneal@89: return false; bgneal@89: } bgneal@89: $(this).attr('disabled', 'disabled').val('Posting reply...'); bgneal@89: $.ajax({ bgneal@89: url: '/forums/quick-reply/', bgneal@89: type: 'POST', bgneal@89: data: { bgneal@89: body : postText.val(), bgneal@89: topic_id : $('#id_topic_id').val() bgneal@89: }, bgneal@89: dataType: 'html', bgneal@89: success: function (data, textStatus) { bgneal@89: postText.val(''); bgneal@89: $('#forum-topic tr:last').after(data); bgneal@89: var lastTr = $('#forum-topic tr:last'); bgneal@89: lastTr.hide(); bgneal@89: lastTr.fadeIn(3000); bgneal@89: postButton.removeAttr('disabled').val('Submit Reply'); bgneal@89: }, bgneal@89: error: function (xhr, textStatus, ex) { bgneal@89: alert('Oops, an error occurred. Please reload the page and try again.'); bgneal@89: postButton.removeAttr('disabled').val('Submit Reply'); bgneal@89: } bgneal@89: }); bgneal@89: return false; bgneal@89: }); bgneal@98: $('a.post-flag').click(function () { bgneal@98: var id = this.id; bgneal@98: if (id.match(/fp-(\d)/)) { bgneal@98: id = RegExp.$1; bgneal@98: if (confirm('Only flag a post if you feel it is spam, abuse, violates site rules, ' + bgneal@98: 'or is not appropriate. ' + bgneal@98: 'A moderator will be notified and will review the post. ' + bgneal@98: 'Are you sure you want to flag this post?')) { bgneal@99: $.ajax({ bgneal@99: url: '/forums/flag-post/', bgneal@99: type: 'POST', bgneal@99: data: {id: id}, bgneal@99: dataType: 'text', bgneal@99: success: function (response, textStatus) { bgneal@99: alert(response); bgneal@99: }, bgneal@99: error: function (xhr, textStatus, ex) { bgneal@99: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@99: } bgneal@99: }); bgneal@98: } bgneal@98: } bgneal@98: return false; bgneal@98: }); bgneal@95: $('#id_body').markItUp(mySettings); bgneal@89: });