function remove_whitespace(node) { var ttt; for (ttt = 0; ttt < node.childNodes.length; ttt++) { if (node.childNodes[ttt] && node.childNodes[ttt].nodeType == '3' && !/\S/.test(node.childNodes[ttt].nodeValue)) { node.removeChild(node.childNodes[ttt]); ttt--; } else { if (node.childNodes[ttt].childNodes.length) { remove_whitespace(node.childNodes[ttt]); } } } return; } function fm_row_handle(section) { var fm_section = jQuery(section); fm_section.find('.wdform_row_handle').remove(); var row_handle = jQuery('
").attr("class", "fm_mail_input").prependTo("#" + parent_id);
jQuery("").attr("class", "mail_name").text(value).appendTo(mail_div);
jQuery("").attr("class", "dashicons dashicons-trash").attr("onclick", "fm_delete_mail(this, '" + value + "')").attr("title", "Delete Email").appendTo(mail_div);
jQuery("#" + value_id).val("");
jQuery("#" + toAdd_id).val(jQuery("#" + toAdd_id).val() + value + ",");
}
}
function fm_delete_mail(img, value) {
jQuery(img).parent().remove();
jQuery("#mail").val(jQuery("#mail").val().replace(value + ',', ''));
}
function form_maker_options_tabs(id) {
jQuery("#fieldset_id").val(id);
jQuery(".fm_fieldset_active").removeClass("fm_fieldset_active").addClass("fm_fieldset_deactive");
jQuery("#" + id + "_fieldset").removeClass("fm_fieldset_deactive").addClass("fm_fieldset_active");
jQuery(".fm_fieldset_tab").removeClass("active");
jQuery("#" + id).addClass("active");
return false;
}
function set_type(type) {
switch(type) {
case 'post':
document.getElementById('post').removeAttribute('style');
document.getElementById('page').setAttribute('style','display:none');
document.getElementById('custom_text').setAttribute('style','display:none');
document.getElementById('url').setAttribute('style','display:none');
break;
case 'page':
document.getElementById('page').removeAttribute('style');
document.getElementById('post').setAttribute('style','display:none');
document.getElementById('custom_text').setAttribute('style','display:none');
document.getElementById('url').setAttribute('style','display:none');
break;
case 'custom_text':
document.getElementById('page').setAttribute('style','display:none');
document.getElementById('post').setAttribute('style','display:none');
document.getElementById('custom_text').removeAttribute('style');
document.getElementById('url').setAttribute('style','display:none');
break;
case 'url':
document.getElementById('page').setAttribute('style','display:none');
document.getElementById('post').setAttribute('style','display:none');
document.getElementById('custom_text').setAttribute('style','display:none');
document.getElementById('url').removeAttribute('style');
break;
case 'none':
document.getElementById('page').setAttribute('style','display:none');
document.getElementById('post').setAttribute('style','display:none');
document.getElementById('custom_text').setAttribute('style','display:none');
document.getElementById('url').setAttribute('style','display:none');
break;
}
}
function check_isnum(e) {
var chCode1 = e.which || e.keyCode;
if ( chCode1 > 31
&& (chCode1 < 48 || chCode1 > 57)
&& (chCode1 != 46)
&& (chCode1 != 45)
&& (chCode1 < 35 || chCode1 > 40) ) {
return false;
}
return true;
}
// Check Email.
function fm_check_email(id) {
if (document.getElementById(id) && jQuery('#' + id).val() != '') {
var email_array = jQuery('#' + id).val().split(',');
var re = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,61}$/;
for (var email_id = 0; email_id < email_array.length; email_id++) {
var email = email_array[email_id].replace(/^\s+|\s+$/g, '');
if ( email && ! re.test( email ) && email.indexOf('{') === -1 ) {
alert('This is not a valid email address.');
/* Do only if there is active class */
if( jQuery('#submenu li a').hasClass('active') ) {
var activeTabId = jQuery("#submenu .active").attr("id");
var error_cont_id = jQuery('#' + id).closest(".fm_fieldset_deactive").attr("id");
if(typeof error_cont_id != 'undefined') {
var error_tab_id = error_cont_id.split("_fieldset");
tab_id = error_tab_id[0];
/* If current active and error active tabs are the same */
if ( activeTabId != tab_id ) {
var activeContentId = activeTabId +"_fieldset";
jQuery("#"+activeContentId).removeClass("fm_fieldset_active");
jQuery("#"+activeContentId).removeClass("fm_fieldset_deactive");
jQuery("#" + error_cont_id).addClass("fm_fieldset_active");
jQuery("#submenu .active").removeClass('active');
jQuery("#" + tab_id).addClass("active");
}
}
} else {
var error_cont_id = jQuery('#' + id).closest(".fm_fieldset_deactive").attr("id");
if(typeof error_cont_id != 'undefined') {
var tab_id = error_cont_id.split("_fieldset");
tab_id = tab_id[0];
jQuery("#" + error_cont_id).removeClass("fm_fieldset_deactive");
jQuery("#" + error_cont_id).addClass("fm_fieldset_active");
jQuery("#" + tab_id).addClass("active");
}
}
jQuery('#' + id).css('border', '1px solid #FF0000');
jQuery('#' + id).focus();
jQuery('html, body').animate({
scrollTop:jQuery('#' + id).offset().top - 200
}, 500);
return true;
}
}
jQuery('#' + id).css('border', '1px solid #ddd');
}
return false;
}
function wdhide(id) {
document.getElementById(id).style.display = "none";
}
function wdshow(id) {
document.getElementById(id).style.display = "block";
}
function delete_field_condition(id) {
var cond_id = id.split("_");
document.getElementById("condition"+cond_id[0]).removeChild(document.getElementById("condition_div"+id));
}
function change_choices(value, ids, types, params) {
value = value.split("_");
global_index = value[0];
id = value[1];
index = value[2];
ids_array = ids.split("@@**@@");
types_array = types.split("@@**@@");
params_array = params.split("@@**@@");
switch(types_array[id]) {
case "type_text":
case "type_password":
case "type_textarea":
case "type_name":
case "type_submitter_mail":
case "type_number":
case "type_phone":
case "type_paypal_price":
case "type_paypal_price_new":
case "type_spinner":
case "type_date_new":
case "type_phone_new":
if(types_array[id]=="type_number" || types_array[id]=="type_phone")
var keypress_function = "return check_isnum_space(event)";
else
if(types_array[id]=="type_paypal_price" || types_array[id]=="type_paypal_price_new")
var keypress_function = "return check_isnum_point(event)";
else
var keypress_function = "";
if(document.getElementById("field_value"+global_index+"_"+index).tagName=="SELECT") {
document.getElementById("condition_div"+global_index+"_"+index).removeChild(document.getElementById("field_value"+global_index+"_"+index));
var label_input = document.createElement('input');
label_input.setAttribute("id", "field_value"+global_index+'_'+index);
label_input.setAttribute("type", "text");
label_input.setAttribute("value", "");
label_input.setAttribute("class", "fm_condition_field_input_value");
label_input.setAttribute("onKeyPress", keypress_function);
document.getElementById("condition_div"+global_index+"_"+index).insertBefore(label_input,document.getElementById("delete_condition"+global_index+"_"+index));
document.getElementById("condition_div"+global_index+"_"+index).insertBefore(document.createTextNode(' '),document.getElementById("delete_condition"+global_index+"_"+index));
}
else {
document.getElementById("field_value"+global_index+'_'+index).value="";
document.getElementById("field_value"+global_index+'_'+index).setAttribute("onKeyPress", keypress_function);
}
break;
case "type_own_select":
case "type_radio":
case "type_checkbox":
if(types_array[id]=="type_own_select")
w_size = params_array[id].split('*:*w_size*:*');
else
w_size = params_array[id].split('*:*w_flow*:*');
w_choices = w_size[1].split('*:*w_choices*:*');
w_choices_array = w_choices[0].split('***');
if(w_size[1].indexOf('*:*w_value_disabled*:*') !== -1){
w_value_disabled = w_size[1].split('*:*w_value_disabled*:*');
w_choices_value = w_value_disabled[1].split('*:*w_choices_value*:*');
w_choices_value_array = w_choices_value[0].split('***');
}
else{
w_choices_value_array = w_choices_array;
}
var choise_select = document.createElement('select');
choise_select.setAttribute("id", "field_value"+global_index+'_'+index);
choise_select.setAttribute("class", "fm_condition_field_select_value");
if(types_array[id]== "type_checkbox") {
choise_select.setAttribute('multiple', 'multiple');
choise_select.setAttribute('class', 'multiple_select');
}
for(k=0; k