comparison media/js/forums.js @ 107:e94398f5e027

Forums: implemented post delete feature.
author Brian Neal <bgneal@gmail.com>
date Tue, 22 Sep 2009 03:36:39 +0000
parents 10d6182b9f6e
children 80ab249d1adc
comparison
equal deleted inserted replaced
106:cb72577785df 107:e94398f5e027
31 }); 31 });
32 return false; 32 return false;
33 }); 33 });
34 $('a.post-flag').click(function () { 34 $('a.post-flag').click(function () {
35 var id = this.id; 35 var id = this.id;
36 if (id.match(/fp-(\d)/)) { 36 if (id.match(/fp-(\d+)/)) {
37 id = RegExp.$1; 37 id = RegExp.$1;
38 if (confirm('Only flag a post if you feel it is spam, abuse, violates site rules, ' + 38 if (confirm('Only flag a post if you feel it is spam, abuse, violates site rules, ' +
39 'or is not appropriate. ' + 39 'or is not appropriate. ' +
40 'A moderator will be notified and will review the post. ' + 40 'A moderator will be notified and will review the post. ' +
41 'Are you sure you want to flag this post?')) { 41 'Are you sure you want to flag this post?')) {
53 }); 53 });
54 } 54 }
55 } 55 }
56 return false; 56 return false;
57 }); 57 });
58 $('a.post-delete').click(function () {
59 var id = this.id;
60 if (id.match(/dp-(\d+)/)) {
61 id = RegExp.$1;
62 if (confirm('Are you sure you want to delete this post?')) {
63 $.ajax({
64 url: '/forums/delete-post/',
65 type: 'POST',
66 data: {id: id},
67 dataType: 'text',
68 success: function (response, textStatus) {
69 alert(response);
70 $('#post-' + id).fadeOut(3000);
71 },
72 error: function (xhr, textStatus, ex) {
73 alert('Oops, an error occurred: ' + xhr.statusText + ' - ' + xhr.responseText);
74 }
75 });
76 }
77 }
78 return false;
79 });
58 $('#id_body').markItUp(mySettings); 80 $('#id_body').markItUp(mySettings);
59 }); 81 });