1/** 2 * @file 3 */ 4 5(function ($, Drupal, drupalSettings) { 6 7 'use strict'; 8 9 Drupal.extlink = Drupal.extlink || {}; 10 11 /** 12 * Apply a class and a trailing <span> to all links not containing images. 13 * 14 * @param {object[]} links 15 * An array of DOM elements representing the links. 16 * @param {string} class_name 17 * The class to apply to the links. 18 */ 19 Drupal.extlink.applyClassAndSpan = function (links, class_name) { 20 var $links_to_process, $links_with_images, i, length; 21 if (drupalSettings.data.extlink.extImgClass) { 22 $links_to_process = $(links); 23 } 24 else { 25 $links_with_images = $(links).find('img, svg').parents('a'); 26 $links_to_process = $(links).not($links_with_images); 27 } 28 29 // Add data-extlink attribute. 30 $links_to_process.attr('data-extlink', ''); 31 32 length = $links_to_process.length; 33 for (i = 0; i < length; i++) { 34 var $link = $($links_to_process[i]), $span; 35 if (class_name !== '0') { 36 $span = $link.find('span.apply-external'); 37 if ($span.length) { 38 $link = $span; 39 } 40 $link.removeClass('internal-url'); 41 $link.addClass(class_name); 42 Drupal.attachBehaviors($link.parent().get(0)); 43 } 44 if (class_name === drupalSettings.data.extlink.mailtoClass) { 45 $link.append('<span class="' + class_name + '" aria-label="' + drupalSettings.data.extlink.mailtoLabel + '"></span>'); 46 } 47 } 48 }; 49 50})(jQuery, Drupal, drupalSettings);
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.