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@108: alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + bgneal@108: xhr.responseText); 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@107: 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@107: $('a.post-delete').click(function () { bgneal@107: var id = this.id; bgneal@107: if (id.match(/dp-(\d+)/)) { bgneal@107: id = RegExp.$1; bgneal@107: if (confirm('Are you sure you want to delete this post?')) { bgneal@107: $.ajax({ bgneal@107: url: '/forums/delete-post/', bgneal@107: type: 'POST', bgneal@107: data: {id: id}, bgneal@107: dataType: 'text', bgneal@107: success: function (response, textStatus) { bgneal@107: alert(response); bgneal@107: $('#post-' + id).fadeOut(3000); bgneal@107: }, bgneal@107: error: function (xhr, textStatus, ex) { bgneal@107: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@107: } bgneal@107: }); bgneal@107: } bgneal@107: } bgneal@107: return false; bgneal@107: }); bgneal@109: $('#forum-mod-del-topic').click(function () { bgneal@109: return confirm('Are you sure you want to delete this topic?\n' + bgneal@109: 'WARNING: all posts will be lost.'); bgneal@109: }); bgneal@95: $('#id_body').markItUp(mySettings); bgneal@123: $('#smileys_dialog').dialog({autoOpen:false}); bgneal@123: var firstTime = true; bgneal@123: $('#more_smileys').click(function () { bgneal@123: $('#smileys_dialog').dialog('open'); bgneal@123: var postBox = $('#id_body')[0]; bgneal@123: if (firstTime) { bgneal@123: $.ajax({ bgneal@123: url: '/smiley/farm/extra/', bgneal@123: type: 'GET', bgneal@123: dataType: 'html', bgneal@123: success: function(data, textStatus) { bgneal@123: var img = $('#smiley_busy'); bgneal@123: img.hide(); bgneal@123: img.after(data); bgneal@123: $('#smileys_dialog .smiley_farm img').click(function() { bgneal@123: postBox.value += ' ' + this.alt + ' '; bgneal@123: postBox.focus(); bgneal@123: }); bgneal@123: firstTime = false; bgneal@123: }, bgneal@123: error: function (xhr, textStatus, ex) { bgneal@123: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@123: } bgneal@123: }); bgneal@123: } bgneal@123: return false; bgneal@123: }); bgneal@89: });