webshims.register('form-core', function($, webshims, window, document, undefined, options){ "use strict"; webshims.capturingEventPrevented = function(e){ if(!e._isPolyfilled){ var isDefaultPrevented = e.isDefaultPrevented; var preventDefault = e.preventDefault; e.preventDefault = function(){ clearTimeout($.data(e.target, e.type + 'DefaultPrevented')); $.data(e.target, e.type + 'DefaultPrevented', setTimeout(function(){ $.removeData(e.target, e.type + 'DefaultPrevented'); }, 30)); return preventDefault.apply(this, arguments); }; e.isDefaultPrevented = function(){ return !!(isDefaultPrevented.apply(this, arguments) || $.data(e.target, e.type + 'DefaultPrevented') || false); }; e._isPolyfilled = true; } }; var modules = webshims.modules; var support = webshims.support; var isValid = function(elem){ return ($.prop(elem, 'validity') || {valid: 1}).valid; }; var lazyLoad = function(){ var toLoad = ['form-validation']; $(document).off('.lazyloadvalidation'); if(options.lazyCustomMessages){ options.customMessages = true; toLoad.push('form-message'); } if(webshims._getAutoEnhance(options.customDatalist)){ options.fD = true; toLoad.push('form-datalist'); } if(options.addValidators){ toLoad.push('form-validators'); } webshims.reTest(toLoad); }; /* * Selectors for all browsers */ var extendSels = function(){ var matches, matchesOverride; var exp = $.expr[":"]; var rElementsGroup = /^(?:form|fieldset)$/i; var hasInvalid = function(elem){ var ret = false; $(elem).jProp('elements').each(function(){ if(!rElementsGroup.test(this.nodeName || '')){ ret = exp.invalid(this); if(ret){ return false; } } }); return ret; }; $.extend(exp, { "valid-element": function(elem){ return rElementsGroup.test(elem.nodeName || '') ? !hasInvalid(elem) : !!($.prop(elem, 'willValidate') && isValid(elem)); }, "invalid-element": function(elem){ return rElementsGroup.test(elem.nodeName || '') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem)); }, "required-element": function(elem){ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required')); }, "user-error": function(elem){ return ($.prop(elem, 'willValidate') && $(elem).getShadowElement().hasClass((options.iVal.errorClass || 'user-error'))); }, "optional-element": function(elem){ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false); } }); ['valid', 'invalid', 'required', 'optional'].forEach(function(name){ exp[name] = $.expr[":"][name+"-element"]; }); // sizzle/jQuery has a bug with :disabled/:enabled selectors if(support.fieldsetdisabled && !$('
').find(':disabled').filter(':disabled').is(':disabled')){ matches = $.find.matches; matchesOverride = {':disabled': 1, ':enabled': 1}; $.find.matches = function(expr, elements){ if(matchesOverride[expr]){ return matches.call(this, '*'+expr, elements); } return matches.apply(this, arguments); }; $.extend(exp, { "enabled": function( elem ) { return 'disabled' in elem && elem.disabled === false && !$.find.matchesSelector(elem, 'fieldset[disabled] *'); }, "disabled": function( elem ) { return elem.disabled === true || ('disabled' in elem && $.find.matchesSelector(elem, 'fieldset[disabled] *')); } }); } //bug was partially fixed in 1.10.0 for IE9, but not IE8 (move to es5 as soon as 1.10.2 is used) if(typeof document.activeElement == 'unknown'){ var pseudoFocus = exp.focus; exp.focus = function(){ try { return pseudoFocus.apply(this, arguments); } catch(e){ webshims.error(e); } return false; }; } }; var formExtras = { noAutoCallback: true, options: options }; var addModule = webshims.loader.addModule; var lazyLoadProxy = function(obj, fn, args){ lazyLoad(); webshims.ready('form-validation', function(){ obj[fn].apply(obj, args); }); }; var transClass = ('transitionDelay' in document.documentElement.style) ? '' : ' no-transition'; var poCFG = webshims.cfg.wspopover; addModule('form-validation', $.extend({d: ['form-message']}, formExtras)); addModule('form-validators', $.extend({}, formExtras)); if(support.formvalidation && !webshims.bugs.bustedValidity){ //create delegatable events webshims.capturingEvents(['invalid'], true); } if($.expr.filters){ extendSels(); } else { webshims.ready('sizzle', extendSels); } webshims.triggerInlineForm = function(elem, event){ $(elem).trigger(event); }; if(!poCFG.position && poCFG.position !== false){ poCFG.position = { at: 'left bottom', my: 'left top', collision: 'fit flip' }; } webshims.wsPopover = { id: 0, _create: function(){ this.options = $.extend(true, {}, poCFG, this.options); this.id = webshims.wsPopover.id++; this.eventns = '.wsoverlay' + this.id; this.timers = {}; this.element = $('