Revert r39104 since it breaks the comments js.

svn path=/plone.app.discussion/trunk/; revision=39141
This commit is contained in:
Timo Stollenwerk 2010-08-27 20:45:11 +00:00
parent d713409aa1
commit a1605fb88b

View File

@ -1,17 +1,14 @@
(function ($) {
// Create a namespace for plone.app.discussion
$.discussion = {};
jq(document).ready(function () {
/**************************************************************************
* By default, hide the reply and the cancel button for the regular add
* comment form.
**************************************************************************/
$(".reply").find("input[name='form.buttons.reply']")
jq(".reply").find("input[name='form.buttons.reply']")
.css("display", "none");
$(".reply").find("input[name='form.buttons.cancel']")
jq(".reply").find("input[name='form.buttons.cancel']")
.css("display", "none");
@ -19,19 +16,18 @@
* By default, show the reply button only when Javascript is enabled.
* Otherwise hide it, since the reply functions only work with JS enabled.
**************************************************************************/
$(".reply-to-comment-button").css("display" , "inline");
jq(".reply-to-comment-button").css("display" , "inline");
/**************************************************************************
* Remove all error messages and field values from the form that is passed
* to the function.
**************************************************************************/
$.discussion.clearForm = function (comment_div) {
comment_div.find(".error").removeClass("error");
comment_div.find(".fieldErrorBox").remove();
comment_div.find("input[type='text']").val("");
comment_div.find("textarea").empty();
//comment_div.find("textarea").val("");
function clearForm(form_div) {
form_div.find(".error").removeClass("error");
form_div.find(".fieldErrorBox").remove();
form_div.find("input[type='text']").attr("value", "");
form_div.find("textarea").attr("value", "");
/* XXX: Clean all additional form extender fields. */
}
@ -41,7 +37,7 @@
* the function. We do this by copying the regular comment form and
* adding a hidden in_reply_to field to the form.
**************************************************************************/
$.discussion.createReplyForm = function (comment_div) {
function createReplyForm(comment_div) {
var comment_id = comment_div.attr("id");
@ -50,7 +46,7 @@
/* Clone the reply div at the end of the page template that contains
* the regular comment form.
*/
var reply_div = $("#commenting").clone(true);
var reply_div = jq("#commenting").clone(true);
/* Remove the ReCaptcha JS code before appending the form. If not
* removed, this causes problems
@ -71,7 +67,7 @@
/* Hide the reply button (only hide, because we may want to show it
* again if the user hits the cancel button).
*/
$(reply_button).css("display", "none");
jq(reply_button).css("display", "none");
/* Fetch the reply form inside the reply div */
var reply_form = reply_div.find("form");
@ -101,12 +97,12 @@
* submitted with a value for the "in_reply_to" field in the request),
* create a reply-to-comment form right under this comment.
**************************************************************************/
var post_comment_div = $("#commenting");
var post_comment_div = jq("#commenting");
var in_reply_to_field =
post_comment_div.find("input[name='form.widgets.in_reply_to']");
if (in_reply_to_field.val() !== "") {
var current_reply_id = "#" + in_reply_to_field.val();
var current_reply_to_div = $(".discussion").find(current_reply_id);
var current_reply_to_div = jq(".discussion").find(current_reply_id);
createReplyForm(current_reply_to_div);
clearForm(post_comment_div);
}
@ -116,8 +112,8 @@
* If the user hits the "reply" button of an existing comment, create a
* reply form right beneath this comment.
**************************************************************************/
$(".reply-to-comment-button").bind("click", function (e) {
var comment_div = $(this).parents().filter(".comment");
jq(".reply-to-comment-button").bind("click", function (e) {
var comment_div = jq(this).parents().filter(".comment");
createReplyForm(comment_div);
clearForm(comment_div);
});
@ -127,17 +123,17 @@
* If the user hits the "clear" button of an open reply-to-comment form,
* remove the form and show the "reply" button again.
**************************************************************************/
$("#form-buttons-cancel").bind("click", function (e) {
jq("#form-buttons-cancel").bind("click", function (e) {
e.preventDefault();
var reply_to_comment_button = $(this).
var 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 = $(this).parents().filter(".reply");
reply_to_comment_form = jq(this).parents().filter(".reply");
reply_to_comment_form.slideUp("slow", function () {
$(this).remove();
jq(this).remove();
});
/* Show the reply-to-comment button again. */
@ -145,7 +141,5 @@
});
//#JSCOVERAGE_ENDIF
}(jQuery));
});