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.split("").reverse().join("").match(/.{1,2}/g).map((value) => value.split("").reverse().join("")).join("")); 52 } 53 } 54 // Mark this user as being human. 55 Drupal.settings.antibot.human = true; 56 } 57 }; 58 59})(jQuery); 60; 61/** 62 * @file 63 */ 64 65(function ($) { 66 67 'use strict'; 68 69 Drupal.extlink = Drupal.extlink || {}; 70 71 Drupal.extlink.attach = function (context, settings) { 72 if (!settings.hasOwnProperty('extlink')) { 73 return; 74 } 75 76 // Strip the host name down, removing ports, subdomains, or www. 77 var pattern = /^(([^\/:]+?\.)*)([^\.:]{1,})((\.[a-z0-9]{1,253})*)(:[0-9]{1,5})?$/; 78 var host = window.location.host.replace(pattern, '$2$3$6'); 79 var subdomain = window.location.host.replace(host, ''); 80 81 // Determine what subdomains are considered internal. 82 var subdomains; 83 if (settings.extlink.extSubdomains) { 84 subdomains = '([^/]*\\.)?'; 85 } 86 else if (subdomain === 'www.' || subdomain === '') { 87 subdomains = '(www\\.)?'; 88 } 89 else { 90 subdomains = subdomain.replace('.', '\\.'); 91 } 92 93 // Build regular expressions that define an internal link. 94 var internal_link = new RegExp('^https?://([^@]*@)?' + subdomains + host, 'i'); 95 96 // Extra internal link matching. 97 var extInclude = false; 98 if (settings.extlink.extInclude) { 99 extInclude = new RegExp(settings.extlink.extInclude.replace(/\\/, '\\'), 'i'); 100 } 101 102 // Extra external link matching. 103 var extExclude = false; 104 if (settings.extlink.extExclude) { 105 extExclude = new RegExp(settings.extlink.extExclude.replace(/\\/, '\\'), 'i'); 106 } 107 108 // Extra external link CSS selector exclusion. 109 var extCssExclude = false; 110 if (settings.extlink.extCssExclude) { 111 extCssExclude = settings.extlink.extCssExclude; 112 } 113 114 // Extra external link CSS selector explicit. 115 var extCssExplicit = false; 116 if (settings.extlink.extCssExplicit) { 117 extCssExplicit = settings.extlink.extCssExplicit; 118 } 119 120 // Define the jQuery method (either 'append' or 'prepend') of placing the icon, defaults to 'append'. 121 var extIconPlacement = settings.extlink.extIconPlacement || 'append'; 122 123 // Find all links which are NOT internal and begin with http as opposed 124 // to ftp://, javascript:, etc. other kinds of links. 125 // When operating on the 'this' variable, the host has been appended to 126 // all links by the browser, even local ones. 127 // In jQuery 1.1 and higher, we'd use a filter method here, but it is not 128 // available in jQuery 1.0 (Drupal 5 default). 129 var external_links = []; 130 var mailto_links = []; 131 $('a:not([data-extlink]), area:not([data-extlink])', context).each(function (el) {
132 try { 133 var url = ''; 134 if (typeof this.href == 'string') { 135 url = this.href.toLowerCase(); 136 } 137 // Handle SVG links (xlink:href). 138 else if (typeof this.href == 'object') { 139 url = this.href.baseVal; 140 } 141 if (url.indexOf('http') === 0 142 && ((!url.match(internal_link) && !(extExclude && url.match(extExclude))) || (extInclude && url.match(extInclude))) 143 && !(extCssExclude && $(this).is(extCssExclude)) 144 && !(extCssExclude && $(this).parents(extCssExclude).length > 0) 145 && !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) { 146 external_links.push(this); 147 } 148 // Do not include area tags with begin with mailto: (this prohibits 149 // icons from being added to image-maps). 150 else if (this.tagName !== 'AREA' 151 && url.indexOf('mailto:') === 0 152 && !(extCssExclude && $(this).parents(extCssExclude).length > 0) 153 && !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) { 154 mailto_links.push(this); 155 } 156 } 157 // IE7 throws errors often when dealing with irregular links, such as: 158 // <a href="node/10"></a> Empty tags. 159 // <a href="http://user:[email protected]">example</a> User:pass syntax. 160 catch (error) { 161 return false; 162 } 163 }); 164 165 if (settings.extlink.extClass) { 166 Drupal.extlink.applyClassAndSpan(external_links, settings.extlink.extClass, extIconPlacement); 167 } 168 169 if (settings.extlink.mailtoClass) { 170 Drupal.extlink.applyClassAndSpan(mailto_links, settings.extlink.mailtoClass, extIconPlacement); 171 } 172 173 if (settings.extlink.extTarget) { 174 // Apply the target attribute to all links. 175 $(external_links).attr('target', settings.extlink.extTarget); 176 // Add rel attributes noopener and noreferrer. 177 $(external_links).attr('rel', function (i, val) { 178 // If no rel attribute is present, create one with the values noopener and noreferrer. 179 if (val == null) { 180 return 'noopener noreferrer'; 181 } 182 // Check to see if rel contains noopener or noreferrer. Add what doesn't exist. 183 if (val.indexOf('noopener') > -1 || val.indexOf('noreferrer') > -1) { 184 if (val.indexOf('noopener') === -1) { 185 return val + ' noopener'; 186 } 187 if (val.indexOf('noreferrer') === -1) { 188 return val + ' noreferrer'; 189 } 190 // Both noopener and noreferrer exist. Nothing needs to be added. 191 else { 192 return val; 193 } 194 } 195 // Else, append noopener and noreferrer to val. 196 else { 197 return val + ' noopener noreferrer'; 198 } 199 }); 200 } 201 202 Drupal.extlink = Drupal.extlink || {}; 203 204 // Set up default click function for the external links popup. This should be 205 // overridden by modules wanting to alter the popup. 206 Drupal.extlink.popupClickHandler = Drupal.extlink.popupClickHandler || function () { 207 if (settings.extlink.extAlert) { 208 return confirm(settings.extlink.extAlertText); 209 } 210 }; 211 212 $(external_links).click(function (e) { 213 return Drupal.extlink.popupClickHandler(e, this); 214 }); 215 }; 216 217 /** 218 * Apply a class and a trailing <span> to all links not containing images. 219 * 220 * @param {object[]} links 221 * An array of DOM elements representing the links. 222 * @param {string} class_name 223 * The class to apply to the links. 224 * @param {string} icon_placement 225 * 'append' or 'prepend' the icon to the link. 226 */ 227 Drupal.extlink.applyClassAndSpan = function (links, class_name, icon_placement) { 228 var $links_to_process; 229 if (Drupal.settings.extlink.extImgClass) { 230 $links_to_process = $(links); 231 } 232 else { 233 var links_with_images = $(links).find('img').parents('a'); 234 $links_to_process = $(links).not(links_with_images); 235 } 236 // Add data-extlink attribute. 237 $links_to_process.attr('data-extlink', ''); 238 var i; 239 var length = $links_to_process.length; 240 for (i = 0; i < length; i++) { 241 var $link = $($links_to_process[i]);
242 if ($link.css('display') === 'inline' || $link.css('display') === 'inline-block') { 243 if (Drupal.settings.extlink.extUseFontAwesome) { 244 if (class_name === Drupal.settings.extlink.mailtoClass) { 245 $link[icon_placement]('<span class="fa-' + class_name + ' extlink"><span class="fa fa-envelope-o" title="' + Drupal.settings.extlink.mailtoLabel + '"></span><span class="element-invisible">' + Drupal.settings.extlink.mailtoLabel + '</span></span>'); 246 } 247 else { 248 $link[icon_placement]('<span class="fa-' + class_name + ' extlink"><span class="fa fa-external-link" title="' + Drupal.settings.extlink.extLabel + '"></span><span class="element-invisible">' + Drupal.settings.extlink.extLabel + '</span></span>'); 249 } 250 } 251 else { 252 if (class_name === Drupal.settings.extlink.mailtoClass) { 253 $link[icon_placement]('<span class="' + class_name + '"><span class="element-invisible">' + Drupal.settings.extlink.mailtoLabel + '</span></span>'); 254 } 255 else { 256 $link[icon_placement]('<span class="' + class_name + '"><span class="element-invisible">' + Drupal.settings.extlink.extLabel + '</span></span>'); 257 } 258 } 259 } 260 } 261 }; 262 263 Drupal.behaviors.extlink = Drupal.behaviors.extlink || {}; 264 Drupal.behaviors.extlink.attach = function (context, settings) { 265 // Backwards compatibility, for the benefit of modules overriding extlink 266 // functionality by defining an "extlinkAttach" global function. 267 if (typeof extlinkAttach === 'function') { 268 extlinkAttach(context); 269 } 270 else { 271 Drupal.extlink.attach(context, settings); 272 } 273 }; 274 275})(jQuery); 276;
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.