This repository has been archived by the owner on Dec 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
tFormer.min.js
47 lines (46 loc) · 22.8 KB
/
tFormer.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* tFormer v0.5.4*/
(function(w,x,p){var z=["button","submit"],A="text password select-one checkbox textarea range number email hidden file date datetime-local search tel time url month week".split(" "),B=["checkbox","select-one","select","file"],C="number date datetime-local time month week range".split(" "),D="timeout requestTimeout request validClass errorClass disabledClass processingClass rules validateEvent before onerror onvalid own eventBefore eventError eventValid".split(" "),q={errorClass:"error",processingClass:"processing",
disabledClass:"disabled",validClass:"valid",eventBefore:"tFormer:before",eventError:"tFormer:error",eventValid:"tFormer:valid",timeout:0,requestTimeout:2E3,validateEvent:"input keyup",fields:{},buttons:{},submitButtonControl:!0,submitButton:null},r=function(a,b){if(!(this instanceof r))return new r(a,b);var c=a,c=this.form=(c="string"===typeof c?x.forms[c]:c)&&"FORM"===c.nodeName?c:null;if(null===this.form)return null;if(!c?0:c.getAttribute("empowered")){a:{for(var d=0,e=this.cache.length;d<e;d++)if(this.cache[d].form==
c){c=this.cache[d];break a}c=null}if(c)return c.set(b),c}else s(c,"empowered",1),s(c,"novalidate","novalidate");this.config=this.config||k(q);this.set(b);this.init();this.cache.push(this);return this},f=r.prototype;f.cache=[];f.init=function(){if(this.inited)return this;this.fields={};this.buttons={};this.inited=!0;this.invalid=this.holded=this.locked=0;this.valid=!0;this.fields={};this.buttons={};this.xhr={};this.xhrTimeout={};var a=this.get("submitButton");a&&(this.buttons.submit=new t(this,a));
for(var a=0,b=this.form.length;a<b;a++){var c=this.form[a],d=c.type,e="button"!==d?!c?null:c.getAttribute("name"):u(c,"check");-1!==l(A,d)&&e&&(this.fields[e]=new y(this,c));-1!==l(z,d)&&(e="submit"==d?d:e)&&!("submit"==e&&this.button[e])&&(this.buttons[e]=new t(this,c))}var g=this;this.form.onsubmit=function(a){a=a||w.event;var b=g.button("submit"),c=g.get("submitButtonControl"),d="function"==typeof g.get("submit"),e=b.get("processingClass"),f=g.valid&&d;if(e&&b.hasClass(e)||g.locked)return m(a),
!1;f&&m(a);g.valid&&(c&&b.processing(!0),d&&g.execute(g.form,"submit",[a,g]));if(f)return!1;try{if(!g.valid&&!g.validate({no_timeout:!0}))return m(a),b.processing(!1),!1;if(d)return m(a),g.execute(g.form,"submit",[a,g]),!1;g.form.submit();return!0}catch(h){}};this.validate({highlight:!1,fire_event:!1,silence:!0});return this.submitControl()};f.destroy=function(){for(var a in this.fields)this.fields[a].destroy();for(a in this.buttons)this.buttons[a].destroy();this.inited=!1;return this};f.drop=function(){var a=
this.fields,b=this.buttons;this.destroy();this.set(k(q));for(var c in a)a[c].drop();for(c in b)b[c].drop();this.locked=0;return this.init()};f.validate=function(a){var b=this.fields,c=0,d;for(d in b)c+=b[d].validate(a||{})?0:1;this.invalid=c;this.valid=0===c;return 0===c};f.toObject=function(){for(var a=this.form,b={},c=0,d=a.length;c<d;c++){var e=a[c],g=!e?null:e.getAttribute("name");"checkbox"==e.type?b[g]=e.checked:"radio"==e.type?(b[g]||(b[g]=""),e.checked&&(b[g]=e.value)):"submit"!==e.type&&
"button"!==e.type&&(b[g]=e.value)}return b};f.get=function(a){return this.config[a]};f.set=function(a){var b=this.inited;b&&this.destroy();this.config=v(this.config,a);b&&this.init();return this};f.field=function(a){return this.fields[a]};f.button=function(a){return this.buttons[a]};f.submit=function(a){if(!this.config)return this;"function"==typeof a&&(this.config.submit=a);return this};f.submitControl=function(a){var b=this.button("submit"),c=this.get("submitButtonControl");this.valid=0===this.invalid&&
0===this.holded&&0===this.locked;a=!1===a||!0===a?a:this.valid;if(b&&c)b[a?"enable":"disable"]();return this};f.submitDisable=function(){return this.submitControl(!1)};f.submitEnable=function(){return this.submitControl(!0)};f.processing=function(a){var b=this.button("submit");b&&b.processing(a);return this};f.lock=function(a){this.locked+=a||1;return this.submitControl(!1)};f.unlock=function(a){this.locked-=a||1;return this.submitControl()};f.execute=function(a,b,c){"string"==typeof b&&(b=this.get(b));
return"function"==typeof b?b.apply(a,c||[]):null};w.tFormer=r;var f=function(){},h=f.prototype;h.destroy=function(){for(var a=this.el,b=this.events,c=0,d=b.length;c<d;c++)this.off(b[0][0],b[0][1]);this.removeClass(this.get("errorClass"));this.removeClass(this.get("desabledClass"));this.removeClass(this.get("processignClass"));u(a,"holded",null);u(a,"error",null);this.timer&&clearTimeout(this.timer);this.xhr&&this.xhr.abort();this.xhrTimeout&&clearTimeout(this.xhrTimeout);this.valid||(this.parent.invalid=
0!==this.parent.invalid?this.parent.invalid-1:0);this.parent.submitControl();this.inited=!1;return this};h.drop=function(){return this.set(k(q))};h.set=function(a){var b=!this.el?null:this.el.getAttribute("name"),c=this.inited;c&&this.destroy();for(var d in a)if(~l(D,d)){var e=d,g=a[d];this.config[e]=g;this.parent.config.fields[b]||(this.parent.config.fields[b]=k(q));this.parent.config.fields[b][e]=g}c&&this.init();return this};h.get=function(a){return this.config[a]};h.on=function(a,b,c){c=c||this.el;
a=a.split(" ");for(var d=0,e=a.length;d<e;d++)c.addEventListener?c.addEventListener(a[d],b,!1):c.attachEvent?c.attachEvent("on"+a[d],b):c[a[d]]=b,this.events.push([a[d],b]);return this};h.off=function(a,b){var c=this.el,d=this.events;a=a.split(" ");if(!b){for(var c=0,e=d.length;c<e;c++)-1!==l(a,d[c][0])&&d.splice(c,1);return this}c.removeEventListener?c.removeEventListener(a,b,!1):c.detachEvent?c.detachEvent("on"+a,b):c[a]=null;c=0;for(e=d.length;c<e;c++)if(-1!==l(a,d[c][0])&&d[c][1]==b){d.splice(c,
1);break}return this};h.trigger=function(a){var b=this.el,c;if(!this.silence){try{return c=x.createEvent("HTMLEvents"),c.initEvent(a,!0,!0),!b.dispatchEvent(c)}catch(d){try{return b.fireEvent("on"+a)}catch(e){}}return this}};h.addClass=function(a){var b=this.el,c=b.className.split(" ")||[];if(-1===l(c,a)){c.push(a);a=c;if("[object Array]"==Object.prototype.toString.call(a))for(var c=[],d=0,e=a.length;d<e;d++)""!==a[d]&&c.push(a[d]);else c=void 0;b.className=0<c.length?c.join(" "):""}return this};
h.removeClass=function(a){var b=this.el;this.hasClass(a)&&(b.className=b.className.replace(RegExp("(\\s|^)"+a+"(\\s|$)")," "));return this};h.hasClass=function(a){return!!~(" "+this.el.className+" ").indexOf(" "+a+" ")};h.data=function(a,b){var c=u(this.el,a,b);return b===p?c:this};h.attr=function(a,b){var c=this.el;switch(b){case null:c&&c.removeAttribute(a);break;case p:return!c?null:c.getAttribute(a);default:s(c,a,b)}};h.processing=function(a){var b=this.get("processingClass"),c=this.hasClass(b);
!1===a||null===a&&c?this.removeClass(b):(!0===a||null===a&&c)&&this.addClass(b);return this};var h=function(a,b){var c=function(){};c.prototype=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.superclass=b.prototype},y=function(a,b){var c=b.type,d,e,g,f,h=[];this.parent=a;this.el=b;this.config={};this.events=[];d=this.attr("name");e=null!==this.attr("required");g=this.attr("min");f=this.attr("max");d=a.config.fields?a.config.fields[d]:{};"string"==typeof d&&(d={rules:d});this.set(v(k(a.config),
k(d)));this.config.rules=this.config.rules||this.data("rules");e&&h.push("*");"email"==c&&h.push("@");"url"==c&&h.push("url");"number"==c&&(h.push("num"),null!==g&&h.push(">"+g),null!==f&&h.push("<"+f));0<h.length&&(this.config.rules=_v_("").rules(this.config.rules||this.data("rules")).addRule(h.join(" ")).rule);this.value=b.value;this.validationStart="v_start";this.validationSuccess="v_success";this.validationError="v_error";this.fire_event=this.highlight=!0;this.silence=!1;return this.init()};h(y,
f);var j=y.prototype;j.init=function(){var a=this,b=a.el.value,c=a.attr("type"),d="checkbox"==c;if(a.inited)return a;a.events=[];a.valid=!0;a.holded=!1;a.value=b;b=a.get("validateEvent");~l(C,c)&&-1===b.indexOf("change")&&(b=b.split(" "),b.push("change"),b=b.join(" "));~l(B,c)&&(b="change");a.set({validateEvent:b});a.on(b,function(){if(a.get("rules")&&(a.value!=a.el.value||d)){a.value=a.el.value;a.removeClass(a.get("errorClass"));a.removeClass(a.get("processingClass"));a.parent.invalid+=a.valid?1:
0;a.valid=!1;a.removeClass(a.get("errorClass"));a.parent.submitControl();var b=a.get("timeout");0<a.get("timeout")?(a.timer&&clearTimeout(a.timer),a.timer=setTimeout(function(){a.validate()},b)):a.validate()}});if(a.hasRules("=#")&&(c=_v_().rules(a.config.rules).parsedRules["=#"],c=x.getElementById(c)))a.on("input keyup",function(){a.validate({highlight:!!a.value})},c);if(!~b.indexOf("blur")&&"change"!==b)a.on("blur",function(){a.get("rules")&&(a.timer&&clearTimeout(a.timer),(!a.valid||!a.hasRules("request"))&&
a.validate({no_timeout:!0}))});a.validate({silence:!0});a.inited=!0;return a};j.setRules=function(a,b){this.set({rules:a},b);this.validate(b);return this};j.hasRules=function(a){return _v_().rules(this.get("rules")).hasRule(a)};j.addRules=function(a,b){return this.setRules(_v_().rules(this.get("rules")).addRule(a).rule,b)};j.delRule=function(a,b){return this.setRules(_v_().rules(this.get("rules")).delRule(a).rule,b)};j.error=function(a){this.valid=!a?!0:!1;if(!this.highlight&&!this.valid)return this;
a=this.get("errorClass");this.valid?(this.removeClass(a),this.data("error",null)):(this.addClass(a),this.data("error","1"));return this};j.hold=function(a){var b=this.data("holded");this.holded=a===p?!this.holded:!0===a?!0:!1;this.data("holded",this.holded?1:null);!b&&!0===this.holded?this.parent.holded++:b&&!1===this.holded&&this.parent.holded--;this.parent.submitControl();return this};j.validate=function(a){var b=this.el,c=this.attr("type"),d=!0,e=this.get("own"),g=this.get("request"),f=this.get("rules"),
h=_v_(this.el.value||"").rules(f),c="checkbox"==c,j=h.hasRule("*");if(!f)return d;a=a||{};this.silence=!0===a.silence?!0:!1;this.highlight=!1===a.highlight||!0===a.silence?!1:!0;this.fire_event=!1===a.fire_event||!0===a.silence?!1:!0;this.silence||(this.execute("before"),this.trigger(this.get("eventBefore")),this.trigger(this.validationStart));if("function"==typeof e)d=e.call(this.el);else if(c)!b.checked&&j&&(d=!1);else{if(j||0<this.el.value.length)d=h.validate();if(g&&d)return this.requestValidate(a),
this.highlight=!0,null}d?this.__validationSuccess():this.__validationError();this.fire_event=this.highlight=!0;this.silence=!1;return d};j.__validationStart=function(){};j.__validationError=function(){this.trigger(this.get("eventError"));this.parent.invalid+=this.valid?1:0;this.parent.submitControl();this.error(!0);this.execute("onerror")};j.__validationSuccess=function(){this.trigger(this.get("eventValid"));this.parent.invalid-=!this.valid?1:0;this.parent.submitControl();this.error(!1);this.execute("onvalid")};
j.requestValidate=function(a){var b=this,c=b.attr("name"),d=b.el.value,e=b.get("request"),g=b.parent.button(!b.el?null:b.el.getAttribute("name")),f="post"==e.method.toLowerCase()?"POST":"GET",h=e.data||{},j,k=e.url||w.location.href;"GET"==f?(k+=~k.indexOf("?")?"&":"?",k+=c+"="+d):h[c]=d;j=k;var c=a.no_timeout?0:e.timeout||0,l=function(){var a=b.xhr;1==a.readyState&&b.execute(e.start,[a]);if(4==a.readyState&&200==a.status){var c=!0===b.execute(e.end,[a.response])?!0:!1;b["__validation"+(c?"Success":
"Error")]()}if(4==a.readyState||0==a.readystate)b.processing(!1).hold(!1),g&&g.processing(!1)},m=function(){b.processing(!0).hold(!0);g&&g.processing(!0);var a=n.newRequest();b.xhr=a;a.onreadystatechange=l;a.open(f,j,!0);a.setRequestHeader("Accept-Language","en");"POST"==f?(a.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(E(h))):a.send(null)};if(b.xhr&&(0!==b.xhr.readyState||4!==b.xhr.readyState))b.xhr.abort(),b.processing(!1).hold(!1),g&&g.processing(!1);
b.xhrTimeout&&clearTimeout(b.xhrTimeout);b.hold(!1);0<c&&!0!==a.no_timeout?b.xhrTimeout=setTimeout(function(){m()},c):m()};j.execute=function(a,b){if(!this.silence)return"string"==typeof a&&(a=this.get(a)),this.parent.execute(this.el,a,b)};var t=function(a,b){var c=this.attr("type");this.parent=a;this.el=b;this.config={};this.events=[];this.name=c="submit"===c?c:this.data("check");this.set(v(k(a.config),k(a.config.buttons?a.config.buttons[c]:{})));return this.init()};h(t,f);f=t.prototype;f.init=function(){var a=
this,b=a.el,c=a.parent;a.inited&&a.destroy();if("submit"==b.type||b==c.get("submitButton"))a.on("click",function(a){m(a);c.form.onsubmit(a);return!1});else a.on("click",function(){var b=c.field(a.data("check"));b&&b.validate({no_timeout:!0})});this.inited=!0;return this};f.disable=function(){this.addClass(this.get("disabledClass"));return this};f.enable=function(){this.removeClass(this.get("disabledClass"));return this};var v=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},
m=function(a){a.preventDefault?a.preventDefault():event.returnValue=!1},k=function(a){return"[object Array]"==Object.prototype.toString.call(a)?a.slice():v({},a)},l=function(a,b){for(var c=-1,d=a?a.length:0;++c<d;)if(a[c]===b)return c;return-1},u=function(a,b,c){switch(c){case null:a&&a.removeAttribute("data-"+b);break;case p:return!a?null:a.getAttribute("data-"+b);default:s(a,"data-"+b,c)}},s=function(a,b,c){if(!a)return null;a.setAttribute(b,c)},n={_factories:[function(){return new XMLHttpRequest},
function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],_factory:null,newRequest:function(){if(null!==n._factory)return n._factory();for(var a=0;a<n._factories.length;a++)try{var b=n._factories[a],c=b();if(null!==c)return n._factory=b,c}catch(d){}n._factory=function(){throw Error("Object XMLHttpRequest not supported");};n._factory()}},E=function(a){var b=[],c=/%20/g,d;for(d in a){var e=encodeURIComponent(d).replace(c,"+")+"=",e=e+encodeURIComponent(a[d].toString()).replace(c,
"+");b.push(e)}return b.join("&")}})(window,document);
/* _v_ v0.5.0*/
(function(z,s,A){var g=function(a){if(!(this instanceof g))return new g(a);this.value=a||"";this.separator=" ";this.rule="";this.parsedRules=[];return this},j=g.prototype;j.separate=function(a){this.separator=a;this.rules(this.rule);return this};j.rules=function(a){this.rule=a||"";this.parseRules();return this};j.addRule=function(a){var b=this.parsedRules,c=g().rules(a).parsedRules,d;for(d in c)if(a=c[d])if(a&&b.hasOwnProperty(d)){b[d]=m(b[d]);a=m(a);for(var e=0,h=a.length;e<h;e++)-1===r(b[d],a[e])&&
b[d].push(a[e])}else b[d]=a;else b[d]=a;this.rule=v(this.parsedRules,this.separator);return this};j.delRule=function(a){var b=this.parsedRules;a=g().rules(a).parsedRules;for(var c in a){var d=a[c];if(b.hasOwnProperty(c))if(d===A)delete b[c];else{b[c]=m(b[c]);for(var d=m(d),e=0,h=d.length;e<h;e++){var B=r(b[c],d[e]);~B&&b[c].splice(B,1)}0===b[c].length?delete b[c]:1===b[c].length&&(b[c]=b[c][0])}}this.rule=v(this.parsedRules,this.separator);return this};j.hasRule=function(a){a=g().rules(a).parsedRules;
var b=this.parsedRules,c;for(c in a){var d=a[c];if(!d)if(b.hasOwnProperty(c))continue;else return!1;b[c]=m(b[c]);for(var d=m(d),e=0,h=d.length;e<h;e++)if(-1===r(b[c],d[e]))return!1}return!0};j.parseRules=function(){for(var a=this.rule.split(this.separator),b={},c=this.keys,d=0,e=a.length;d<e;d++){var h=a[d],g,j,l=A;if(c[h])g=c[h],j=h;else for(var n=this.keys_order,t=0,p=n.length;t<p;t++){var u=n[t];if(0===h.indexOf(u)){j=u;l=h.replace(u,"");(h=/^\[(.+)\]$/.exec(l))&&(l=h[1].split(","));g=this.keys[j];
break}}g&&(b[j]=l)}this.parsedRules=b;this.rule=v(b,this.separator);return b};j.validate=function(a){a&&this.rules(a);a=this.parsedRules;for(var b in a)try{if(!this.keys[b].call(this,a[b]))return!1}catch(c){return!1}return!0};j.extend=function(a,b){j.keys[a]=b;j.keys_order.push(a);j.keys_order=this.keys_order.sort(function(a,b){return b.length-a.length});return this};j.keys={};j.keys_order=[];z._v_=g;var C={"*":function(){return 0!==this.value.length},a:function(){return/^[a-z]+$/i.test(this.value)},
a1:function(){return/^[a-z0-9]+$/i.test(this.value)},a_:function(){return/^[a-z_-]+$/i.test(this.value)},a1_:function(){return/^[a-z0-9_-]+$/i.test(this.value)},"@":function(){return/^((([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(this.value)},
"@s":function(){for(var a=this.value.split(","),b=0;b<a.length;b++)if(!g(a[b]).validate("@"))return!1;return!0},ip:function(){return/^((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})$/i.test(this.value)},b64:function(){return/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$/.test(this.value)},url:function(){return/^(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(this.value)},
"int":function(){return/^\-?[0-9]+$/.test(this.value)},num:function(){return/^[0-9]+$/.test(this.value)},dec:function(){return/^\-?[0-9]*\.?[0-9]+$/.test(this.value)},nat:function(){return/^[0-9]+$/i.test(this.value)},"l=":function(a){if("number"==typeof a||"string"==typeof a)return this.value.length==a;for(var b in a)if(this.value.length==a[b])return!0;return!1},"l>":function(a){return this.value.length>a},"l>=":function(a){return this.value.length>=a},"l<":function(a){return this.value.length<a},
"l<=":function(a){return this.value.length<=a},"lr=":function(a){return this.value.length>=a[0]&&this.value.length<=a[1]},">":function(a){var b=this.value;return g(b).validate("dec")&&parseFloat(b)>parseFloat(a)},">=":function(a){var b=this.value;return g(b).validate("dec")&&parseFloat(b)>=parseFloat(a)},"<":function(a){var b=this.value;return g(b).validate("dec")&&parseFloat(b)<parseFloat(a)},"<=":function(a){var b=this.value;return g(b).validate("dec")&&parseFloat(b)<=parseFloat(a)},"r=":function(a){var b=
this.value;return g(b).validate("dec")&&parseFloat(b)>=parseFloat(a[0])&&parseFloat(b)<=parseFloat(a[1])},"reg=":function(a){return RegExp(a,"i").test(this.value)},"=":function(a){var b=this.value;if("string"==typeof a||"number"==typeof a)return b==a;for(var c=0,d=a.length;c<d;c++)if(0===a[c].indexOf("#")){var e;e=a[c].replace("#","");e=s.getElementById(e);if(!e)break;if(b==e.value)return!0}else if(b==a[c])return!0;return!1},"=#":function(a){var b=this.value;if("string"==typeof a||"number"==typeof a){a=
a.split(" ");var c=s.getElementById(a);return!c?!1:b==c.value}for(var d=0;d<a.length;d++)if((c=s.getElementById(a[d]))&&b==c.value)return!0;return!1},"!=":function(a){a=q(a)?"["+a.join(",")+"]":a;return!g(this.value).validate("="+a)},"!":function(a){if("string"==typeof a||"number"==typeof a)return-1===this.value.toString().indexOf(a.toString());for(var b in a)if(~this.value.toString().indexOf(a[b].toString()))return!1;return!0},c:function(){return/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/.test(this.value)},
cv:function(){return/^4[0-9]{12}(?:[0-9]{3})?$/.test(this.value)},cm:function(){return/^5[1-5][0-9]{14}$/.test(this.value)},ca:function(){return/^3[47][0-9]{13}$/.test(this.value)},cd:function(){return/^6(?:011|5[0-9]{2})[0-9]{12}$/.test(this.value)},"D=":function(a){return!!D(this.value,a)}},w;for(w in C)g().extend(w,C[w]);var E="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),F="Sun Mon Tue Wed Thu Fri Sat".split(" "),G="January February March April May June July August September October November December".split(" "),
H="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),D=function(a,b){var c=(new Date).getFullYear(),d=0,e=1,h=0,g=0,j=0,l=-1,n=-1,t=-1,p=-1,u=-1,m=-1,r=-1,q="m",s="h",k=1,f="",v=a.replace(/\s+/g," ");b=b.replace(/\s+/g," ");for(var x=0,w=b.length;x<w;x++){var y=b.charAt(x);switch(y){case "Y":f+="(\\d{4})";l=k++;break;case "y":f+="(\\d{2})";l=k++;break;case "M":case "m":f+="(\\d{1,2})";n=k++;q="m";break;case "N":f+="("+G.join("|")+")";n=k++;q="N";break;case "n":f+="("+H.join("|")+")";n=k++;
q="n";break;case "D":case "d":f+="(\\d{1,2})";t=k++;break;case "W":f+="("+E.join("|")+")";k++;break;case "w":f+="("+F.join("|")+")";k++;break;case "H":case "h":f+="(\\d{1,2})";p=k++;s="h";break;case "R":case "r":f+="(\\d{1,2})";p=k++;s="r";break;case "I":case "i":f+="(\\d{1,2})";u=k++;break;case "S":case "s":f+="(\\d{1,2})";m=k++;break;case "A":case "a":f+="(AM|am|PM|pm)";r=k++;break;default:f+="^"==y?b.charAt(++x):y}}k=v.match(RegExp(f));if(!k)return null;-1<l&&(c=parseInt(k[l],10),c=50>c?c+2E3:
100>c?c+1900:c);if(-1<n)switch(q){case "m":d=parseInt(k[n],10)-1;if(11<d)return null;break;case "N":d=parseInt(__monthNumbers[k[n]],10);if(isNaN(d))return null;break;case "n":if(d=parseInt(__shortMonthNumbers[k[n]],10),isNaN(d))return null}if(-1<t){e=parseInt(k[t],10);if(!(l=1>e))l=1==d&&(0===c%4&&0!==c%100||0===c%400)?29:[31,28,31,30,31,30,31,31,30,31,30,31][d],l=e>l;if(l)return null}if(-1<p&&(h=parseInt(k[p],10),"h"==s&&(0===h||12<h)||23<h)||-1<u&&(g=parseInt(k[u],10),59<g)||-1<m&&(j=parseInt(k[m],
10),59<j))return null;if(-1<r&&(p=k[r],("pm"==p||"PM"==p)&&12>h))h+=12;return new Date(c,d,e,h,g,j)},q=function(a){return"[object Array]"==Object.prototype.toString.call(a)},r=function(a,b){for(var c=-1,d=a?a.length:0;++c<d;)if(a[c]===b)return c;return-1};z.__inArray=r;var m=function(a){return!q(a)?[a]:a},v=function(a,b){var c=b=b||" ",d;for(d in a){var e=a[d];if(q(e)){for(var h=[],g=0,j=e.length;g<j;g++)e[g]&&h.push(e[g]);e=h&&1<h.length?h:h[0]}c=e?q(e)?c+(d+"["+e.join(",")+"]"+b):c+(d+e+b):c+(d+
b)}return c=c.substr(b.length,c.length-2*b.length)}})(window,document);