PageSourceSearch

https://www.longwood.edu/media/site-assets/public-site/javascript/2023scripts.js

js longwood.edu collected 2026-09-24 09:04:11 UTC 9,402 bytes, 352 lines download raw bytes

1    // Function to check and import assets
2    function importAsset(asset) {
3        var selector = asset.type + '[' + (asset.type === 'link' ? 'href' : 'src') + '="' + asset.href + '"]';
4        var element = document.querySelector(selector);
5
6        if (!element) {
7            element = document.createElement(asset.type);
8            if (asset.type === 'link') {
9                element.rel = asset.rel;
10                element.href = asset.href;
11            } else {
12                element.src = asset.src;
13            }
14            document.head.appendChild(element);
15        }
16    }
17
18$(document).ready(function(){
19
20
21	function heroHeight() {
22		if ($('.hero-slab').length) {
23			$('.page-header').parent(':not(.longwood-fixed)').find('.page-header').show();
24			$('.breadcrumb_con').parent(':not(.longwood-fixed)').find('.breadcrumb_con').show();
25
26			$('.cloned-header, .cloned-breadcrumb').remove();
27
28			const hero = $('.hero-slab .hero-cutout-image');
29			if (!hero.length || !hero.is(':visible')) {
30				// console.warn('Hero image not found or not visible. Skipping heroHeight adjustments for page-header.');
31			}
32			const hh = hero.length ? hero.outerHeight() : 0;
33
34
35			if (window.innerWidth > 63.75 * 16) {
36				$('.page-header').parent(':not(.longwood-fixed)').find('.page-header').each(function() {
37					const originalElement = $(this);
38					if (hero.length) {
39						const cloned = originalElement.clone(true, true).addClass('cloned-header');
40						cloned.height('').appendTo(hero);
41						originalElement.hide();
42					} else {
43						originalElement.show();
44					}
45				});
46			} else {
47				$('.page-header').parent(':not(.longwood-fixed)').find('.page-header').each(function() {
48					const originalElement = $(this);
49					if (hero.length) {
50						const cloned = originalElement.clone(true, true).addClass('cloned-header');
51						cloned.height(hh).insertAfter(hero);
52						originalElement.hide();
53					} else {
54						originalElement.show();
55					}
56				});
57			}
58
59			$('.breadcrumb_con').parent(':not(.longwood-fixed)').find('.breadcrumb_con').each(function() {
60				const originalElement = $(this);
61				if (hero.length) {
62					const cloned = originalElement.clone(true, true).addClass('cloned-breadcrumb');
63					cloned.insertAfter(hero);
64					originalElement.hide();
65				} else {
66					originalElement.show();
67				}
68			});
69			
70		} else {
71			$('.cloned-header, .cloned-breadcrumb').remove();
72			$('.page-header').parent(':not(.longwood-fixed)').find('.page-header').show().removeClass('cloned-header');
73			$('.breadcrumb_con').parent(':not(.longwood-fixed)').find('.breadcrumb_con').show().removeClass('cloned-breadcrumb');
74
75			$('.page-header').addClass('noHero');
76			$('.breadcrumb_con').addClass('noHero');
77		}
78	}
79
80
81
82
83	// HEADER
84	function matchHeaders() {
85		$('nav.actions ul').css('width',$('nav.topLevel ul').innerWidth());
86	}
87	$('header #headerFloat a.headerOpen').click(function(){
88		if ($('header').hasClass('bigmenuOpen')) {
89			$('header').removeClass('bigmenuOpen');
90			if ($(window).scrollTop() > 600) {
91				$('a.lancer-dashboard-toggle').hide();
92			}
93			$('header a.logo').removeClass('lefted');
94		}
95		else {
96			$('header').addClass('bigmenuOpen');
97			$('.off-canvas-wrap').removeClass('move-left');
98			$('a.lancer-dashboard-toggle').show();
99		}
100		matchHeaders();
101		return false;							
102		
103	});
104    
105
106	// detect a click anywhere outside of #header and doesnt have class .lancer-dashboard-toggle
107	$(document).click(function(event) {
108		if (!$(event.target).closest('header').length && !$(event.target).hasClass('lancer-dashboard-toggle')) {
109			if ($('header').hasClass('bigmenuOpen')) {
110				$('header').removeClass('bigmenuOpen');
111				if ($(window).scrollTop() > 600) {
112					$('a.lancer-dashboard-toggle').hide();
113				}
114				$('header a.logo').removeClass('lefted');
115			}
116		}
117	});
118    
119	$('header #headerFloat form input').focus(function(){
120		if (window.innerWidth > 63.75 * 16 ) {
121			// if header a.logo has class "lefted", remove it, else add it
122			if ($('header a.logo').hasClass('lefted')) {
123				$('header a.logo').removeClass('lefted');
124			}
125			else {
126				$('header a.logo').addClass('lefted');
127			}
128			$(this).removeClass('normal');
129		}
130		else {
131			if ($('header').hasClass('bigmenuOpen')) {
132				$('header').removeClass('bigmenuOpen');
133				if ($(window).scrollTop() > 600) {
134					$('a.lancer-dashboard-toggle').hide();
135				}
136				
137			}
138			else {
139				$('header').addClass('bigmenuOpen');
140				$('.off-canvas-wrap').removeClass('move-left');
141				$('a.lancer-dashboard-toggle').show();
142			}
143			matchHeaders();
144			return false;
145
146		}
147	});
148	$('header #headerFloat form input').blur(function(){
149		$(this).val('');
150		if ($('header a.logo').hasClass('lefted')) {
151			$('header a.logo').removeClass('lefted');
152		}
153		else {
154			$('header a.logo').addClass('lefted');
155		}
156	});
157	$('header #headerFloat form input').blur(function(){
158		console.log('scrolltop: '+$(window).scrollTop());
159		if ($(window).scrollTop() > 150) {
160			$(this).addClass('normal');
161		}
162	});
163	$('a.lancer-dashboard-toggle').click(function(){
164		$('html, body').animate({scrollTop:0}, 'fast');
165		$('header').removeClass('bigmenuOpen');
166	});
167	$(window).scroll(function () {
168		if ($(this).scrollTop() > 150) {
169			if (!$('header').hasClass('bigmenuOpen')) {
170				$('a.right-off-canvas-toggle.offcanvas-toggle.lancer-dashboard-toggle.match').hide();
171			}
172			$('header #headerFloat form input').addClass('normal');
173			$('header #headerFloat').addClass('fixed');
174		} else {
175			$('a.right-off-canvas-toggle.offcanvas-toggle.lancer-dashboard-toggle.match').show();
176			$('header #headerFloat form input').removeClass('normal');
177			$('header #headerFloat').removeClass('fixed');
178		}
179	});
180	//on window resize, matchHeaders
181	$(window).resize(function(){
182		matchHeaders();
183		heroHeight();
184        //$('.lancer-dashboard-toggle-container').css('top',$('.inner-wrap > header').outerHeight()+10);
185	});
186
187	$(document).on('click', '.downBadge', function() {
188		// scroll down to .aosContainer
189		$('html, body').animate({
190		scrollTop: $(".impact").offset().top
191		}, 300);
192	});
193	$(window).scroll(function () {
194		// Check the scroll position
195		if ($(this).scrollTop() > 100) {
196			$('.downBadge').hide();
197		} else {
198			// If not scrolled enough, show the element
199			$('.downBadge').show();
200		}
201	});
202
203	heroHeight();
204    //$('.lancer-dashboard-toggle-container').css('top',$('.inner-wrap > header').outerHeight()+10);
205	
206	// lancer dashboard tracking class
207	$('.lancer-dashboard a').addClass('ld_link');
208
209	// END HEADER
210    
211    
212	// PAGE
213	$('.news-list-large').not('.2024newsfeed').each(function() {
214		// mods CT101 Check if there are no <li> elements in the ul.articles of this .news-list-large
215		if ($(this).find('ul.articles li').length === 0) {
216			// remove the whole thing
217			$(this).closest('div.row').remove();
218		}
219	});
220    $('.news-list:has(ul):not(:has(li))').hide(); // hide dept news feeds if no stories
221
222	// END PAGE
223
224	// FOOTER
225	function footerMatchHeight() {
226		$('ul.campus-links').height($('ul.other-links').innerHeight());
227	}
228	function replaceSvgImages(container) {
229		// Find all <img> tags within the container
230		$(container).find('img').each(function() {
231			var imgSrc = $(this).attr('src');
232			
233			// Check if the image source ends with '.svg'
234			if (imgSrc && imgSrc.toLowerCase().endsWith('.svg')) {
235			// Fetch the SVG file
236			$.get(imgSrc, function(data) {
237				// Replace the <img> tag with the SVG content
238				$(data).find('svg').attr('class', $(this).attr('class')); // Preserve class attribute if needed
239				$(this).replaceWith($(data).find('svg'));
240			}.bind(this), 'xml');
241			}
242		});
243	}
244	
245	$(window).resize(function() {
246		footerMatchHeight();
247	});
248	footerMatchHeight();
249	// END FOOTER
250    
251    
252	// MODS
253
254		// NEWS
255		if(window.innerWidth <  63.75 * 16){
256			$('.altMediumImage').prependTo('.story');
257		}
258        
259        // Pagination: hide numbers, keep arrows, show current as plain text
260		const observer = new MutationObserver(() => {
261		const pagination = document.querySelector('.pagination.intranet-news-landing');
262		if (!pagination) return;
263
264		const items = pagination.querySelectorAll('li');
265		if (items.length === 0) return;
266
267		items.forEach(li => {
268			const text = li.textContent.trim();
269
270			// keep arrows
271			if (text === '<<' || text === '<' || text === '>' || text === '>>') return;
272
273			// keep current page, but remove link
274			if (li.classList.contains('current')) {
275			const span = li.querySelector('.currentpage');
276			if (span) {
277				li.innerHTML = `<span class="currentpage">${span.textContent}</span>`;
278			} else {
279				li.textContent = text;
280			}
281			return;
282			}
283
284			// hide all other numbers
285			if (/^\d+$/.test(text)) {
286			li.style.display = 'none';
287			}
288		});
289
290		observer.disconnect();
291		});
292
293		observer.observe(document.body, { childList: true, subtree: true });
294        
295        // Content Type 3208 (click entire container instead of just button)
296        $(document).on('click', '.jpb_event_list ul li.ct3208-event-block', function() {
297			window.location = $(this).find('a.button').attr('href');
298		});
299
300});
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352

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.