PageSourceSearch

https://www.foxvalleyymca.org/core/lib/front/auto_capitalize.js?ver=1.0

js foxvalleyymca.org collected 2026-09-28 07:33:09 UTC 1,587 bytes, 68 lines download raw bytes

1//ver 1.0
2(function($) {
3	var CAPITALIZE_FIELD_NAMES = [
4		'FirstName',
5		'MiddleName',
6		'LastName',
7		'HomeAddress',
8		'HomeAddressLine2',
9		'HomeCity',
10		'BusinessAddress',
11		'BusinessAddressLine2',
12		'BusinessCity',
13		'EmergencyContact',
14		'BillingAddress',
15		'City',
16	];
17	var SKIP_FIELD_NAMES = {
18		HomeState: true,
19		BusinessState: true,
20	};
21
22	function capitalizeTokens(str) {
23		if(typeof str != 'string') {
24			return '';
25		}
26		return str.replace(/\S+/g, function(token) {//For each cluster of non-whitespace characters attempt to capitalize the first letter.
27			return token.charAt(0).toUpperCase() + token.slice(1);
28		});
29	}
30
31	function buildSelector() {
32		return CAPITALIZE_FIELD_NAMES.map(function(name) {
33			return 'input[name="' + name + '"], textarea[name="' + name + '"]';
34		}).join(',');
35	}
36
37	function initAutoCapitalizeFields() {
38		var selector = buildSelector();
39		$(document).on('blur', selector, function() {
40			if(!window.CoreGlobals || CoreGlobals.AutoCapitalize !== 'name_and_address') {
41				return;
42			}
43
44			var $field = $(this);
45			if($field.data('autoCapitalizeApplied')) {
46				return;
47			}
48
49			var name = $field.attr('name');
50			if(SKIP_FIELD_NAMES[name]) {
51				return;
52			}
53
54			var val = $field.val();
55			if(typeof val !== 'string' || val.trim() === '') {
56				return;
57			}
58
59			$field.val(capitalizeTokens(val));
60			$field.data('autoCapitalizeApplied', true);
61		});
62	}
63
64	window.capitalizeTokens = window.capitalizeTokens || capitalizeTokens;
65	window.initAutoCapitalizeFields = initAutoCapitalizeFields;
66
67	$(document).ready(initAutoCapitalizeFields);
68})(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.