PageSourceSearch

https://www.ausableriver.org/sites/all/themes/asra/js/custom/custom.js

js ausableriver.org collected 2026-10-02 17:15:49 UTC 5,249 bytes, 155 lines download raw bytes

1/**
2 * @file
3 * A JavaScript file for the theme.
4 *
5 * In order for this JavaScript to be loaded on pages, see the instructions in
6 * the README.txt next to this file.
7 */
8
9// JavaScript should be made compatible with libraries other than jQuery by
10// wrapping it with an "anonymous closure". See:
11// - https://drupal.org/node/1446420
12// - http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth
13(function ($, Drupal, window, document, undefined) {
14
15
16// To understand behaviors, see https://drupal.org/node/756722#behaviors
17Drupal.behaviors.my_custom_behavior = {
18  attach: function(context, settings) {
19
20    // Place your code here.
21
22  }
23};
24
25
26})(jQuery, Drupal, this, this.document);
27
28
29// Additional Toggle for Secondary Menu
30jQuery('.mobileBtnWrapper a.mainMenuToggle').toggle(function() { 
31  jQuery("body.not-front nav#secondaryMenu").slideDown(200, 'easeInSine');
32},
33 function() { 
34   jQuery("body.not-front nav#secondaryMenu").slideUp(200, 'easeOutSine');
35});
36
37
38// General Onready
39jQuery(document).ready(function() {
40  // Open the current active path in the sidebar.
41	jQuery('#sidebarMenu .active-trail').siblings('span').click()
42	
43  //valid email check (footer)
44  jQuery('#mailchimp-signup-subscribe-block-footer-signup-form').submit(function(e){
45	  var emailRegex = new RegExp("^[A-Za-z0-9_-]+[A-Za-z0-9_\.\-]*[A-Za-z0-9_-]+@[A-Za-z0-9_-]+[A-Za-z0-9\.-]*\\.[a-zA-Z]{2,4}$","i");
46	  if(!emailRegex.test(jQuery('#edit-mergevars-email').val())){
47		e.preventDefault();
48		alert('Please enter a valid email.');
49	  }
50  });
51  
52  //valid email check (newsletter page)
53  jQuery('#mailchimp-signup-subscribe-block-mail-chimp-voices-form').submit(function(e){
54	  var emailRegex =  new RegExp("^[A-Za-z0-9_-]+[A-Za-z0-9_\.\-]*[A-Za-z0-9_-]+@[A-Za-z0-9_-]+[A-Za-z0-9\.-]*\\.[a-zA-Z]{2,4}$","i");
55	  if(!emailRegex.test(jQuery('#edit-mergevars-email').val())){
56		e.preventDefault();
57		alert('Please enter a valid email.');
58	  }
59  });
60  
61  //length check for search (popup)
62  jQuery('#search-block-form--2').submit(function(e){
63	if(jQuery('#edit-search-block-form--4').val().length < 3){
64		e.preventDefault();
65		alert('Please enter a search of 3 characters or more.');
66	}
67  });
68  
69  //length check for search (page)
70  jQuery('#search-form').submit(function(e){
71	if(jQuery('#edit-keys').val().length < 3){
72		e.preventDefault();
73		alert('Please enter a search of 3 characters or more.');
74	}
75  });
76  
77  // SVG Fallbacks
78  if (!Modernizr.svg) {
79	jQuery(".homepage-logo img").attr("src", "/sites/all/themes/asra/i/logos/ausable-logo.svg");   
80	jQuery(".header-logo img").attr("src", "/sites/all/themes/asra/i/logos/ausable-logo.svg");  
81	jQuery(".footer-nysdos-logo img").attr("src", "/sites/all/themes/asra/i/logos/footer-nysdos-logo.png");
82	jQuery(".adw-accreditation-logo img").attr("src", "/sites/all/themes/asra/i/logos/adworkshop-logo-white.png");
83  }	
84  
85  // Custom Class Assignments
86
87});
88
89
90// Search Toggle
91jQuery('nav#secondaryMenu ul li.search a').click(function() {
92  jQuery(".search-form-dim-window").fadeIn('slow');
93  jQuery("body").addClass("noscroll");
94  jQuery("#edit-search-block-form--4").focus();
95  if(jQuery('#edit-submit--4').val() !=""){
96	jQuery('#edit-submit--4').val("")
97  }
98});
99jQuery('.search-form-dim-window-close-button a').click(function() {
100  jQuery(".search-form-dim-window").fadeOut('fast');
101  jQuery("body").removeClass("noscroll");
102});
103
104
105// Map Legend Toggle
106jQuery('a.map-legend-toggle').click(function() {
107  jQuery('.map-legend').toggleClass('active');
108  jQuery('.map-legend-inner').slideToggle( 400, function() {
109	// Animation complete.  
110  });	
111});	
112
113
114// Subpage Sidebar Move
115jQuery(window).bind('resize', function(){
116  	
117  if(jQuery(this).width() > 960) {
118	jQuery(".subpage-content-sidebar").insertBefore(".subpage-content-main");
119	jQuery(".subpage-featured-map-toggles-column").insertAfter(".subpage-featured-map-column");
120	jQuery(".subpage-map-container.featured, .subpage-map-container.featured .global-width").css("height", jQuery(window).height() - jQuery("header.site-header").outerHeight());
121  } 
122  else {
123    jQuery(".subpage-content-sidebar").insertAfter(".subpage-content-main");
124	jQuery(".subpage-featured-map-toggles-column").insertAfter(".subpage-map-container");
125	jQuery(".subpage-map-container.featured, .subpage-map-container.featured .global-width").css("height", "");
126  }
127  
128}).resize();
129
130
131// Clean function to remove unwatned nodes from inside a DOM node (Support for inline-block grid layout)
132var utils = {};
133utils.clean = function(node) {
134  var child, i, len = node.childNodes.length;
135  if (len === 0) { return; }
136  // iterate backwards, as we are removing unwanted nodes
137  for (i = len; i > 0; i -= 1) {
138		child = node.childNodes[i - 1];
139		// comment node? or empty text node
140		if (child.nodeType === 8 || (child.nodeType === 3 && !/\S/.test(child.nodeValue) )) {
141			node.removeChild(child);
142		}
143		else {
144			if (child.nodeType === 1) {
145				utils.clean(child);
146			}
147		}
148  }
149};
150// Add .inline-block-grid-parent class where needed
151jQuery(".generic-promos-container, form.search-form .form-wrapper").addClass("inline-block-grid-parent");
152// Run divs with class .inline-block-grid-parent through clean function
153jQuery(".inline-block-grid-parent").each( function(){ 
154  utils.clean(this);
155})

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.