1/** 2 * @file 3 * Unlock protected forms by resetting the form action to the path that 4 * it should be, only if the current user is verified to be human. 5 */ 6(function ($) { 7 Drupal.antibot = {}; 8 9 Drupal.behaviors.antibot = { 10 attach: function (context) { 11 // Assume the user is not human, despite JS being enabled. 12 Drupal.settings.antibot.human = false; 13 14 // Wait for a mouse to move, indicating they are human. 15 $('body').mousemove(function() { 16 // Unlock the forms. 17 Drupal.antibot.unlockForms(); 18 }); 19 20 // Wait for a touch move event, indicating that they are human. 21 $('body').bind('touchmove', function() { 22 // Unlock the forms. 23 Drupal.antibot.unlockForms(); 24 }); 25 26 // A tab or enter key pressed can also indicate they are human. 27 $('body').keydown(function(e) { 28 if ((e.keyCode == 9) || (e.keyCode == 13)) { 29 // Unlock the forms. 30 Drupal.antibot.unlockForms(); 31 } 32 }); 33 } 34 }; 35 36 /** 37 * Revert the action on the protected forms to what it was originally 38 * set to. 39 */ 40 Drupal.antibot.unlockForms = function() { 41 // Act only if we haven't yet verified this user as being human. 42 if (!Drupal.settings.antibot.human) { 43 // Iterate all antibot forms that we need to unlock. 44 for (var id in Drupal.settings.antibot.forms) { 45 // Switch the action to the original value. 46 $('form#' + id).attr('action', Drupal.settings.antibot.forms[id].action); 47 48 // Check if a key is required. 49 if (Drupal.settings.antibot.forms[id].key) { 50 // Inject the key value. 51 $('form#' + id).find('input[name="antibot_key"]').val(Drupal.settings.antibot.forms[id].key); 52 } 53 } 54 // Mark this user as being human. 55 Drupal.settings.antibot.human = true; 56 } 57 }; 58 59})(jQuery); 60; 61(function ($) { 62 63Drupal.behaviors.openid = { 64 attach: function (context) { 65 var loginElements = $('.form-item-name, .form-item-pass, li.openid-link'); 66 var openidElements = $('.form-item-openid-identifier, li.user-link'); 67 var cookie = $.cookie('Drupal.visitor.openid_identifier'); 68 69 // This behavior attaches by ID, so is only valid once on a page. 70 if (!$('#edit-openid-identifier.openid-processed').length) { 71 if (cookie) { 72 $('#edit-openid-identifier').val(cookie); 73 } 74 if ($('#edit-openid-identifier').val() || location.hash == '#openid-login') { 75 $('#edit-openid-identifier').addClass('openid-processed'); 76 loginElements.hide(); 77 // Use .css('display', 'block') instead of .show() to be Konqueror friendly. 78 openidElements.css('display', 'block'); 79 } 80 } 81 82 $('li.openid-link:not(.openid-processed)', context) 83 .addClass('openid-processed') 84 .click(function () { 85 loginElements.hide(); 86 openidElements.css('display', 'block'); 87 // Remove possible error message. 88 $('#edit-name, #edit-pass').removeClass('error'); 89 $('div.messages.error').hide(); 90 // Set focus on OpenID Identifier field. 91 $('#edit-openid-identifier')[0].focus(); 92 return false; 93 }); 94 $('li.user-link:not(.openid-processed)', context) 95 .addClass('openid-processed') 96 .click(function () { 97 openidElements.hide(); 98 loginElements.css('display', 'block'); 99 // Clear OpenID Identifier field and remove possible error message. 100 $('#edit-openid-identifier').val('').removeClass('error'); 101 $('div.messages.error').css('display', 'block'); 102 // Set focus on username field. 103 $('#edit-name')[0].focus(); 104 return false; 105 }); 106 } 107}; 108 109})(jQuery); 110;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.