1(function ($, Drupal) { 2 Drupal.behaviors.tantalum = { 3 attach: function (context) { 4 $(once('media-embed-link', '.d-media.embedded-media', context)).each(function() { 5 // OM-1700 - Replace media links and remove any empty a tags 6 if ($(this).find("a").hasClass("media-link")) { 7 let manualLinkEl = $(this).find("a").first(); 8 let manualLink = manualLinkEl.attr('href'); 9 let originalLinks = $(this).find("a.media-link"); 10 originalLinks.each(function (index, originalLink) { 11 $(originalLink).attr('href', manualLink); 12 }); 13 if ( manualLinkEl.text().trim() === '') { 14 manualLinkEl.remove(); 15 }; 16 }; 17 18 if ($(this).siblings("a")) { 19 let overrideLink = $(this).siblings("a"); 20 if (overrideLink.text().trim() === '') { 21 overrideLink.remove(); 22 }; 23 }; 24 }); 25 26 const elements = once('share-social-media', '#share-social-media', context); 27 elements.forEach(function(element) { 28 $(element).click(function () { 29 $('.block-simple-blockshare-buttons').toggle(); 30 if ($("#share-social-media").attr("aria-expanded") === "true") { 31 $("#share-social-media").attr("aria-expanded", "false"); 32 $('.block-simple-blockshare-buttons').attr("aria-hidden", "true"); 33 } 34 else { 35 $("#share-social-media").attr("aria-expanded", "true"); 36 $('.block-simple-blockshare-buttons').attr("aria-hidden", "false"); 37 $('.a2a_button_facebook').focus(); 38 } 39 }); 40 }); 41 42 var custom_interval = setInterval(function () { 43 $(".layerTile").each(function (index) { 44 if ($(this).attr("alt") == "" || typeof $(this).attr("alt") === "undefined") { 45 $(this).attr("alt", `layer ${index}`); 46 clearInterval(custom_interval); 47 } 48 }); 49 }, 500); 50 51 $(".diff-controls__item").each(function () { 52 const title = $("label", this).text(); 53 if (title === "View mode") { 54 $(this).hide(); 55 } 56 }); 57 58 // Any time WYSIWYG W/Media is present, look for embedded media and grab 59 // the view mode to add to the figure wrapper. Way easier to handle styling. 60 const embeddedMedia = $(".field-text-with-media figure > .d-media"); 61 if ($(embeddedMedia).length !== 0) { 62 $(embeddedMedia).each(function () { 63 const media = $(this); 64 const classes = $(media).attr("class").split(" "); 65 $.each(classes, function (index, item) { 66 if (item.includes("view-mode")) { 67 const viewModeClass = item.replace("media--view-mode--", ""); 68 $(media).closest("figure").addClass(viewModeClass); 69 } 70 }); 71 }); 72 } 73 74 // Placeholder test for sidebar map 75 function openModal(modalUrl) { 76 const ajaxSettings = { 77 url: modalUrl, 78 dialogType: "modal", 79 dialog: { 80 width: 1000, 81 classes: { 82 "ui-dialog": "sidebar-ui-dialog" 83 } 84 }, 85 }; 86 Drupal.ajax(ajaxSettings).execute(); 87 } 88 89 const modals = once('modal-popup-link', '.modal-popup-link', context); 90 modals.forEach(function(modal) { 91 $(modal).click(function() { 92 const modalUrl = $(this).attr("data-link"); 93 if (modalUrl) { 94 openModal(modalUrl); 95 } 96 }) 97 }) 98 }, 99 }; 100 101 // Toggles Explore Search section if there are more than 5 terms 102 // Special logic needed for layouts with tabs/accordions 103 const tabScienceTerms = $(".usgs-tabs-wrapper .c-usgs-explore-science ul").find("li"); 104 const accordionScienceTerms = $(".usgs-accordion-wrapper .c-usgs-explore-science ul").find("li"); 105 const scienceTerms = $(".c-usgs-explore-science ul").find("li"); 106 const tabWrapper = ".node--type--science .usgs-tabs-wrapper"; 107 const accordionWrapper = ".node--type--science .usgs-accordion-wrapper"; 108 const wrapper = ""; 109 110 function hideKeywords($element, $type) { 111 if ($element.length > 5) { 112 $(".d-usgs-keyword-more").show(); 113 $element.each(function (i) { 114 if (i > 4) { 115 $(this).hide(); 116 } 117 }); 118 119 $(`${$type} .d-usgs-keyword-more`).click(function (event) { 120 event.preventDefault(); 121 $element.each(function (i) { 122 if (i > 4) { 123 $(this).toggle(); 124 } 125 }); 126 if ($(this).find("i").hasClass("fa-arrow-down")) { 127 $(this).find("i").removeClass("fa-arrow-down").addClass("fa-arrow-up"); 128 } else if ($(this).find("i").hasClass("fa-arrow-up")) { 129 $(this).find("i").removeClass("fa-arrow-up").addClass("fa-arrow-down"); 130 } 131 }); 132 } 133 } 134 135 if ($(tabWrapper).length || $(accordionWrapper).length) { 136 // Hide keywords on desktop tabs 137 hideKeywords(tabScienceTerms, tabWrapper); 138 // Hide keywords on mobile tabs 139 hideKeywords(accordionScienceTerms, accordionWrapper); 140 } else { 141 // Hide keywords on mobile tabs 142 hideKeywords(scienceTerms, wrapper); 143 } 144 145 $(".fas.fa-share-alt").click(function () { 146 $(".block-addtoany-block").toggle(); 147 }); 148 149 // On a group homepage, if there is nothing in the group body, then there shouldn't be any bottom border on info-link block 150 if ($(".group-home-content").length) { 151 if ($.trim($(".group-home-content").text()).length == 0 && $(".info-links").length) { 152 $(".info-links").css("border-bottom", "none"); 153 // Mobile 154 $(".info-links .field-last .paragraph").css("border-bottom", "none"); 155 } 156 } 157 158 // If LP does not have info links and the view is empty, hide the bottom boder 159 if ($(".node--type--landing-page").length) { 160 if (!$(".node-intro").hasClass(".info-links") && $(".view-group-lp.view-empty").length) { 161 $(".intro-cta").css("border-bottom", "none"); 162 } 163 } 164})(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.