fbuilderjQuery = (typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery; fbuilderjQuery(function(){ (function($) { $.extend({ stringifyXX : function stringifyXX(obj) { var enc = function(param) { var escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, meta = { '\b' : '\\b', '\t' : '\\t', '\n' : '\\n', '\f' : '\\f', '\r' : '\\r', '"' : '\\"', '\\' : '\\\\' }; escapable.lastIndex = 0; return escapable.test(param) ? param.replace(escapable, function (a) { var c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) : param; }; var t = typeof (obj); if (t != "object" || obj === null) { // simple data type if (t == "string") obj = '"' + obj + '"'; return String(obj); } else { // recurse array or object var n, v, json = [], arr = (obj && obj.constructor == Array); for (n in obj) { v = obj[n]; t = typeof(v); if (t!="function") { if (t == "string") v = '"' + enc(v) + '"'; else if (t == "object" && v !== null) v = $.stringifyXX(v); json.push((arr ? "" : '"' + n + '":') + String(v)); } } return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}"); } } }); })(fbuilderjQuery); });fbuilderjQuery=(typeof fbuilderjQuery!='undefined')?fbuilderjQuery:jQuery;(function(factory){if(typeof define==="function"&&define.amd){define(["fbuilderjQuery"],factory);}else if(typeof module==="object"&&module.exports){module.exports=factory(require("fbuilderjQuery"));}else{factory(fbuilderjQuery);}}(function($){$.extend($.fn,{validate:function(options){if(!this.length){if(options&&options.debug&&window.console){console.warn("Nothing selected, can't validate, returning nothing.");} return;} var validator=$.data(this[0],"validator");if(validator){return validator;} this.attr("novalidate","novalidate");validator=new $.validator(options,this[0]);$.data(this[0],"validator",validator);if(validator.settings.onsubmit){this.on("click.validate",":submit",function(event){validator.submitButton=event.currentTarget;if($(this).hasClass("cancel")){validator.cancelSubmit=true;} if($(this).attr("formnovalidate")!==undefined){validator.cancelSubmit=true;}});this.on("submit.validate",function(event){if(validator.settings.debug){event.preventDefault();} function handle(){var hidden,result;if(validator.submitButton&&(validator.settings.submitHandler||validator.formSubmitted)){hidden=$("").attr("name",validator.submitButton.name).val($(validator.submitButton).val()).appendTo(validator.currentForm);} if(validator.settings.submitHandler){result=validator.settings.submitHandler.call(validator,validator.currentForm,event);if(hidden){hidden.remove();} if(result!==undefined){return result;} return false;} return true;} if(validator.cancelSubmit){validator.cancelSubmit=false;return handle();} if(validator.form()){if(validator.pendingRequest){validator.formSubmitted=true;return false;} return handle();}else{validator.focusInvalid();return false;}});} return validator;},valid:function(){var valid,validator,errorList;if($(this[0]).is("form")){valid=this.validate().form();}else{errorList=[];valid=true;validator=$(this[0].form).validate();this.each(function(){valid=validator.element(this)&&valid;if(!valid){errorList=errorList.concat(validator.errorList);}});validator.errorList=errorList;} return valid;},rules:function(command,argument){var element=this[0],settings,staticRules,existingRules,data,param,filtered;if(element==null){return;} if(!element.form&&element.hasAttribute("contenteditable")){element.form=this.closest("form")[0];element.name=this.attr("name");} if(element.form==null){return;} if(command){settings=$.data(element.form,"validator").settings;staticRules=settings.rules;existingRules=$.validator.staticRules(element);switch(command){case"add":$.extend(existingRules,$.validator.normalizeRule(argument));delete existingRules.messages;staticRules[element.name]=existingRules;if(argument.messages){settings.messages[element.name]=$.extend(settings.messages[element.name],argument.messages);} break;case"remove":if(!argument){delete staticRules[element.name];return existingRules;} filtered={};$.each(argument.split(/\s/),function(index,method){filtered[method]=existingRules[method];delete existingRules[method];});return filtered;}} data=$.validator.normalizeRules($.extend({},$.validator.classRules(element),$.validator.attributeRules(element),$.validator.dataRules(element),$.validator.staticRules(element)),element);if(data.required){param=data.required;delete data.required;data=$.extend({required:param},data);} if(data.remote){param=data.remote;delete data.remote;data=$.extend(data,{remote:param});} return data;}});$.extend($.expr.pseudos||$.expr[":"],{blank:function(a){return!$.trim(""+$(a).val());},filled:function(a){var val=$(a).val();return val!==null&&!!$.trim(""+val);},unchecked:function(a){return!$(a).prop("checked");}});$.validator=function(options,form){this.settings=$.extend(true,{},$.validator.defaults,options);this.currentForm=form;this.init();};$.validator.format=function(source,params){if(arguments.length===1){return function(){var args=$.makeArray(arguments);args.unshift(source);return $.validator.format.apply(this,args);};} if(params===undefined){return source;} if(arguments.length>2&¶ms.constructor!==Array){params=$.makeArray(arguments).slice(1);} if(params.constructor!==Array){params=[params];} $.each(params,function(i,n){source=source.replace(new RegExp("\\{"+i+"\\}","g"),function(){return n;});});return source;};$.extend($.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"cpefb_error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:false,focusInvalid:true,errorContainer:$([]),errorLabelContainer:$([]),onsubmit:true,ignore:":hidden",ignoreTitle:false,onfocusin:function(element){this.lastActive=element;if(this.settings.focusCleanup){if(this.settings.unhighlight){this.settings.unhighlight.call(this,element,this.settings.errorClass,this.settings.validClass);} this.hideThese(this.errorsFor(element));}},onfocusout:function(element){if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){this.element(element);}},onkeyup:function(element,event){var excludedKeys=[16,17,18,20,35,36,37,38,39,40,45,144,225];if(event.which===9&&this.elementValue(element)===""||$.inArray(event.keyCode,excludedKeys)!==-1){return;}else if(element.name in this.submitted||element.name in this.invalid){this.element(element);}},onclick:function(element){if(element.name in this.submitted){this.element(element);}else if(element.parentNode.name in this.submitted){this.element(element.parentNode);}},highlight:function(element,errorClass,validClass){if(element.type==="radio"){this.findByName(element.name).addClass(errorClass).removeClass(validClass);}else{$(element).addClass(errorClass).removeClass(validClass);}},unhighlight:function(element,errorClass,validClass){if(element.type==="radio"){this.findByName(element.name).removeClass(errorClass).addClass(validClass);}else{$(element).removeClass(errorClass).addClass(validClass);}}},setDefaults:function(settings){$.extend($.validator.defaults,settings);},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:$.validator.format("Please enter no more than {0} characters."),minlength:$.validator.format("Please enter at least {0} characters."),rangelength:$.validator.format("Please enter a value between {0} and {1} characters long."),range:$.validator.format("Please enter a value between {0} and {1}."),max:$.validator.format("Please enter a value less than or equal to {0}."),min:$.validator.format("Please enter a value greater than or equal to {0}."),step:$.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:false,prototype:{init:function(){this.labelContainer=$(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm);this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var groups=(this.groups={}),rules;$.each(this.settings.groups,function(key,value){if(typeof value==="string"){value=value.split(/\s/);} $.each(value,function(index,name){groups[name]=key;});});rules=this.settings.rules;$.each(rules,function(key,value){rules[key]=$.validator.normalizeRule(value);});function delegate(event){if(!this.form&&this.hasAttribute("contenteditable")){this.form=$(this).closest("form")[0];this.name=$(this).attr("name");} var validator=$.data(this.form,"validator"),eventType="on"+event.type.replace(/^validate/,""),settings=validator.settings;if(settings[eventType]&&!$(this).is(settings.ignore)){settings[eventType].call(validator,this,event);}} $(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], "+"[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], "+"[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], "+"[type='radio'], [type='checkbox'], [contenteditable], [type='button']",delegate).on("click.validate","select, option, [type='radio'], [type='checkbox']",delegate);if(this.settings.invalidHandler){$(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler);}},form:function(){this.checkForm();$.extend(this.submitted,this.errorMap);this.invalid=$.extend({},this.errorMap);if(!this.valid()){$(this.currentForm).triggerHandler("invalid-form",[this]);} this.showErrors();return this.valid();},checkForm:function(){this.prepareForm();for(var i=0,elements=(this.currentElements=this.elements());elements[i];i++){this.check(elements[i]);} return this.valid();},element:function(element){var cleanElement=this.clean(element),checkElement=this.validationTargetFor(cleanElement),v=this,result=true,rs,group;if(checkElement===undefined){delete this.invalid[cleanElement.name];}else{this.prepareElement(checkElement);this.currentElements=$(checkElement);group=this.groups[checkElement.name];if(group){$.each(this.groups,function(name,testgroup){if(testgroup===group&&name!==checkElement.name){cleanElement=v.validationTargetFor(v.clean(v.findByName(name)));if(cleanElement&&cleanElement.name in v.invalid){v.currentElements.push(cleanElement);result=v.check(cleanElement)&&result;}}});} rs=this.check(checkElement)!==false;result=result&&rs;if(rs){this.invalid[checkElement.name]=false;}else{this.invalid[checkElement.name]=true;} if(!this.numberOfInvalids()){this.toHide=this.toHide.add(this.containers);} this.showErrors();$(element).attr("aria-invalid",!rs);} return result;},showErrors:function(errors){if(errors){var validator=this;$.extend(this.errorMap,errors);this.errorList=$.map(this.errorMap,function(message,name){return{message:message,element:validator.findByName(name)[0]};});this.successList=$.grep(this.successList,function(element){return!(element.name in errors);});} if(this.settings.showErrors){this.settings.showErrors.call(this,this.errorMap,this.errorList);}else{this.defaultShowErrors();}},resetForm:function(){if($.fn.resetForm){$(this.currentForm).resetForm();} this.invalid={};this.submitted={};this.prepareForm();this.hideErrors();var elements=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(elements);},resetElements:function(elements){var i;if(this.settings.unhighlight){for(i=0;elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,"");this.findByName(elements[i].name).removeClass(this.settings.validClass);}}else{elements.removeClass(this.settings.errorClass).removeClass(this.settings.validClass);}},numberOfInvalids:function(){return this.objectLength(this.invalid);},objectLength:function(obj){var count=0,i;for(i in obj){if(obj[i]!==undefined&&obj[i]!==null&&obj[i]!==false){count++;}} return count;},hideErrors:function(){this.hideThese(this.toHide);},hideThese:function(errors){/**errors.not(this.containers).text("");*/this.addWrapper(errors).hide();},valid:function(){return this.size()===0;},size:function(){return this.errorList.length;},focusInvalid:function(){if(this.settings.focusInvalid){try{$(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin");}catch(e){}}},findLastActive:function(){var lastActive=this.lastActive;return lastActive&&$.grep(this.errorList,function(n){return n.element.name===lastActive.name;}).length===1&&lastActive;},elements:function(){var validator=this,rulesCache={};return $(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter(function(){var name=this.name||$(this).attr("name");if(!name&&validator.settings.debug&&window.console){console.error("%o has no name assigned",this);} if(this.hasAttribute("contenteditable")){this.form=$(this).closest("form")[0];this.name=name;} if(name in rulesCache||!validator.objectLength($(this).rules())){return false;} rulesCache[name]=true;return true;});},clean:function(selector){return $(selector)[0];},errors:function(){var errorClass=this.settings.errorClass.split(" ").join(".");return $(this.settings.errorElement+"."+errorClass,this.errorContext);},resetInternals:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=$([]);this.toHide=$([]);},reset:function(){this.resetInternals();this.currentElements=$([]);},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers);},prepareElement:function(element){this.reset();this.toHide=this.errorsFor(element);},elementValue:function(element){var $element=$(element),type=element.type,val,idx;if(type==="radio"||type==="checkbox"){return this.findByName(element.name).filter(":checked").val();}else if(type==="number"&&typeof element.validity!=="undefined"){return element.validity.badInput?"NaN":$element.val();} if(element.hasAttribute("contenteditable")){val=$element.text();}else{val=$element.val();} if(type==="file"){if(val.substr(0,12)==="C:\\fakepath\\"){return val.substr(12);} idx=val.lastIndexOf("/");if(idx>=0){return val.substr(idx+1);} idx=val.lastIndexOf("\\");if(idx>=0){return val.substr(idx+1);} return val;} if(typeof val==="string"){return val.replace(/\r/g,"");} return val;},check:function(element){element=this.validationTargetFor(this.clean(element));var rules=$(element).rules(),rulesCount=$.map(rules,function(n,i){return i;}).length,dependencyMismatch=false,val=this.elementValue(element),result,method,rule,normalizer;if(typeof rules.normalizer==="function"){normalizer=rules.normalizer;}else if(typeof this.settings.normalizer==="function"){normalizer=this.settings.normalizer;} if(normalizer){val=normalizer.call(element,val);if(typeof val!=="string"){throw new TypeError("The normalizer should return a string value.");} delete rules.normalizer;} for(method in rules){rule={method:method,parameters:rules[method]};try{result=$.validator.methods[method].call(this,val,element,rule.parameters);if(result==="dependency-mismatch"&&rulesCount===1){dependencyMismatch=true;continue;} dependencyMismatch=false;if(result==="pending"){this.toHide=this.toHide.not(this.errorsFor(element));return;} if(!result){this.formatAndAdd(element,rule);return false;}}catch(e){if(this.settings.debug&&window.console){console.log("Exception occurred when checking element "+element.id+", check the '"+rule.method+"' method.",e);} if(e instanceof TypeError){e.message+=". Exception occurred when checking element "+element.id+", check the '"+rule.method+"' method.";} throw e;}} if(dependencyMismatch){return;} if(this.objectLength(rules)){this.successList.push(element);} return true;},customDataMessage:function(element,method){return $(element).data("msg"+method.charAt(0).toUpperCase()+ method.substring(1).toLowerCase())||$(element).data("msg");},customMessage:function(name,method){var m=this.settings.messages[name];return m&&(m.constructor===String?m:m[method]);},findDefined:function(){for(var i=0;iWarning: No message defined for "+element.name+""),theregex=/\$?\{(\d+)\}/g;if(typeof message==="function"){message=message.call(this,rule.parameters,element);}else if(theregex.test(message)){message=$.validator.format(message.replace(theregex,"{$1}"),rule.parameters);} return message;},formatAndAdd:function(element,rule){var message=this.defaultMessage(element,rule);this.errorList.push({message:message,element:element,method:rule.method});this.errorMap[element.name]=message;this.submitted[element.name]=message;},addWrapper:function(toToggle){if(this.settings.wrapper){toToggle=toToggle.add(toToggle.parent(this.settings.wrapper));} return toToggle;},defaultShowErrors:function(){var i,elements,error;for(i=0;this.errorList[i];i++){error=this.errorList[i];if(this.settings.highlight){this.settings.highlight.call(this,error.element,this.settings.errorClass,this.settings.validClass);} this.showLabel(error.element,error.message);} if(this.errorList.length){this.toShow=this.toShow.add(this.containers);} if(this.settings.success){for(i=0;this.successList[i];i++){this.showLabel(this.successList[i]);}} if(this.settings.unhighlight){for(i=0,elements=this.validElements();elements[i];i++){this.settings.unhighlight.call(this,elements[i],this.settings.errorClass,this.settings.validClass);}} this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show();},validElements:function(){return this.currentElements.not(this.invalidElements());},invalidElements:function(){return $(this.errorList).map(function(){return this.element;});},showLabel:function(element,message){var place,group,errorID,v,error=this.errorsFor(element),elementID=this.idOrName(element),describedBy=$(element).attr("aria-describedby");if(error.length){error.removeClass(this.settings.validClass).addClass(this.settings.errorClass);error.html(message);}else{error=$("<"+this.settings.errorElement+">").attr("id",elementID+"-error").addClass(this.settings.errorClass).html(message||"");place=error;if(this.settings.wrapper){place=error.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();} if(this.labelContainer.length){this.labelContainer.append(place);}else if(this.settings.errorPlacement){this.settings.errorPlacement.call(this,place,$(element));}else{place.insertAfter(element);} if(error.is("label")){error.attr("for",elementID);}else if(error.parents("label[for='"+this.escapeCssMeta(elementID)+"']").length===0){errorID=error.attr("id");if(!describedBy){describedBy=errorID;}else if(!describedBy.match(new RegExp("\\b"+this.escapeCssMeta(errorID)+"\\b"))){describedBy+=" "+errorID;} $(element).attr("aria-describedby",describedBy);group=this.groups[element.name];if(group){v=this;$.each(v.groups,function(name,testgroup){if(testgroup===group){$("[name='"+v.escapeCssMeta(name)+"']",v.currentForm).attr("aria-describedby",error.attr("id"));}});}}} if(!message&&this.settings.success){error.text("");if(typeof this.settings.success==="string"){error.addClass(this.settings.success);}else{this.settings.success(error,element);}} this.toShow=this.toShow.add(error);},errorsFor:function(element){var name=this.escapeCssMeta(this.idOrName(element)),describer=$(element).attr("aria-describedby"),selector="label[for='"+name+"'], label[for='"+name+"'] *";if(describer){selector=selector+", #"+this.escapeCssMeta(describer).replace(/\s+/g,", #");} return this.errors().filter(selector);},escapeCssMeta:function(string){return string.replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1");},idOrName:function(element){return this.groups[element.name]||(this.checkable(element)?element.name:element.id||element.name);}, validationTargetFor:function(element){if(this.checkable(element)){element=this.findByName(element.name);} return $(element).not(this.settings.ignore)[0];},checkable:function(element){return(/radio|checkbox/i).test(element.type);},findByName:function(name){return $(this.currentForm).find("[name='"+this.escapeCssMeta(name)+"']");},getLength:function(value,element){switch(element.nodeName.toLowerCase()){case"select":return $("option:selected",element).length;case"input":if(this.checkable(element)){return this.findByName(element.name).filter(":checked").length;}} return value.length;},depend:function(param,element){return this.dependTypes[typeof param]?this.dependTypes[typeof param](param,element):true;},dependTypes:{"boolean":function(param){return param;},"string":function(param,element){return!!$(param,element.form).length;},"function":function(param,element){return param(element);}},optional:function(element){var val=this.elementValue(element);return!$.validator.methods.required.call(this,val,element)&&"dependency-mismatch";},startRequest:function(element){if(!this.pending[element.name]){this.pendingRequest++;$(element).addClass(this.settings.pendingClass);this.pending[element.name]=true;}},stopRequest:function(element,valid){this.pendingRequest--;if(this.pendingRequest<0){this.pendingRequest=0;} delete this.pending[element.name];$(element).removeClass(this.settings.pendingClass);if(valid&&this.pendingRequest===0&&this.formSubmitted&&this.form()){$(this.currentForm).submit();if(this.submitButton){$("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove();} this.formSubmitted=false;}else if(!valid&&this.pendingRequest===0&&this.formSubmitted){$(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted=false;}},previousValue:function(element,method){method=typeof method==="string"&&method||"remote";return $.data(element,"previousValue")||$.data(element,"previousValue",{old:null,valid:true,message:this.defaultMessage(element,{method:method})});},destroy:function(){this.resetForm();$(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur");}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},number:{number:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(className,rules){if(className.constructor===String){this.classRuleSettings[className]=rules;}else{$.extend(this.classRuleSettings,className);}},classRules:function(element){var rules={},classes=$(element).attr("class");if(classes){$.each(classes.split(" "),function(){if(this in $.validator.classRuleSettings){$.extend(rules,$.validator.classRuleSettings[this]);}});} return rules;},normalizeAttributeRule:function(rules,type,method,value){if(/min|max|step/.test(method)&&(type===null||/number|range|text/.test(type))){if(!/^\s*$/.test(value))value=Number(value);if(isNaN(value)){value=undefined;}} if(value||value===0){rules[method]=value;}else if(type===method&&type!=="range"){rules[method]=true;}},attributeRules:function(element){var rules={},$element=$(element),type=element.getAttribute("type"),method,value;for(method in $.validator.methods){if(method==="required"){value=element.getAttribute(method);if(value===""){value=true;} value=!!value;}else{value=$element.attr(method);} this.normalizeAttributeRule(rules,type,method,value);} if(rules.maxlength&&/-1|2147483647|524288/.test(rules.maxlength)){delete rules.maxlength;} return rules;},dataRules:function(element){var rules={},$element=$(element),type=element.getAttribute("type"),method,value;for(method in $.validator.methods){value=$element.data("rule"+method.charAt(0).toUpperCase()+method.substring(1).toLowerCase());this.normalizeAttributeRule(rules,type,method,value);} return rules;},staticRules:function(element){var rules={},validator=$.data(element.form,"validator");if(validator.settings.rules){rules=$.validator.normalizeRule(validator.settings.rules[element.name])||{};} return rules;},normalizeRules:function(rules,element){$.each(rules,function(prop,val){if(val===false){delete rules[prop];return;} if(val.param||val.depends){var keepRule=true;switch(typeof val.depends){case"string":keepRule=!!$(val.depends,element.form).length;break;case"function":keepRule=val.depends.call(element,element);break;} if(keepRule){rules[prop]=val.param!==undefined?val.param:true;}else{$.data(element.form,"validator").resetElements($(element));delete rules[prop];}}});$.each(rules,function(rule,parameter){rules[rule]=$.isFunction(parameter)&&rule!=="normalizer"?parameter(element):parameter;});$.each(["minlength","maxlength"],function(){if(rules[this]){rules[this]=Number(rules[this]);}});$.each(["rangelength","range"],function(){var parts;if(rules[this]){if($.isArray(rules[this])){rules[this]=[Number(rules[this][0]),Number(rules[this][1])];}else if(typeof rules[this]==="string"){parts=rules[this].replace(/[\[\]]/g,"").split(/[\s,]+/);rules[this]=[Number(parts[0]),Number(parts[1])];}}});if($.validator.autoCreateRanges){if(rules.min!=null&&rules.max!=null){rules.range=[rules.min,rules.max];delete rules.min;delete rules.max;} if(rules.minlength!=null&&rules.maxlength!=null){rules.rangelength=[rules.minlength,rules.maxlength];delete rules.minlength;delete rules.maxlength;}} return rules;},normalizeRule:function(data){if(typeof data==="string"){var transformed={};$.each(data.split(/\s/),function(){transformed[this]=true;});data=transformed;} return data;},addMethod:function(name,method,message){$.validator.methods[name]=method;$.validator.messages[name]=message!==undefined?message:$.validator.messages[name];if(method.length<3){$.validator.addClassRules(name,$.validator.normalizeRule(name));}},methods:{required:function(value,element,param){if(!this.depend(param,element)){return"dependency-mismatch";} if(element.nodeName.toLowerCase()==="select"){var val=$(element).val();return val&&val.length>0;} if(this.checkable(element)){return this.getLength(value,element)>0;} return value.length>0;},email:function(value,element){return this.optional(element)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value);},url:function(value,element){return this.optional(element)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value);},date:function(value,element){return this.optional(element)||!/Invalid|NaN/.test(new Date(value).toString());},dateISO:function(value,element){return this.optional(element)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value);},number:function(value,element){return this.optional(element)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);},digits:function(value,element){return this.optional(element)||/^\d+$/.test(value);},minlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||length>=param;},maxlength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||length<=param;},rangelength:function(value,element,param){var length=$.isArray(value)?value.length:this.getLength(value,element);return this.optional(element)||(length>=param[0]&&length<=param[1]);},min:function(value,element,param){return this.optional(element)||value>=param;},max:function(value,element,param){return this.optional(element)||value<=param;},range:function(value,element,param){return this.optional(element)||(value>=param[0]&&value<=param[1]);},step:function(value,element,param){var type=$(element).attr("type"),errorMessage="Step attribute on input type "+type+" is not supported.",supportedTypes=["text","number","range"],re=new RegExp("\\b"+type+"\\b"),notSupported=type&&!re.test(supportedTypes.join()),decimalPlaces=function(num){var match=(""+num).match(/(?:\.(\d+))?$/);if(!match){return 0;} return match[1]?match[1].length:0;},toInt=function(num){return Math.round(num*Math.pow(10,decimals));},valid=true,decimals;if(notSupported){throw new Error(errorMessage);} decimals=decimalPlaces(param);if(decimalPlaces(value)>decimals||toInt(value)%toInt(param)!==0){valid=false;} return this.optional(element)||valid;},equalTo:function(value,element,param){var target=$(param);if(this.settings.onfocusout&&target.not(".validate-equalTo-blur").length){target.addClass("validate-equalTo-blur").on("blur.validate-equalTo",function(){$(element).valid();});} return value===target.val();},remote:function(value,element,param,method){if(this.optional(element)){return"dependency-mismatch";} method=typeof method==="string"&&method||"remote";var previous=this.previousValue(element,method),validator,data,optionDataString;if(!this.settings.messages[element.name]){this.settings.messages[element.name]={};} previous.originalMessage=previous.originalMessage||this.settings.messages[element.name][method];this.settings.messages[element.name][method]=previous.message;param=typeof param==="string"&&{url:param}||param;optionDataString=$.param($.extend({data:value},param.data));if(previous.old===optionDataString){return previous.valid;} previous.old=optionDataString;validator=this;this.startRequest(element);data={};data[element.name]=value;$.ajax($.extend(true,{mode:"abort",port:"validate"+element.name,dataType:"json",data:data,context:validator.currentForm,success:function(response){var valid=response===true||response==="true",errors,message,submitted;validator.settings.messages[element.name][method]=previous.originalMessage;if(valid){submitted=validator.formSubmitted;validator.resetInternals();validator.toHide=validator.errorsFor(element);validator.formSubmitted=submitted;validator.successList.push(element);validator.invalid[element.name]=false;validator.showErrors();}else{errors={};message=response||validator.defaultMessage(element,{method:method,parameters:value});errors[element.name]=previous.message=message;validator.invalid[element.name]=true;validator.showErrors(errors);} previous.valid=valid;validator.stopRequest(element,valid);}},param));return"pending";}}});var pendingRequests={},ajax;if($.ajaxPrefilter){$.ajaxPrefilter(function(settings,_,xhr){var port=settings.port;if(settings.mode==="abort"){if(pendingRequests[port]){pendingRequests[port].abort();} pendingRequests[port]=xhr;}});}else{ajax=$.ajax;$.ajax=function(settings){var mode=("mode"in settings?settings:$.ajaxSettings).mode,port=("port"in settings?settings:$.ajaxSettings).port;if(mode==="abort"){if(pendingRequests[port]){pendingRequests[port].abort();} pendingRequests[port]=ajax.apply(this,arguments);return pendingRequests[port];} return ajax.apply(this,arguments);};} return $;}));fbuilderjQuery = (typeof fbuilderjQuery != 'undefined' ) ? fbuilderjQuery : jQuery; fbuilderjQuery(function(){ (function($) { // Namespace of fbuilder $.fbuilder = $.fbuilder || {}; $.fbuilder[ 'objName' ] = 'fbuilderjQuery'; $.fbuilder[ 'controls' ] = ( typeof $.fbuilder[ 'controls' ] != 'undefined' ) ? $.fbuilder[ 'controls' ]: {}; $.fbuilder[ 'forms' ] = ( typeof $.fbuilder[ 'forms' ] != 'undefined' ) ? $.fbuilder[ 'forms' ]: {}; $.fbuilder[ 'htmlEncode' ] = function(value) { value = $('
').text(value).html() value = value.replace( /&/g, '&').replace(/"/g, """); return value; }; $.fbuilder[ 'configValidate' ] = function(elem) { elem.validate({ ignore:".ignore,.ignorepb", errorElement: "div", errorClass:"cpefb_error", errorPlacement: function(e, element) { if (element.parents(".dfield").find(".cpefb_error.message").not("[style]").length>0) return; e.insertAfter(element.parents(".dfield").children().last()); e.addClass("message"); } }); }; $.fbuilder['htmlDecode']=function(value) { if(/&(?:#x[a-f0-9]+|#[0-9]+|[a-z0-9]+);?/ig.test(value))value=$('
').html(value).text();return value; }; $.fbuilder[ 'escape_symbol' ] = function( value ) // Escape the symbols used in regulars expressions { return value.replace(/([\^\$\-\.\,\[\]\(\)\/\\\*\?\+\!\{\}])/g, "\\$1"); }; $.fbuilder[ 'parseValStr' ] = function( value ) { return '"' + value.replace(/'/g, "\\'").replace( /\$/g, '') + '"'; }; $.fbuilder[ 'parseVal' ] = function( value, thousandSeparator, decimalSymbol ) { if( value == '' ) return 0; value += ''; thousandSeparator = new RegExp( $.fbuilder.escape_symbol( ( typeof thousandSeparator == 'undefined' ) ? ',' : thousandSeparator ), 'g' ); decimalSymbol = new RegExp( $.fbuilder.escape_symbol( ( typeof decimalSymbol == 'undefined' ) ? '.' : decimalSymbol ), 'g' ); var t = value.replace( thousandSeparator, '' ).replace( decimalSymbol, '.' ).replace( /\s/g, '' ), p = /[+-]?((\d+(\.\d+)?)|(\.\d+))/.exec( t ); return ( p ) ? p[0]*1 : $.fbuilder[ 'parseValStr' ]( value ); }; $.fn.fbuilder = function(options){ var opt = $.extend({}, { pub:false, identifier:"", title:"" },options, true); opt.messages = $.extend({ previous: "Previous", next: "Next", pageof: "Page {0} of {0}", required: "This field is required.", email: "Please enter a valid email address.", datemmddyyyy: "Please enter a valid date with this format(mm/dd/yyyy)", dateddmmyyyy: "Please enter a valid date with this format(dd/mm/yyyy)", number: "Please enter a valid number.", digits: "Please enter only digits.", maxlength: $.validator.format("Please enter no more than {0} characters"), minlength: $.validator.format("Please enter at least {0} characters."), equalTo: "Please enter the same value again.", max: $.validator.format("Please enter a value less than or equal to {0}."), min: $.validator.format("Please enter a value greater than or equal to {0}.") },opt.messages); opt.messages.max = $.validator.format(opt.messages.max); opt.messages.min = $.validator.format(opt.messages.min); $.extend($.validator.messages, opt.messages); var items = []; var reloadItemsPublic = function() { $("#fieldlist"+opt.identifier).closest( 'form' ).addClass( theForm.formtemplate ); $("#fieldlist"+opt.identifier).html("").addClass(theForm.formlayout); $("#formheader"+opt.identifier).html(theForm.show()); var page = 0; $("#fieldlist"+opt.identifier).append('
'); for (var i=0;i
'); } else { $("#fieldlist"+opt.identifier+" .pb"+page).append(items[i].show()); if (items[i].predefinedClick) { $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).attr("placeholder",items[i].predefined); $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).attr("value",""); } if (items[i].userhelpTooltip) { var uh = $("#fieldlist"+opt.identifier+" .pb"+page).find("#"+items[i].name).closest(".fields"); uh.find(".uh").css("display","none"); if (uh.find(".uh").text()!="") { uh.attr("uh",uh.find(".uh").text()); } } } } if (page>0) { $("#fieldlist"+opt.identifier+" .pb"+page).addClass("pbEnd"); $("#fieldlist"+opt.identifier+" .pbreak").each(function(index) { var code = $(this).html(); var bSubmit = ''; if (index == page) { if ( $( "#cpcaptchalayer"+opt.identifier ).length && !/^\s*$/.test( $( "#cpcaptchalayer"+opt.identifier ).html() ) ) { code += '
'+$("#cpcaptchalayer"+opt.identifier).html()+'
'; $("#cpcaptchalayer"+opt.identifier).html(""); } if ($("#cp_subbtn"+opt.identifier).html()) { bSubmit = ''; } } $(this).html('
'+opt.messages.pageof.replace( /\{\s*\d+\s*\}/, (index+1) ).replace( /\{\s*\d+\s*\}/, (page+1) )+''+code+'
'+opt.messages.previous+'
'+opt.messages.next+'
'+bSubmit+'
'); }); $( '#fieldlist'+opt.identifier).find(".pbPrevious,.pbNext").bind("click", { 'identifier' : opt.identifier }, function( evt ) { var identifier = evt.data.identifier; function focusTop(){try {$('html, body').animate({scrollTop: $("#fieldlist"+identifier+" .pb"+page).find("fieldset").offset().top}, 100);}catch(e){}} if ( ($(this).hasClass("pbPrevious")) || (($(this).hasClass("pbNext")) && $(this).parents("form").valid()) ) { var page = parseInt($(this).parents(".pbreak").attr("page")); (($(this).hasClass("pbPrevious"))?page--:page++); $("#fieldlist"+identifier+" .pbreak").css("display","none"); $("#fieldlist"+identifier+" .pbreak").find(".field").addClass("ignorepb"); $("#fieldlist"+identifier+" .pb"+page).css("display","block"); $("#fieldlist"+identifier+" .pb"+page).find(".field").removeClass("ignorepb"); if ($("#fieldlist"+identifier+" .pb"+page).find(".field").length>0) { try { if ($("#fieldlist"+identifier+" .pb"+page).find(".field").is(":visible")) $("#fieldlist"+identifier+" .pb"+page).find(".field")[0].focus(); else focusTop(); } catch(e){focusTop()} } else focusTop(); } else { $(this).parents("form").validate().focusInvalid(); } return false; }); } else { if ( $( "#cpcaptchalayer"+opt.identifier ).length && !/^\s*$/.test( $( "#cpcaptchalayer"+opt.identifier ).html() ) ) { $("#fieldlist"+opt.identifier+" .pb"+page).append('
'+$("#cpcaptchalayer"+opt.identifier).html()+'
'); $("#cpcaptchalayer"+opt.identifier).html(""); } if ($("#cp_subbtn"+opt.identifier).html()) { $("#fieldlist"+opt.identifier+" .pb"+page).append(''); } } // Set Captcha Event $( document ).on( 'click', '#fbuilder .captcha img', function(){ var e = $( this ); e.attr( 'src', e.attr( 'src' ).replace( /&\d+$/, '' ) + '&' + Math.floor( Math.random()*1000 ) ); } ); $( document ).on("click","#fieldlist"+opt.identifier+" .pbSubmit", function( evt ) { $("#fieldlist"+opt.identifier+" .pbSubmit").closest("form").submit(); }); if (i>0) { theForm.after_show( opt.identifier ); for (var i=0;i'+(this.title!=''?'

'+this.title+'

':'')+(this.description!=''?''+this.description+'':'')+'
'; }, after_show:function( id ){ $( '#cp_calculatedfieldsf_pform'+id ).attr( 'data-evalequations', this.evalequations ).attr( 'autocomplete', ( ( this.autocomplete ) ? 'on' : 'off' ) ); } }); //var theForm = new fform(), var theForm, ffunct = { getItem: function( name ) { for( var i in items ) { if( items[ i ].name == name ) { return items[ i ]; } } return false; }, getItems: function() { return items; }, loadData:function(f) { var d, e = $("#"+f); this.formId = e.parents( 'form' ).attr( 'id' ); if ( d = $.parseJSON( e.val() )) { if (d.length==2) { items = []; for (var i=0;i
'+this.userhelp+'
'; } } ); $.fbuilder.controls[ 'femail' ] = function(){}; $.extend( $.fbuilder.controls[ 'femail' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Email", ftype:"femail", predefined:"", predefinedClick:false, required:false, size:"medium", equalTo:"", show:function() { return '
'+this.userhelp+'
'; }, val:function() { var e = $( '[id="' + this.name + '"]:not(.ignore)' ); if( e.length ) return $.fbuilder.parseValStr( e.val() ); return ''; } } );$.fbuilder.controls[ 'fapp' ] = function(){}; $.extend( $.fbuilder.controls[ 'fapp' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Number", ftype:"fapp", services:new Array({name:"Service 1",price:1,capacity:1,duration:60,pb:0,pa:0,ohindex:0}), /*openhours:new Array({type:"all",d:"",h1:8,m1:0,h2:17,m2:0}),new Array({name:"Default",openhours:new Array({type:"all",d:"",h1:8,m1:0,h2:17,m2:0})})*/ openhours:new Array(), allOH:new Array({name:"Default",openhours:new Array({type:"all",d:"",h1:8,m1:0,h2:17,m2:0})}), usedSlots:new Array(), dateFormat:"mm/dd/yy", showDropdown:false, showTotalCost:false, showTotalCostFormat:"$ {0}", showEndTime:false, usedSlotsCheckbox:false, avoidOverlaping:true, emptySelectCheckbox:false, emptySelect:"-- Please select service --", dropdownRange:"-10:+10", working_dates:[true,true,true,true,true,true,true], numberOfMonths:1, maxNumberOfApp:0, showAllServices:false, allowDifferentQuantities:false, allowSelectSameSlot:false, firstDay:0, minDate:"0", maxDate:"", defaultDate:"", invalidDates:"", required:true, bSlotsCheckbox: true, bSlots:30, militaryTime:1, cacheArr:new Array(), getD:new Date(), formId:0, getMinDate:"", getMaxDate:"", arr:new Array(), allUsedSlots:new Array(), service_selected:0, quantity_selected:1, tz:0, tzCache:[], loadOK:false, ignoreUsedSlots:false, initialapp:"", initialID:0, pctByDay:new Array(), htmlUsedSlots:new Array(), extras:0, sub_cost:0, percent:0, notShowBookedDate:true, showWeek:false, autonum:0, availableSlotsByService:[], slotsDate:[], getSplittedSlots:function(d,s) { function splitSlots (a,serviceindex) { var dots = new Array(); for (var i=0;ia[j].t1 && sa[j].t1 && e 0) ind--; return ind; }, show:function() { return '
'+this.userhelp+'
'; }, tzf: function(d) { function getTZ(o,d) { var tz = ((new Date($.datepicker.parseDate("yy-mm-dd",d).getTime()+12*60*60*1000)).getTimezoneOffset() * -1)/60 - parseFloat(cp_hourbk_timezone); if (typeof cp_hourbk_observedaylight !== 'undefined' && cp_hourbk_observedaylight) { try{ if ($.datepicker.parseDate("yy-mm-dd",cp_hourbk_daylightnextchange).getTime() <= $.datepicker.parseDate("yy-mm-dd",d).getTime()) tz += parseFloat(cp_hourbk_daylightnexaction); }catch (e) {} } o.tzCache[d] = tz; return tz; } return (typeof cp_hourbk_timezone !== 'undefined')?((typeof this.tzCache[d] !== 'undefined')?this.tzCache[d]:getTZ(this,d)):this.tz; }, getSpecialDays:function() { var me = this; var a = new Array(); if (!me.emptySelectCheckbox || (me.emptySelectCheckbox && $(".fieldCalendarService"+me.name+" select option:selected").index() > 0 )) { var ohindex = me.services[me.normalizeSelectIndex($(".fieldCalendarService"+me.name+" select option:selected").index())].ohindex; for (var i=0;i= a[i].t2) a[i].t2 += 24 * 60; } }, initcacheOpenHours: function() { var me = this; for (j=0;j=arr[i].t2) arr[i].t2 += 24 * 60; } if (me.ignoreUsedSlots) var data2 = $.merge(data1.slice(0),[]); else { me.usedSlots[d] = me.usedSlots[d] || []; var data2 = $.merge(data1.slice(0),me.usedSlots[d]); var t = $.datepicker.parseDate("yy-mm-dd", d); t.setDate(t.getDate() - 1); var bd = $.datepicker.formatDate("yy-mm-dd", t); me.usedSlots[bd] = me.usedSlots[bd] || []; for (var i=0;i me.usedSlots[bd][i].h2 && me.usedSlots[bd][i].h2!=0) || me.usedSlots[bd][i].h2>24) { if (me.usedSlots[bd][i].h1>me.usedSlots[bd][i].h2) me.usedSlots[bd][i].h2 += 24; var obj = jQuery.extend({}, me.usedSlots[bd][i]); obj.h2 = me.usedSlots[bd][i].h2 - 24; obj.h1 = 0;obj.m1 = 0; obj.d = d; data2[data2.length] = obj; } } } for (var i=0;idata[i].t2) data[i].t2 += 24 * 60; } if (typeof cp_hourbk_cmpublic !== 'undefined') data = me.getSplittedSlots(data,s); data = me.getCompatSlots(data); for (var i=0;icapacity_service || (data[i].service.length==0 || (data[i].service.length && data[i].service[0]!=s))) //|| (!me.avoidOverlaping && (data[i].quantity+me.quantity_selected>capacity_service && (typeof data[i].serviceindex === 'undefined' || data[i].serviceindex==s)) )) || (!me.avoidOverlaping && ((data[i].quantity+me.quantity_selected>capacity_service && data[i].serviceindex==s) || typeof data[i].serviceindex === 'undefined') )) { for (var j=0;j arr[j].t1) && (data[i].t1 < arr[j].t2) && (data[i].t2 > arr[j].t1) && (data[i].t2 < arr[j].t2)) { var v1 = {t1:arr[j].t1, t2:data[i].t1, h1:arr[j].h1, h2:data[i].h1, m1:arr[j].m1, m2:data[i].m1}; var v2 = {t1:data[i].t2, t2:arr[j].t2, h1:data[i].h2, h2:arr[j].h2, m1:data[i].m2, m2:arr[j].m2}; arr.splice(j, 1, v1, v2); j--; } else if ((data[i].t1 > arr[j].t1) && (data[i].t1 < arr[j].t2)) { arr[j].t2 = data[i].t1; arr[j].h2 = data[i].h1; arr[j].m2 = data[i].m1; } else if ((data[i].t2 > arr[j].t1) && (data[i].t2 < arr[j].t2)) { arr[j].t1 = data[i].t2; arr[j].h1 = data[i].h2; arr[j].m1 = data[i].m2; } else if ((data[i].t1 <= arr[j].t1) && (data[i].t2 >= arr[j].t2)) { arr.splice(j, 1); j--; } } } } for (var i=0;i=0;i--) { if ($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+arr[i].t2*60*1000 <= currenttime) arr.splice(i, 1 ); else if ($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+arr[i].t1*60*1000 <= currenttime) { var st = arr[i].t1;//var st = arr[i].t1 + duration + me.pb + me.pa; while ($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime() + st*60*1000 < currenttime) { if (!me.bSlotsCheckbox) st += me.bduration; else st += duration + me.pb + me.pa; //st += duration + me.pb + me.pa; } var m1 = st % 60; var h1 = (st - m1)/60; arr[i].t1 = st; arr[i].h1 = h1; arr[i].m1 = m1; } } } if (me.maxDate!=="" && me.getMaxDate!="") { var current = me.getMaxDate; var currenttime = current.getTime()+me.tzf(d)*60*60*1000; for (var i=arr.length-1;i>=0;i--) { if ($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+arr[i].t1*60*1000 >= currenttime) arr.splice(i, 1 ); else if ($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+arr[i].t2*60*1000 >= currenttime) { var et = arr[i].t1; while ($.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime() + (et + duration)*60*1000 <= currenttime) et += duration; var m2 = et % 60; var h2 = (et - m2)/60; arr[i].t2 = et; arr[i].h2 = h2; arr[i].m2 = m2; } } } for (var i=arr.length-1;i>=0;i--) if (arr[i].t1+duration + me.pb + me.pa > arr[i].t2 || arr[i].t1 > 24*60) //if (arr[i].t1+duration > arr[i].t2 || arr[i].t1 > 24*60) arr.splice(i, 1 ); return arr; }, formattime: function(t,mt)/*mt=2 for database 09:00*/ { if (t<0) t+=(24*60); t = t % (24*60); var h = Math.floor(t/60); var m = t%60; var suffix = ""; if (mt==0) { if (h>12) { h = h-12; suffix = " PM"; } else if (h==12) suffix = " PM"; else { if (h==0 && mt!=2) h=12; suffix = " AM"; } } return (((h<10)?((mt==2)?"0":"0"):"")+h+":"+(m<10?"0":"")+m)+suffix; }, formatString: function(obj,showdate,tz) { var me = this; tz = tz * 60; if (typeof obj.st === 'undefined') obj.st = obj.h1*60+obj.m1*1; if (typeof obj.et === 'undefined') obj.et = obj.h2*60+obj.m2*1; var str = ""; if (showdate) { var d = $.datepicker.parseDate("yy-mm-dd", obj.d); if (tz!=0) { if (obj.st+tz<0) d.setDate(d.getDate() - 1); else if (obj.st+tz>24*60) d.setDate(d.getDate() + 1); } str += ""+$.datepicker.formatDate(me.dateFormat, d)+" "; } str += (showdate?"":""); str += me.formattime(obj.st+tz,me.militaryTime)+(me.showEndTime?("-"+me.formattime(obj.et+tz,me.militaryTime)):""); str += (showdate?"":""); return str; }, getCurrentSlots: function(arr,d,s) { var me = this; var duration = parseFloat(me.services[s].duration); var html = ""; var htmlSlots = new Array(); var pb = 0; var pa = 0; var v = false; var capacity_service = me.services[s].capacity; if (true) { var compactUsedSlots = me.getCompatSlots(me.htmlUsedSlots[d]) for (var i=0;i=capacity_service && compactUsedSlots[i].serviceindex==s) if (compactUsedSlots[i].serviceindex==s) { compactUsedSlots[i].st = compactUsedSlots[i].h1 * 60 + compactUsedSlots[i].m1; compactUsedSlots[i].t = $.datepicker.parseDate("yy-mm-dd",compactUsedSlots[i].d).getTime()+compactUsedSlots[i].st*60*1000; compactUsedSlots[i].html = ""; var v = false; if (me.minDate!=="" && me.getMinDate!="") //check with the min date { var current = me.getMinDate; var currenttime = current.getTime()-me.tzf(d)*60*60*1000; if (compactUsedSlots[i].t > currenttime) { v = true; } } else v = true; if (v) { if (compactUsedSlots[i].quantity>=capacity_service || compactUsedSlots[i].currentSelection) compactUsedSlots[i].html = '
'+me.formatString(compactUsedSlots[i],false,me.tzf(d))+''+((typeof compactUsedSlots[i].e !== 'undefined')?"
"+compactUsedSlots[i].e+"
":"")+'
'; compactUsedSlots[i].availableslot = false; htmlSlots[htmlSlots.length] = compactUsedSlots[i]; } } } } if ((typeof specialPadding === 'undefined')) { pb = me.pb; pa = me.pa; } for (var i=0;i= et) et += 24 * 60; st += me.pb; while (st + duration + me.pa <=et && st < 24 * 60) { html = ""; htmlSlots[htmlSlots.length] = {availableslot:true,st:st,serviceindex:s,h1:Math.floor((st)/60),m1:((st)%60),h2:Math.floor((st+duration)/60),m2:((st+duration)%60),html:html,t:$.datepicker.parseDate("yy-mm-dd",arr[i].day).getTime()+st*60*1000}; if (!me.bSlotsCheckbox) st += me.bduration; else st += me.bduration + pa + pb; } } htmlSlots.sort(function(a, b){ if ((typeof cp_hourbk_cmpublic !== 'undefined') && (a.t == b.t)) { if ((typeof a.quantity !== 'undefined') && (typeof b.quantity === 'undefined')) { b.html = b.html.replace("ahbslotavailabilityP",(capacity_service - a.quantity)); b.quantity = a.quantity; } else if ((typeof b.quantity !== 'undefined') && (typeof a.quantity === 'undefined')) { a.html = a.html.replace("ahbslotavailabilityP",(capacity_service - b.quantity)); a.quantity = b.quantity; } } return a.t - b.t }); //remove duplicates htmlSlots = htmlSlots.reduce(function(field, e1){ var matches = field.filter(function(e2){return e1.html== e2.html}); if (matches.length == 0){ field.push(e1); }return field; }, []); htmlSlots = htmlSlots.reduce(function(field, e1){ var matches = field.filter(function(e2){return e1.t== e2.t}); if (matches.length == 0){ field.push(e1); } else { for (var i=0;i0 && htmlSlots.length>0) for (var i=0;i=me.cacheArr[d][i].t2) me.cacheArr[d][i].t2 += 24 * 60; if (st<=me.cacheArr[d][i].t1 && et>=me.cacheArr[d][i].t1) htmlSlots[htmlSlots.length] = jQuery.extend({}, me.cacheArr[d][i]); } for (var i=0;me.usedSlots[d] && i=me.usedSlots[d][i].t2) me.usedSlots[d][i].t2 += 24 * 60; if (st<=me.usedSlots[d][i].t1 && et>=me.usedSlots[d][i].t1) htmlSlots[htmlSlots.length] = jQuery.extend({}, me.usedSlots[d][i]); } } return htmlSlots; } var day = $.datepicker.parseDate("yy-mm-dd", d); if (this.tzf(d)==0) { me.htmlUsedSlots[d] = setHtmlUsedSlots(d,0,24); var arr = this.getAvailablePartialSlots(d,[{h1:0,m1:0,h2:0,m2:0}],s); } else if (this.tzf(d) > 0) { day.setDate(day.getDate() - 1); var d1 = $.datepicker.formatDate("yy-mm-dd",day); var arr = $.merge(this.getAvailablePartialSlots(d1,[{h1:0,m1:0,h2:24-this.tzf(d),m2:0}],s),this.getAvailablePartialSlots(d,[{h1:24-this.tzf(d),m1:0,h2:24,m2:0}],s)); me.htmlUsedSlots[d] = $.merge(setHtmlUsedSlots(d1,24-this.tzf(d),24), setHtmlUsedSlots(d,0,24-this.tzf(d))); } else { day.setDate(day.getDate() + 1); var d1 = $.datepicker.formatDate("yy-mm-dd",day); var arr = $.merge(this.getAvailablePartialSlots(d,[{h1:0,m1:0,h2:this.tzf(d)*-1,m2:0}],s),this.getAvailablePartialSlots(d1,[{h1:this.tzf(d)*-1,m1:0,h2:24,m2:0}],s)); me.htmlUsedSlots[d] = $.merge(setHtmlUsedSlots(d,this.tzf(d)*-1,24), setHtmlUsedSlots(d1,0,this.tzf(d)*-1)); } me.slotsDate[c] = arr; return arr; }, getAvailableSlots: function(d) { var me = this; var c = "s"+(me.showAllServices?"":me.service_selected)+"q"+me.quantity_selected+"d"+d; if (me.tzf(d)==0 && typeof me.slotsDate[c]!== 'undefined') return me.slotsDate[c]; var a_max = []; if (!me.showAllServices) a_max = this.getAvailableSlotsByService(d,me.service_selected); else { me.availableSlotsByService[d] = []; for (var i=0; i< me.services.length;i++) { me.availableSlotsByService[d][i] = this.getAvailableSlotsByService(d,i); if (me.availableSlotsByService[d][i].length > a_max.length) a_max = me.availableSlotsByService[d][i].slice(0); } } me.slotsDate[c] = a_max; return a_max; }, rC: function(d) { var me = this; var day = $.datepicker.formatDate('yy-mm-dd', d); var c = new Array(day,"d"+day); if (me.working_dates[d.getDay()]==0 && ($.inArray(day, me.special_days) == -1)) c.push("nonworking","ui-datepicker-unselectable","ui-state-disabled"); for( var i = 0, l = me.invalidDates.length; i < l; i++ ) { if (d.getTime() === me.invalidDates[i].getTime() && ($.inArray(day, me.special_days) == -1)) c.push("nonworking","ui-datepicker-unselectable","ui-state-disabled","invalidDate"); } if (me.minDate!=="" && me.getMinDate!="" && day < $.datepicker.formatDate('yy-mm-dd', me.getMinDate)) c.push("nonworking","ui-datepicker-unselectable","ui-state-disabled","beforemindate"); if (me.maxDate!=="" && me.getMaxDate!="" && day > $.datepicker.formatDate('yy-mm-dd', me.getMaxDate)) c.push("nonworking","ui-datepicker-unselectable","ui-state-disabled","aftermaxdate"); if (($.inArray("ui-datepicker-unselectable",c)==-1) && !me.emptySelectCheckbox || (me.emptySelectCheckbox && $(".fieldCalendarService"+me.name+" select option:selected").index() > 0 )) { var arr = me.getAvailableSlots(day); if (arr.length==0 && me.notShowBookedDate) c.push("nonworking","ui-datepicker-unselectable","ui-state-disabled","notavailslot"); if (typeof cp_hourbk_cmpublic !== 'undefined') { var used = 0; var cclass = c.join(" "); var q = 0; var total = 0; if (!me.showAllServices) { var htmlSlots = me.getCurrentSlots(arr,day,me.service_selected); for (var i=0;i0)/*compatible with old version*/ { if (!me.openhours[0].name) { var obj = {name:"Default",openhours:me.openhours.slice(0)}; me.openhours = new Array(); me.openhours[0] = obj; } me.allOH = new Array(); me.allOH = me.openhours.slice(0); me.openhours = new Array(); } var dd = ""; if (me.initialapp!="") { try{ var s = me.initialapp.split(";"); var s2 = ""; var ind = 0; for (var i=0;i 0 ))) { $( '#field' + me.form_identifier + '-' + me.index + ' .slotsCalendar'+me.name ).html(""); return; } function getSlots(d) { var data1 = me.cacheArr[d]; var duration = me.duration; me.bduration = me.duration; if (!me.bSlotsCheckbox) me.bduration = me.bSlots*1; var arr = me.getAvailableSlots(d); var nextdateAvailable = $.datepicker.parseDate("yy-mm-dd", d); var c = "s"+(me.showAllServices?"":me.service_selected)+"q"+me.quantity_selected; var s = $( '#field' + me.form_identifier + '-' + me.index + ' .slotsCalendar'+me.name ); var i =0; if (me.notShowBookedDate && (me.maxNumberOfApp==0 || me.allUsedSlots.length0 ) { e.datepicker("setDate", nextdateAvailable); me.getD = nextdateAvailable; onChangeDateOrService($.datepicker.formatDate("yy-mm-dd", nextdateAvailable)); } else { e.datepicker("setDate", me.getMinDate); s.html("
"+cp_hourbk_nomore_label+"
"); } return; } me.service_change = false; function getStrSlots(arr,d,s) { var str = ""; var htmlSlots = me.getCurrentSlots(arr,d,s); var capacity_service = me.services[s].capacity; for (var i=0;i
'+me.services[i].name+'
'+str_s+''; } } if (str=="") str = cp_hourbk_nomore_label; var before = ""; if (s.find(".slots").length>0) { before = s.find(".slots").attr("d"); } s.html("
"+$.datepicker.formatDate(me.dateFormat, $.datepicker.parseDate("yy-mm-dd", d))+"
"+str+"
"); if (before!="" && before!=d) { s.find(".slots span:first").hide().show(200); } var str1="",str2=""; me.allUsedSlots = me.allUsedSlots || []; me.allUsedSlots.sort(function(a, b){ return ($.datepicker.parseDate("yy-mm-dd", a.d).getTime()+(a.h1*60+a.m1)*60*1000) - ($.datepicker.parseDate("yy-mm-dd", b.d).getTime()+(b.h1*60+b.m1)*60*1000)}); j = 0; var total = 0; for (var i=0;i"+me.formatString(me.allUsedSlots[i],true,me.tzf(d))+""+me.services[me.allUsedSlots[i].serviceindex].name+"("+me.allUsedSlots[i].quantity+")["+(cp_hourbk_cancel_label?cp_hourbk_cancel_label:'cancel')+"]"+(((typeof cp_hourbk_repeat !== 'undefined'))?showrepeat(me,i):"")+""; str2 += ((str2=="")?"":";")+me.allUsedSlots[i].d+" "+me.formattime(me.allUsedSlots[i].h1*60+me.allUsedSlots[i].m1*1,2)+"/"+me.formattime(me.allUsedSlots[i].h2*60+me.allUsedSlots[i].m2*1,2)+" "+me.allUsedSlots[i].serviceindex+" "+me.allUsedSlots[i].quantity; if (me.allUsedSlots[i].d==d) j++; } me.sub_cost = total; total = me.sub_cost + me.extras; total = total*(1+me.percent/100); total = total.toFixed(2); if (me.showTotalCost && (str1!="")) str1 += '
'+cp_hourbk_cost_label+' '+me.showTotalCostFormat.replace("{0}", total)+'
'; $( '.usedSlots'+me.name ).html(str1); $( '#field' + me.form_identifier + '-' + me.index + ' #'+me.name ).val(str2); $( '#field' + me.form_identifier + '-' + me.index + ' #tcost'+me.name ).val(total); $( '#field' + me.form_identifier + '-' + me.index + ' #'+me.name ).change(); try { $( "#fbuilder .slots div a" ).tooltip({ position: { my: "left top+10" }, open: function (event, ui) { $(this).tooltip( "option", "content", $(this).parent().find(".ahbmoreinfo").html() ); }, tooltipClass: "ahbtooltip" }); } catch (e) {} $( '.slotsCalendar' + me.name + ' .slots a').off("click").on("click", function() { var q = parseFloat($(".fieldCalendarService"+me.name+" select.ahbfield_quantity option:selected").val()); if ((me.maxNumberOfApp==1 && me.allUsedSlots.length==me.maxNumberOfApp) || (me.allUsedSlots.length>0 && me.allUsedSlots[0].quantity!=q && !me.allowDifferentQuantities)) //cancel previous slot { for (var i = 0; (idata[i].h2 && data[i].h2!=0) || data[i].h2>24) { if (data[i].h1>data[i].h2) data[i].h2 += 24; var obj = jQuery.extend({}, data[i]); obj.h2 = data[i].h2 - 24; obj.h1 = 0;obj.m1 = 0; var d = $.datepicker.parseDate("yy-mm-dd", dd); d.setDate(d.getDate() + 1); obj.d = $.datepicker.formatDate("yy-mm-dd", d); data[i].h2 = 24; me.cacheArr[obj.d] = me.cacheArr[obj.d] || []; me.cacheArr[obj.d][me.cacheArr[obj.d].length] = obj; } } me.slotsDate = []; me.loadOK = true; } }); } this.invalidDates = this.invalidDates.replace( /\s+/g, '' ); try{ var df = "mm/dd/yy"; if (this.invalidDates.indexOf(".")!=-1) df = me.dateFormat; if( !/^\s*$/.test( this.invalidDates ) ) { var counter = 0, dates = this.invalidDates.split( ',' ); this.invalidDates = []; for( var i = 0, h = dates.length; i < h; i++ ) { var range = dates[ i ].split( '-' ); if( range.length == 2 ) { var fromD = $.datepicker.parseDate(df,range[ 0 ]), toD = $.datepicker.parseDate(df,range[ 1 ]); while( fromD <= toD ) { if (fromD !== null) { this.invalidDates[ counter ] = fromD; var tmp = new Date( fromD.valueOf() ); tmp.setDate( tmp.getDate() + 1 ); fromD = tmp; counter++; } } } else { for( var j = 0, k = range.length; j < k; j++ ) { if ($.datepicker.parseDate(df,range[ j ]) !== null) { this.invalidDates[ counter ] = $.datepicker.parseDate(df,range[ j ]); counter++; } } } } } } catch (e) {} if ($.validator.messages.date_format && $.validator.messages.date_format!="") me.dateFormat = $.validator.messages.date_format; var capacity = 1; for (var i=0;i'+me.services[i].name+''; me.services[i].capacity = (parseFloat(me.services[i].capacity)>0)?me.services[i].capacity:1; if (capacity'+ str ; var str2 = ""; for (var i=1;i<=me.services[0].capacity;i++) str2 += ''; d.html('

'); me.service_selected = me.normalizeSelectIndex($(".fieldCalendarService"+me.name+" select.ahbfield_service option:selected").index()); me.quantity_selected = parseFloat($(".fieldCalendarService"+me.name+" select.ahbfield_quantity option:selected").val()); me.duration = parseFloat(me.services[me.service_selected].duration); me.pa = me.services[me.service_selected].pa * 1 || 0; me.pb = me.services[me.service_selected].pb * 1 || 0; $(".fieldCalendarService"+me.name+" select.ahbfield_service").bind("change", function() { me.service_change = true; me.service_selected = me.normalizeSelectIndex($(".fieldCalendarService"+me.name+" select.ahbfield_service option:selected").index()); me.duration = parseFloat(me.services[me.service_selected].duration); me.pa = me.services[me.service_selected].pa * 1 || 0; me.pb = me.services[me.service_selected].pb * 1 || 0; //me.cacheOpenHours = new Array(); me.special_days = me.getSpecialDays(); var str2 = ""; for (var i=1;i<=me.services[me.service_selected].capacity;i++) str2 += ''; $(".fieldCalendarService"+me.name+" select.ahbfield_quantity").html(str2); me.quantity_selected = parseFloat($(".fieldCalendarService"+me.name+" select.ahbfield_quantity option:selected").val()); if (typeof me.getDMin!='undefined') me.getD = me.getDMin; $( '#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name ).datepicker( "option", "beforeShowDay", function(d){return me.rC(d)} ); onChangeDateOrService($.datepicker.formatDate('yy-mm-dd', me.getD)); }); $(".fieldCalendarService"+me.name+" select.ahbfield_quantity").bind("change", function() { if (!me.allowDifferentQuantities) { me.quantity_selected = parseFloat($(".fieldCalendarService"+me.name+" select.ahbfield_quantity option:selected").val()); me.allUsedSlots = me.allUsedSlots || []; for (var i=0;i=arr[j].t1 && s.h2*60+s.m2*1<=arr[j].t2) find = true; } me.usedSlots[s.d] = me.usedSlots[s.d] || []; f = false; for (var j=0;j=0 && parseFloat(a[0]) < 24 && parseFloat(a[1])>=0 && parseFloat(a[1]) < 60 ) me.getMinDate = new Date(me.getMinDate.getFullYear(),me.getMinDate.getMonth(),me.getMinDate.getDate(),parseFloat(a[0]),parseFloat(a[1])); } e.datepicker("option", "minDate", me.getMinDate ); e.datepicker("setDate", me.getMinDate); } if (me.maxDate!=="") try{me.getMaxDate = $.datepicker._getMinMaxDate( e.data('datepicker'), 'max' ); me.getMaxDate.setHours(24, 0, 0, 0);} catch (e) {} if (typeof hrsMax !== 'undefined') { var t = new Date(); me.getMaxDate.setHours(t.getHours(), t.getMinutes(), t.getSeconds()); me.getMaxDate = new Date((me.getMaxDate.getTime() + hrsMax * 60 * 60 * 1000) ); } try{ if (me.defaultDate!=="") e.datepicker("setDate", me.defaultDate); } catch (e) {} e.datepicker("option", "maxDate", me.maxDate ); if (me.getMaxDate!="" && me.tzf($.datepicker.formatDate("yy-mm-dd",me.getMaxDate))!=0) e.datepicker("option", "maxDate", new Date(me.getMaxDate.getTime()+me.tzf($.datepicker.formatDate("yy-mm-dd",me.getMaxDate))*60*60*1000) ); me.tmpinvalidDatestime = new Array(); try { for (var i=0;i -1 ) return false; if (me.working_dates[date.getDay()]==0) return false; return true; } var sum = 0; for (var i=0;i0) { var nextdateAvailable = e.datepicker("getDate"); var i = 0; while (!DisableSpecificDates(nextdateAvailable) && i<400) { nextdateAvailable.setDate(nextdateAvailable.getDate() + 1); i++; } e.datepicker("setDate", nextdateAvailable); me.getD = nextdateAvailable; function ifLoadOk() { if (!me.loadOK) setTimeout(ifLoadOk,100); else { $( '#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name ).datepicker( "option", "beforeShowDay", function(d){return me.rC(d)} ); onChangeDateOrService($.datepicker.formatDate('yy-mm-dd', me.getD)); $( '#field' + me.form_identifier + '-' + me.index + ' .fieldCalendar'+me.name ).datepicker( "option", "beforeShowDay", function(d){return me.rC(d)} ); } } ifLoadOk(); } preselect_service = function(v) { $(".fieldCalendarService"+me.name+" select.ahbfield_service").children().removeAttr("selected"); if (me.emptySelectCheckbox) $(".fieldCalendarService"+me.name+" select.ahbfield_service").children().eq(v+1).prop('selected', 'selected').change(); else $(".fieldCalendarService"+me.name+" select.ahbfield_service").children().eq(v).prop('selected', 'selected').change(); } if (typeof cp_hourbk_preselect !== 'undefined' && cp_hourbk_preselect!="") preselect_service(cp_hourbk_preselect*1); else if (me.initialapp!="" && dd!="") { try{ me.getD = $.datepicker.parseDate("yy-mm-dd",dd); e.datepicker("setDate", me.getD); preselect_service(me.initialServiceInd); onChangeDateOrService(dd); } catch (e) {} } getExtrasVisible = function(f) { try{ var p = f.attr("id").split( '_' ); var items = $.fbuilder[ 'forms' ]["_"+p[p.length-1]].getItems(); for (var i=0;i 1 ) ? '_'+p[ 1 ] : '', me = ( typeof $.fbuilder[ 'forms' ] != 'undefined' && typeof $.fbuilder[ 'forms' ][ _index ] != 'undefined' ) ? $.fbuilder[ 'forms' ][ _index ].getItem( p[ 0 ]+'_'+p[ 1 ] ) : null; if( me != null ) { $.ajax({ dataType : 'json', type: "POST", url : document.location.href, data : { cp_app_action: 'get_slots', formid: me.formId, initialID: me.initialID, formfield: me.name.replace(me.form_identifier, "") }, success: function(data) { var overlapping = false; var find = false; me.ignoreUsedSlots = true; me.cacheArr = new Array(); for (var i=0;i=t2) find = true; } if (!find) { overlapping = true; if (msg == "") msg = "
Affected times:
"; msg += "
"+me.formatString(me.allUsedSlots[i],true,me.tzf(d))+""+me.services[me.allUsedSlots[i].serviceindex].name+"
"; } //overlapping = !find; } me.ignoreUsedSlots = false; var isValid = !overlapping; if (true === isValid) { var submitted = validator.formSubmitted; validator.prepareElement( element ); validator.formSubmitted = submitted; validator.successList.push( element ); delete validator.invalid[ element.name ]; validator.showErrors(); } else { for (var i=0;i'+label+''; } else if(!/^\s*$/.test(me.message)) { label = ''+label+''; dlg += '
'+me.message+'
' } return '
'+ '
'+ dlg+ '
'; }, after_show:function() { $(document).on('click','.cff-open-dlg', function(){ var dlg = $(this).closest('.fields').find('.cff-dialog'), w = dlg.data('width'), h=dlg.data('height'); dlg.removeClass('hide'); if('undefined' == typeof w) w = Math.min($(this).closest('form').width(), $(window).width(), dlg.width()); if('undefined' == typeof h) h = Math.min($(this).closest('form').height(), $(window).height(), dlg.height()); dlg.data('width',w); dlg.data('height',h); dlg.css({'width': w+'px', 'height': h+'px', 'margin-top': (-1*h/2)+'px', 'margin-left': (-1*w/2)+'px'}); }); $(document).on('click','.cff-close-dlg', function(){$(this).closest('.cff-dialog').addClass('hide');}); }, val:function() { var e = $('[id="'+this.name+'"]:checked:not(.ignore)'); if( e.length ) { var t = $.fbuilder.parseValStr( e[0].value ); if(!$.isNumeric(t)) t = t.replace(/^"/,'').replace(/"$/,''); } return (v) ? (($.isNumeric(v)) ? v : '"'+v+'"') : 0; } } ); var fcount = 1; var fcount_tags = 1; var fnum = "_"+fcount; var cp_avoid_hidden = false; while (20>fcount || eval("typeof cp_appbooking_fbuilder_config"+fnum+" != 'undefined'")) { try { var cp_appbooking_fbuilder_config = eval("cp_appbooking_fbuilder_config"+fnum); while (20>fcount_tags && !$("#fbuilder_"+fcount_tags).length) fcount_tags++; cp_appbooking_fbuilder_config = $.parseJSON(cp_appbooking_fbuilder_config.obj); cp_appbooking_fbuilder_config.identifier = "_"+fcount_tags; var opt_identifier = $("#fieldlist_"+fcount_tags); opt_identifier.attr("fcount_tags",fcount_tags); opt_identifier.attr("fnum",fnum); opt_identifier.addClass("cp_avoid_hidden") var f = $("#fbuilder_"+fcount_tags).fbuilder(cp_appbooking_fbuilder_config); f.fBuild.loadData("form_structure_"+fcount_tags); $.fbuilder.configValidate($("#cp_appbooking_pform_"+fcount_tags)); if((typeof opt_identifier.attr("fnum") !== 'undefined') && !opt_identifier.is(':hidden')) $(opt_identifier).addClass("cp_v_v"); else cp_avoid_hidden = true; } catch (e) {} fcount++; fcount_tags++; fnum = "_"+fcount; } if (cp_avoid_hidden) $( document ).each( function() { (new MutationObserver( function(mutationsList, observer) { for(let k in mutationsList) { var mutation = mutationsList[k]; if (mutation.type === 'childList') { if(mutation.addedNodes.length) { try{ $(".cp_avoid_hidden").each(function(){ var opt_identifier= $("#"+$(this).attr("id")); if((typeof opt_identifier.attr("fnum") !== 'undefined') && !opt_identifier.is(':hidden') && !opt_identifier.hasClass("cp_v_v")) { $(opt_identifier).addClass("cp_v_v"); var fnum = opt_identifier.attr("fnum"); var fcount_tags = opt_identifier.attr("fcount_tags"); var cp_appbooking_fbuilder_config = eval("cp_appbooking_fbuilder_config"+fnum); cp_appbooking_fbuilder_config = $.parseJSON(cp_appbooking_fbuilder_config.obj); cp_appbooking_fbuilder_config.identifier = "_"+fcount_tags; var f = $("#fbuilder_"+fcount_tags).fbuilder(cp_appbooking_fbuilder_config); f.fBuild.loadData("form_structure_"+fcount_tags); $.fbuilder.configValidate(opt_identifier.closest("form")); } }) }catch(err){} } } } } )).observe(this, { childList: true, subtree: true }); } ); })(fbuilderjQuery); });