From e0a6a4045ee7ac84a28e498c1cf22bc21f460d85 Mon Sep 17 00:00:00 2001 From: Mike Norman Date: Wed, 27 May 2015 16:46:24 -0400 Subject: [PATCH] add option 'tooltipCustomClass' - allow user to add their own custom CSS class to raised tooltips --- .gitignore | 1 + build/example.htm | 4 +-- build/jquery.validity.js | 19 +++++++++-- build/jquery.validity.lang.de.js | 2 +- build/jquery.validity.lang.es.js | 2 +- build/jquery.validity.lang.fr.js | 56 ++++++++++++++++---------------- build/jquery.validity.min.js | 14 ++++---- src/jquery.validity.core.js | 2 ++ src/jquery.validity.outputs.js | 12 ++++++- version.txt | 2 +- 10 files changed, 70 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 251f522..137a94b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea *.swp compiler/jQuery.validity.* *.DS_Store diff --git a/build/example.htm b/build/example.htm index 760504e..5199dcf 100644 --- a/build/example.htm +++ b/build/example.htm @@ -19,7 +19,7 @@ - + - \ No newline at end of file + diff --git a/build/jquery.validity.js b/build/jquery.validity.js index 42214ba..b4c544f 100644 --- a/build/jquery.validity.js +++ b/build/jquery.validity.js @@ -1,11 +1,11 @@ /* - * jQuery.validity v1.4.6 + * jQuery.validity v1.4.7 * http://validity.thatscaptaintoyou.com/ * https://github.com/whatgoodisaroad/validity * * Dual licensed under MIT and GPL * - * Date: 2014-07-04 (Friday, 04 July 2014) + * Date: 2015-05-27 (Wednesday, 27 May 2015) */ (function($, undefined) { @@ -58,6 +58,8 @@ var val + ""; }, + tooltipCustomClass: null, + debugPrivates:false }, @@ -1143,6 +1145,10 @@ __private = { start:function() { $("." + $.validity.outputs.tooltip.tooltipClass) .remove(); + if ($.validity.settings.tooltipCustomClass) { + $("." + $.validity.outputs.tooltip.tooltipCustomClass) + .remove(); + } }, end:function(results) { @@ -1161,8 +1167,14 @@ __private = { pos.left += $obj.width() + 18; pos.top += 8; + var tooltipClasses = '\"validity-tooltip '; + if ($.validity.settings.tooltipCustomClass) { + tooltipClasses += $.validity.settings.tooltipCustomClass; + } + tooltipClasses += '\"'; + var tooltip = $( - "
" + + "
" + msg + "
" + "
" + @@ -1309,6 +1321,7 @@ __private = { // Create one and position it next to the input. $("
") + .attr('id', 'validity-modal-msg-' + off.left + '-' + off.top) .addClass(errorClass) .css(errorStyle) .text(msg) diff --git a/build/jquery.validity.lang.de.js b/build/jquery.validity.lang.de.js index 271a136..f02fdcb 100644 --- a/build/jquery.validity.lang.de.js +++ b/build/jquery.validity.lang.de.js @@ -46,4 +46,4 @@ $.extend($.validity.messages, { generic:"Ungültig." }); -$.validity.setup({ defaultFieldName:"Dieses Feld", }); +$.validity.setup({ defaultFieldName:"Dieses Feld" }); diff --git a/build/jquery.validity.lang.es.js b/build/jquery.validity.lang.es.js index b2cf58f..73b16fd 100644 --- a/build/jquery.validity.lang.es.js +++ b/build/jquery.validity.lang.es.js @@ -45,4 +45,4 @@ $.extend($.validity.messages, { generic:"No válido." }); -$.validity.setup({ defaultFieldName:"Este campo", }); +$.validity.setup({ defaultFieldName:"Este campo" }); diff --git a/build/jquery.validity.lang.fr.js b/build/jquery.validity.lang.fr.js index e9f988c..dd300f1 100644 --- a/build/jquery.validity.lang.fr.js +++ b/build/jquery.validity.lang.fr.js @@ -2,47 +2,47 @@ $.extend($.validity.messages, { require:"#{field} est requis.", // Format validators: match:"#{field} est dans un mauvais format.", - integer:"#{field} doit �tre un nombre entier positif.", - date:"#{field} doit �tre une date.", - email:"#{field} doit �tre une adresse email.", - usd:"#{field} doit �tre un montant en US Dollars.", - url:"#{field} doit �tre une adresse URL.", - number:"#{field} doit �tre un nombre.", - zip:"#{field} doit �tre un code postal ##### ou #####-####.", - phone:"#{field} doit �tre un num�ro de t�l�phone ###-###-####.", - guid:"#{field} doit �tre un guid du type {3F2504E0-4F89-11D3-9A0C-0305E82C3301}.", - time24:"#{field} doit �tre une heure au format 24 heures (ex: 23:00).", - time12:"#{field} doit �tre une heure au format 12 heures (ex:12:00 AM/PM)", + integer:"#{field} doit être un nombre entier positif.", + date:"#{field} doit être une date.", + email:"#{field} doit être une adresse email.", + usd:"#{field} doit être un montant en US Dollars.", + url:"#{field} doit être une adresse URL.", + number:"#{field} doit être un nombre.", + zip:"#{field} doit être un code postal ##### ou #####-####.", + phone:"#{field} doit être un numéro de téléphone ###-###-####.", + guid:"#{field} doit être un guid du type {3F2504E0-4F89-11D3-9A0C-0305E82C3301}.", + time24:"#{field} doit être une heure au format 24 heures (ex: 23:00).", + time12:"#{field} doit être une heure au format 12 heures (ex:12:00 AM/PM)", // Value range messages: - lessThan:"#{field} doit �tre inf�rieur � #{max}.", - lessThanOrEqualTo:"#{field} doit �tre inf�rieur ou �gal � #{max}.", - greaterThan:"#{field} doit �tre sup�rieur � #{min}.", - greaterThanOrEqualTo:"#{field} doit �tre sup�rieur ou �gal � #{min}.", - range:"#{field} doit �tre compris entre #{min} et #{max}.", + lessThan:"#{field} doit être inférieur à #{max}.", + lessThanOrEqualTo:"#{field} doit être inférieur ou égal à #{max}.", + greaterThan:"#{field} doit être supérieur à #{min}.", + greaterThanOrEqualTo:"#{field} doit être supérieur ou égal à #{min}.", + range:"#{field} doit être compris entre #{min} et #{max}.", // Value length messages: - tooLong:"#{field} ne doit pas d�passer #{max} caract�res.", - tooShort:"#{field} doit contenir au minimum #{min} caract�res.", + tooLong:"#{field} ne doit pas dépasser #{max} caractères.", + tooShort:"#{field} doit contenir au minimum #{min} caractères.", // Composition validators: - nonHtml:"#{field} ne doit pas contenir de caract�res HTML.", - alphabet:"#{field} contient des carat�res interdits.", + nonHtml:"#{field} ne doit pas contenir de caractères HTML.", + alphabet:"#{field} contient des caratères interdits.", - minCharClass:"#{field} ne doit pas contenir plus de #{min} #{charClass} caract�res.", - maxCharClass:"#{field} ne doit pas contenir moins de #{min} #{charClass} caract�res.", + minCharClass:"#{field} ne doit pas contenir plus de #{min} #{charClass} caractères.", + maxCharClass:"#{field} ne doit pas contenir moins de #{min} #{charClass} caractères.", // Aggregate validator messages: equal:"Les valeurs ne correspondent pas.", - distinct:"Une valeur est r�p�t�e.", - sum:"La somme des valeurs diff�re de #{sum}.", - sumMax:"La somme des valeurs doit �tre inf�rieure � #{max}.", - sumMin:"La somme des valeurs doit �tre sup�rieure � #{min}.", + distinct:"Une valeur est répétée.", + sum:"La somme des valeurs diffère de #{sum}.", + sumMax:"La somme des valeurs doit être inférieure à #{max}.", + sumMin:"La somme des valeurs doit être supérieure à #{min}.", // Radio validator messages: - radioChecked:"La valeur s�lectionn�e est invalide.", + radioChecked:"La valeur sélectionnée est invalide.", generic:"Invalide." }); -$.validity.setup({ defaultFieldName:"Ce champ", }); \ No newline at end of file +$.validity.setup({ defaultFieldName:"Ce champ" }); diff --git a/build/jquery.validity.min.js b/build/jquery.validity.min.js index d5e325d..82159a7 100644 --- a/build/jquery.validity.min.js +++ b/build/jquery.validity.min.js @@ -1,16 +1,16 @@ /* - * jQuery.validity v1.4.6 + * jQuery.validity v1.4.7 * http://validity.thatscaptaintoyou.com/ * https://github.com/whatgoodisaroad/validity * * Dual licensed under MIT and GPL * - * Date: 2014-07-04 (Friday, 04 July 2014) + * Date: 2015-05-27 (Wednesday, 27 May 2015) */ (function(a,e){function d(b,c,h){a.validity.registerReduction(b);var d=[];(b.reduction||b).filter(a.validity.settings.elementSupport).each(function(){c(this)?d.push(this):j(this,i(h,{field:p(this)}))});b.reduction=a(d);return b}function g(){if(a.validity.isValidating())a.validity.report.errors++,a.validity.report.valid=!1}function j(b,c){g();a.validity.out.raise(a(b),c)}function k(b,c){g();a.validity.out.raiseAggregate(b,c)}function l(b){var a=0;b.each(function(){var b=parseFloat(this.value);a+=isNaN(b)? 0:b});return a}function i(b,a){for(var h in a)a.hasOwnProperty(h)&&(b=b.replace(RegExp("#\\{"+h+"\\}","g"),a[h]));return o(b)}function p(b){if(!a.validity.settings.useInfer)return a.validity.settings.defaultFieldName;var b=a(b),c=b.prop("id"),h=a.validity.settings.defaultFieldName;if(b.prop("title").length)h=b.prop("title");else if(/^([A-Z0-9][a-z]*)+$/.test(c))h=c.replace(/([A-Z0-9])[a-z]*/g," $&");else if(/^[a-z0-9]+(_[a-z0-9]+)*$/.test(c)){b=c.split("_");for(c=0;c]*$/},messages:{require:"#{field} is required.",match:"#{field} is in an invalid format.",integer:"#{field} must be a positive, whole number.",date:"#{field} must be formatted as a date. (mm/dd/yyyy)", email:"#{field} must be formatted as an email.",usd:"#{field} must be formatted as a US Dollar amount.",url:"#{field} must be formatted as a URL.",number:"#{field} must be formatted as a number.",zip:"#{field} must be formatted as a zipcode ##### or #####-####.",phone:"#{field} must be formatted as a phone number ###-###-####.",guid:"#{field} must be formatted as a guid like {3F2504E0-4F89-11D3-9A0C-0305E82C3301}.",time24:"#{field} must be formatted as a 24 hour time: 23:00.",time12:"#{field} must be formatted as a 12 hour time: 12:00 AM/PM", @@ -29,11 +29,11 @@ e=function(a){return a},g=a.validity.messages.equal;if(d.length){a.isFunction(b) (e=b,typeof c=="string"&&(g=c)):typeof b=="string"&&(g=b);for(var m=a.map(d,function(a){return e(a.value)}),n=0;nl(d))k(d,c||i(a.validity.messages.sumMin,{min:b})),this.reduction=a([]);return this},radioChecked:function(b, c){a.validity.registerReduction(this);var d=(this.reduction||this).filter(a.validity.settings.elementSupport);d.is(":radio")&&d.find(":checked").val()!=b&&k(d,c||a.validity.messages.radioChecked)},radioNotChecked:function(b,c){a.validity.registerReduction(this);var d=(this.reduction||this).filter(a.validity.settings.elementSupport);d.is(":radio")&&d.filter(":checked").val()==b&&k(d,c||a.validity.messages.radioChecked)},checkboxChecked:function(b){return d(this,function(b){return!a(b).is(":checkbox")|| -a(b).is(":checked")},b||a.validity.messages.checkboxChecked)},assert:function(b,c){a.validity.registerReduction(this);var e=this.reduction||this;if(e.length)if(a.isFunction(b))return d(this,b,c||a.validity.messages.generic);else if(!b)k(e,c||a.validity.messages.generic),this.reduction=a([]);return this},fail:function(a){return this.assert(!1,a)}});q={validate:d,addToReport:g,raiseError:j,raiseAggregateError:k,numericSum:l,format:i,infer:p,capitalize:o,orEmpty:f}})(jQuery);(function(a){a.validity.outputs.tooltip={tooltipClass:"validity-tooltip",start:function(){a("."+a.validity.outputs.tooltip.tooltipClass).remove()},end:function(e){!e.valid&&a.validity.settings.scrollTo&&a(document).scrollTop(a("."+a.validity.outputs.tooltip.tooltipClass).offset().top)},raise:function(e,d){var g=e.offset();g.left+=e.width()+18;g.top+=8;var j=a('
'+d+'
').click(function(){e.focus(); -a(this).fadeOut()}).css(g).hide().appendTo("body").fadeIn();if(a.validity.settings.fadeOutTooltipsOnFocus)e.on("focus",function(){j.fadeOut()})},raiseAggregate:function(a,d){a.length&&this.raise(a.filter(":last"),d)}}})(jQuery); +a(b).is(":checked")},b||a.validity.messages.checkboxChecked)},assert:function(b,c){a.validity.registerReduction(this);var e=this.reduction||this;if(e.length)if(a.isFunction(b))return d(this,b,c||a.validity.messages.generic);else if(!b)k(e,c||a.validity.messages.generic),this.reduction=a([]);return this},fail:function(a){return this.assert(!1,a)}});q={validate:d,addToReport:g,raiseError:j,raiseAggregateError:k,numericSum:l,format:i,infer:p,capitalize:o,orEmpty:f}})(jQuery);(function(a){a.validity.outputs.tooltip={tooltipClass:"validity-tooltip",start:function(){a("."+a.validity.outputs.tooltip.tooltipClass).remove();a.validity.settings.tooltipCustomClass&&a("."+a.validity.outputs.tooltip.tooltipCustomClass).remove()},end:function(e){!e.valid&&a.validity.settings.scrollTo&&a(document).scrollTop(a("."+a.validity.outputs.tooltip.tooltipClass).offset().top)},raise:function(e,d){var g=e.offset();g.left+=e.width()+18;g.top+=8;var j='"validity-tooltip ';a.validity.settings.tooltipCustomClass&& +(j+=a.validity.settings.tooltipCustomClass);j+='"';var k=a("
"+d+'
').click(function(){e.focus();a(this).fadeOut()}).css(g).hide().appendTo("body").fadeIn();if(a.validity.settings.fadeOutTooltipsOnFocus)e.on("focus",function(){k.fadeOut()})},raiseAggregate:function(a,d){a.length&&this.raise(a.filter(":last"),d)}}})(jQuery); (function(a){function e(a){return a.attr("id")&&a.attr("id").length?a.attr("id"):a.attr("name")&&a.attr("name").length?a.attr("name"):""}a.validity.outputs.label={cssClass:"error",start:function(){a("label."+a.validity.outputs.label.cssClass).remove()},end:function(d){if(!d.valid&&a.validity.settings.scrollTo)location.hash=a("."+a.validity.outputs.label.cssClass+":eq(0)").attr("for")},raise:function(d,g){var j="."+a.validity.outputs.label.cssClass+"[for='"+e(d)+"']";if(a(j).length)a(j).text(g);else{var j= a("