2009-06-29 11:54:53 +02:00
|
|
|
jq(document).ready(function() {
|
|
|
|
|
|
|
|
/*****************************************************************
|
2009-06-29 15:38:00 +02:00
|
|
|
* Check or uncheck all checkboxes
|
2009-06-29 11:54:53 +02:00
|
|
|
*****************************************************************/
|
2009-07-01 00:17:42 +02:00
|
|
|
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","");
|
2009-06-29 22:44:20 +02:00
|
|
|
jq(this).val("0");
|
2009-07-01 00:17:42 +02:00
|
|
|
}
|
2009-06-29 11:54:53 +02:00
|
|
|
});
|
|
|
|
|
2009-06-29 17:09:41 +02:00
|
|
|
|
2009-06-29 15:39:55 +02:00
|
|
|
/*****************************************************************
|
2009-07-01 00:17:42 +02:00
|
|
|
* Delete comment
|
2009-06-29 15:39:55 +02:00
|
|
|
*****************************************************************/
|
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");
|
|
|
|
var target = path + "/@@moderate-delete-comment";
|
|
|
|
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
|
|
|
},
|
|
|
|
error: function(msg){
|
|
|
|
alert("Error sending AJAX request:" + target);
|
2009-08-26 17:05:58 +02:00
|
|
|
}
|
2009-07-01 00:17:42 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* Publish comment
|
|
|
|
*****************************************************************/
|
|
|
|
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";
|
|
|
|
var currentFilter = jq(form).find("[name='form.button.Filter']").attr("value");
|
|
|
|
jq.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: target,
|
|
|
|
success: function(msg){
|
|
|
|
if (currentFilter == 'pending') {
|
|
|
|
// fade out row
|
|
|
|
jq(row).fadeOut("normal", function(){
|
|
|
|
jq(this).remove();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
// fade out button
|
|
|
|
jq(button).fadeOut("normal", function(){
|
|
|
|
jq(this).remove();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2009-06-29 15:38:00 +02:00
|
|
|
/*****************************************************************
|
2009-06-29 17:09:41 +02:00
|
|
|
* Bulk actions (delete, publish)
|
2009-06-29 15:38:00 +02:00
|
|
|
*****************************************************************/
|
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 currentFilter = jq(form).find("[name='form.button.Filter']").attr("value");
|
|
|
|
var currentAction = jq(form).find("[name='form.select.BulkAction']").val();
|
|
|
|
var selectField = jq(form).find("[name='form.select.BulkAction']");
|
2009-06-29 17:09:41 +02:00
|
|
|
if (valArray.length) {
|
|
|
|
jq.post(target, params, function(data) {
|
|
|
|
valArray.each(function () {
|
2009-07-01 00:17:42 +02:00
|
|
|
// if bulkaction is delete, or the current filter is
|
|
|
|
// pending (because then publish also removes the comment),
|
|
|
|
// remove all selected comments.
|
2009-06-29 17:09:41 +02:00
|
|
|
if (currentAction == 'delete' || currentFilter == 'pending') {
|
2009-06-29 17:29:51 +02:00
|
|
|
var row = jq(this).parent().parent();
|
2009-06-29 17:09:41 +02:00
|
|
|
row.fadeOut("normal", function() {
|
|
|
|
row.remove();
|
|
|
|
});
|
|
|
|
}
|
2009-07-01 00:17:42 +02:00
|
|
|
// bulkaction is publish and there is no current filter
|
|
|
|
if (currentAction == 'publish' && currentFilter == '') {
|
|
|
|
// remove the publish button
|
2009-06-29 17:29:51 +02:00
|
|
|
var row = jq(this).parent().parent();
|
2009-07-01 00:17:42 +02:00
|
|
|
var form = row.find("form.workflow_action");
|
2009-06-29 17:29:51 +02:00
|
|
|
var publishButton = row.find(".comment-publish-button");
|
2009-07-01 00:17:42 +02:00
|
|
|
var selectField = row.find("input:checkbox");
|
|
|
|
jq(publishButton).fadeOut("normal", function(){
|
|
|
|
jq(form).remove();
|
|
|
|
});
|
|
|
|
// reset the select fields
|
|
|
|
selectField.attr("checked","");
|
|
|
|
}
|
2009-06-29 17:09:41 +02:00
|
|
|
});
|
2009-06-29 15:38:00 +02:00
|
|
|
});
|
2009-06-29 17:09:41 +02:00
|
|
|
} else {
|
2009-07-01 00:17:42 +02:00
|
|
|
// The user has submitted a bulk action, but no comment
|
|
|
|
// was selected.
|
|
|
|
// Todo: nicer and translated message
|
2009-06-29 17:09:41 +02:00
|
|
|
alert("You haven't selected anything for this bulk action.");
|
|
|
|
}
|
2009-07-01 00:17:42 +02:00
|
|
|
// reset the bulkaction select
|
|
|
|
selectField.find("option[value='-1']").attr( 'selected', 'selected' );
|
2009-06-29 15:38:00 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|