Move the functions out of the ready function. this makes the JS tests pass.
svn path=/plone.app.discussion/trunk/; revision=39151
This commit is contained in:
parent
67fb426f08
commit
ba8e7ac5cd
@ -1,24 +1,3 @@
|
||||
|
||||
jq(document).ready(function () {
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* By default, hide the reply and the cancel button for the regular add
|
||||
* comment form.
|
||||
**************************************************************************/
|
||||
jq(".reply").find("input[name='form.buttons.reply']")
|
||||
.css("display", "none");
|
||||
jq(".reply").find("input[name='form.buttons.cancel']")
|
||||
.css("display", "none");
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* By default, show the reply button only when Javascript is enabled.
|
||||
* Otherwise hide it, since the reply functions only work with JS enabled.
|
||||
**************************************************************************/
|
||||
jq(".reply-to-comment-button").css("display" , "inline");
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* Remove all error messages and field values from the form that is passed
|
||||
* to the function.
|
||||
@ -46,7 +25,7 @@ jq(document).ready(function () {
|
||||
/* Clone the reply div at the end of the page template that contains
|
||||
* the regular comment form.
|
||||
*/
|
||||
var reply_div = jq("#commenting").clone(true);
|
||||
var reply_div = $("#commenting").clone(true);
|
||||
|
||||
/* Remove the ReCaptcha JS code before appending the form. If not
|
||||
* removed, this causes problems
|
||||
@ -67,7 +46,7 @@ jq(document).ready(function () {
|
||||
/* 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");
|
||||
$(reply_button).css("display", "none");
|
||||
|
||||
/* Fetch the reply form inside the reply div */
|
||||
var reply_form = reply_div.find("form");
|
||||
@ -92,17 +71,37 @@ jq(document).ready(function () {
|
||||
}
|
||||
|
||||
|
||||
$(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']")
|
||||
.css("display", "none");
|
||||
$(".reply").find("input[name='form.buttons.cancel']")
|
||||
.css("display", "none");
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* 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");
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* If the user has hit the reply button of a reply-to-comment form (form was
|
||||
* 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 = jq("#commenting");
|
||||
var post_comment_div = $("#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 = jq(".discussion").find(current_reply_id);
|
||||
var current_reply_to_div = $(".discussion").find(current_reply_id);
|
||||
createReplyForm(current_reply_to_div);
|
||||
clearForm(post_comment_div);
|
||||
}
|
||||
@ -112,8 +111,8 @@ jq(document).ready(function () {
|
||||
* If the user hits the "reply" button of an existing comment, create a
|
||||
* reply form right beneath this comment.
|
||||
**************************************************************************/
|
||||
jq(".reply-to-comment-button").bind("click", function (e) {
|
||||
var comment_div = jq(this).parents().filter(".comment");
|
||||
$(".reply-to-comment-button").bind("click", function (e) {
|
||||
var comment_div = $(this).parents().filter(".comment");
|
||||
createReplyForm(comment_div);
|
||||
clearForm(comment_div);
|
||||
});
|
||||
@ -123,17 +122,17 @@ jq(document).ready(function () {
|
||||
* If the user hits the "clear" button of an open reply-to-comment form,
|
||||
* remove the form and show the "reply" button again.
|
||||
**************************************************************************/
|
||||
jq("#form-buttons-cancel").bind("click", function (e) {
|
||||
$("#form-buttons-cancel").bind("click", function (e) {
|
||||
e.preventDefault();
|
||||
var reply_to_comment_button = jq(this).
|
||||
var reply_to_comment_button = $(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 = $(this).parents().filter(".reply");
|
||||
reply_to_comment_form.slideUp("slow", function () {
|
||||
jq(this).remove();
|
||||
$(this).remove();
|
||||
});
|
||||
|
||||
/* Show the reply-to-comment button again. */
|
||||
|
@ -4,12 +4,12 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
|
||||
dir="ltr" id="html">
|
||||
<head>
|
||||
<meta name="generator" content=
|
||||
"HTML Tidy, see www.w3.org" />
|
||||
<meta http-equiv="Content-Type" content=
|
||||
"text/html; charset=utf-8" />
|
||||
|
||||
<title>plone.app.discussion comments Test Suite</title>
|
||||
|
||||
<!-- pad js -->
|
||||
<script type="text/javascript" src="../../browser/javascripts/comments.js">
|
||||
</script>
|
||||
|
||||
<!-- QUnit -->
|
||||
<link rel="stylesheet" href="../qunit/qunit.css" type=
|
||||
"text/css" media="screen" />
|
||||
@ -18,12 +18,11 @@
|
||||
<!-- Scripts -->
|
||||
<script type="text/javascript" src="jquery.js">
|
||||
</script>
|
||||
<script type="text/javascript" src=
|
||||
"../../browser/javascripts/comments.js">
|
||||
</script>
|
||||
|
||||
<!-- Tests -->
|
||||
<script type="text/javascript" src="test_comments.js">
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -40,5 +39,6 @@
|
||||
<ol id="qunit-tests">
|
||||
</ol>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
|
||||
module("comments", {
|
||||
setup: function () {
|
||||
@ -96,5 +98,9 @@ test("Clear all form values from a form.", function() {
|
||||
var text = comment_div.find("input[name='form.widgets.text']");
|
||||
equals(author.val(), "", "The author form value should be empty");
|
||||
equals(text.text(), "", "The text form value should be empty");
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user