PageSourceSearch

https://une-mereveilleuse-aventure.fr/assets/frontend/js/jquery.validate.js

js une-mereveilleuse-aventure.fr collected 2026-10-08 21:19:45 UTC 53,016 bytes, 1,163 lines download raw bytes

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