Use "(function($) { /* some code that uses $ */ })(jQuery)" instead of "$(document).ready(function(){ /* some code that uses $ */ });" to invoke jQuery code.

svn path=/plone.app.discussion/trunk/; revision=40214
This commit is contained in:
Timo Stollenwerk
2010-09-24 14:21:26 +00:00
parent 4ec334b3d4
commit 399bba5eca
5 changed files with 215 additions and 188 deletions
@@ -5,23 +5,21 @@
dir="ltr" id="html">
<head>
<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" />
<script type="text/javascript" src="../qunit/qunit.js">
</script>
<!-- Scripts -->
<script type="text/javascript" src="jquery.js">
<!-- qUnit -->
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css"
media="screen" />
<script type="text/javascript" src="../qunit/qunit.js"></script>
<!-- jQuery -->
<script type="text/javascript" src="jquery.js"></script>
<!-- plone.app.discussion -->
<script type="text/javascript" src="../../browser/javascripts/comments.js">
</script>
<!-- Tests -->
<script type="text/javascript" src="test_comments.js">
</script>
<script type="text/javascript" src="test_comments.js"></script>
</head>
@@ -115,26 +115,24 @@ $(document).ready(function () {
test("Create a comment reply form.", function() {
expect(2);
var comment_div = $("#1282720906349675");
var reply_button = comment_div.find(".reply-to-comment-button");
// Hit the reply button
reply_button.trigger("click");
createReplyForm(comment_div);
var reply_form = comment_div.find(".reply");
ok(reply_form, "Reply form has been copied");
var reply_button = comment_div.children(".reply-to-comment-button");
$.createReplyForm(comment_div);
var reply_form = comment_div.children(".reply");
ok(reply_form.find("input[name='form.widgets.in_reply_to']"), "Reply form has been copied");
same(reply_form.find("input[name='form.widgets.in_reply_to']").val(), "1282720906349675", "The reply for should have the id of the comment in the in_reply_to field");
});
test("Clear all form values from a form.", function() {
// Create a reply form with some values
var comment_div = $("#1282720906349675");
createReplyForm(comment_div);
$.createReplyForm(comment_div);
var reply_form = comment_div.find(".reply");
var author = reply_form.find("input[name='form.widgets.author']");
var text = comment_div.find("input[name='form.widgets.text']");
author.val("my author");
text.val("my text");
// Call the clearForm function to clear the form
clearForm(comment_div);
$.clearForm(comment_div);
// Check if all form fields have been cleared
var author = comment_div.find("input[name='form.widgets.author']");
var text = comment_div.find("input[name='form.widgets.text']");