summaryrefslogtreecommitdiff
path: root/site-media/js
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2011-06-14 00:19:02 +0200
committerLeif Johansson <leifj@sunet.se>2011-06-14 00:19:02 +0200
commit89c04f033f4f4bc1a4a7f1e6fdb09c9798a7b60b (patch)
treee18d515d27aa7c7d4808e834a2928c479c323c9c /site-media/js
parent63eac434d82c8a18c3c2b437049f8c2401b0349f (diff)
updated validation
Diffstat (limited to 'site-media/js')
-rw-r--r--site-media/js/jquery.validate.js376
1 files changed, 198 insertions, 178 deletions
diff --git a/site-media/js/jquery.validate.js b/site-media/js/jquery.validate.js
index e402ea8..72296a6 100644
--- a/site-media/js/jquery.validate.js
+++ b/site-media/js/jquery.validate.js
@@ -1,12 +1,10 @@
-/*
- * jQuery validation plug-in 1.7
+/**
+ * jQuery Validation Plugin 1.8.1
*
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
* http://docs.jquery.com/Plugins/Validation
*
- * Copyright (c) 2006 - 2008 Jörn Zaefferer
- *
- * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
+ * Copyright (c) 2006 - 2011 Jörn Zaefferer
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
@@ -30,30 +28,30 @@ $.extend($.fn, {
if ( validator ) {
return validator;
}
-
+
validator = new $.validator( options, this[0] );
- $.data(this[0], 'validator', validator);
-
+ $.data(this[0], 'validator', validator);
+
if ( validator.settings.onsubmit ) {
-
+
// allow suppresing validation by adding a cancel class to the submit button
this.find("input, button").filter(".cancel").click(function() {
validator.cancelSubmit = true;
});
-
+
// when a submitHandler is used, capture the submitting button
if (validator.settings.submitHandler) {
this.find("input, button").filter(":submit").click(function() {
validator.submitButton = this;
});
}
-
+
// validate the form on submit
this.submit( function( event ) {
if ( validator.settings.debug )
// prevent form submit to be able to see console output
event.preventDefault();
-
+
function handle() {
if ( validator.settings.submitHandler ) {
if (validator.submitButton) {
@@ -69,7 +67,7 @@ $.extend($.fn, {
}
return true;
}
-
+
// prevent submit for invalid forms or custom submit handlers
if ( validator.cancelSubmit ) {
validator.cancelSubmit = false;
@@ -87,7 +85,7 @@ $.extend($.fn, {
}
});
}
-
+
return validator;
},
// http://docs.jquery.com/Plugins/Validation/valid
@@ -116,7 +114,7 @@ $.extend($.fn, {
// http://docs.jquery.com/Plugins/Validation/rules
rules: function(command, argument) {
var element = this[0];
-
+
if (command) {
var settings = $.data(element.form, 'validator').settings;
var staticRules = settings.rules;
@@ -141,7 +139,7 @@ $.extend($.fn, {
return filtered;
}
}
-
+
var data = $.validator.normalizeRules(
$.extend(
{},
@@ -150,14 +148,14 @@ $.extend($.fn, {
$.validator.attributeRules(element),
$.validator.staticRules(element)
), element);
-
+
// make sure required is at front
if (data.required) {
var param = data.required;
delete data.required;
data = $.extend({required: param}, data);
}
-
+
return data;
}
});
@@ -180,7 +178,7 @@ $.validator = function( options, form ) {
};
$.validator.format = function(source, params) {
- if ( arguments.length == 1 )
+ if ( arguments.length == 1 )
return function() {
var args = $.makeArray(arguments);
args.unshift(source);
@@ -199,7 +197,7 @@ $.validator.format = function(source, params) {
};
$.extend($.validator, {
-
+
defaults: {
messages: {},
groups: {},
@@ -215,11 +213,11 @@ $.extend($.validator, {
ignoreTitle: false,
onfocusin: function(element) {
this.lastActive = element;
-
+
// hide error label and remove error class on focus if enabled
if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
- this.errorsFor(element).hide();
+ this.addWrapper(this.errorsFor(element)).hide();
}
},
onfocusout: function(element) {
@@ -240,11 +238,19 @@ $.extend($.validator, {
else if (element.parentNode.name in this.submitted)
this.element(element.parentNode);
},
- highlight: function( element, errorClass, validClass ) {
- $(element).addClass(errorClass).removeClass(validClass);
+ highlight: function(element, errorClass, validClass) {
+ if (element.type === 'radio') {
+ this.findByName(element.name).addClass(errorClass).removeClass(validClass);
+ } else {
+ $(element).addClass(errorClass).removeClass(validClass);
+ }
},
- unhighlight: function( element, errorClass, validClass ) {
- $(element).removeClass(errorClass).addClass(validClass);
+ unhighlight: function(element, errorClass, validClass) {
+ if (element.type === 'radio') {
+ this.findByName(element.name).removeClass(errorClass).addClass(validClass);
+ } else {
+ $(element).removeClass(errorClass).addClass(validClass);
+ }
}
},
@@ -272,11 +278,11 @@ $.extend($.validator, {
max: $.validator.format("Please enter a value less than or equal to {0}."),
min: $.validator.format("Please enter a value greater than or equal to {0}.")
},
-
+
autoCreateRanges: false,
-
+
prototype: {
-
+
init: function() {
this.labelContainer = $(this.settings.errorLabelContainer);
this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
@@ -287,7 +293,7 @@ $.extend($.validator, {
this.pending = {};
this.invalid = {};
this.reset();
-
+
var groups = (this.groups = {});
$.each(this.settings.groups, function(key, value) {
$.each(value.split(/\s/), function(index, name) {
@@ -298,7 +304,7 @@ $.extend($.validator, {
$.each(rules, function(key, value) {
rules[key] = $.validator.normalizeRule(value);
});
-
+
function delegate(event) {
var validator = $.data(this[0].form, "validator"),
eventType = "on" + event.type.replace(/^validate/, "");
@@ -322,15 +328,15 @@ $.extend($.validator, {
this.showErrors();
return this.valid();
},
-
+
checkForm: function() {
this.prepareForm();
for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
this.check( elements[i] );
}
- return this.valid();
+ return this.valid();
},
-
+
// http://docs.jquery.com/Plugins/Validation/Validator/element
element: function( element ) {
element = this.clean( element );
@@ -372,7 +378,7 @@ $.extend($.validator, {
? this.settings.showErrors.call( this, this.errorMap, this.errorList )
: this.defaultShowErrors();
},
-
+
// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
resetForm: function() {
if ( $.fn.resetForm )
@@ -382,30 +388,30 @@ $.extend($.validator, {
this.hideErrors();
this.elements().removeClass( this.settings.errorClass );
},
-
+
numberOfInvalids: function() {
return this.objectLength(this.invalid);
},
-
+
objectLength: function( obj ) {
var count = 0;
for ( var i in obj )
count++;
return count;
},
-
+
hideErrors: function() {
this.addWrapper( this.toHide ).hide();
},
-
+
valid: function() {
return this.size() == 0;
},
-
+
size: function() {
return this.errorList.length;
},
-
+
focusInvalid: function() {
if( this.settings.focusInvalid ) {
try {
@@ -419,44 +425,43 @@ $.extend($.validator, {
}
}
},
-
+
findLastActive: function() {
var lastActive = this.lastActive;
return lastActive && $.grep(this.errorList, function(n) {
return n.element.name == lastActive.name;
}).length == 1 && lastActive;
},
-
+
elements: function() {
var validator = this,
rulesCache = {};
-
+
// select all valid inputs inside the form (no submit or reset buttons)
- // workaround $Query([]).add until http://dev.jquery.com/ticket/2114 is solved
- return $([]).add(this.currentForm.elements)
- .filter(":input")
+ return $(this.currentForm)
+ .find("input, select, textarea")
.not(":submit, :reset, :image, [disabled]")
.not( this.settings.ignore )
.filter(function() {
!this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
-
+
// select only the first element for each name, and only those with rules specified
if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
return false;
-
+
rulesCache[this.name] = true;
return true;
});
},
-
+
clean: function( selector ) {
return $( selector )[0];
},
-
+
errors: function() {
return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
},
-
+
reset: function() {
this.successList = [];
this.errorList = [];
@@ -465,32 +470,32 @@ $.extend($.validator, {
this.toHide = $([]);
this.currentElements = $([]);
},
-
+
prepareForm: function() {
this.reset();
this.toHide = this.errors().add( this.containers );
},
-
+
prepareElement: function( element ) {
this.reset();
this.toHide = this.errorsFor(element);
},
-
+
check: function( element ) {
element = this.clean( element );
-
+
// if radio/checkbox, validate first element in group instead
if (this.checkable(element)) {
- element = this.findByName( element.name )[0];
+ element = this.findByName( element.name ).not(this.settings.ignore)[0];
}
-
+
var rules = $(element).rules();
var dependencyMismatch = false;
- for( method in rules ) {
+ for (var method in rules ) {
var rule = { method: method, parameters: rules[method] };
try {
var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
-
+
// if a method indicates that the field is optional and therefore valid,
// don't mark it as valid when there are no other rules
if ( result == "dependency-mismatch" ) {
@@ -498,12 +503,12 @@ $.extend($.validator, {
continue;
}
dependencyMismatch = false;
-
+
if ( result == "pending" ) {
this.toHide = this.toHide.not( this.errorsFor(element) );
return;
}
-
+
if( !result ) {
this.formatAndAdd( element, rule );
return false;
@@ -520,20 +525,20 @@ $.extend($.validator, {
this.successList.push(element);
return true;
},
-
+
// return the custom message for the given element and validation method
// specified in the element's "messages" metadata
customMetaMessage: function(element, method) {
if (!$.metadata)
return;
-
+
var meta = this.settings.meta
? $(element).metadata()[this.settings.meta]
: $(element).metadata();
-
+
return meta && meta.messages && meta.messages[method];
},
-
+
// return the custom message for the given element name and validation method
customMessage: function( name, method ) {
var m = this.settings.messages[name];
@@ -541,7 +546,7 @@ $.extend($.validator, {
? m
: m[method]);
},
-
+
// return the first defined argument, allowing empty strings
findDefined: function() {
for(var i = 0; i < arguments.length; i++) {
@@ -550,7 +555,7 @@ $.extend($.validator, {
}
return undefined;
},
-
+
defaultMessage: function( element, method) {
return this.findDefined(
this.customMessage( element.name, method ),
@@ -561,7 +566,7 @@ $.extend($.validator, {
"<strong>Warning: No message defined for " + element.name + "</strong>"
);
},
-
+
formatAndAdd: function( element, rule ) {
var message = this.defaultMessage( element, rule.method ),
theregex = /\$?\{(\d+)\}/g;
@@ -569,22 +574,22 @@ $.extend($.validator, {
message = message.call(this, rule.parameters, element);
} else if (theregex.test(message)) {
message = jQuery.format(message.replace(theregex, '{$1}'), rule.parameters);
- }
+ }
this.errorList.push({
message: message,
element: element
});
-
+
this.errorMap[element.name] = message;
this.submitted[element.name] = message;
},
-
+
addWrapper: function(toToggle) {
if ( this.settings.wrapper )
toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
return toToggle;
},
-
+
defaultShowErrors: function() {
for ( var i = 0; this.errorList[i]; i++ ) {
var error = this.errorList[i];
@@ -608,23 +613,23 @@ $.extend($.validator, {
this.hideErrors();
this.addWrapper( this.toShow ).show();
},
-
+
validElements: function() {
return this.currentElements.not(this.invalidElements());
},
-
+
invalidElements: function() {
return $(this.errorList).map(function() {
return this.element;
});
},
-
+
showLabel: function(element, message) {
var label = this.errorsFor( element );
if ( label.length ) {
// refresh error/success class
label.removeClass().addClass( this.settings.errorClass );
-
+
// check if we have a generated label, replace the message then
label.attr("generated") && label.html(message);
} else {
@@ -651,14 +656,14 @@ $.extend($.validator, {
}
this.toShow = this.toShow.add(label);
},
-
+
errorsFor: function(element) {
var name = this.idOrName(element);
return this.errors().filter(function() {
return $(this).attr('for') == name;
});
},
-
+
idOrName: function(element) {
return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
},
@@ -666,7 +671,7 @@ $.extend($.validator, {
checkable: function( element ) {
return /radio|checkbox/i.test(element.type);
},
-
+
findByName: function( name ) {
// select by name and filter by form for performance over form.find("[name=...]")
var form = this.currentForm;
@@ -674,7 +679,7 @@ $.extend($.validator, {
return element.form == form && element.name == name && element || null;
});
},
-
+
getLength: function(value, element) {
switch( element.nodeName.toLowerCase() ) {
case 'select':
@@ -685,13 +690,13 @@ $.extend($.validator, {
}
return value.length;
},
-
+
depend: function(param, element) {
return this.dependTypes[typeof param]
? this.dependTypes[typeof param](param, element)
: true;
},
-
+
dependTypes: {
"boolean": function(param, element) {
return param;
@@ -703,18 +708,18 @@ $.extend($.validator, {
return param(element);
}
},
-
+
optional: function(element) {
return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
},
-
+
startRequest: function(element) {
if (!this.pending[element.name]) {
this.pendingRequest++;
this.pending[element.name] = true;
}
},
-
+
stopRequest: function(element, valid) {
this.pendingRequest--;
// sometimes synchronization fails, make sure pendingRequest is never < 0
@@ -729,7 +734,7 @@ $.extend($.validator, {
this.formSubmitted = false;
}
},
-
+
previousValue: function(element) {
return $.data(element, "previousValue") || $.data(element, "previousValue", {
old: null,
@@ -737,9 +742,9 @@ $.extend($.validator, {
message: this.defaultMessage( element, "remote" )
});
}
-
+
},
-
+
classRuleSettings: {
required: {required: true},
email: {email: true},
@@ -752,13 +757,13 @@ $.extend($.validator, {
digits: {digits: true},
creditcard: {creditcard: true}
},
-
+
addClassRules: function(className, rules) {
className.constructor == String ?
this.classRuleSettings[className] = rules :
$.extend(this.classRuleSettings, className);
},
-
+
classRules: function(element) {
var rules = {};
var classes = $(element).attr('class');
@@ -769,35 +774,35 @@ $.extend($.validator, {
});
return rules;
},
-
+
attributeRules: function(element) {
var rules = {};
var $element = $(element);
-
- for (method in $.validator.methods) {
+
+ for (var method in $.validator.methods) {
var value = $element.attr(method);
if (value) {
rules[method] = value;
}
}
-
+
// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
delete rules.maxlength;
}
-
+
return rules;
},
-
+
metadataRules: function(element) {
if (!$.metadata) return {};
-
+
var meta = $.data(element.form, 'validator').settings.meta;
return meta ?
$(element).metadata()[meta] :
$(element).metadata();
},
-
+
staticRules: function(element) {
var rules = {};
var validator = $.data(element.form, 'validator');
@@ -806,7 +811,7 @@ $.extend($.validator, {
}
return rules;
},
-
+
normalizeRules: function(rules, element) {
// handle dependency check
$.each(rules, function(prop, val) {
@@ -832,12 +837,12 @@ $.extend($.validator, {
}
}
});
-
+
// evaluate parameters
$.each(rules, function(rule, parameter) {
rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
});
-
+
// clean number parameters
$.each(['minlength', 'maxlength', 'min', 'max'], function() {
if (rules[this]) {
@@ -849,7 +854,7 @@ $.extend($.validator, {
rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
}
});
-
+
if ($.validator.autoCreateRanges) {
// auto-create ranges
if (rules.min && rules.max) {
@@ -863,15 +868,15 @@ $.extend($.validator, {
delete rules.maxlength;
}
}
-
+
// To support custom messages in metadata ignore rule methods titled "messages"
if (rules.messages) {
delete rules.messages;
}
-
+
return rules;
},
-
+
// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
normalizeRule: function(data) {
if( typeof data == "string" ) {
@@ -883,7 +888,7 @@ $.extend($.validator, {
}
return data;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Validator/addMethod
addMethod: function(name, method, message) {
$.validator.methods[name] = method;
@@ -912,121 +917,123 @@ $.extend($.validator, {
return $.trim(value).length > 0;
}
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/remote
remote: function(value, element, param) {
if ( this.optional(element) )
return "dependency-mismatch";
-
+
var previous = this.previousValue(element);
if (!this.settings.messages[element.name] )
this.settings.messages[element.name] = {};
previous.originalMessage = this.settings.messages[element.name].remote;
this.settings.messages[element.name].remote = previous.message;
-
- param = typeof param == "string" && {url:param} || param;
-
- if ( previous.old !== value ) {
- previous.old = value;
- var validator = this;
- this.startRequest(element);
- var data = {};
- data[element.name] = value;
- $.ajax($.extend(true, {
- url: param,
- mode: "abort",
- port: "validate" + element.name,
- dataType: "json",
- data: data,
- success: function(response) {
- validator.settings.messages[element.name].remote = previous.originalMessage;
- var valid = response === true;
- if ( valid ) {
- var submitted = validator.formSubmitted;
- validator.prepareElement(element);
- validator.formSubmitted = submitted;
- validator.successList.push(element);
- validator.showErrors();
- } else {
- var errors = {};
- var message = (previous.message = response || validator.defaultMessage( element, "remote" ));
- errors[element.name] = $.isFunction(message) ? message(value) : message;
- validator.showErrors(errors);
- }
- previous.valid = valid;
- validator.stopRequest(element, valid);
- }
- }, param));
- return "pending";
- } else if( this.pending[element.name] ) {
+
+ param = typeof param == "string" && {url:param} || param;
+
+ if ( this.pending[element.name] ) {
return "pending";
}
- return previous.valid;
+ if ( previous.old === value ) {
+ return previous.valid;
+ }
+
+ previous.old = value;
+ var validator = this;
+ this.startRequest(element);
+ var data = {};
+ data[element.name] = value;
+ $.ajax($.extend(true, {
+ url: param,
+ mode: "abort",
+ port: "validate" + element.name,
+ dataType: "json",
+ data: data,
+ success: function(response) {
+ validator.settings.messages[element.name].remote = previous.originalMessage;
+ var valid = response === true;
+ if ( valid ) {
+ var submitted = validator.formSubmitted;
+ validator.prepareElement(element);
+ validator.formSubmitted = submitted;
+ validator.successList.push(element);
+ validator.showErrors();
+ } else {
+ var errors = {};
+ var message = response || validator.defaultMessage( element, "remote" );
+ errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
+ validator.showErrors(errors);
+ }
+ previous.valid = valid;
+ validator.stopRequest(element, valid);
+ }
+ }, param));
+ return "pending";
},
// http://docs.jquery.com/Plugins/Validation/Methods/minlength
minlength: function(value, element, param) {
return this.optional(element) || this.getLength($.trim(value), element) >= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
maxlength: function(value, element, param) {
return this.optional(element) || this.getLength($.trim(value), element) <= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
rangelength: function(value, element, param) {
var length = this.getLength($.trim(value), element);
return this.optional(element) || ( length >= param[0] && length <= param[1] );
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/min
min: function( value, element, param ) {
return this.optional(element) || value >= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/max
max: function( value, element, param ) {
return this.optional(element) || value <= param;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/range
range: function( value, element, param ) {
return this.optional(element) || ( value >= param[0] && value <= param[1] );
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/email
email: function(value, element) {
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
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);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/url
url: function(value, element) {
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
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);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/date
date: function(value, element) {
return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
dateISO: function(value, element) {
return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/number
number: function(value, element) {
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/digits
digits: function(value, element) {
return this.optional(element) || /^\d+$/.test(value);
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
// based on http://en.wikipedia.org/wiki/Luhn
creditcard: function(value, element) {
@@ -1054,13 +1061,13 @@ $.extend($.validator, {
return (nCheck % 10) == 0;
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/accept
accept: function(value, element, param) {
param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
- return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
+ return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
},
-
+
// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
equalTo: function(value, element, param) {
// bind to the blur event of the target in order to revalidate whenever the target field is updated
@@ -1070,9 +1077,9 @@ $.extend($.validator, {
});
return value == target.val();
}
-
+
}
-
+
});
// deprecated, use $.validator.format instead
@@ -1082,36 +1089,49 @@ $.format = $.validator.format;
// ajax mode: abort
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
-// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
+// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
;(function($) {
- var ajax = $.ajax;
var pendingRequests = {};
- $.ajax = function(settings) {
- // create settings for compatibility with ajaxSetup
- settings = $.extend(settings, $.extend({}, $.ajaxSettings, settings));
- var port = settings.port;
- if (settings.mode == "abort") {
- if ( pendingRequests[port] ) {
- pendingRequests[port].abort();
+ // Use a prefilter if available (1.5+)
+ if ( $.ajaxPrefilter ) {
+ $.ajaxPrefilter(function(settings, _, xhr) {
+ var port = settings.port;
+ if (settings.mode == "abort") {
+ if ( pendingRequests[port] ) {
+ pendingRequests[port].abort();
+ }
+ pendingRequests[port] = xhr;
}
- return (pendingRequests[port] = ajax.apply(this, arguments));
- }
- return ajax.apply(this, arguments);
- };
+ });
+ } else {
+ // Proxy ajax
+ var ajax = $.ajax;
+ $.ajax = function(settings) {
+ var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
+ port = ( "port" in settings ? settings : $.ajaxSettings ).port;
+ if (mode == "abort") {
+ if ( pendingRequests[port] ) {
+ pendingRequests[port].abort();
+ }
+ return (pendingRequests[port] = ajax.apply(this, arguments));
+ }
+ return ajax.apply(this, arguments);
+ };
+ }
})(jQuery);
// provides cross-browser focusin and focusout events
// IE has native support, in other browsers, use event caputuring (neither bubbles)
// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
-// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
+// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
;(function($) {
// only implement if not provided by jQuery core (since 1.4)
// TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
$.each({
focus: 'focusin',
- blur: 'focusout'
+ blur: 'focusout'
}, function( original, fix ){
$.event.special[fix] = {
setup:function() {