(function($){$.widget("lws.lws_required",{options:{lazy:!1},_create:function(){if(this.element.data('lazy')!=undefined)
this.options.lazy=this.element.data('lazy');this.element.css('padding-left','12px');if(this.element.closest('.lws-reqborder').length){this.border=this.element.closest('.lws-reqborder');this.iconpx='1px'}else if(this.element.closest('.lws-reqinpborder').length){this.border=this.element.closest('.lws-reqinpborder');this.iconpx='0px'}else{this.border=this.element;this.iconpx='2px'}
this.icon=$("<div>",{'class':'lws-required-icon lws-icon lws-icon-lw_required'}).appendTo(this.element.parent());this.icon.css('top',this.iconpx).css('left',this.iconpx);this.element.on('focus',this._bind(this._focusElement,this));this.element.on('blur',this._bind(this._blurElement,this));if(!this.options.lazy)
this.element.prop('required',!0);},_bind:function(fn,me){return function(){return fn.apply(me,arguments)}},_focusElement:function(){this.element.removeClass('lws_required_status_ok lws_required_status_bad lws_required_status_missing');this.icon.removeClass('lws-icon lws-icon-required lws-icon lws-icon-cross lws-icon lws-icon-checkmark lws-icon lws-icon-warning').addClass('lws-icon lws-icon-required');this.icon.css('background-color','#3fa9f5');this.border.css('border-color','#3fa9f5')},_blurElement:function(){this.test()},test:function(){this._clearState();if(!this.element.val()){this._setMissing();return!1}
if(!this.isValidValue()){this._setBadFormat();return!1}
this._setOk();return!0},isValidValue:function(){if(this.element.attr('type')=='email')
this._isValidEmailAddress(this.element.val());var pattern=this.element.attr('pattern');if(pattern!=undefined&&pattern.trim()!='')
return pattern.test(this.element.val());return!0},_isValidEmailAddress:function(emailAddress){var pattern=/^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([ \t]*\r\n)?[ \t]+)?([\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]))*(([ \t]*\r\n)?[ \t]+)?")@(([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;return pattern.test(emailAddress)},_clearState:function(){this.icon.removeClass('lws-icon lws-icon-required lws-icon lws-icon-cross lws-icon lws-icon-checkmark lws-icon lws-icon-warning')},_setOk:function(){this.element.addClass('lws_required_status_ok');this.icon.addClass('lws-icon lws-icon-checkmark');this.icon.css('background-color','#2bb300');this.border.css('border-color','#2bb300')},_setMissing:function(){this.element.addClass('lws_required_status_missing');this.icon.addClass('lws-icon lws-icon-cross');this.icon.css('background-color','#cc1d25');this.border.css('border-color','#cc1d25')},_setBadFormat:function(){this.element.addClass('lws_required_status_bad');this.icon.addClass('lws-icon lws-icon-warning');this.icon.css('background-color','#ff931e');this.border.css('border-color','#ff931e')},})})(jQuery)
jQuery(function($){$(".lws-required").lws_required()})