diff sites/all/modules/captcha/captcha.js @ 2:b74b41bb73f0

-- Google analytics module
author danieleb <danielebarchiesi@me.com>
date Thu, 22 Aug 2013 17:22:54 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/all/modules/captcha/captcha.js	Thu Aug 22 17:22:54 2013 +0100
@@ -0,0 +1,40 @@
+(function ($) {
+
+  Drupal.behaviors.captcha = {
+    attach: function (context) {
+
+      // Turn off autocompletion for the CAPTCHA response field.
+      // We do it here with Javascript (instead of directly in the markup)
+      // because this autocomplete attribute is not standard and
+      // it would break (X)HTML compliance.
+      $("#edit-captcha-response").attr("autocomplete", "off");
+
+    }
+  };
+
+  Drupal.behaviors.captchaAdmin = {
+    attach: function (context) {
+    	// Add onclick handler to checkbox for adding a CAPTCHA description
+    	// so that the textfields for the CAPTCHA description are hidden
+    	// when no description should be added.
+      // @todo: div.form-item-captcha-description depends on theming, maybe
+      // it's better to add our own wrapper with id (instead of a class).
+    	$("#edit-captcha-add-captcha-description").click(function() {
+    		if ($("#edit-captcha-add-captcha-description").is(":checked")) {
+    			// Show the CAPTCHA description textfield(s).
+    			$("div.form-item-captcha-description").show('slow');
+    		}
+    		else {
+    			// Hide the CAPTCHA description textfield(s).
+    			$("div.form-item-captcha-description").hide('slow');
+    		}
+    	});
+    	// Hide the CAPTCHA description textfields if option is disabled on page load.
+    	if (!$("#edit-captcha-add-captcha-description").is(":checked")) {
+    		$("div.form-item-captcha-description").hide();
+    	}
+    }
+
+  };
+
+})(jQuery);