[177a560] | 1 | |
---|
| 2 | // JavaScript behaviors for the Image CAPTCHA |
---|
| 3 | Drupal.behaviors.imageCaptcha = function (context) { |
---|
| 4 | |
---|
| 5 | // Add a click event to CAPTCHA images to reload the CAPTCHA image |
---|
| 6 | $(".captcha_image", context).click(function() { |
---|
| 7 | $(this).attr('src', $(this).attr('src').replace(/\?.*$/, '') + '?r=' + Math.random()); |
---|
| 8 | }) |
---|
| 9 | |
---|
| 10 | }; |
---|
| 11 | |
---|
| 12 | // JavaScript behaviors for the Image CAPTCHA admin page |
---|
| 13 | Drupal.behaviors.imageCaptchaAdmin = function (context) { |
---|
| 14 | |
---|
| 15 | // Helper function to show/hide noise level widget. |
---|
| 16 | var noise_level_shower = function(speed) { |
---|
| 17 | speed = (typeof speed == 'undefined') ? 'slow' : speed; |
---|
| 18 | if ($("#edit-image-captcha-dot-noise").is(":checked") || $("#edit-image-captcha-line-noise").is(":checked")) { |
---|
| 19 | $("#edit-image-captcha-noise-level-wrapper").show(speed); |
---|
| 20 | } |
---|
| 21 | else { |
---|
| 22 | $("#edit-image-captcha-noise-level-wrapper").hide(speed); |
---|
| 23 | } |
---|
| 24 | } |
---|
| 25 | // Add onclick handler to the dot and line noise check boxes. |
---|
| 26 | $("#edit-image-captcha-dot-noise").click(noise_level_shower); |
---|
| 27 | $("#edit-image-captcha-line-noise").click(noise_level_shower); |
---|
| 28 | // Show or hide appropriately on page load. |
---|
| 29 | noise_level_shower(0); |
---|
| 30 | |
---|
| 31 | // Helper function to show/hide smooth distortion widget. |
---|
| 32 | var smooth_distortion_shower = function(speed) { |
---|
| 33 | speed = (typeof speed == 'undefined') ? 'slow' : speed; |
---|
| 34 | if ($("#edit-image-captcha-distortion-amplitude").val() > 0) { |
---|
| 35 | $("#edit-image-captcha-bilinear-interpolation-wrapper").show(speed); |
---|
| 36 | } |
---|
| 37 | else { |
---|
| 38 | $("#edit-image-captcha-bilinear-interpolation-wrapper").hide(speed); |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | // Add onchange handler to the distortion level select widget. |
---|
| 42 | $("#edit-image-captcha-distortion-amplitude").change(smooth_distortion_shower); |
---|
| 43 | // Show or hide appropriately on page load. |
---|
| 44 | smooth_distortion_shower(0) |
---|
| 45 | |
---|
| 46 | }; |
---|