PageSourceSearch

https://alzfdn.org/wp-content/plugins/afadir/public/js/afadir-public.js?ver=1.0.0

js alzfdn.org collected 2026-09-24 09:11:12 UTC 15,446 bytes, 490 lines download raw bytes

1(function( $ ) {
2	'use strict';
3
4	/**
5	 *
6	 */
7
8	 $(function() {
9	 	 
10    $("#new_screening_form").validate({
11        groups: {
12            name: "afadir_field_ongoingscreenings_enable afadir_field_singleday_enable"
13        },
14        rules: {
15            'afadir_field_ongoingscreenings_enable': {
16                require_from_group: [1, ".singleday_ongoingscreenings"]
17            },
18            'afadir_field_singleday_enable': {
19                require_from_group: [1, ".singleday_ongoingscreenings"]
20            }, 
21            afadir_field_singleday_date: {
22            	required: {
23	    	        depends: function(element) {
24				          return $("#afadir_field_singleday_enable").is(":checked");
25				        }
26            	}
27			      },
28			      afadir_field_singleday_time: {
29            	required: {
30	    	        depends: function(element) {
31				          return $("#afadir_field_singleday_enable").is(":checked");
32				        }
33            	}
34			      },			      
35			      afadir_field_singleday_time_end: {
36            	required: {
37	    	        depends: function(element) {
38				          return $("#afadir_field_singleday_enable").is(":checked");
39				        }
40            	}
41			      },
42            afadir_field_ongoingscreenings_date: {
43            	required: {
44	    	        depends: function(element) {
45				          return $("#afadir_field_ongoingscreenings_enable").is(":checked");
46				        }
47            	}
48			      },
49			      afadir_field_ongoingscreenings_time: {
50            	required: {
51	    	        depends: function(element) {
52				          return $("#afadir_field_ongoingscreenings_date").val() == "daily";
53				        }
54            	}
55			      },			      
56			      'afadir_field_ongoingscreenings_weekly_day[]': {
57            	required: {
58	    	        depends: function(element) {
59				          return $("#afadir_field_ongoingscreenings_date").val() == "weekly";
60				        }
61            	}
62			      },
63			      'afadir_field_ongoingscreenings_weekly_time_start[]': {
64            	required: {
65	    	        depends: function(element) {
66				          return $("#afadir_field_ongoingscreenings_date").val() == "weekly";
67				        }
68            	}
69			      },
70
71			      'afadir_field_ongoingscreenings_monthly_month[]': {
72            	required: {
73	    	        depends: function(element) {
74				          return $("#afadir_field_ongoingscreenings_date").val() == "monthly";
75				        }
76            	}
77			      },
78			      'afadir_field_ongoingscreenings_monthly_day[]': {
79            	required: {
80	    	        depends: function(element) {
81				          return $("#afadir_field_ongoingscreenings_date").val() == "monthly";
82				        }
83            	}
84			      },
85			      'afadir_field_ongoingscreenings_monthly_time_start[]': {
86            	required: {
87	    	        depends: function(element) {
88				          return $("#afadir_field_ongoingscreenings_date").val() == "monthly";
89				        }
90            	}
91			      },			       			     			       
92        },
93		    messages: {
94		        afadir_field_ongoingscreenings_enable: "Please select either Single Day Event or Ongoing Screenings or both"
95		    },
96		    submitHandler: function(form) {
97		    	$('.afadir_field_ongoingscreenings_child:hidden').each(function(){
98						$('.afadir_field_ongoingscreenings_child:hidden, .afadir_field_ongoingscreenings_child:hidden :input').prop("disabled",true);
99					});
100		    	form.submit();
101		  	}
102    });
103
104
105		// $('#new_screening_form').submit(function(e) {
106		// 	e.preventDefault();
107		// 		$('.afadir_field_ongoingscreenings_child:hidden').each(function(){
108		// 			$('.afadir_field_ongoingscreenings_child:hidden, .afadir_field_ongoingscreenings_child:hidden :input').prop("disabled",true);
109		// 		});
110		//     return true; // return false to cancel form action
111		// });
112
113
114
115		if ( $('#afadir_field_singleday_enable').is(':not(:checked)') ) {
116	    $('#afadir_field_singleday_enable ').removeAttr('checked');
117	    $('.afadir_field_singleday_child').hide();
118		}
119
120		if ( $('#afadir_field_ongoingscreenings_enable ').is(':not(:checked)') ) {
121	    $('#afadir_field_ongoingscreenings_enable ').removeAttr('checked');
122	    $('.afadir_field_ongoingscreenings_child').hide();
123		}
124
125
126		$('#afadir_field_ongoingscreenings_enable').on('change', function() {
127			if( $(this).is(':not(:checked)') ){
128				$('.afadir_field_ongoingscreenings_child').hide();
129			}
130		});
131
132
133		$('#afadir_field_singleday_enable').click(function(){
134			$('body').find('[name="afadir_field_singleday_date"]').toggle();
135			$('body').find('[name="afadir_field_singleday_time"]').toggle();
136			$('body').find('[name="afadir_field_singleday_time_end"]').toggle();
137			$('body').find('#afadir_field_singleday_appointment').toggle();
138		});	
139
140		$('#afadir_field_ongoingscreenings_enable').click(function(){
141			$('body').find('[name="afadir_field_ongoingscreenings_date"]').toggle();
142			// $('body').find('[name="afadir_field_ongoingscreenings_time"]').toggle();
143			// $('body').find('[name="afadir_field_ongoingscreenings_time_end"]').toggle();
144			$('body').find('#afadir_field_ongoingscreenings_appointment').toggle();
145		});
146
147
148		if ( $('.afadir_field_venuetype').val() != 'other' ) {
149			$('.afadir_field_venuetype_other').hide();
150		}
151		$('.afadir_field_venuetype').on('change', function() {
152			if ( $('.afadir_field_venuetype').val() == 'other' ) {
153				$('.afadir_field_venuetype_other').show();
154			}else{
155				$('.afadir_field_venuetype_other').hide();
156			}
157		})
158
159
160		if ( $('#afadir_field_quantitymaterials').val() != 'other' ) {
161			$('#afadir_field_quantitymaterials_other').hide();
162		}
163		$('#afadir_field_quantitymaterials').on('change', function() {
164			if ( $('#afadir_field_quantitymaterials').val() == 'other' ) {
165				$('#afadir_field_quantitymaterials_other').show();
166			}else{
167				$('#afadir_field_quantitymaterials_other').hide();
168			}
169		});
170
171		if ( $('#afadir_field_ongoingscreenings_date').val() == '' ) {
172			$('.afadir_field_ongoingscreenings_weekly, .afadir_field_ongoingscreenings_monthly, .afadir_field_ongoingscreenings_daily').hide();
173		}	
174		if ( $('#afadir_field_ongoingscreenings_date').val() == 'daily' ){
175			$('.afadir_field_ongoingscreenings_daily').show();
176			$('.afadir_field_ongoingscreenings_weekly').hide();
177			$('.afadir_field_ongoingscreenings_monthly').hide();
178		}			
179		if ( $('#afadir_field_ongoingscreenings_date').val() == 'weekly' ){
180			$('.afadir_field_ongoingscreenings_weekly').show();
181			$('.afadir_field_ongoingscreenings_daily').hide();
182			$('.afadir_field_ongoingscreenings_monthly').hide();
183		}		
184		if ( $('#afadir_field_ongoingscreenings_date').val() == 'monthly' ){
185			$('.afadir_field_ongoingscreenings_monthly').show();
186			$('.afadir_field_ongoingscreenings_daily').hide();
187			$('.afadir_field_ongoingscreenings_weekly').hide();
188		}
189
190		$('#afadir_field_ongoingscreenings_date').on('change', function() {
191			if ( $(this).val() == 'daily' ) {
192				$('.afadir_field_ongoingscreenings_daily').show();
193				$('.afadir_field_ongoingscreenings_monthly').hide();
194				$('.afadir_field_ongoingscreenings_weekly').hide();
195			}			
196			else if ( $(this).val() == 'weekly' ) {
197				$('.afadir_field_ongoingscreenings_daily').hide();
198				$('.afadir_field_ongoingscreenings_weekly').show();
199				$('.afadir_field_ongoingscreenings_monthly').hide();
200			}
201			else if ( $(this).val() == 'monthly' ){
202				$('.afadir_field_ongoingscreenings_daily').hide();
203				$('.afadir_field_ongoingscreenings_monthly').show();
204				$('.afadir_field_ongoingscreenings_weekly').hide();
205			}
206			else{
207				$('.afadir_field_ongoingscreenings_weekly, .afadir_field_ongoingscreenings_monthly, .afadir_field_ongoingscreenings_daily').hide();
208			}
209		});
210
211		if ( $( ".afadir_datepicker" ).length ) {
212			$('.afadir_datepicker').datepicker();
213		}
214
215
216
217
218		/*
219		 *	Member Search Filter
220		 *	URL related functions
221		 */	
222		$('#member-filter #afadir_search_services').on('change', function() {
223		 	var service = this.value;
224		 	service = isSanitized(service);
225
226			var u = new Url;
227			delete u.query.region;
228			u.query.service=service; // adds or replaces the param
229			window.location.href = u;
230		})
231
232		$('#member-filter #afadir_search_types').on('change', function() {
233		 	var type = this.value;
234		 	type = isSanitized(type);
235
236			var u = new Url;
237			delete u.query.region;
238			u.query.type=type; // adds or replaces the param
239			window.location.href = u;
240		})
241
242		$('#member-filter #afadir_search_state').on('change', function() {
243		 	var state = this.value;
244		 	state = isSanitized(state);
245
246			var u = new Url;
247			u.query.state=state; // adds or replaces the param
248			window.location.href = u;
249		})
250
251		$('#member-filter #afadir_search_zip').keypress(function (e) {
252		 var key = e.which;
253		 if(key == 13) { // the enter key code
254
255			 	var zip = this.value;
256			 	zip = isSanitized(zip);
257				
258				var u = new Url;
259				delete u.query.region;
260				u.query.zip=zip; // adds or replaces the param
261				window.location.href = u;
262				
263				return false;		   
264			}
265		});
266
267
268		$("#member-filter .afadir_search_languages").on('click', function() {
269			console.log("testing");
270	    if(this.checked) {
271			 	var language = this.value;
272			 	console.log(language);
273			 	// language = isSanitized(language);
274
275				var u = new Url('https://alzfdn.org/find-a-member/find-an-afa-member-organization/');
276				if (language == 'english') {
277					u.query.language=language; // adds or replaces the param
278				}
279				if (language == 'spanish') {
280					u.query.language=language; // adds or replaces the param
281				}
282				window.location.href = u;
283	    }
284	    else{
285			 	var language = this.value;
286				var u = new Url;
287
288				if (language == 'english') {
289	  			delete u.query.language;
290				}
291				if (language == 'spanish') {
292	  			delete u.query.language;
293				}
294				window.location.href = u;
295	    }
296		});		
297
298
299
300		/*
301		 *	Screening Site Search Filter
302		 *	URL related functions
303		 */	
304		$('#screening-filter #afadir_search_zip').keypress(function (e) {
305		 var key = e.which;
306		 if(key == 13) { // the enter key code
307
308			 	var zip = this.value;
309			 	zip = isSanitized(zip);
310				
311				var u = new Url('https://alzfdn.org/memory-screening/find-a-site/');
312				u.query.zip = zip; // adds or replaces the param
313				r.query.radius=radius; // adds or replaces the param
314				window.location.href = u;
315				window.location.href = r;
316
317				var radius = this.value;
318			 	radius = isSanitized(radius);
319
320				return false;		    
321			}
322		});
323
324		$('#screening-filter #afadir_search_wp').keypress(function (e) {
325		 var key = e.which;
326		 if(key == 13) { // the enter key code
327
328			 	var zip = this.value;
329			 	zip = isSanitized(zip);
330				
331				var u = new Url('https://alzfdn.org/memory-screening/find-a-site/');
332				u.query.zip = zip; // adds or replaces the param
333				r.query.radius=radius; // adds or replaces the param
334				window.location.href = u;
335				window.location.href = r;
336
337				var radius = this.value;
338			 	radius = isSanitized(radius);
339
340				return false;		    
341			}
342		});
343
344		$('#screening-filter #afadir_search_state').on('change', function() {
345		 	var state = this.value;
346		 	state = isSanitized(state);
347
348			var u = new Url('https://alzfdn.org/memory-screening/find-a-site/');
349			u.query.state=state; // adds or replaces the param
350			window.location.href = u;
351		})
352
353
354		$('#screening-filter #afadir_search_radius').on('change', function() {
355		 	var radius = this.value;
356		 	radius = isSanitized(radius);
357
358			var u = new Url('https://alzfdn.org/memory-screening/find-a-site/');
359			u.query.radius=radius; // adds or replaces the param
360			window.location.href = u;
361		})
362
363		$("#screening-filter .afadir_search_languages").on('change', function() {
364	    if(this.checked) {
365			 	var language = this.value;
366			 	console.log(language);
367			 	// language = isSanitized(language);
368
369				var u = new Url('https://alzfdn.org/memory-screening/find-a-site/');
370				if (language == 'english') {
371					u.query.language=language; // adds or replaces the param
372				}
373				if (language == 'spanish') {
374					u.query.language=language; // adds or replaces the param
375				}
376				window.location.href = u;
377	    }
378	    else{
379			 	var language = this.value;
380				var u = new Url;
381
382				if (language == 'english') {
383	  			delete u.query.language;
384				}
385				if (language == 'spanish') {
386	  			delete u.query.language;
387				}
388				window.location.href = u;
389	    }
390		});
391
392
393		$('#screening-filter #afadir_search_country').on('change', function() {
394		 	var country = this.value;
395		 	country = isSanitized(country);
396
397			var u = new Url('https://alzfdn.org/memory-screening/find-a-site/');
398			u.query.country=country; // adds or replaces the param
399			window.location.href = u;
400		})
401
402
403
404
405		var more = $(".pushtoprev");
406		more.appendTo(more.prev());
407
408		$("#pmpro_level-3").closest('.entry-content').find('h2').text("Memory Screening Acount Registration");
409
410
411		// $(".pmpro-checkout .entry-content #pmpro_pricing_fields p").each(function() {
412		//     var text = $(this).text();
413		//     text = text.replace("You have selected the Screening Site Account membership level", "You have selected to become a Memory Screening Site.");
414		//     $(this).text(text);
415		// });	
416
417		$('.pmpro-checkout .entry-content #pmpro_pricing_fields p:contains("You have selected the Screening Site Account membership level.")').text('You have selected to become a Memory Screening Site.');
418
419
420    function makeRepeater(sectionsSelector, addClass, removeClass, AYSMsg){  
421      $(  
422       sectionsSelector + " " + addClass +","+  
423       sectionsSelector + " " + removeClass  
424      ).on("click", function(event){ 
425
426         // Avoiding the link to do the default behavior.  
427         event.preventDefault();  
428  
429         // Get the container to be removed/cloned  
430         var theContainer = $(this).parents(sectionsSelector);  
431         if($(this).is(addClass)){  
432  
433            // Cloning the container with events  
434            var clonedSection = $(theContainer).clone(true);  
435  
436            // And appending it just after the current container  
437            $(clonedSection).insertAfter(theContainer);  
438         }else{  
439            // If the user confirm the "Are You Sure" message   
440            // we can remove the current container  
441            if(confirm(AYSMsg)){  
442  
443               // Making fade out, hide and remove element a sequence  
444               // to provide a nice UX when removing element.   
445               $(theContainer).fadeOut('normal',   
446                  function( ){  
447                    $(this).hide('fast',   
448                      function(){ $(this).remove();  }   
449                    );  
450                  }   
451               );  
452            }  
453         }  
454      });  
455    }
456
457    makeRepeater(  
458        '.afadir_field_ongoingscreenings_weekly',   /* The container selector */  
459        '.add',                   /* The add action selector */  
460        '.remove',                /* The remove action selector */  
461        'Are you sure you want to remove this date?' /* The AYS message. */  
462    ); 
463
464    makeRepeater(  
465        '.afadir_field_ongoingscreenings_monthly',   /* The container selector */  
466        '.add',                   /* The add action selector */  
467        '.remove',                /* The remove action selector */  
468        'Are you sure you want to remove this date?' /* The AYS message. */  
469    ); 
470
471
472	 });
473
474	function isSanitized(value) {
475		
476		if (value.match(/^[\w\,\.\_\s]+$/)){
477			return value;
478		}
479		else{
480			value = 'all';
481			return value;
482		}
483	}
484
485  function isEmpty( el ){
486      return !$.trim(el.html())
487  }
488
489
490})( 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.