1(function ($, Drupal) { 2 const onceName = 'akt_expand_collapse'; 3 4 var strReplaceAll = function (str,mapObj) { 5 var re = new RegExp(Object.keys(mapObj).join("|"),"g"); 6 7 return str.replace(re, function(matched){ 8 return mapObj[matched]; 9 }); 10 } 11 12 /** 13 * Enable expand/collapse elements from CKEditor. 14 */ 15 Drupal.behaviors.expand_collapse = { 16 attach: function (context, settings) { 17 once(onceName, '[data-collapsed-content]', context).forEach(async function (element) { 18 var el = $(element); 19 if (!el.hasClass('collapsible-content')) { 20 var toggleText = el.data('collapsed-content').toggle_text; 21 22 if (!toggleText) { 23 toggleText = "Show Translation"; 24 } 25 26 expandedToggleText = strReplaceAll(toggleText, { 27 'Show' : 'Hide', 28 'Expand' : 'Collapse', 29 'View' : 'Hide', 30 'Display': 'Hide', 31 }); 32 33 var toggleButton = "<div><button class='accordion-button inline-link' data-collapsed-label='"+toggleText+"' data-expanded-label='"+expandedToggleText+"'><span>"+toggleText+"</span></button></div>"; 34 35 $(toggleButton).insertBefore(el); 36 el.addClass('collapsible-content'); 37 } 38 }); 39 } 40 } 41})(jQuery, Drupal);
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.