PageSourceSearch

http://gbo26.ru/wp-content/plugins/calculated-fields-form/js/jquery.validate.js

js gbo26.ru collected 2026-10-08 17:42:02 UTC 40,621 bytes, 1,253 lines download raw bytes

1/**
2 * jQuery Validation Plugin @VERSION
3 *
4 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
5 * http://docs.jquery.com/Plugins/Validation
6 *
7 * Copyright (c) 2012 Jörn Zaefferer
8 *
9 * Dual licensed under the MIT and GPL licenses:
10 *   http://www.opensource.org/licenses/mit-license.php
11 *   http://www.gnu.org/licenses/gpl.html
12 */
13fbuilderjQuery = (typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery;
14 
15fbuilderjQuery(function(){
16(function($) {
17
18$.extend($.fn, {
19	// http://docs.jquery.com/Plugins/Validation/validate
20	validate: function( options ) {
21		// if nothing is selected, return nothing; can't chain anyway
22		if (!this.length) {
23			if (options && options.debug && window.console) {
24				console.warn( "nothing selected, can't validate, returning nothing" );
25			}
26			return;
27		}
28
29		// check if a validator for this form was already created
30		var validator = $.data(this[0], 'validator');
31		if ( validator ) {
32			return validator;
33		}
34
35		// Add novalidate tag if HTML5.
36		this.attr('novalidate', 'novalidate');
37
38		validator = new $.validator( options, this[0] );
39		$.data(this[0], 'validator', validator);
40
41		if ( validator.settings.onsubmit ) {
42
43			this.validateDelegate( ":submit", "click", function(ev) {
44				if ( validator.settings.submitHandler ) {
45					validator.submitButton = ev.target;
46				}
47				// allow suppressing validation by adding a cancel class to the submit button
48				if ( $(ev.target).hasClass('cancel') ) {
49					validator.cancelSubmit = true;
50				}
51			});
52
53			// validate the form on submit
54			this.submit( function( event ) {
55				if ( validator.settings.debug ) {
56					// prevent form submit to be able to see console output
57					event.preventDefault();
58				}
59				function handle() {
60					var hidden;
61					if ( validator.settings.submitHandler ) {
62						if (validator.submitButton) {
63							// insert a hidden input as a replacement for the missing submit button
64							hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
65						}
66						validator.settings.submitHandler.call( validator, validator.currentForm, event );
67						if (validator.submitButton) {
68							// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
69							hidden.remove();
70						}
71						return false;
72					}
73					return true;
74				}
75
76				// prevent submit for invalid forms or custom submit handlers
77				if ( validator.cancelSubmit ) {
78					validator.cancelSubmit = false;
79					return handle();
80				}
81				if ( validator.form() ) {
82					if ( validator.pendingRequest ) {
83						validator.formSubmitted = true;
84						return false;
85					}
86					return handle();
87				} else {
88					validator.focusInvalid();
89					return false;
90				}
91			});
92		}
93
94		return validator;
95	},
96	// http://docs.jquery.com/Plugins/Validation/valid
97	valid: function() {
98		if ( $(this[0]).is('form')) {
99			return this.validate().form();
100		} else {
101			var valid = true;
102			var validator = $(this[0].form).validate();
103			this.each(function() {
104				valid &= validator.element(this);
105			});
106			return valid;
107		}
108	},
109	// attributes: space seperated list of attributes to retrieve and remove
110	removeAttrs: function(attributes) {
111		var result = {},
112			$element = this;
113		$.each(attributes.split(/\s/), function(index, value) {
114			result[value] = $element.attr(value);
115			$element.removeAttr(value);
116		});
117		return result;
118	},
119	// http://docs.jquery.com/Plugins/Validation/rules
120	rules: function(command, argument) {
121		var element = this[0];
122
123		if (command) {
124			var settings = $.data(element.form, 'validator').settings;
125			var staticRules = settings.rules;
126			var existingRules = $.validator.staticRules(element);
127			switch(command) {
128			case "add":
129				$.extend(existingRules, $.validator.normalizeRule(argument));
130				staticRules[element.name] = existingRules;
131				if (argument.messages) {
132					settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
133				}
134				break;
135			case "remove":
136				if (!argument) {
137					delete staticRules[element.name];
138					return existingRules;
139				}
140				var filtered = {};
141				$.each(argument.split(/\s/), function(index, method) {
142					filtered[method] = existingRules[method];
143					delete existingRules[method];
144				});
145				return filtered;
146			}
147		}
148
149		var data = $.validator.normalizeRules(
150		$.extend(
151			{},
152			$.validator.metadataRules(element),
153			$.validator.classRules(element),
154			$.validator.attributeRules(element),
155			$.validator.staticRules(element)
156		), element);
157
158		// make sure required is at front
159		if (data.required) {
160			var param = data.required;
161			delete data.required;
162			data = $.extend({required: param}, data);
163		}
164
165		return data;
166	}
167});
168
169// Custom selectors
170$.extend($.expr[":"], {
171	// http://docs.jquery.com/Plugins/Validation/blank
172	blank: function(a) {return !$.trim("" + a.value);},
173	// http://docs.jquery.com/Plugins/Validation/filled
174	filled: function(a) {return !!$.trim("" + a.value);},
175	// http://docs.jquery.com/Plugins/Validation/unchecked
176	unchecked: function(a) {return !a.checked;}
177});
178
179// constructor for validator
180$.validator = function( options, form ) {
181	this.settings = $.extend( true, {}, $.validator.defaults, options );
182	this.currentForm = form;
183	this.init();
184};
185
186$.validator.format = function(source, params) {
187	if ( arguments.length === 1 ) {
188		return function() {
189			var args = $.makeArray(arguments);
190			args.unshift(source);
191			return $.validator.format.apply( this, args );
192		};
193	}
194	if ( arguments.length > 2 && params.constructor !== Array  ) {
195		params = $.makeArray(arguments).slice(1);
196	}
197	if ( params.constructor !== Array ) {
198		params = [ params ];
199	}
200	$.each(params, function(i, n) {
201		source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
202	});
203	return source;
204};
205
206$.extend($.validator, {
207
208	defaults: {
209		messages: {},
210		groups: {},
211		rules: {},
212		errorClass: "cpefb_error",
213		validClass: "valid",
214		errorElement: "label",
215		focusInvalid: true,
216		errorContainer: $( [] ),
217		errorLabelContainer: $( [] ),
218		onsubmit: true,
219		ignore: ":hidden",
220		ignoreTitle: false,
221		onfocusin: function(element, event) {
222			this.lastActive = element;
223
224			// hide error label and remove error class on focus if enabled
225			if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
226				if ( this.settings.unhighlight ) {
227					this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.val
227idClass );
228				}
229				this.addWrapper(this.errorsFor(element)).hide();
230			}
231		},
232		onfocusout: function(element, event) {
233			if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
234				this.element(element);
235			}
236		},
237		onkeyup: function(element, event) {
238			if ( element.name in this.submitted || element === this.lastElement ) {
239				this.element(element);
240			}
241		},
242		onclick: function(element, event) {
243			// click on selects, radiobuttons and checkboxes
244			if ( element.name in this.submitted ) {
245				this.element(element);
246			}
247			// or option elements, check parent select in that case
248			else if (element.parentNode.name in this.submitted) {
249				this.element(element.parentNode);
250			}
251		},
252		highlight: function(element, errorClass, validClass) {
253			if (element.type === 'radio') {
254				this.findByName(element.name).addClass(errorClass).removeClass(validClass);
255			} else {
256				$(element).addClass(errorClass).removeClass(validClass);
257			}
258		},
259		unhighlight: function(element, errorClass, validClass) {
260			if (element.type === 'radio') {
261				this.findByName(element.name).removeClass(errorClass).addClass(validClass);
262			} else {
263				$(element).removeClass(errorClass).addClass(validClass);
264			}
265		}
266	},
267
268	// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
269	setDefaults: function(settings) {
270		$.extend( $.validator.defaults, settings );
271	},
272
273	messages: {
274		required: "This field is required.",
275		remote: "Please fix this field.",
276		email: "Please enter a valid email address.",
277		url: "Please enter a valid URL.",
278		date: "Please enter a valid date.",
279		dateISO: "Please enter a valid date (ISO).",
280		number: "Please enter a valid number.",
281		digits: "Please enter only digits.",
282		creditcard: "Please enter a valid credit card number.",
283		equalTo: "Please enter the same value again.",
284		accept: "Please enter a value with a valid extension.",
285		upload_size: $.validator.format("The file you've chosen is too big, maximum is {0} kB."),
286		maxlength: $.validator.format("Please enter no more than {0} characters."),
287		minlength: $.validator.format("Please enter at least {0} characters."),
288		rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
289		range: $.validator.format("Please enter a value between {0} and {1}."),
290		max: $.validator.format("Please enter a value less than or equal to {0}."),
291		min: $.validator.format("Please enter a value greater than or equal to {0}.")
292	},
293
294	autoCreateRanges: false,
295
296	prototype: {
297
298		init: function() {
299			this.labelContainer = $(this.settings.errorLabelContainer);
300			this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
301			this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
302			this.submitted = {};
303			this.valueCache = {};
304			this.pendingRequest = 0;
305			this.pending = {};
306			this.invalid = {};
307			this.reset();
308
309			var groups = (this.groups = {});
310			$.each(this.settings.groups, function(key, value) {
311				$.each(value.split(/\s/), function(index, name) {
312					groups[name] = key;
313				});
314			});
315			var rules = this.settings.rules;
316			$.each(rules, function(key, value) {
317				rules[key] = $.validator.normalizeRule(value);
318			});
319
320			function delegate(event) {
321				var validator = $.data(this[0].form, "validator"),
322					eventType = "on" + event.type.replace(/^validate/, "");
323				if (validator.settings[eventType]) {
324					validator.settings[eventType].call(validator, this[0], event);
325				}
326			}
327			$(this.currentForm)
328				.validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, " +
329					"[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
330					"[type='email'], [type='datetime'], [type='date'], [type='month'], " +
331					"[type='week'], [type='time'], [type='datetime-local'], " +
332					"[type='range'], [type='color'] ",
333					"focusin focusout keyup", delegate)
334				.validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
335
336			if (this.settings.invalidHandler) {
337				$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
338			}
339		},
340
341		// http://docs.jquery.com/Plugins/Validation/Validator/form
342		form: function() {
343			this.checkForm();
344			$.extend(this.submitted, this.errorMap);
345			this.invalid = $.extend({}, this.errorMap);
346			if (!this.valid()) {
347				$(this.currentForm).triggerHandler("invalid-form", [this]);
348			}
349			this.showErrors();
350			return this.valid();
351		},
352
353		checkForm: function() {
354			this.prepareForm();
355			for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
356				this.check( elements[i] );
357			}
358			return this.valid();
359		},
360
361		// http://docs.jquery.com/Plugins/Validation/Validator/element
362		element: function( element ) {
363			element = this.validationTargetFor( this.clean( element ) );
364			this.lastElement = element;
365			this.prepareElement( element );
366			this.currentElements = $(element);
367			var result = this.check( element ) !== false;
368			if (result) {
369				delete this.invalid[element.name];
370			} else {
371				this.invalid[element.name] = true;
372			}
373			if ( !this.numberOfInvalids() ) {
374				// Hide error containers on last error
375				this.toHide = this.toHide.add( this.containers );
376			}
377			this.showErrors();
378			return result;
379		},
380
381		// http://docs.jquery.com/Plugins/Validation/Validator/showErrors
382		showErrors: function(errors) {
383			if(errors) {
384				// add items to error list and map
385				$.extend( this.errorMap, errors );
386				this.errorList = [];
387				for ( var name in errors ) {
388					this.errorList.push({
389						message: errors[name],
390						element: this.findByName(name)[0]
391					});
392				}
393				// remove items from success list
394				this.successList = $.grep( this.successList, function(element) {
395					return !(element.name in errors);
396				});
397			}
398			if (this.settings.showErrors) {
399				this.settings.showErrors.call( this, this.errorMap, this.errorList );
400			} else {
401				this.defaultShowErrors();
402			}
403		},
404
405		// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
406		resetForm: function() {
407			if ( $.fn.resetForm ) {
408				$( this.currentForm ).resetForm();
409			}
410			this.submitted = {};
411			this.lastElement = null;
412			this.prepareForm();
413			this.hideErrors();
414			this.elements().removeClass( this.settings.errorClass );
415		},
416
417		numberOfInvalids: function() {
418			return this.objectLength(this.invalid);
419		},
420
421		objectLength: function( obj ) {
422			var count = 0;
423			for ( var i in obj ) {
424				count++;
425			}
426			return count;
427		},
428
429		hideErrors: function() {
430			this.addWrapper( this.toHide ).hide();
431		},
432
433		valid: function() {
434			return this.size() === 0;
435		},
436
437		size: function() {
438			return this.errorList.length;
439		},
440
441		focusInvalid: function() {
442			if( this.settings.focusInvalid ) {
443				try {
444					$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
445					.filter(":visible")
446					.focus()
447					// manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
448					.trigger("focusin");
449				} catch(e) {
450					// ignore IE throwing errors when focusing hidden elements
451				}
452			}
453		},
454
455		findLastActive: function() {
456			var lastActive = this.lastActive;
457			return lastActive && $.grep(this.errorList, function(n) {
458				return n.element.name === lastActive.name;
459			}).length === 1 && lastActive;
460		},
461
462		elements: function() {
463			var validator = this,
464				rulesCache = {};
465
466			// select all valid inputs inside the form (no submit or reset buttons)
467			return $(this.currentForm)
468			.find("input, select, textarea")
469			.not(":submit, :reset, :image, [disabled]")
470			.not( this.settings.ignore )
471			.filter(function() {
472				if ( !this.name && validator.settings.debug && window.console ) {
473					console.error( "%o has no name assigned", this);
474				}
475
476				// select only the first element for each name, and only those with rules specified
477				if ( this.name in rulesCache || !validator.objectLength($(this).rules()) ) {
478					return false;
479				}
480
481				rulesCache[this.name] = true;
482				return true;
483			});
484		},
485
486		clean: function( selector ) {
487			return $( selector )[0];
488		},
489
490		errors: function() {
491			var errorClass = this.settings.errorClass.replace(' ', '.');
492			return $( this.settings.errorElement + "." + errorClass, this.errorContext );
493		},
494
495		reset: function() {
496			this.successList = [];
497			this.errorList = [];
498			this.errorMap = {};
499			this.toShow = $([]);
500			this.toHide = $([]);
501			this.currentElements = $([]);
502		},
503
504		prepareForm: function() {
505			this.reset();
506			this.toHide = this.errors().add( this.containers );
507		},
508
509		prepareElement: function( element ) {
510			this.reset();
511			this.toHide = this.errorsFor(element);
512		},
513
514		elementValue: function( element ) {
515			var val = $(element).val();
516			if( typeof val === 'string' ) {
517				return val.replace(/\r/g, "");
518			}
519			return val;
520		},
521
522		check: function( element ) {
523			element = this.validationTargetFor( this.clean( element ) );
524
525			var rules = $(element).rules();
526			var dependencyMismatch = false;
527			var val = this.elementValue(element);
528			var result;
529
530			for (var method in rules ) {
531				var rule = { method: method, parameters: rules[method] };
532				try {
533
534					result = $.validator.methods[method].call( this, val, element, rule.parameters );
535
536					// if a method indicates that the field is optional and therefore valid,
537					// don't mark it as valid when there are no other rules
538					if ( result === "dependency-mismatch" ) {
539						dependencyMismatch = true;
540						continue;
541					}
542					dependencyMismatch = false;
543
544					if ( result === "pending" ) {
545						this.toHide = this.toHide.not( this.errorsFor(element) );
546						return;
547					}
548
549					if( !result ) {
550						this.formatAndAdd( element, rule );
551						return false;
552					}
553				} catch(e) {
554					if ( this.settings.debug && window.console ) {
555						console.log("exception occurred when checking element " + element.i
555d + ", check the '" + rule.method + "' method", e);
556					}
557					throw e;
558				}
559			}
560			if (dependencyMismatch) {
561				return;
562			}
563			if ( this.objectLength(rules) ) {
564				this.successList.push(element);
565			}
566			return true;
567		},
568
569		// return the custom message for the given element and validation method
570		// specified in the element's "messages" metadata
571		customMetaMessage: function(element, method) {
572			if (!$.metadata) {
573				return;
574			}
575			var meta = this.settings.meta ? $(element).metadata()[this.settings.meta] : $(element).metadata();
576			return meta && meta.messages && meta.messages[method];
577		},
578
579		// return the custom message for the given element name and validation method
580		customMessage: function( name, method ) {
581			var m = this.settings.messages[name];
582			return m && (m.constructor === String ? m : m[method]);
583		},
584
585		// return the first defined argument, allowing empty strings
586		findDefined: function() {
587			for(var i = 0; i < arguments.length; i++) {
588				if (arguments[i] !== undefined) {
589					return arguments[i];
590				}
591			}
592			return undefined;
593		},
594
595		defaultMessage: function( element, method) {
596			return this.findDefined(
597				this.customMessage( element.name, method ),
598				this.customMetaMessage( element, method ),
599				// title is never undefined, so handle empty string as undefined
600				!this.settings.ignoreTitle && element.title || undefined,
601				$.validator.messages[method],
602				"<strong>Warning: No message defined for " + element.name + "</strong>"
603			);
604		},
605
606		formatAndAdd: function( element, rule ) {
607			var message = this.defaultMessage( element, rule.method ),
608				theregex = /\$?\{(\d+)\}/g;
609			if ( typeof message === "function" ) {
610				message = message.call(this, rule.parameters, element);
611			} else if (theregex.test(message)) {
612				message = $.validator.format(message.replace(theregex, '{$1}'), rule.parameters);
613			}
614			this.errorList.push({
615				message: message,
616				element: element
617			});
618
619			this.errorMap[element.name] = message;
620			this.submitted[element.name] = message;
621		},
622
623		addWrapper: function(toToggle) {
624			if ( this.settings.wrapper ) {
625				toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
626			}
627			return toToggle;
628		},
629
630		defaultShowErrors: function() {
631			var i, elements;
632			for ( i = 0; this.errorList[i]; i++ ) {
633				var error = this.errorList[i];
634				if ( this.settings.highlight ) {
635					this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
636				}
637				this.showLabel( error.element, error.message );
638			}
639			if( this.errorList.length ) {
640				this.toShow = this.toShow.add( this.containers );
641			}
642			if (this.settings.success) {
643				for ( i = 0; this.successList[i]; i++ ) {
644					this.showLabel( this.successList[i] );
645				}
646			}
647			if (this.settings.unhighlight) {
648				for ( i = 0, elements = this.validElements(); elements[i]; i++ ) {
649					this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
650				}
651			}
652			this.toHide = this.toHide.not( this.toShow );
653			this.hideErrors();
654			this.addWrapper( this.toShow ).show();
655		},
656
657		validElements: function() {
658			return this.currentElements.not(this.invalidElements());
659		},
660
661		invalidElements: function() {
662			return $(this.errorList).map(function() {
663				return this.element;
664			});
665		},
666
667		showLabel: function(element, message) {
668			var label = this.errorsFor( element );
669			if ( label.length ) {
670				// refresh error/success class
671				label.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
672
673				// check if we have a generated label, replace the message then
674				if ( label.attr("generated") ) {
675					label.html(message);
676				}
677			} else {
678				// create label
679				label = $("<" + this.settings.errorElement + "/>")
680					.attr({"for":  this.idOrName(element), generated: true})
681					.addClass(this.settings.errorClass)
682					.html(message || "");
683				if ( this.settings.wrapper ) {
684					// make sure the element is visible, even in IE
685					// actually showing the wrapped element is handled elsewhere
686					label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
687				}
688				if ( !this.labelContainer.append(label).length ) {
689					if ( this.settings.errorPlacement ) {
690						this.settings.errorPlacement(label, $(element) );
691					} else {
692					label.insertAfter(element);
693					}
694				}
695			}
696			if ( !message && this.settings.success ) {
697				label.text("");
698				if ( typeof this.settings.success === "string" ) {
699					label.addClass( this.settings.success );
700				} else {
701					this.settings.success( label );
702				}
703			}
704			this.toShow = this.toShow.add(label);
705		},
706
707		errorsFor: function(element) {
708			var name = this.idOrName(element);
709			return this.errors().filter(function() {
710				return $(this).attr('for') === name;
711			});
712		},
713
714		idOrName: function(element) {
715			return this.groups[element.name] || (this.checkable(element) ? element.name : element.i
715d || element.name);
716		},
717
718		validationTargetFor: function(element) {
719			// if radio/checkbox, validate first element in group instead
720			if (this.checkable(element)) {
721				element = this.findByName( element.name ).not(this.settings.ignore)[0];
722			}
723			return element;
724		},
725
726		checkable: function( element ) {
727			return (/radio|checkbox/i).test(element.type);
728		},
729
730		findByName: function( name ) {
731			// select by name and filter by form for performance over form.find("[name=...]")
732			var form = this.currentForm;
733			return $(document.getElementsByName(name)).map(function(index, element) {
734				return element.form === form && element.name === name && element  || null;
735			});
736		},
737
738		getLength: function(value, element) {
739			switch( element.nodeName.toLowerCase() ) {
740			case 'select':
741				return $("option:selected", element).length;
742			case 'input':
743				if( this.checkable( element) ) {
744					return this.findByName(element.name).filter(':checked').length;
745				}
746			}
747			return value.length;
748		},
749
750		depend: function(param, element) {
751			return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true;
752		},
753
754		dependTypes: {
755			"boolean": function(param, element) {
756				return param;
757			},
758			"string": function(param, element) {
759				return !!$(param, element.form).length;
760			},
761			"function": function(param, element) {
762				return param(element);
763			}
764		},
765
766		optional: function(element) {
767			var val = this.elementValue(element);
768			return !$.validator.methods.required.call(this, val, element) && "dependency-mismatch";
769		},
770
771		startRequest: function(element) {
772			if (!this.pending[element.name]) {
773				this.pendingRequest++;
774				this.pending[element.name] = true;
775			}
776		},
777
778		stopRequest: function(element, valid) {
779			this.pendingRequest--;
780			// sometimes synchronization fails, make sure pendingRequest is never < 0
781			if (this.pendingRequest < 0) {
782				this.pendingRequest = 0;
783			}
784			delete this.pending[element.name];
785			if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) {
786				$(this.currentForm).submit();
787				this.formSubmitted = false;
788			} else if (!valid && this.pendingRequest === 0 && this.formSubmitted) {
789				$(this.currentForm).triggerHandler("invalid-form", [this]);
790				this.formSubmitted = false;
791			}
792		},
793
794		previousValue: function(element) {
795			return $.data(element, "previousValue") || $.data(element, "previousValue", {
796				old: null,
797				valid: true,
798				message: this.defaultMessage( element, "remote" )
799			});
800		}
801
802	},
803
804	classRuleSettings: {
805		required: {required: true},
806		email: {email: true},
807		url: {url: true},
808		date: {date: true},
809		dateISO: {dateISO: true},
810		number: {number: true},
811		digits: {digits: true},
812		creditcard: {creditcard: true}
813	},
814
815	addClassRules: function(className, rules) {
816		if ( className.constructor === String ) {
817			this.classRuleSettings[className] = rules;
818		} else {
819			$.extend(this.classRuleSettings, className);
820		}
821	},
822
823	classRules: function(element) {
824		var rules = {};
825		var classes = $(element).attr('class');
826		if ( classes ) {
827			$.each(classes.split(' '), function() {
828				if (this in $.validator.classRuleSettings) {
829					$.extend(rules, $.validator.classRuleSettings[this]);
830				}
831			});
832		}
833		return rules;
834	},
835
836	attributeRules: function(element) {
837		var rules = {};
838		var $element = $(element);
839
840		for (var method in $.validator.methods) {
841			var value;
842
843			// support for <input required> in both html5 and older browsers
844			if (method === 'required') {
845				value = $element.get(0).getAttribute(method);
846				// Some browsers return an empty string for the required attribute
847				// and non-HTML5 browsers might have required="" markup
848				if (value === "") {
849					value = true;
850				} else if (value === "false") {
851					value = false;
852				}
853				// force non-HTML5 browsers to return bool
854				value = !!value;
855			} else {
856				value = $element.attr(method);
857			}
858
859			if (value) {
860				rules[method] = value;
861			} else if ($element[0].getAttribute("type") === method) {
862				rules[method] = true;
863			}
864		}
865
866		// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
867		if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
868			delete rules.maxlength;
869		}
870
871		return rules;
872	},
873
874	metadataRules: function(element) {
875		if (!$.metadata) {
876			return {};
877		}
878
879		var meta = $.data(element.form, 'validator').settings.meta;
880		return meta ?
881			$(element).metadata()[meta] :
882			$(element).metadata();
883	},
884
885	staticRules: function(element) {
886		var rules = {};
887		var validator = $.data(element.form, 'validator');
888		if (validator.settings.rules) {
889			rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
890		}
891		return rules;
892	},
893
894	normalizeRules: function(rules, element) {
895		// handle dependency check
896		$.each(rules, function(prop, val) {
897			// ignore rule when param is explicitly false, eg. required:false
898			if (val === false) {
899				delete rules[prop];
900				return;
901			}
902			if (val.param || val.depends) {
903				var keepRule = true;
904				switch (typeof val.depends) {
905					case "string":
906						keepRule = !!$(val.depends, element.form).length;
907						break;
908					case "function":
909						keepRule = val.depends.call(element, element);
910						break;
911				}
912				if (keepRule) {
913					rules[prop] = val.param !== undefined ? val.param : true;
914				} else {
915					delete rules[prop];
916				}
917			}
918		});
919
920		// evaluate parameters
921		$.each(rules, function(rule, parameter) {
922			rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
923		});
924
925		// clean number parameters
926		$.each(['minlength', 'maxlength', 'min', 'max'], function() {
927			if (rules[this]) {
928				rules[this] = Number(rules[this]);
929			}
930		});
931		$.each(['rangelength', 'range'], function() {
932			if (rules[this]) {
933				rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
934			}
935		});
936
937		if ($.validator.autoCreateRanges) {
938			// auto-create ranges
939			if (rules.min && rules.max) {
940				rules.range = [rules.min, rules.max];
941				delete rules.min;
942				delete rules.max;
943			}
944			if (rules.minlength && rules.maxlength) {
945				rules.rangelength = [rules.minlength, rules.maxlength];
946				delete rules.minlength;
947				delete rules.maxlength;
948			}
949		}
950
951		// To support custom messages in metadata ignore rule methods titled "messages"
952		if (rules.messages) {
953			delete rules.messages;
954		}
955
956		return rules;
957	},
958
959	// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
960	normalizeRule: function(data) {
961		if( typeof data === "string" ) {
962			var transformed = {};
963			$.each(data.split(/\s/), function() {
964				transformed[this] = true;
965			});
966			data = transformed;
967		}
968		return data;
969	},
970
971	// http://docs.jquery.com/Plugins/Validation/Validator/addMethod
972	addMethod: function(name, method, message) {
973		$.validator.methods[name] = method;
974		$.validator.messages[name] = message !== undefined ? message : $.validator.messages[name];
975		if (method.length < 3) {
976			$.validator.addClassRules(name, $.validator.normalizeRule(name));
977		}
978	},
979
980	methods: {
981
982		// http://docs.jquery.com/Plugins/Validation/Methods/required
983		required: function(value, element, param) {
984			// check if dependency is met
985			if ( !this.depend(param, element) ) {
986				return "dependency-mismatch";
987			}
988			if ( element.nodeName.toLowerCase() === "select" ) {
989				// could be an array for select-multiple or a string, both are fine this way
990				var val = $(element).val();
991				return val && val.length > 0;
992			}
993			if ( this.checkable(element) ) {
994				return this.getLength(value, element) > 0;
995			}
996			return $.trim(value).length > 0;
997		},
998
999		// http://docs.jquery.com/Plugins/Validation/Methods/remote
1000		remote: function(value, element, param) {
1001			if ( this.optional(element) ) {
1002				return "dependency-mismatch";
1003			}
1004
1005			var previous = this.previousValue(element);
1006			if (!this.settings.messages[element.name] ) {
1007				this.settings.messages[element.name] = {};
1008			}
1009			previous.originalMessage = this.settings.messages[element.name].remote;
1010			this.settings.messages[element.name].remote = previous.message;
1011
1012			param = typeof param === "string" && {url:param} || param;
1013
1014			if ( this.pending[element.name] ) {
1015				return "pending";
1016			}
1017			if ( previous.old === value ) {
1018				return previous.valid;
1019			}
1020
1021			previous.old = value;
1022			var validator = this;
1023			this.startRequest(element);
1024			var data = {};
1025			data[element.name] = value;
1026			$.ajax($.extend(true, {
1027				url: param,
1028				mode: "abort",
1029				port: "validate" + element.name,
1030				dataType: "json",
1031				data: data,
1032				success: function(response) {
1033					validator.settings.messages[element.name].remote = previous.originalMessage;
1034					var valid = response === true;
1035					if ( valid ) {
1036						var submitted = validator.formSubmitted;
1037						validator.prepareElement(element);
1038						validator.formSubmitted = submitted;
1039						validator.successList.push(element);
1040						validator.showErrors();
1041					} else {
1042						var errors = {};
1043						var message = response || validator.defaultMessage( element, "remote" );
1044						errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
1045						validator.showErrors(errors);
1046					}
1047					previous.valid = valid;
1048					validator.stopRequest(element, valid);
1049				}
1050			}, param));
1051			return "pending";
1052		},
1053
1054		// http://docs.jquery.com/Plugins/Validation/Methods/minlength
1055		minlength: function(value, element, param) {
1056			var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1057			return this.optional(element) || length >= param;
1058		},
1059
1060		// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
1061		maxlength: function(value, element, param) {
1062			var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1063			return this.optional(element) || length <= param;
1064		},
1065
1066		// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
1067		rangelength: function(value, element, param) {
1068			var length = $.isArray( value ) ? value.length : this.getLength($.trim(value), element);
1069			return this.optional(element) || ( length >= param[0] && length <= param[1] );
1070		},
1071
1072		// http://docs.jquery.com/Plugins/Validation/Methods/min
1073		min: function( value, element, param ) {
1074			return this.optional(element) || value >= param;
1075		},
1076
1077		// http://docs.jquery.com/Plugins/Validation/Methods/max
1078		max: function( value, element, param ) {
1079			return this.optional(element) || value <= param;
1080		},
1081
1082		// http://docs.jquery.com/Plugins/Validation/Methods/range
1083		range: function( value, element, param ) {
1084			return this.optional(element) || ( value >= param[0] && value <= param[1] );
1085		},
1086
1087		// http://docs.jquery.com/Plugins/Validation/Methods/email
1088		email: function(value, element) {
1089			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
1090			return this.optional(element) || /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i.test(value);
1091		},
1092
1093		// http://docs.jquery.com/Plugins/Validation/Methods/url
1094		url: function(value, element) {
1095			// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
1096			return this.optional(element) || /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value);
1097		},
1098
1099		// http://docs.jquery.com/Plugins/Validation/Methods/date
1100		date: function(value, element) {
1101			return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
1102		},
1103
1104		// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
1105		dateISO: function(value, element) {
1106			return this.optional(element) || /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(value);
1107		},
1108
1109		// http://docs.jquery.com/Plugins/Validation/Methods/number
1110		number: function(value, element) {
1111			return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
1112		},
1113
1114		// http://docs.jquery.com/Plugins/Validation/Methods/digits
1115		digits: function(value, element) {
1116			return this.optional(element) || /^\d+$/.test(value);
1117		},
1118
1119		// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
1120		// based on http://en.wikipedia.org/wiki/Luhn
1121		creditcard: function(value, element) {
1122			if ( this.optional(element) ) {
1123				return "dependency-mismatch";
1124			}
1125			// accept only spaces, digits and dashes
1126			if (/[^0-9 \-]+/.test(value)) {
1127				return false;
1128			}
1129			var nCheck = 0,
1130				nDigit = 0,
1131				bEven = false;
1132
1133			value = value.replace(/\D/g, "");
1134
1135			for (var n = value.length - 1; n >= 0; n--) {
1136				var cDigit = value.charAt(n);
1137				nDigit = parseInt(cDigit, 10);
1138				if (bEven) {
1139					if ((nDigit *= 2) > 9) {
1140						nDigit -= 9;
1141					}
1142				}
1143				nCheck += nDigit;
1144				bEven = !bEven;
1145			}
1146
1147			return (nCheck % 10) === 0;
1148		},
1149
1150		// http://docs.jquery.com/Plugins/Validation/Methods/accept
1151		accept: function(value, element, param) {
1152			param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
1153			return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
1154		},
1155
1156		// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
1157		equalTo: function(value, element, param) {
1158			// bind to the blur event of the target in order to revalidate whenever the target field is updated
1159			// TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
1160			var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
1161				$(element).valid();
1162			});
1163			return value === target.val();
1164		}
1165
1166	}
1167
1168});
1169
1170// deprecated, use $.validator.format instead
1171$.format = $.validator.format;
1172
1173}(fbuilderjQuery));
1174
1175// ajax mode: abort
1176// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
1177// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
1178(function($) {
1179	var pendingRequests = {};
1180	// Use a prefilter if available (1.5+)
1181	if ( $.ajaxPrefilter ) {
1182		$.ajaxPrefilter(function(settings, _, xhr) {
1183			var port = settings.port;
1184			if (settings.mode === "abort") {
1185				if ( pendingRequests[port] ) {
1186					pendingRequests[port].abort();
1187				}
1188				pendingRequests[port] = xhr;
1189			}
1190		});
1191	} else {
1192		// Proxy ajax
1193		var ajax = $.ajax;
1194		$.ajax = function(settings) {
1195			var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
1196				port = ( "port" in settings ? settings : $.ajaxSettings ).port;
1197			if (mode === "abort") {
1198				if ( pendingRequests[port] ) {
1199					pendingRequests[port].abort();
1200				}
1201				return (pendingRequests[port] = ajax.apply(this, arguments));
1202			}
1203			return ajax.apply(this, arguments);
1204		};
1205	}
1206}(fbuilderjQuery));
1207
1208// provides cross-browser focusin and focusout events
1209// IE has native support, in other browsers, use event caputuring (neither bubbles)
1210
1211// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
1212// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
1213(function($) {
1214	// only implement if not provided by jQuery core (since 1.4)
1215	// TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
1216	if (!fbuilderjQuery.event.special.focusin && !fbuilderjQuery.event.special.focusout && document.addEventListener) {
1217		$.each({
1218			focus: 'focusin',
1219			blur: 'focusout'
1220		}, function( original, fix ){
1221			$.event.special[fix] = {
1222				setup:function() {
1223					this.addEventListener( original, handler, true );
1224				},
1225				teardown:function() {
1226					this.removeEventListener( original, handler, true );
1227				},
1228				handler: function(e) {
1229					var args = arguments;
1230					args[0] = $.event.fix(e);
1231					args[0].type = fix;
1232					return $.event.dispatch.apply(this, args);
1233				}
1234			};
1235			function handler(e) {
1236				e = $.event.fix(e);
1237				e.type = fix;
1238				return $.event.dispatch.call(this, e);
1239			}
1240		});
1241	}
1242	$.extend($.fn, {
1243		validateDelegate: function(delegate, type, handler) {
1244			return this.bind(type, function(event) {
1245				var target = $(event.target);
1246				if (target.is(delegate)) {
1247					return handler.apply(target, arguments);
1248				}
1249			});
1250		}
1251	});
1252}(fbuilderjQuery));
1253});

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.