PageSourceSearch

https://www.cahcf.org/wp-content/themes/master-ill-sienna-2021/js/common.js

js cahcf.org collected 2026-09-28 11:46:46 UTC 6,760 bytes, 239 lines download raw bytes

1// FONT SIZER
2	function illDoTextSize( size_index ) {
3		var bclass = '';
4		switch(size_index) {
5			case 0:
6				bclass = '';
7				break;
8			case 1:
9				bclass = 'big';
10				break;
11			case 2:
12				bclass = 'bigger';
13				break;
14			case 3:
15				bclass = 'biggest';
16				break;
17		}
18		jQuery('body').removeClass('big').removeClass('bigger').removeClass('biggest');
19		jQuery('body').addClass(bclass);
20	}
21	function illIncrementTextSize() {
22		var current_size = illReadCookie('text_size');
23		if( current_size != null ) {
24			current_size++;
25		} else {
26			current_size = 0;
27		}
28		if( current_size > 3 ) {
29			current_size = 0;
30		}
31
32		illDoTextSize(current_size);
33		illCreateCookie('text_size', current_size, 30);
34	}
35
36// HIGH CONTRAST 
37	function illDoHighContrast( high_contrast_status ) {
38		var body_elem = document.getElementsByTagName("body")[0];
39		if( high_contrast_status == 1 ) {
40			body_elem.className += " high_contrast";
41		} else {
42			body_elem.className = body_elem.className.replace(' high_contrast', '')
43		}
44	}
45	function toggleHighContrast() {
46		var high_contrast_status = illReadCookie("high_contrast");
47		if( high_contrast_status == null || high_contrast_status == 0 ) {
48			high_contrast_status = 1;
49		} else {
50			high_contrast_status = 0;
51		}
52		illDoHighContrast(high_contrast_status);
53		illCreateCookie("high_contrast", high_contrast_status, 30);
54	}
55
56// COOKIES - CONTRAST AND FONT CHOICE
57	function illCreateCookie( name, value, days ) {
58		if(days) {
59			var date = new Date();
60			date.setTime(date.getTime()+(days*24*60*60*1000));
61			var expires = "; expires="+date.toGMTString();
62		} else {
63			var expires = "";
64		}
65		document.cookie = name+"="+value+expires+"; path=/";
66	}
67	function illReadCookie( name ) {
68		var nameEQ = name + "=";
69		var ca = document.cookie.split(';');
70		for( var i=0; i < ca.length; i++ ) {
71			var c = ca[i];
72			while (c.charAt(0)==' ') c = c.substring(1,c.length);
73			if( c.indexOf(nameEQ) == 0 ) return c.substring(nameEQ.length,c.length);
74		}
75		return null;
76	}
77
78// 2018
79jQuery(document).ready(function($) {
80	// assign the dashicons to the appropriate menu items
81		$('.menu li').each(function(){
82			var atext = $(this).find('a').text();
83			var aclass = '';
84			switch(atext) {
85				case 'Twitter':
86					//aclass = 'dashicons dashicons-twitter';
87					aclass = 'fab fa-twitter';
88					break;
89				case 'Email':
90					//aclass = 'dashicons dashicons-email-alt';
91					aclass ='far fa-envelope';
92					break;
93				case 'Google Plus':
94					//aclass = 'dashicons dashicons-googleplus';
95					aclass = 'fab .fa-google-plus';
96					break;
97				case 'Facebook':
98					//aclass = 'dashicons dashicons-facebook-alt';
99					aclass = 'fab fa-facebook-f';
100					break;
101				case 'LinkedIn':
102					aclass = 'fab fa-linkedin';
103					break;
104				case 'Pinterest':
105					aclass = 'fab fa-pinterest-p';
106					break;
107				case 'YouTube':
108					aclass = 'fab fa-youtube';
109					break;
110				case 'Instagram':
111					aclass = 'fab fa-instagram';
112					break;
113			}
114			if(aclass != '') {
115				$(this).find('a').text('');
116				$(this).find('a').html('<span class="'+ aclass +'" role="presentation"></span><span style="font-size:0;">'+atext+'</span>');
117				//$(this).find('span').addClass(aclass);
118			}
119			if(atext == 'Search') {
120				$(this).find('a').text('');
121				$(this).find('a').parent().html(
122					'<form id="search" action="/" method="get" role="search">' + 
123						'<fieldset>' +
124							'<label for="s">Search</label>' +
125							'<input id="s" type="text" name="s" placeholder="search site" value="" />' +
126							'<input type="submit" class="" value="" />' +
127						'</fieldset>' +
128					'</form><!--/search-->'
129				);
130			}
131		});
132
133	// font size changer
134		illDoTextSize(parseInt(illReadCookie("text_size")));
135		$('.textsize').click(function() {
136			illIncrementTextSize();
137		});
138
139	// high contrast
140		illDoHighContrast(illReadCookie("high_contrast"));
141		$('.highcontrast').click(function() {
142			toggleHighContrast();
143		});
144	
145	// search prevent empty submit
146		$("form.search").on("submit", function(e) {
147			if( jQuery(this).find("input[type=text]").val() == "" ) {
148				e.preventDefault();
149				return false;
150			}
151			$(this).find("input[type=text]").focus();
152		});
153		$("form.search").hover(function(){
154   			$("form.search").addClass("show");
155		}, function(){
156			setTimeout(function() {
157				$("form.search").removeClass("show");
158			}, 8000);
159		});
160
161	// dropdown nav keyboard navigation helper
162		var nav_element_id = "nav_contain";
163		var nav_ul_id = "menu-primary"; // first <ul> of the nav
164		var kid_class = "sub-menu";
165		$("." + kid_class + " a").on("focus", function() {
166			jQuery(this).closest("." + kid_class).closest("li").addClass("active");
167		});
168		$("." + kid_class + " a").on("blur", function() {
169			jQuery(this).closest("." + kid_class).closest("li").removeClass("active");
170		});
171
172	// share button
173		$('#share div').click(function() {
174			$(this).parent().toggleClass('active');
175		});
176
177	// remove icon on document image links
178		$('a:has(img)').addClass('no_icon');
179
180	// collapse-o-matic titles are annoying
181		$(".collapseomatic").hover(function(){
182			// Get the current title
183			var title = $(this).attr("title");
184			// Store it in a temporary attribute
185			$(this).attr("tmp_title", title);
186			// Set the title to nothing so we don't see the tooltips
187			$(this).attr("title","");
188		});
189  		$(".collapseomatic").click(function(){// Fired when we leave the element
190        	// Retrieve the title from the temporary attribute
191        	var title = $(this).attr("tmp_title");
192        	// Return the title to what it was
193        	$(this).attr("title", title);
194    	});
195
196  	// sticky header
197		var winWidth = window.outerWidth ? window.outerWidth : document.body.clientWidth;
198		if(winWidth >= 901) {
199			$(window).on("scroll",function(){
200			    if($(window).scrollTop()>0){
201			        $('header').addClass("stick");
202			    } else{
203			        $('header').removeClass("stick");
204			    }		    
205			});
206		}
207		//header_sizing();
208
209	// responsive menu
210		$('#navbtn').click(function() {
211			$(this).toggleClass('open');
212			$('header').toggleClass('open');
213		});
214
215	// move the utility nav to the bottom of the main menu on mobile (900px)
216		if(winWidth <= 900) {
217			// get the top right info
218			var top_right = $('header .top .right').html();
219			// remove it from the header
220			$('header .top .right').html('');
221			// put it in the main nav area
222			$('nav.primary_nav .menu-primary-menu-container').prepend(top_right);
223		}
224
225});
226
227// redo the header height on resize
228	jQuery(document).resize(function() {
229		header_sizing();
230	});
231
232// header sizing adjustments
233	function header_sizing() {
234		// move the hero down to accomodate
235		var header_height = jQuery('header').outerHeight();
236		jQuery('.hero-wrap, .content-wrap, .ill_directory, .ill_assoc_directory').css({
237			'padding-top' : header_height + 'px'
238		});
239	}

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.