PageSourceSearch

https://pbr.lv/wp-content/themes/halfcreative/framework/js/pe/jquery.pixelentity.contactForm.js?ver=1415478202

js pbr.lv collected 2026-10-04 17:08:43 UTC 3,387 bytes, 155 lines download raw bytes

1(function ($) {
2	/*jslint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false, nomen: false */ 
3	/*global jQuery,setTimeout,location,setInterval,YT,clearInterval,clearTimeout,pixelentity */
4	
5	$.pixelentity = $.pixelentity || {version: '1.0.0'};
6	
7	$.pixelentity.peThemeContactForm = {	
8		conf: {
9			api: false
10		} 
11	};
12	
13	var ajaxurl = window.peContactForm ? decodeURIComponent(window.peContactForm.url) : false;
14	var validateRegexps = {
15			"email": /^[a-zA-Z0-9._\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4}$/,
16			"default": /.{4}/ 
17		};
18	
19	function PeThemeContactForm(target, conf) {
20		var fields = [];
21		var msgOK,msgKO;
22		
23		// init function
24		function start() {
25			target
26				.bind("submit",submit)
27				.find("input,textarea")
28				.each(addField)
29				.bind("change",inlineValidation)
30				.end();
31			
32			msgOK = $("#contactFormSent");
33			msgKO = $("#contactFormError");
34		}
35		
36		function addField() {
37			var el = $(this);
38			if (el.attr("type") == "submit") {
39				return;
40			}
41			fields.push(el);
42			el.attr("data-fieldID",fields.length-1);
43		}
44		
45		function inlineValidation() {
46			validate(fields[this.getAttribute("data-fieldID")]);
47			return true;
48		}
49		
50		function validate(field,submit) {
51			var val = field.val();
52			var type = field.attr("data-validation");
53			var ok = true;
54			if (val === "") {
55				if (field.hasClass("required")) {
56					ok = false;
57				}
58			} else {
59				var rule = validateRegexps[type] ? validateRegexps[type] : validateRegexps["default"];
60				ok = (val.match(rule) !== null);
61			}
62			
63			var action = ok ? "removeClass" : "addClass";
64			field[action]("error");
65			field.closest(".control-group")[action]("error");
66			return ok;
67		}
68		
69		function submit(e) {
70			var ok = true;
71			var data = {};
72			var val;
73			var i;
74			
75			for (i=0; i<fields.length; i++){
76				ok = validate(fields[i],true) && ok;
77				if (ok) {
78					if (fields[i].is(":radio") && !fields[i].is(":checked")) {
79						continue;
80					}
81					val = fields[i].val();
82					data[fields[i].attr("name")] = val;
83				}
84			}
85			target.find("span.error")[ok ? "hide" : "show"]().end();
86			target.find("span.success")[ok ? "show" : "hide"]().end();
87			if (ok) {
88				send(data);
89				msgKO.hide();
90			} else {
91				msgKO.show();
92			}
93			return false;
94		}
95		
96		function send(data) {
97			jQuery.post(
98				ajaxurl || target.attr("action"),
99				{
100					action : 'peThemeContactForm',
101					data : data
102				},
103				result
104			);
105		}
106		
107		function result(response) {
108			if (response.success) {
109				for (var i=0; i<fields.length; i++){
110					fields[i].val("");
111				}
112				msgOK.show();
113				msgKO.hide();
114			} else {
115				msgKO.show();
116				msgOK.hide();
117			}
118		}
119
120		
121		$.extend(this, {
122			// plublic API
123			destroy: function() {
124				target.data("peThemeContactForm", null);
125				target = undefined;
126			}
127		});
128		
129		// initialize
130		start();
131	}
132	
133	// jQuery plugin implementation
134	$.fn.peThemeContactForm = function(conf) {
135		
136		// return existing instance	
137		var api = this.data("peThemeContactForm");
138		
139		if (api) { 
140			return api; 
141		}
142		
143		conf = $.extend(true, {}, $.pixelentity.peThemeContactForm.conf, conf);
144		
145		// install the plugin for each entry in jQuery object
146		this.each(function() {
147			var el = $(this);
148			api = new PeThemeContactForm(el, conf);
149			el.data("peThemeContactForm", api); 
150		});
151		
152		return conf.api ? api: this;		 
153	};
154	
155}(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.