gremmie@1
|
1 $(document).ready(function() {
|
bgneal@126
|
2 var postText = $('#id_comment');
|
bgneal@126
|
3 var postButton = $('#comment-form-post');
|
bgneal@126
|
4 postButton.click(function () {
|
bgneal@126
|
5 var text = $.trim(postText.val());
|
bgneal@126
|
6 if (text.length == 0) {
|
bgneal@126
|
7 alert('Please enter some text.');
|
bgneal@126
|
8 return false;
|
bgneal@126
|
9 }
|
bgneal@126
|
10 postButton.attr('disabled', 'disabled').val('Posting Comment...');
|
bgneal@126
|
11 $.ajax({
|
bgneal@126
|
12 url: '/comments/post/',
|
bgneal@126
|
13 type: 'POST',
|
bgneal@126
|
14 data: {
|
bgneal@126
|
15 comment : text,
|
bgneal@126
|
16 content_type : $('#id_content_type').val(),
|
bgneal@126
|
17 object_pk : $('#id_object_pk').val()
|
gremmie@1
|
18 },
|
bgneal@126
|
19 dataType: 'html',
|
bgneal@126
|
20 success: function (data, textStatus) {
|
bgneal@126
|
21 postText.val('');
|
gremmie@1
|
22 $('#comment-list').append(data);
|
gremmie@1
|
23 var lastLi = $('#comment-list > li:last');
|
gremmie@1
|
24 lastLi.hide();
|
gremmie@1
|
25 lastLi.fadeIn(3000);
|
bgneal@126
|
26 postButton.removeAttr('disabled').val('Post Comment');
|
gremmie@1
|
27 var count = $('#comment-count');
|
gremmie@1
|
28 if (count.length) {
|
gremmie@1
|
29 count.html(parseInt(count.html()) + 1);
|
gremmie@1
|
30 }
|
gremmie@1
|
31 },
|
bgneal@126
|
32 error: function (xhr, textStatus, ex) {
|
bgneal@126
|
33 alert('Oops, an error occurred. ' + xhr.statusText + ' - ' +
|
bgneal@126
|
34 xhr.responseText);
|
bgneal@126
|
35 postButton.removeAttr('disabled').val('Post Comment');
|
bgneal@126
|
36 }
|
bgneal@126
|
37 });
|
gremmie@1
|
38 return false;
|
gremmie@1
|
39 });
|
gremmie@1
|
40 $('a.comment-flag').click(function () {
|
gremmie@1
|
41 var id = this.id;
|
gremmie@1
|
42 if (id.match(/fc-(\d+)/)) {
|
gremmie@1
|
43 id = RegExp.$1;
|
gremmie@1
|
44 if (confirm('Only flag a comment if you feel it is spam, abuse, violates site rules, ' +
|
gremmie@1
|
45 'or is not appropriate. ' +
|
gremmie@1
|
46 'A moderator will be notified and will review the comment. ' +
|
gremmie@1
|
47 'Are you sure you want to flag this comment?')) {
|
bgneal@99
|
48 $.ajax({
|
bgneal@99
|
49 url: '/comments/flag/',
|
bgneal@99
|
50 type: 'POST',
|
bgneal@99
|
51 data: {id: id},
|
bgneal@99
|
52 dataType: 'text',
|
bgneal@99
|
53 success: function (response, textStatus) {
|
bgneal@99
|
54 alert(response);
|
bgneal@99
|
55 },
|
bgneal@99
|
56 error: function (xhr, textStatus, ex) {
|
bgneal@99
|
57 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@99
|
58 }
|
bgneal@99
|
59 });
|
gremmie@1
|
60 }
|
gremmie@1
|
61 }
|
gremmie@1
|
62 return false;
|
gremmie@1
|
63 });
|
bgneal@126
|
64 postText.markItUp(mySettings);
|
bgneal@127
|
65
|
bgneal@127
|
66 $('#smileys_dialog').dialog({autoOpen:false});
|
bgneal@127
|
67 var firstTime = true;
|
bgneal@127
|
68 $('#more_smileys').click(function () {
|
bgneal@127
|
69 $('#smileys_dialog').dialog('open');
|
bgneal@127
|
70 var postBox = $('#id_comment')[0];
|
bgneal@127
|
71 if (firstTime) {
|
bgneal@127
|
72 $.ajax({
|
bgneal@127
|
73 url: '/smiley/farm/extra/',
|
bgneal@127
|
74 type: 'GET',
|
bgneal@127
|
75 dataType: 'html',
|
bgneal@127
|
76 success: function(data, textStatus) {
|
bgneal@127
|
77 var img = $('#smiley_busy');
|
bgneal@127
|
78 img.hide();
|
bgneal@127
|
79 img.after(data);
|
bgneal@127
|
80 $('#smileys_dialog .smiley_farm img').click(function() {
|
bgneal@127
|
81 postBox.value += ' ' + this.alt + ' ';
|
bgneal@127
|
82 postBox.focus();
|
bgneal@127
|
83 });
|
bgneal@127
|
84 firstTime = false;
|
bgneal@127
|
85 },
|
bgneal@127
|
86 error: function (xhr, textStatus, ex) {
|
bgneal@127
|
87 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@127
|
88 }
|
bgneal@127
|
89 });
|
bgneal@127
|
90 }
|
bgneal@127
|
91 return false;
|
bgneal@127
|
92 });
|
bgneal@127
|
93 $('#markdown_help_dialog').dialog({autoOpen: false, width: 720, height: 600});
|
bgneal@127
|
94 var firstTimeMd = true;
|
bgneal@127
|
95 $('#markdown_help').click(function () {
|
bgneal@127
|
96 $('#markdown_help_dialog').dialog('open');
|
bgneal@127
|
97 if (firstTimeMd) {
|
bgneal@127
|
98 $.ajax({
|
bgneal@127
|
99 url: '/core/markdown_help/',
|
bgneal@127
|
100 type: 'GET',
|
bgneal@127
|
101 dataType: 'html',
|
bgneal@127
|
102 success: function(data, textStatus) {
|
bgneal@127
|
103 var img = $('#markdown_busy');
|
bgneal@127
|
104 img.hide();
|
bgneal@127
|
105 img.after(data);
|
bgneal@127
|
106 firstTimeMd = false;
|
bgneal@127
|
107 },
|
bgneal@127
|
108 error: function (xhr, textStatus, ex) {
|
bgneal@127
|
109 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
|
bgneal@127
|
110 }
|
bgneal@127
|
111 });
|
bgneal@127
|
112 }
|
bgneal@127
|
113 return false;
|
bgneal@127
|
114 });
|
gremmie@1
|
115 });
|