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")) { var f1 = $("#fieldlist"+identifier+" .pb"+page).find(".field:visible"); if (f1.parents("fieldset").parents("#fieldlist"+identifier+" .pb"+page).length>0) focusTop(); else f1[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[ 'fcurrency' ] = function(){}; $.extend( $.fbuilder.controls[ 'fcurrency' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Currency", ftype:"fcurrency", predefined:"", predefinedClick:false, required:false, size:"small", readonly:false, currencyText:"USD", thousandSeparator:",", centSeparator:".", min:"", max:"", formatDynamically:false, getFormattedValue:function( value ) { this.centSeparator = $.trim(this.centSeparator); if( /^\s*$/.test( this.centSeparator ) ) { this.centSeparator = '.'; } var v = $.trim( value ); v = v.replace( new RegExp( $.fbuilder[ 'escape_symbol' ](this.currencySymbol), 'g' ), '' ) .replace( new RegExp( $.fbuilder[ 'escape_symbol' ](this.currencyText), 'g' ), '' ); v = $.fbuilder.parseVal( v, this.thousandSeparator, this.centSeparator ); if( !isNaN( v ) ) { v = v.toString(); var parts = v.toString().split("."), counter = 0, str = ''; if( !/^\s*$/.test( this.thousandSeparator ) ) { for( var i = parts[0].length-1; i >= 0; i--){ counter++; str = parts[0][i] + str; if( counter%3 == 0 && i != 0 ) str = this.thousandSeparator + str; } parts[0] = str; } if( typeof parts[ 1 ] != 'undefined' && parts[ 1 ].length == 1 ) { parts[ 1 ] += '0'; } if( /^\s*$/.test( this.centSeparator ) ) { this.centSeparator = '.'; } return this.currencySymbol+parts.join( this.centSeparator )+this.currencyText; } else { return value; } }, show:function() { return '
'+this.userhelp+'
'; }, after_show:function() { if( this.formatDynamically ) { var me = this; $( document ).on( 'change', '[name="' + me.name + '"]', function(){ this.value = me.getFormattedValue( this.value ); } ); } if( typeof $[ 'validator' ] != 'undefined' ) { $.validator.addMethod( 'min', function( value, element, param ) { var e = element; if( element.id.match( /_\d+$/) ) { var e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+$/)[ 0 ] ].getItem( element.name ) } var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '', centSymbol = ( typeof e.centSeparator != 'undefined' && $.trim( e.centSeparator ) ) ? e.centSeparator : '.'; return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, centSymbol ) >= param; } ); $.validator.addMethod( 'max', function( value, element, param ) { var e = element; if( element.id.match( /_\d+$/) ) { var e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+$/)[ 0 ] ].getItem( element.name ) } var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '', centSymbol = ( typeof e.centSeparator != 'undefined' && $.trim( e.centSeparator ) ) ? e.centSeparator : '.'; return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, centSymbol ) <= param; } ); } }, val:function() { var e = $( '[id="' + this.name + '"]:not(.ignore)' ); if( e.length ) { var v = $.trim( e.val() ); v = v.replace( new RegExp( $.fbuilder[ 'escape_symbol' ](this.currencySymbol), 'g' ), '' ) .replace( new RegExp( $.fbuilder[ 'escape_symbol' ](this.currencyText), 'g' ), '' ); return $.fbuilder.parseVal( v, this.thousandSeparator, this.centSeparator ); } return 0; } } ); $.fbuilder.controls[ 'fnumber' ] = function(){}; $.extend( $.fbuilder.controls[ 'fnumber' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Number", ftype:"fnumber", predefined:"", predefinedClick:false, required:false, size:"small", thousandSeparator:"", decimalSymbol:".", min:"", max:"", dformat:"digits", formats:new Array("digits","number"), show:function() { return '
'+this.userhelp+'
'; }, after_show:function() { if( typeof $[ 'validator' ] != 'undefined' ) { $.validator.addMethod( 'number', function( value, element ) { var e = element; if( element.id.match( /_\d+$/) ) { var e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+$/)[ 0 ] ].getItem( element.name ) } var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '', decimalSymbol = ( typeof e.decimalSymbol != 'undefined' && $.trim( e.decimalSymbol ) ) ? e.decimalSymbol : '.'; var regExp = new RegExp( '^-?(?:\\d+|\\d{1,3}(?:' + $.fbuilder.escape_symbol( thousandSeparator ) + '\\d{3})+)?(?:' + $.fbuilder.escape_symbol( decimalSymbol ) + '\\d+)?$' ); return this.optional(element) || regExp.test( value ); } ); $.validator.addMethod( 'min', function( value, element, param ) { var e = element; if( element.id.match( /_\d+$/) ) { var e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+$/)[ 0 ] ].getItem( element.name ) } var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '', decimalSymbol = ( typeof e.decimalSymbol != 'undefined' && $.trim( e.decimalSymbol ) ) ? e.decimalSymbol : '.'; return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, decimalSymbol ) >= param; } ); $.validator.addMethod( 'max', function( value, element, param ) { var e = element; if( element.id.match( /_\d+$/) ) { var e = $.fbuilder[ 'forms' ][ element.id.match( /_\d+$/)[ 0 ] ].getItem( element.name ) } var thousandSeparator = ( typeof e.thousandSeparator != 'undefined' ) ? e.thousandSeparator : '', decimalSymbol = ( typeof e.decimalSymbol != 'undefined' && $.trim( e.decimalSymbol ) ) ? e.decimalSymbol : '.'; return this.optional(element) || $.fbuilder.parseVal( value, thousandSeparator, decimalSymbol ) <= param; } ); } }, val:function() { var e = $( '[id="' + this.name + '"]:not(.ignore)' ); if( e.length ) { var v = $.trim( e.val() ); return $.fbuilder.parseVal( v, this.thousandSeparator, this.decimalSymbol ); } return 0; } } ); $.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[ 'fdate' ] = function(){}; $.extend( $.fbuilder.controls[ 'fdate' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Date", ftype:"fdate", predefined:"", predefinedClick:false, size:"medium", required:false, dformat:"mm/dd/yyyy", dseparator:"/", tformat:"24", showDropdown:false, dropdownRange:"-10:+10", minDate:"", maxDate:"", invalidDates:"", minHour:0, maxHour:23, minMinute:0, maxMinute:59, stepHour: 1, stepMinute: 1, showDatepicker: true, showTimepicker: false, ariaHourLabel: 'hours', ariaMinuteLabel: 'minutes', ariaAMPMLabel: 'am or pm', defaultDate:"", defaultTime:"", working_dates:[true,true,true,true,true,true,true], _set_Events : function() { var me = this, f = function(){ $( '#'+me.name+'_date' ).valid(); me.set_dateTime(); }; $( document ).on( 'change', '#'+me.name+'_date', function(){ f(); } ); $( document ).on( 'change', '#'+me.name+'_hours', function(){ f(); } ); $( document ).on( 'change', '#'+me.name+'_minutes', function(){ f(); } ); $( document ).on( 'change', '#'+me.name+'_ampm', function(){ f(); } ); $( '#cp_calculatedfieldsf_pform'+me.form_identifier ).bind( 'reset', function(){ setTimeout( function(){ me.set_DefaultDate(); me.set_DefaultTime(); me.set_dateTime(); }, 500 ); } ); }, _validateDate: function( d, w, i ) { try{ if( d === null || !w[ d.getDay()] ) return false; if( i !== null ) { for( var j = 0, h = i.length; j < h; j++ ) { if( d.getDate() == i[ j ].getDate() && d.getMonth() == i[ j ].getMonth() && d.getFullYear() == i[ j ].getFullYear() ) return false; } } } catch( _err ){} return true; }, _validateTime : function( e, i ) { if( i.showTimepicker ) { var base = e.name.replace( '_date', '' ), h = $('#'+base+'_hours').val(), m = $('#'+base+'_minutes').val(); if( i.tformat == 12 ) { if( $('#'+base+'_ampm').val() == 'pm' && h != 12 ) h = h*1 + 12; if( $('#'+base+'_ampm').val() == 'am' && h == 12 ) h = 0; } if( h < i.minHour || i.maxHour < h || (h == i.minHour && m < i.minMinute) || (h == i.maxHour && i.maxMinute < m) ) return false; } return true; }, init:function() { var me = this, _checkValue = function( v, min, max ) { v = parseInt( v ); v = ( isNaN( v ) ) ? max : v; return Math.min(Math.max(v,min),max); }; // Date me.dformat = me.dformat.replace(/\//g, me.dseparator); me.invalidDates = me.invalidDates.replace( /\s+/g, '' ); if( me.dropdownRange.indexOf( ':' ) == -1 ) me.dropdownRange = '-10:+10'; if( !/^\s*$/.test( me.invalidDates ) ) { var dateRegExp = new RegExp( /^\d{1,2}\/\d{1,2}\/\d{4}$/ ), counter = 0, dates = me.invalidDates.split( ',' ); me.invalidDates = []; for( var i = 0, h = dates.length; i < h; i++ ) { var range = dates[ i ].split( '-' ); if( range.length == 2 && range[0].match( dateRegExp ) != null && range[1].match( dateRegExp ) != null ) { var fromD = new Date( range[ 0 ] ), toD = new Date( range[ 1 ] ); while( fromD <= toD ) { me.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( range[ j ].match( dateRegExp ) != null ) { me.invalidDates[ counter ] = new Date( range[ j ] ); counter++; } } } } } // Time me.minHour = _checkValue( me.minHour, 0, 23 ); me.maxHour = _checkValue( me.maxHour, 0, 23 ); me.minMinute = _checkValue( me.minMinute, 0, 59 ); me.maxMinute = _checkValue( me.maxMinute, 0, 59 ); me.stepHour = _checkValue( me.stepHour, 1, Math.max( 1, me.maxHour - me.minHour ) ); me.stepMinute = _checkValue( me.stepMinute, 1, Math.max( 1, me.maxMinute - me.minMinute ) ); // Set handles me._setHndl('minDate'); me._setHndl('maxDate'); }, get_hours:function() { var me = this, str = '', i = 0, h, from = ( me.tformat == 12 ) ? 1 : me.minHour, to = ( me.tformat == 12 ) ? 12 : me.maxHour; while( ( h = from + me.stepHour * i ) <= to ) { if( h < 10 ) h = '0'+''+h; str += ''; i++; } return ':'; }, get_minutes:function() { var me = this, str = '', i = 0, m, n = (me.minHour == me.maxHour)?me.minMinute : 0, x = (me.minHour == me.maxHour)?me.maxMinute : 59; while( ( m = n + me.stepMinute * i ) <= x ) { if( m < 10 ) m = '0'+''+m; str += ''; i++; } return ''; }, get_ampm:function() { var str = ''; if( this.tformat == 12 ) { return ''; } return str; }, set_dateTime:function() { var me = this, str = $( '#'+me.name+'_date' ).val(); if( me.showTimepicker && str!="") { str += ' '+$( '#'+me.name+'_hours' ).val(); str += ':'+$( '#'+me.name+'_minutes' ).val(); if( $( '#'+me.name+'_ampm' ).length ) str += $( '#'+me.name+'_ampm' ).val(); } $( '#'+me.name ).val( str ).change(); }, set_minDate:function(v, ignore) { var e = $('[id*="'+this.name+'"].hasDatepicker'); if(e.length) { e.datepicker('option', 'minDate', (ignore) ? null : v); e.change(); } }, set_maxDate:function(v, ignore) { var e = $('[id*="'+this.name+'"].hasDatepicker'); if(e.length) { e.datepicker('option', 'maxDate', (ignore) ? null : v); e.change(); } }, set_DefaultDate : function() { var me = this, p = { dateFormat: me.dformat.replace(/yyyy/g,"yy"), minDate: me._getAttr('minDate'), maxDate: me._getAttr('maxDate') }, dp = $( "#"+me.name+"_date" ), dd = (me.defaultDate != "") ? me.defaultDate : ( ( me.predefined != "" ) ? me.predefined : new Date() ); dp.click( function(){ $(document).click(); $(this).focus(); } ); if(me.showDropdown ) p = $.extend(p,{changeMonth: true,changeYear: true,yearRange: me.dropdownRange}); p = $.extend(p, {beforeShowDay:(function(w,i) { return function(d){return [me._validateDate(d, w, i), ""];};})(me.working_dates, me.invalidDates)}); dp.datepicker(p); if(!me.predefinedClick) dp.datepicker( "setDate", dd); if(!me._validateDate(dp.datepicker("getDate"), me.working_dates, me.invalidDates)) dp.datepicker( "setDate", ''); }, set_DefaultTime : function() { var me = this, _setValue = function( f, v, m ) { v = Math.min( v*1, m*1 ); v = ( v < 10 ) ? 0+''+v : v; $( '#' + f + ' [value="' + v + '"]' ).prop( 'selected', true ); }; if( me.showTimepicker ) { var parts, time = {}, tmp = 0, max_minutes = 59; if( ( parts = /(\d{1,2}):(\d{1,2})\s*([ap]m)?/gi.exec( me.defaultTime ) ) != null ) { time[ 'hour' ] = parts[ 1 ]*1+((parts.length == 4 && /pm/i.test(parts[3]) && parts[1] != 12) ? 12 : 0); time[ 'minute' ] = parts[ 2 ]; } else { var d = new Date(); time[ 'hour' ] = d.getHours(); time[ 'minute' ] = d.getMinutes(); } time[ 'hour' ] = Math.min(Math.max(time[ 'hour' ], me.minHour), me.maxHour); if(time[ 'hour' ] <= me.minHour) time[ 'minute' ] = Math.max(time['minute'],me.minMinute); if(me.maxHour <= time[ 'hour' ]) time[ 'minute' ] = Math.min(time['minute'],me.maxMinute); _setValue( me.name+'_hours', ( me.tformat == 12 ) ? ( ( time[ 'hour' ] > 12 ) ? time[ 'hour' ] - 12 : ( ( time[ 'hour' ] == 0 ) ? 12 : time[ 'hour' ] ) ) : time[ 'hour' ], ( me.tformat == 12 ) ? 12 : me.maxHour ); _setValue( me.name+'_minutes', time[ 'minute' ], (time[ 'hour' ] == me.maxHour) ? me.maxMinute : 59); $( '#'+me.name+'_ampm'+' [value="' + ( ( time[ 'hour' ] < 12 ) ? 'am' : 'pm' ) + '"]' ).prop( 'selected', true ); } }, show:function() { var me = this, n = me.name, attr = 'value', format_label = [], date_tag_type = 'text', disabled = '', date_tag_class = 'field date'+me.dformat.replace(/[^a-z]/ig,"")+' '+me.size+((me.required && me.showDatepicker)?' required': ''); if( me.predefinedClick ) attr = 'placeholder'; if( me.showDatepicker ) format_label.push(me.dformat); else{ date_tag_type = 'hidden'; disabled='disabled';} if( me.showTimepicker ) format_label.push('HH:mm'); return '
'+( ( me.showTimepicker ) ? ' '+me.get_hours()+me.get_minutes()+' '+me.get_ampm() : '' )+''+me.userhelp+'
'; }, after_show:function() { function closeOtherDatepicker(){ $('#ui-datepicker-div').css("display","none"); } setTimeout(closeOtherDatepicker,100); var me = this, date_format = 'date'+me.dformat.replace(/[^a-z]/ig,""), validator = function( v, e ) { try { var _dp = $.datepicker, _fb = $.fbuilder, p = e.name.replace('_date', '').split('_'), _index = (p.length > 1) ? '_'+p[ 1 ] : '', item = ('forms' in _fb && _index in _fb[ 'forms' ]) ? _fb[ 'forms' ][ _index ].getItem(p[ 0 ]+'_'+p[ 1 ]) : null, inst = _dp._getInst( e ), minDate = _dp._determineDate( inst, _dp._get( inst, 'minDate'), null), maxDate = _dp._determineDate(inst, _dp._get(inst, 'maxDate'), null), dateFormat = _dp._get(inst, 'dateFormat'), date = _dp.parseDate(dateFormat, v, _dp._getFormatConfig(inst)); if( item != null ) { return this.optional( e ) || ( ( minDate == null || date >= minDate ) && ( maxDate == null || date <= maxDate ) && item._validateDate( $( e ).datepicker( 'getDate' ), item.working_dates, item.invalidDates ) && item._validateTime( e, item ) ); } return true; } catch( er ) { return false; } }; if(!(date_format in $.validator.methods)) $.validator.addMethod(date_format, validator ); me.set_DefaultDate(); me.set_DefaultTime(); me._set_Events(); me.set_dateTime(); }, val:function(raw) { raw = raw || false; var me = this, e = $( '[id="' + me.name + '"]:not(.ignore)' ), dformat = me.dformat.replace(new RegExp('\\'+me.dseparator, 'g'), '/'); if( e.length ) { var v = e.val(), rt; if(raw) return $.fbuilder.parseValStr(v, raw); if( dformat == 'yyyy/mm/dd' || dformat == 'yyyy/dd/mm' ) rt = '(\\d{4})[\\/\\-\\.](\\d{1,2})[\\/\\-\\.](\\d{1,2})'; else rt = '(\\d{1,2})[\\/\\-\\.](\\d{1,2})[\\/\\-\\.](\\d{4})'; v = $.trim(e.val()); var re = new RegExp( rt+'(\\s(\\d{1,2})[:\\.](\\d{1,2})\s*([amp]{2})?)?' ), d = re.exec( v ), h = 0, m = 0, date; if( d ) { if( typeof d[ 5 ] != 'undefined' ) h = d[ 5 ]*1; if( typeof d[ 6 ] != 'undefined' ) m = d[ 6 ]*1; if( typeof d[ 7 ] != 'undefined' ) { var am = d[ 7 ].toLowerCase(); if(am == 'pm' && h < 12 ) h += 12; if(am == 'am' && h == 12) h -= 12; } switch( dformat ) { case 'yyyy/dd/mm': date = new Date( d[ 1 ], ( d[ 3 ] * 1 - 1 ), d[ 2 ], h, m, 0, 0 ); break; case 'yyyy/mm/dd': date = new Date( d[ 1 ], ( d[ 2 ] * 1 - 1 ), d[ 3 ], h, m, 0, 0 ); break; case 'dd/mm/yyyy': date = new Date( d[ 3 ], ( d[ 2 ] * 1 - 1 ), d[ 1 ], h, m, 0, 0 ); break; case 'mm/dd/yyyy': date = new Date( d[ 3 ], ( d[ 1 ] * 1 - 1 ), d[ 2 ], h, m, 0, 0 ); break; } if( me.showTimepicker ) return date.valueOf() / 86400000; else return Math.ceil( date.valueOf() / 86400000 ); } } return 0; }, setVal:function( v ) { try { v = $.trim(v) .replace( /\s+/g, ' ' ) .split( ' ' ); if(this.showDatepicker) { this.defaultDate = v[ 0 ]; this.set_DefaultDate(); } if(this.showTimepicker) { var t = (v.length == 2) ? v[1] : ((!this.showDatepicker) ? v[0] : false); if(t !== false) { this.defaultTime = t; this.set_DefaultTime(); } } this.set_dateTime(); } catch( err ) {} } } ); $.fbuilder.controls[ 'ftextarea' ] = function(){}; $.extend( $.fbuilder.controls[ 'ftextarea' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Untitled", ftype:"ftextarea", predefined:"", predefinedClick:false, required:false, size:"medium", minlength:"", maxlength:"", rows:4, show:function() { return '
'+this.userhelp+'
'; }, val:function() { var e = $( '[id="' + this.name + '"]:not(.ignore)' ), v = ''; if( e.length ) { v = e.val(); } return v; } } ); $.fbuilder.controls[ 'fcheck' ]=function(){}; $.extend( $.fbuilder.controls[ 'fcheck' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Check All That Apply", ftype:"fcheck", layout:"one_column", required:false, showDep:false, show:function() { this.choicesVal = ((typeof(this.choicesVal) != "undefined" && this.choicesVal !== null)?this.choicesVal:this.choices.slice(0)); var str = ""; if (!(typeof(this.choicesDep) != "undefined" && this.choicesDep !== null)) { this.choicesDep = new Array(); for (var i=0;i'; } return '
'+str+''+this.userhelp+'
'; }, showHideDep:function( toShow, toHide ) { var item = $( '#'+this.name+'.depItem' ), form_identifier = this.form_identifier; try { if( item.length ) { var parent = item.closest( '.fields' ); parent.find( '.field' ).each( function() { var item = $( this ); if( item.attr( 'dep' ) && item.attr( 'dep' ) != '' ) { var d = item.attr( 'dep' ).split( ',' ); for ( i=0; i'; } return '
'+str+''+this.userhelp+'
'; }, showHideDep:function( toShow, toHide ) { var item = $( '#'+this.name+'.depItem' ), form_identifier = this.form_identifier; try { if( item.length ) { var parent = item.closest( '.fields' ); parent.find( '.field' ).each( function() { var item = $( this ); if( item.attr( 'dep' ) && item.attr( 'dep' ) != '' ) { var d = item.attr( 'dep' ).split( ',' ); for ( i=0; i'+l[i]+''; } return '
'+this.userhelp+'
'; }, showHideDep:function( toShow, toHide ) { var item = $( '#'+this.name ), form_identifier = this.form_identifier; try { if( item.find( '.depItem' ).length ) { var id = item.attr( 'id' ); item.find( '.depItem' ).each( function() { var item = $( this ); if( item.attr( 'dep' ) && item.attr( 'dep' ) != '' ) { var d = item.attr( 'dep' ).split( ',' ); for ( i=0; i
'+((this._patch) ? '' : '' )+''+this.userhelp+'
'; }, after_show:function() { var me = this; if (typeof message_ffile_accept != "undefined") $.extend($.validator.messages, {accept: $.validator.format(message_ffile_accept)}); if(!('accept' in $.validator.methods)) $.validator.addMethod("accept", function(value, element, param) { if( this.optional( element ) ) return true; else{ param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif"; var regExpObj = new RegExp(".(" + param + ")$", "i"); for( var i = 0, h = element.files.length; i < h; i++ ) if( !element.files[ i ].name.match( regExpObj ) ) return false; return true; } }); if (typeof cp_hourbk_message_ffile_size != "undefined") $.extend($.validator.messages, {upload_size: $.validator.format(cp_hourbk_message_ffile_size)}); if(!('upload_size' in $.validator.methods)) $.validator.addMethod("upload_size", function(value, element,params) { if( this.optional( element ) ) return true; else{ var total = 0; for( var i = 0, h = element.files.length; i < h; i++ ) total += element.files[ i ].size/1024; return ( total <= params ); } }); $( '#'+me.name ).change( function(){ var h = this.files.length, n = 0; $( this ).siblings( 'span.files-list' ).remove(); $('[id="'+me.name+'_patch"]').remove(); if(1 <= h) { var filesContainer = $(''); for( var i = 0; i < h; i++ ) { (function(i, file){ if(me.preview && file.type.match('image.*') && 'FileReader' in window) { var reader = new FileReader(); reader.onload = function (e) { var img = $(''); img.attr('src', e.target.result).css('maxWidth', '100%'); if(me.thumb_height != '') img.attr('height', me.thumb_height); if(me.thumb_width != '') img.attr('width', me.thumb_width); filesContainer.append($(''+(n ? ', ' : '')+'').append(img)); n++; }; reader.readAsDataURL(file); } else if(1 < h){filesContainer.append($('').text((n ? ', ' : '')+file.name));n++;} })(i, this.files[i]); } $( this ).after( filesContainer ); } }); } } ); $.fbuilder.controls[ 'fpassword' ] = function(){}; $.extend( $.fbuilder.controls[ 'fpassword' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Untitled", ftype:"fpassword", predefined:"", predefinedClick:false, required:false, size:"medium", minlength:"", maxlength:"", 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[ 'fPhone' ]=function(){}; $.extend( $.fbuilder.controls[ 'fPhone' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Phone", ftype:"fPhone", required:false, readonly:false, dformat:"### ### ####", predefined:"888 888 8888", predefinedClick:true, show:function() { var me = this, str = "", tmp = this.dformat.split(' '), tmpv = this.predefined.split(' '), attr = ( typeof this.predefinedClick != 'undefined' && this.predefinedClick ) ? 'placeholder' : 'value'; for (var i=0;i
'+$.trim(tmp[i])+'
'; } } return '
'+str+''+this.userhelp+'
'; }, after_show: function() { var me = this, tmp = me.dformat.split(' '); $.validator.messages["phone"] = $.validator.messages["digits"]; if(!('phone' in $.validator.methods)) $.validator.addMethod("phone", function(value, element) { if( this.optional( element ) ) return true; else return /^\+{0,1}\d*$/.test(value); }); for (var i = 0, h = tmp.length; i < h; i++ ) { $( '#'+me.name+'_'+i ).bind( 'change', function(){ var v = ''; for( var i = 0; i < tmp.length; i++ ) { v += $( '#'+me.name+'_'+i ).val(); } $( '#'+me.name ).val( v ).change(); } ); if( i+1 < h ) { $('#'+me.name+'_'+i).bind( 'keyup', { 'next': i+1 }, function( evt ){ var e = $( this ); if( e.val().length == e.attr( 'maxlength' ) ) { e.change(); $( '#'+me.name+'_'+evt.data.next ).focus(); } } ); } } }, val:function(raw) { raw = raw || false; var e = $( '[id="' + this.name + '"]:not(.ignore)' ); if( e.length ) return $.fbuilder.parseValStr( e.val(), raw ); return 0; }, setVal:function( v ) { $( '[name="'+this.name+'"]' ).val( v ); v = $.trim( v ).replace( /[^\d]/g, ' ').split( ' ' ); for( var i in v ) $( '[id="' + this.name + '_' + i + '"]' ).val( v[ i ] ); } } ); $.fbuilder.controls[ 'fCommentArea' ]=function(){}; $.extend( $.fbuilder.controls[ 'fCommentArea' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Comments here", ftype:"fCommentArea", userhelp:"A description of the section goes here.", show:function() { return '
'+this.userhelp+'
'; } } ); $.fbuilder.controls[ 'fhidden' ]=function(){}; $.extend( $.fbuilder.controls[ 'fhidden' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fhidden", title:"", predefined:"", show:function() { return '
'; } } ); $.fbuilder.controls[ 'fSectionBreak' ] = function(){}; $.extend( $.fbuilder.controls[ 'fSectionBreak' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Section Break", ftype:"fSectionBreak", userhelp:"A description of the section goes here.", show:function() { return '
'+this.userhelp+'
'; } } ); $.fbuilder.controls[ 'fPageBreak' ]=function(){}; $.extend( $.fbuilder.controls[ 'fPageBreak' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Page Break", ftype:"fPageBreak", show:function() { return '
'+this.userhelp+'
'; } } ); $.fbuilder.controls[ 'fsummary' ] = function(){}; $.extend( $.fbuilder.controls[ 'fsummary' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Summary", ftype:"fsummary", fields:"", titleClassname:"summary-field-title", valueClassname:"summary-field-value", fieldsArray:[], show:function() { var me = this, p = $.trim( me.fields.replace( /\,+/g, ',') ).split( ',' ), l = p.length; if( l ) { var str = '
'+( ( !/^\s*$/.test( me.title ) ) ? '

'+me.title+'

': '' )+'
'; for( var i = 0; i < l; i++ ) { if( !/^\s*$/.test( p[ i ] ) ) { p[ i ] = $.trim( p[ i ] ); str += '
'; } } str += '
'; return str; } }, after_show: function(){ var me = this, p = $.trim(me.fields.replace( /\,+/g, ',') ).split( ',' ), l = p.length; if( l ) { for( var i = 0; i < l; i++ ) { if( !/^\s*$/.test( p[ i ] ) ) { p[ i ] = $.trim( p[ i ] ); me.fieldsArray.push( p[ i ] + me.form_identifier ); $( document ).on( 'change', '#' + p[ i ] + me.form_identifier, function(){ me.update(); } ); } } $( document ).on( 'showHideDepEvent', function( evt, form_identifier ) { me.update(); }); $( '#cp_calculatedfieldsf_pform'+me.form_identifier ).bind( 'reset', function(){ setTimeout( function(){ me.update(); }, 10 ); } ); } }, update:function() { for ( var j = 0, k = this.fieldsArray.length; j < k; j++ ) { var i = this.fieldsArray[ j ], e = $( '[id="' + i + '"]'), tt = $( '[ref="' + i + '"]'); if( e.length && tt.length ) { //var t = $( '#' + i ).closest( '.fields' ).find( 'label[for="'+i+'"]' ).text(), var t = $( '#' + i ).closest( '.fields' ).find( 'label:first' ).html(), v = []; e.each( function(){ var e = $(this); if( /(checkbox|radio)/i.test( e.attr( 'type' ) ) && !e.is( ':checked' ) ) { return; } else if( e[0].tagName == 'SELECT' ) { v.push( $(e[0].options[ e[0].selectedIndex ]).attr( 'vt' ) ); } else { if( e.attr( 'vt' ) ) { v.push( e.attr( 'vt' ) ); } else if( e.attr( 'summary' ) ) { v.push( $( '#' + i ).closest( '.fields' ).find( '.'+e.attr( 'summary' )+i ).html() ); } else { v.push( e.val() ); } } } ); try { if (t.substring(t.length-1)=='*') t = t.substring(0, t.length-1); if (t.substring(t.length-1)==':') t = t.substring(0, t.length-1); } catch (e) {} tt.find( '.cff-summary-title' ).html( ( /^\s*$/.test( t ) ) ? '' : t ); tt.find( '.cff-summary-value' ).html( v.join( ', ' ) ); if (v.join( ', ' ).trim()=="") tt.addClass("emptyvalue"); else tt.removeClass("emptyvalue"); if( e.hasClass( 'ignore' ) ) { tt.hide(); } else { tt.show(); } } } } }); $.fbuilder.controls[ 'datasource' ] = function(){}; $.fbuilder.controls[ 'datasource' ].prototype = { isDataSource:true, active : '', list : { 'database' : { databaseData: '', queryData : { active: 'structure', query: '', value: '', text: '', table: '', where: '', orderby: '' }, getData : function( callback, p ) { var url = document.location.href, data = $.extend( {}, this.queryData ); if( data.active == 'structure' ) { data.where = btoa(p.replaceVariables( data.where )); data.orderby = btoa(p.replaceVariables( data.orderby )); } else { data.query = p.replaceVariables( data.query ); } $.ajax( { dataType : 'json', url : url, cache : false, data : $.extend( { ahbqeaction1b0f65fa84b66f139dd5: 'K0JkQmI4WU5TYzJtWkRoV0d0c2lrQzR6ZU1sVlN3U2s3VlQySndac0JNVT0=' }, this.databaseData, data ), success : function( data ){ callback( data ); } } ); } }, 'csv' : { csvData : { text : 0, value : 0, fields : [], rows : [] }, getData : function( callback ) { var obj = { data : [] }; for( var i in this.csvData.rows ) { var text = this.csvData.text, value = this.csvData.value; if( typeof this.csvData.rows[ i ].length == 'undefined' ) { text = this.csvData.fields[ text ]; value = this.csvData.fields[ value ]; } obj.data.push( { text: this.csvData.rows[ i ][ text ], value : this.csvData.rows[ i ][ value ] } ); } callback( obj ); } }, 'posttype' : { posttypeData:{ posttype : '', value : '', text : '', last : '', id : '' }, getData : function( callback, p ) { var url = document.location.href, data = $.extend( {}, this.posttypeData ); if( !/^\s*$/.test( data.id ) ) { data.id = p.replaceVariables( data.id ); } $.ajax( { dataType : 'json', url : url, cache : false, data : $.extend( { ahbqeaction1b0f65fa84b66f139dd5: 'RjJobjZzNlhOb0F6dG9mL2dhSXo5QT09' }, data ), success : function( data ){ callback( data ); } } ); } }, 'taxonomy' : { taxonomyData:{ taxonomy : '', value : '', text : '', id : '', slug : '' }, getData : function( callback, p ) { var url = document.location.href, data = $.extend( {}, this.taxonomyData ); if( !/^\s*$/.test( data.id ) ) { data.id = p.replaceVariables( data.id ); } if( !/^\s*$/.test( data.slug ) ) { data.slug = p.replaceVariables( data.slug ); } $.ajax( { dataType : 'json', url : url, cache : false, data : $.extend( { ahbqeaction1b0f65fa84b66f139dd5: 'TndieElveUVZTDJZMzM0aUY0Z09pZz09' }, data ), success : function( data ){ callback( data ); } } ); } }, 'user' : { userData : { logged : false, text : '', value : '', id : '', login : '' }, getData : function( callback, p ) { var url = document.location.href, data = $.extend( {}, this.userData ); if( !data.logged ) { if( !/^\s*$/.test( data.id ) ) { data.id = p.replaceVariables( data.id ); } if( !/^\s*$/.test( data.login ) ) { data.login = p.replaceVariables( data.login ); } } $.ajax( { dataType : 'json', url : url, cache : false, data : $.extend( { ahbqeaction1b0f65fa84b66f139dd5: 'Z2dXVm9uU2pINzlSQmZCeWNrYSs5Zz09' }, data ), success : function( data ){ callback( data ); } } ); } } }, getData : function( callback ) { this.list[ this.active ].getData( callback, this ); }, replaceVariables : function( str ) { var _match, tmpArr = []; // To avoid duplicate handles while ( _match = /<[%](fieldname\d+)[%]>/.exec( str ) ) { var me = this, e = _match[ 1 ]+this.form_identifier, f = $.fbuilder[ 'forms' ][ this.form_identifier ].getItem( e ); if( ( typeof this.hasBeenPutRelationHandles == 'undefined' || !this.hasBeenPutRelationHandles ) && $.inArray( _match[ 1 ], tmpArr ) == -1 ) { $( document ).on( 'change', '#'+e, function() { me.after_show(); } ); tmpArr.push( _match[ 1 ] ); } if( f ) { str = str.replace( _match[ 0 ], f.val() ); } } this.hasBeenPutRelationHandles = true; return str; } }; $.fbuilder.controls[ 'ftextds' ]=function(){}; $.extend( $.fbuilder.controls[ 'ftextds' ].prototype, $.fbuilder.controls[ 'ftext' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"ftextds", show:function() { return $.fbuilder.controls[ 'ftext' ].prototype.show.call( this ); }, after_show : function(){ var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { if( data.data.length ) { if (!me.predefined) $( '#' + me.name ).val( data.data[ 0 ][ 'value' ] ).change(); } } } ); } }); $.fbuilder.controls[ 'femailds' ]=function(){}; $.extend( $.fbuilder.controls[ 'femailds' ].prototype, $.fbuilder.controls[ 'femail' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"femailds", show:function() { return $.fbuilder.controls[ 'femail' ].prototype.show.call( this ); }, after_show : function(){ var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { if( data.data.length ) { if (!me.predefined) $( '#' + me.name ).val( data.data[ 0 ][ 'value' ] ).change(); } } } ); } }); $.fbuilder.controls[ 'ftextareads' ]=function(){}; $.extend( $.fbuilder.controls[ 'ftextareads' ].prototype, $.fbuilder.controls[ 'ftextarea' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"ftextareads", show:function() { return $.fbuilder.controls[ 'ftextarea' ].prototype.show.call( this ); }, after_show : function(){ var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { if( data.data.length ) { if (!me.predefined) $( '#' + me.name ).val( data.data[ 0 ][ 'value' ] ).change(); } } } ); } }); $.fbuilder.controls[ 'fcheckds' ] = function(){}; $.extend( $.fbuilder.controls[ 'fcheckds' ].prototype, $.fbuilder.controls[ 'fcheck' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fdropdownds", show:function() { return '
'+this.userhelp+'
'; }, after_show : function(){ var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { var str = ''; for( var i = 0, h = data.data.length; i < h; i++ ) { var e = data.data[ i ]; str += '
'; } $( '#field' + me.form_identifier + '-' + me.index + ' .dfield' ).html( str ).change(); } } ); } }); $.fbuilder.controls[ 'fradiods' ]=function(){}; $.extend( $.fbuilder.controls[ 'fradiods' ].prototype, $.fbuilder.controls[ 'fradio' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fradiods", show:function() { return '
'+this.userhelp+'
'; }, after_show : function(){ var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { var str = ''; for( var i = 0, h = data.data.length; i < h; i++ ) { var e = data.data[ i ]; str += '
'; } $( '#field' + me.form_identifier + '-' + me.index + ' .dfield' ).html( str ).change(); } } ); } } ); $.fbuilder.controls[ 'fPhoneds' ]=function(){}; $.extend( $.fbuilder.controls[ 'fPhoneds' ].prototype, $.fbuilder.controls[ 'fPhone' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fPhoneds", show:function() { return $.fbuilder.controls[ 'fPhone' ].prototype.show.call( this ); }, after_show : function() { var me = this; $.fbuilder.controls[ 'fPhone' ].prototype.after_show.call( me ); $.fbuilder.controls[ 'datasource' ].prototype.getData.call( me, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { if( data.data.length ) { var v = data.data[ 0 ].value, p = $.trim( me.dformat.replace(/[^\s#]/g, '' ).replace( /\s+/g, ' ' ) ).split( ' ' ), h = p.length, r = '', e; for( var i = 0; i < h; i++ ) { r += '(.{' + p[ i ].length + '})'; } v = v.replace( /\s+/, '' ); e = ( new RegExp( r ) ).exec( v ); if( e ) { for( var i = 0; i < h; i++ ) { if (!me.predefined) $( '#' + me.name + '_' + i ).val( e[ i+1 ] ).change(); } } } } } ); } } ); $.fbuilder.controls[ 'fdropdownds' ] = function(){}; $.extend( $.fbuilder.controls[ 'fdropdownds' ].prototype, $.fbuilder.controls[ 'fdropdown' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fdropdownds", show:function() { this.choices = []; return $.fbuilder.controls[ 'fdropdown' ].prototype.show.call( this ); }, after_show : function(){ var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { var str = '', t, v; for( var i = 0, h = data.data.length; i < h; i++ ) { v = ( ( typeof data.data[ i ][ 'value' ] != 'undefined' ) ? data.data[ i ][ 'value' ] : '' ); t = ( ( typeof data.data[ i ][ 'text' ] != 'undefined' ) ? data.data[ i ][ 'text' ] : v ); str += ''; } $( '#' + me.name ).html( str ).change(); } } ); } }); $.fbuilder.controls[ 'fhiddends' ]=function(){}; $.extend( $.fbuilder.controls[ 'fhiddends' ].prototype, $.fbuilder.controls[ 'fhidden' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fhiddends", show:function() { return $.fbuilder.controls[ 'fhidden' ].prototype.show.call( this ); }, after_show : function() { var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { if( typeof data.error != 'undefined' ) { alert( data.error ); } else { if( data.data.length ) { if (!me.predefined) $( '#' + me.name ).val( data.data[ 0 ][ 'value' ] ).change(); } } } ); } } ); $.fbuilder.controls[ 'fcontainer' ] = function(){}; $.fbuilder.controls[ 'fcontainer' ].prototype = { fields:[], columns:1, after_show: function() { var e = $( '#'+this.name ), f; for( var i = 0, h = this.fields.length; i < h; i++ ) { f = $( '#'+this.fields[ i ]+this.form_identifier ).closest( '.fields' ).detach(); if( this.columns > 1 ) { f.addClass( 'column'+this.columns ); if( i%this.columns == 0 ) f.css( 'clear', 'left' ); } f.appendTo( e ); } }, showHideDep:function( toShow, toHide ) { var hide = ( $.inArray( this.name, toHide ) != -1 ), index; for( var i = 0, h = this.fields; i < h; i++ ) { if( $.inArray( this.fields[ i ]+this.form_identifier, toHide ) == -1 ) { toHide.push( this.fields[ i ]+this.form_identifier ); index = $.inArray( d[ i ], toShow ); if( index != -1 ) { toShow.splice( index, 1); } $( '#' + this.fields[ i ]+this.form_identifier ).closest( '.fields' ) .find( '.field' ) .each(function() { $(this).addClass('ignore'); }); } } } }; $.fbuilder.controls[ 'ffieldset' ]=function(){}; $.extend( $.fbuilder.controls[ 'ffieldset' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { title:"Untitled", ftype:"ffieldset", fields:[], columns:1, show:function() { return '
'+( ( !/^\s*$/.test( this.title ) ) ? ''+this.title+'' : '' )+'
'; }, after_show: function() { $.fbuilder.controls[ 'fcontainer' ].prototype.after_show.call(this); }, showHideDep:function( toShow, toHide ) { $.fbuilder.controls[ 'fcontainer' ].prototype.showHideDep.call( this, toShow, toHide ); } } ); $.fbuilder.controls[ 'fdiv' ]=function(){}; $.extend( $.fbuilder.controls[ 'fdiv' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fdiv", fields:[], columns:1, show:function() { return '
'; }, after_show: function() { $.fbuilder.controls[ 'fcontainer' ].prototype.after_show.call(this); }, showHideDep:function( toShow, toHide ) { $.fbuilder.controls[ 'fcontainer' ].prototype.showHideDep.call( this, toShow, toHide ); } } ); $.fbuilder.controls[ 'fMedia' ]=function(){}; $.extend( $.fbuilder.controls[ 'fMedia' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fMedia", sMediaType:"image", // image, audio, video data:{ image:{ sWidth:"", sHeight:"", sSrc:"", sAlt:"", sLink:"", sTarget:"", sFigcaption: "" }, audio:{ sWidth:"", sSrc:"", sSrcAlt:"", sControls:1, sLoop:0, sAutoplay:0, sMuted:0, sPreload: "auto", sFallback: "", sFigcaption: "" }, video:{ sWidth:"", sHeight:"", sSrc:"", sSrcAlt:"", sPoster:"", sControls:1, sLoop:0, sAutoplay:0, sMuted:0, sPreload: "auto", sFallback: "", sFigcaption: "" } }, _show_image: function() { var d = this.data.image, esc = $.fbuilder.htmlEncode, a = [], l = [], r = ''; if( $.trim( d.sWidth ) ) a.push( 'width="'+esc( d.sWidth )+'"' ); if( $.trim( d.sHeight ) ) a.push( 'height="'+esc( d.sHeight )+'"' ); if( $.trim( d.sSrc ) ) a.push( 'src="'+esc( d.sSrc )+'"' ); if( $.trim( d.sAlt ) ) a.push( 'alt="'+esc( d.sAlt )+'"' ); if( $.trim( d.sLink ) ) { l.push( 'href="'+esc( d.sLink )+'"' ); if( $.trim( d.sTarget ) ) l.push( 'target="'+esc( d.sTarget )+'"' ); r = ''; } else { r = ''; } return r; }, _show_audio_video: function( d, isV ) { var esc = $.fbuilder.htmlEncode, a = [], t = ( isV ) ? 'video' : 'audio' ; if( $.trim( d.sWidth ) ) a.push( 'width="'+esc( d.sWidth )+'"' ); if( isV && $.trim( d.sHeight ) ) a.push( 'height="'+esc( d.sHeight )+'"' ); if( isV && $.trim( d.sPoster ) ) a.push( 'poster="'+esc( d.sPoster )+'"' ); if( $.trim( d.sSrc ) ) a.push( 'src="'+esc( d.sSrc )+'"' ); if( d.sAutoplay ) a.push( 'autoplay' ); if( d.sControls ) a.push( 'controls' ); if( d.sLoop ) a.push( 'loop' ); if( d.sMuted ) a.push( 'muted' ); a.push( 'preload="'+esc( d.sPreload )+'"' ); return '<'+t+' '+a.join( ' ' )+'>'+( ( $.trim( d.sSrcAlt ) ) ? '' : '' )+'

'+d.sFallback+'

'; }, _show_audio: function() { return this._show_audio_video( this.data.audio, false ); }, _show_video: function() { return this._show_audio_video( this.data.video, true ); }, show:function() { return '
'+this[ '_show_'+this.sMediaType]()+'
'+this.data[ this.sMediaType].sFigcaption+'
'; } } ); $.fbuilder.controls[ 'fButton' ]=function(){}; $.extend( $.fbuilder.controls[ 'fButton' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fButton", sType:"button", sValue:"button", sOnclick:"", userhelp:"A description of the section goes here.", show:function() { var esc = function( v ){ v = v.replace( /</g, '&').replace(/"/g, """).replace( /\n+/g, ' ' ); return v;}, type = this.sType, clss = ''; if( this.sType == 'calculate' ) { type = 'button'; clss = 'calculate-button'; } else if( this.sType == 'reset' ) { clss = 'reset-button'; } return '
'+this.userhelp+'
'; }, after_show:function() { $( '#'+this.name ).click( function() { var e = $( this ); if( e.hasClass( 'calculate-button' ) ) { var suffix = e.attr( 'id' ).match(/_\d+$/)[0], items = $.fbuilder[ 'forms' ][ suffix ].getItems(); $.fbuilder[ 'calculator' ].defaultCalc( '#'+e.closest( 'form' ).attr( 'id' ) ); for(var i = 0, h = items.length; i < h; i++ ) { if(items[i].ftype == 'fsummary') { items[i].update(); } } } if( e.hasClass( 'reset-button' ) ) { setTimeout( function() { var identifier = e.closest( 'form' ).attr( 'id' ).replace( /cp_calculatedfieldsf_pform/, '' ); $.fbuilder[ 'showHideDep' ]( { 'formIdentifier' : identifier } ); var page = parseInt( e.closest( '.pbreak' ).attr( 'page' ) ); if( page ) { $("#fieldlist"+identifier+" .pbreak").css("display","none"); $("#fieldlist"+identifier+" .pbreak").find(".field").addClass("ignorepb"); $("#fieldlist"+identifier+" .pb0").css("display","block"); if ($("#fieldlist"+identifier+" .pb0").find(".field").length>0) { $("#fieldlist"+identifier+" .pb0").find(".field").removeClass("ignorepb"); try { $("#fieldlist"+identifier+" .pb0").find(".field")[0].focus(); } catch(e){} } } }, 50 ); } } ); } } ); $.fbuilder.controls[ 'fnumberds' ]=function(){}; $.extend( $.fbuilder.controls[ 'fnumberds' ].prototype, $.fbuilder.controls[ 'fnumber' ].prototype, $.fbuilder.controls[ 'datasource' ].prototype, { ftype:"fnumberds", show:function() { return $.fbuilder.controls[ 'fnumber' ].prototype.show.call( this ); }, after_show : function(){ var me = this; $.fbuilder.controls[ 'datasource' ].prototype.getData.call( this, function( data ) { var v = ''; if( typeof data.error != 'undefined' ) { alert( data.error ); } else { if( data.data.length ) { v = data.data[ 0 ][ 'value' ]; } } if (!me.predefined) $( '#' + me.name ).val( v ).change(); } ); } }); $.fbuilder.controls[ 'fhtml' ]=function(){}; $.extend( $.fbuilder.controls[ 'fhtml' ].prototype, $.fbuilder.controls[ 'ffields' ].prototype, { ftype:"fhtml", fcontent:"", show:function() { return '
'+$( '
' ).html( this.fcontent ).html()+'
'; } } );$.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(23, 59, 59, 999);} 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; if (!$("#fieldlist_"+fcount_tags).html().length) { 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.find(".avoid_overlapping_before").length>0) $(opt_identifier).addClass("cp_v_v"); 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); });