vendor/assets/javascripts/webshims/shims/form-validators.js in webshims-rails-1.14.4 vs vendor/assets/javascripts/webshims/shims/form-validators.js in webshims-rails-1.14.5

- old
+ new

@@ -1,8 +1,13 @@ webshims.register('form-validators', function($, webshims, window, document, undefined, options){ "use strict"; -var iValClasses = '.'+ options.iVal.errorClass +', .'+options.iVal.successClass; + +var iValClasses; +webshims.ready('form-validation', function(){ + iValClasses = '.'+ options.iVal.errorClass +', .'+options.iVal.successClass; +}); + (function(){ if(webshims.refreshCustomValidityRules){ webshims.error("form-validators already included. please remove custom-validity.js"); } @@ -28,11 +33,11 @@ for(var id in elements){ elem = elements[id].elem; if(elem != noTest && elements[id].val != (val = elem.value)){ elements[id].val = val; - if($(elem).hasClass(iValClasses)){ + if(iValClasses && $.find.matchesSelector(elem, iValClasses)){ $(elem).trigger('updatevalidation.webshims'); } else { testValidityRules(elem); } } @@ -335,11 +340,11 @@ } if(data.toggle){ val = !val; } $.prop( elem, data.prop, val); - if(e){ + if(iValClasses && e){ $(elem).getShadowElement().filter(iValClasses).trigger('updatevalidation.webshims'); } }; if(!data._init || !data.masterElement){ @@ -375,15 +380,17 @@ if(data.prop !== "value" || specialVal){ $(data.masterElement.type === 'radio' && getGroupElements(data.masterElement) || data.masterElement).on('change', depFn); } else { $(data.masterElement).on('change', function(){ webshims.refreshCustomValidityRules(elem); - $(elem) - .getShadowElement() - .filter(iValClasses) - .trigger('updatevalidation.webshims') - ; + if(iValClasses){ + $(elem) + .getShadowElement() + .filter(iValClasses) + .trigger('updatevalidation.webshims') + ; + } }); } } if(data.prop == "value" && !specialVal){ @@ -414,11 +421,11 @@ $([]) ; } data.ajaxvalidate.depends.on('change', function(){ - if($(this).is(':valid')){ + if($.find.matchesSelector(this, ':valid')){ webshims.refreshCustomValidityRules(elem); } }); opts = data.ajaxvalidate; @@ -477,10 +484,10 @@ getData: function(){ var data; data = {}; data[$.prop(elem, 'name') || $.prop(elem, 'id')] = $(elem).val(); opts.depends.each(function(){ - if($(this).is(':invalid')){ + if($.find.matchesSelector(this, ':invalid')){ data = false; return false; } data[$.prop(this, 'name') || $.prop(this, 'id')] = $(this).val(); });