From e9f24cfa74a61c79984290def482d59010c5cc0e Mon Sep 17 00:00:00 2001 From: Timo Stollenwerk Date: Sat, 20 Jun 2009 16:00:36 +0000 Subject: [PATCH] Complete rewrite of the show/hide reply-to-comment forms. Switch from Javascript event handlers to jQuery event binding. Replace reply-to-comment image with a standard reply button. Fix IE7 show reply-to-comment form is not working. svn path=/plone.app.discussion/trunk/; revision=27533 --- plone/app/discussion/browser/comments.pt | 17 ++- .../javascripts/reply_to_comment_form.js | 117 ++++++++++-------- 2 files changed, 71 insertions(+), 63 deletions(-) diff --git a/plone/app/discussion/browser/comments.pt b/plone/app/discussion/browser/comments.pt index a04ee14..3938f3e 100644 --- a/plone/app/discussion/browser/comments.pt +++ b/plone/app/discussion/browser/comments.pt @@ -34,7 +34,7 @@ anonymous_creator python:creator in ('Anonymous User', '');" tal:attributes="class python:'comment replyTreeLevel'+str(depth); style string:margin-left: ${depth}em; - id string:comment-${reply/id}"> + id string:${reply/id}">
@@ -85,6 +85,13 @@ This is the body text of the comment.
+ +
- - - - diff --git a/plone/app/discussion/browser/javascripts/reply_to_comment_form.js b/plone/app/discussion/browser/javascripts/reply_to_comment_form.js index c4a0ca2..273c12d 100644 --- a/plone/app/discussion/browser/javascripts/reply_to_comment_form.js +++ b/plone/app/discussion/browser/javascripts/reply_to_comment_form.js @@ -1,71 +1,80 @@ jq(document).ready(function() { - /* Show the reply-to-comment button only when Javascript is enabled. + + /***************************************************************** + * 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" , "block"); - }); + *****************************************************************/ + jq(".reply-to-comment-button").css("display" , "inline"); -function createReplyToCommentForm(comment_id) { - /* - * This function creates a form to reply to a specific comment with - * the comment_id given as parameter. It does so by cloneing the existing - * commenting form at the end of the page template. - */ - /* The jQuery id of the reply-to-comment button */ - var button = "#reply-to-comment-" + comment_id + "-button"; + /***************************************************************** + * Create reply to comment form. + *****************************************************************/ + jq(".reply-to-comment-button").bind("click", function(e){ - /* 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. - */ - reply_div = jq("#commenting").clone(true); - reply_div.insertAfter(button).css("display", "none") + var comment_div = jq(this).parents().filter(".comment"); + var comment_id = comment_div.attr("id"); - /* Remove id="reply" attribute, since we use it to uniquely - the main reply form. */ - reply_div.removeAttr("id") + var reply_button = comment_div.find(".reply-to-comment-button"); - /* Hide the reply button (only hide, because we may want to show it - * again if the user hits the cancel button). - */ - jq(button).css("display", "none"); + /* 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"); - /* Fetch the reply form inside the reply div */ - reply_form = reply_div.find("form"); + /* Remove id="reply" attribute, since we use it to uniquely + the main reply form. */ + reply_div.removeAttr("id") - /* Add a hidden field with the id of the comment */ - reply_form.append("