gremmie@1: $(document).ready(function() { bgneal@126: var postText = $('#id_comment'); bgneal@126: var postButton = $('#comment-form-post'); bgneal@126: postButton.click(function () { bgneal@126: var text = $.trim(postText.val()); bgneal@126: if (text.length == 0) { bgneal@126: alert('Please enter some text.'); bgneal@126: return false; bgneal@126: } bgneal@126: postButton.attr('disabled', 'disabled').val('Posting Comment...'); bgneal@126: $.ajax({ bgneal@126: url: '/comments/post/', bgneal@126: type: 'POST', bgneal@126: data: { bgneal@126: comment : text, bgneal@126: content_type : $('#id_content_type').val(), bgneal@126: object_pk : $('#id_object_pk').val() gremmie@1: }, bgneal@126: dataType: 'html', bgneal@126: success: function (data, textStatus) { bgneal@126: postText.val(''); gremmie@1: $('#comment-list').append(data); gremmie@1: var lastLi = $('#comment-list > li:last'); gremmie@1: lastLi.hide(); gremmie@1: lastLi.fadeIn(3000); bgneal@126: postButton.removeAttr('disabled').val('Post Comment'); gremmie@1: var count = $('#comment-count'); gremmie@1: if (count.length) { gremmie@1: count.html(parseInt(count.html()) + 1); gremmie@1: } gremmie@1: }, bgneal@126: error: function (xhr, textStatus, ex) { bgneal@126: alert('Oops, an error occurred. ' + xhr.statusText + ' - ' + bgneal@126: xhr.responseText); bgneal@126: postButton.removeAttr('disabled').val('Post Comment'); bgneal@126: } bgneal@126: }); gremmie@1: return false; gremmie@1: }); gremmie@1: $('a.comment-flag').click(function () { gremmie@1: var id = this.id; gremmie@1: if (id.match(/fc-(\d+)/)) { gremmie@1: id = RegExp.$1; gremmie@1: if (confirm('Only flag a comment if you feel it is spam, abuse, violates site rules, ' + gremmie@1: 'or is not appropriate. ' + gremmie@1: 'A moderator will be notified and will review the comment. ' + gremmie@1: 'Are you sure you want to flag this comment?')) { bgneal@99: $.ajax({ bgneal@99: url: '/comments/flag/', 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: }); gremmie@1: } gremmie@1: } gremmie@1: return false; gremmie@1: }); bgneal@126: postText.markItUp(mySettings); bgneal@127: bgneal@127: $('#smileys_dialog').dialog({autoOpen:false}); bgneal@127: var firstTime = true; bgneal@127: $('#more_smileys').click(function () { bgneal@127: $('#smileys_dialog').dialog('open'); bgneal@127: var postBox = $('#id_comment')[0]; bgneal@127: if (firstTime) { bgneal@127: $.ajax({ bgneal@127: url: '/smiley/farm/extra/', bgneal@127: type: 'GET', bgneal@127: dataType: 'html', bgneal@127: success: function(data, textStatus) { bgneal@127: var img = $('#smiley_busy'); bgneal@127: img.hide(); bgneal@127: img.after(data); bgneal@127: $('#smileys_dialog .smiley_farm img').click(function() { bgneal@127: postBox.value += ' ' + this.alt + ' '; bgneal@127: postBox.focus(); bgneal@127: }); bgneal@127: firstTime = false; bgneal@127: }, bgneal@127: error: function (xhr, textStatus, ex) { bgneal@127: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@127: } bgneal@127: }); bgneal@127: } bgneal@127: return false; bgneal@127: }); bgneal@127: $('#markdown_help_dialog').dialog({autoOpen: false, width: 720, height: 600}); bgneal@127: var firstTimeMd = true; bgneal@127: $('#markdown_help').click(function () { bgneal@127: $('#markdown_help_dialog').dialog('open'); bgneal@127: if (firstTimeMd) { bgneal@127: $.ajax({ bgneal@127: url: '/core/markdown_help/', bgneal@127: type: 'GET', bgneal@127: dataType: 'html', bgneal@127: success: function(data, textStatus) { bgneal@127: var img = $('#markdown_busy'); bgneal@127: img.hide(); bgneal@127: img.after(data); bgneal@127: firstTimeMd = false; bgneal@127: }, bgneal@127: error: function (xhr, textStatus, ex) { bgneal@127: alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText); bgneal@127: } bgneal@127: }); bgneal@127: } bgneal@127: return false; bgneal@127: }); gremmie@1: });