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";
|
|
|
|
jq.ajax({
|
|
|
|
type: "GET",
|
|
|
|
url: target,
|
2009-12-07 17:11:49 +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
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
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 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-12-08 12:19:26 +01:00
|
|
|
/* Remove all selected lines. */
|
|
|
|
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
|
|
|
});
|
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
|
|
|
});
|
|
|
|
|
|
|
|
});
|