1/*-------------------------------------------------------------- 2# Custom 'child theme' javascript added to the IDFive templates by the Communications and Public Affairs web team 3--------------------------------------------------------------*/ 4 5/*-------------------------------------------------------------- 6# UMB Alerts Banner 7--------------------------------------------------------------*/ 8 9$( document ).ready(function() { 10 $.ajax({ 11 url: "https://www.umaryland.edu/alerts-include/?template=umbbanner", 12 cache: false, 13 dataType: "html", 14 success: function(data) { 15 /*Checks for comment confirming there is an active alert*/ 16 if ( data.includes("Alerts code will be output") ) 17 { 18 $( "div.off-canvas" ).addClass("--has-global-alert").prepend( '<div class="global-alert" id="global-alert">' + data + '</div>' ); 19 20 } 21 22 } 23 }); 24}); 25 26/*-------------------------------------------------------------- 27# If the hero title on the UMB homepage or a landing page is too large to fit on one line, shrink the font size until it fits 28--------------------------------------------------------------*/ 29 30function isOverflowingX(overflowElement) { 31 /*Check if the specified element is overflowing its container on the X axis*/ 32 var IsOverflowingBool = false; 33 $(overflowElement).each(function() { 34 if ( (this).offsetWidth < (this).scrollWidth ) { 35 IsOverflowingBool = true; 36 } 37 }); 38 return IsOverflowingBool; 39}; 40 41function fixHeroOverflow() { 42 var overflowElement = ".hero__content .hero__title"; /*The selector for the hero title*/ 43 var minFontSize = 18; /*Cannot shrink below the specified minimum size*/ 44 $( '.hero__content, ' + overflowElement ).css('max-width','100%').css('overflow-x','hidden').css('overflow-y','hidden'); /*Sets necessary CSS to the hero title and its container*/ 45 $(overflowElement).css('font-size',''); /*Resets font size (necessary on certain page size changes)*/ 46 while (isOverflowingX(overflowElement) && (parseInt($(overflowElement).css('font-size')) > minFontSize)) { 47 $(overflowElement).css('font-size', (parseInt($(overflowElement).css('font-size')) - 1) + 'px' ); 48 } 49}; 50 51/*Run the function on document ready*/ 52$( document ).ready(function() { 53 fixHeroOverflow(); 54}); 55 56/*Run after page is fully loaded (there's a chance fonts won't be fully loaded on document ready)*/ 57$( window ).on('load', function() { 58 fixHeroOverflow(); 59}); 60 61/*Run the function on page resize*/ 62$( window ).resize(function() { 63 fixHeroOverflow(); 64}); 65 66/*-------------------------------------------------------------- 67# Icons to identify file links and external links 68--------------------------------------------------------------*/ 69 70$( document ).ready(function() { 71 72 /*Add icons to external links*/ 73 74 /*Note: Certain incompatible content types, including Multi-column Card links and Featured News Headline links (see below), excluded*/ 75 var linkIconExclusions = '.promotional-badges__badge a, a.card__link, .featured-news__headline a, a.related__resources-sociallinks-button, .paragraph-widget--social-directory a'; 76 77 /*Apply the icons to most links*/ 78 $('#main-content a').not('[href*="umaryland.edu"]').not(linkIconExclusions).filter(function() { 79 return this.hostname && this.hostname !== location.hostname; 80 }).append('Â <span class="externallinkmarker"></span>'); 81 82 /*Multi-column Card links and Featured News Headline links need the link to be appended in the child span instead*/ 83 $('#main-content a.card__link, #main-content .featured-news__headline a').not('[href*="umaryland.edu"]').filter(function() { 84 return this.hostname && this.hostname !== location.hostname; 85 }).children('span').append('Â <span class="externallinkmarker"></span>'); 86 87 /*Add icons to file links*/ 88 89 /*Cycle through all file extensions we want to apply icons to*/ 90 $.each(['sitemanager','pdf','doc','docx','rtf','xls','xlsx','ppt','pptx','zip'], function( index, value ) { 91 92 /*Define the HTML code to be appended to standard file links*/ 93 var fileLinkIconHTML; 94 var linkConditional; 95 if (value == 'sitemanager') { 96 /*Preview links in the CMS are a special case*/ 97 fileLinkIconHTML = 'Â <span class="filelinkmarker">file</span>'; 98 linkConditional = '[href*="SiteManager?ctfn=download"]'; 99 } else { 100 fileLinkIconHTML = 'Â <span class="filelinkmarker">' + value + '</span>'; 101 linkConditional = '[href$="' + value + '" i]';/*Note: The i makes the selector case-insensitive*/ 102 } 103 104 /*Apply the icons to most links*/ 105 /*Note: Certain incompatible content types, including Multi-column Card links and Featured News Headline links (see below), excluded. Any links already marked as external are also excluded*/ 106 $( '#main-content a' + linkConditional).not(':has(.externallinkmarker)').not(linkIconExclusions).append(fileLinkIconHTML); 107 108 /*Multi-column Card links and Featured News Headline links need the link to be appended in the child span instead*/ 109 $( '#main-content a' + linkConditional + '.card__link, #main-content .featured-news__headline a' + linkConditional ).not(':has(.externallinkmarker)').children('span').append(fileLinkIconHTML); 110 111 }); 112 113 /*Icons in Related Resources links need an extra span (applies to both file links and external links)*/ 114 $( '#main-content .related__resources-links a:has(.externallinkmarker, .filelinkmarker)').wrapInner('<span></span>'); 115 116}); 117 118/*-------------------------------------------------------------- 119# Selectively float images in the Article content type, based on their dimensions 120--------------------------------------------------------------*/ 121 122$( document ).ready(function() { 123 124 /*In fulltext Articles, adjust the style of the featured image based on its size and aspect ratio*/ 125 126 $('.featured-news__fulltext__image').each(function() { 127 128 /*Get the containing element's current width, and the intrinsic width & height of the image (as opposed the current display width and height)*/ 129 130 var containerWidth = $('.featured-news__fulltext').width();
131 var imageWidth = $(this)[0].naturalWidth; 132 var imageHeight = $(this)[0].naturalHeight; 133 134 /*Image is displayed block-level by default*/ 135 136 /*If image is too small (less than 900 pixels wide and less than 75% of the container width) OR image is too tall (aspect ratio under 16:9)*/ 137 if (((imageWidth < 900) && (imageWidth < (containerWidth * .75))) || ((imageWidth / imageHeight) < (16/9))) { 138 139 /*Float the image right*/ 140 $(this).css('float','right'); 141 142 /*If the image is to be floated right, unfloat the pullquote to avoid conflicts*/ 143 $('.featured-news__fulltext__pullquote').addClass('unfloated-pullquote'); 144 145 } 146 147 }); 148 149}); 150 151/*-------------------------------------------------------------- 152# Remove carousel containers from the tab index, for improved accessibility 153--------------------------------------------------------------*/ 154 155$( document ).ready(function() { 156 $(".carousel.flickity-enabled.is-draggable").attr('tabindex', '-1'); 157});
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.