Make Javascripts pass JSLint validation
svn path=/plone.app.discussion/trunk/; revision=39059
This commit is contained in:
		
							parent
							
								
									d4b4c56fe2
								
							
						
					
					
						commit
						d3074fa4fd
					
				| @ -4,6 +4,9 @@ Changelog | |||||||
| 1.0b7 (unreleased) | 1.0b7 (unreleased) | ||||||
| ------------------ | ------------------ | ||||||
| 
 | 
 | ||||||
|  | * Make Javascripts pass JSLint validation. | ||||||
|  |   [timo] | ||||||
|  | 
 | ||||||
| * Put email notification subscribers into their own zcml file so it is easier | * Put email notification subscribers into their own zcml file so it is easier | ||||||
|   for integrators to override them. |   for integrators to override them. | ||||||
|   [timo] |   [timo] | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| jq(document).ready(function() { | 
 | ||||||
|  | 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  |      * Remove all error messages and field values from the form that is passed | ||||||
|      * submitted with a value for the "in_reply_to" field in the request),  |      * to the function. | ||||||
|      * create a reply-to-comment form right under this comment. |  | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     var post_comment_div = jq("#commenting"); |     function clearForm(form_div) { | ||||||
|     var in_reply_to_field =  |         form_div.find(".error").removeClass("error"); | ||||||
| 	    post_comment_div.find("input[name='form.widgets.in_reply_to']"); |         form_div.find(".fieldErrorBox").remove(); | ||||||
|     if (in_reply_to_field.val() != "") { |         form_div.find("input[type='text']").attr("value", ""); | ||||||
|         var current_reply_id = "#" + in_reply_to_field.val(); |         form_div.find("textarea").attr("value", ""); | ||||||
|         var current_reply_to_div = jq(".discussion").find(current_reply_id); |         /* XXX: Clean all additional form extender fields. */ | ||||||
|         createReplyForm(current_reply_to_div); |  | ||||||
|         clearForm(post_comment_div); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -39,7 +37,7 @@ jq(document).ready(function() { | |||||||
|      * the function. We do this by copying the regular comment form and  |      * the function. We do this by copying the regular comment form and  | ||||||
|      * adding a hidden in_reply_to field to the form. |      * adding a hidden in_reply_to field to the form. | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     function createReplyForm(comment_div){ |     function createReplyForm(comment_div) { | ||||||
| 
 | 
 | ||||||
|         var comment_id = comment_div.attr("id"); |         var comment_id = comment_div.attr("id"); | ||||||
| 
 | 
 | ||||||
| @ -64,7 +62,7 @@ jq(document).ready(function() { | |||||||
| 
 | 
 | ||||||
|         /* Remove id="reply" attribute, since we use it to uniquely |         /* Remove id="reply" attribute, since we use it to uniquely | ||||||
|            the main reply form. */ |            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 |         /* Hide the reply button (only hide, because we may want to show it | ||||||
|          * again if the user hits the cancel button). |          * 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 |      * If the user has hit the reply button of a reply-to-comment form (form was  | ||||||
|      * to the function. |      * 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) { |     var post_comment_div = jq("#commenting"); | ||||||
|         form_div.find(".error").removeClass("error"); |     var in_reply_to_field =  | ||||||
|         form_div.find(".fieldErrorBox").remove(); |         post_comment_div.find("input[name='form.widgets.in_reply_to']"); | ||||||
|         form_div.find("input[type='text']").attr("value", ""); |     if (in_reply_to_field.val() !== "") { | ||||||
|         form_div.find("textarea").attr("value", ""); |         var current_reply_id = "#" + in_reply_to_field.val(); | ||||||
|         /* XXX: Clean all additional form extender fields. */ |         var current_reply_to_div = jq(".discussion").find(current_reply_id); | ||||||
|  |         createReplyForm(current_reply_to_div); | ||||||
|  |         clearForm(post_comment_div); | ||||||
|     } |     } | ||||||
|     	 |     	 | ||||||
|      |      | ||||||
| @ -111,7 +112,7 @@ jq(document).ready(function() { | |||||||
|      * If the user hits the "reply" button of an existing comment, create a  |      * If the user hits the "reply" button of an existing comment, create a  | ||||||
|      * reply form right beneath this comment. |      * reply form right beneath this comment. | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     jq(".reply-to-comment-button").bind("click", function(e){ |     jq(".reply-to-comment-button").bind("click", function (e) { | ||||||
|         var comment_div = jq(this).parents().filter(".comment"); |         var comment_div = jq(this).parents().filter(".comment"); | ||||||
|         createReplyForm(comment_div); |         createReplyForm(comment_div); | ||||||
|         clearForm(comment_div); |         clearForm(comment_div); | ||||||
| @ -122,21 +123,23 @@ jq(document).ready(function() { | |||||||
|      * If the user hits the "clear" button of an open reply-to-comment form, |      * If the user hits the "clear" button of an open reply-to-comment form, | ||||||
|      * remove the form and show the "reply" button again. |      * remove the form and show the "reply" button again. | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     jq("#form-buttons-cancel").bind("click", function(e){ |     jq("#form-buttons-cancel").bind("click", function (e) { | ||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|         reply_to_comment_button = jq(this). |         var reply_to_comment_button = jq(this). | ||||||
| 		                                  parents(). | 		                                  parents(). | ||||||
| 								          filter(".comment"). | 								          filter(".comment"). | ||||||
| 									      find(".reply-to-comment-button"); | 									      find(".reply-to-comment-button"); | ||||||
| 
 | 
 | ||||||
|         /* Find the reply-to-comment form and hide and remove it again. */ |         /* 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 = jq(this).parents().filter(".reply"); | ||||||
|         reply_to_comment_form.slideUp("slow", function() { jq(this).remove(); } ); |         reply_to_comment_form.slideUp("slow", function () {  | ||||||
|  |             jq(this).remove();  | ||||||
|  |         }); | ||||||
| 
 | 
 | ||||||
|         /* Show the reply-to-comment button again. */ |         /* Show the reply-to-comment button again. */ | ||||||
|         reply_to_comment_button.css("display", "inline"); |         reply_to_comment_button.css("display", "inline"); | ||||||
| 
 | 
 | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  }); | }); | ||||||
|   |   | ||||||
| @ -1,10 +1,11 @@ | |||||||
| jq(document).ready(function() { | 
 | ||||||
|  | jq(document).ready(function () { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     /************************************************************************** |     /************************************************************************** | ||||||
|      * Delete a single comment. |      * Delete a single comment. | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     jq("input[name='form.button.Delete']").click(function(e) { |     jq("input[name='form.button.Delete']").click(function (e) { | ||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|         var button = jq(this); |         var button = jq(this); | ||||||
|         var row = jq(this).parent().parent(); |         var row = jq(this).parent().parent(); | ||||||
| @ -15,13 +16,13 @@ jq(document).ready(function() { | |||||||
|         jq.ajax({ |         jq.ajax({ | ||||||
|             type: "GET", |             type: "GET", | ||||||
|             url: target, |             url: target, | ||||||
|             success: function(msg){ |             success: function (msg) { | ||||||
|                 // fade out row
 |                 // fade out row
 | ||||||
|                 jq(row).fadeOut("normal", function(){ |                 jq(row).fadeOut("normal", function () { | ||||||
|                     jq(this).remove(); |                     jq(this).remove(); | ||||||
|                 }); |                 }); | ||||||
|             }, |             }, | ||||||
|             error: function(msg){ |             error: function (msg) { | ||||||
|                 alert("Error sending AJAX request:" + target); |                 alert("Error sending AJAX request:" + target); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| @ -31,7 +32,7 @@ jq(document).ready(function() { | |||||||
|     /************************************************************************** |     /************************************************************************** | ||||||
|      * Publish a single comment. |      * Publish a single comment. | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     jq("input[name='form.button.Publish']").click(function(e) { |     jq("input[name='form.button.Publish']").click(function (e) { | ||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|         var button = jq(this); |         var button = jq(this); | ||||||
|         var row = jq(this).parent().parent(); |         var row = jq(this).parent().parent(); | ||||||
| @ -42,13 +43,13 @@ jq(document).ready(function() { | |||||||
|             type: "GET", |             type: "GET", | ||||||
|             url: target, |             url: target, | ||||||
|             data: "workflow_action=publish", |             data: "workflow_action=publish", | ||||||
|             success: function(msg){ |             success: function (msg) { | ||||||
|                 // fade out row
 |                 // fade out row
 | ||||||
|                 jq(row).fadeOut("normal", function(){ |                 jq(row).fadeOut("normal", function () { | ||||||
|                     jq(this).remove(); |                     jq(this).remove(); | ||||||
|                 }); |                 }); | ||||||
|             }, |             }, | ||||||
|             error: function(msg){ |             error: function (msg) { | ||||||
|                 alert("Error sending AJAX request:" + target); |                 alert("Error sending AJAX request:" + target); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| @ -58,31 +59,31 @@ jq(document).ready(function() { | |||||||
|     /************************************************************************** |     /************************************************************************** | ||||||
|      * Bulk actions for comments (delete, publish) |      * Bulk actions for comments (delete, publish) | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     jq("input[name='form.button.BulkAction']").click(function(e) { |     jq("input[name='form.button.BulkAction']").click(function (e) { | ||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|         var form = jq(this).parents("form") |         var form = jq(this).parents("form"); | ||||||
|         var target = jq(form).attr('action'); |         var target = jq(form).attr('action'); | ||||||
|         var params = jq(form).serialize(); |         var params = jq(form).serialize(); | ||||||
|         var valArray = jq('input:checkbox:checked'); |         var valArray = jq('input:checkbox:checked'); | ||||||
|         var selectField = jq(form).find("[name='form.select.BulkAction']"); |         var selectField = jq(form).find("[name='form.select.BulkAction']"); | ||||||
|         if (selectField.val() == '-1') { |         if (selectField.val() === '-1') { | ||||||
|             // XXX: translate message
 |             // XXX: translate message
 | ||||||
|             alert("You haven't selected a bulk action. Please select one."); |             alert("You haven't selected a bulk action. Please select one."); | ||||||
|         } else if (valArray.length == 0) { |         } else if (valArray.length === 0) { | ||||||
|             // XXX: translate message
 |             // XXX: translate message
 | ||||||
|             alert("You haven't selected any comment for this bulk action. Please select at least one comment."); |             alert("You haven't selected any comment for this bulk action. Please select at least one comment."); | ||||||
|         } else { |         } else { | ||||||
|             jq.post(target, params, function(data) { |             jq.post(target, params, function (data) { | ||||||
|                 valArray.each(function () { |                 valArray.each(function () { | ||||||
|                     /* Remove all selected lines. */ |                     /* Remove all selected lines. */ | ||||||
|                     var row = jq(this).parent().parent(); |                     var row = jq(this).parent().parent(); | ||||||
|                     row.fadeOut("normal", function() { |                     row.fadeOut("normal", function () { | ||||||
|                         row.remove(); |                         row.remove(); | ||||||
|                     }); |                     }); | ||||||
|                 }); |                 }); | ||||||
|             }); |             }); | ||||||
|             // reset the bulkaction select
 |             // reset the bulkaction select
 | ||||||
|             selectField.find("option[value='-1']").attr( 'selected', 'selected' ); |             selectField.find("option[value='-1']").attr('selected', 'selected'); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
| 	 | 	 | ||||||
| @ -90,17 +91,16 @@ jq(document).ready(function() { | |||||||
|     /************************************************************************** |     /************************************************************************** | ||||||
|      * Check or uncheck all checkboxes from the batch moderation page. |      * Check or uncheck all checkboxes from the batch moderation page. | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     jq("input[name='check_all']").click(function(){ |     jq("input[name='check_all']").click(function () { | ||||||
|           if(jq(this).val()==0){ |         if (jq(this).val() === 0) { | ||||||
|             jq(this).parents("table") |             jq(this).parents("table") | ||||||
|                    .find("input:checkbox") |                    .find("input:checkbox") | ||||||
|                    .attr("checked","checked"); |                    .attr("checked", "checked"); | ||||||
|             jq(this).val("1"); |             jq(this).val("1"); | ||||||
|           } |         } else { | ||||||
|           else{ |  | ||||||
|             jq(this).parents("table") |             jq(this).parents("table") | ||||||
|                    .find("input:checkbox") |                    .find("input:checkbox") | ||||||
|                    .attr("checked",""); |                    .attr("checked", ""); | ||||||
|             jq(this).val("0"); |             jq(this).val("0"); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
| @ -109,7 +109,7 @@ jq(document).ready(function() { | |||||||
|     /************************************************************************** |     /************************************************************************** | ||||||
|      * Show full text of a comment in the batch moderation page. |      * Show full text of a comment in the batch moderation page. | ||||||
|      **************************************************************************/ |      **************************************************************************/ | ||||||
|     jq(".show-full-comment-text").click(function(e) {     |     jq(".show-full-comment-text").click(function (e) {     | ||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|         var target = jq(this).attr("href"); |         var target = jq(this).attr("href"); | ||||||
|         var td = jq(this).parent(); |         var td = jq(this).parent(); | ||||||
| @ -117,11 +117,11 @@ jq(document).ready(function() { | |||||||
|             type: "GET", |             type: "GET", | ||||||
|             url: target, |             url: target, | ||||||
|             data: "", |             data: "", | ||||||
|             success: function(data){ |             success: function (data) { | ||||||
|                 // show full text
 |                 // show full text
 | ||||||
|                 td.replaceWith("<td>" + data + "</td>"); |                 td.replaceWith("<td>" + data + "</td>"); | ||||||
|             }, |             }, | ||||||
|             error: function(msg){ |             error: function (msg) { | ||||||
|                 alert("Error getting full comment text:" + target); |                 alert("Error getting full comment text:" + target); | ||||||
|             } |             } | ||||||
|         });         |         });         | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user