PageSourceSearch

https://durhamcountylibrary.org/wp-content/mu-plugins/dcl-custom-functions.js?ver=1698954335

js durhamcountylibrary.org collected 2026-09-24 08:57:58 UTC 26,307 bytes, 717 lines download raw bytes

1// replace the no-js body class if javascript is enabled
2jQuery(document).ready( function($) {
3	$('html').removeClass("no-js").addClass("has-js");
4	$('.main-navigation button.menu-toggle').remove();
5});
6
7
8// for sitewide alerts, add in a dismiss link that removes the alert on click
9jQuery(document).ready( function($) {
10	var theLanguage = $('html').attr('lang');
11	var dismissText;
12	if (theLanguage == 'es-ES') {
13		dismissText = "Cerrar";
14	} else {
15		dismissText = "Dismiss";
16	}
17	$('<a/>', {
18		"class" : "dismiss-alert",
19		"href" : "#",
20		"title" : 'Dismiss alert',
21		// text : "Dismiss",
22		on: {
23			click: function(event) {
24				var alertId = $(this).parent().attr('id');
25				document.cookie = "dcol-" + alertId + "=hide; path=/";
26				$("#" + alertId).remove();
27			}
28		}
29    }).append("<span class='dismiss-text'>" + dismissText + "</span>").append("<span class='dismiss-toggle'>x</span>").appendTo('div.sitewide-alert');
30});
31
32
33    
34jQuery(document).ready(function($) {
35    /*
36     * jQuery simple and accessible hide-show system (collapsible regions), using ARIA
37     * @version v1.9.1   
38     * Website: https://a11y.nicolas-hoffmann.net/hide-show/
39     * License MIT: https://github.com/nico3333fr/jquery-accessible-hide-show-aria/blob/master/LICENSE
40     */
41    // loading expand paragraphs
42    // these are recommended settings by a11y experts. You may update to fulfill your needs, but be sure of what you’re doing.
43    var attr_control = 'data-controls',
44        attr_expanded = 'aria-expanded',
45        attr_labelledby = 'data-labelledby',
46        attr_hidden = 'data-hidden',
47        $expandmore = $('.js-expandmore'),
48        $body = $('body'),
49        delay = 1500,
50        hash = window.location.hash.replace("#", ""),
51        multiexpandable = true,
52        expand_all_text = 'Expand All',
53        collapse_all_text = 'Collapse All';
54
55
56    if ($expandmore.length) { // if there are at least one :)
57        $expandmore.each(function(index_to_expand) {
58            var $this = $(this),
59                index_lisible = index_to_expand + 1,
60                options = $this.data(),
61                $hideshow_prefix_classes = typeof options.hideshowPrefixClass !== 'undefined' ? options.hideshowPrefixClass + '-' : '',
62                not_all_expands = typeof options.notAllExpands !== 'undefined' ? true : false,
63                $to_expand = $this.next(".js-to_expand"),
64                $expandmore_text = $this.html();
65
66            $this.html('<button type="button" class="' + $hideshow_prefix_classes + 'expandmore__button js-expandmore-button"' + ( not_all_expands ? 'data-not-all-expands="true"' : '' ) + '><span class="' + $hideshow_prefix_classes + 'expandmore__symbol" aria-hidden="true"></span>' + '<span class="js-expandmore-text">' + $expandmore_text + '</span></button>');
67            var $button = $this.children('.js-expandmore-button');
68
69            $to_expand.addClass($hideshow_prefix_classes + 'expandmore__to_expand').stop().delay(delay).queue(function() {
70                var $this = $(this);
71                if ($this.hasClass('js-first_load')) {
72                    $this.removeClass('js-first_load');
73                }
74            });
75
76            $button.attr('id', 'label_expand_' + index_lisible);
77            $button.attr(attr_control, 'expand_' + index_lisible);
78            $button.attr(attr_expanded, 'false');
79
80            $to_expand.attr('id', 'expand_' + index_lisible);
81            $to_expand.attr(attr_hidden, 'true');
82            $to_expand.attr(attr_labelledby, 'label_expand_' + index_lisible);
83            
84            if (not_all_expands) {
85               $to_expand.attr('data-not-all-expands', 'true');
86            }
87
88            // quick tip to open (if it has class is-opened or if hash is in expand)
89            if ($to_expand.hasClass('is-opened') || (hash !== "" && $to_expand.find($("#" + hash)).length)) {
90                $button.addClass('is-opened').attr(attr_expanded, 'true');
91                $to_expand.removeClass('is-opened').removeAttr(attr_hidden);
92            }
93
94
95        });
96
97
98    }
99
100
101    $body.on('click', '.js-expandmore-button', function(event) {
102        var $this = $(this),
103            $destination = $('#' + $this.attr(attr_control));
104
105        if ($this.attr(attr_expanded) === 'false') {
106
107            if (multiexpandable === false) {
108                $('.js-expandmore-button').removeClass('is-opened').attr(attr_expanded, 'false');
109                $('.js-to_expand').attr(attr_hidden, 'true');
110            }
111
112            $this.addClass('is-opened').attr(attr_expanded, 'true');
113            $destination.removeAttr(attr_hidden);
114        } else {
115            $this.removeClass('is-opened').attr(attr_expanded, 'false');
116            $destination.attr(attr_hidden, 'true');
117        }
118
119        event.preventDefault();
120
121    });
122
123    $body.on('click keydown', '.js-expandmore', function(event) {
124        var $this = $(this),
125            $target = $(event.target),
126            $button_in = $this.find('.js-expandmore-button');
127
128        if (!$target.is($button_in) && !$target.closest($button_in).length) {
129
130            if (event.type === 'click') {
131                $button_in.trigger('click');
132                return false;
133            }
134            if (event.type === 'keydown' && (event.keyCode === 13 || event.keyCode === 32)) {
135                $button_in.trigger('click');
136                return false;
137            }
138
139        }
140
141
142    });
143
144    $body.on('click', '.js-expandmore-all', function(event) {
145        var $this = $(this),
146            options = $this.data(),
147            is_expanded = $this.attr('data-expand'),
148            txt_expand_all = typeof options.textExpandAll !== 'undefined' ? options.textExpandAll : expand_all_text,
149            txt_collapse_all = typeof options.textCloseAll !== 'undefined' ? options.textCloseAll : collapse_all_text,
150            $all_buttons = $('.js-expandmore-button:not([data-not-all-expands])'),
151            $all_destinations = $('.js-to_expand:not([data-not-all-expands])');
152
153        if (is_expanded === 'true') {
154            $all_buttons.addClass('is-opened').attr(attr_expanded, 'true');
155            $all_destinations.removeAttr(attr_hidden);
156            $this.attr('data-expand', 'false').html(txt_collapse_all);
157        } else {
158            $all_buttons.removeClass('is-opened').attr(attr_expanded, 'false');
159            $all_destinations.attr(attr_hidden, 'true');
160            $this.attr('data-expand', 'true').html(txt_expand_all);
161        }
162
163
164    });
165
166
167});
168
169
170jQuery(document).ready(function($) {
171	
172	var theLanguage = $('html').attr('lang');
173	if (theLanguage == 'es-ES') {
174		setupNavSpanish();
175	} else {
176		setupNav();
177	}
178	
179	
180	var lastitem='';
181	var megaNavPanels = $('#primary-menu > .menu-item-has-children > .sub-menu').hide();
182
183	var clickedAlready = false;
184	$('#primary-menu > .menu-item-has-children > a').on('touchstart click',(function(e) {
185		if (e.type == "touchstart") {
186			e.preventDefault();
187			clickedAlready = true;
188			megaNavPanels.not($(this).next()).hide();
189			megaNavPanels.not($(this).next()).prev().attr('aria-expanded', 'false');
190			$(this).attr('aria-expanded', function (i, attr) {
191				return attr == 'true' ? 'false' : 'true'
192			});
193			$(this).next().slideToggle();
194		} else if (e.type == "click" && !clickedAlready) {
195			e.preventDefault();
196			megaNavPanels.not($(this).next()).hide();
197			megaNavPanels.not($(this).next()).prev().attr('aria-expanded', 'false');
198			$(this).attr('aria-expanded', function (i, attr) {
199				return attr == 'true' ? 'false' : 'true'
200			});
201			$(this).next().slideToggle();
202		} else {
203			e.preventDefault();
204			clickedAlready = false;
205		}
206	})); 
207	
208	
209	// make sure submenu closes (only) when we move to the next item
210	$("#primary-menu > .menu-item-has-children").focusout(function(e) {
211		// if the target of the event isn't the container nor a descendant of the container
212		if (!$(this).is(e.target) && $(this).has(e.relatedTarget).length === 0) {
213			$(this).children(".sub-menu").hide();
214			if ($(this).children('.menu-link').attr('aria-expanded')) {
215				$(this).children('.menu-link').attr('aria-expanded', 'false');
216			}
217		}
218	}); 
219	
220	// also close when clicked outside
221	// ******* this isn't working - hides priority nav sub-menus when you click on them ******* now it may be fixed?
222	$(document).click(function(e) {
223		if ( (!$("#primary-menu > .menu-item-has-children").is(e.target) && $("#primary-menu > .menu-item-has-children").has(e.target).length === 0) && (!$(".priority-nav__dropdown > .menu-item-has-children").is(e.target) && $(".priority-nav__dropdown > .menu-item-has-children").has(e.target).length === 0 ) ) {
224			//console.log('outside click');
225			megaNavPanels.hide();
226			$('#primary-menu > .menu-item-has-children > a').attr('aria-expanded', 'false');
227	  } /*else {
228		  console.log('target click');
229	  } */
230	  /*if ($(".priority-nav__dropdown > .menu-item-has-children").is(e.target) || $(".priority-nav__dropdown > .menu-item-has-children").has(e.target).length != 0 ) {
231		  console.log('priority click');
232	  } */
233	}); 
234	
235	// also if the escape button is pressed
236	$(document).keyup(function(e) {
237	  if (e.keyCode === 27) {
238		  megaNavPanels.hide();
239		  $('#primary-menu > .menu-item-has-children > a').attr('aria-expanded', 'false');
240	  }
241	});
242	
243
244	/* set up priority nav */
245	function setupNav() {
246		var nav = priorityNav.init({
247			initClass: "js-priority-nav",
248			mainNavWrapper: ".menu-menu-1-container",
249			mainNav: "#primary-menu",
250			navDropdownLabel: "more",
251			breakPoint: 0,
252			throttleDelay: '50',
253			moved: function() {
254				
255				// Borrow focus class from navigation.js, add to all priority nav menu links
256	/* 			var links = $('.priority-nav__dropdown a');
257				links.off('focus').focus(function() {
258					$(this).toggleClass('focus');
259				});
260				links.off('blur').blur(function() {
261					$(this).toggleClass('focus');
262				}); */
263				
264				// remove focusout behavior so leaving one submenu doesn't also close the other
265				$('.priority-nav__dropdown > .menu-item-has-children').off('focusout');
266				
267				// add focusout handling to close priority nav dropdown
268				$(".priority-nav__dropdown").off('focusout').focusout(function(e) {
269					// if the target of the click isn't the dropdown or its descendant
270					if (!$(this).is(e.target) && $(this).has(e.relatedTarget).length === 0) {
271						$(this).hide();						
272						$('.priority-nav__dropdown > .menu-item-has-children > .menu-link').attr('aria-expanded', 'false');
273					}
274				}); 
275				
276				// use same slidetoggle effect on priority nav as on mega menus
277				$('.priority-nav__dropdown-toggle').off('click').on('click', function(){
278					$('.priority-nav__dropdown').slideToggle();
279				});
280							
281				// close the toggles if the 'more' menu is closed (otherwise they'll still be there when it's reopened)
282				var priorityNavPanels = $('.priority-nav__dropdown > .menu-item-has-children > .sub-menu').hide();	
283				$('.priority-nav__dropdown-toggle').click(function() {
284					priorityNavPanels.slideUp();
285					priorityNavPanels.attr('aria-expanded', 'false');
286					// also hide all the other dropdowns if the priority nav is active
287					$('#primary-menu > .menu-item-has-children > .sub-menu').hide();
288					$('#primary-menu > .menu-item-has-children > .menu-link').attr('aria-expanded', 'false');
289				});
290				
291				// and close the priority nav dropdown if another dropdown is opened
292				/*var clickedAlready = false;
293				$('#primary-menu > .menu-item-has-children > a').on('touchstart click',(function(e) {
294					if (e.type == "touchstart") {
295						clickedAlready = true;
296						$('.priority-nav__dropdown').hide();
297					} else if (e.type == "click" && !clickedAlready) {
298						$('.priority-nav__dropdown').hide();
299					} else {
300						clickedAlready = false;
301					}
302				})); */
303
304			},
305		});
306	}
307	
308		/* set up priority nav */
309	function setupNavSpanish() {
310		var nav = priorityNav.init({
311			initClass: "js-priority-nav",
312			mainNavWrapper: ".menu-menu-1-spanish-container",
313			mainNav: "#primary-menu",
314			navDropdownLabel: "más",
315			breakPoint: 0,
316			throttleDelay: 50,
317			offsetPixels: 2,
318			moved: function() {
319				
320				// Borrow focus class from navigation.js, add to all priority nav menu links
321	/* 			var links = $('.priority-nav__dropdown a');
322				links.off('focus').focus(function() {
323					$(this).toggleClass('focus');
324				});
325				links.off('blur').blur(function() {
326					$(this).toggleClass('focus');
327				}); */
328				
329				// remove focusout behavior so leaving one submenu doesn't also close the other
330				$('.priority-nav__dropdown > .menu-item-has-children').off('focusout');
331				
332				// add focusout handling to close priority nav dropdown
333				$(".priority-nav__dropdown").off('focusout').focusout(function(e) {
334					// if the target of the click isn't the dropdown or its descendant
335					if (!$(this).is(e.target) && $(this).has(e.relatedTarget).length === 0) {
336						$(this).hide();						
337						$('.priority-nav__dropdown > .menu-item-has-children > .menu-link').attr('aria-expanded', 'false');
338					}
339				}); 
340				
341				// use same slidetoggle effect on priority nav as on mega menus
342				$('.priority-nav__dropdown-toggle').off('click').on('click', function(){
343					$('.priority-nav__dropdown').slideToggle();
344				});
345							
346				// close the toggles if the 'more' menu is closed (otherwise they'll still be there when it's reopened)
347				var priorityNavPanels = $('.priority-nav__dropdown > .menu-item-has-children > .sub-menu').hide();	
348				$('.priority-nav__dropdown-toggle').click(function() {
349					priorityNavPanels.slideUp();
350					priorityNavPanels.attr('aria-expanded', 'false');
351					// also hide all the other dropdowns if the priority nav is active
352					$('#primary-menu > .menu-item-has-children > .sub-menu').hide();
353					$('#primary-menu > .menu-item-has-children > .menu-link').attr('aria-expanded', 'false');
354				});
355				
356				// and close the priority nav dropdown if another dropdown is opened
357				/*var clickedAlready = false;
358				$('#primary-menu > .menu-item-has-children > a').on('touchstart click',(function(e) {
359					if (e.type == "touchstart") {
360						clickedAlready = true;
361						$('.priority-nav__dropdown').hide();
362					} else if (e.type == "click" && !clickedAlready) {
363						$('.priority-nav__dropdown').hide();
364					} else {
365						clickedAlready = false;
366					}
367				})); */
368
369			},
370		});
371	}
372
373});
374
375
376/* hide search box, set up toggle button, set up catalog / site toggle */
377jQuery(document).ready(function($) {
378	var searchForm = $('#search-main > .search-wrapper').hide();
379	var theLanguage = $('html').attr('lang');
380	var catalogLabel, websiteLabel, searchingCatalog, searchingWebsite;
381	if (theLanguage == 'es-ES') {
382		catalogLabel = "Catálogo";
383		websiteLabel = 'Página web';
384		searchingCatalog = 'Actualmente está buscando en el catálogo';
385		searchingWebsite = 'Actualmente está buscando en la página web';
386	} else {
387		catalogLabel = "Catalog";
388		websiteLabel = 'Website';
389		searchingCatalog = 'Currently searching the catalog';
390		searchingWebsite = 'Currently searching the website';
391	}
392	searchForm.prepend('<select id="search-source" class="search-source" aria-label="Search source"><option value="catalog">' + catalogLabel + '</option><option value="website">' + websiteLabel + '</option></select>');
393	$('#search-main .search-wrapper').prepend('<p class="hide-search"><a class="toggle-search" href="#">x<span class="screen-reader-text">hide search</span></a></p>');
394	$('#catalog-search-form').prepend('<p class="search-status">' + searchingCatalog + '</p>');
395	$('#search-main .site-search-form').prepend('<p class="search-status">' + searchingWebsite + '</p>');
396	
397	$('.search-wrapper .site-search-form').hide();
398	$('#search-source').change(function() {
399		if(this.value == 'website') {
400			$('#catalog-search-form').hide();
401			$('#search-main .site-search-form').show();
402		} else if(this.value == 'catalog') {
403			$('#search-main .site-search-form').hide();
404			$('#catalog-search-form').show();
405		}
406	});
407	
408	
409	var clickedAlready = false;
410	$('.toggle-search').on('touchstart click',(function(e) {
411		if (e.type == "touchstart") {
412			e.preventDefault();
413			clickedAlready = true;
414			$(this).attr('aria-expanded', function (i, attr) {
415				return attr == 'true' ? 'false' : 'true'
416			});
417			// $(this).next().slideToggle();
418			$(searchForm).slideToggle();
419		} else if (e.type == "click" && !clickedAlready) {
420			e.preventDefault();
421			$(this).attr('aria-expanded', function (i, attr) {
422				return attr == 'true' ? 'false' : 'true'
423			});
424			// $(this).next().slideToggle();
425			$(searchForm).slideToggle();
426		} else {
427			e.preventDefault();
428			clickedAlready = false;
429		}
430	})); 
431	
432	// close when click outside
433	$(document).on('touchstart click',(function(e) {
434	  if (!$("#search-main").is(e.target) && $("#search-main").has(e.target).length === 0 ) {
435		 searchForm.hide();
436		 $('.toggle-search').attr('aria-expanded', 'false');
437	  }
438	}));
439	
440	
441	// set up a separate search box toggle for the homepage
442	var searchHome = $('#search-home > .search-wrapper');
443	searchHome.prepend('<select id="home-search-source" class="search-source" aria-label="Search source"><option value="catalog">' + catalogLabel + '</option><option value="website">' + websiteLabel + '</option></select>');
444	$('#home-catalog-search').prepend('<p class="search-status">' + searchingCatalog + '</p>');
445	$('#search-home .site-search-form').prepend('<p class="search-status">' + searchingWebsite + '</p>');
446	
447	 $('#home-search-source').change(function() {
448		 if(this.value == 'website') {
449			 $('#home-catalog-search').hide();
450			 $('#search-home .site-search-form').show();
451		 } else if(this.value == 'catalog') {
452			 $('#search-home .site-search-form').hide();
453			 $('#home-catalog-search').show();
454		 }
455	 });
456	
457});
458
459/* remove page sidebar if nothing is in it */
460jQuery(document).ready(function($) {
461	if( $('.entry-content div.page-sidebar div').length == 0 ) {
462        $('.entry-content div.page-sidebar').remove();
463    }
464	
465	if( $('#secondary-mobile .section-navigation').children().length == 0 ) {
466        $('#secondary-mobile .section-navigation').remove();
467		if ($('#secondary-mobile .section-navigation').children().length == 0) {
468			$('#secondary-mobile').remove();	
469		}
470    }
471	if( $('#secondary .section-navigation').children().length == 0 ) {
472        $('#secondary .section-navigation').remove();
473		if ($('#secondary .section-navigation').children().length == 0) {
474			$('#secondary').remove();	
475		}
476    }
477	
478});
479
480
481// plugin to change tag type, via https://stackoverflow.com/questions/8584098/how-to-change-an-element-type-using-jquery/8584217 - used in featherlight gallery plugin below
482(function($) {
483    $.fn.changeElementType = function(newType) {
484        var attrs = {};
485
486        $.each(this[0].attributes, function(idx, attr) {
487            attrs[attr.nodeName] = attr.nodeValue;
488        });
489		
490		var newElement = $("<" + newType + "/>", attrs);
491		
492		$.each($._data($(this).get(0), 'events'), function() {
493		  // iterate registered handler of original
494		  $.each(this, function() {
495			$(newElement).bind(this.type, this.handler);
496		  });
497		});
498		
499        // this.replaceWith(function() {
500            // return $("<" + newType + "/>", attrs).append($(this).contents());
501        // });
502		
503		this.replaceWith(newElement);
504		
505    }
506})(jQuery);
507
508
509/* featherlight improvements */
510jQuery(document).ready(function($) {
511	/* adding alt text and captions to the lightbox images */
512	$.featherlightGallery.prototype.afterContent = function() {
513	  var alt = this.$currentTarget.find('img').attr('alt');
514	  this.$instance.find('img').prop("alt", alt);
515	  
516	  var object  = this.$instance.find('.featherlight-content'),
517	   caption = this.$currentTarget.next('.wp-caption-text').text();
518	  object.find( '.caption' ).remove();
519	  if ( caption.length > 0 ) {
520		var $captionElm = $( '<div class="caption">' ).appendTo(object);
521		$captionElm.text(caption);
522	  }
523	  
524	};
525	
526	/* swapping out next / previous spans for buttons to make them keyboard accessible */	
527	$.featherlightGallery.prototype.afterOpen = function() {
528		var object  = this.$instance.find('.featherlight-content'),	
529		prevButton = object.find('span.featherlight-previous'),
530		nextButton = object.find('span.featherlight-next');
531		if (prevButton.length != 0) {
532			prevButton.changeElementType("button");
533		}
534		if (nextButton.length != 0) {
535			nextButton.changeElementType("button"); 
536		}
537			
538	}
539
540});
541
542
543
544
545/* jQuery(document).ready(function($) {
546	
547	if(navigator.geolocation) {
548		var getLocationLink = $('<p class="find-my-location"><a href="#">Find my current closest location</a></p>');
549		$('.location-list').before(getLocationLink);
550	
551		getLocationLink.on('click', (function(e) {
552			e.preventDefault();
553			//$(getLocationLink).hide();
554			//$('.location-list').before('<p class="location-permissions">We need permission to check your location. Look for a browser popup </p>');
555			navigator.geolocation.getCurrentPosition(geoSuccess, geoError);
556			
557			function geoError(err) {
558				if (err.code == 1) {
559					getLocationLink.after("<p>Uh oh, looks like we don't have permission to access your current location. If you still want to find the closest library, check your browser settings and try again.</p>");
560				} else if (err.code == 2 || err.code == 3) {
561					getLocationLink.after("<p>Sorry, we're having trouble calculating your current location. Please try again later.</p>");
562				}
563			}
564			
565			function geoSuccess(position) {
566				var currentLatitude = position.coords.latitude;
567				var currentLongitude = position.coords.longitude;
568				
569				var closest,
570					closestDistance,
571					nextClosest,
572					nextClosestDistance,
573					locationLatitude,
574					locationLongitude,
575					locationCoords,
576					distance;
577				$('.location-overview').each(function(i, location) {
578					locationLatitude = $(this).attr("data-latitude");
579					locationLongitude = $(this).attr("data-longitude");
580					locationCoords = {
581						latitude: locationLatitude,
582						longitude: locationLongitude
583					};
584					distance = computeDistance(position.coords,locationCoords);  // locationCoords should create a literal object from the latitude and longitude from each location
585					if(closest) {
586						if (distance < closestDistance) {
587							nextClosestDistance = closestDistance;
588							nextClosest = closest;
589							closestDistance = distance;
590							closest = $(this);
591						} else if (!nextClosest || distance < nextClosestDistance) {
592							nextClosestDistance = distance;
593							nextClosest = $(this);
594						}
595					} else {
596						closestDistance = distance;
597						closest = $(this);
598					}
599				});
600
601				
602				var closestLocation = $('<div class="closest-location" style="background-color:grey;"><h2>Your closest location is:</h2>' + closest.html() + '</div>');
603				if (nextClosestDistance - closestDistance < 2) {
604					var nextClosestLink = nextClosest.find('h2 > a').clone().get(0);
605					closestLocation.append('<p class="next-closest">Also close: </p>');
606					closestLocation.children('.next-closest').append(nextClosestLink);
607				}
608				closestLocation.append('<p class="dismiss-closest"><a href="#">Dismiss</a></p>');
609				$(getLocationLink).before(closestLocation);
610				$('.dismiss-closest > a').on('click', (function(e) {
611					$(closestLocation).remove();
612					$(getLocationLink).show();
613				}));
614			}
615			  
616		}));
617		
618		// --------------------- Ready Bake ------------------
619		//
620		// Uses the Spherical Law of Cosines to find the distance
621		// between two lat/long points
622		//
623		function computeDistance(startCoords, destCoords) {
624			var startLatRads = degreesToRadians(startCoords.latitude);
625			var startLongRads = degreesToRadians(startCoords.longitude);
626			var destLatRads = degreesToRadians(destCoords.latitude);
627			var destLongRads = degreesToRadians(destCoords.longitude);
628
629			var Radius = 6371; // radius of the Earth in km
630			var km = Math.acos(Math.sin(startLatRads) * Math.sin(destLatRads) + 
631							Math.cos(startLatRads) * Math.cos(destLatRads) *
632							Math.cos(startLongRads - destLongRads)) * Radius;
633							
634			var mileage = km * 0.621371;
635
636			return mileage;
637		}
638
639		function degreesToRadians(degrees) {
640			radians = (degrees * Math.PI)/180;
641			return radians;
642		}
643
644		// ------------------ End Ready Bake -----------------
645	}
646}); */
647
648
649/** 
650  * use ajax to load the feedback form
651  */
652jQuery(document).ready(function($) {
653	/* if Spanish version of the site, redirect the feedback link to the regular Ask Us link */
654	var theLanguage = $('html').attr('lang');
655	if (theLanguage == 'es-ES') {
656		var askUsUrl = WPURLS.siteurl + "/ask-us/?lang=es";
657		$('.feedback-button').attr("href", askUsUrl);
658	} else {
659		
660		$('.feedback-button').on('click', function(e) {
661			e.preventDefault();
662			var button = $(this);
663			$.ajax({
664				url: FeedbackForm.doShortCode,
665				type: 'POST',
666				data: {
667					action: 'load_feedback_form',
668				},
669				success: function(data) {
670	//                do something on success 
671					// hacky way to fix gravity forms ajax issue - may break going forward
672					data = data.replace('document.addEventListener( \'DOMContentLoaded\', function($){', 'jQuery(document).ready(function($){');
673					var $formDiv = $("<div>", {id: "feedback-form"}).html(data).append( '<a href="#" class="cancel-link">cancel</a>' );
674					$formDiv.appendTo( "#feedback-panel" );
675					$('.cancel-link').on('click', function(e) {
676						e.preventDefault();
677						$( "#feedback-form" ).hide();
678						button.show();
679						button.unbind();
680						button.on('click', function(e) {
681							e.preventDefault();
682							$( "#feedback-form" ).show();
683							button.hide();
684						})
685					})
686					$("#input_11_4").val(window.location.href);
687					$("#input_11_5").val(navigator.userAgent);
688					$("#input_11_6").val($(document).width());
689					button.hide();
690				},
691				error: function() {
692
693				}
694			})
695			// }
696			$([document.documentElement, document.body]).animate({
697				scrollTop: $("#feedback-panel").offset().top
698			}, 1000);
699		})
700		
701		// add a dismiss link on the confirmation message
702		$(document).on('gform_confirmation_loaded', function(event, formId){
703			if(formId == 11) {
704				var button = $('.feedback-button');
705				$('.cancel-link').remove();
706				$( "#feedback-form" ).append( '<a href="#" class="feedback-dismiss-link">dismiss</a>' );
707				$('.feedback-dismiss-link').on('click', function(e) {
708					e.preventDefault();
709					$( "#feedback-form" ).remove();
710				})
711			} else {
712				// run code specific to form ID 2
713			}
714		});
715		
716	}
717});

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.