PageSourceSearch

https://www.ramapo.edu/wp-content/themes/rcnjrd/js/main.js?ver=7.1.2

js ramapo.edu collected 2026-10-01 09:23:07 UTC 18,747 bytes, 609 lines download raw bytes

1(function($) {
2$(document).ready(function() {
3
4	$(".fancybox").fancybox({
5		 openEffect  : 'elastic',
6		 closeEffect : 'elastic',
7		 margin      : [50, 20, 50, 20],
8		 helpers : {
9			 title : {
10				 type : 'inside'
11			 },
12			 // prevent page jump top when clicked on element with the fancybox class
13			 overlay: {
14				locked: false
15			}
16		 },
17		 beforeShow : function() {
18			 var alt = this.element.find('img').attr('alt');        
19			 this.inner.find('img').attr('alt', alt);        
20			 this.title = alt;
21		 }
22	 });
23	 
24	$( "#main-nav li.has-menu").hover(
25		function() {
26			$(this).addClass( "active" );
27			$("#main-nav").addClass( "hovered" );
28		},function() {
29			$("#main-nav").removeClass( "hovered" );
30			$("#main-nav li.has-menu").removeClass( "active" );
31		}   
32	);
33
34	// keyboard navigation on focus
35	$( "#main-nav li.has-menu").focusin(
36		function() {
37			// first remove all classes from all elements
38			$("#main-nav").removeClass( "hovered" );
39			$("#main-nav li.has-menu").removeClass( "active" );
40
41			// add class to only current focused element
42			$(this).addClass( "active" );
43			$("#main-nav").addClass( "hovered" );
44		}   
45	);
46
47	$( "#main-nav").focusout(
48		function() {
49			// first remove all classes from all elements
50			$("#main-nav").removeClass( "hovered" );
51			$("#main-nav li.has-menu").removeClass( "active" );
52		}   
53	);
54
55	// open and close hamburger menu
56	$('#menu-toggle').on('click touchend', function(e) {
57		$(this).toggleClass('open');
58		$("#main-nav, body").toggleClass('open');
59		return false;
60	});
61	
62
63	// hide div with content on load
64	$("#majorsFooterExplanation").hide();	
65
66	
67	$("#main-nav li.has-menu").on('click', '.parent', function() {
68		if ($(window).width() <= 1023){
69			$(this).parent().toggleClass('clicked');
70		}
71		return false;
72	});
73
74	$("#main-nav li.has-menu").on('click', '.parent-sub', function(event) {
75		if ($(window).width() <= 1023){
76			$(this).parent().toggleClass('clicked');
77		}
78		return false;
79	});
80
81	// keep the mobile menu open
82	$('#main-ul').focusin( function(event) {
83		if ($(window).width() <= 1023){
84			$("#main-nav, body").addClass('open');
85			$("#menu-toggle").addClass('open');
86		}
87	});
88	$('#main-ul').focusout( function(event) {
89		if ($(window).width() <= 1023){
90			$("#main-nav, body").removeClass('open');
91			$("#menu-toggle").removeClass('open');
92		}
93	});
94
95	// keep the mobile menu open while in the submenues
96	$(".title, .hide-desktop").focusin( function(event) {
97		$(this).parents(".has-menu").addClass( "clicked active" );
98	});
99	
100	$(window).on('load scroll', function(){
101		var windowTop = $(window).scrollTop();
102
103		if(windowTop <= 167){
104				$("#scroll-nav").removeClass("is-scrolled");
105		}
106		else{
107				$("#scroll-nav").addClass("is-scrolled");
108		}
109	}); 
110	
111	$( window ).resize(function() {
112		$("#main-nav, body, #menu-toggle").removeClass('open');
113		$("#main-nav ul").removeProp('style');
114		if ($(window).width() >= 768){
115			$("#person-slideshow").addClass('desktop');
116			$("#page-slideshow").addClass('desktop');
117			$("#breadcrumbs ul, #breadcrumbs .fa-minus").hide();
118			$("#breadcrumbs .fa-plus").show();
119		}
120		else {
121			$("#person-slideshow").removeClass('desktop');
122			$("#page-slideshow").removeClass('desktop');
123		}
124	});
125	
126	$( '#person-slideshow' ).on( 'cycle-initialized', function( event, opts ) {
127		 if ($(window).width() >= 768){
128			 $("#person-slideshow").addClass('desktop');
129		 }
130		 else {
131			$("#person-slideshow").removeClass('desktop');
132		 }
133	});
134	
135	$(".callout #trigger a").click(function(){
136		$('#swap-items').slideToggle();
137		return false;
138	});
139			
140	$("#swap-items li").click(function(){
141		var show = $(this).attr('rel');
142		$(".swap-content.active").slideToggle().removeClass('active');
143		$("#" + show).slideToggle().addClass('active');
144		$('#swap-items').slideToggle();
145	});
146	
147	$("#breadcrumbs h1 span").click(function(event) {
148		$("#breadcrumbs > .wrapper > ul").slideToggle('slow');
149		$("#breadcrumbs .fa-plus, #breadcrumbs .fa-minus").slideToggle('slow');
150		$(this).toggleClass('open');
151		return false;
152	});
153	$("#mobile-site-nav").keypress(function(event) {
154		$("#breadcrumbs > .wrapper > ul").slideToggle('slow');
155		$("#breadcrumbs .fa-plus, #breadcrumbs .fa-minus").slideToggle('slow');
156		$(this).toggleClass('open');
157		return false;
158	});
159	// $("#bc-menu").focusout(function(event) {
160	// 	$("#breadcrumbs > .wrapper > ul").slideToggle('slow');
161	// 	$("#breadcrumbs .fa-plus, #breadcrumbs .fa-minus").slideToggle('slow');
162	// 	$(this).toggleClass('open');
163	// 	return false;
164	// });
165
166	$("#bc-menu").on('click', '.menu-item-has-children a', function(event) {
167		event.stopPropagation();
168		$(this).parent().find( 'ul' ).slideToggle('slow');
169		if($(this).parent().hasClass('menu-item-has-children')) {
170			$(this).parent().toggleClass('clicked');
171			return false;
172		} 
173	});
174	$("#bc-menu").focusout(function(event) {
175		event.stopPropagation();
176		$(this).parent().find( 'ul' ).slideToggle('slow');
177		if($(this).parent().hasClass('menu-item-has-children')) {
178			$(this).parent().toggleClass('clicked');
179			return false;
180		} 
181	});
182	
183	
184	$(".accordions .item p.question").on( 'click', function() {
185		if ( $(this).hasClass('open')) {  
186			$(this).next("div").slideToggle('fast');
187			$(this).find('.fa-plus').slideToggle('fast');
188			$(this).find('.fa-minus').slideToggle('fast');
189		}
190		else {
191		$(".accordions .item > div:visible").slideToggle('fast');
192		$(".accordions .item p.question").removeClass('open');
193		
194		$(".accordions .item p.question").find('.fa-plus').show();
195		$(".accordions .item p.question").find('.fa-minus').hide();
196		
197		$(this).next("div").slideToggle('fast');
198		$(this).find('.fa-plus').slideToggle('fast');
199		$(this).find('.fa-minus').slideToggle('fast');
200		$(this).addClass('open');
201		}
202	});
203	$(".accordions .item p.question").keypress(function(event) {
204		$(this).click();
205	});
206	
207	$("#tabs a").click(function(){
208		// check to see if we have more than 1 set of tabs
209		var tabsCount = $("div[id*='tabs']").length;
210		if( 1 < tabsCount ){
211			// grab all children of this tab set and reset active class
212			$(this).parent().children('a').removeClass('active');
213			$(this).addClass('active');
214			// get all rel attributes and reset active class on tab content
215			$(this).parent().children().each(function () {
216				var rel = $(this).prop('rel');
217				$("#" + rel).removeClass('active');
218			});
219			// reasign active class to appropriate tab content
220			var target = $(this).attr('rel');
221			$("#" + target).addClass('active');
222		}
223		else {
224			$("#tabs a").removeClass('active');
225			$(this).addClass('active');
226			var target = $(this).attr('rel');
227			$("#tab-content div.content").removeClass('active');
228			$("#" + target).addClass('active');
229		}		
230		return false;
231	});
232
233	// Equalize the height of success stories boxes in the success stories tab after it is opened
234	$( '#tabs a.success-tab' ).click(function(){
235		equalheight( '.ss-person div' );
236	});
237	
238	/* Filter by Categories */
239	$("#trigger-cats-1").click(function() {
240
241		// clear all existing colors
242	 	$('#key li').css('background-color', 'transparent')
243	 				.css('color', '#000');
244
245		//remove the cats-row ul from active (erase from any existing)
246		$("#cats-row ul").removeClass('active');
247
248		//DEV ADDED THIS to clear the visible candidates when you go from one trigger to the next.
249		$(".course" ).removeClass('isVisible');
250
251		//add to class with course - ie all of them to be active
252		$(".course").addClass('active');
253		//get number of classes with .course. length?
254		var total = $(".course").length;
255		//go the matches span, and add the number to it.
256		$("#matches span").html(total);
257		//emove teh active from the cat-trigger, which is originally set to active. 
258		$(".cat-trigger").removeClass('active');
259		//to the current element? add class active.
260		$(this).addClass('active');
261		//show the matches count
262		$("#matches").show();
263		//key is that little bar with major/minor's id. show it
264		$("#key").show();
265		//the big pae goes to top of screen
266		var target = $("#filter-cats");
267		$('html,body').animate({
268				scrollTop: target.offset().top - 50
269		}, 1000);
270
271		$("#majorsFooterExplanation").show();
272
273	});
274	
275	$("#trigger-cats-2, #trigger-cats-3").click(function() {
276
277		// clear all existing colors
278	 	$('#key li').css('background-color', 'transparent')
279	 				.css('color', '#000');
280
281		//remove the classes that have this active-class tacked on to their name.
282		$(".course").removeClass (function (index, css) {
283				return (css.match (/(^|\s)active-\S+/g) || []).join(' ');
284		});
285		//DEV ADDED THIS to clear the visible candidates when you go from one trigger to the next.
286		$(".course" ).removeClass('isVisible');
287		//this targets the rel value of the current cat.
288		var target = $(this).attr('rel');
289		//inactivate the current list active
290		$("#cats-row ul").removeClass('active');
291		//this is an id of #cats-2 but the id is trigger-cats-2
292		$("#" + target).addClass('active');
293		//remove the active class from "cat-trigger" class
294		$(".cat-trigger").removeClass('active');
295		//add active to the current class set
296		$(this).addClass('active');
297		//remove teh active from the courses inside the row lists?
298		$("#cats-row li, .course").removeClass('active');
299		//length
300		var total = $(".course.active").length;
301		//just the html needs to have total in it
302		$("#matches span").html(total);
303		//show the content
304		$("#matches").show();
305		//show the little thing
306		$("#key").show();
307		//second target
308		var target2 = $("#filter-cats");
309		//scroll back to the top.
310		$('html,body').animate({
311				scrollTop: target2.offset().top - 50
312		}, 1000);
313
314		$("#majorsFooterExplanation").hide();
315	});
316	
317	//we have this as an example of toggling a class to make portions of the page with major info visible or not.
318	$('#cats-row li').click(function() {
319
320		// The current class becomes active or inactive
321		$(this).toggleClass('active');
322
323		$(".course").removeClass (function (index, css) {
324				return (css.match (/(^|\s)active-\S+/g) || []).join(' ');
325		});
326
327		var courses = ($(this).attr('rel')).split(" ");
328		var activecourses = [];
329		for ( var i = 0; i < courses.length; ++i ) {
330			if( typeof courses[i] == 'undefined' ) continue;
331			activecourses[i] = 'active-' + courses[i];
332		}
333
334		$('#cats-2, #cats-3').find('li').each(function(){
335			if($(this).hasClass('active')) {
336				var rels = ($(this).attr('rel')).split(" ");
337				for ( var i = 0; i < rels.length; ++i ) {
338					if( typeof rels[i] == 'undefined' ) continue;
339					$(".course." + rels[i]).addClass("active-" + rels[i]);
340				}
341			}
342		});
343
344		var total = $(".course:visible").length;
345		$("#matches span").html(total);
346
347		$("#majorsFooterExplanation").show();
348	});
349
350	/*
351	THIS function implements the Click Filter on the list items "All, Major, Minor, Concentration."
352	 */
353	 $('#key li').click(function() {
354
355	 	// clear all existing colors
356	 	$('#key li').css('background-color', 'transparent')
357	 				.css('color', '#000');
358
359		//Set the Major/Minor/Concentration/Reset to active or not, the mark the Classes that have that specific interest.  
360		$(this).toggleClass('active');
361
362		if($(this).attr('rel') != 'all-courses') {
363			// add the active background color to the element clicked
364	 		$(this).css('background-color', '#FEAD16')
365	 		   		.css('color', '#FFF');
366		}
367		
368		var interests = $(this).attr('rel');
369		var activeInterests = 'active-' + interests;
370		 
371		 //add a new tag that marks the "currently visible" as visible.
372		 $(".course:visible").addClass('isVisible');
373
374		 //remove all visible. Why? because you've taken over the visible Classes, and you don't want overlap. between what should be active and what was at the previous click
375		$(".course").removeClass (function (index, css) {
376				return (css.match (/(^|\s)active-\S+/g) || []).join(' ');
377		});
378
379		//if "course" has an active class, since we're taking control, we want to remove its ability to do so
380		$(".course").removeClass('active');
381
382		//if you have the Major/Minor/Concentration Active, then do the active-interests add on. 
383		//Don't mistake this for the above line - that looks as course having active
384		////while this line looks at major/minor/concentration being Active.
385		if ( $(this).hasClass('active') ) {
386			$(".isVisible.course." + interests).addClass(activeInterests);
387		}
388
389		// Equalize height of boxes upon changing selection
390		equalheight('.course:visible');
391		
392		//add the numbers.
393		var total = $(".course:visible").length;
394		$("#matches span").html(total);
395
396		//turns off the class after.
397		$(this).toggleClass('active');
398	});
399
400
401	$('.course-wrap').click(function() {
402		var url = $(this).attr('data-url');
403		// MAJORS WHEN CLICKED OPEN IN THE SAME TAB
404		window.open(url, "_self");
405	});
406
407	$('#key ul li').hover(
408		// on hover
409		function() {
410			// change hover background color on non-selected items ONLY
411			if( ( $(this).css( 'background-color' ) != 'rgb(254, 173, 22)' ) ) {
412				$(this).css( 'background-color', '#EBEBEB' );
413			}
414		},
415		// on hover out
416		function() {
417			if( ( $(this).css( 'background-color' ) != 'rgb(254, 173, 22)' ) ) {
418				$(this).css( 'background-color', 'transparent' );
419			}
420		}
421	);
422	
423	equalheight = function(container){
424
425		var currentTallest = 0,
426				 currentRowStart = 0,
427				 rowDivs = new Array(),
428				 $el,
429				 topPosition = 0;
430
431		$(container).each(function() {
432
433			$el = $(this);
434			$($el).height('auto');
435			topPostion = $el.position().top;
436
437			if (currentRowStart != topPostion) {
438				for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
439					rowDivs[currentDiv].height(currentTallest);
440				}
441				rowDivs.length = 0; // empty the array
442				currentRowStart = topPostion;
443				currentTallest = $el.height();
444				rowDivs.push($el);
445			} else {
446				rowDivs.push($el);
447				currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
448			}
449			for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
450				rowDivs[currentDiv].height(currentTallest);
451			}
452		});
453	}
454
455	// pass a URL paramater to expand all accords
456	var getUrlParameter = function getUrlParameter(sParam) {
457	var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i;
458
459	for (i = 0; i < sURLVariables.length; i++) {
460		sParameterName = sURLVariables[i].split('=');
461
462			if (sParameterName[0] === sParam) {
463				return sParameterName[1] === undefined ? true : sParameterName[1];
464			}
465		}
466	};
467	var expand = getUrlParameter('expandAll');
468	if( true === expand ) {
469		// open accordions
470		$( ".accordions .item p.question" ).each(function( i ) {
471			$(".accordions .item p.question").addClass('open');
472			$(".accordions .item p.question").find('.fa-plus').hide();
473			$(".accordions .item p.question").find('.fa-minus').show();
474			$(".accordions .item div").find('.fa-minus').show();
475			$(".accordions .item div").css("display", "block");
476		});
477	}
478
479	$(window).on('load resize', function(){
480		equalheight('.course');
481		equalheight('.equal-height');
482
483		// Equalize the height of success stories boxes.
484		equalheight('.ss-person div');
485
486		// Equalize faculty profiles
487		equalheight('.facProfile');
488	});
489
490
491	// Replace each horizontal rule added by using the WP editor with the styled one
492	$('hr').replaceWith('<div class="divider"><img src="/wp-content/themes/rcnjrd/images/icons/ramapo-arch-icom_rule.png" alt="Ramapo" /></div>');
493
494	// Add divider after header above calendar
495	$('h2.tribe-events-page-title').after('<div class="divider"><img src="/wp-content/themes/rcnjrd/images/icons/ramapo-arch-icom_rule.png" alt="Ramapo" /></div>');
496});
497
498// Initialize slider on load
499$( '#page-slideshow' ).on( 'cycle-initialized', function( event, opts ) {
500	if ($(window).width() >= 768){
501		 $("#page-slideshow").addClass('desktop');
502	} else {
503		$("#page-slideshow").removeClass('desktop');
504	}
505});
506
507// Repeat each menu item that has children in the mobile navigation on load & expand appropriate sections based on current page
508$(window).on( 'load', function() {
509
510	// target correct site navigation if the mobile view
511	if ($(window).width() <= 768){
512		$("#rcnj-screen-reader-shortcut-nav").attr("href", "#mobile-site-nav")
513	}
514
515	// Extract all items from the mobile dropdown menu that HAVE children
516	$all_parent_menus = $( '#bc-menu .menu-item-has-children' );
517
518	// Go through each & repeat the parent as a list item before all other list items in the list
519	$.each( $all_parent_menus, function( i, val ) {
520		var $parent_item = $( val ).find( 'a:first' );
521		var $the_submenu = $( val ).find( 'ul' );
522		//$( val ).removeClass( 'current-menu-item' );
523		$the_submenu.children( ':first' ).before( '<li id ="' + $( val ).attr( 'id' ) + '"><a href="' + $parent_item.attr( 'href' ) + '">' + $parent_item.text() + '</a></li>' );
524	});
525
526	var curr_page_url = window.location.href;
527	var $els = $( '#bc-menu a[href="' + curr_page_url + '"]' );
528
529	switch( $els.length ) {
530		case 1:
531			// 1st level in the nav (does not have any children & is not a child)
532			$els.parent().addClass( 'bc-current' );
533			var $closest_el_parent = $( $els[0] ).closest( 'li.menu-item-has-children' );
534			break;
535		case 2:
536			// 2nd level in the nav (has children) and is the first children (the repeated one)
537			$( $els[1] ).parent().addClass( 'bc-current' );
538			var $closest_el_parent = $( $els[1] ).closest( 'li.menu-item-has-children' );
539			break;
540		default:
541	}
542
543	if( $els.length != 0 ) {
544		$closest_el_parent.addClass( 'clicked' );
545		if( $closest_el_parent.closest( 'ul' ).hasClass( 'menu-depth-1' ) ) {
546			// 2 levels deep
547			$closest_el_parent.closest( 'ul' ).parent().addClass( 'clicked' );
548		}
549	}
550});
551
552// animating numbers on the home page
553// https://jsfiddle.net/anaganisk/cLpn5t08/1/
554var $findme = $('#home-page-panel-quick-facts');
555var exec = false;
556function Scrolled() {
557  $findme.each(function() {
558    var $section = $(this),
559      findmeOffset = $section.offset(),
560      findmeTop = findmeOffset.top,
561      findmeBottom = $section.height() + findmeTop,
562      scrollTop = $(document).scrollTop(),
563      visibleBottom = window.innerHeight,
564      prevVisible = $section.prop('_visible');
565
566    if ((findmeTop > scrollTop + visibleBottom) ||
567      findmeBottom < scrollTop) {
568      visible = false;
569    } else visible = true;
570
571    if (!prevVisible && visible) {
572    	if(!exec){
573              $('.animate-number').each(function() {
574          $(this).prop('Counter', 0).animate({
575            Counter: $(this).text()
576          }, {
577            duration: 3000,
578
579            step: function(now) {
580              $(this).text(Math.ceil(now));
581              exec = true;
582            }
583          });
584        });
585      }
586    }
587    $section.prop('_visible', visible);
588  });
589
590}
591
592function Setup() {
593  var $top = $('#top'),
594    $bottom = $('#bottom');
595
596  $top.height(500);
597  $bottom.height(500);
598
599  Scrolled();
600
601  $(window).scroll(function() {
602    Scrolled();
603  });
604}
605$(document).ready(function() {
606  Setup();
607});
608
609})(jQuery);

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.