-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjquery.validate.tooltips.min.js
10 lines (10 loc) · 1.93 KB
/
jquery.validate.tooltips.min.js
1
2
3
4
5
6
7
8
9
10
/**
* jQuery Validation Tooltips Plugin v1.0
* http://envysphere.com/jquery-validation-tooltips-14/
*
* Copyright 2011, Shaun Simmons
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/(function(a){a.extend(a.validator.defaults,{errorPlacement:function(a,b){a.css("visibility","hidden").appendTo(b[0].form)},showErrors:function(a,b){this.defaultShowErrors(),this.reflow(b)},errorPosition:"r",errorSpacing:{top:2,right:3,bottom:2,left:3}}),a.validator.prototype.reflow=function(b){if(!b){typeof this.lastElement!="undefined"&&(this.reset(),this.form());return}var c=b.length;while(c--){var d=a(b[c].element),e=this.errorsFor(b[c].element),f=[d.data("errorposition")||this.settings.errorPosition][0].toLowerCase(),g,h=0,i=0;switch(b[c].element.type){case"checkbox":case"radio":var j=d.parent("label");if(j.length)d=j,h=-3;else{var k=a(this.currentForm).find("label[for='"+d.attr("id")+"']");k.length&&(d=k,h=-3)}}g=d.position();switch(f){case"t":h+=g.top-this.settings.errorSpacing.top-d.outerHeight(),i+=g.left;break;case"b":h+=g.top+this.settings.errorSpacing.bottom+d.outerHeight(),i+=g.left;break;case"l":h+=g.top,i+=g.left-this.settings.errorSpacing.right-e.outerWidth();break;case"tl":h+=g.top-this.settings.errorSpacing.top-d.outerHeight(),i+=g.left-this.settings.errorSpacing.right-e.outerWidth();break;case"tr":h+=g.top-this.settings.errorSpacing.top-d.outerHeight(),i+=g.left+this.settings.errorSpacing.left+d.outerWidth();break;case"bl":h+=g.top+this.settings.errorSpacing.bottom+d.outerHeight(),i+=g.left-this.settings.errorSpacing.right-e.outerWidth();break;case"br":h+=g.top+this.settings.errorSpacing.bottom+d.outerHeight(),i+=g.left+this.settings.errorSpacing.left+d.outerWidth();break;case"r":default:h+=g.top,i+=g.left+this.settings.errorSpacing.left+d.outerWidth()}e.css({left:i+"px",top:h+"px",position:"absolute",visibility:"visible"})}}})(jQuery);