function frmProFormJS(){var currentlyAddingRow=false;var action="";var processesRunning=0;var lookupQueues={};var hiddenSubmitButtons=[];function setNextPage(e){var $thisObj=jQuery(this);var thisType=$thisObj.attr("type");if(thisType!=="submit")e.preventDefault();var f=$thisObj.parents("form:first"),v="",d="",thisName=this.name;if(thisName==="frm_prev_page"||this.className.indexOf("frm_prev_page")!==-1)v=jQuery(f).find(".frm_next_page").attr("id").replace("frm_next_p_","");else if(thisName==="frm_save_draft"|| this.className.indexOf("frm_save_draft")!==-1)d=1;else if(this.className.indexOf("frm_page_skip")!==-1){var goingTo=$thisObj.data("page");var formId=jQuery(f).find('input[name="form_id"]').val();var orderField=jQuery(f).find('input[name="frm_page_order_'+formId+'"]');jQuery(f).append('');if(goingTo==="")orderField.remove();else orderField.val(goingTo)}else if(this.className.indexOf("frm_page_back")!==-1)v=$thisObj.data("page"); jQuery(".frm_next_page").val(v);jQuery(".frm_saving_draft").val(d);if(thisType!=="submit")f.trigger("submit")}function toggleSection(){jQuery(this).parent().children(".frm_toggle_container").slideToggle("fast");var arrow=jQuery(this).children(".frm_arrow_icon");if(-1!==this.className.indexOf("active")){this.className=this.className.replace(" active","");arrow.attr("aria-expanded","false")}else{this.className+=" active";arrow.attr("aria-expanded","true")}}function loadDateFields(){jQuery(document).on("focusin", ".frm_date",triggerDateField);loadUniqueTimeFields()}function triggerDateField(){if(this.className.indexOf("frm_custom_date")!==-1||typeof __frmDatepicker==="undefined")return;var dateFields=__frmDatepicker,id=this.id,idParts=id.split("-"),altID="";if(isRepeatingFieldByName(this.name))altID='input[id^="'+idParts[0]+'"]';else altID='input[id^="'+idParts.join("-")+'"]';jQuery.datepicker.setDefaults(jQuery.datepicker.regional[""]);var optKey=0;for(var i=0;i0)max=max-uploadedCount}var form=field.closest("form");field.dropzone({url:frm_js.ajax_url,addRemoveLinks:false,paramName:field.attr("id").replace("_dropzone",""),maxFilesize:uploadFields[i].maxFilesize,maxFiles:max,uploadMultiple:uploadFields[i].uploadMultiple,hiddenInputContainer:field.parent()[0],dictDefaultMessage:uploadFields[i].defaultMessage,dictFallbackMessage:uploadFields[i].fallbackMessage, dictFallbackText:uploadFields[i].fallbackText,dictFileTooBig:uploadFields[i].fileTooBig,dictInvalidFileType:uploadFields[i].invalidFileType,dictResponseError:uploadFields[i].responseError,dictCancelUpload:uploadFields[i].cancel,dictCancelUploadConfirmation:uploadFields[i].cancelConfirm,dictRemoveFile:uploadFields[i].remove,dictMaxFilesExceeded:uploadFields[i].maxFilesExceeded,resizeMethod:"contain",resizeWidth:uploadFields[i].resizeWidth,resizeHeight:uploadFields[i].resizeHeight,thumbnailWidth:60, thumbnailHeight:60,timeout:uploadFields[i].timeout,previewTemplate:filePreviewHTML(uploadFields[i]),acceptedFiles:uploadFields[i].acceptedFiles,fallback:function(){jQuery(this.element).closest("form").removeClass("frm_ajax_submit")},init:function(){var hidden=field.parent().find(".dz-hidden-input");if(typeof hidden.attr("id")==="undefined")hidden.attr("id",uploadFields[i].label);this.on("sending",function(file,xhr,formData){if(!anyPrecedingRequiredFieldsCompleted(uploadFields[i],selector)){this.removeFile(file); alert(frm_js.empty_fields);return false}else if(isSpam(uploadFields[i].parentFormID)){this.removeFile(file);alert(frm_js.file_spam);return false}else{formData.append("action","frm_submit_dropzone");formData.append("field_id",uploadFields[i].fieldID);formData.append("form_id",uploadFields[i].formID);formData.append("nonce",frm_js.nonce)}});this.on("success",function(file,response){var mediaIDs=jQuery.parseJSON(response);for(var m=0;m'+file.name+""}}});this.on("addedfile",function(){processesRunning++;frmFrontForm.showSubmitLoading(form)});this.on("removedfile",function(file){var fileCount=this.files.length;if(this.options.uploadMultiple===false&&fileCount<1)this.enable();if(file.accepted!==false&& uploadFields[i].uploadMultiple!==true)jQuery('input[name="'+fieldName+'"]').val("");if(file.accepted!==false&&typeof file.mediaID!=="undefined"){jQuery(file.previewElement).remove();fileCount=this.files.length;this.options.maxFiles=uploadFields[i].maxFiles-fileCount}});if(typeof uploadFields[i].mockFiles!=="undefined")for(var f=0;f\n'+'
\n'+'
\n'+'
\n'+'
\n'+'
\n'+ ''+"
\n"+'
\n'+'
\n'+"
\n"+""}function getHiddenUploadHTML(field,mediaID,fieldName){return''}function removeFile(){var fieldName= jQuery(this).data("frm-remove");fadeOut(jQuery(this).closest(".dz-preview"));var singleField=jQuery('input[name="'+fieldName+'"]');if(singleField.length)singleField.val("")}function isSpam(formID){if(isHoneypotSpam(formID)||isHeadless())return true;else return false}function isHoneypotSpam(formID){var val=document.getElementById("frm_verify_"+formID).value;return val!==""}function isHeadless(){return window._phantom||window.callPhantom||window.__phantomas||window.Buffer||window.emit||window.spawn} function anyPrecedingRequiredFieldsCompleted(uploadField,fileSelector){var prevPage,requiredFields,fieldsComplete=true,dropzoneDiv=jQuery(fileSelector),form=dropzoneDiv.closest("form");if(form.length<1)return false;prevPage=form.find('input[name="frm_prev_page"]');if(prevPage.length)return true;requiredFields=jQuery(form).find(".frm_required_field:visible input, .frm_required_field:visible select, .frm_required_field:visible textarea, "+fileSelector);if(requiredFields.length<1)return true;else{for(var r= 0,rl=requiredFields.length;r-1||requiredFields[r].getAttribute("data-frmfile")!==null)continue;if(frmFrontForm.checkRequiredField(requiredFields[r],[]).length<1){fieldsComplete=true;break}else fieldsComplete=false}return fieldsComplete}}function showOtherText(){var type=this.type,other=false,select=false;if(type==="select-one"){select=true;var curOpt=this.options[this.selectedIndex];if(typeof curOpt!== "undefined"&&curOpt.className==="frm_other_trigger")other=true}else if(type==="select-multiple"){select=true;var allOpts=this.options;other=false;for(var i=0;i-1)originalEvent="value changed";else originalEvent="other";return originalEvent}function checkFieldsWithConditionalLogicDependentOnThis(fieldId, changedInput){if(typeof __FRMRULES==="undefined"||typeof __FRMRULES[fieldId]==="undefined"||__FRMRULES[fieldId].dependents.length<1||changedInput===null||typeof changedInput==="undefined")return;var triggerFieldArgs=__FRMRULES[fieldId];var repeatArgs=getRepeatArgsFromFieldName(changedInput[0].name);for(var i=0,l=triggerFieldArgs.dependents.length;id},"<=":function(c,d){return c>=d},">":function(c,d){return c=":function(c,d){return c<=d},"LIKE":function(c,d){if(!d)return false;c=prepareLogicValueForLikeComparison(c);d=prepareEnteredValueForLikeComparison(c,d);return d.indexOf(c)!=-1},"not LIKE":function(c,d){if(!d)return true;c=prepareLogicValueForLikeComparison(c);d=prepareEnteredValueForLikeComparison(c,d);return d.indexOf(c)==-1}};return theOperators[op](a,b)}function prepareLogicValueForComparison(a){if(String(a).search(/^\s*(\+|-)?((\d+(\.\d+)?)|(\.\d+))\s*$/)!== -1)a=parseFloat(a);else if(typeof a==="string")a=a.trim();return a}function prepareEnteredValueForComparison(a,b){if(typeof b==="undefined"||b===null||b===false)b="";if(jQuery.isArray(b)&&jQuery.inArray(String(a),b)>-1)b=a;if(typeof a==="number"&&typeof b==="string")b=parseFloat(b);if(typeof b==="string")b=b.trim();return b}function prepareLogicValueForLikeComparison(val){return prepareValueForLikeComparison(val)}function prepareEnteredValueForLikeComparison(logicValue,enteredValue){enteredValue= prepareValueForLikeComparison(enteredValue);var currentValue="";if(jQuery.isArray(enteredValue))for(var i=0,l=enteredValue.length;i-1){enteredValue=logicValue;break}}return enteredValue}function prepareValueForLikeComparison(val){if(typeof val==="string")val=val.toLowerCase();else if(typeof val==="number")val=val.toString();return val}function routeToHideOrShowField(depFieldArgs,logicOutcomes){var onCurrentPage, action=getHideOrShowAction(depFieldArgs,logicOutcomes);if(depFieldArgs.fieldType==="submit")onCurrentPage=isSubmitButtonOnPage(depFieldArgs.containerId);else onCurrentPage=isFieldDivOnPage(depFieldArgs.containerId);if(action=="show")if(depFieldArgs.fieldType==="data"&&depFieldArgs.hasOwnProperty("dataLogic"))updateDynamicField(depFieldArgs,onCurrentPage);else showFieldAndSetValue(depFieldArgs,onCurrentPage);else hideFieldAndClearValue(depFieldArgs,onCurrentPage)}function isFieldDivOnPage(containerId){var fieldDiv= document.getElementById(containerId);return fieldDiv!==null}function isSubmitButtonOnPage(container){var submitButton=document.querySelector("#"+container);return submitButton!=null}function getHideOrShowAction(depFieldArgs,logicOutcomes){if(depFieldArgs.anyAll==="any")if(logicOutcomes.indexOf(true)>-1)action=depFieldArgs.showHide;else action=reverseAction(depFieldArgs.showHide);else if(logicOutcomes.indexOf(false)>-1)action=reverseAction(depFieldArgs.showHide);else action=depFieldArgs.showHide;return action} function reverseAction(action){if(action==="show")action="hide";else action="show";return action}function showFieldAndSetValue(depFieldArgs,onCurrentPage){if(isFieldCurrentlyShown(depFieldArgs.containerId,depFieldArgs.formId))return;removeFromHideFields(depFieldArgs.containerId,depFieldArgs.formId);if(depFieldArgs.fieldType==="submit"){if(onCurrentPage)showOrEnableSubmitButton(depFieldArgs);return}if(onCurrentPage){setValuesInsideFieldOnPage(depFieldArgs.containerId,depFieldArgs);showFieldContainer(depFieldArgs.containerId)}else setValuesInsideFieldAcrossPage(depFieldArgs)} function showOrEnableSubmitButton(depFieldArgs){if(depFieldArgs.hideDisable&&depFieldArgs.hideDisable==="disable")enableButton("#"+depFieldArgs.containerId);else showFieldContainer(depFieldArgs.containerId);removeSubmitButtonFromHiddenList(depFieldArgs)}function removeSubmitButtonFromHiddenList(depFieldArgs){hiddenSubmitButtons=hiddenSubmitButtons.filter(function(button){return button!==depFieldArgs.formKey})}function enableButton(buttonSelector){jQuery(buttonSelector).prop("disabled",false)}function setValuesInsideFieldOnPage(container, depFieldArgs){var inputs=getInputsInFieldOnPage(container),inContainer=depFieldArgs.fieldType==="divider"||depFieldArgs.fieldType==="form";setValueForInputs(inputs,inContainer,depFieldArgs.formId,"required")}function setValuesInsideFieldAcrossPage(depFieldArgs){var inputs=getInputsInFieldAcrossPage(depFieldArgs),inContainer=depFieldArgs.fieldType==="divider"||depFieldArgs.fieldType==="form";setValueForInputs(inputs,inContainer,depFieldArgs.formId)}function getInputsInFieldOnPage(containerId){var container= document.getElementById(containerId);return container.querySelectorAll('select[name^="item_meta"], textarea[name^="item_meta"], input[name^="item_meta"]')}function getInputsInFieldAcrossPage(depFieldArgs){var inputs=[];if(depFieldArgs.fieldType==="divider")inputs=getInputsInHiddenSection(depFieldArgs);else if(depFieldArgs.fieldType==="form")inputs=getInputsInHiddenEmbeddedForm(depFieldArgs);else inputs=getHiddenInputs(depFieldArgs);return inputs}function getHiddenInputs(depFieldArgs){var name=""; if(depFieldArgs.isRepeating){var containerFieldId=getContainerFieldId(depFieldArgs);name="item_meta["+containerFieldId+"]["+depFieldArgs.repeatRow+"]["+depFieldArgs.fieldId+"]"}else name="item_meta["+depFieldArgs.fieldId+"]";return document.querySelectorAll('[name^="'+name+'"]')}function setValueForInputs(inputs,inContainer,formId,setRequired){if(inputs.length){var prevInput;for(var i=0;i -1&&is_optional===-1)input.setAttribute("aria-required",true)}function skipSetValue(i,prevInput,inputs){var typeArray=["checkbox","radio"];if(i<1||typeof prevInput==="undefined")return false;var isOther=inputs[i].className.indexOf("frm_other_input")!==-1;return isOther||prevInput.name==inputs[i].name&&typeArray.indexOf(prevInput.type)>-1}function isChildInputConditionallyHidden(input,formId){var fieldDivPart=frmFrontForm.getFieldId(input,true),fieldDivId="frm_field_"+fieldDivPart+"_container";return isFieldConditionallyHidden(fieldDivId, formId)}function showFieldContainer(containerId){jQuery("#"+containerId).show()}function hideFieldAndClearValue(depFieldArgs,onCurrentPage){if(isFieldConditionallyHidden(depFieldArgs.containerId,depFieldArgs.formId))return;addToHideFields(depFieldArgs.containerId,depFieldArgs.formId);if(depFieldArgs.fieldType==="submit"){if(onCurrentPage)hideOrDisableSubmitButton(depFieldArgs);return}if(onCurrentPage){hideFieldContainer(depFieldArgs.containerId);clearInputsInFieldOnPage(depFieldArgs.containerId)}else clearInputsInFieldAcrossPage(depFieldArgs)} function hideOrDisableSubmitButton(depFieldArgs){if(depFieldArgs.containerId==undefined)depFieldArgs.containerId=getSubmitButtonContainerID(depFieldArgs);addSubmitButtonToHiddenList(depFieldArgs);if(depFieldArgs.hideDisable&&depFieldArgs.hideDisable==="disable")disableButton("#"+depFieldArgs.containerId);else hideFieldContainer(depFieldArgs.containerId)}function addSubmitButtonToHiddenList(depFieldArgs){hiddenSubmitButtons.push(depFieldArgs.formKey)}function isOnPageSubmitButtonHidden(formKey){return hiddenSubmitButtons.indexOf(formKey)!== -1}function hidePreviouslyHiddenSubmitButton(submitContainerID){var formId=submitContainerID.replace("frm_form_","");formId=formId.replace("_container .frm_final_submit","");var depFieldArgs=getRulesForSingleField("submit_"+formId);if(depFieldArgs)hideOrDisableSubmitButton(depFieldArgs)}function getFormKeyFromFormElementID(elementId){return elementId.replace("form_","")}function hideFieldContainer(containerId){jQuery("#"+containerId).hide()}function disableButton(buttonSelector){jQuery(buttonSelector).prop("disabled", true)}function clearInputsInFieldOnPage(containerId){var inputs=getInputsInFieldOnPage(containerId);clearValueForInputs(inputs,"required")}function clearInputsInFieldAcrossPage(depFieldArgs){var inputs=getInputsInFieldAcrossPage(depFieldArgs);clearValueForInputs(inputs)}function getInputsInHiddenSection(depFieldArgs){var inputs=[];if(depFieldArgs.fieldType==="divider")inputs=document.querySelectorAll('[data-sectionid="'+depFieldArgs.fieldId+'"]');return inputs}function getInputsInHiddenEmbeddedForm(depFieldArgs){return document.querySelectorAll('[id^="field_'+ depFieldArgs.fieldKey+'-"]')}function clearValueForInputs(inputs,required){if(inputs.length<1)return;var prevInput,blankSelect,valueChanged=true;for(var i=0,l=inputs.length;i-1||inputs[i].name.indexOf("[row_ids]")>-1){prevInput=inputs[i];continue}if(i>0&&prevInput.name!=inputs[i].name&&valueChanged===true)triggerChange(jQuery(prevInput));valueChanged=true;if(inputs[i].type==="radio"||inputs[i].type==="checkbox")inputs[i].checked=false;else if(inputs[i].tagName=== "SELECT"){blankSelect=inputs[i].selectedIndex===0&&inputs[i].options[0].text.trim()==="";if(blankSelect||inputs[i].selectedIndex===-1)valueChanged=false;else inputs[i].selectedIndex=-1;var chosenId=inputs[i].id.replace(/[^\w]/g,"_");var autocomplete=document.getElementById(chosenId+"_chosen");if(autocomplete!==null)jQuery(inputs[i]).trigger("chosen:updated")}else if(inputs[i].type==="range")inputs[i].value=0;else if(inputs[i].getAttribute("data-frmprice")!==null)setHiddenProduct(inputs[i]);else inputs[i].value= "";if(required==="required"){inputs[i].required=false;inputs[i].setAttribute("aria-required",false)}prevInput=inputs[i]}if(valueChanged===true)triggerChange(jQuery(prevInput))}function isFieldCurrentlyShown(containerId,formId){return isFieldConditionallyHidden(containerId,formId)===false}function isFieldConditionallyHidden(containerId,formId){var hidden=false,hiddenFields=getHiddenFields(formId);if(hiddenFields.indexOf(containerId)>-1)hidden=true;return hidden}function clearHideFields(){var hideFieldInputs= document.querySelectorAll('[id^="frm_hide_fields_"]');clearValueForInputs(hideFieldInputs)}function addToHideFields(htmlFieldId,formId){var hiddenFields=getHiddenFields(formId);if(hiddenFields.indexOf(htmlFieldId)>-1);else{hiddenFields.push(htmlFieldId);hiddenFields=JSON.stringify(hiddenFields);var frmHideFieldsInput=document.getElementById("frm_hide_fields_"+formId);if(frmHideFieldsInput!==null)frmHideFieldsInput.value=hiddenFields}}function getAllHiddenFields(){var formId,i,hiddenFields=[],hideFieldInputs= document.querySelectorAll('*[id^="frm_hide_fields_"]'),formTotal=hideFieldInputs.length;for(i=0;i0)defaultValue=$select.data("frmval")}placeholder=defaultValue;defaultValue=setDropdownPlaceholder(defaultValue,input);if(placeholder!==defaultValue)placeholder=true;if(typeof defaultValue!=="undefined"){var numericKey=new RegExp(/\[\d*\]$/i);if(input.type==="checkbox"||input.type==="radio")setCheckboxOrRadioDefaultValue(input.name,defaultValue);else if(input.type==="hidden"&&input.name.indexOf("[]")>-1)setHiddenCheckboxDefaultValue(input.name,defaultValue);else if(!inContainer&& input.type==="hidden"&&input.name.indexOf("][")>-1&&numericKey.test(input.name))setHiddenCheckboxDefaultValue(input.name.replace(numericKey,""),defaultValue);else{if(defaultValue.constructor===Object){var addressType=input.getAttribute("name").split("[").slice(-1)[0];if(addressType!==null){addressType=addressType.replace("]","");defaultValue=defaultValue[addressType];if(typeof defaultValue=="undefined")defaultValue=""}}if(typeof defaultValue==="object")defaultValue="["+defaultValue+"]";input.value= defaultValue}if(!placeholder&&input.tagName==="SELECT"){maybeUpdateChosenOptions(input);if(input.value==="")setOtherSelectValue(input,defaultValue)}triggerChange($input)}}function setDropdownPlaceholder(defaultValue,input){var placeholder;if(typeof defaultValue==="undefined"&&input.tagName==="SELECT"){placeholder=input.getAttribute("data-placeholder");if(placeholder!==null)defaultValue=""}return defaultValue}function setCheckboxOrRadioDefaultValue(inputName,defaultValue){var radioInputs=document.getElementsByName(inputName), isSet=false,firstInput=false;if(typeof defaultValue==="object")defaultValue=Object.keys(defaultValue).map(function(key){return defaultValue[key]});for(var i=0,l=radioInputs.length;i -1){radioInputs[i].checked=true;isSet=true;if(radioInputs[i].type==="radio")break}}if(!isSet&&firstInput!==false)setOtherValueLimited(firstInput,defaultValue)}function setHiddenCheckboxDefaultValue(inputName,defaultValue){var hiddenInputs=jQuery('input[name^="'+inputName+'"]').get();if(typeof defaultValue==="object")defaultValue=Object.keys(defaultValue).map(function(key){return defaultValue[key]});if(jQuery.isArray(defaultValue))for(var i=0,l=defaultValue.length;i-1){hiddenFields.splice(itemIndex,1);hiddenFields=JSON.stringify(hiddenFields);var frmHideFieldsInput=document.getElementById("frm_hide_fields_"+formId);frmHideFieldsInput.value=hiddenFields}}function checkFieldsWatchingLookup(fieldId, changedInput,originalEvent){if(typeof __FRMLOOKUP==="undefined"||typeof __FRMLOOKUP[fieldId]==="undefined"||__FRMLOOKUP[fieldId].dependents.length<1||changedInput===null||typeof changedInput==="undefined")return;var triggerFieldArgs=__FRMLOOKUP[fieldId];var parentRepeatArgs=getRepeatArgsFromFieldName(changedInput[0].name);for(var i=0,l=triggerFieldArgs.dependents.length;i-1&&jQuery().chosen)jQuery(childSelect).trigger("chosen:updated")}function disableLookup(childSelect){childSelect.className=childSelect.className+" frm_loading_lookup";childSelect.disabled=true;maybeUpdateChosenOptions(childSelect)}function disableFormPreLookup(formId){processesRunning++;if(processesRunning===1){var form=getFormById(formId);if(form!==null)frmFrontForm.showSubmitLoading(jQuery(form))}} function enableFormAfterLookup(formId){processesRunning--;if(processesRunning<=0){var form=getFormById(formId);if(form!==null)frmFrontForm.removeSubmitLoading(jQuery(form),"enable",processesRunning)}}function getFormById(formId){var form=document.querySelector("#frm_form_"+formId+"_container form");if(form===null){form=document.getElementById("frm_form_"+formId+"_container");if(form!==null)form=form.closest("form")}return form}function enableLookup(childSelect,isReadOnly){if(isReadOnly===false)childSelect.disabled= false;childSelect.className=childSelect.className.replace(" frm_loading_lookup","")}function replaceSelectLookupFieldOptions(fieldArgs,childSelect,newOptions){var origVal=childSelect.value;for(var i=childSelect.options.length;i>0;i--)childSelect.remove(i);var optsLength=newOptions.length;for(i=0;i0}function addLookupToQueueOfTwo(childFieldArgs,childInput){var elementId=childInput.id;if(elementId in lookupQueues){if(lookupQueues[elementId].length>=2)lookupQueues[elementId]=lookupQueues[elementId].slice(0,1)}else lookupQueues[elementId]=[];lookupQueues[elementId].push({childFieldArgs:childFieldArgs, childInput:childInput})}function checkQueueAfterLookupCompleted(elementId){removeLookupFromQueue(elementId);doNextItemInLookupQueue(elementId)}function removeLookupFromQueue(elementId){lookupQueues[elementId].shift()}function doNextItemInLookupQueue(elementId){if(currentLookupHasQueue(elementId)){var childFieldArgs=lookupQueues[elementId][0].childFieldArgs,childInput=lookupQueues[elementId][0].childInput;maybeInsertValueInFieldWatchingLookup(childFieldArgs,childInput)}}function insertValueInFieldWatchingLookup(fieldKey, childInput,newValue){newValue=newValue.replace(/&/g,"&");childInput.value=newValue;triggerChange(jQuery(childInput),fieldKey)}function addRepeatRowForInput(fieldName,childFieldArgs){var repeatArgs=getRepeatArgsFromFieldName(fieldName);if(repeatArgs.repeatRow!=="")childFieldArgs.repeatRow=repeatArgs.repeatRow;else childFieldArgs.repeatRow=""}function updateDynamicField(depFieldArgs,onCurrentPage){var depFieldArgsCopy=cloneObjectForDynamicFields(depFieldArgs);if(depFieldArgsCopy.inputType==="data")updateDynamicListData(depFieldArgsCopy, onCurrentPage);else if(onCurrentPage)updateDynamicFieldOptions(depFieldArgsCopy)}function cloneObjectForDynamicFields(depFieldArgs){var dataLogic={actualValue:depFieldArgs.dataLogic.actualValue,fieldId:depFieldArgs.dataLogic.fieldId};var dynamicFieldArgs={fieldId:depFieldArgs.fieldId,fieldKey:depFieldArgs.fieldKey,formId:depFieldArgs.formId,containerId:depFieldArgs.containerId,repeatRow:depFieldArgs.repeatRow,dataLogic:dataLogic,children:"",inputType:depFieldArgs.inputType};return dynamicFieldArgs} function updateDynamicListData(depFieldArgs,onCurrentPage){if(onCurrentPage){var $fieldDiv=jQuery("#"+depFieldArgs.containerId);addLoadingIcon($fieldDiv)}jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_get_data",entry_id:depFieldArgs.dataLogic.actualValue,current_field:depFieldArgs.fieldId,hide_id:depFieldArgs.containerId,on_current_page:onCurrentPage,nonce:frm_js.nonce},success:function(html){if(onCurrentPage){var $optContainer=$fieldDiv.find(".frm_opt_container, .frm_data_container"); $optContainer.html(html);var $listInputs=$optContainer.children("input");var listVal=$listInputs.val();removeLoadingIcon($optContainer);if(html===""||listVal==="")hideDynamicField(depFieldArgs);else showDynamicField(depFieldArgs,$fieldDiv,$listInputs,true)}else updateHiddenDynamicListField(depFieldArgs,html)}})}function updateDynamicFieldOptions(depFieldArgs,fieldElement){var $fieldDiv=jQuery("#"+depFieldArgs.containerId),$fieldInputs=$fieldDiv.find('select[name^="item_meta"], input[name^="item_meta"]'), prevValue=getFieldValueFromInputs($fieldInputs),defaultVal=$fieldInputs.data("frmval"),editingEntry=$fieldDiv.closest("form").find('input[name="id"]').val();addLoadingIcon($fieldDiv);jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_fields_ajax_data_options",trigger_field_id:depFieldArgs.dataLogic.fieldId,entry_id:depFieldArgs.dataLogic.actualValue,field_id:depFieldArgs.fieldId,default_value:defaultVal,container_id:depFieldArgs.containerId,editing_entry:editingEntry,prev_val:prevValue, nonce:frm_js.nonce},success:function(html){var $optContainer=$fieldDiv.find(".frm_opt_container, .frm_data_container");$optContainer.html(html);var $dynamicFieldInputs=$optContainer.find('select, input[type="checkbox"], input[type="radio"]');removeLoadingIcon($optContainer);if(html===""||$dynamicFieldInputs.length<1)hideDynamicField(depFieldArgs);else{var valueChanged=dynamicFieldValueChanged(depFieldArgs,$dynamicFieldInputs,prevValue);showDynamicField(depFieldArgs,$fieldDiv,$dynamicFieldInputs,valueChanged)}}})} function dynamicFieldValueChanged(depFieldArgs,$dynamicFieldInputs,prevValue){var newValue=getFieldValueFromInputs($dynamicFieldInputs);return prevValue!==newValue}function updateHiddenDynamicListField(depFieldArgs,newValue){var inputId="field_"+depFieldArgs.fieldKey;if(depFieldArgs.repeatRow!=="")inputId+="-"+depFieldArgs.repeatRow;var listInput=document.getElementById(inputId);if(listInput===null)return;listInput.value=newValue;if(isFieldConditionallyHidden(depFieldArgs.containerId,depFieldArgs.formId))removeFromHideFields(depFieldArgs.containerId, depFieldArgs.formId);triggerChange(jQuery(listInput))}function addLoadingIcon($fieldDiv){var currentHTML=$fieldDiv.html();if(currentHTML.indexOf("frm-loading-img")>-1);else{var loadingIcon='';$fieldDiv.html(currentHTML+loadingIcon);var $optContainer=$fieldDiv.find(".frm_opt_container, .frm_data_container");$optContainer.hide()}}function addLoadingIconJS(fieldDiv,optContainer){var currentHTML=fieldDiv.innerHTML;if(currentHTML.indexOf("frm-loading-img")>-1);else{optContainer.style.display= "none";var loadingIcon=document.createElement("span");loadingIcon.setAttribute("class","frm-loading-img");fieldDiv.insertBefore(loadingIcon,optContainer.nextSibling)}}function removeLoadingIcon($optContainer){$optContainer.parent().children(".frm-loading-img").remove();$optContainer.show()}function removeLoadingIconJS(fieldDiv,optContainer){var loadingIcon=fieldDiv.getElementsByClassName("frm-loading-img")[0];if(loadingIcon!==null&&loadingIcon!==undefined)loadingIcon.parentNode.removeChild(loadingIcon); optContainer.style.display="block"}function getFieldValueFromInputs($inputs){var fieldValue=[],currentValue="";$inputs.each(function(){currentValue=this.value;if(this.type==="radio"||this.type==="checkbox"){if(this.checked===true)fieldValue.push(currentValue)}else if(currentValue!=="")fieldValue.push(currentValue)});if(fieldValue.length===0)fieldValue="";return fieldValue}function hideDynamicField(depFieldArgs){hideFieldAndClearValue(depFieldArgs,true)}function showDynamicField(depFieldArgs,$fieldDiv, $fieldInputs,valueChanged){if(isFieldConditionallyHidden(depFieldArgs.containerId,depFieldArgs.formId)){removeFromHideFields(depFieldArgs.containerId,depFieldArgs.formId);$fieldDiv.show()}if($fieldInputs.hasClass("frm_chzn"))loadChosen();if(valueChanged===true)triggerChange($fieldInputs)}function triggerCalc(){if(typeof __FRMCALC==="undefined")return;var triggers=__FRMCALC.triggers;if(triggers)jQuery(triggers.join()).trigger({type:"change",selfTriggered:true});triggerCalcWithoutFields()}function triggerCalcWithoutFields(){var calcs= __FRMCALC.calc,vals=[];for(var fieldKey in calcs)if(calcs[fieldKey].fields.length<1){var totalField=document.getElementById("field_"+fieldKey);if(totalField!==null&&!isChildInputConditionallyHidden(totalField,calcs[fieldKey].form_id))doSingleCalculation(__FRMCALC,fieldKey,vals)}}function doCalculation(fieldId,triggerField){if(typeof __FRMCALC==="undefined")return;var allCalcs=__FRMCALC,calc=allCalcs.fields[fieldId],vals=[];if(typeof calc==="undefined")return;var keys=calc.total;var len=keys.length; var pages=getStartEndPage(allCalcs.calc[keys[0]]);for(var i=0,l=len;i0)pages.start=hasPreviousPage[0];if(hasAnotherPage!==null)pages.end=hasAnotherPage; return pages}function closest(el,fn){return el&&(fn(el)?el:closest(el.parentNode,fn))}function isTotalFieldOnPage(calcDetails,pages){if(typeof pages.start!=="undefined"||typeof pages.end!=="undefined"){var hiddenTotalField=jQuery('input[type=hidden][name*="['+calcDetails.field_id+']"]');if(hiddenTotalField.length)return isHiddenTotalOnPage(hiddenTotalField,pages)}return true}function isHiddenTotalOnPage(hiddenTotalField,pages){var onPage,hiddenParent=hiddenTotalField.closest(".frm_form_field");if(hiddenParent.length)return true; var totalPos=hiddenTotalField.index();var isAfterStart=true;var isBeforeEnd=true;if(typeof pages.start!=="undefined")isAfterStart=jQuery(pages.start).index()totalPos;onPage=isAfterStart&&isBeforeEnd;if(!onPage)onPage=hiddenTotalField.closest(".do-calculation").length>0;return onPage}function isTotalFieldConditionallyHidden(calcDetails,triggerFieldName){var hidden=false,fieldId=calcDetails.field_id,formId=calcDetails.form_id, hiddenFields=getHiddenFields(formId);if(hiddenFields.length<1)return hidden;if(calcDetails.inSection==="0"&&calcDetails.inEmbedForm==="0")hidden=isNonRepeatingFieldConditionallyHidden(fieldId,hiddenFields);else{var repeatArgs=getRepeatArgsFromFieldName(triggerFieldName);if(isNonRepeatingFieldConditionallyHidden(fieldId,hiddenFields))hidden=true;else if(isRepeatingFieldConditionallyHidden(fieldId,repeatArgs,hiddenFields))hidden=true;else if(calcDetails.inSection!=="0"&&calcDetails.inEmbedForm!=="0")hidden= isRepeatingFieldConditionallyHidden(calcDetails.inSection,repeatArgs,hiddenFields);else if(calcDetails.inSection!=="0")hidden=isNonRepeatingFieldConditionallyHidden(calcDetails.inSection,hiddenFields);else if(calcDetails.inEmbedForm!=="0")hidden=isNonRepeatingFieldConditionallyHidden(calcDetails.inEmbedForm,hiddenFields)}return hidden}function isNonRepeatingFieldConditionallyHidden(fieldId,hiddenFields){var htmlID="frm_field_"+fieldId+"_container";return hiddenFields.indexOf(htmlID)>-1}function isRepeatingFieldConditionallyHidden(fieldId, repeatArgs,hiddenFields){var hidden=false;if(repeatArgs.repeatingSection){var fieldRepeatId="frm_field_"+fieldId+"-"+repeatArgs.repeatingSection;fieldRepeatId+="-"+repeatArgs.repeatRow+"_container";hidden=hiddenFields.indexOf(fieldRepeatId)>-1}return hidden}function maybeShowCalculationsErrorAlert(err,fieldKey,thisFullCalc){var alertMessage="";if(!jQuery("form").hasClass("frm-admin-viewing"))return;alertMessage+=frm_js.calc_error+" "+fieldKey+":\n\n";alertMessage+=thisFullCalc+"\n\n";if(err.message)alertMessage+= err.message+"\n\n";alert(alertMessage)}function doSingleCalculation(allCalcs,fieldKey,vals,triggerField){var currency,total,dec,thisCalc=allCalcs.calc[fieldKey],thisFullCalc=thisCalc.calc,totalField=jQuery(document.getElementById("field_"+fieldKey)),fieldInfo={triggerField:triggerField,inSection:false,thisFieldCall:'input[id^="field_'+fieldKey+'-"]'};if(totalField.length<1&&typeof triggerField!=="undefined"){fieldInfo.inSection=true;fieldInfo.thisFieldId=objectSearch(allCalcs.fieldsWithCalc,fieldKey); totalField=getSiblingField(fieldInfo)}if(totalField===null||totalField.length<1)return;thisFullCalc=getValsForSingleCalc(thisCalc,thisFullCalc,allCalcs,vals,fieldInfo);total="";dec="";if(thisCalc.calc_type==="text")total=thisFullCalc;else{dec=thisCalc.calc_dec;if(thisFullCalc.indexOf(").toFixed(")>-1){var calcParts=thisFullCalc.split(").toFixed(");if(isNumeric(calcParts[1])){dec=calcParts[1];thisFullCalc=thisFullCalc.replace(").toFixed("+dec,"")}}thisFullCalc=trimNumericCalculation(thisFullCalc); if(thisFullCalc!=="")try{total=parseFloat(eval(thisFullCalc))}catch(err){maybeShowCalculationsErrorAlert(err,fieldKey,thisFullCalc)}if(typeof total==="undefined"||isNaN(total))total=0;if(isNumeric(dec)&&total!=="")total=total.toFixed(dec)}if(thisCalc.is_currency===true&&isNumeric(total)){currency=getCurrency(thisCalc.form_id);if(currency.decimals>0){total=Math.round10(total,currency.decimals);total=maybeAddTrailingZeroToPrice(total,currency);dec=currency.decimals}}if(totalField.val()===total){setDisplayedTotal(totalField, total,currency);return}if((isNumeric(dec)||thisCalc.is_currency)&&totalField.attr("type")==="number")if(total.toString().slice(-1)=="0"&&navigator.userAgent.toLowerCase().indexOf("firefox")>-1)totalField[0].setAttribute("type","text");totalField.val(total);if(triggerField===null||typeof triggerField==="undefined"||totalField.attr("name")!=triggerField.attr("name"))triggerChange(totalField,fieldKey);setDisplayedTotal(totalField,total,currency)}function setDisplayedTotal(totalField,total,currency){var prepend, append,showTotal=totalField.parent().prev();if(!showTotal.hasClass("frm_total_formatted"))return;prepend=showTotal.data("prepend");append=showTotal.data("append");if(typeof prepend==="undefined")prepend="";if(typeof append==="undefined")append="";if(typeof currency==="object"){total=formatCurrency(total,currency);if(currency.symbol_left===prepend)prepend="";if(currency.symbol_right===append)append=""}if(prepend!=="")prepend=''+prepend+"";if(append!=="")append=''+ append+"";showTotal.html(prepend+''+total+""+append)}function getValsForSingleCalc(thisCalc,thisFullCalc,allCalcs,vals,fieldInfo){var fCount=thisCalc.fields.length;for(var f=0,c=fCount;f=3}function getCalcFieldId(field,allCalcs,vals){if(typeof vals[field.valKey]!=="undefined"&&vals[field.valKey]!==0)return vals;vals[field.valKey]=0;var currency,calcField=getCalcField(field);if(calcField===false)return vals;calcField.each(function(){var thisVal=getOptionValue(field.thisField,this);if(field.thisField.type==="date"){var d=getDateFieldValue(allCalcs.date, thisVal);if(d!==null)vals[field.valKey]=Math.ceil(d/(1E3*60*60*24))}else if(this.hasAttribute("data-frmprice")||field.thisField.type==="total"){currency=getCurrency(field.formID);vals[field.valKey]+=parseFloat(!currency?thisVal:preparePrice(thisVal,currency))}else{var n=thisVal;if(n!==""&&n!==0){n=n.trim();n=parseFloat(n.replace(/,/g,"").match(/-?[\d\.]+$/))}if(typeof n==="undefined"||isNaN(n)||n==="")n=0;vals[field.valKey]+=n}});return vals}function getTextCalcFieldId(field,vals){if(typeof vals[field.valKey]!== "undefined"&&vals[field.valKey]!=="")return vals;vals[field.valKey]="";var calcField=getCalcField(field);if(calcField===false)return vals;var count=0;var sep="";calcField.each(function(){var thisVal=getOptionValue(field.thisField,this);thisVal=thisVal.trim();sep=getCalcSep(field,count);if(thisVal!==""){vals[field.valKey]+=sep+thisVal;count++}});return vals}function getCalcSep(field,count){var sep="";if(count>0){if(field.thisField.type==="time")if(count==1)sep=":";else{if(count==2)sep=" "}else sep= ", ";var customSep=jQuery(document).triggerHandler("frmCalSeparation",[field.thisField,count]);if(typeof customSep!=="undefined")sep=customSep}return sep}function getCalcField(field){var calcField;if(field.inSection===false)calcField=jQuery(field.thisFieldCall);else calcField=getSiblingField(field);if(calcField===null||typeof calcField==="undefined"||calcField.length<1)calcField=false;return calcField}function getDateFieldValue(dateFormat,thisVal){var d=0;if(!thisVal);else if(typeof jQuery.datepicker=== "undefined"){var splitAt="-";if(dateFormat.indexOf("/")>-1)splitAt="/";var year="",month="",day="",formatPieces=dateFormat.split(splitAt),datePieces=thisVal.split(splitAt);for(var i=0;icurrentYearPlusFifteen)year="19"+datePieces[i];else year="20"+datePieces[i]}else if(formatPieces[i]==="yy")year=datePieces[i];else if(formatPieces[i]=== "m"||formatPieces[i]==="mm"){month=datePieces[i];if(month.length<2)month="0"+month}else if(formatPieces[i]==="d"||formatPieces[i]==="dd"){day=datePieces[i];if(day.length<2)day="0"+day}d=Date.parse(year+"-"+month+"-"+day)}else d=jQuery.datepicker.parseDate(dateFormat,thisVal);return d}function getSiblingField(field){if(typeof field.triggerField==="undefined")return null;var fields=null,container=field.triggerField.closest(".frm_repeat_sec, .frm_repeat_inline, .frm_repeat_grid"),repeatArgs=getRepeatArgsFromFieldName(field.triggerField.attr("name")), siblingFieldCall=field.thisFieldCall.replace("[id=","[id^=").replace(/-"]/g,"-"+repeatArgs.repeatRow+'"]');if(container.length||repeatArgs.repeatRow!==""){if(container.length)fields=container.find(siblingFieldCall);else fields=jQuery(siblingFieldCall);if(fields===null||typeof fields==="undefined"||fields.length<1)fields=uncheckedSiblingOrOutsideSection(field,container,siblingFieldCall)}else fields=getNonSiblingField(field);return fields}function uncheckedSiblingOrOutsideSection(field,container,siblingFieldCall){var fields= null;if(siblingFieldCall.indexOf(":checked")){var inSection=container.find(siblingFieldCall.replace(":checked",""));if(inSection.length<1)fields=getNonSiblingField(field)}else fields=getNonSiblingField(field);return fields}function getNonSiblingField(field){return jQuery(field.thisFieldCall)}function getOptionValue(thisField,currentOpt){var thisVal;if(isOtherOption(thisField,currentOpt))thisVal=getOtherValueAnyField(thisField,currentOpt);else if(currentOpt.type==="checkbox"||currentOpt.type==="radio")if(currentOpt.checked)thisVal= currentOpt.hasAttribute("data-frmprice")?currentOpt.dataset.frmprice:currentOpt.value;else thisVal=currentOpt.dataset.off;else thisVal=currentOpt.hasAttribute("data-frmprice")?currentOpt.dataset.frmprice:jQuery(currentOpt).val();if(typeof thisVal==="undefined")thisVal="";return thisVal}function isOtherOption(thisField,currentOpt){var isOtherOpt=false;if(currentOpt.type==="hidden"){if(getOtherValueLimited(currentOpt)!=="")isOtherOpt=true}else if(thisField.type==="select"){var optClass=currentOpt.className; if(optClass&&optClass.indexOf("frm_other_trigger")>-1)isOtherOpt=true}else if(thisField.type==="checkbox"||thisField.type==="radio")if(currentOpt.id.indexOf("-other_")>-1&¤tOpt.id.indexOf("-otext")<0)isOtherOpt=true;return isOtherOpt}function getOtherValueLimited(currentOpt){var otherVal="",otherText=document.getElementById(currentOpt.id+"-otext");if(otherText!==null&&otherText.value!=="")otherVal=otherText.value;return otherVal}function getOtherValueAnyField(thisField,currentOpt){var otherVal= 0;if(thisField.type==="select")if(currentOpt.type==="hidden")if(isCurrentOptRepeating(currentOpt));else otherVal=getOtherValueLimited(currentOpt);else otherVal=getOtherSelectValue(currentOpt);else if(thisField.type==="checkbox"||thisField.type==="radio")if(currentOpt.type==="hidden");else otherVal=getOtherValueLimited(currentOpt);return otherVal}function isCurrentOptRepeating(currentOpt){var isRepeating=false,parts=currentOpt.name.split("[");if(parts.length>2)isRepeating=true;return isRepeating}function getOtherSelectValue(currentOpt){var fields= getOtherSelects(currentOpt);return fields.val()}function setOtherSelectValue(thisField,value){var i,fields=getOtherSelects(thisField);if(fields.length<1)return;fields.val(value);for(i=0;i0)for(i=0;i'+opts.options.edit_link+"");else data.setCell(row,col,"");col++}if(showDelete)if(typeof entry.deleteLink!=="undefined")data.setCell(row,col,''+opts.options.delete_link+"");else data.setCell(row,col,"");row++}}else{data.addRows(1);col=0;for(i=0,l=colCount;i0)data.setCell(0,col,"");else data.setCell(0,col,opts.options.no_entries);col++}}var chart=new google.visualization.Table(document.getElementById("frm_google_table_"+opts.options.form_id));chart.draw(data,opts.graphOpts)}function generateGoogleGraphs(graphs){for(var i=0,l=graphs.length;i0){var lastRowIndex=jQuery(".frm_repeat_"+id+":last").attr("id").replace("frm_section_"+id+"-","");if(lastRowIndex.indexOf("i")>-1)i=1;else i=1+parseInt(lastRowIndex)}jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"json",data:{action:"frm_add_form_row",field_id:id,i:i,numberOfSections:numberOfSections, nonce:frm_js.nonce},success:function(r){if(r.html){var html=r.html;var item=jQuery(html).addClass("frm-fade-in");thisBtn.parents(".frm_section_heading").append(item);if(r.is_repeat_limit_reached)hideAddButton(id);var checked=["other"];var fieldID,fieldObject;var reset="reset";var repeatArgs={repeatingSection:id.toString(),repeatRow:i.toString()};jQuery(html).find("input, select, textarea").each(function(){if(this.name==="")return true;if(this.type=="file")fieldID=this.name.replace("file","").split("-")[0]; else fieldID=this.name.replace("item_meta[","").split("]")[2].replace("[","");if(jQuery.inArray(fieldID,checked)==-1){if(this.id===false||this.id==="")return;fieldObject=jQuery("#"+this.id);checked.push(fieldID);hideOrShowFieldById(fieldID,repeatArgs);updateWatchingFieldById(fieldID,repeatArgs,"value changed");checkFieldsWithConditionalLogicDependentOnThis(fieldID,fieldObject);checkFieldsWatchingLookup(fieldID,fieldObject,"value changed");doCalculation(fieldID,fieldObject);reset="persist"}});jQuery(html).find(".frm_html_container").each(function(){var fieldID= this.id.replace("frm_field_","").split("-")[0];checked.push(fieldID);hideOrShowFieldById(fieldID,repeatArgs)});loadDropzones(repeatArgs.repeatRow);loadSliders();loadChosen()}if(typeof frmThemeOverride_frmAddRow=="function")frmThemeOverride_frmAddRow(id,r);jQuery(document).trigger("frmAfterAddRow");jQuery(".frm_repeat_"+id).each(function(i){this.style.zIndex=999-i});currentlyAddingRow=false},error:function(){currentlyAddingRow=false}});return false}function editEntry(){var $edit=jQuery(this),entryId= $edit.data("entryid"),prefix=$edit.data("prefix"),postId=$edit.data("pageid"),formId=$edit.data("formid"),cancel=$edit.data("cancel"),fields=$edit.data("fields"),excludeFields=$edit.data("excludefields"),$cont=jQuery(document.getElementById(prefix+entryId)),orig=$cont.html();$cont.html('");jQuery.ajax({type:"POST",url:frm_js.ajax_url,dataType:"html",data:{action:"frm_entries_edit_entry_ajax", post_id:postId,entry_id:entryId,id:formId,nonce:frm_js.nonce,fields:fields,exclude_fields:excludeFields},success:function(html){$cont.children(".frm-loading-img").replaceWith(html);$edit.removeClass("frm_inplace_edit").addClass("frm_cancel_edit");$edit.html(cancel);checkConditionalLogic("editInPlace");if(typeof frmFrontForm.fieldValueChanged==="function")jQuery(document).on("change",'.frm-show-form input[name^="item_meta"], .frm-show-form select[name^="item_meta"], .frm-show-form textarea[name^="item_meta"]', frmFrontForm.fieldValueChanged);checkFieldsOnPage(prefix+entryId)}});return false}function cancelEdit(){var $cancelLink=jQuery(this),prefix=$cancelLink.data("prefix"),entryId=$cancelLink.data("entryid"),$cont=jQuery(document.getElementById(prefix+entryId));$cont.children(".frm_forms").replaceWith("");$cont.children(".frm_orig_content").fadeIn("slow").removeClass("frm_orig_content");switchCancelToEdit($cancelLink)}function switchCancelToEdit($link){var label=$link.data("edit");$link.removeClass("frm_cancel_edit").addClass("frm_inplace_edit"); $link.html(label)}function deleteEntry(){var $link=jQuery(this),confirmText=$link.data("deleteconfirm");if(confirm(confirmText)){var entryId=$link.data("entryid"),prefix=$link.data("prefix");$link.replaceWith('');jQuery.ajax({type:"POST",url:frm_js.ajax_url,data:{action:"frm_entries_destroy",entry:entryId,nonce:frm_js.nonce},success:function(html){if(html.replace(/^\s+|\s+$/g,"")==="success"){var container=jQuery(document.getElementById(prefix+ entryId));container.fadeOut("slow",function(){container.remove()});jQuery(document.getElementById("frm_delete_"+entryId)).fadeOut("slow");jQuery(document).trigger("frmEntryDeleted",[entryId])}else jQuery(document.getElementById("frm_delete_"+entryId)).replaceWith(html)}})}return false}function doEditInPlaceCleanUp(form){var entryIdField=jQuery(form).find('input[name="id"]');if(entryIdField.length){var link=document.getElementById("frm_edit_"+entryIdField.val());if(isCancelLink(link))switchCancelToEdit(jQuery(link))}} function isCancelLink(link){return link!==null&&link.className.indexOf("frm_cancel_edit")>-1}function loadUniqueTimeFields(){if(typeof __frmUniqueTimes==="undefined")return;var timeFields=__frmUniqueTimes;for(var i=0;i-1)if(selectLabel)stars[i].className+=" star-rating-hover";else stars[i].classList.remove("star-rating-hover", "star-rating-on");else selectLabel=parseInt(stars[i].value)<=current}function unhoverStars(){var input=this.previousSibling,starGroup=input.parentElement;starGroup.classList.remove("frm-star-hovered");var stars=starGroup.childNodes;var selected=jQuery(starGroup).find("input:checked").attr("id");var isSelected="";for(var i=stars.length-1;i>0;i--)if(typeof stars[i].className!=="undefined"&&stars[i].className.indexOf("star-rating")>-1){stars[i].classList.remove("star-rating-hover");if(isSelected===""&& typeof selected!=="undefined"&&stars[i].getAttribute("for")==selected)isSelected=" star-rating-on";if(isSelected!=="")stars[i].className+=isSelected}}function loadSliders(){jQuery(document).on("input change","input[data-frmrange]",function(){var i,c=this.parentNode.children;for(i=0;i1)input=input.eq(0);input.trigger({type:"change",selfTriggered:true,frmTriggered:fieldKey})}function loadCustomInputMasks(){if(typeof __frmMasks==="undefined")return;var maskFields=__frmMasks;for(var i=0;i=0}function checkPasswordField(){if(this.className.indexOf("frm_strength_meter")>-1){var fieldId= this.name.replace(/\D/g,""),checks=passwordChecks();for(var check in checks){var span=document.getElementById("frm-pass-"+check+"-"+fieldId);addOrRemoveVerifyPass(checks[check],this.value,span)}}}function passwordChecks(){return{"eight-char":/^.{8,}$/,number:/\d/,uppercase:/[A-Z]/,lowercase:/[a-z]/,"special-char":/(?=.*[^a-zA-Z0-9])/}}function addOrRemoveVerifyPass(regEx,password,span){if(span!==null){var remove=regEx.test(password);if(remove)maybeRemovePassReq(span);else maybeRemovePassVerified(span)}} function maybeRemovePassReq(span){if(span.classList.contains("frm-pass-req")){span.classList.remove("frm-pass-req");span.classList.add("frm-pass-verified")}}function maybeRemovePassVerified(span){if(span.classList.contains("frm-pass-verified")){span.classList.remove("frm-pass-verified");span.classList.add("frm-pass-req")}}function checkCheckboxSelectionLimit(){var limit=parseInt(this.getAttribute("data-frmlimit")),checked=this.checked;if(!limit)return;var allBoxes=jQuery(this).parents(".frm_opt_container").find('input[type="checkbox"]'); if(limit>=allBoxes.length)return;var checkedBoxes=allBoxes.filter(function(){return this.checked});if(checked){if(checkedBoxes.length>=limit)allBoxes.filter(function(){return!this.checked}).attr("disabled","disabled")}else allBoxes.removeAttr("disabled")}function addTopAddRowBtnForRepeater(){jQuery('.frm_section_heading:has(div[class*="frm_repeat_"])').each(function(){var firstRepeatedSection=jQuery(this).find('div[class*="frm_repeat_"]:first');firstRepeatedSection.before(firstRepeatedSection.find(".frm_add_form_row").clone().addClass("frm_hidden"))})} function maybeDisableCheckboxesWithLimit(){jQuery('input[type="checkbox"][data-frmlimit]:not(:checked)').each(function(){var limit=parseInt(this.getAttribute("data-frmlimit"));if(!limit)return;var allBoxes=jQuery(this).parents(".frm_opt_container").find('input[type="checkbox"]');if(limit>=allBoxes.length)return;var checkedBoxes=allBoxes.filter(function(){return this.checked});if(limit>checkedBoxes.length)return;this.setAttribute("disabled","disabled")})}function checkQuantityFieldMinMax(input){var val= parseFloat(input.value?input.value.trim():0),max=input.hasAttribute("max")?parseFloat(input.getAttribute("max")):0,min=input.hasAttribute("min")?parseFloat(input.getAttribute("min")):0;if(isNaN(val))return 0;max=isNaN(max)?0:max;min=isNaN(min)?0:min<0?0:min;if(valmax){input.value=max;return max}return val}function setHiddenProduct(input){input.setAttribute("data-frmhidden","1");triggerChange(jQuery(input))}function setHiddenProductContainer(container){if(container.innerHTML.indexOf("data-frmprice")!== -1)jQuery(container).find("input[data-frmprice], select:has([data-frmprice])").attr("data-frmhidden","1")}function setShownProduct(input){var wasHidden=input.getAttribute("data-frmhidden");if(wasHidden!==null){input.removeAttribute("data-frmhidden");triggerChange(jQuery(input))}}function calcProductsTotal(e){var formTotals=[],totalFields,leftSymbol,rightSymbol;if(typeof __FRMCURR==="undefined")return;if(undefined!==e&&"undefined"!==typeof e.target&&("keyup"===e.type||"change"===e.type)){var el=e.target; if(el.hasAttribute("data-frmprice")&&el instanceof HTMLInputElement&&"text"===el.type)el.setAttribute("data-frmprice",el.value.trim())}totalFields=jQuery("[data-frmtotal]");if(!totalFields.length)return;totalFields.each(function(){var currency,formId,formatted,total=0,totalField=jQuery(this),$form=totalField.closest("form"),isRepeatingTotal=isRepeatingFieldByName(this.name);if(!$form.length)return;formId=$form.find('input[name="form_id"]').val();currency=getCurrency(formId);if(typeof formTotals[formId]!== "undefined"&&!isRepeatingTotal)total=formTotals[formId];else{$form.find("input[data-frmprice],select:has([data-frmprice])").each(function(){var quantity,$this,price=0,isUserDef=false,isSingle=false;if(isRepeatingTotal&&!isRepeatingWithTotal(this,totalField[0]))return;if(this.hasAttribute("data-frmhigherpg")||isProductFieldHidden(this))return;if(this.tagName==="SELECT"){if(this.selectedIndex!==-1)price=this.options[this.selectedIndex].getAttribute("data-frmprice")}else{isUserDef="text"===this.type; isSingle="hidden"===this.type;$this=jQuery(this);if(!isUserDef&&!isSingle&&!$this.is(":checked"))return;price=this.getAttribute("data-frmprice")}if(!price)price=0;else{price=preparePrice(price,currency);quantity=getQuantity(isUserDef,this);price=parseFloat(quantity)*parseFloat(price)}total+=price});if(!isRepeatingTotal)formTotals[formId]=total}total=isNaN(total)?0:total;currency.decimal_separator=currency.decimal_separator.trim();if(!currency.decimal_separator.length)currency.decimal_separator="."; total=currency.decimals>0?Math.round10(total,currency.decimals):Math.ceil(total);total=maybeAddTrailingZeroToPrice(total,currency);totalField.val(total);triggerChange(totalField);total=formatCurrency(total,currency);formatted=totalField.prev(".frm_total_formatted");if(formatted.length<1)formatted=totalField.closest(".frm_form_field").find(".frm_total_formatted");if(formatted.length)formatted.html(total)})}function formatCurrency(total,currency){var leftSymbol,rightSymbol;total=maybeAddTrailingZeroToPrice(total, currency);total=addThousands(total,currency);leftSymbol=currency.symbol_left+currency.symbol_padding;rightSymbol=currency.symbol_padding+currency.symbol_right;return leftSymbol+total+rightSymbol}function isProductFieldHidden(input){return input.getAttribute("data-frmhidden")!==null}function isRepeatingWithTotal(input,total){var regex=/item_meta\[.+?\]\[.+?\]/;return isRepeatingFieldByName(input.name)&&total.name.match(regex)[0]===input.name.match(regex)[0]}function getCurrency(formId){if(typeof __FRMCURR!== "undefined"&&typeof __FRMCURR[formId]!=="undefined")return __FRMCURR[formId]}function getQuantity(isUserDef,field){var quantity,quantityFields,isRepeating,fieldID,$this=jQuery(field);fieldID=frmFrontForm.getFieldId(field,false);if(!fieldID)return 0;isRepeating=isRepeatingFieldByName(field.name);if(isRepeating){var match=field.name.match(/item_meta\[.+?\]\[.+?\]/);if(null===match)return 0;$this.nameMatch=match[0]}quantity=getQuantityField($this,fieldID,isRepeating);if(quantity)quantity=checkQuantityFieldMinMax(quantity); else{quantityFields=getQuantityFields($this,isRepeating);if(1===quantityFields.length&&""===quantityFields[0].getAttribute("data-frmproduct").trim())quantity=checkQuantityFieldMinMax(quantityFields[0]);else quantity=1}if(0===quantity&&isUserDef)quantity=1;return quantity}function getQuantityField(elementObj,fieldID,isRepeating){var quantity,quantityFields=elementObj.closest("form").find("[data-frmproduct]");fieldID=fieldID.toString();quantityFields.each(function(){var ids;if(isRepeating&&-1===this.name.indexOf(elementObj.nameMatch))return true; ids=JSON.parse(this.getAttribute("data-frmproduct").trim());if(""===ids)return true;ids="string"===typeof ids?[ids.toString()]:ids;if(ids.indexOf(fieldID)>-1){quantity=this;return false}});return quantity}function getQuantityFields(elementObj,isRepeating){var quantityFields;if(isRepeating)quantityFields=elementObj.closest("form").find('[name^="'+elementObj.nameMatch+'"]'+"[data-frmproduct]");else quantityFields=elementObj.closest("form").find('[data-frmproduct]:not([id*="-"])');return quantityFields} function preparePrice(price,currency){var matches;if(!price)return 0;price=price+"";matches=price.match(/[0-9,.]*\.?,?[0-9]+/g);if(null===matches)return 0;price=matches.length?matches[matches.length-1]:0;if(price){price=maybeUseDecimal(price,currency);price=price.replace(currency.thousand_separator,"").replace(currency.decimal_separator,".")}return price}function maybeUseDecimal(amount,currency){var used_for_decimal,amount_parts;if(currency.thousand_separator=="."){amount_parts=amount.split("."); used_for_decimal=2==amount_parts.length&&2==amount_parts[1].length;if(used_for_decimal)amount=amount.replace(".",currency.decimal_separator)}return amount}function maybeAddTrailingZeroToPrice(price,currency){if("number"!==typeof price)return price;price+="";var pos=price.indexOf(".");if(pos===-1)price=price+".00";else if(price.substring(pos+1).length<2)price+="0";return price.replace(".",currency.decimal_separator)}function addThousands(total,currency){if(currency.thousand_separator)total=total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, currency.thousand_separator);return total}return{init:function(){jQuery(document).on("frmFormComplete",afterFormSubmitted);jQuery(document).on("frmPageChanged",afterPageChanged);jQuery(document).on("frmAfterAddRow frmAfterRemoveRow",calcProductsTotal);jQuery(document).on("click",".frm_trigger",toggleSection);var $blankField=jQuery(".frm_blank_field");if($blankField.length)$blankField.closest(".frm_toggle_container").prev(".frm_trigger").click();jQuery(document).on("click",".frm_remove_link",removeFile); jQuery(document).on("focusin","input[data-frmmask]",function(){jQuery(this).mask(jQuery(this).data("frmmask").toString(),{autoclear:false})});jQuery(document).on("frmFieldChanged",maybeCheckDependent);jQuery(document).on("keyup","input.frm_strength_meter",checkPasswordField);jQuery(document).on("mouseenter click",".frm-star-group input",loadStars);jQuery(document).on("mouseenter",".frm-star-group .star-rating:not(.star-rating-readonly)",hoverStars);jQuery(document).on("mouseleave",".frm-star-group .star-rating:not(.star-rating-readonly)", unhoverStars);jQuery(document).on("click",'.frm-show-form input[type="submit"], .frm-show-form input[name="frm_prev_page"], .frm_page_back, .frm_page_skip, .frm-show-form .frm_save_draft, .frm_prev_page, .frm_button_submit',setNextPage);jQuery(document).on("change",'.frm_other_container input[type="checkbox"], .frm_other_container input[type="radio"], .frm_other_container select',showOtherText);jQuery(document).on("click",".frm_remove_form_row",removeRow);jQuery(document).on("click",".frm_add_form_row", addRow);jQuery(".frm_edit_link_container").on("click","a.frm_inplace_edit",editEntry);jQuery(".frm_edit_link_container").on("click","a.frm_cancel_edit",cancelEdit);jQuery(document).on("click",".frm_ajax_delete",deleteEntry);jQuery(".frm_month_heading, .frm_year_heading").click(function(){var content=jQuery(this).children(".ui-icon-triangle-1-e, .ui-icon-triangle-1-s");if(content.hasClass("ui-icon-triangle-1-e")){content.addClass("ui-icon-triangle-1-s").removeClass("ui-icon-triangle-1-e");jQuery(this).next(".frm_toggle_container").fadeIn("slow")}else{content.addClass("ui-icon-triangle-1-e").removeClass("ui-icon-triangle-1-s"); jQuery(this).next(".frm_toggle_container").hide()}});addTopAddRowBtnForRepeater();jQuery(document).on("click",'input[type="checkbox"][data-frmlimit]',checkCheckboxSelectionLimit);jQuery(document).on("change",'[type="checkbox"][data-frmprice],[type="radio"][data-frmprice],[type="hidden"][data-frmprice],select:has([data-frmprice])',calcProductsTotal);jQuery(document).on("keyup change",'[data-frmproduct],[type="text"][data-frmprice]',calcProductsTotal);maybeDisableCheckboxesWithLimit();setInlineFormWidth(); checkConditionalLogic("pageLoad");checkFieldsOnPage();calcProductsTotal()},savingDraft:function(object){return savingDraftEntry(object)},goingToPreviousPage:function(object){return goingToPrevPage(object)},hideOrShowFields:function(ids,event){if("pageLoad"===event)clearHideFields();var len=ids.length,repeatArgs={repeatingSection:"",repeatRow:""};for(var i=0,l=len;i-1){hidePreviouslyHiddenSubmitButton(hiddenFields[i]);continue}}if(container!==null){container.style.display="none";setHiddenProductContainer(container)}}},submitAllowed:function(object){var formElementId=object.getAttribute("id");if(!isSubmitButtonOnPage(formElementId+ " .frm_final_submit")||goingToPrevPage(object)||savingDraftEntry(object))return true;var formKey=getFormKeyFromFormElementID(formElementId);return!isOnPageSubmitButtonHidden(formKey)},checkDependentDynamicFields:function(ids){var len=ids.length,repeatArgs={repeatingSection:"",repeatRow:""};for(var i=0,l=len;i0)for(var i=0,l=opts.length;i