qvem 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/config/initializers/qvem.rb +38 -0
- data/lib/qvem.rb +8 -0
- data/lib/qvem/version.rb +3 -0
- data/vendor/assets/javascripts/jquery.qtip2.min.js +2 -0
- data/vendor/assets/javascripts/jquery.validate.js +1207 -0
- data/vendor/assets/javascripts/rails-qvem.js.coffee +56 -0
- data/vendor/assets/stylesheets/jquery.qtip.css +623 -0
- metadata +105 -0
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Qvem
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'qvem'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install qvem
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Rails.application.config.to_prepare do
|
2
|
+
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
|
3
|
+
att_name = instance.method_name.capitalize.gsub(/_/," ")
|
4
|
+
msges = instance.error_message.uniq.map do |e|
|
5
|
+
"#{att_name} #{e}"
|
6
|
+
end.join(". ")
|
7
|
+
"<span class=\"field_with_error\" data-error=\"#{msges}\" >#{html_tag}</span>".html_safe
|
8
|
+
end
|
9
|
+
|
10
|
+
ActionView::Helpers::InstanceTag.class_eval do
|
11
|
+
def to_input_field_tag(field_type, options = {})
|
12
|
+
options = options.stringify_keys
|
13
|
+
options["size"] = options["maxlength"] || ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"] unless options.key?("size")
|
14
|
+
options = ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS.merge(options)
|
15
|
+
if field_type == "hidden"
|
16
|
+
options.delete("size")
|
17
|
+
end
|
18
|
+
options["type"] ||= field_type
|
19
|
+
options["value"] = options.fetch("value"){ value_before_type_cast(object) } unless field_type == "file"
|
20
|
+
options["value"] &&= ERB::Util.html_escape(options["value"])
|
21
|
+
add_default_name_and_id(options)
|
22
|
+
options.merge!({"data-fieldname"=> @method_name})
|
23
|
+
tag("input", options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_text_area_tag(options = {})
|
27
|
+
options = ActionView::Helpers::InstanceTag::DEFAULT_TEXT_AREA_OPTIONS.merge(options.stringify_keys)
|
28
|
+
add_default_name_and_id(options)
|
29
|
+
if size = options.delete("size")
|
30
|
+
options["cols"], options["rows"] = size.split("x") if size.respond_to?(:split)
|
31
|
+
end
|
32
|
+
options.merge!({"data-fieldname"=> @method_name})
|
33
|
+
content_tag("textarea", options.delete('value') || value_before_type_cast(object), options)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/lib/qvem.rb
ADDED
data/lib/qvem/version.rb
ADDED
@@ -0,0 +1,2 @@
|
|
1
|
+
/*! qTip2 (includes: svg ajax tips modal viewport imagemap ie6 / basic css3) | qtip2.com | Licensed MIT, GPL | Mon Jun 24 2013 07:20:47 */
|
2
|
+
(function(a,b,c){(function(a){"use strict",typeof define=="function"&&define.amd?define(["jquery"],a):jQuery&&!jQuery.fn.qtip&&a(jQuery)})(function(d){function G(c){v={pageX:c.pageX,pageY:c.pageY,type:"mousemove",scrollX:a.pageXOffset||b.body.scrollLeft||b.documentElement.scrollLeft,scrollY:a.pageYOffset||b.body.scrollTop||b.documentElement.scrollTop}}function H(a){var b=function(a){return a===g||"object"!=typeof a},c=function(a){return!d.isFunction(a)&&(!a&&!a.attr||a.length<1||"object"==typeof a&&!a.jquery&&!a.then)};if(!a||"object"!=typeof a)return f;b(a.metadata)&&(a.metadata={type:a.metadata});if("content"in a){if(b(a.content)||a.content.jquery)a.content={text:a.content};c(a.content.text||f)&&(a.content.text=f),"title"in a.content&&(b(a.content.title)&&(a.content.title={text:a.content.title}),c(a.content.title.text||f)&&(a.content.title.text=f))}return"position"in a&&b(a.position)&&(a.position={my:a.position,at:a.position}),"show"in a&&b(a.show)&&(a.show=a.show.jquery?{target:a.show}:{event:a.show}),"hide"in a&&b(a.hide)&&(a.hide=a.hide.jquery?{target:a.hide}:{event:a.hide}),"style"in a&&b(a.style)&&(a.style={classes:a.style}),d.each(u,function(){this.sanitize&&this.sanitize(a)}),a}function I(h,i,j,k){function O(a){var b=0,c,d=i,e=a.split(".");while(d=d[e[b++]])b<e.length&&(c=d);return[c||i,e.pop()]}function P(a){return y.concat("").join(a?"-"+a+" ":" ")}function Q(){var a=i.style.widget,b=J.hasClass(L);J.removeClass(L),L=a?"ui-state-disabled":"qtip-disabled",J.toggleClass(L,b),J.toggleClass("ui-helper-reset "+P(),a).toggleClass(A,i.style.def&&!a),M.content&&M.content.toggleClass(P("content"),a),M.titlebar&&M.titlebar.toggleClass(P("header"),a),M.button&&M.button.toggleClass(w+"-icon",!a)}function R(a){M.title&&(M.titlebar.remove(),M.titlebar=M.title=M.button=g,a!==f&&q.reposition())}function S(){var a=i.content.title.button,b=typeof a=="string",c=b?a:"Close tooltip";M.button&&M.button.remove(),a.jquery?M.button=a:M.button=d("<a />",{"class":"qtip-close "+(i.style.widget?"":w+"-icon"),title:c,"aria-label":c}).prepend(d("<span />",{"class":"ui-icon ui-icon-close",html:"×"})),M.button.appendTo(M.titlebar||J).attr("role","button").click(function(a){return J.hasClass(L)||q.hide(a),f})}function T(){var a=s+"-title";M.titlebar&&R(),M.titlebar=d("<div />",{"class":w+"-titlebar "+(i.style.widget?P("header"):"")}).append(M.title=d("<div />",{id:a,"class":w+"-title","aria-atomic":e})).insertBefore(M.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(a){d(this).toggleClass("ui-state-active ui-state-focus",a.type.substr(-4)==="down")}).delegate(".qtip-close","mouseover mouseout",function(a){d(this).toggleClass("ui-state-hover",a.type==="mouseover")}),i.content.title.button&&S()}function U(a){var b=M.button;if(!q.rendered)return f;a?S():b.remove()}function V(a,b){var c=M.title;if(!q.rendered||!a)return f;d.isFunction(a)&&(a=a.call(h,N.event,q));if(a===f||!a&&a!=="")return R(f);a.jquery&&a.length>0?c.empty().append(a.css({display:"block"})):c.html(a),b!==f&&q.rendered&&J[0].offsetWidth>0&&q.reposition(N.event)}function W(a){a&&d.isFunction(a.done)&&a.done(function(a){X(a,null,f)})}function X(a,b,e){function j(a){function i(c){c&&(delete h[c.src],clearTimeout(q.timers.img[c.src]),d(c).unbind(K)),d.isEmptyObject(h)&&(b!==f&&q.reposition(N.event),a())}var e,h={};if((e=g.find("img[src]:not([height]):not([width])")).length===0)return i();e.each(function(a,b){if(h[b.src]!==c)return;var e=0,f=3;(function g(){if(b.height||b.width||e>f)return i(b);e+=1,q.timers.img[b.src]=setTimeout(g,700)})(),d(b).bind("error"+K+" load"+K,function(){i(this)}),h[b.src]=b})}var g=M.content;return!q.rendered||!a?f:(d.isFunction(a)&&(a=a.call(h,N.event,q)||""),e!==f&&W(i.content.deferred),a.jquery&&a.length>0?g.empty().append(a.css({display:"block"})):g.html(a),q.rendered<0?J.queue("fx",j):(I=0,j(d.noop)),q)}function Y(){function m(a){if(J.hasClass(L))return f;clearTimeout(q.timers.show),clearTimeout(q.timers.hide);var b=function(){q.toggle(e,a)};i.show.delay>0?q.timers.show=setTimeout(b,i.show.delay):b()}function n(a){if(J.hasClass(L)||D||I)return f;var b=d(a.relatedTarget||a.target),e=b.closest(z)[0]===J[0],h=b[0]===g.show[0];clearTimeout(q.timers.show),clearTimeout(q.timers.hide);if(c.target==="mouse"&&e||i.hide.fixed&&/mouse(out|leave|move)/.test(a.type)&&(e||h)){try{a.preventDefault(),a.stopImmediatePropagation()}catch(j){}return}i.hide.delay>0?q.timers.hide=setTimeout(function(){q.hide(a)},i.hide.delay):q.hide(a)}function o(a){if(J.hasClass(L))return f;clearTimeout(q.timers.inactive),q.timers.inactive=setTimeout(function(){q.hide(a)},i.hide.inactive)}function p(a){q.rendered&&J[0].offsetWidth>0&&q.reposition(a)}var c=i.position,g={show:i.show.target,hide:i.hide.target,viewport:d(c.viewport),document:d(b),body:d(b.body),window:d(a)},k={show:d.trim(""+i.show.event).split(" "),hide:d.trim(""+i.hide.event).split(" ")},l=d.browser.msie&&parseInt(d.browser.version,10)===6;J.bind("mouseenter"+K+" mouseleave"+K,function(a){var b=a.type==="mouseenter";b&&q.focus(a),J.toggleClass(C,b)}),/mouse(out|leave)/i.test(i.hide.event)&&i.hide.leave==="window"&&g.window.bind("mouseout"+K+" blur"+K,function(a){!/select|option/.test(a.target.nodeName)&&!a.relatedTarget&&q.hide(a)}),i.hide.fixed?(g.hide=g.hide.add(J),J.bind("mouseover"+K,function(){J.hasClass(L)||clearTimeout(q.timers.hide)})):/mouse(over|enter)/i.test(i.show.event)&&g.hide.bind("mouseleave"+K,function(a){clearTimeout(q.timers.show)}),(""+i.hide.event).indexOf("unfocus")>-1&&c.container.closest("html").bind("mousedown"+K+" touchstart"+K,function(a){var b=d(a.target),c=q.rendered&&!J.hasClass(L)&&J[0].offsetWidth>0,e=b.parents(z).filter(J[0]).length>0;b[0]!==h[0]&&b[0]!==J[0]&&!e&&!h.has(b[0]).length&&!b.attr("disabled")&&q.hide(a)}),"number"==typeof i.hide.inactive&&(g.show.bind("qtip-"+j+"-inactive",o),d.each(t.inactiveEvents,function(a,b){g.hide.add(M.tooltip).bind(b+K+"-inactive",o)})),d.each(k.hide,function(a,b){var c=d.inArray(b,k.show),e=d(g.hide);c>-1&&e.add(g.show).length===e.length||b==="unfocus"?(g.show.bind(b+K,function(a){J[0].offsetWidth>0?n(a):m(a)}),delete k.show[c]):g.hide.bind(b+K,n)}),d.each(k.show,function(a,b){g.show.bind(b+K,m)}),"number"==typeof i.hide.distance&&g.show.add(J).bind("mousemove"+K,function(a){var b=N.origin||{},c=i.hide.distance,d=Math.abs;(d(a.pageX-b.pageX)>=c||d(a.pageY-b.pageY)>=c)&&q.hide(a)}),c.target==="mouse"&&(g.show.bind("mousemove"+K,G),c.adjust.mouse&&(i.hide.event&&(J.bind("mouseleave"+K,function(a){(a.relatedTarget||a.target)!==g.show[0]&&q.hide(a)}),M.target.bind("mouseenter"+K+" mouseleave"+K,function(a){N.onTarget=a.type==="mouseenter"})),g.document.bind("mousemove"+K,function(a){q.rendered&&N.onTarget&&!J.hasClass(L)&&J[0].offsetWidth>0&&q.reposition(a||v)}))),(c.adjust.resize||g.viewport.length)&&(d.event.special.resize?g.viewport:g.window).bind("resize"+K,p),g.window.bind("scroll"+K,p)}function Z(){var c=[i.show.target[0],i.hide.target[0],q.rendered&&M.tooltip[0],i.position.container[0],i.position.viewport[0],i.position.container.closest("html")[0],a,b];q.rendered?d([]).pushStack(d.grep(c,function(a){return typeof a=="object"})).unbind(K):i.show.target.unbind(K+"-create")}var q=this,r=b.body,s=w+"-"+j,D=0,I=0,J=d(),K=".qtip-"+j,L="qtip-disabled",M,N;q.id=j,q.rendered=f,q.destroyed=f,q.elements=M={target:h},q.timers={img:{}},q.options=i,q.checks={},q.plugins={},q.cache=N={event:{},target:d(),disabled:f,attr:k,onTarget:f,lastClass:""},q.checks.builtin={"^id$":function(a,b,c){var g=c===e?t.nextid:c,h=w+"-"+g;g!==f&&g.length>0&&!d("#"+h).length&&(J[0].id=h,M.content[0].id=h+"-content",M.title[0].id=h+"-title")},"^content.text$":function(a,b,c){X(i.content.text)},"^content.deferred$":function(a,b,c){W(i.content.deferred)},"^content.title.text$":function(a,b,c){if(!c)return R();!M.title&&c&&T(),V(c)},"^content.title.button$":function(a,b,c){U(c)},"^position.(my|at)$":function(a,b,c){"string"==typeof c&&(a[b]=new u.Corner(c))},"^position.container$":function(a,b,c){q.rendered&&J.appendTo(c)},"^show.ready$":function(){q.rendered?q.toggle(e):q.render(1)},"^style.classes$":function(a,b,c){J.attr("class",w+" qtip "+c)},"^style.width|height":function(a,b,c){J.css(b,c)},"^style.widget|content.title":Q,"^events.(render|show|move|hide|focus|blur)$":function(a,b,c){J[(d.isFunction(c)?"":"un")+"bind"]("tooltip"+b,c)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){var a=i.position;J.attr("tracking",a.target==="mouse"&&a.adjust.mouse),Z(),Y()}},d.extend(q,{_triggerEvent:function(a,b,c){var e=d.Event("tooltip"+a);return e.originalEvent=(c?d.extend({},c):g)||N.event||g,J.trigger(e,[q].concat(b||[])),!e.isDefaultPrevented()},render:function(a){if(q.rendered)return q;var b=i.content.text,c=i.content.title,g=i.position;return d.attr(h[0],"aria-describedby",s),J=M.tooltip=d("<div/>",{id:s,"class":[w,A,i.style.classes,w+"-pos-"+i.position.my.abbrev()].join(" "),width:i.style.width||"",height:i.style.height||"",tracking:g.target==="mouse"&&g.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":f,"aria-describedby":s+"-content","aria-hidden":e}).toggleClass(L,N.disabled).data("qtip",q).appendTo(i.position.container).append(M.content=d("<div />",{"class":w+"-content",id:s+"-content","aria-atomic":e})),q.rendered=-1,D=1,c.text?(T(),d.isFunction(c.text)||V(c.text,f)):c.button&&S(),(!d.isFunction(b)||b.then)&&X(b,f),q.rendered=e,Q(),d.each(i.events,function(a,b){d.isFunction(b)&&J.bind(a==="toggle"?"tooltipshow tooltiphide":"tooltip"+a,b)}),d.each(u,function(){this.initialize==="render"&&this(q)}),Y(),J.queue("fx",function(b){q._triggerEvent("render"),D=0,(i.show.ready||a)&&q.toggle(e,N.event,f),b()}),q},get:function(a){var b,c;switch(a.toLowerCase()){case"dimensions":b={height:J.outerHeight(f),width:J.outerWidth(f)};break;case"offset":b=u.offset(J,i.position.container);break;default:c=O(a.toLowerCase()),b=c[0][c[1]],b=b.precedance?b.string():b}return b},set:function(a,b){function m(a,b){var c,d,e;for(c in k)for(d in k[c])if(e=(new RegExp(d,"i")).exec(a))b.push(e),k[c][d].apply(q,b)}var c=/^position\.(my|at|adjust|target|container)|style|content|show\.ready/i,h=/^content\.(title|attr)|style/i,j=f,k=q.checks,l;return"string"==typeof a?(l=a,a={},a[l]=b):a=d.extend(e,{},a),d.each(a,function(b,e){var f=O(b.toLowerCase()),g;g=f[0][f[1]],f[0][f[1]]="object"==typeof e&&e.nodeType?d(e):e,a[b]=[f[0],f[1],e,g],j=c.test(b)||j}),H(i),D=1,d.each(a,m),D=0,q.rendered&&J[0].offsetWidth>0&&j&&q.reposition(i.position.target==="mouse"?g:N.event),q},toggle:function(a,c){function t(){a?(d.browser.msie&&J[0].style.removeAttribute("filter"),J.css("overflow",""),"string"==typeof h.autofocus&&d(h.autofocus,J).focus(),h.target.trigger("qtip-"+j+"-inactive")):J.css({display:"",visibility:"",opacity:"",left:"",top:""}),q._triggerEvent(a?"visible":"hidden")}if(c){if(/over|enter/.test(c.type)&&/out|leave/.test(N.event.type)&&i.show.target.add(c.target).length===i.show.target.length&&J.has(c.relatedTarget).length)return q;N.event=d.extend({},c)}if(!q.rendered)return a?q.render(1):q;var g=a?"show":"hide",h=i[g],k=i[a?"hide":"show"],l=i.position,m=i.content,n=J[0].offsetWidth>0,o=a||h.target.length===1,p=!c||h.target.length<2||N.target[0]===c.target,r,s;return(typeof a).search("boolean|number")&&(a=!n),!J.is(":animated")&&n===a&&p?q:q._triggerEvent(g,[90])?(d.attr(J[0],"aria-hidden",!a),a?(N.origin=d.extend({},v),q.focus(c),d.isFunction(m.text)&&X(m.text,f),d.isFunction(m.title.text)&&V(m.title.text,f),!F&&l.target==="mouse"&&l.adjust.mouse&&(d(b).bind("mousemove.qtip",G),F=e),q.reposition(c,arguments[2]),!h.solo||d(z,h.solo).not(J).qtip("hide",d.Event("tooltipsolo"))):(clearTimeout(q.timers.show),delete N.origin,F&&!d(z+'[tracking="true"]:visible',h.solo).not(J).length&&(d(b).unbind("mousemove.qtip"),F=f),q.blur(c)),h.effect===f||o===f?(J[g](),t.call(J)):d.isFunction(h.effect)?(J.stop(1,1),h.effect.call(J,q),J.queue("fx",function(a){t(),a()})):J.fadeTo(90,a?1:0,t),a&&h.target.trigger("qtip-"+j+"-inactive"),q):q},show:function(a){return q.toggle(e,a)},hide:function(a){return q.toggle(f,a)},focus:function(a){if(!q.rendered)return q;var b=d(z),c=parseInt(J[0].style.zIndex,10),e=t.zindex+b.length,f=d.extend({},a),g;return J.hasClass(B)||q._triggerEvent("focus",[e],f)&&(c!==e&&(b.each(function(){this.style.zIndex>c&&(this.style.zIndex=this.style.zIndex-1)}),b.filter("."+B).qtip("blur",f)),J.addClass(B)[0].style.zIndex=e),q},blur:function(a){return J.removeClass(B),q._triggerEvent("blur",[J.css("zIndex")],a),q},reposition:function(c,e){if(!q.rendered||D)return q;D=1;var g=i.position.target,h=i.position,j=h.my,k=h.at,r=h.adjust,s=r.method.split(" "),t=J.outerWidth(f),w=J.outerHeight(f),x=0,y=0,z=J.css("position"),A=h.viewport,B={left:0,top:0},C=h.container,E=J[0].offsetWidth>0,F=c&&c.type==="scroll",G=d(a),H,I;if(d.isArray(g)&&g.length===2)k={x:m,y:l},B={left:g[0],top:g[1]};else if(g==="mouse"&&(c&&c.pageX||N.event.pageX))k={x:m,y:l},c=v&&v.pageX&&(r.mouse||!c||!c.pageX)?{pageX:v.pageX,pageY:v.pageY}:(c&&(c.type==="resize"||c.type==="scroll")?N.event:c&&c.pageX&&c.type==="mousemove"?c:!r.mouse&&N.origin&&N.origin.pageX&&i.show.distance?N.origin:c)||c||N.event||v||{},z!=="static"&&(B=C.offset()),B={left:c.pageX-B.left,top:c.pageY-B.top},r.mouse&&F&&(B.left-=v.scrollX-G.scrollLeft(),B.top-=v.scrollY-G.scrollTop());else{g==="event"&&c&&c.target&&c.type!=="scroll"&&c.type!=="resize"?N.target=d(c.target):g!=="event"&&(N.target=d(g.jquery?g:M.target)),g=N.target,g=d(g).eq(0);if(g.length===0)return q;g[0]===b||g[0]===a?(x=u.iOS?a.innerWidth:g.width(),y=u.iOS?a.innerHeight:g.height(),g[0]===a&&(B={top:(A||g).scrollTop(),left:(A||g).scrollLeft()})):u.imagemap&&g.is("area")?H=u.imagemap(q,g,k,u.viewport?s:f):u.svg&&g[0].ownerSVGElement?H=u.svg(q,g,k,u.viewport?s:f):(x=g.outerWidth(f),y=g.outerHeight(f),B=u.offset(g,C)),H&&(x=H.width,y=H.height,I=H.offset,B=H.position);if(u.iOS>3.1&&u.iOS<4.1||u.iOS>=4.3&&u.iOS<4.33||!u.iOS&&z==="fixed")B.left-=G.scrollLeft(),B.top-=G.scrollTop();B.left+=k.x===o?x:k.x===p?x/2:0,B.top+=k.y===n?y:k.y===p?y/2:0}return B.left+=r.x+(j.x===o?-t:j.x===p?-t/2:0),B.top+=r.y+(j.y===n?-w:j.y===p?-w/2:0),u.viewport?(B.adjusted=u.viewport(q,B,h,x,y,t,w),I&&B.adjusted.left&&(B.left+=I.left),I&&B.adjusted.top&&(B.top+=I.top)):B.adjusted={left:0,top:0},q._triggerEvent("move",[B,A.elem||A],c)?(delete B.adjusted,e===f||!E||isNaN(B.left)||isNaN(B.top)||g==="mouse"||!d.isFunction(h.effect)?J.css(B):d.isFunction(h.effect)&&(h.effect.call(J,q,d.extend({},B)),J.queue(function(a){d(this).css({opacity:"",height:""}),d.browser.msie&&this.style.removeAttribute("filter"),a()})),D=0,q):q},disable:function(a){return"boolean"!=typeof a&&(a=!J.hasClass(L)&&!N.disabled),q.rendered?(J.toggleClass(L,a),d.attr(J[0],"aria-disabled",a)):N.disabled=!!a,q},enable:function(){return q.disable(f)},destroy:function(){var a=h[0],b=d.attr(a,E),c=h.data("qtip");q.destroyed=e,q.rendered&&(J.stop(1,0).remove(),d.each(q.plugins,function(){this.destroy&&this.destroy()})),clearTimeout(q.timers.show),clearTimeout(q.timers.hide),Z();if(!c||q===c)d.removeData(a,"qtip"),i.suppress&&b&&(d.attr(a,"title",b),h.removeAttr(E)),h.removeAttr("aria-describedby");return h.unbind(".qtip-"+j),delete x[q.id],h}})}function J(a,c){var h,i,j,k,l,m=d(this),n=d(b.body),o=this===b?n:m,p=m.metadata?m.metadata(c.metadata):g,q=c.metadata.type==="html5"&&p?p[c.metadata.name]:g,r=m.data(c.metadata.name||"qtipopts");try{r=typeof r=="string"?d.parseJSON(r):r}catch(s){}k=d.extend(e,{},t.defaults,c,typeof r=="object"?H(r):g,H(q||p)),i=k.position,k.id=a;if("boolean"==typeof k.content.text){j=m.attr(k.content.attr);if(k.content.attr!==f&&j)k.content.text=j;else return f}i.container.length||(i.container=n),i.target===f&&(i.target=o),k.show.target===f&&(k.show.target=o),k.show.solo===e&&(k.show.solo=i.container.closest("body")),k.hide.target===f&&(k.hide.target=o),k.position.viewport===e&&(k.position.viewport=i.container),i.container=i.container.eq(0),i.at=new u.Corner(i.at),i.my=new u.Corner(i.my);if(d.data(this,"qtip"))if(k.overwrite)m.qtip("destroy");else if(k.overwrite===f)return f;return k.suppress&&(l=d.attr(this,"title"))&&d(this).removeAttr("title").attr(E,l).attr("title",""),h=new I(m,k,a,!!j),d.data(this,"qtip",h),m.bind("remove.qtip-"+a+" removeqtip.qtip-"+a,function(){h.destroy()}),h}function K(a){var b=this,c=a.elements.tooltip,g=a.options.content.ajax,h=t.defaults.content.ajax,i=".qtip-ajax",j=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,k=e,l=f,m;a.checks.ajax={"^content.ajax":function(a,d,e){d==="ajax"&&(g=e),d==="once"?b.init():g&&g.url?b.load():c.unbind(i)}},d.extend(b,{init:function(){return g&&g.url&&c.unbind(i)[g.once?"one":"bind"]("tooltipshow"+i,b.load),b},load:function(c){function r(){var b;if(a.destroyed)return;k=f,p&&(l=e,a.show(c.originalEvent)),(b=h.complete||g.complete)&&d.isFunction(b)&&b.apply(g.context||a,arguments)}function s(b,c,e){var f;if(a.destroyed)return;o&&"string"==typeof b&&(b=d("<div/>").append(b.replace(j,"")).find(o)),(f=h.success||g.success)&&d.isFunction(f)?f.call(g.context||a,b,c,e):a.set("content.text",b)}function t(b,c,d){if(a.destroyed||b.status===0)return;a.set("content.text",c+": "+d)}if(l){l=f;return}var i=g.url.lastIndexOf(" "),n=g.url,o,p=!g.loading&&k;if(p)try{c.preventDefault()}catch(q){}else if(c&&c.isDefaultPrevented())return b;m&&m.abort&&m.abort(),i>-1&&(o=n.substr(i),n=n.substr(0,i)),m=d.ajax(d.extend({error:h.error||t,context:a},g,{url:n,success:s,complete:r}))},destroy:function(){m&&m.abort&&m.abort(),a.destroyed=e}}),b.init()}function L(a,b,c){var d=Math.ceil(b/2),e=Math.ceil(c/2),f={bottomright:[[0,0],[b,c],[b,0]],bottomleft:[[0,0],[b,0],[0,c]],topright:[[0,c],[b,0],[b,c]],topleft:[[0,0],[0,c],[b,c]],topcenter:[[0,c],[d,0],[b,c]],bottomcenter:[[0,0],[b,0],[d,c]],rightcenter:[[0,0],[b,e],[0,c]],leftcenter:[[b,0],[b,c],[0,e]]};return f.lefttop=f.bottomright,f.righttop=f.bottomleft,f.leftbottom=f.topright,f.rightbottom=f.topleft,f[a.string()]}function M(a,b){function D(a){var b=v.is(":visible");v.show(),a(),v.toggle(b)}function E(){x.width=r.height,x.height=r.width}function F(){x.width=r.width,x.height=r.height}function G(b,d,g,j){if(!t.tip)return;var k=q.corner.clone(),u=g.adjusted,v=a.options.position.adjust.method.split(" "),x=v[0],y=v[1]||v[0],z={left:f,top:f,x:0,y:0},A,B={},C;q.corner.fixed!==e&&(x===s&&k.precedance===h&&u.left&&k.y!==p?k.precedance=k.precedance===h?i:h:x!==s&&u.left&&(k.x=k.x===p?u.left>0?m:o:k.x===m?o:m),y===s&&k.precedance===i&&u.top&&k.x!==p?k.precedance=k.precedance===i?h:i:y!==s&&u.top&&(k.y=k.y===p?u.top>0?l:n:k.y===l?n:l),k.string()!==w.corner.string()&&(w.top!==u.top||w.left!==u.left)&&q.update(k,f)),A=q.position(k,u),A[k.x]+=I(k,k.x),A[k.y]+=I(k,k.y),A.right!==c&&(A.left=-A.right),A.bottom!==c&&(A.top=-A.bottom),A.user=Math.max(0,r.offset);if(z.left=x===s&&!!u.left)k.x===p?B["margin-left"]=z.x=A["margin-left"]:(C=A.right!==c?[u.left,-A.left]:[-u.left,A.left],(z.x=Math.max(C[0],C[1]))>C[0]&&(g.left-=u.left,z.left=f),B[A.right!==c?o:m]=z.x);if(z.top=y===s&&!!u.top)k.y===p?B["margin-top"]=z.y=A["margin-top"]:(C=A.bottom!==c?[u.top,-A.top]:[-u.top,A.top],(z.y=Math.max(C[0],C[1]))>C[0]&&(g.top-=u.top,z.top=f),B[A.bottom!==c?n:l]=z.y);t.tip.css(B).toggle(!(z.x&&z.y||k.x===p&&z.y||k.y===p&&z.x)),g.left-=A.left.charAt?A.user:x!==s||z.top||!z.left&&!z.top?A.left:0,g.top-=A.top.charAt?A.user:y!==s||z.left||!z.left&&!z.top?A.top:0,w.left=u.left,w.top=u.top,w.corner=k.clone()}function H(){var b=r.corner,c=a.options.position,d=c.at,g=c.my.string?c.my.string():c.my;return b===f||g===f&&d===f?f:(b===e?q.corner=new u.Corner(g):b.string||(q.corner=new u.Corner(b),q.corner.fixed=e),w.corner=new u.Corner(q.corner.string()),q.corner.string()!=="centercenter")}function I(a,b,c){b=b?b:a[a.precedance];var d=t.titlebar&&a.y===l,e=d?t.titlebar:v,f="border-"+b+"-width",g=function(a){return parseInt(a.css(f),10)},h;return D(function(){h=(c?g(c):g(t.content)||g(e)||g(v))||0}),h}function J(a){var b=t.titlebar&&a.y===l,c=b?t.titlebar:t.content,e=d.browser.mozilla,f=e?"-moz-":d.browser.webkit?"-webkit-":"",g="border-radius-"+a.y+a.x,h="border-"+a.y+"-"+a.x+"-radius",i=function(a){return parseInt(c.css(a),10)||parseInt(v.css(a),10)},j;return D(function(){j=i(h)||i(f+h)||i(f+g)||i(g)||0}),j}function K(a){function z(a,b,c){var d=a.css(b)||n;return c&&d===a.css(c)?f:j.test(d)?f:d}var b,c,g,h=t.tip.css("cssText",""),i=a||q.corner,j=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,k="border-"+i[i.precedance]+"-color",m="background-color",n="transparent",o=" !important",s=t.titlebar,u=s&&(i.y===l||i.y===p&&h.position().top+x.height/2+r.offset<s.outerHeight(e)),w=u?s:t.content;D(function(){y.fill=z(h,m)||z(w,m)||z(t.content,m)||z(v,m)||h.css(m),y.border=z(h,k,"color")||z(w,k,"color")||z(t.content,k,"color")||z(v,k,"color")||v.css(k),d("*",h).add(h).css("cssText",m+":"+n+o+";border:0"+o+";")})}function M(a){var b=a.precedance===i,c=x[b?j:k],d=x[b?k:j],e=a.string().indexOf(p)>-1,f=c*(e?.5:1),g=Math.pow,h=Math.round,l,m,n,o=Math.sqrt(g(f,2)+g(d,2)),q=[z/f*o,z/d*o];return q[2]=Math.sqrt(g(q[0],2)-g(z,2)),q[3]=Math.sqrt(g(q[1],2)-g(z,2)),l=o+q[2]+q[3]+(e?0:q[0]),m=l/o,n=[h(m*d),h(m*c)],{height:n[b?0:1],width:n[b?1:0]}}function N(a,b,c){return"<qvml:"+a+' xmlns="urn:schemas-microsoft.com:vml" class="qtip-vml" '+(b||"")+' style="behavior: url(#default#VML); '+(c||"")+'" />'}var q=this,r=a.options.style.tip,t=a.elements,v=t.tooltip,w={top:0,left:0},x={width:r.width,height:r.height},y={},z=r.border||0,A=".qtip-tip",B=!!(d("<canvas />")[0]||{}).getContext,C;q.corner=g,q.mimic=g,q.border=z,q.offset=r.offset,q.size=x,a.checks.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){q.init()||q.destroy(),a.reposition()},"^style.tip.(height|width)$":function(){x={width:r.width,height:r.height},q.create(),q.update(),a.reposition()},"^content.title.text|style.(classes|widget)$":function(){t.tip&&t.tip.length&&q.update()}},d.extend(q,{init:function(){var a=H()&&(B||d.browser.msie);return a&&(q.create(),q.update(),v.unbind(A).bind("tooltipmove"+A,G)),a},create:function(){var a=x.width,b=x.height,c;t.tip&&t.tip.remove(),t.tip=d("<div />",{"class":"qtip-tip"}).css({width:a,height:b}).prependTo(v),B?d("<canvas />").appendTo(t.tip)[0].getContext("2d").save():(c=N("shape",'coordorigin="0,0"',"position:absolute;"),t.tip.html(c+c),d("*",t.tip).bind("click mousedown",function(a){a.stopPropagation()}))},update:function(a,b){var c=t.tip,j=c.children(),k=x.width,s=x.height,A=r.mimic,C=Math.round,D,G,H,J,O;a||(a=w.corner||q.corner),A===f?A=a:(A=new u.Corner(A),A.precedance=a.precedance,A.x==="inherit"?A.x=a.x:A.y==="inherit"?A.y=a.y:A.x===A.y&&(A[a.precedance]=a[a.precedance])),D=A.precedance,a.precedance===h?E():F(),t.tip.css({width:k=x.width,height:s=x.height}),K(a),y.border!=="transparent"?(z=I(a,g),r.border===0&&z>0&&(y.fill=y.border),q.border=z=r.border!==e?r.border:z):q.border=z=0,H=L(A,k,s),q.size=O=M(a),c.css(O).css("line-height",O.height+"px"),a.precedance===i?J=[C(A.x===m?z:A.x===o?O.width-k-z:(O.width-k)/2),C(A.y===l?O.height-s:0)]:J=[C(A.x===m?O.width-k:0),C(A.y===l?z:A.y===n?O.height-s-z:(O.height-s)/2)],B?(j.attr(O),G=j[0].getContext("2d"),G.restore(),G.save(),G.clearRect(0,0,3e3,3e3),G.fillStyle=y.fill,G.strokeStyle=y.border,G.lineWidth=z*2,G.lineJoin="miter",G.miterLimit=100,G.translate(J[0],J[1]),G.beginPath(),G.moveTo(H[0][0],H[0][1]),G.lineTo(H[1][0],H[1][1]),G.lineTo(H[2][0],H[2][1]),G.closePath(),z&&(v.css("background-clip")==="border-box"&&(G.strokeStyle=y.fill,G.stroke()),G.strokeStyle=y.border,G.stroke()),G.fill()):(H="m"+H[0][0]+","+H[0][1]+" l"+H[1][0]+","+H[1][1]+" "+H[2][0]+","+H[2][1]+" xe",J[2]=z&&/^(r|b)/i.test(a.string())?parseFloat(d.browser.version,10)===8?2:1:0,j.css({coordsize:k+z+" "+(s+z),antialias:""+(A.string().indexOf(p)>-1),left:J[0],top:J[1],width:k+z,height:s+z}).each(function(a){var b=d(this);b[b.prop?"prop":"attr"]({coordsize:k+z+" "+(s+z),path:H,fillcolor:y.fill,filled:!!a,stroked:!a}).toggle(!!z||!!a),!a&&b.html()===""&&b.html(N("stroke",'weight="'+z*2+'px" color="'+y.border+'" miterlimit="1000" joinstyle="miter"'))})),b!==f&&q.position(a)},position:function(a){var b=t.tip,c={},e=Math.max(0,r.offset),g,n,o;return r.corner===f||!b?f:(a=a||q.corner,g=a.precedance,n=M(a),o=[a.x,a.y],g===h&&o.reverse(),d.each(o,function(b,d){var f,h,o;d===p?(f=g===i?m:l,c[f]="50%",c["margin-"+f]=-Math.round(n[g===i?j:k]/2)+e):(f=I(a,d),h=I(a,d,t.content),o=J(a),c[d]=b?h:e+(o>f?o:-f))}),c[a[g]]-=n[g===h?j:k],b.css({top:"",bottom:"",left:"",right:"",margin:""}).css(c),c)},destroy:function(){t.tip&&t.tip.remove(),t.tip=!1,v.unbind(A)}}),q.init()}function N(c){function s(){q=d(p,j).not("[disabled]").map(function(){return typeof this.focus=="function"?this:null})}function t(a){q.length<1&&a.length?a.not("body").blur():q.first().focus()}function v(a){var b=d(a.target),c=b.closest(".qtip"),e;e=c.length<1?f:parseInt(c[0].style.zIndex,10)>parseInt(j[0].style.zIndex,10),!e&&d(a.target).closest(z)[0]!==j[0]&&t(b)}var g=this,h=c.options.show.modal,i=c.elements,j=i.tooltip,k="#qtip-overlay",l=".qtipmodal",m=l+c.id,n="is-modal-qtip",o=d(b.body),p=u.modal.focusable.join(","),q={},r;c.checks.modal={"^show.modal.(on|blur)$":function(){g.init(),i.overlay.toggle(j.is(":visible"))},"^content.text$":function(){s()}},d.extend(g,{init:function(){return h.on?(r=g.create(),j.attr(n,e).css("z-index",u.modal.zindex+d(z+"["+n+"]").length).unbind(l).unbind(m).bind("tooltipshow"+l+" tooltiphide"+l,function(a,b,c){var e=a.originalEvent;if(a.target===j[0])if(e&&a.type==="tooltiphide"&&/mouse(leave|enter)/.test(e.type)&&d(e.relatedTarget).closest(r[0]).length)try{a.preventDefault()}catch(f){}else(!e||e&&!e.solo)&&g[a.type.replace("tooltip","")](a,c)}).bind("tooltipfocus"+l,function(a){if(a.isDefaultPrevented()||a.target!==j[0])return;var b=d(z).filter("["+n+"]"),c=u.modal.zindex+b.length,e=parseInt(j[0].style.zIndex,10);r[0].style.zIndex=c-2,b.each(function(){this.style.zIndex>e&&(this.style.zIndex-=1)}),b.end().filter("."+B).qtip("blur",a.originalEvent),j.addClass(B)[0].style.zIndex=c;try{a.preventDefault()}catch(f){}}).bind("tooltiphide"+l,function(a){a.target===j[0]&&d("["+n+"]").filter(":visible").not(j).last().qtip("focus",a)}),h.escape&&d(b).unbind(m).bind("keydown"+m,function(a){a.keyCode===27&&j.hasClass(B)&&c.hide(a)}),h.blur&&i.overlay.unbind(m).bind("click"+m,function(a){j.hasClass(B)&&c.hide(a)}),s(),g):g},create:function(){function e(){r.css({height:c.height(),width:c.width()})}var b=d(k),c=d(a);return b.length?i.overlay=b.insertAfter(d(z).last()):(r=i.overlay=d("<div />",{id:k.substr(1),html:"<div></div>",mousedown:function(){return f}}).hide().insertAfter(d(z).last()),c.unbind(l).bind("resize"+l,e),e(),r)},toggle:function(a,b,c){if(a&&a.isDefaultPrevented())return g;var i=h.effect,k=b?"show":"hide",l=r.is(":visible"),p=d("["+n+"]").filter(":visible").not(j),q;return r||(r=g.create()),r.is(":animated")&&l===b&&r.data("toggleState")!==f||!b&&p.length?g:(b?(r.css({left:0,top:0}),r.toggleClass("blurs",h.blur),h.stealfocus!==f&&(o.bind("focusin"+m,v),t(d("body :focus")))):o.unbind("focusin"+m),r.stop(e,f).data("toggleState",b),d.isFunction(i)?i.call(r,b):i===f?r[k]():r.fadeTo(parseInt(c,10)||90,b?1:0,function(){b||d(this).hide()}),b||r.queue(function(a){r.css({left:"",top:""}).removeData("toggleState"),a()}),g)},show:function(a,b){return g.toggle(a,e,b)},hide:function(a,b){return g.toggle(a,f,b)},destroy:function(){var a=r;return a&&(a=d("["+n+"]").not(j).length<1,a?(i.overlay.remove(),d(b).unbind(l)):i.overlay.unbind(l+c.id),o.unbind("focusin"+m)),j.removeAttr(n).unbind(l)}}),g.init()}function O(c){var g=this,h=c.elements,i=c.options,l=h.tooltip,m=".ie6-"+c.id,n=d("select, object").length<1,o=0,p=f,q;c.checks.ie6={"^content|style$":function(a,b,c){redraw()}},d.extend(g,{init:function(){var c=d(a),f;n&&(h.bgiframe=d('<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:\'\';" style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=0); -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";"></iframe>'),h.bgiframe.appendTo(l),l.bind("tooltipmove"+m,g.adjustBGIFrame)),q=d("<div/>",{id:"qtip-rcontainer"}).appendTo(b.body),g.redraw(),h.overlay&&!p&&(f=function(){h.overlay[0].style.top=c.scrollTop()+"px"},c.bind("scroll.qtip-ie6, resize.qtip-ie6",f),f(),h.overlay.addClass("qtipmodal-ie6fix"),p=e)},adjustBGIFrame:function(){var a=c.get("dimensions"),b=c.plugins.tip,d=h.tip,e,f;f=parseInt(l.css("border-left-width"),10)||0,f={left:-f,top:-f},b&&d&&(e=b.corner.precedance==="x"?["width","left"]:["height","top"],f[e[1]]-=d[e[0]]()),h.bgiframe.css(f).css(a)},redraw:function(){if(c.rendered<1||o)return g;var a=i.style,b=i.position.container,d,e,f,h;return o=1,a.height&&l.css(k,a.height),a.width?l.css(j,a.width):(l.css(j,"").appendTo(q),e=l.width(),e%2<1&&(e+=1),f=l.css("max-width")||"",h=l.css("min-width")||"",d=(f+h).indexOf("%")>-1?b.width()/100:0,f=(f.indexOf("%")>-1?d:1)*parseInt(f,10)||e,h=(h.indexOf("%")>-1?d:1)*parseInt(h,10)||0,e=f+h?Math.min(Math.max(e,h),f):e,l.css(j,Math.round(e)).appendTo(b)),o=0,g},destroy:function(){n&&h.bgiframe.remove(),l.unbind(m)}}),g.init()}var e=!0,f=!1,g=null,h="x",i="y",j="width",k="height",l="top",m="left",n="bottom",o="right",p="center",q="flip",r="flipinvert",s="shift",t,u,v,w="qtip",x={},y=["ui-widget","ui-tooltip"],z="div.qtip."+w,A=w+"-default",B=w+"-focus",C=w+"-hover",D="_replacedByqTip",E="oldtitle",F;t=d.fn.qtip=function(a,b,h){var i=(""+a).toLowerCase(),j=g,k=d.makeArray(arguments).slice(1),l=k[k.length-1],m=this[0]?d.data(this[0],"qtip"):g;if(!arguments.length&&m||i==="api")return m;if("string"==typeof a)return this.each(function(){var a=d.data(this,"qtip");if(!a)return e;l&&l.timeStamp&&(a.cache.event=l);if(i!=="option"&&i!=="options"||!b)a[i]&&a[i].apply(a[i],k);else if(d.isPlainObject(b)||h!==c)a.set(b,h);else return j=a.get(b),f}),j!==g?j:this;if("object"==typeof a||!arguments.length)return m=H(d.extend(e,{},a)),t.bind.call(this,m,l)},t.bind=function(a,b){return this.each(function(g){function n(a){function b(){l.render(typeof a=="object"||h.show.ready),i.show.add(i.hide).unbind(k)}if(l.cache.disabled)return f;l.cache.event=d.extend({},a),l.cache.target=a?d(a.target):[c],h.show.delay>0?(clearTimeout(l.timers.show),l.timers.show=setTimeout(b,h.show.delay),j.show!==j.hide&&i.hide.bind(j.hide,function(){clearTimeout(l.timers.show)})):b()}var h,i,j,k,l,m;m=d.isArray(a.id)?a.id[g]:a.id,m=!m||m===f||m.length<1||x[m]?t.nextid++:x[m]=m,k=".qtip-"+m+"-create",l=J.call(this,m,a);if(l===f)return e;h=l.options,d.each(u,function(){this.initialize==="initialize"&&this(l)}),i={show:h.show.target,hide:h.hide.target},j={show:d.trim(""+h.show.event).replace(/ /g,k+" ")+k,hide:d.trim(""+h.hide.event).replace(/ /g,k+" ")+k},/mouse(over|enter)/i.test(j.show)&&!/mouse(out|leave)/i.test(j.hide)&&(j.hide+=" mouseleave"+k),i.show.bind("mousemove"+k,function(a){G(a),l.cache.onTarget=e}),i.show.bind(j.show,n),(h.show.ready||h.prerender)&&n(b)}).attr("data-hasqtip",e)},u=t.plugins={Corner:function(a){a=(""+a).replace(/([A-Z])/," $1").replace(/middle/gi,p).toLowerCase(),this.x=(a.match(/left|right/i)||a.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(a.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase();var b=a.charAt(0);this.precedance=b==="t"||b==="b"?i:h,this.string=function(){return this.precedance===i?this.y+this.x:this.x+this.y},this.abbrev=function(){var a=this.x.substr(0,1),b=this.y.substr(0,1);return a===b?a:this.precedance===i?b+a:a+b},this.invertx=function(a){this.x=this.x===m?o:this.x===o?m:a||this.x},this.inverty=function(a){this.y=this.y===l?n:this.y===n?l:a||this.y},this.clone=function(){return{x:this.x,y:this.y,precedance:this.precedance,string:this.string,abbrev:this.abbrev,clone:this.clone,invertx:this.invertx,inverty:this.inverty}}},offset:function(a,c){function l(a,b){e.left+=b*a.scrollLeft(),e.top+=b*a.scrollTop()}var e=a.offset(),f=a.closest("body"),g=d.browser.msie&&b.compatMode!=="CSS1Compat",h=c,i,j,k;if(h){do h.css("position")!=="static"&&(j=h.position(),e.left-=j.left+(parseInt(h.css("borderLeftWidth"),10)||0)+(parseInt(h.css("marginLeft"),10)||0),e.top-=j.top+(parseInt(h.css("borderTopWidth"),10)||0)+(parseInt(h.css("marginTop"),10)||0),!i&&(k=h.css("overflow"))!=="hidden"&&k!=="visible"&&(i=h));while((h=d(h[0].offsetParent)).length);(i&&i[0]!==f[0]||g)&&l(i||f,1)}return e},iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||f,fn:{attr:function(a,b){if(this.length){var c=this[0],e="title",f=d.data(c,"qtip");if(a===e&&f&&"object"==typeof f&&f.options.suppress)return arguments.length<2?d.attr(c,E):(f&&f.options.content.attr===e&&f.cache.attr&&f.set("content.text",b),this.attr(E,b))}return d.fn["attr"+D].apply(this,arguments)},clone:function(a){var b=d([]),c="title",e=d.fn["clone"+D].apply(this,arguments);return a||e.filter("["+E+"]").attr("title",function(){return d.attr(this,E)}).removeAttr(E),e}}},d.each(u.fn,function(a,b){if(!b||d.fn[a+D])return e;var c=d.fn[a+D]=d.fn[a];d.fn[a]=function(){return b.apply(this,arguments)||c.apply(this,arguments)}}),d.ui||(d["cleanData"+D]=d.cleanData,d.cleanData=function(a){for(var b=0,e;(e=a[b])!==c;b++)try{d(e).triggerHandler("removeqtip")}catch(f){}d["cleanData"+D](a)}),t.version="",t.nextid=0,t.inactiveEvents="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),t.zindex=15e3,t.defaults={prerender:f,id:f,overwrite:e,suppress:e,content:{text:e,attr:"title",deferred:f,title:{text:f,button:f}},position:{my:"top left",at:"bottom right",target:f,container:f,viewport:f,adjust:{x:0,y:0,mouse:e,resize:e,method:"flipinvert flipinvert"},effect:function(a,b,c){d(this).animate(b,{duration:200,queue:f})}},show:{target:f,event:"mouseenter",effect:e,delay:90,solo:f,ready:f,autofocus:f},hide:{target:f,event:"mouseleave",effect:e,delay:0,fixed:f,inactive:f,leave:"window",distance:f},style:{classes:"",widget:f,width:f,height:f,def:e},events:{render:g,move:g,show:g,hide:g,toggle:g,visible:g,hidden:g,focus:g,blur:g}},u.svg=function(a,c,e,f){var g=d(b),h=c[0],i={width:0,height:0,position:{top:1e10,left:1e10}},j,k,l,m,n;while(!h.getBBox)h=h.parentNode;if(h.getBBox&&h.parentNode){j=h.getBBox(),k=h.getScreenCTM(),l=h.farthestViewportElement||h;if(!l.createSVGPoint)return i;m=l.createSVGPoint(),m.x=j.x,m.y=j.y,n=m.matrixTransform(k),i.position.left=n.x,i.position.top=n.y,m.x+=j.width,m.y+=j.height,n=m.matrixTransform(k),i.width=n.x-i.position.left,i.height=n.y-i.position.top,i.position.left+=g.scrollLeft(),i.position.top+=g.scrollTop()}return i},u.ajax=function(a){var b=a.plugins.ajax;return"object"==typeof b?b:a.plugins.ajax=new K(a)},u.ajax.initialize="render",u.ajax.sanitize=function(a){var b=a.content,c;b&&"ajax"in b&&(c=b.ajax,typeof c!="object"&&(c=a.content.ajax={url:c}),"boolean"!=typeof c.once&&c.once&&(c.once=!!c.once))},d.extend(e,t.defaults,{content:{ajax:{loading:e,once:e}}}),u.tip=function(a){var b=a.plugins.tip;return"object"==typeof b?b:a.plugins.tip=new M(a)},u.tip.initialize="render",u.tip.sanitize=function(a){var b=a.style,c;b&&"tip"in b&&(c=a.style.tip,typeof c!="object"&&(a.style.tip={corner:c}),/string|boolean/i.test(typeof c.corner)||(c.corner=e),typeof c.width!="number"&&delete c.width,typeof c.height!="number"&&delete c.height,typeof c.border!="number"&&c.border!==e&&delete c.border,typeof c.offset!="number"&&delete c.offset)},d.extend(e,t.defaults,{style:{tip:{corner:e,mimic:f,width:6,height:6,border:e,offset:0}}}),u.modal=function(a){var b=a.plugins.modal;return"object"==typeof b?b:a.plugins.modal=new N(a)},u.modal.initialize="render",u.modal.sanitize=function(a){a.show&&(typeof a.show.modal!="object"?a.show.modal={on:!!a.show.modal}:typeof a.show.modal.on=="undefined"&&(a.show.modal.on=e))},u.modal.zindex=t.zindex-200,u.modal.focusable=["a[href]","area[href]","input","select","textarea","button","iframe","object","embed","[tabindex]","[contenteditable]"],d.extend(e,t.defaults,{show:{modal:{on:f,effect:e,blur:e,stealfocus:e,escape:e}}}),u.viewport=function(c,d,e,f,g,q,t){function L(a,b,c,e,f,g,h,i,j){var k=d[f],l=x[a],m=y[a],n=c===s,o=-E.offset[f]+D.offset[f]+D["scroll"+f],q=l===f?j:l===g?-j:-j/2,t=m===f?i:m===g?-i:-i/2,u=G&&G.size?G.size[h]||0:0,v=G&&G.corner&&G.corner.precedance===a&&!n?u:0,w=o-k+v,z=k+j-D[h]-o+v,A=q-(x.precedance===a||l===x[b]?t:0)-(m===p?i/2:0);return n?(v=G&&G.corner&&G.corner.precedance===b?u:0,A=(l===f?1:-1)*q-v,d[f]+=w>0?w:z>0?-z:0,d[f]=Math.max(-E.offset[f]+D.offset[f]+(v&&G.corner[a]===p?G.offset:0),k-A,Math.min(Math.max(-E.offset[f]+D.offset[f]+D[h],k+A),d[f]))):(e*=c===r?2:0,w>0&&(l!==f||z>0)?(d[f]-=A+e,J["invert"+a](f)):z>0&&(l!==g||w>0)&&(d[f]-=(l===p?-A:A)+e,J["invert"+a](g)),d[f]<o&&-d[f]>z&&(d[f]=k,J=x.clone())),d[f]-k}var u=e.target,v=c.elements.tooltip,x=e.my,y=e.at,z=e.adjust,A=z.method.split(" "),B=A[0],C=A[1]||A[0],D=e.viewport,E=e.container,F=c.cache,G=c.plugins.tip,H={left:0,top:0},I,J,K;if(!D.jquery||u[0]===a||u[0]===b.body||z.method==="none")return H;I=v.css("position")==="fixed",D={elem:D,height:D[(D[0]===a?"h":"outerH")+"eight"](),width:D[(D[0]===a?"w":"outerW")+"idth"](),scrollleft:I?0:D.scrollLeft(),scrolltop:I?0:D.scrollTop(),offset:D.offset()||{left:0,top:0}},E={elem:E,scrollLeft:E.scrollLeft(),scrollTop:E.scrollTop(),offset:E.offset()||{left:0,top:0}};if(B!=="shift"||C!=="shift")J=x.clone();return H={left:B!=="none"?L(h,i,B,z.x,m,o,j,f,q):0,top:C!=="none"?L(i,h,C,z.y,l,n,k,g,t):0},J&&F.lastClass!==(K=w+"-pos-"+J.abbrev())&&v.removeClass(c.cache.lastClass).addClass(c.cache.lastClass=K),H},u.imagemap=function(a,b,c,e){function v(a,b,c){var d=0,e=1,f=1,g=0,h=0,i=a.width,j=a.height;while(i>0&&j>0&&e>0&&f>0){i=Math.floor(i/2),j=Math.floor(j/2),c.x===m?e=i:c.x===o?e=a.width-i:e+=Math.floor(i/2),c.y===l?f=j:c.y===n?f=a.height-j:f+=Math.floor(j/2),d=b.length;while(d--){if(b.length<2)break;g=b[d][0]-a.position.left,h=b[d][1]-a.position.top,(c.x===m&&g>=e||c.x===o&&g<=e||c.x===p&&(g<e||g>a.width-e)||c.y===l&&h>=f||c.y===n&&h<=f||c.y===p&&(h<f||h>a.height-f))&&b.splice(d,1)}}return{left:b[0][0],top:b[0][1]}}b.jquery||(b=d(b));var f=a.cache.areas={},g=(b[0].shape||b.attr("shape")).toLowerCase(),h=b[0].coords||b.attr("coords"),i=h.split(","),j=[],k=d('img[usemap="#'+b.parent("map").attr("name")+'"]'),q=k.offset(),r={width:0,height:0,position:{top:1e10,right:0,bottom:0,left:1e10}},s=0,t=0,u;q.left+=Math.ceil((k.outerWidth()-k.width())/2),q.top+=Math.ceil((k.outerHeight()-k.height())/2);if(g==="poly"){s=i.length;while(s--)t=[parseInt(i[--s],10),parseInt(i[s+1],10)],t[0]>r.position.right&&(r.position.right=t[0]),t[0]<r.position.left&&(r.position.left=t[0]),t[1]>r.position.bottom&&(r.position.bottom=t[1]),t[1]<r.position.top&&(r.position.top=t[1]),j.push(t)}else{s=-1;while(s++<i.length)j.push(parseInt(i[s],10))}switch(g){case"rect":r={width:Math.abs(j[2]-j[0]),height:Math.abs(j[3]-j[1]),position:{left:Math.min(j[0],j[2]),top:Math.min(j[1],j[3])}};break;case"circle":r={width:j[2]+2,height:j[2]+2,position:{left:j[0],top:j[1]}};break;case"poly":r.width=Math.abs(r.position.right-r.position.left),r.height=Math.abs(r.position.bottom-r.position.top),c.abbrev()==="c"?r.position={left:r.position.left+r.width/2,top:r.position.top+r.height/2}:(f[c+h]||(r.position=v(r,j.slice(),c),e&&(e[0]==="flip"||e[1]==="flip")&&(r.offset=v(r,j.slice(),{x:c.x===m?o:c.x===o?m:p,y:c.y===l?n:c.y===n?l:p}),r.offset.left-=r.position.left,r.offset.top-=r.position.top),f[c+h]=r),r=f[c+h]),r.width=r.height=0}return r.position.left+=q.left,r.position.top+=q.top,r},u.ie6=function(a){var b=d.browser,c=a.plugins.ie6;return!b.msie||(""+b.version).charAt(0)!=="6"?f:"object"==typeof c?c:a.plugins.ie6=new O(a)},u.ie6.initialize="render"})})(window,document);
|
@@ -0,0 +1,1207 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Validation Plugin 1.9.0
|
3
|
+
*
|
4
|
+
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
5
|
+
* http://docs.jquery.com/Plugins/Validation
|
6
|
+
*
|
7
|
+
* Copyright (c) 2006 - 2011 Jörn Zaefferer
|
8
|
+
*
|
9
|
+
* Dual licensed under the MIT and GPL licenses:
|
10
|
+
* http://www.opensource.org/licenses/mit-license.php
|
11
|
+
* http://www.gnu.org/licenses/gpl.html
|
12
|
+
*/
|
13
|
+
(function($) {
|
14
|
+
|
15
|
+
$.extend($.fn, {
|
16
|
+
// http://docs.jquery.com/Plugins/Validation/validate
|
17
|
+
validate: function( options ) {
|
18
|
+
|
19
|
+
// if nothing is selected, return nothing; can't chain anyway
|
20
|
+
if (!this.length) {
|
21
|
+
options && options.debug && window.console && console.warn( "nothing selected, can't validate, returning nothing" );
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
|
25
|
+
// check if a validator for this form was already created
|
26
|
+
var validator = $.data(this[0], 'validator');
|
27
|
+
if ( validator ) {
|
28
|
+
return validator;
|
29
|
+
}
|
30
|
+
|
31
|
+
// Add novalidate tag if HTML5.
|
32
|
+
this.attr('novalidate', 'novalidate');
|
33
|
+
|
34
|
+
validator = new $.validator( options, this[0] );
|
35
|
+
$.data(this[0], 'validator', validator);
|
36
|
+
|
37
|
+
if ( validator.settings.onsubmit ) {
|
38
|
+
|
39
|
+
var inputsAndButtons = this.find("input, button");
|
40
|
+
|
41
|
+
// allow suppresing validation by adding a cancel class to the submit button
|
42
|
+
inputsAndButtons.filter(".cancel").click(function () {
|
43
|
+
validator.cancelSubmit = true;
|
44
|
+
});
|
45
|
+
|
46
|
+
// when a submitHandler is used, capture the submitting button
|
47
|
+
if (validator.settings.submitHandler) {
|
48
|
+
inputsAndButtons.filter(":submit").click(function () {
|
49
|
+
validator.submitButton = this;
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
// validate the form on submit
|
54
|
+
this.submit( function( event ) {
|
55
|
+
if ( validator.settings.debug )
|
56
|
+
// prevent form submit to be able to see console output
|
57
|
+
event.preventDefault();
|
58
|
+
|
59
|
+
function handle() {
|
60
|
+
if ( validator.settings.submitHandler ) {
|
61
|
+
if (validator.submitButton) {
|
62
|
+
// insert a hidden input as a replacement for the missing submit button
|
63
|
+
var hidden = $("<input type='hidden'/>").attr("name", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);
|
64
|
+
}
|
65
|
+
validator.settings.submitHandler.call( validator, validator.currentForm );
|
66
|
+
if (validator.submitButton) {
|
67
|
+
// and clean up afterwards; thanks to no-block-scope, hidden can be referenced
|
68
|
+
hidden.remove();
|
69
|
+
}
|
70
|
+
return false;
|
71
|
+
}
|
72
|
+
return true;
|
73
|
+
}
|
74
|
+
|
75
|
+
// prevent submit for invalid forms or custom submit handlers
|
76
|
+
if ( validator.cancelSubmit ) {
|
77
|
+
validator.cancelSubmit = false;
|
78
|
+
return handle();
|
79
|
+
}
|
80
|
+
if ( validator.form() ) {
|
81
|
+
if ( validator.pendingRequest ) {
|
82
|
+
validator.formSubmitted = true;
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
return handle();
|
86
|
+
} else {
|
87
|
+
validator.focusInvalid();
|
88
|
+
return false;
|
89
|
+
}
|
90
|
+
});
|
91
|
+
}
|
92
|
+
|
93
|
+
return validator;
|
94
|
+
},
|
95
|
+
// http://docs.jquery.com/Plugins/Validation/valid
|
96
|
+
valid: function() {
|
97
|
+
if ( $(this[0]).is('form')) {
|
98
|
+
return this.validate().form();
|
99
|
+
} else {
|
100
|
+
var valid = true;
|
101
|
+
var validator = $(this[0].form).validate();
|
102
|
+
this.each(function() {
|
103
|
+
valid &= validator.element(this);
|
104
|
+
});
|
105
|
+
return valid;
|
106
|
+
}
|
107
|
+
},
|
108
|
+
// attributes: space seperated list of attributes to retrieve and remove
|
109
|
+
removeAttrs: function(attributes) {
|
110
|
+
var result = {},
|
111
|
+
$element = this;
|
112
|
+
$.each(attributes.split(/\s/), function(index, value) {
|
113
|
+
result[value] = $element.attr(value);
|
114
|
+
$element.removeAttr(value);
|
115
|
+
});
|
116
|
+
return result;
|
117
|
+
},
|
118
|
+
// http://docs.jquery.com/Plugins/Validation/rules
|
119
|
+
rules: function(command, argument) {
|
120
|
+
var element = this[0];
|
121
|
+
|
122
|
+
if (command) {
|
123
|
+
var settings = $.data(element.form, 'validator').settings;
|
124
|
+
var staticRules = settings.rules;
|
125
|
+
var existingRules = $.validator.staticRules(element);
|
126
|
+
switch(command) {
|
127
|
+
case "add":
|
128
|
+
$.extend(existingRules, $.validator.normalizeRule(argument));
|
129
|
+
staticRules[element.name] = existingRules;
|
130
|
+
if (argument.messages)
|
131
|
+
settings.messages[element.name] = $.extend( settings.messages[element.name], argument.messages );
|
132
|
+
break;
|
133
|
+
case "remove":
|
134
|
+
if (!argument) {
|
135
|
+
delete staticRules[element.name];
|
136
|
+
return existingRules;
|
137
|
+
}
|
138
|
+
var filtered = {};
|
139
|
+
$.each(argument.split(/\s/), function(index, method) {
|
140
|
+
filtered[method] = existingRules[method];
|
141
|
+
delete existingRules[method];
|
142
|
+
});
|
143
|
+
return filtered;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
var data = $.validator.normalizeRules(
|
148
|
+
$.extend(
|
149
|
+
{},
|
150
|
+
$.validator.metadataRules(element),
|
151
|
+
$.validator.classRules(element),
|
152
|
+
$.validator.attributeRules(element),
|
153
|
+
$.validator.staticRules(element)
|
154
|
+
), element);
|
155
|
+
|
156
|
+
// make sure required is at front
|
157
|
+
if (data.required) {
|
158
|
+
var param = data.required;
|
159
|
+
delete data.required;
|
160
|
+
data = $.extend({required: param}, data);
|
161
|
+
}
|
162
|
+
|
163
|
+
return data;
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
// Custom selectors
|
168
|
+
$.extend($.expr[":"], {
|
169
|
+
// http://docs.jquery.com/Plugins/Validation/blank
|
170
|
+
blank: function(a) {return !$.trim("" + a.value);},
|
171
|
+
// http://docs.jquery.com/Plugins/Validation/filled
|
172
|
+
filled: function(a) {return !!$.trim("" + a.value);},
|
173
|
+
// http://docs.jquery.com/Plugins/Validation/unchecked
|
174
|
+
unchecked: function(a) {return !a.checked;}
|
175
|
+
});
|
176
|
+
|
177
|
+
// constructor for validator
|
178
|
+
$.validator = function( options, form ) {
|
179
|
+
this.settings = $.extend( true, {}, $.validator.defaults, options );
|
180
|
+
this.currentForm = form;
|
181
|
+
this.init();
|
182
|
+
};
|
183
|
+
|
184
|
+
$.validator.format = function(source, params) {
|
185
|
+
if ( arguments.length == 1 )
|
186
|
+
return function() {
|
187
|
+
var args = $.makeArray(arguments);
|
188
|
+
args.unshift(source);
|
189
|
+
return $.validator.format.apply( this, args );
|
190
|
+
};
|
191
|
+
if ( arguments.length > 2 && params.constructor != Array ) {
|
192
|
+
params = $.makeArray(arguments).slice(1);
|
193
|
+
}
|
194
|
+
if ( params.constructor != Array ) {
|
195
|
+
params = [ params ];
|
196
|
+
}
|
197
|
+
$.each(params, function(i, n) {
|
198
|
+
source = source.replace(new RegExp("\\{" + i + "\\}", "g"), n);
|
199
|
+
});
|
200
|
+
return source;
|
201
|
+
};
|
202
|
+
|
203
|
+
$.extend($.validator, {
|
204
|
+
|
205
|
+
defaults: {
|
206
|
+
messages: {},
|
207
|
+
groups: {},
|
208
|
+
rules: {},
|
209
|
+
errorClass: "error",
|
210
|
+
validClass: "valid",
|
211
|
+
errorElement: "label",
|
212
|
+
focusInvalid: true,
|
213
|
+
errorContainer: $( [] ),
|
214
|
+
errorLabelContainer: $( [] ),
|
215
|
+
onsubmit: true,
|
216
|
+
ignore: ":hidden",
|
217
|
+
ignoreTitle: false,
|
218
|
+
onfocusin: function(element, event) {
|
219
|
+
this.lastActive = element;
|
220
|
+
|
221
|
+
// hide error label and remove error class on focus if enabled
|
222
|
+
if ( this.settings.focusCleanup && !this.blockFocusCleanup ) {
|
223
|
+
this.settings.unhighlight && this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass );
|
224
|
+
this.addWrapper(this.errorsFor(element)).hide();
|
225
|
+
}
|
226
|
+
},
|
227
|
+
onfocusout: function(element, event) {
|
228
|
+
if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
|
229
|
+
// console.log("on focus out =>>>>>>>>"+element.name);
|
230
|
+
this.element(element);
|
231
|
+
}
|
232
|
+
},
|
233
|
+
onkeyup: function(element, event) {
|
234
|
+
if ( element.name in this.submitted || element == this.lastElement ) {
|
235
|
+
this.element(element);
|
236
|
+
}
|
237
|
+
},
|
238
|
+
onclick: function(element, event) {
|
239
|
+
// click on selects, radiobuttons and checkboxes
|
240
|
+
if ( element.name in this.submitted )
|
241
|
+
this.element(element);
|
242
|
+
// or option elements, check parent select in that case
|
243
|
+
else if (element.parentNode.name in this.submitted)
|
244
|
+
this.element(element.parentNode);
|
245
|
+
},
|
246
|
+
highlight: function(element, errorClass, validClass) {
|
247
|
+
if (element.type === 'radio') {
|
248
|
+
this.findByName(element.name).addClass(errorClass).removeClass(validClass);
|
249
|
+
} else {
|
250
|
+
$(element).addClass(errorClass).removeClass(validClass);
|
251
|
+
}
|
252
|
+
},
|
253
|
+
unhighlight: function(element, errorClass, validClass) {
|
254
|
+
if (element.type === 'radio') {
|
255
|
+
this.findByName(element.name).removeClass(errorClass).addClass(validClass);
|
256
|
+
} else {
|
257
|
+
var value = this.findByName(element.name);
|
258
|
+
// console.log("valuevaluevalue"+element.id);
|
259
|
+
$(element).removeClass(errorClass).addClass(validClass);
|
260
|
+
var id = element.id;
|
261
|
+
// console.log(id);
|
262
|
+
var sel = $("#"+element.id);
|
263
|
+
// console.log(sel);
|
264
|
+
$("#"+element.id).removeAttr("data-error");
|
265
|
+
if ($("#"+element.id).qtip()){
|
266
|
+
$("#"+element.id).qtip("hide");
|
267
|
+
$("#"+element.id).qtip("destroy");
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
}
|
272
|
+
}
|
273
|
+
},
|
274
|
+
|
275
|
+
// http://docs.jquery.com/Plugins/Validation/Validator/setDefaults
|
276
|
+
setDefaults: function(settings) {
|
277
|
+
$.extend( $.validator.defaults, settings );
|
278
|
+
},
|
279
|
+
|
280
|
+
messages: {
|
281
|
+
required: "Field is required*",
|
282
|
+
remote: "Please fix this field.",
|
283
|
+
email: "Please enter a valid email address.",
|
284
|
+
url: "Please enter a valid URL.",
|
285
|
+
date: "Please enter a valid date.",
|
286
|
+
dateISO: "Please enter a valid date (ISO).",
|
287
|
+
number: "Please enter a valid number.",
|
288
|
+
digits: "Please enter only digits.",
|
289
|
+
creditcard: "Please enter a valid credit card number.",
|
290
|
+
equalTo: "Please enter the same value again.",
|
291
|
+
accept: "Please enter a value with a valid extension.",
|
292
|
+
maxlength: $.validator.format("Enter less than {0} characters."),
|
293
|
+
minlength: $.validator.format("Please enter at least {0} characters."),
|
294
|
+
rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."),
|
295
|
+
range: $.validator.format("Please enter a value between {0} and {1}."),
|
296
|
+
max: $.validator.format("Please enter a value less than or equal to {0}."),
|
297
|
+
min: $.validator.format("Please enter a value greater than or equal to {0}.")
|
298
|
+
},
|
299
|
+
|
300
|
+
autoCreateRanges: false,
|
301
|
+
|
302
|
+
prototype: {
|
303
|
+
|
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
|
+
$.each(value.split(/\s/), function(index, name) {
|
318
|
+
groups[name] = key;
|
319
|
+
});
|
320
|
+
});
|
321
|
+
var rules = this.settings.rules;
|
322
|
+
$.each(rules, function(key, value) {
|
323
|
+
rules[key] = $.validator.normalizeRule(value);
|
324
|
+
});
|
325
|
+
|
326
|
+
function delegate(event) {
|
327
|
+
var validator = $.data(this[0].form, "validator"),
|
328
|
+
eventType = "on" + event.type.replace(/^validate/, "");
|
329
|
+
validator.settings[eventType] && validator.settings[eventType].call(validator, this[0], event);
|
330
|
+
}
|
331
|
+
$(this.currentForm)
|
332
|
+
.validateDelegate("[type='text'], [type='password'], [type='file'], select, textarea, " +
|
333
|
+
"[type='number'], [type='search'] ,[type='tel'], [type='url'], " +
|
334
|
+
"[type='email'], [type='datetime'], [type='date'], [type='month'], " +
|
335
|
+
"[type='week'], [type='time'], [type='datetime-local'], " +
|
336
|
+
"[type='range'], [type='color'] ",
|
337
|
+
"focusin focusout keyup", delegate)
|
338
|
+
.validateDelegate("[type='radio'], [type='checkbox'], select, option", "click", delegate);
|
339
|
+
|
340
|
+
if (this.settings.invalidHandler)
|
341
|
+
$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
|
342
|
+
},
|
343
|
+
|
344
|
+
// http://docs.jquery.com/Plugins/Validation/Validator/form
|
345
|
+
form: function() {
|
346
|
+
this.checkForm();
|
347
|
+
$.extend(this.submitted, this.errorMap);
|
348
|
+
this.invalid = $.extend({}, this.errorMap);
|
349
|
+
if (!this.valid())
|
350
|
+
$(this.currentForm).triggerHandler("invalid-form", [this]);
|
351
|
+
this.showErrors();
|
352
|
+
return this.valid();
|
353
|
+
},
|
354
|
+
|
355
|
+
checkForm: function() {
|
356
|
+
this.prepareForm();
|
357
|
+
for ( var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++ ) {
|
358
|
+
this.check( elements[i] );
|
359
|
+
}
|
360
|
+
return this.valid();
|
361
|
+
},
|
362
|
+
|
363
|
+
// http://docs.jquery.com/Plugins/Validation/Validator/element
|
364
|
+
element: function( element ) {
|
365
|
+
element = this.validationTargetFor( this.clean( element ) );
|
366
|
+
// console.log("inside the element function"+element);
|
367
|
+
this.lastElement = element;
|
368
|
+
this.prepareElement( element );
|
369
|
+
this.currentElements = $(element);
|
370
|
+
var result = this.check( element );
|
371
|
+
if ( result ) {
|
372
|
+
delete this.invalid[element.name];
|
373
|
+
} else {
|
374
|
+
this.invalid[element.name] = true;
|
375
|
+
}
|
376
|
+
if ( !this.numberOfInvalids() ) {
|
377
|
+
// Hide error containers on last error
|
378
|
+
this.toHide = this.toHide.add( this.containers );
|
379
|
+
}
|
380
|
+
this.showErrors();
|
381
|
+
return result;
|
382
|
+
},
|
383
|
+
|
384
|
+
// http://docs.jquery.com/Plugins/Validation/Validator/showErrors
|
385
|
+
showErrors: function(errors) {
|
386
|
+
if(errors) {
|
387
|
+
// add items to error list and map
|
388
|
+
$.extend( this.errorMap, errors );
|
389
|
+
this.errorList = [];
|
390
|
+
for ( var name in errors ) {
|
391
|
+
this.errorList.push({
|
392
|
+
message: errors[name],
|
393
|
+
element: this.findByName(name)[0]
|
394
|
+
});
|
395
|
+
}
|
396
|
+
// remove items from success list
|
397
|
+
this.successList = $.grep( this.successList, function(element) {
|
398
|
+
return !(element.name in errors);
|
399
|
+
});
|
400
|
+
}
|
401
|
+
this.settings.showErrors
|
402
|
+
? this.settings.showErrors.call( this, this.errorMap, this.errorList )
|
403
|
+
: this.defaultShowErrors();
|
404
|
+
},
|
405
|
+
|
406
|
+
// http://docs.jquery.com/Plugins/Validation/Validator/resetForm
|
407
|
+
resetForm: function() {
|
408
|
+
if ( $.fn.resetForm )
|
409
|
+
$( this.currentForm ).resetForm();
|
410
|
+
this.submitted = {};
|
411
|
+
this.lastElement = null;
|
412
|
+
this.prepareForm();
|
413
|
+
this.hideErrors();
|
414
|
+
this.elements().removeClass( this.settings.errorClass );
|
415
|
+
},
|
416
|
+
|
417
|
+
numberOfInvalids: function() {
|
418
|
+
return this.objectLength(this.invalid);
|
419
|
+
},
|
420
|
+
|
421
|
+
objectLength: function( obj ) {
|
422
|
+
var count = 0;
|
423
|
+
for ( var i in obj )
|
424
|
+
count++;
|
425
|
+
return count;
|
426
|
+
},
|
427
|
+
|
428
|
+
hideErrors: function() {
|
429
|
+
var objects = this.addWrapper( this.toHide );
|
430
|
+
this.addWrapper( this.toHide ).hide();
|
431
|
+
|
432
|
+
},
|
433
|
+
|
434
|
+
valid: function() {
|
435
|
+
return this.size() == 0;
|
436
|
+
},
|
437
|
+
|
438
|
+
size: function() {
|
439
|
+
return this.errorList.length;
|
440
|
+
},
|
441
|
+
|
442
|
+
focusInvalid: function() {
|
443
|
+
if( this.settings.focusInvalid ) {
|
444
|
+
try {
|
445
|
+
$(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])
|
446
|
+
.filter(":visible")
|
447
|
+
.focus()
|
448
|
+
// manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find
|
449
|
+
.trigger("focusin");
|
450
|
+
} catch(e) {
|
451
|
+
// ignore IE throwing errors when focusing hidden elements
|
452
|
+
}
|
453
|
+
}
|
454
|
+
},
|
455
|
+
|
456
|
+
findLastActive: function() {
|
457
|
+
var lastActive = this.lastActive;
|
458
|
+
return lastActive && $.grep(this.errorList, function(n) {
|
459
|
+
return n.element.name == lastActive.name;
|
460
|
+
}).length == 1 && lastActive;
|
461
|
+
},
|
462
|
+
|
463
|
+
elements: function() {
|
464
|
+
var validator = this,
|
465
|
+
rulesCache = {};
|
466
|
+
|
467
|
+
// select all valid inputs inside the form (no submit or reset buttons)
|
468
|
+
return $(this.currentForm)
|
469
|
+
.find("input, select, textarea")
|
470
|
+
.not(":submit, :reset, :image, [disabled]")
|
471
|
+
.not( this.settings.ignore )
|
472
|
+
.filter(function() {
|
473
|
+
!this.name && validator.settings.debug && window.console && console.error( "%o has no name assigned", this);
|
474
|
+
|
475
|
+
// select only the first element for each name, and only those with rules specified
|
476
|
+
if ( this.name in rulesCache || !validator.objectLength($(this).rules()) )
|
477
|
+
return false;
|
478
|
+
|
479
|
+
rulesCache[this.name] = true;
|
480
|
+
return true;
|
481
|
+
});
|
482
|
+
},
|
483
|
+
|
484
|
+
clean: function( selector ) {
|
485
|
+
return $( selector )[0];
|
486
|
+
},
|
487
|
+
|
488
|
+
errors: function() {
|
489
|
+
return $( this.settings.errorElement + "." + this.settings.errorClass, this.errorContext );
|
490
|
+
},
|
491
|
+
|
492
|
+
reset: function() {
|
493
|
+
this.successList = [];
|
494
|
+
this.errorList = [];
|
495
|
+
this.errorMap = {};
|
496
|
+
this.toShow = $([]);
|
497
|
+
this.toHide = $([]);
|
498
|
+
this.currentElements = $([]);
|
499
|
+
},
|
500
|
+
|
501
|
+
prepareForm: function() {
|
502
|
+
this.reset();
|
503
|
+
this.toHide = this.errors().add( this.containers );
|
504
|
+
},
|
505
|
+
|
506
|
+
prepareElement: function( element ) {
|
507
|
+
this.reset();
|
508
|
+
this.toHide = this.errorsFor(element);
|
509
|
+
},
|
510
|
+
|
511
|
+
check: function( element ) {
|
512
|
+
element = this.validationTargetFor( this.clean( element ) );
|
513
|
+
|
514
|
+
var rules = $(element).rules();
|
515
|
+
var dependencyMismatch = false;
|
516
|
+
for (var method in rules ) {
|
517
|
+
var rule = { method: method, parameters: rules[method] };
|
518
|
+
try {
|
519
|
+
var result = $.validator.methods[method].call( this, element.value.replace(/\r/g, ""), element, rule.parameters );
|
520
|
+
|
521
|
+
// if a method indicates that the field is optional and therefore valid,
|
522
|
+
// don't mark it as valid when there are no other rules
|
523
|
+
if ( result == "dependency-mismatch" ) {
|
524
|
+
dependencyMismatch = true;
|
525
|
+
continue;
|
526
|
+
}
|
527
|
+
dependencyMismatch = false;
|
528
|
+
|
529
|
+
if ( result == "pending" ) {
|
530
|
+
this.toHide = this.toHide.not( this.errorsFor(element) );
|
531
|
+
return;
|
532
|
+
}
|
533
|
+
|
534
|
+
if( !result ) {
|
535
|
+
this.formatAndAdd( element, rule );
|
536
|
+
return false;
|
537
|
+
}
|
538
|
+
} catch(e) {
|
539
|
+
this.settings.debug && window.console && console.log("exception occured when checking element " + element.id
|
540
|
+
+ ", check the '" + rule.method + "' method", e);
|
541
|
+
throw e;
|
542
|
+
}
|
543
|
+
}
|
544
|
+
if (dependencyMismatch)
|
545
|
+
return;
|
546
|
+
if ( this.objectLength(rules) )
|
547
|
+
this.successList.push(element);
|
548
|
+
return true;
|
549
|
+
},
|
550
|
+
|
551
|
+
// return the custom message for the given element and validation method
|
552
|
+
// specified in the element's "messages" metadata
|
553
|
+
customMetaMessage: function(element, method) {
|
554
|
+
if (!$.metadata)
|
555
|
+
return;
|
556
|
+
|
557
|
+
var meta = this.settings.meta
|
558
|
+
? $(element).metadata()[this.settings.meta]
|
559
|
+
: $(element).metadata();
|
560
|
+
|
561
|
+
return meta && meta.messages && meta.messages[method];
|
562
|
+
},
|
563
|
+
|
564
|
+
// return the custom message for the given element name and validation method
|
565
|
+
customMessage: function( name, method ) {
|
566
|
+
var m = this.settings.messages[name];
|
567
|
+
return m && (m.constructor == String
|
568
|
+
? m
|
569
|
+
: m[method]);
|
570
|
+
},
|
571
|
+
|
572
|
+
// return the first defined argument, allowing empty strings
|
573
|
+
findDefined: function() {
|
574
|
+
for(var i = 0; i < arguments.length; i++) {
|
575
|
+
if (arguments[i] !== undefined)
|
576
|
+
return arguments[i];
|
577
|
+
}
|
578
|
+
return undefined;
|
579
|
+
},
|
580
|
+
|
581
|
+
defaultMessage: function( element, method) {
|
582
|
+
return this.findDefined(
|
583
|
+
this.customMessage( element.name, method ),
|
584
|
+
this.customMetaMessage( element, method ),
|
585
|
+
// title is never undefined, so handle empty string as undefined
|
586
|
+
!this.settings.ignoreTitle && element.title || undefined,
|
587
|
+
$.validator.messages[method],
|
588
|
+
"<strong>Warning: No message defined for " + element.name + "</strong>"
|
589
|
+
);
|
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 = jQuery.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
|
+
|
609
|
+
addWrapper: function(toToggle) {
|
610
|
+
if ( this.settings.wrapper )
|
611
|
+
toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) );
|
612
|
+
return toToggle;
|
613
|
+
},
|
614
|
+
|
615
|
+
defaultShowErrors: function() {
|
616
|
+
for ( var i = 0; this.errorList[i]; i++ ) {
|
617
|
+
var error = this.errorList[i];
|
618
|
+
this.settings.highlight && this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass );
|
619
|
+
this.showLabel( error.element, error.message );
|
620
|
+
}
|
621
|
+
if( this.errorList.length ) {
|
622
|
+
this.toShow = this.toShow.add( this.containers );
|
623
|
+
}
|
624
|
+
if (this.settings.success) {
|
625
|
+
for ( var i = 0; this.successList[i]; i++ ) {
|
626
|
+
this.showLabel( this.successList[i] );
|
627
|
+
}
|
628
|
+
}
|
629
|
+
if (this.settings.unhighlight) {
|
630
|
+
for ( var i = 0, elements = this.validElements(); elements[i]; i++ ) {
|
631
|
+
this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass );
|
632
|
+
}
|
633
|
+
}
|
634
|
+
this.toHide = this.toHide.not( this.toShow );
|
635
|
+
this.hideErrors();
|
636
|
+
this.addWrapper( this.toShow ).show();
|
637
|
+
},
|
638
|
+
|
639
|
+
validElements: function() {
|
640
|
+
return this.currentElements.not(this.invalidElements());
|
641
|
+
},
|
642
|
+
|
643
|
+
invalidElements: function() {
|
644
|
+
return $(this.errorList).map(function() {
|
645
|
+
return this.element;
|
646
|
+
});
|
647
|
+
},
|
648
|
+
|
649
|
+
showLabel: function(element, message) {
|
650
|
+
var label = this.errorsFor( element );
|
651
|
+
if ( label.length ) {
|
652
|
+
// refresh error/success class
|
653
|
+
label.removeClass( this.settings.validClass ).addClass( this.settings.errorClass );
|
654
|
+
|
655
|
+
// check if we have a generated label, replace the message then
|
656
|
+
label.attr("generated") && label.html(message);
|
657
|
+
// console.log("label.length");
|
658
|
+
} else {
|
659
|
+
// create label
|
660
|
+
label = $("<" + this.settings.errorElement + "/>")
|
661
|
+
.attr({"for": this.idOrName(element), generated: true})
|
662
|
+
.addClass(this.settings.errorClass)
|
663
|
+
.html(message || "");
|
664
|
+
if ( this.settings.wrapper ) {
|
665
|
+
// make sure the element is visible, even in IE
|
666
|
+
// actually showing the wrapped element is handled elsewhere
|
667
|
+
label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
|
668
|
+
}
|
669
|
+
if ( !this.labelContainer.append(label).length )
|
670
|
+
this.settings.errorPlacement
|
671
|
+
? this.settings.errorPlacement(label, $(element) )
|
672
|
+
: label.insertAfter(element);
|
673
|
+
|
674
|
+
}
|
675
|
+
if ( !message && this.settings.success ) {
|
676
|
+
// console.log("label.length label.text");
|
677
|
+
label.text("");
|
678
|
+
typeof this.settings.success == "string"
|
679
|
+
? label.addClass( this.settings.success )
|
680
|
+
: this.settings.success( label );
|
681
|
+
}
|
682
|
+
this.toShow = this.toShow.add(label);
|
683
|
+
},
|
684
|
+
|
685
|
+
errorsFor: function(element) {
|
686
|
+
var name = this.idOrName(element);
|
687
|
+
return this.errors().filter(function() {
|
688
|
+
return $(this).attr('for') == name;
|
689
|
+
});
|
690
|
+
},
|
691
|
+
|
692
|
+
idOrName: function(element) {
|
693
|
+
return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);
|
694
|
+
},
|
695
|
+
|
696
|
+
validationTargetFor: function(element) {
|
697
|
+
// if radio/checkbox, validate first element in group instead
|
698
|
+
if (this.checkable(element)) {
|
699
|
+
element = this.findByName( element.name ).not(this.settings.ignore)[0];
|
700
|
+
}
|
701
|
+
return element;
|
702
|
+
},
|
703
|
+
|
704
|
+
checkable: function( element ) {
|
705
|
+
return /radio|checkbox/i.test(element.type);
|
706
|
+
},
|
707
|
+
|
708
|
+
findByName: function( name ) {
|
709
|
+
// select by name and filter by form for performance over form.find("[name=...]")
|
710
|
+
var form = this.currentForm;
|
711
|
+
return $(document.getElementsByName(name)).map(function(index, element) {
|
712
|
+
return element.form == form && element.name == name && element || null;
|
713
|
+
});
|
714
|
+
},
|
715
|
+
|
716
|
+
getLength: function(value, element) {
|
717
|
+
switch( element.nodeName.toLowerCase() ) {
|
718
|
+
case 'select':
|
719
|
+
return $("option:selected", element).length;
|
720
|
+
case 'input':
|
721
|
+
if( this.checkable( element) )
|
722
|
+
return this.findByName(element.name).filter(':checked').length;
|
723
|
+
}
|
724
|
+
return value.length;
|
725
|
+
},
|
726
|
+
|
727
|
+
depend: function(param, element) {
|
728
|
+
return this.dependTypes[typeof param]
|
729
|
+
? this.dependTypes[typeof param](param, element)
|
730
|
+
: true;
|
731
|
+
},
|
732
|
+
|
733
|
+
dependTypes: {
|
734
|
+
"boolean": function(param, element) {
|
735
|
+
return param;
|
736
|
+
},
|
737
|
+
"string": function(param, element) {
|
738
|
+
return !!$(param, element.form).length;
|
739
|
+
},
|
740
|
+
"function": function(param, element) {
|
741
|
+
return param(element);
|
742
|
+
}
|
743
|
+
},
|
744
|
+
|
745
|
+
optional: function(element) {
|
746
|
+
return !$.validator.methods.required.call(this, $.trim(element.value), element) && "dependency-mismatch";
|
747
|
+
},
|
748
|
+
|
749
|
+
startRequest: function(element) {
|
750
|
+
if (!this.pending[element.name]) {
|
751
|
+
this.pendingRequest++;
|
752
|
+
this.pending[element.name] = true;
|
753
|
+
}
|
754
|
+
},
|
755
|
+
|
756
|
+
stopRequest: function(element, valid) {
|
757
|
+
this.pendingRequest--;
|
758
|
+
// sometimes synchronization fails, make sure pendingRequest is never < 0
|
759
|
+
if (this.pendingRequest < 0)
|
760
|
+
this.pendingRequest = 0;
|
761
|
+
delete this.pending[element.name];
|
762
|
+
if ( valid && this.pendingRequest == 0 && this.formSubmitted && this.form() ) {
|
763
|
+
$(this.currentForm).submit();
|
764
|
+
this.formSubmitted = false;
|
765
|
+
} else if (!valid && this.pendingRequest == 0 && this.formSubmitted) {
|
766
|
+
$(this.currentForm).triggerHandler("invalid-form", [this]);
|
767
|
+
this.formSubmitted = false;
|
768
|
+
}
|
769
|
+
},
|
770
|
+
|
771
|
+
previousValue: function(element) {
|
772
|
+
return $.data(element, "previousValue") || $.data(element, "previousValue", {
|
773
|
+
old: null,
|
774
|
+
valid: true,
|
775
|
+
message: this.defaultMessage( element, "remote" )
|
776
|
+
});
|
777
|
+
}
|
778
|
+
|
779
|
+
},
|
780
|
+
|
781
|
+
classRuleSettings: {
|
782
|
+
required: {required: true},
|
783
|
+
email: {email: true},
|
784
|
+
url: {url: true},
|
785
|
+
date: {date: true},
|
786
|
+
dateISO: {dateISO: true},
|
787
|
+
dateDE: {dateDE: true},
|
788
|
+
number: {number: true},
|
789
|
+
numberDE: {numberDE: true},
|
790
|
+
digits: {digits: true},
|
791
|
+
creditcard: {creditcard: true}
|
792
|
+
},
|
793
|
+
|
794
|
+
addClassRules: function(className, rules) {
|
795
|
+
className.constructor == String ?
|
796
|
+
this.classRuleSettings[className] = rules :
|
797
|
+
$.extend(this.classRuleSettings, className);
|
798
|
+
},
|
799
|
+
|
800
|
+
classRules: function(element) {
|
801
|
+
var rules = {};
|
802
|
+
var classes = $(element).attr('class');
|
803
|
+
classes && $.each(classes.split(' '), function() {
|
804
|
+
if (this in $.validator.classRuleSettings) {
|
805
|
+
$.extend(rules, $.validator.classRuleSettings[this]);
|
806
|
+
}
|
807
|
+
});
|
808
|
+
return rules;
|
809
|
+
},
|
810
|
+
|
811
|
+
attributeRules: function(element) {
|
812
|
+
var rules = {};
|
813
|
+
var $element = $(element);
|
814
|
+
|
815
|
+
for (var method in $.validator.methods) {
|
816
|
+
var value;
|
817
|
+
// If .prop exists (jQuery >= 1.6), use it to get true/false for required
|
818
|
+
if (method === 'required' && typeof $.fn.prop === 'function') {
|
819
|
+
value = $element.prop(method);
|
820
|
+
} else {
|
821
|
+
value = $element.attr(method);
|
822
|
+
}
|
823
|
+
if (value) {
|
824
|
+
rules[method] = value;
|
825
|
+
} else if ($element[0].getAttribute("type") === method) {
|
826
|
+
rules[method] = true;
|
827
|
+
}
|
828
|
+
}
|
829
|
+
|
830
|
+
// maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs
|
831
|
+
if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {
|
832
|
+
delete rules.maxlength;
|
833
|
+
}
|
834
|
+
|
835
|
+
return rules;
|
836
|
+
},
|
837
|
+
|
838
|
+
metadataRules: function(element) {
|
839
|
+
if (!$.metadata) return {};
|
840
|
+
|
841
|
+
var meta = $.data(element.form, 'validator').settings.meta;
|
842
|
+
return meta ?
|
843
|
+
$(element).metadata()[meta] :
|
844
|
+
$(element).metadata();
|
845
|
+
},
|
846
|
+
|
847
|
+
staticRules: function(element) {
|
848
|
+
var rules = {};
|
849
|
+
var validator = $.data(element.form, 'validator');
|
850
|
+
if (validator.settings.rules) {
|
851
|
+
rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};
|
852
|
+
}
|
853
|
+
return rules;
|
854
|
+
},
|
855
|
+
|
856
|
+
normalizeRules: function(rules, element) {
|
857
|
+
// handle dependency check
|
858
|
+
$.each(rules, function(prop, val) {
|
859
|
+
// ignore rule when param is explicitly false, eg. required:false
|
860
|
+
if (val === false) {
|
861
|
+
delete rules[prop];
|
862
|
+
return;
|
863
|
+
}
|
864
|
+
if (val.param || val.depends) {
|
865
|
+
var keepRule = true;
|
866
|
+
switch (typeof val.depends) {
|
867
|
+
case "string":
|
868
|
+
keepRule = !!$(val.depends, element.form).length;
|
869
|
+
break;
|
870
|
+
case "function":
|
871
|
+
keepRule = val.depends.call(element, element);
|
872
|
+
break;
|
873
|
+
}
|
874
|
+
if (keepRule) {
|
875
|
+
rules[prop] = val.param !== undefined ? val.param : true;
|
876
|
+
} else {
|
877
|
+
delete rules[prop];
|
878
|
+
}
|
879
|
+
}
|
880
|
+
});
|
881
|
+
|
882
|
+
// evaluate parameters
|
883
|
+
$.each(rules, function(rule, parameter) {
|
884
|
+
rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;
|
885
|
+
});
|
886
|
+
|
887
|
+
// clean number parameters
|
888
|
+
$.each(['minlength', 'maxlength', 'min', 'max'], function() {
|
889
|
+
if (rules[this]) {
|
890
|
+
rules[this] = Number(rules[this]);
|
891
|
+
}
|
892
|
+
});
|
893
|
+
$.each(['rangelength', 'range'], function() {
|
894
|
+
if (rules[this]) {
|
895
|
+
rules[this] = [Number(rules[this][0]), Number(rules[this][1])];
|
896
|
+
}
|
897
|
+
});
|
898
|
+
|
899
|
+
if ($.validator.autoCreateRanges) {
|
900
|
+
// auto-create ranges
|
901
|
+
if (rules.min && rules.max) {
|
902
|
+
rules.range = [rules.min, rules.max];
|
903
|
+
delete rules.min;
|
904
|
+
delete rules.max;
|
905
|
+
}
|
906
|
+
if (rules.minlength && rules.maxlength) {
|
907
|
+
rules.rangelength = [rules.minlength, rules.maxlength];
|
908
|
+
delete rules.minlength;
|
909
|
+
delete rules.maxlength;
|
910
|
+
}
|
911
|
+
}
|
912
|
+
|
913
|
+
// To support custom messages in metadata ignore rule methods titled "messages"
|
914
|
+
if (rules.messages) {
|
915
|
+
delete rules.messages;
|
916
|
+
}
|
917
|
+
|
918
|
+
return rules;
|
919
|
+
},
|
920
|
+
|
921
|
+
// Converts a simple string to a {string: true} rule, e.g., "required" to {required:true}
|
922
|
+
normalizeRule: function(data) {
|
923
|
+
if( typeof data == "string" ) {
|
924
|
+
var transformed = {};
|
925
|
+
$.each(data.split(/\s/), function() {
|
926
|
+
transformed[this] = true;
|
927
|
+
});
|
928
|
+
data = transformed;
|
929
|
+
}
|
930
|
+
return data;
|
931
|
+
},
|
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
|
+
|
942
|
+
methods: {
|
943
|
+
|
944
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/required
|
945
|
+
required: function(value, element, param) {
|
946
|
+
// check if dependency is met
|
947
|
+
if ( !this.depend(param, element) )
|
948
|
+
return "dependency-mismatch";
|
949
|
+
switch( element.nodeName.toLowerCase() ) {
|
950
|
+
case 'select':
|
951
|
+
// could be an array for select-multiple or a string, both are fine this way
|
952
|
+
var val = $(element).val();
|
953
|
+
return val && val.length > 0;
|
954
|
+
case 'input':
|
955
|
+
if ( this.checkable(element) )
|
956
|
+
return this.getLength(value, element) > 0;
|
957
|
+
default:
|
958
|
+
return $.trim(value).length > 0;
|
959
|
+
}
|
960
|
+
},
|
961
|
+
|
962
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/remote
|
963
|
+
remote: function(value, element, param) {
|
964
|
+
if ( this.optional(element) )
|
965
|
+
return "dependency-mismatch";
|
966
|
+
|
967
|
+
var previous = this.previousValue(element);
|
968
|
+
if (!this.settings.messages[element.name] )
|
969
|
+
this.settings.messages[element.name] = {};
|
970
|
+
previous.originalMessage = this.settings.messages[element.name].remote;
|
971
|
+
this.settings.messages[element.name].remote = previous.message;
|
972
|
+
|
973
|
+
param = typeof param == "string" && {url:param} || param;
|
974
|
+
|
975
|
+
if ( this.pending[element.name] ) {
|
976
|
+
return "pending";
|
977
|
+
}
|
978
|
+
if ( previous.old === value ) {
|
979
|
+
return previous.valid;
|
980
|
+
}
|
981
|
+
|
982
|
+
previous.old = value;
|
983
|
+
var validator = this;
|
984
|
+
this.startRequest(element);
|
985
|
+
var data = {};
|
986
|
+
data[element.name] = value;
|
987
|
+
$.ajax($.extend(true, {
|
988
|
+
url: param,
|
989
|
+
mode: "abort",
|
990
|
+
port: "validate" + element.name,
|
991
|
+
dataType: "json",
|
992
|
+
data: data,
|
993
|
+
success: function(response) {
|
994
|
+
validator.settings.messages[element.name].remote = previous.originalMessage;
|
995
|
+
var valid = response === true;
|
996
|
+
if ( valid ) {
|
997
|
+
var submitted = validator.formSubmitted;
|
998
|
+
validator.prepareElement(element);
|
999
|
+
validator.formSubmitted = submitted;
|
1000
|
+
validator.successList.push(element);
|
1001
|
+
validator.showErrors();
|
1002
|
+
} else {
|
1003
|
+
var errors = {};
|
1004
|
+
var message = response || validator.defaultMessage( element, "remote" );
|
1005
|
+
errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
|
1006
|
+
validator.showErrors(errors);
|
1007
|
+
}
|
1008
|
+
previous.valid = valid;
|
1009
|
+
validator.stopRequest(element, valid);
|
1010
|
+
}
|
1011
|
+
}, param));
|
1012
|
+
return "pending";
|
1013
|
+
},
|
1014
|
+
|
1015
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/minlength
|
1016
|
+
minlength: function(value, element, param) {
|
1017
|
+
return this.optional(element) || this.getLength($.trim(value), element) >= param;
|
1018
|
+
},
|
1019
|
+
|
1020
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/maxlength
|
1021
|
+
maxlength: function(value, element, param) {
|
1022
|
+
return this.optional(element) || this.getLength($.trim(value), element) <= param;
|
1023
|
+
},
|
1024
|
+
|
1025
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/rangelength
|
1026
|
+
rangelength: function(value, element, param) {
|
1027
|
+
var length = this.getLength($.trim(value), element);
|
1028
|
+
return this.optional(element) || ( length >= param[0] && length <= param[1] );
|
1029
|
+
},
|
1030
|
+
|
1031
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/min
|
1032
|
+
min: function( value, element, param ) {
|
1033
|
+
return this.optional(element) || value >= param;
|
1034
|
+
},
|
1035
|
+
|
1036
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/max
|
1037
|
+
max: function( value, element, param ) {
|
1038
|
+
return this.optional(element) || value <= param;
|
1039
|
+
},
|
1040
|
+
|
1041
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/range
|
1042
|
+
range: function( value, element, param ) {
|
1043
|
+
return this.optional(element) || ( value >= param[0] && value <= param[1] );
|
1044
|
+
},
|
1045
|
+
|
1046
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/email
|
1047
|
+
email: function(value, element) {
|
1048
|
+
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
|
1049
|
+
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);
|
1050
|
+
},
|
1051
|
+
|
1052
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/url
|
1053
|
+
url: function(value, element) {
|
1054
|
+
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/
|
1055
|
+
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);
|
1056
|
+
},
|
1057
|
+
|
1058
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/date
|
1059
|
+
date: function(value, element) {
|
1060
|
+
return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
|
1061
|
+
},
|
1062
|
+
|
1063
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/dateISO
|
1064
|
+
dateISO: function(value, element) {
|
1065
|
+
return this.optional(element) || /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(value);
|
1066
|
+
},
|
1067
|
+
|
1068
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/number
|
1069
|
+
number: function(value, element) {
|
1070
|
+
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value);
|
1071
|
+
},
|
1072
|
+
|
1073
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/digits
|
1074
|
+
digits: function(value, element) {
|
1075
|
+
return this.optional(element) || /^\d+$/.test(value);
|
1076
|
+
},
|
1077
|
+
|
1078
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/creditcard
|
1079
|
+
// based on http://en.wikipedia.org/wiki/Luhn
|
1080
|
+
creditcard: function(value, element) {
|
1081
|
+
if ( this.optional(element) )
|
1082
|
+
return "dependency-mismatch";
|
1083
|
+
// accept only spaces, digits and dashes
|
1084
|
+
if (/[^0-9 -]+/.test(value))
|
1085
|
+
return false;
|
1086
|
+
var nCheck = 0,
|
1087
|
+
nDigit = 0,
|
1088
|
+
bEven = false;
|
1089
|
+
|
1090
|
+
value = value.replace(/\D/g, "");
|
1091
|
+
|
1092
|
+
for (var n = value.length - 1; n >= 0; n--) {
|
1093
|
+
var cDigit = value.charAt(n);
|
1094
|
+
var nDigit = parseInt(cDigit, 10);
|
1095
|
+
if (bEven) {
|
1096
|
+
if ((nDigit *= 2) > 9)
|
1097
|
+
nDigit -= 9;
|
1098
|
+
}
|
1099
|
+
nCheck += nDigit;
|
1100
|
+
bEven = !bEven;
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
return (nCheck % 10) == 0;
|
1104
|
+
},
|
1105
|
+
|
1106
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/accept
|
1107
|
+
accept: function(value, element, param) {
|
1108
|
+
param = typeof param == "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
|
1109
|
+
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
1110
|
+
},
|
1111
|
+
|
1112
|
+
// http://docs.jquery.com/Plugins/Validation/Methods/equalTo
|
1113
|
+
equalTo: function(value, element, param) {
|
1114
|
+
// bind to the blur event of the target in order to revalidate whenever the target field is updated
|
1115
|
+
// TODO find a way to bind the event just once, avoiding the unbind-rebind overhead
|
1116
|
+
var target = $(param).unbind(".validate-equalTo").bind("blur.validate-equalTo", function() {
|
1117
|
+
$(element).valid();
|
1118
|
+
});
|
1119
|
+
return value == target.val();
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
});
|
1125
|
+
|
1126
|
+
// deprecated, use $.validator.format instead
|
1127
|
+
$.format = $.validator.format;
|
1128
|
+
|
1129
|
+
})(jQuery);
|
1130
|
+
|
1131
|
+
// ajax mode: abort
|
1132
|
+
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
|
1133
|
+
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
|
1134
|
+
;(function($) {
|
1135
|
+
var pendingRequests = {};
|
1136
|
+
// Use a prefilter if available (1.5+)
|
1137
|
+
if ( $.ajaxPrefilter ) {
|
1138
|
+
$.ajaxPrefilter(function(settings, _, xhr) {
|
1139
|
+
var port = settings.port;
|
1140
|
+
if (settings.mode == "abort") {
|
1141
|
+
if ( pendingRequests[port] ) {
|
1142
|
+
pendingRequests[port].abort();
|
1143
|
+
}
|
1144
|
+
pendingRequests[port] = xhr;
|
1145
|
+
}
|
1146
|
+
});
|
1147
|
+
} else {
|
1148
|
+
// Proxy ajax
|
1149
|
+
var ajax = $.ajax;
|
1150
|
+
$.ajax = function(settings) {
|
1151
|
+
var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
|
1152
|
+
port = ( "port" in settings ? settings : $.ajaxSettings ).port;
|
1153
|
+
if (mode == "abort") {
|
1154
|
+
if ( pendingRequests[port] ) {
|
1155
|
+
pendingRequests[port].abort();
|
1156
|
+
}
|
1157
|
+
return (pendingRequests[port] = ajax.apply(this, arguments));
|
1158
|
+
}
|
1159
|
+
return ajax.apply(this, arguments);
|
1160
|
+
};
|
1161
|
+
}
|
1162
|
+
})(jQuery);
|
1163
|
+
|
1164
|
+
// provides cross-browser focusin and focusout events
|
1165
|
+
// IE has native support, in other browsers, use event caputuring (neither bubbles)
|
1166
|
+
|
1167
|
+
// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation
|
1168
|
+
// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target
|
1169
|
+
;(function($) {
|
1170
|
+
// only implement if not provided by jQuery core (since 1.4)
|
1171
|
+
// TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs
|
1172
|
+
if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {
|
1173
|
+
$.each({
|
1174
|
+
focus: 'focusin',
|
1175
|
+
blur: 'focusout'
|
1176
|
+
}, function( original, fix ){
|
1177
|
+
$.event.special[fix] = {
|
1178
|
+
setup:function() {
|
1179
|
+
this.addEventListener( original, handler, true );
|
1180
|
+
},
|
1181
|
+
teardown:function() {
|
1182
|
+
this.removeEventListener( original, handler, true );
|
1183
|
+
},
|
1184
|
+
handler: function(e) {
|
1185
|
+
arguments[0] = $.event.fix(e);
|
1186
|
+
arguments[0].type = fix;
|
1187
|
+
return $.event.handle.apply(this, arguments);
|
1188
|
+
}
|
1189
|
+
};
|
1190
|
+
function handler(e) {
|
1191
|
+
e = $.event.fix(e);
|
1192
|
+
e.type = fix;
|
1193
|
+
return $.event.handle.call(this, e);
|
1194
|
+
}
|
1195
|
+
});
|
1196
|
+
};
|
1197
|
+
$.extend($.fn, {
|
1198
|
+
validateDelegate: function(delegate, type, handler) {
|
1199
|
+
return this.bind(type, function(event) {
|
1200
|
+
var target = $(event.target);
|
1201
|
+
if (target.is(delegate)) {
|
1202
|
+
return handler.apply(target, arguments);
|
1203
|
+
}
|
1204
|
+
});
|
1205
|
+
}
|
1206
|
+
});
|
1207
|
+
})(jQuery);
|