2009-06-29 11:54:53 +02:00
|
|
|
jq(document).ready(function() {
|
|
|
|
|
|
|
|
|
2010-06-04 11:25:47 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Delete a single comment.
|
|
|
|
**************************************************************************/
|
2009-07-01 00:17:42 +02:00
|
|
|
jq("input[name='form.button.Delete']").click(function(e) {
|
2009-06-29 15:39:55 +02:00
|
|
|
e.preventDefault();
|
2009-07-01 00:17:42 +02:00
|
|
|
var button = jq(this);
|
|
|
|
var row = jq(this).parent().parent();
|
|
|
|
var form = jq(row).parents("form");
|
|
|
|
var path = jq(row).find("input:checkbox").attr("value");
|
2010-01-27 15:54:07 +01:00
|
|
|
var target = path + "/@@moderate-delete-comment";
|
2009-07-01 00:17:42 +02:00
|
|
|
var comment_id = jq(this).attr("id");
|
|
|
|
jq.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: target,
|
|
|
|
success: function(msg){
|
|
|
|
// fade out row
|
|
|
|
jq(row).fadeOut("normal", function(){
|
|
|
|
jq(this).remove();
|
2009-06-29 17:29:51 +02:00
|
|
|
});
|
2009-07-01 00:17:42 +02:00
|
|
|
},
|
2010-01-27 15:54:07 +01:00
|
|
|
error: function(msg){
|
2009-07-01 00:17:42 +02:00
|
|
|
alert("Error sending AJAX request:" + target);
|
2009-08-26 17:05:58 +02:00
|
|
|
}
|
2009-07-01 00:17:42 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-06-04 11:25:47 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Publish a single comment.
|
|
|
|
**************************************************************************/
|
2009-07-01 00:17:42 +02:00
|
|
|
jq("input[name='form.button.Publish']").click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var button = jq(this);
|
|
|
|
var row = jq(this).parent().parent();
|
|
|
|
var form = jq(row).parents("form");
|
|
|
|
var path = jq(row).find("input:checkbox").attr("value");
|
|
|
|
var target = path + "/@@moderate-publish-comment";
|
|
|
|
jq.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: target,
|
2010-01-27 15:54:07 +01:00
|
|
|
data: "workflow_action=publish",
|
2009-07-01 00:17:42 +02:00
|
|
|
success: function(msg){
|
2009-12-08 12:19:26 +01:00
|
|
|
// fade out row
|
|
|
|
jq(row).fadeOut("normal", function(){
|
|
|
|
jq(this).remove();
|
|
|
|
});
|
2009-07-01 00:17:42 +02:00
|
|
|
},
|
|
|
|
error: function(msg){
|
|
|
|
alert("Error sending AJAX request:" + target);
|
2009-08-26 17:05:58 +02:00
|
|
|
}
|
2009-06-29 15:39:55 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-06-04 11:25:47 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Bulk actions for comments (delete, publish)
|
|
|
|
**************************************************************************/
|
2009-07-01 00:17:42 +02:00
|
|
|
jq("input[name='form.button.BulkAction']").click(function(e) {
|
2009-06-29 15:38:00 +02:00
|
|
|
e.preventDefault();
|
2009-07-01 00:17:42 +02:00
|
|
|
var form = jq(this).parents("form")
|
|
|
|
var target = jq(form).attr('action');
|
|
|
|
var params = jq(form).serialize();
|
|
|
|
var valArray = jq('input:checkbox:checked');
|
|
|
|
var selectField = jq(form).find("[name='form.select.BulkAction']");
|
2010-01-25 11:51:27 +01:00
|
|
|
if (selectField.val() == '-1') {
|
2010-01-27 15:54:07 +01:00
|
|
|
// XXX: translate message
|
2010-01-25 11:51:27 +01:00
|
|
|
alert("You haven't selected a bulk action. Please select one.");
|
|
|
|
} else if (valArray.length == 0) {
|
2010-01-27 15:54:07 +01:00
|
|
|
// XXX: translate message
|
2010-01-25 11:51:27 +01:00
|
|
|
alert("You haven't selected any comment for this bulk action. Please select at least one comment.");
|
|
|
|
} else {
|
2009-06-29 17:09:41 +02:00
|
|
|
jq.post(target, params, function(data) {
|
|
|
|
valArray.each(function () {
|
2010-01-25 11:51:27 +01:00
|
|
|
/* Remove all selected lines. */
|
2009-12-08 12:19:26 +01:00
|
|
|
var row = jq(this).parent().parent();
|
|
|
|
row.fadeOut("normal", function() {
|
|
|
|
row.remove();
|
|
|
|
});
|
2009-06-29 17:09:41 +02:00
|
|
|
});
|
2009-06-29 15:38:00 +02:00
|
|
|
});
|
2010-01-25 11:51:27 +01:00
|
|
|
// reset the bulkaction select
|
|
|
|
selectField.find("option[value='-1']").attr( 'selected', 'selected' );
|
2009-06-29 17:09:41 +02:00
|
|
|
}
|
2009-06-29 15:38:00 +02:00
|
|
|
});
|
2010-06-04 11:25:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* Check or uncheck all checkboxes from the batch moderation page.
|
|
|
|
**************************************************************************/
|
|
|
|
jq("input[name='check_all']").click(function(){
|
|
|
|
if(jq(this).val()==0){
|
|
|
|
jq(this).parents("table")
|
|
|
|
.find("input:checkbox")
|
|
|
|
.attr("checked","checked");
|
|
|
|
jq(this).val("1");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
jq(this).parents("table")
|
|
|
|
.find("input:checkbox")
|
|
|
|
.attr("checked","");
|
|
|
|
jq(this).val("0");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2009-06-29 15:38:00 +02:00
|
|
|
|
2010-06-04 11:25:47 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* Show full text of a comment in the batch moderation page.
|
|
|
|
**************************************************************************/
|
2010-01-25 12:43:29 +01:00
|
|
|
jq(".show-full-comment-text").click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var target = jq(this).attr("href");
|
|
|
|
var td = jq(this).parent();
|
|
|
|
jq.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: target,
|
|
|
|
data: "",
|
|
|
|
success: function(data){
|
|
|
|
// show full text
|
|
|
|
td.replaceWith("<td>" + data + "</td>");
|
|
|
|
},
|
|
|
|
error: function(msg){
|
|
|
|
alert("Error getting full comment text:" + target);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2010-06-04 11:25:47 +02:00
|
|
|
});
|