fix publish comment. remove ajax functions for now.

svn path=/plone.app.discussion/trunk/; revision=27864
This commit is contained in:
Timo Stollenwerk 2009-07-07 08:00:41 +00:00
parent 54f6c09c7b
commit bed1b420ba
3 changed files with 23 additions and 127 deletions

View File

@ -80,11 +80,14 @@ jq(document).ready(function() {
/***************************************************************** /*****************************************************************
* Remove comment. * Remove comment.
*****************************************************************/ *****************************************************************/
/*
jq("input[name='form.button.DeleteComment']").click(function(e){ jq("input[name='form.button.DeleteComment']").click(function(e){
e.preventDefault(); e.preventDefault();
var form = jq(this).parent(); var form = jq(this).parent();
var target = jq(form).attr("action"); var target = jq(form).attr("action");
var comment = jq(form).parent() var comment = jq(form).parent();
var reply_comments = jq(comment).find("~ .comment:not(.replyTreeLevel0 ~ div)");
reply_comments.css("background", "red");
jq.ajax({ jq.ajax({
type: "GET", type: "GET",
url: target, url: target,
@ -99,10 +102,12 @@ jq(document).ready(function() {
}, },
}); });
}); });
*/
/***************************************************************** /*****************************************************************
* Publish comment. * Publish comment.
*****************************************************************/ *****************************************************************/
/*
jq("input[name='form.button.PublishComment']").click(function(e){ jq("input[name='form.button.PublishComment']").click(function(e){
e.preventDefault(); e.preventDefault();
var button = jq(this); var button = jq(this);
@ -123,4 +128,5 @@ jq(document).ready(function() {
}, },
}); });
}); });
*/
}); });

View File

@ -1,126 +0,0 @@
jq(document).ready(function() {
/*****************************************************************
* Show the reply button only when Javascript is enabled.
* Otherwise hide it, since the reply functions relies on jQuery.
*****************************************************************/
jq(".reply-to-comment-button").css("display" , "inline");
/*****************************************************************
* Create reply to comment form.
*****************************************************************/
jq(".reply-to-comment-button").bind("click", function(e){
var comment_div = jq(this).parents().filter(".comment");
var comment_id = comment_div.attr("id");
var reply_button = comment_div.find(".reply-to-comment-button");
/* Clone the reply div at the end of the page template that contains
* the regular comment form and insert it after the reply button of the
* current comment.
*/
var reply_div = jq("#commenting").clone(true);
reply_div.appendTo(comment_div).css("display", "none");
/* Remove id="reply" attribute, since we use it to uniquely
the main reply form. */
reply_div.removeAttr("id")
/* Hide the reply button (only hide, because we may want to show it
* again if the user hits the cancel button).
*/
jq(reply_button).css("display", "none");
/* Fetch the reply form inside the reply div */
var reply_form = reply_div.find("form");
/* Add a hidden field with the id of the comment */
reply_form.append("<input type=\"hidden\" value=\"" + comment_id + "\" name=\"form.reply_to_comment_id\" />");
/* Change the form action to @@reply-to-comment */
var old_action = reply_form.attr("action");
var new_action = old_action.replace("@@add-comment", "@@reply-to-comment");
reply_form.attr("action", new_action);
/* Add a remove-reply-to-comment Javascript function to remove the form */
var cancel_reply_button = reply_div.find(".cancelreplytocomment");
cancel_reply_button.attr("id", comment_id);
/* Remove already typed in text from the reply form. */
reply_form.find(".field").find("input").attr("value", "")
reply_form.find(".field").find("textarea").attr("value", "")
/* Show the reply layer with a slide down effect */
reply_div.slideDown("slow");
/* Show the cancel button in the reply-to-comment form */
cancel_reply_button.css("display", "inline");
});
/*****************************************************************
* Remove reply to comment form.
*****************************************************************/
jq(".cancelreplytocomment").bind("click", function(e){
reply_to_comment_button = jq(this).parents().filter(".comment").find(".reply-to-comment-button");
/* Find the reply-to-comment form and hide and remove it again. */
reply_to_comment_form = jq(this).parents().filter(".reply")
reply_to_comment_form.slideUp("slow", function() { jq(this).remove(); } );
/* Show the reply-to-comment button again. */
reply_to_comment_button.css("display", "inline");
});
/*****************************************************************
* Remove comment.
*****************************************************************/
jq("input[name='form.button.DeleteComment']").click(function(e){
e.preventDefault();
var form = jq(this).parent();
var target = jq(form).attr("action");
var comment = jq(form).parent()
jq.ajax({
type: "GET",
url: target,
success: function(msg){
// fade out row
jq(comment).fadeOut("normal", function(){
jq(this).remove();
});
},
error: function(msg){
alert("Error sending AJAX request:" + target);
},
});
});
/*****************************************************************
* Publish comment.
*****************************************************************/
jq("input[name='form.button.PublishComment']").click(function(e){
e.preventDefault();
var button = jq(this);
var form = jq(this).parent();
var target = jq(form).attr("action");
var comment = jq(form).parent()
jq.ajax({
type: "GET",
url: target,
success: function(msg){
// fade out row
jq(button).fadeOut("normal", function(){
jq(form).remove();
});
},
error: function(msg){
alert("Error sending AJAX request:" + target);
},
});
});
});

View File

@ -5,6 +5,10 @@ from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFPlone import PloneMessageFactory as _
from Products.statusmessages.interfaces import IStatusMessage
class View(BrowserView): class View(BrowserView):
"""Moderation View """Moderation View
""" """
@ -96,6 +100,12 @@ class DeleteComment(BrowserView):
del conversation[comment_id] del conversation[comment_id]
IStatusMessage(self.context.REQUEST).addStatusMessage(
_("Comment deleted."),
type="info")
return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER)
class PublishComment(BrowserView): class PublishComment(BrowserView):
"""Publish a comment """Publish a comment
""" """
@ -113,6 +123,12 @@ class PublishComment(BrowserView):
catalog = getToolByName(comment, 'portal_catalog') catalog = getToolByName(comment, 'portal_catalog')
catalog.reindexObject(comment) catalog.reindexObject(comment)
IStatusMessage(self.context.REQUEST).addStatusMessage(
_("Comment published."),
type="info")
return self.context.REQUEST.RESPONSE.redirect(self.context.REQUEST.HTTP_REFERER)
class BulkActionsView(BrowserView): class BulkActionsView(BrowserView):
"""Bulk actions (unapprove, approve, delete, mark as spam). """Bulk actions (unapprove, approve, delete, mark as spam).
""" """