PageSourceSearch

https://healthylompoc.org/res/intouch/js/block.contacts.js

js healthylompoc.org collected 2026-10-08 05:45:17 UTC 3,494 bytes, 152 lines download raw bytes

1var CONTACTS_FRONTEND_AJAX = '/ajax/intouch/contacts';
2
3mwListForm = function ($form) {
4
5	var $class = {
6
7// ---- PROPERTIES ----
8
9	ajax		: mwAjax,		// Ajax constructor
10
11// ---- METHODS ----
12
13	state		: function ($el, $state) {
14
15		// State can be loading/idle
16
17		if ( $state ) {
18
19			$el.find('.mwFormSubmit').animate({ opacity: 0 }, 300);
20			$el.find('.mwFormLoader').fadeIn(300);
21
22			// Classic compatable
23			$el.find('.mwFormSubmitRow .mwInput.Button').fadeOut(300);
24			$el.find('.mwFormSubmitRow .mwInput.Loader').fadeIn(300);
25
26		} else { //If loader
27
28			$el.find('.mwFormSubmit').animate({ opacity: 1 }, 300);
29			$el.find('.mwFormLoader').fadeOut(300);
30
31			// Classic compatable
32			$el.find('.mwFormSubmitRow .mwInput.Button').fadeIn(300);
33			$el.find('.mwFormSubmitRow .mwInput.Loader').fadeOut(300);
34
35		} //IF idle
36
37	}, //FUNC state
38
39	submit		: function () {
40
41		var $this = this;
42
43
44		// Getting form elements
45		var $el		= _jq($form);
46		var $sn		= $el.attr('id');
47		var $status	= $el.find('.mwFormStatus');
48
49		// Cleaning status
50		$status.html('');
51
52		// Cleaning status and validations
53		$status.html('');
54		setValidations($el, {});
55
56		// Setting loading state
57		$this.state($el, true);
58
59		// Getting form url
60		var $url = $el.attr('action') || CONTACTS_FRONTEND_AJAX + '/submit';
61
62		$this.ajax($url, $el, false)
63
64			.success( function ($data) {
65
66				// Not hiding loader if redirecting or reloading
67				// Othewise hiding
68
69				if ( $data.redirect )
70					window.location.href = $data.redirect;
71				else
72					$this.state($el, false);
73
74			}) //FUNC mwAjax.success
75
76			.error( function ($data) {
77
78				// Error causes idling
79				$this.state($el, false);
80
81				// Setting status if error returned
82				$status.html( mwError($data.status.text) );
83
84				// Lasy support for recaptcha
85				// Need to reset captcha on errors
86				//ToDo: Inputs based customization
87				if ( typeof(grecaptcha) !== UNDEFINED )
88					grecaptcha.reset();
89
90				// Each validation message should be captured
91				if ( $data._validations && $data._validations[$sn] ) {
92
93					// Manually processing messages yet.
94					// ToDo: Implement erorrs handling API for frontend
95
96					// Looping through each failed field and each message for that field
97					// All validatinos are indexed by form ID
98					for ( var $field in $data._validations[$sn] ) {
99						for ( var $msg in $data._validations[$sn][$field] ) {
100
101							// Appending each message to status area
102							$status.append( mwError($data._validations[$sn][$field][$msg]) );
103
104						} //FOR each message for field
105					} //FOR each fail field
106
107				} //IF validations come
108
109			}) //FUNC mwAjax.error.callback
110
111			.stop( function () {
112
113			// ---- Scrolling to form top ----
114
115				// Giving some space above form (for titles/headers)
116				var $delta = 100;
117
118				// Floating height can be specified in page template
119				var $f = jQuery('DIV[data-floatHeight]');
120
121				if ( $f.length ) {
122
123					$delta += $f.attr('data-floatHeight')*1;
124
125				} else { //IF height specified
126
127					// If not specified directly - trying to get some common
128					var $f = jQuery('.menuWrap');
129					if ( $f.css('position') == 'fixed' )
130						$delta += $f.height();
131
132				} //If nothing found
133
134				// Animating to show errors
135				jQuery('html, body').animate({
136					scrollTop: jQuery('#' + $sn).offset().top - $delta
137				}, 300); //jQuery.animate.options
138
139			}) //FUNC mwAjax.stop
140
141			.go();
142
143		return false;
144
145	} //FUNC submit
146
147// ---- END ----
148
149	} //CLASS mwListForm
150
151	return $class;
152} //CONSTRUCTOR mwListForm

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.