Make Javascripts pass JSLint validation

svn path=/plone.app.discussion/trunk/; revision=39059
This commit is contained in:
Timo Stollenwerk 2010-08-27 10:34:42 +00:00
parent d4b4c56fe2
commit d3074fa4fd
3 changed files with 66 additions and 60 deletions

View File

@ -4,6 +4,9 @@ Changelog
1.0b7 (unreleased)
------------------
* Make Javascripts pass JSLint validation.
[timo]
* Put email notification subscribers into their own zcml file so it is easier
for integrators to override them.
[timo]

View File

@ -1,3 +1,4 @@
jq(document).ready(function () {
@ -19,18 +20,15 @@ jq(document).ready(function() {
/**************************************************************************
* 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.
* Remove all error messages and field values from the form that is passed
* to the function.
**************************************************************************/
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 = jq(".discussion").find(current_reply_id);
createReplyForm(current_reply_to_div);
clearForm(post_comment_div);
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. */
}
@ -64,7 +62,7 @@ jq(document).ready(function() {
/* Remove id="reply" attribute, since we use it to uniquely
the main reply form. */
reply_div.removeAttr("id")
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).
@ -95,15 +93,18 @@ jq(document).ready(function() {
/**************************************************************************
* Remove all error messages and field values from the form that is passed
* to the function.
* 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.
**************************************************************************/
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. */
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 = jq(".discussion").find(current_reply_id);
createReplyForm(current_reply_to_div);
clearForm(post_comment_div);
}
@ -124,14 +125,16 @@ jq(document).ready(function() {
**************************************************************************/
jq("#form-buttons-cancel").bind("click", function (e) {
e.preventDefault();
reply_to_comment_button = jq(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 = jq(this).parents().filter(".reply")
reply_to_comment_form.slideUp("slow", function() { jq(this).remove(); } );
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");

View File

@ -1,3 +1,4 @@
jq(document).ready(function () {
@ -60,15 +61,15 @@ jq(document).ready(function() {
**************************************************************************/
jq("input[name='form.button.BulkAction']").click(function (e) {
e.preventDefault();
var form = jq(this).parents("form")
var form = jq(this).parents("form");
var target = jq(form).attr('action');
var params = jq(form).serialize();
var valArray = jq('input:checkbox:checked');
var selectField = jq(form).find("[name='form.select.BulkAction']");
if (selectField.val() == '-1') {
if (selectField.val() === '-1') {
// XXX: translate message
alert("You haven't selected a bulk action. Please select one.");
} else if (valArray.length == 0) {
} else if (valArray.length === 0) {
// XXX: translate message
alert("You haven't selected any comment for this bulk action. Please select at least one comment.");
} else {
@ -91,13 +92,12 @@ jq(document).ready(function() {
* Check or uncheck all checkboxes from the batch moderation page.
**************************************************************************/
jq("input[name='check_all']").click(function () {
if(jq(this).val()==0){
if (jq(this).val() === 0) {
jq(this).parents("table")
.find("input:checkbox")
.attr("checked", "checked");
jq(this).val("1");
}
else{
} else {
jq(this).parents("table")
.find("input:checkbox")
.attr("checked", "");