annotate media/js/comments.js @ 120:f8f4514b806a

Added a 24-hour time preference flag in the user profile. Added forum template tags for showing forum dates/times adjusted for the user's time zone.
author Brian Neal <bgneal@gmail.com>
date Sun, 25 Oct 2009 21:55:28 +0000
parents 10d6182b9f6e
children b0d62247c3e4
rev   line source
gremmie@1 1 $(document).ready(function() {
gremmie@1 2 $('#comment-form-post').click(function () {
gremmie@1 3 $(this).attr('disabled', 'disabled').val('Posting Comment...');
gremmie@1 4 $.post('/comments/post/', {
gremmie@1 5 comment : $('#id_comment').val(),
gremmie@1 6 content_type : $('#id_content_type').val(),
gremmie@1 7 object_pk : $('#id_object_pk').val()
gremmie@1 8 },
gremmie@1 9 function (data, textStatus) {
gremmie@1 10 $('#id_comment').val('');
gremmie@1 11 $('#comment-list').append(data);
gremmie@1 12 var lastLi = $('#comment-list > li:last');
gremmie@1 13 lastLi.hide();
gremmie@1 14 lastLi.fadeIn(3000);
gremmie@1 15 $('#comment-form-post').removeAttr('disabled').val('Post Comment');
gremmie@1 16 var count = $('#comment-count');
gremmie@1 17 if (count.length) {
gremmie@1 18 count.html(parseInt(count.html()) + 1);
gremmie@1 19 }
gremmie@1 20 },
gremmie@1 21 'html');
gremmie@1 22 return false;
gremmie@1 23 });
gremmie@1 24 $('a.comment-flag').click(function () {
gremmie@1 25 var id = this.id;
gremmie@1 26 if (id.match(/fc-(\d+)/)) {
gremmie@1 27 id = RegExp.$1;
gremmie@1 28 if (confirm('Only flag a comment if you feel it is spam, abuse, violates site rules, ' +
gremmie@1 29 'or is not appropriate. ' +
gremmie@1 30 'A moderator will be notified and will review the comment. ' +
gremmie@1 31 'Are you sure you want to flag this comment?')) {
bgneal@99 32 $.ajax({
bgneal@99 33 url: '/comments/flag/',
bgneal@99 34 type: 'POST',
bgneal@99 35 data: {id: id},
bgneal@99 36 dataType: 'text',
bgneal@99 37 success: function (response, textStatus) {
bgneal@99 38 alert(response);
bgneal@99 39 },
bgneal@99 40 error: function (xhr, textStatus, ex) {
bgneal@99 41 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
bgneal@99 42 }
bgneal@99 43 });
gremmie@1 44 }
gremmie@1 45 }
gremmie@1 46 return false;
gremmie@1 47 });
gremmie@1 48 $('#id_comment').markItUp(mySettings);
gremmie@1 49 });