';
if(typeof $result.fields!=='undefined'){
$.each($result.fields, function(index, value){
$(value+'[name="'+index+'"]').parent().addClass('error');
});
}}else{
SUPER.after_email_send_hook($form);
if(($form.children('form').attr('method')=='post')&&($form.children('form').attr('action')!=='')){
$form.children('form').submit();
return false;
}
$html='
';
}
$html +='>';
}
if($result.redirect){
window.location.href=$result.redirect;
}else{
if($result.msg!==''){
$html +=$result.msg;
$html +='';
$html +='
';
$($html).prependTo($form);
}
if($result.loading!==true){
var $proceed=SUPER.before_scrolling_to_message_hook($form, $form.offset().top - 30);
if($proceed===true){
$('html, body').animate({
scrollTop: $form.offset().top-200
}, 1000);
}
$form.find('.super-form-button.super-loading .super-button-name').html($old_html);
$form.find('.super-form-button.super-loading').removeClass('super-loading');
if($result.error===false){
if($form.data('hide')===true){
$form.find('.super-field, .super-multipart-progress, .super-field, .super-multipart-steps').fadeOut($duration);
setTimeout(function (){
$form.find('.super-field, .super-shortcode').remove();
}, $duration);
}else{
if($form.data('clear')===true){
SUPER.init_clear_form($form);
}}
}}
}},
error: function (xhr, ajaxOptions, thrownError){
console.log(xhr, ajaxOptions, thrownError);
alert('Failed to process data, please try again');
}});
});
};
SUPER.upload_files=function(e, $form, $data, $duration, $old_html, $status, $status_update){
$form.find('.super-fileupload-files').each(function(){
var $minfiles=$(this).parent().find('.super-active-files').data('minfiles');
if(typeof $minfiles==='undefined'){
$minfiles=0;
}
if(( $minfiles===0)&&($(this).parent().find('.super-fileupload-files').children('div').length===0)){
$(this).parent().find('.super-fileupload').addClass('finished');
}});
$form.find('.super-fileupload-files > div:not(.super-uploaded)').each(function(){
var data=$(this).data();
data.submit();
});
$form.find('.super-fileupload').on('fileuploaddone', function (e, data){
var $value,
$field=$(this).parents('.super-field-wrapper:eq(0)').children('input[type="hidden"]');
$.each(data.result.files, function (index, file){
if(!file.error){
if($field.val()===''){
$field.val(file.name);
}else{
$field.val($field.val()+','+file.name);
}}
});
$value=$field.val();
$value=$value.split(',');
$data[$field.attr('name')]=$field.val();
if($(this).parents('.super-field-wrapper:eq(0)').find('.super-fileupload-files > div.error').length){
$form.find('.super-form-button.super-loading .super-button-name').html($old_html);
$form.find('.super-form-button.super-loading').removeClass('super-loading');
clearInterval($interval);
}else{
if($(this).parents('.super-field-wrapper:eq(0)').find('.super-fileupload-files > div:not(.error)').length==$value.length){
$(this).addClass('finished');
}}
});
var $interval=setInterval(function(){
var $total_file_uploads=0;
$form.find('.super-fileupload').each(function(){
var $shortcode_field=$(this);
var $skip=false;
$shortcode_field.parents('.super-shortcode.super-column').each(function(){
if($(this).css('display')=='none'){
$skip=true;
}});
var $parent=$shortcode_field.parents('.super-shortcode:eq(0)');
if(( $parent.css('display')=='none')&&(!$parent.hasClass('super-hidden'))){
$skip=true;
}
if($skip!==true){
$total_file_uploads++;
}else{
$shortcode_field.removeClass('finished');
}});
if($form.find('.super-fileupload.finished').length==$total_file_uploads){
clearInterval($interval);
SUPER.init_fileupload_fields();
$form.find('.super-fileupload').removeClass('super-rendered').fileupload('destroy');
setTimeout(function(){
SUPER.complete_submit(e, $form, $duration, $old_html, $status, $status_update);
}, 1000);
}}, 1000);
};
SUPER.trim=function($this){
if(typeof $this==='string'){
return $this.replace(/^\s+|\s+$|\s+(?=\s)/g, "");
}};
SUPER.handle_validations=function($this, $validation, $conditional_validation, $duration){
var $regex,
$value,
$numbers,
$pattern,
$attr,
$text_field,
$total,
$parent,
$currency,
$format,
$decimals,
$thousand_separator,
$decimal_seperator,
$logic,
$field_value,
$value2,
$string_value,
$string_field_value,
$bracket,
$form,
$regular_expression,
$name,
$element,
$sum,
$selected,
$counter,
$file_error,
$index,
$checked,
$urlRegex=/^(http(s)?:\/\/)?(www\.)?[a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,5}(:[0-9]{1,5})?(\/.*)?$/;
var $error=false;
var $custom_regex=$this.parent().find('.super-custom-regex').val();
var $may_be_empty=$this.data('may-be-empty');
if(($may_be_empty===true)&&($this.val().length===0)){
return false;
}
$('.super-field.conditional[data-conditionalfield="'+$this.attr('name')+'"]').each(function(){
if($(this).data('conditionalvalue')==$this.val()){
$(this).addClass('active');
$(this).find('select').data('excludeconditional','0');
}else{
$(this).removeClass('active');
$(this).find('select').data('excludeconditional','1');
}});
if($custom_regex!==''){
$regex=new RegExp($custom_regex);
$value=$this.val();
if($regex.test($value)){
}else{
$error=true;
}}
if($validation=='captcha'){
$error=true;
}
if($validation=='numeric'){
$regex=/^\d+$/;
$value=$this.val();
if(!$regex.test($value)){
$error=true;
}}
if($validation=='float'){
$regex=/^[+-]?\d+(\.\d+)?$/;
$value=$this.val();
if(!$regex.test($value)){
$error=true;
}}
if($validation=='empty'){
$parent=$this.parents('.super-field:eq(0)');
if($parent.hasClass('super-keyword-tags')){
$total=$parent.find('.super-autosuggest-tags > div > span').length;
if($total==0){
$error=true;
}}else{
if(SUPER.trim($this.val())===''){
$error=true;
}}
}
if($validation=='email'){
if(($this.val().length < 4)||(!/^([\w-\.+]+@([\w-]+\.)+[\w-]{2,63})?$/.test($this.val()))){
$error=true;
}}
if($validation=='phone'){
$regex=/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/;
$value=$this.val();
$numbers=$value.split("").length;
if(10 <=$numbers&&$numbers <=20&&$regex.test($value)){
}else{
$error=true;
}}
if($validation=='website'){
$value=$this.val();
$pattern=new RegExp($urlRegex);
if($pattern.test($value)){
}else{
$error=true;
}}
if($validation=='iban'){
$value=$this.val();
if((IBAN.isValid($value)===false)&&($value!=='')){
$error=true;
}}
$attr=$this.attr('data-minlength');
if(typeof $attr!=='undefined'&&$attr!==false){
$text_field=true;
$total=0;
$parent=$this.parents('.super-field:eq(0)');
if($parent.hasClass('super-checkbox')){
$text_field=false;
$checked=$parent.find('label.super-active');
if($checked.length < $attr){
$error=true;
}}
if(($parent.hasClass('super-dropdown'))||($parent.hasClass('super-countries'))){
$text_field=false;
$total=$parent.find('.super-dropdown-ui li.super-active:not(.super-placeholder)').length;
if($total < $attr){
$error=true;
}}
if($parent.hasClass('super-keyword-tags')){
$text_field=false;
$total=$parent.find('.super-shortcode-field > div > span').length;
if($total < $attr){
$error=true;
}}
if($text_field===true){
if(!$parent.hasClass('super-date')){
if($this.val().length < $attr){
$error=true;
}}
}}
$attr=$this.attr('data-maxlength');
if(typeof $attr!=='undefined'&&$attr!==false){
$text_field=true;
$total=0;
$parent=$this.parents('.super-field:eq(0)');
if($parent.hasClass('super-checkbox')){
$text_field=false;
$checked=$parent.find('label.super-active');
if($checked.length > $attr){
$error=true;
}}
if(($parent.hasClass('super-dropdown'))||($parent.hasClass('super-countries'))){
$text_field=false;
$total=$parent.find('.super-dropdown-ui li.super-active:not(.super-placeholder)').length;
if($total > $attr){
$error=true;
}}
if($parent.hasClass('super-keyword-tags')){
$text_field=false;
$total=$parent.find('.super-shortcode-field > div > span').length;
if($total > $attr){
$error=true;
}}
if($text_field===true){
if(!$parent.hasClass('super-date')){
if($this.val().length > $attr){
$error=true;
}}
}}
$attr=$this.attr('data-minnumber');
if(typeof $attr!=='undefined'&&$attr!==false){
$parent=$this.parents('.super-field:eq(0)');
if($parent.hasClass('super-currency')){
$value=$this.val();
$currency=$this.data('currency');
$format=$this.data('format');
$decimals=$this.data('decimals');
$thousand_separator=$this.data('thousand-separator');
$decimal_seperator=$this.data('decimal-separator');
$value=$value.replace($currency, '').replace($format, '');
$value=$value.split($thousand_separator).join('');
$value=$value.split($decimal_seperator).join('.');
$value=($value) ? parseFloat($value):0;
if($value < parseFloat($attr)){
$error=true;
}}else{
if(parseFloat($this.val()) < parseFloat($attr)){
$error=true;
}}
}
$attr=$this.attr('data-maxnumber');
if(typeof $attr!=='undefined'&&$attr!==false){
$parent=$this.parents('.super-field:eq(0)');
if($parent.hasClass('super-currency')){
$value=$this.val();
$currency=$this.data('currency');
$format=$this.data('format');
$decimals=$this.data('decimals');
$thousand_separator=$this.data('thousand-separator');
$decimal_seperator=$this.data('decimal-separator');
$value=$value.replace($currency, '').replace($format, '');
$value=$value.split($thousand_separator).join('');
$value=$value.split($decimal_seperator).join('.');
$value=($value) ? parseFloat($value):0;
if($value > parseFloat($attr)){
$error=true;
}}else{
if(parseFloat($this.val()) > parseFloat($attr)){
$error=true;
}}
}
$logic=$conditional_validation;
if(typeof $logic!=='undefined'&&$logic!='none'&&$logic!==''){
$field_value=$this.val();
$parent=$this.parents('.super-field:eq(0)');
if($parent.hasClass('super-currency')){
$value=$this.val();
$currency=$this.data('currency');
$format=$this.data('format');
$decimals=$this.data('decimals');
$thousand_separator=$this.data('thousand-separator');
$decimal_seperator=$this.data('decimal-separator');
$value=$value.replace($currency, '').replace($format, '');
$value=$value.split($thousand_separator).join('');
$value=$value.split($decimal_seperator).join('.');
$field_value=($value) ? parseFloat($value):0;
}
$value=$this.data('conditional-validation-value');
$value2=$this.data('conditional-validation-value2');
if(typeof $value!=='undefined'){
$string_value=$value.toString();
$string_field_value=$field_value.toString();
$bracket="{";
if($string_value.indexOf($bracket)!=-1){
$form=$this.parents('.super-form:eq(0)');
$regular_expression=/\{(.*?)\}/g;
$name=$regular_expression.exec($value);
$name=$name[1];
$element=$form.find('.super-shortcode-field[name="'+$name+'"]');
if($element.length){
$text_field=true;
$parent=$element.parents('.super-field:eq(0)');
if(($parent.hasClass('super-dropdown'))||($parent.hasClass('super-countries'))){
$text_field=false;
$sum=0;
$selected=$parent.find('.super-dropdown-ui li.super-active:not(.super-placeholder)');
$selected.each(function (){
$sum +=$(this).data('value');
});
$value=$sum;
}
if($parent.hasClass('super-checkbox')){
$text_field=false;
$sum=0;
$checked=$parent.find('input[type="checkbox"]:checked');
$checked.each(function (){
$sum +=$(this).val();
});
$value=$sum;
}
if($parent.hasClass('super-currency')){
$text_field=false;
$value=$element.val();
$currency=$element.data('currency');
$format=$element.data('format');
$decimals=$element.data('decimals');
$thousand_separator=$element.data('thousand-separator');
$decimal_seperator=$element.data('decimal-separator');
$value=$value.replace($currency, '').replace($format, '');
$value=$value.split($thousand_separator).join('');
$value=$value.split($decimal_seperator).join('.');
$value=($value) ? parseFloat($value):0;
}
if($text_field===true){
$value=($element.val()) ? $element.val():'';
}}
}}
if(typeof $value2!=='undefined'){
$string_value=$value2.toString();
$string_field_value=$field_value.toString();
$bracket="{";
if($string_value.indexOf($bracket)!=-1){
$form=$this.parents('.super-form:eq(0)');
$regular_expression=/\{(.*?)\}/g;
$name=$regular_expression.exec($value2);
$name=$name[1];
$element=$form.find('.super-shortcode-field[name="'+$name+'"]');
if($element.length){
$text_field=true;
$parent=$element.parents('.super-field:eq(0)');
if(($parent.hasClass('super-dropdown'))||($parent.hasClass('super-countries'))){
$text_field=false;
$sum=0;
$selected=$parent.find('.super-dropdown-ui li.super-active:not(.super-placeholder)');
$selected.each(function (){
$sum +=$(this).data('value');
});
$value2=$sum;
}
if($parent.hasClass('super-checkbox')){
$text_field=false;
$sum=0;
$checked=$parent.find('input[type="checkbox"]:checked');
$checked.each(function (){
$sum +=$(this).val();
});
$value2=$sum;
}
if($parent.hasClass('super-currency')){
$text_field=false;
$value2=$element.val();
$currency=$element.data('currency');
$format=$element.data('format');
$decimals=$element.data('decimals');
$thousand_separator=$element.data('thousand-separator');
$decimal_seperator=$element.data('decimal-separator');
$value2=$value2.replace($currency, '').replace($format, '');
$value2=$value2.split($thousand_separator).join('');
$value2=$value2.split($decimal_seperator).join('.');
$value2=($value2) ? parseFloat($value2):0;
}
if($text_field===true){
$value2=($element.val()) ? $element.val():'';
}}
}}
$counter=0;
if($logic=='equal'){
if($field_value==$value){
$counter++;
}}
if($logic=='not_equal'){
if($field_value!=$value){
$counter++;
}}
if($logic=='contains'){
if($field_value.indexOf($value) >=0){
$counter++;
}}
$field_value=parseFloat($field_value);
$value=parseFloat($value);
$value2=parseFloat($value2);
if($logic=='greater_than'){
if($field_value>$value){
$counter++;
}}
if($logic=='less_than'){
if($field_value<$value){
$counter++;
}}
if($logic=='greater_than_or_equal'){
if($field_value>=$value){
$counter++;
}}
if($logic=='less_than_or_equal'){
if($field_value<=$value){
$counter++;
}}
if($logic=='greater_than_and_less_than'){
if(($field_value>$value)&&($field_value<$value2)){
$counter++;
}}
if($logic=='greater_than_or_less_than'){
if(($field_value>$value)||($field_value<$value2)){
$counter++;
}}
if($logic=='greater_than_or_equal_and_less_than'){
if(($field_value>=$value)&&($field_value<$value2)){
$counter++;
}}
if($logic=='greater_than_or_equal_or_less_than'){
if(($field_value>=$value)||($field_value<$value2)){
$counter++;
}}
if($logic=='greater_than_and_less_than_or_equal'){
if(($field_value>$value)&&($field_value<=$value2)){
$counter++;
}}
if($logic=='greater_than_or_less_than_or_equal'){
if(($field_value>$value)||($field_value<=$value2)){
$counter++;
}}
if($logic=='greater_than_or_equal_and_less_than_or_equal'){
if(($field_value>=$value)&&($field_value<=$value2)){
$counter++;
}}
if($logic=='greater_than_or_equal_or_less_than_or_equal'){
if(($field_value>=$value)||($field_value<=$value2)){
$counter++;
}}
if($counter===0){
$error=true;
}}
if($this.hasClass('super-fileupload')){
$file_error=false;
$attr=$this.parent().find('.super-active-files').data('minfiles');
if(typeof $attr!=='undefined'&&$attr!==false){
$total=$this.parent().find('.super-fileupload-files').children('div').length;
if($total < $attr){
$error=true;
}}
$attr=$this.parent().find('.super-active-files').data('maxfiles');
if(typeof $attr!=='undefined'&&$attr!==false){
$total=$this.parent().find('.super-fileupload-files').children('div').length;
if($total > $attr){
$error=true;
}}
}
if($error===true){
SUPER.handle_errors($this, $duration);
$index=$this.parents('.super-multipart:eq(0)').index('.super-form:eq(0) .super-multipart');
$this.parents('.super-form:eq(0)').find('.super-multipart-steps').children('.super-multipart-step:eq('+$index+')').addClass('super-error');
}else{
$this.parents('.super-field:eq(0)').removeClass('error-active');
$this.parents('.super-field:eq(0)').children('p').fadeOut($duration, function(){
$(this).remove();
});
}
if($this.parents('.super-multipart:eq(0)').find('.super-field > p').length===0){
$index=$this.parents('.super-multipart:eq(0)').index('.super-form:eq(0) .super-multipart');
$this.parents('.super-form:eq(0)').find('.super-multipart-steps').children('.super-multipart-step:eq('+$index+')').removeClass('super-error');
}
return $error;
};
SUPER.custom_theme_error=function($form, $this){
if($form.find('input[name="hidden_theme"]').length!==0){
var $theme_options=$form.find('input[name="hidden_theme"]').data();
$this.attr('style', 'background-color:'+$theme_options.error_bg+';border-color:'+$theme_options.error_border+';color:'+$theme_options.error_font);
}};
SUPER.get_duration=function($form){
var $duration;
if($form.find('input[name="hidden_duration"]').length===0){
$duration=parseFloat(super_common_i18n.duration);
}else{
$duration=parseFloat($form.find('input[name="hidden_duration"]').val());
}
return $duration;
};
SUPER.handle_errors=function($this, $duration){
var $error_position=$this.parents('.super-field:eq(0)'),
$position='after',
$message,
$element;
if(($error_position.hasClass('top-left'))||($error_position.hasClass('top-right'))){
$position='before';
}
if($this.data('message')){
$message=$this.data('message');
}else{
$message=super_common_i18n.errors.fields.required;
}
if($this.parents('.super-field:eq(0)').children('p').length===0){
$element=$this.parents('.super-field-wrapper:eq(0)');
if($this.hasClass('super-recaptcha')){
$element=$this;
}
if($position=='before'){
$('
' + $message + '
').insertBefore($element);
}
if($position=='after'){
$('
' + $message + '
').appendTo($element.parents('.super-field:eq(0)'));
}}
if(($this.parents('.super-field').next('.grouped').length!==0)||($this.parents('.super-field').hasClass('grouped'))){
$this.parent().children('p').css('max-width', $this.parent().outerWidth()+'px');
}
SUPER.custom_theme_error($this.parents('.super-form'), $this.parent().children('p'));
$this.parents('.super-field:eq(0)').addClass('error-active');
$this.parents('.super-field:eq(0)').children('p').fadeIn($duration);
};
SUPER.validate_form=function($form, $submit_button, $validate_multipart, e, $doing_submit){
SUPER.before_validating_form_hook(undefined, $form, $doing_submit);
var $action=$submit_button.children('.super-button-name').data('action'),
$url=$submit_button.data('href'),
$proceed=SUPER.before_submit_button_click_hook(e, $submit_button),
$regular_expression=/\{(.*?)\}/g,
$array=[],
$data=[],
$error=false,
$duration=SUPER.get_duration($form),
$i=0,
$name,
$element,
$target,
$submit_button_name,
$old_html,
$loading,
$status,
$status_update,
$this,
$index,
$total,
$progress,
$multipart,
$scroll=true,
$match,
$value;
if($action=='clear'){
SUPER.init_clear_form($form);
return false;
}
if($action=='print'){
SUPER.init_print_form($form, $submit_button);
return false;
}
if($proceed===true){
if(($url!=='')&&(typeof $url!=='undefined')){
while (($match=$regular_expression.exec($url))!==null){
$array[$i]=$match[1];
$i++;
}
for ($i=0; $i < $array.length; $i++){
$name=$array[$i];
$element=$form.find('.super-shortcode-field[name="'+$name+'"]');
if($element.length){
$value=$element.val();
$url=$url.replace('{'+$name+'}', $value);
}}
$url=$url.replace('{', '').replace('}', '');
if($url=='#'){
return false;
}else{
$target=$submit_button.data('target');
if(($target!=='undefined')&&($target=='_blank')){
window.open($url, '_blank');
}else{
window.location.href=$url;
}
return false;
}}else{
if($submit_button.parent('.super-form-button').hasClass('super-loading')){
return false;
}}
}
if(typeof $validate_multipart==='undefined') $validate_multipart='';
if(typeof tinyMCE!=='undefined'){
if(typeof tinyMCE.triggerSave!=='undefined'){
tinyMCE.triggerSave();
}}
$form.find('.super-field').find('.super-shortcode-field, .super-recaptcha, .super-active-files').each(function (){
var $hidden=false,
$this=$(this),
$file_error,
$attr,
$total,
$index,
$validation,
$conditional_validation,
$text_field=true;
$this.parents('.super-shortcode.super-column').each(function(){
if($(this).css('display')=='none'){
$hidden=true;
}});
var $parent=$this.parents('.super-shortcode:eq(0)');
if(( $hidden===true)||(( $parent.css('display')=='none')&&(!$parent.hasClass('super-hidden')))){
}else{
if($this.hasClass('super-active-files')){
$text_field=false;
$file_error=false;
$attr=$this.data('minfiles');
if(typeof $attr!=='undefined'&&$attr!==false){
$total=$this.parent().find('.super-fileupload-files').children('div').length;
if($total < $attr){
$file_error=true;
}}
$attr=$this.data('maxfiles');
if(typeof $attr!=='undefined'&&$attr!==false){
$total=$this.parent().find('.super-fileupload-files').children('div').length;
if($total > $attr){
$file_error=true;
}}
if($file_error===true){
$error=true;
SUPER.handle_errors($this, $duration);
$index=$this.parents('.super-multipart:eq(0)').index('.super-form:eq(0) .super-multipart');
$this.parents('.super-form:eq(0)').find('.super-multipart-steps').children('.super-multipart-step:eq('+$index+')').addClass('super-error');
}else{
$this.parents('.super-field:eq(0)').removeClass('error-active');
$this.parents('.super-field:eq(0)').children('p').fadeOut($duration, function(){
$(this).remove();
});
}
if($this.parents('.super-multipart:eq(0)').find('.super-field > p').length===0){
$index=$this.parents('.super-multipart:eq(0)').index('.super-form:eq(0) .super-multipart');
$this.parents('.super-form:eq(0)').find('.super-multipart-steps').children('.super-multipart-step:eq('+$index+')').removeClass('super-error');
}}
if($text_field===true){
if($this.parents('.super-field:eq(0)').hasClass('super-keyword-tags')){
$this=$this.parents('.super-field:eq(0)').find('.super-keyword');
}
$validation=$this.data('validation');
$conditional_validation=$this.data('conditional-validation');
if(SUPER.handle_validations($this, $validation, $conditional_validation, $duration)){
$error=true;
}}
}});
if($error===false){
if($validate_multipart===true) return true;
$submit_button_name=$submit_button.children('.super-button-name');
$submit_button.parents('.super-form-button:eq(0)').addClass('super-loading');
$old_html=$submit_button_name.html();
$loading=$submit_button.children('.super-button-name').data('loading');
if(super_common_i18n.loading!='Loading...'){
$loading=super_common_i18n.loading;
}
$status=$submit_button_name.data('status');
$status_update=$submit_button_name.data('status-update');
$submit_button_name.html('
'+$loading);
if($form.find('.super-fileupload-files > div').length!==0){
SUPER.upload_files(e, $form, $data, $duration, $old_html, $status, $status_update);
}else{
SUPER.complete_submit(e, $form, $duration, $old_html, $status, $status_update);
}}else{
if($validate_multipart===true){
$scroll=true;
if(typeof $form.attr('data-disable-scroll')!=='undefined'){
$scroll=false;
}
if($scroll){
$('html, body').animate({
scrollTop: $form.parents('.super-form:eq(0)').offset().top-30
}, 1000);
}
return false;
}
if($form.find('.super-multipart-step.super-error').length){
$this=$form.find('.super-multipart-step.super-error:eq(0)');
$index=$this.index();
$total=$form.find('.super-multipart').length;
$progress=100 / $total;
$progress=$progress * ($index+1);
$multipart=$form.find('.super-multipart:eq('+$index+')');
$scroll=true;
if(typeof $multipart.attr('data-disable-scroll')!=='undefined'){
$scroll=false;
}
$form.find('.super-multipart-progress-bar').css('width',$progress+'%');
$form.find('.super-multipart-step').removeClass('active');
$form.find('.super-multipart').removeClass('active');
$multipart.addClass('active');
$this.addClass('active');
$proceed=SUPER.before_scrolling_to_error_hook($form, $form.offset().top - 30);
if($proceed!==true) return false;
if($scroll){
$('html, body').animate({
scrollTop: $this.parents('.super-form:eq(0)').offset().top - 30
}, 1000);
}}else{
$proceed=SUPER.before_scrolling_to_error_hook($form, $form.find('.super-field > p').offset().top-200);
if($proceed!==true) return false;
$('html, body').animate({
scrollTop: $form.find('.super-field > p').offset().top-200
}, 1000);
}}
SUPER.after_validating_form_hook(undefined, $form);
};
SUPER.auto_step_multipart=function($field){
var $form=$field.parents('.super-form:eq(0)');
var $active_part=$form.find('.super-multipart.active');
var $auto_step=$active_part.data('step-auto');
if($auto_step=='yes'){
var $total_fields=0;
$active_part.find('.super-shortcode-field').each(function(){
var $this=$(this);
var $hidden=false;
$this.parents('.super-shortcode.super-column').each(function(){
if($(this).css('display')=='none'){
$hidden=true;
}});
var $parent=$this.parents('.super-shortcode:eq(0)');
if(($hidden===true)||($parent.css('display')=='none')){
}else{
$total_fields++;
}});
var $counter=1;
$active_part.find('.super-shortcode-field').each(function(){
var $this=$(this);
var $hidden=false;
$this.parents('.super-shortcode.super-column').each(function(){
if($(this).css('display')=='none'){
$hidden=true;
}});
var $parent=$this.parents('.super-shortcode:eq(0)');
if(($hidden===true)||($parent.css('display')=='none')){
}else{
if($total_fields==$counter){
if($this.attr('name')==$field.attr('name')){
setTimeout(function (){
$active_part.find('.super-next-multipart').click();
}, 200);
}}
$counter++;
}});
}};
SUPER.save_form_params_filter=function(params){
var $functions=super_common_i18n.dynamic_functions.save_form_params_filter;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
params=SUPER[value.name](params);
}});
return params;
};
SUPER.before_submit_hook=function($event, $form, $data, $old_html, callback){
var $functions=super_common_i18n.dynamic_functions.before_submit_hook;
var $found=0;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
$found++;
SUPER[value.name]($event, $form, $data, $old_html, callback);
}});
if($found==0){
callback();
}};
SUPER.before_email_send_hook=function($event, $form, $data, $old_html, callback){
var $functions=super_common_i18n.dynamic_functions.before_email_send_hook;
var $found=0;
if(typeof $functions!=='undefined'){
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
$found++;
SUPER[value.name]($event, $form, $data, $old_html, callback);
}});
}
if($found==0){
callback();
}};
SUPER.before_validating_form_hook=function($changed_field, $form, $doing_submit){
var $functions=super_common_i18n.dynamic_functions.before_validating_form_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($changed_field, $form, $doing_submit);
}});
};
SUPER.after_validating_form_hook=function($changed_field, $form){
var $functions=super_common_i18n.dynamic_functions.after_validating_form_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($changed_field, $form);
}});
};
SUPER.after_initializing_forms_hook=function($changed_field, $form, callback){
var $functions=super_common_i18n.dynamic_functions.after_initializing_forms_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($changed_field, $form);
}});
callback($form);
};
SUPER.get_frontend_or_backend_form=function(){
if($('.super-live-preview').length){
return $('.super-live-preview');
}else{
return $(document);
}};
SUPER.after_dropdown_change_hook=function($field, $form, $skip){
if(typeof $field!=='undefined'){
$form=$field.parents('.super-form:eq(0)');
}else{
$form=SUPER.get_frontend_or_backend_form();
}
var $functions=super_common_i18n.dynamic_functions.after_dropdown_change_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($field, $form);
}});
if(typeof $field!=='undefined'&&($skip!==true)){
SUPER.auto_step_multipart($field);
}
SUPER.save_form_progress($form);
};
SUPER.after_field_change_blur_hook=function($field, $form, $skip){
if((typeof $field!=='undefined')&&($skip!==false)){
$form=$field.parents('.super-form:eq(0)');
}else{
if(typeof $field==='undefined'&&typeof $form!=='undefined'){
}else{
$form=SUPER.get_frontend_or_backend_form();
}}
var $functions=super_common_i18n.dynamic_functions.after_field_change_blur_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($field, $form, $skip);
}});
if(typeof $field!=='undefined'&&($skip!==true)){
SUPER.auto_step_multipart($field);
}
SUPER.save_form_progress($form);
};
SUPER.after_radio_change_hook=function($field, $form, $skip){
if(typeof $field!=='undefined'){
$form=$field.parents('.super-form:eq(0)');
}else{
$form=SUPER.get_frontend_or_backend_form();
}
var $functions=super_common_i18n.dynamic_functions.after_radio_change_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($field, $form);
}});
if(typeof $field!=='undefined'&&($skip!==true)){
SUPER.auto_step_multipart($field);
}
SUPER.save_form_progress($form);
};
SUPER.after_checkbox_change_hook=function($field, $form, $skip){
if(typeof $field!=='undefined'){
$form=$field.parents('.super-form:eq(0)');
}else{
$form=SUPER.get_frontend_or_backend_form();
}
var $functions=super_common_i18n.dynamic_functions.after_checkbox_change_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($field, $form);
}});
if(typeof $field!=='undefined'&&($skip!==true)){
SUPER.auto_step_multipart($field);
}
SUPER.save_form_progress($form);
};
SUPER.save_form_progress_timeout=null;
SUPER.save_form_progress=function($form){
if(!$form.hasClass('super-save-progress')){
return false;
}
if(SUPER.save_form_progress_timeout!==null){
clearTimeout(SUPER.save_form_progress_timeout);
}
SUPER.save_form_progress_timeout=setTimeout(function (){
var $data=SUPER.prepare_form_data($form);
var $form_id=$data.form_id;
$data=SUPER.after_form_data_collected_hook($data.data);
$.ajax({
url: super_common_i18n.ajaxurl,
type: 'post',
data: {
action: 'super_save_form_progress',
data: $data,
form_id: $form_id
}});
}, 300);
};
SUPER.after_email_send_hook=function($form){
var $event,
ga=window[window.GoogleAnalyticsObject||'ga'],
$ga_tracking,
$proceed,
$values,
$parameters;
if(typeof ga=='function'){
$ga_tracking=super_common_i18n.ga_tracking;
$ga_tracking=$ga_tracking.split('\n');
$($ga_tracking).each(function(index, value){
$proceed=true;
$values=value.split(":");
if($values.length>1){
$event=$values[1].split("|");
if(!$form.hasClass('super-form-'+$values[0])){
$proceed=false;
}}else{
$event=$values[0].split("|");
}
if($proceed){
if(( (typeof $event[1]==='undefined')||($event[1]==='')) ||
((typeof $event[2]==='undefined')||($event[2]===''))){
console.log('Seems like we are missing required ga() parameters!');
}else{
if(($event[0]=='send')&&($event[1]=='event')){
if((typeof $event[3]==='undefined')||($event[3]==='')){
console.log('ga() is missing the "eventAction" parameter (The type of interaction e.g. "play")');
}else{
$parameters={};
$parameters.hitType=$event[1];
$parameters.eventCategory=$event[2];
$parameters.eventAction=$event[3];
if(typeof $event[4]!=='undefined'){
$parameters.eventLabel=$event[4];
}
if(typeof $event[5]!=='undefined'){
$parameters.eventValue=$event[5];
}
ga($event[0], $parameters);
}}
}}
});
}
var $functions=super_common_i18n.dynamic_functions.after_email_send_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($form);
}});
};
SUPER.after_responsive_form_hook=function($classes, $new_class, $window_classes, $new_window_class){
var $functions=super_common_i18n.dynamic_functions.after_responsive_form_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($classes, $new_class, $window_classes, $new_window_class);
}});
};
SUPER.prepare_form_data_fields=function($form){
var $data={},
$field,
$files;
$form.find('.super-shortcode-field').each(function(){
var $this=$(this),
$hidden=false,
$parent=$this.parents('.super-shortcode:eq(0)'),
$i,
$new_value,
$selected_items,
$email_value,
$tags,
$counter,
$item_value;
if(typeof $this.attr('name')==='undefined'){
if(!$this.parents('.super-field:eq(0)').hasClass('super-keyword-tags')){
return true;
}else{
$this=$this.parents('.super-field:eq(0)').find('.super-keyword');
}}
$this.parents('.super-shortcode.super-column').each(function(){
if($(this).css('display')=='none'){
$hidden=true;
}});
if(( $hidden===true)||(( $parent.css('display')=='none')&&(!$parent.hasClass('super-hidden')))){
}else{
if($this.hasClass('super-fileupload')){
$parent=$this.parents('.super-field-wrapper:eq(0)');
$field=$parent.find('.super-active-files');
$files=$parent.find('.super-fileupload-files > div');
$data[$field.attr('name')]={
'label':$field.data('email'),
'type':'files',
'exclude':$field.data('exclude'),
'exclude_entry':$field.data('exclude-entry'),
'files':{}};
$files.each(function($index,$file){
$file=$(this);
$data[$field.attr('name')].files[$index]={
'name':$field.attr('name'),
'value':$file.attr('data-name'),
'url':$file.attr('data-url'),
'thumburl':$file.attr('data-thumburl'),
'label':$field.data('email'),
'exclude':$field.data('exclude'),
'exclude_entry':$field.data('exclude-entry'),
'excludeconditional':$field.data('excludeconditional'),
};});
}else{
$data[$this.attr('name')]={
'name':$this.attr('name'),
'value':$this.val(),
'label':$this.data('email'),
'exclude':$this.data('exclude'),
'replace_commas':$this.data('replace-commas'),
'exclude_entry':$this.data('exclude-entry'),
'excludeconditional':$this.data('excludeconditional'),
'type':'var'
};
if($this.attr('name')==='mailchimp_list_id'){
if($this.attr('data-vip')) $data[$this.attr('name')].vip=$this.attr('data-vip');
}
var $super_field=$this.parents('.super-field:eq(0)');
if($super_field.hasClass('super-date')){
$data[$this.attr('name')].timestamp=$this.attr('data-math-diff');
}
if($super_field.hasClass('super-textarea')){
$data[$this.attr('name')].type='text';
}
if($this.hasClass('super-address-autopopulate')){
$data[$this.attr('name')].type='google_address';
$data[$this.attr('name')].geometry={
location: {
'lat':$this.data('lat'),
'lng':$this.data('lng'),
}};}
if($super_field.hasClass('super-hidden')){
if($this.data('code')===true){
$data[$this.attr('name')].code='true';
if($this.attr('data-invoice-padding')){
$data[$this.attr('name')].invoice_padding=$this.attr('data-invoice-padding');
}}
}
if($super_field.hasClass('super-auto-suggest')||$super_field.hasClass('super-wc-order-search')){
var $value=$super_field.find('.super-field-wrapper .super-dropdown-ui > .super-active').attr('data-value');
if(typeof $value!=='undefined'){
$data[$this.attr('name')].value=$value.split(";")[0];
}}
if($super_field.hasClass('super-dropdown')){
$i=0;
$new_value='';
$selected_items=$super_field.find('.super-field-wrapper .super-dropdown-ui > .super-active');
$selected_items.each(function(){
if($i===0){
$new_value +=$(this).text();
if($this.data('admin-email-value')=='both'){
$new_value +=' ('+$(this).data('value')+')';
}}else{
$new_value +=', '+$(this).text();
if($this.data('admin-email-value')=='both'){
$new_value +=' ('+$(this).data('value')+')';
}}
$i++;
});
$data[$this.attr('name')].option_label=$new_value;
if(($this.data('admin-email-value')=='label')||($this.data('admin-email-value')=='both')){
$data[$this.attr('name')].admin_value=$new_value;
}else{
$i=0;
$new_value='';
$selected_items.each(function(){
$item_value=$(this).data('value').toString().split(';');
if($i===0){
$new_value +=$item_value[0];
}else{
$new_value +=', '+$item_value[0];
}
$i++;
});
$data[$this.attr('name')].value=$new_value;
}
$email_value=$this.data('confirm-email-value');
if(($email_value=='label')||($email_value=='both')){
$i=0;
$new_value='';
$selected_items.each(function(){
$item_value=$(this).data('value').toString().split(';');
if($i===0){
$new_value +=$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}else{
$new_value +=', '+$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}
$i++;
});
$data[$this.attr('name')].confirm_value=$new_value;
}
$email_value=$this.data('contact-entry-value');
if(($email_value=='label')||($email_value=='both')){
$i=0;
$new_value='';
$selected_items.each(function(){
$item_value=$(this).data('value').toString().split(';');
if($i===0){
$new_value +=$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}else{
$new_value +=', '+$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}
$i++;
});
$data[$this.attr('name')].entry_value=$new_value;
}}
if($super_field.hasClass('super-checkbox')||$super_field.hasClass('super-radio')){
$i=0;
$new_value='';
$selected_items=$super_field.find('.super-field-wrapper .super-active');
$selected_items.each(function(){
$item_value=$(this).find('input').val().toString().split(';');
if($i===0){
$new_value +=$(this).text();
if($this.data('admin-email-value')=='both'){
$new_value +=' ('+$item_value[0]+')';
}}else{
$new_value +=', '+$(this).text();
if($this.data('admin-email-value')=='both'){
$new_value +=' ('+$item_value[0]+')';
}}
$i++;
});
$data[$this.attr('name')].option_label=$new_value;
if(($this.data('admin-email-value')=='label')||($this.data('admin-email-value')=='both')){
$data[$this.attr('name')].admin_value=$new_value;
}else{
$i=0;
$new_value='';
$selected_items.each(function(){
$item_value=$(this).find('input').val().toString().split(';');
if($i===0){
$new_value +=$item_value[0];
}else{
$new_value +=','+$item_value[0];
}
$i++;
});
$data[$this.attr('name')].value=$new_value;
}
$email_value=$this.data('confirm-email-value');
if(($email_value=='label')||($email_value=='both')){
$i=0;
$new_value='';
$selected_items.each(function(){
$item_value=$(this).find('input').val().toString().split(';');
if($i===0){
$new_value +=$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}else{
$new_value +=', '+$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}
$i++;
});
$data[$this.attr('name')].confirm_value=$new_value;
}
$email_value=$this.data('contact-entry-value');
if(($email_value=='label')||($email_value=='both')){
$i=0;
$new_value='';
$selected_items.each(function(){
$item_value=$(this).find('input').val().toString().split(';');
if($i===0){
$new_value +=$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}else{
$new_value +=', '+$(this).text();
if($email_value=='both'){
$new_value +=' ('+$item_value[0]+')';
}}
$i++;
});
$data[$this.attr('name')].entry_value=$new_value;
}}
if($super_field.hasClass('super-keyword-tags')){
$i=0;
$new_value='';
$super_field.find('.super-autosuggest-tags > div > span').each(function(){
if($i===0){
$new_value +=$(this).data('value');
}else{
$new_value +=','+$(this).data('value');
}
$i++;
});
$data[$super_field.find('.super-keyword').attr('name')].value=$new_value;
}else{
if($this.hasClass('super-keyword')){
$parent=$this.parent().find('.super-entered-keywords');
$tags='';
$counter=0;
$parent.children('span').each(function(){
if($counter===0){
$tags +=$(this).text();
}else{
$tags +=', '+$(this).text();
}
$counter++;
});
$data[$this.attr('name')].value=$tags;
}}
}}
});
return $data;
};
SUPER.prepare_form_data=function($form){
var $data=SUPER.prepare_form_data_fields($form),
$form_id='',
$entry_id='',
$dynamic_columns={},
$dynamic_arrays=[],
$map_key_names=[],
$first_property_name,
new_key,
i,
$dynamic_column_fields_data;
$form.find('.super-column[data-duplicate_limit]').each(function(){
$dynamic_arrays=[];
$map_key_names=[];
$first_property_name=undefined;
$(this).find('.super-duplicate-column-fields').each(function(){
$dynamic_column_fields_data=SUPER.prepare_form_data_fields($(this));
if(typeof $first_property_name==='undefined'){
$first_property_name=Object.getOwnPropertyNames($dynamic_column_fields_data)[0];
}
$dynamic_arrays.push($dynamic_column_fields_data);
});
if($first_property_name!==undefined){
Object.keys($dynamic_arrays[0]).forEach(function(key){
$map_key_names.push(key);
});
Object.keys($dynamic_arrays).forEach(function(key){
if(key>0){
i=0;
Object.keys($dynamic_arrays[key]).forEach(function(old_key){
new_key=$map_key_names[i];
if(old_key!==new_key){
Object.defineProperty($dynamic_arrays[key], new_key, Object.getOwnPropertyDescriptor($dynamic_arrays[key], old_key));
delete $dynamic_arrays[key][old_key];
}
i++;
});
}});
$dynamic_columns[$first_property_name]=$dynamic_arrays;
}});
if(Object.keys($dynamic_columns).length>0){
$data._super_dynamic_data=$dynamic_columns;
}
if($form.find('input[name="hidden_form_id"]').length!==0){
$form_id=$form.find('input[name="hidden_form_id"]').val();
}
$data.hidden_form_id={
'name':'hidden_form_id',
'value':$form_id,
'type':'form_id'
};
if($form.find('input[name="hidden_contact_entry_id"]').length!==0){
$entry_id=$form.find('input[name="hidden_contact_entry_id"]').val();
}
$data.hidden_contact_entry_id={
'name':'hidden_contact_entry_id',
'value':$entry_id,
'type':'entry_id'
};
return {data:$data, form_id:$form_id, entry_id:$entry_id};};
SUPER.after_form_data_collected_hook=function($data){
var $functions=super_common_i18n.dynamic_functions.after_form_data_collected_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
$data=SUPER[value.name]($data);
}});
return $data;
};
SUPER.after_duplicate_column_fields_hook=function($this, $field, $counter, $column, $field_names, $field_labels){
var $functions=super_common_i18n.dynamic_functions.after_duplicate_column_fields_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($this, $field, $counter, $column, $field_names, $field_labels);
}});
};
SUPER.after_appending_duplicated_column_hook=function($form, $unique_field_names, $clone){
var $functions=super_common_i18n.dynamic_functions.after_appending_duplicated_column_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($form, $unique_field_names, $clone);
}});
};
SUPER.after_duplicating_column_hook=function($form, $unique_field_names, $clone){
var $functions=super_common_i18n.dynamic_functions.after_duplicating_column_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($form, $unique_field_names, $clone);
}});
};
SUPER.before_submit_button_click_hook=function(e, $this){
var $proceed=true;
var $functions=super_common_i18n.dynamic_functions.before_submit_button_click_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
$proceed=SUPER[value.name](e, $proceed, $this);
}});
return $proceed;
};
SUPER.after_preview_loaded_hook=function($form_id){
var $functions=super_common_i18n.dynamic_functions.after_preview_loaded_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($form_id);
}});
};
SUPER.after_form_cleared_hook=function($form){
var $functions=super_common_i18n.dynamic_functions.after_form_cleared_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
SUPER[value.name]($form);
}});
};
SUPER.before_scrolling_to_error_hook=function($form, $scroll){
var $proceed=true;
var $functions=super_common_i18n.dynamic_functions.before_scrolling_to_error_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
$proceed=SUPER[value.name]($proceed, $form, $scroll);
}});
return $proceed;
};
SUPER.before_scrolling_to_message_hook=function($form, $scroll){
var $proceed=true;
var $functions=super_common_i18n.dynamic_functions.before_scrolling_to_message_hook;
jQuery.each($functions, function(key, value){
if(typeof SUPER[value.name]!=='undefined'){
$proceed=SUPER[value.name]($proceed, $form, $scroll);
}});
return $proceed;
};
SUPER.google_maps_api=function(){};
SUPER.google_maps_init=function($changed_field, $form){
if(typeof $form==='undefined'){
$form=SUPER.get_frontend_or_backend_form();
}
if($form.hasClass('super-multipart')){
$form=$form.parents('.super-form:eq(0)');
}
SUPER.google_maps_api.initAutocomplete($changed_field, $form);
SUPER.google_maps_api.initMaps($changed_field, $form);
};
SUPER.google_maps_api.initMaps=function($changed_field, $form){
var $maps;
if(typeof $changed_field==='undefined'){
$maps=$form.find('.super-google-map');
}else{
$form=$changed_field.parents('.super-form:eq(0)');
$maps=$form.find('.super-google-map[data-fields*="{'+$changed_field.attr('name')+'}"]');
}
$maps.each(function(){
var $data=jQuery.parseJSON($(this).children('textarea').val()),
$form_id=$form.find('input[name="hidden_form_id"]').val(),
$zoom=parseFloat($data.zoom),
$address=$data.address,
$address_marker=$data.address_marker,
$polyline_stroke_weight=$data.polyline_stroke_weight,
$polyline_stroke_color=$data.polyline_stroke_color,
$polyline_stroke_opacity=$data.polyline_stroke_opacity,
$polyline_geodesic=$data.polyline_geodesic,
$map=new google.maps.Map(document.getElementById('super-google-map-'+$form_id), {
zoom: $zoom
}),
$center_based_on_address=true,
$polylines,
$path=[],
$coordinates,
$lat,
$lng,
$field_name,
$lat_min='',
$lat_max='',
$lng_min='',
$lng_max='',
$regular_expression=/\{(.*?)\}/g,
Path,
geocoder;
if($data.enable_polyline=='true'){
$polylines=$data.polylines.split('\n');
$($polylines).each(function(index, value){
$coordinates=value.split("|");
$lat=$coordinates[0];
$lng=$coordinates[1];
if($regular_expression.exec($lat)!==null){
$field_name=$lat.replace('{','').replace('}','');
$lat=$form.find('.super-shortcode-field[name="'+$field_name+'"]').attr('data-lat');
if(typeof $lat==='undefined'){
$lat=0;
}}
if($regular_expression.exec($lng)!==null){
$field_name=$lng.replace('{','').replace('}','');
$lng=$form.find('.super-shortcode-field[name="'+$field_name+'"]').attr('data-lng');
if(typeof $lng==='undefined'){
$lng=0;
}}
$lat=parseFloat($lat);
$lng=parseFloat($lng);
if($lat!==0&&$lng!==0){
new google.maps.Marker({
position: {lat: $lat, lng: $lng},
map: $map
});
}
$path.push({lat: $lat, lng: $lng});
if($lat_min===''){
$lat_min=$lat;
$lat_max=$lat;
$lng_min=$lng;
$lng_max=$lng;
}
if($lat_min>$lat) $lat_min=$lat;
if($lat_max<$lat) $lat_max=$lat;
if($lng_min>$lng) $lng_min=$lng;
if($lng_max<$lng) $lng_max=$lng;
});
if($lat_min===0||$lat_max===0||$lng_min===0||$lng_max===0){
$map.setCenter(new google.maps.LatLng((($lat_max + $lat_min) / 2.0),
(($lng_max + $lng_min) / 2.0)
));
}else{
$center_based_on_address=false;
$map.setCenter(new google.maps.LatLng((($lat_max + $lat_min) / 2.0),
(($lng_max + $lng_min) / 2.0)
));
$map.fitBounds(new google.maps.LatLngBounds(new google.maps.LatLng($lat_min, $lng_min),
new google.maps.LatLng($lat_max, $lng_max)
));
Path=new google.maps.Polyline({
path: $path,
geodesic: $polyline_geodesic,
strokeColor: $polyline_stroke_color,
strokeOpacity: $polyline_stroke_opacity,
strokeWeight: $polyline_stroke_weight
});
Path.setMap($map);
}}
if(($address!=='')&&($center_based_on_address===true)){
geocoder=new google.maps.Geocoder();
$address=SUPER.update_variable_fields.replace_tags($form, $regular_expression, $address);
if($address!==''){
geocoder.geocode({ 'address': $address}, function(results, status){
if(status=='OK'){
$map.setCenter(results[0].geometry.location);
if($address_marker=='true'){
new google.maps.Marker({
map: $map,
position: results[0].geometry.location
});
}}else{
alert('Geocode was not successful for the following reason: ' + status);
}});
}}
});
};
SUPER.google_maps_api.initAutocomplete=function($changed_field, $form){
$form.find('.super-address-autopopulate:not(.super-autopopulate-init)').each(function(){
var $element=$(this);
var $field=$element.find('.super-shortcode-field');
$element.addClass('super-autopopulate-init');
var $form=$element.parents('.super-form:eq(0)');
var autocomplete=new google.maps.places.Autocomplete($element[0], {types: ['geocode']});
autocomplete.addListener('place_changed', function (){
var mapping={
street_number: 'street_number',
route: 'street_name',
locality: 'city',
administrative_area_level_2: 'municipality',
administrative_area_level_1: 'state',
country: 'country',
postal_code: 'postal_code'
};
var place=autocomplete.getPlace();
$field.val(place.formatted_address);
var lat=autocomplete.getPlace().geometry.location.lat();
var lng=autocomplete.getPlace().geometry.location.lng();
$element.attr('data-lat', lat).attr('data-lng', lng);
SUPER.google_maps_init($element, $form);
$element.trigger('keyup');
var $street_name='';
var $street_number='';
var $input;
var $attribute;
var $val;
var $address;
for (var i=0; i < place.address_components.length; i++){
var addressType=place.address_components[i].types[0];
$attribute=$element.data('map-'+mapping[addressType]);
if(typeof $attribute!=='undefined'){
$attribute=$attribute.split('|');
if($attribute[1]==='') $attribute[1]='long';
$val=place.address_components[i][$attribute[1]+'_name'];
if($attribute[0]=='street_name') $street_name=$val;
if($attribute[0]=='street_number') $street_number=$val;
$input=$form.find('.super-shortcode-field[name="'+$attribute[0]+'"]');
$input.val($val);
SUPER.after_dropdown_change_hook($input);
}}
$attribute=$element.data('map-street_name_number');
if(typeof $attribute!=='undefined'){
$address='';
if($street_name!=='') $address +=$street_name;
if($address!==''){
$address +=' '+$street_number;
}else{
$address +=$street_number;
}
$attribute=$attribute.split('|');
$input=$form.find('.super-shortcode-field[name="'+$attribute[0]+'"]');
$input.val($address);
SUPER.after_dropdown_change_hook($input);
}
$attribute=$element.data('map-street_number_name');
if(typeof $attribute!=='undefined'){
$address='';
if($street_number!=='') $address +=$street_number;
if($address!==''){
$address +=' '+$street_name;
}else{
$address +=$street_name;
}
$attribute=$attribute.split('|');
$input=$form.find('.super-shortcode-field[name="'+$attribute[0]+'"]');
$input.val($address);
SUPER.after_dropdown_change_hook($input);
}});
});
};
SUPER.checkboxes=function(){
$('.super-checkbox').each(function(){
var $value='';
var $counter=0;
var $checked=$(this).find('input[type="checkbox"]:checked');
$checked.each(function (){
if($counter===0) $value=$(this).val();
if($counter!==0) $value=$value + ',' + $(this).val();
$counter++;
});
$(this).find('input[type="hidden"]').val($value);
});
$('.super-radio, .super-shipping').each(function(){
var $name=$(this).find('.super-shortcode-field').attr('name');
$(this).find('input[type="radio"]').attr('name','group_'+$name);
});
$('.super-shipping').each(function(){
if(!$(this).hasClass('html-finished')){
var $currency=$(this).find('.super-shortcode-field').attr('data-currency');
$(this).find('input[type="radio"]').each(function(){
var $html=$(this).parent().html();
var $value=$(this).val();
$(this).parent().html($html+'
— '+$currency+''+parseFloat($value).toFixed(2)+'');
});
$(this).addClass('html-finished');
}});
};
SUPER.reverse_columns=function($form){
$form.find('.super-grid').each(function(){
var $grid=$(this);
var $columns=$grid.children('div.super-column:not(.super-not-responsive)');
$grid.append($columns.get().reverse());
$grid.children('div.super-column:last-child').removeClass('first-column');
$grid.children('div.super-column:eq(0)').addClass('first-column');
});
};
SUPER.handle_columns=function(){
var $this,
$exclusion,
$fields,
$width=0;
$('div.super-field').each(function(){
if($(this).hasClass('grouped')){
if((!$(this).prev().hasClass('grouped'))||($(this).prev().hasClass('grouped-end'))){
$(this).addClass('grouped-start');
}}
});
$('.super-field > .super-label').each(function (){
if($(this).parent().index());
if(!$(this).parent().hasClass('grouped')){
if($(this).outerWidth(true) > $width) $width=$(this).outerWidth(true);
}});
SUPER.checkboxes();
SUPER.generateBarcode();
SUPER.rating();
$('.super-form').each(function (){
$this=$(this);
if($this.hasClass('super-rtl')){
SUPER.reverse_columns($this);
}
$exclusion=super_common_i18n.tab_index_exclusion;
$fields=$($this.find('.super-field:not('+$exclusion+')').get());
$fields.each(function(key, value){
$(value).attr('data-super-tab-index', key);
});
if($this.hasClass('super-rtl')){
SUPER.reverse_columns($this);
}
SUPER.after_initializing_forms_hook(undefined, $this, function($this){
$this.addClass('super-rendered');
if(!$this.hasClass('preload-disabled')){
if(!$this.hasClass('super-initialized')){
setTimeout(function (){
$this.fadeOut(100, function (){
$this.addClass('super-initialized').fadeIn(500);
});
}, 500);
}}else{
$this.addClass('super-initialized');
}});
});
};
SUPER.remove_super_form_classes=function($this, $classes){
$.each($classes, function(k, v){
$this.removeClass(v);
});
};
SUPER.init_replace_html_tags=function($changed_field, $form){
var $i,
$v,
$regex,
$row_regex,
$html_fields,
$target,
$html,
$row_str,
$original,
$field_name,
$field,
$return,
$rows,
$row,
$found,
$tag_items,
$old_name,
$new_name,
$regular_expression,
$array,
$value,
$values,
$new_value,
$match;
if(typeof $form==='undefined'){
$form=SUPER.get_frontend_or_backend_form();
}
if(typeof $changed_field==='undefined'){
$html_fields=$form.find('.super-html-content');
}else{
$form=$changed_field.parents('.super-form:eq(0)');
$html_fields=$form.find('.super-html-content[data-fields*="{'+$changed_field.attr('name')+'}"]');
}
$html_fields.each(function(){
var $counter=0;
$target=$(this);
$html=$target.parent().children('textarea').val();
if($html!==''){
$regex=/foreach\s?\(\s?[\'|"|\s|]?(.*?)[\'|"|\s|]?\)\s?:([\s\S]*?)(?:endforeach\s?;)/g;
while (($v=$regex.exec($html))!==null){
if($v.index===$regex.lastIndex){
$regex.lastIndex++;
}
$original=$v[0];
$field_name=$v[1];
$return='';
if(typeof $v[2]!=='undefined') $return=$v[2];
$rows='';
$field=$form.find('.super-shortcode-field[name="'+$field_name+'"]');
if($field.length){
$row=$return.split('<%counter%>').join(1);
$row=$row.split('<%').join('{');
$row=$row.split('%>').join('}');
$rows +=$row;
$i=2;
$found=$form.find('.super-shortcode-field[name="'+$field_name + '_' + ($i)+'"]').length;
while($found!==0){
$found=$form.find('.super-shortcode-field[name="'+$field_name + '_' + ($i)+'"]').length;
if($found){
$row=$return.split('<%counter%>').join($i);
$row_regex=/<%(.*?)%>/g;
$row_str=$return;
while (($v=$row_regex.exec($row_str))!==null){
if($v.index===$row_regex.lastIndex){
$row_regex.lastIndex++;
}
$tag_items=$v[1].split(';');
$old_name=$tag_items[0];
if($old_name!=='counter'){
$tag_items[0]=$tag_items[0]+'_'+$i;
$new_name=$tag_items.join(';');
$row=$row.split('<%'+$v[1]+'%>').join('{'+$new_name+'}');
}}
$rows +=$row;
}
$i++;
}}
$html=$html.split($original).join($rows);
}
$regular_expression=/\{(.*?)\}/g;
$array=[];
$value='';
while (($match=$regular_expression.exec($html))!==null){
$array[$counter]=$match[1];
$counter++;
}
if($array.length>0){
for ($counter=0; $counter < $array.length; $counter++){
$values=$array[$counter];
$new_value=SUPER.update_variable_fields.replace_tags($form, $regular_expression, '{'+$values+'}', $target);
$html=$html.replace('{'+$values+'}', $new_value);
}}
$html=SUPER.filter_if_statements($html);
$target.html($html);
}});
};
SUPER.init_replace_post_url_tags=function($changed_field, $form){
if(typeof $form==='undefined'){
$form=SUPER.get_frontend_or_backend_form();
}
if(typeof $changed_field!=='undefined'){
$form=$changed_field.parents('.super-form:eq(0)');
}
var $match,
$action=$form.children('form').attr('action'),
$actiontags=$form.children('form').attr('data-actiontags'),
$regular_expression=/\{(.*?)\}/g,
$array=[],
$counter=0,
$target,
$values,
$new_value;
if(typeof $action!=='undefined'){
$target=$form.children('form');
while (($match=$regular_expression.exec($actiontags))!==null){
$array[$counter]=$match[1];
$counter++;
}
if($array.length>0){
for ($counter=0; $counter < $array.length; $counter++){
$values=$array[$counter];
$new_value=SUPER.update_variable_fields.replace_tags($form, $regular_expression, '{'+$values+'}', $target);
$actiontags=$actiontags.replace('{'+$values+'}', $new_value);
}}
$target.attr('action', $actiontags);
}};
SUPER.init_text_editors=function(){
if(typeof tinyMCE!=='undefined'){
$('.super-text-editor:not(.super-initialized)').each(function(){
var $this=$(this),
$name=$this.attr('id'),
$incl_url=$this.data('incl-url');
tinyMCE.execCommand ('mceRemoveEditor', true, $name);
var tinyMCEPreInit={
baseURL: $this.data('baseurl'),
suffix: '.min',
mceInit: {},
qtInit: {},
ref: {},
load_ext: function(url,lang){
var sl=tinyMCE.ScriptLoader;
sl.markDone(url+'/langs/'+lang+'.js');
sl.markDone(url+'/langs/'+lang+'_dlg.js');
}};
tinyMCEPreInit.mceInit[$name]={
theme:"modern",
skin:"lightgray",
language:"en",
formats:{
alignleft: [{
selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",
styles: {
textAlign:"left"
}},{
selector: "img,table,dl.wp-caption",
classes: "alignleft"
}],
aligncenter: [{
selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",
styles: {
textAlign:"center"
}},{
selector: "img,table,dl.wp-caption",
classes: "aligncenter"
}],
alignright: [{
selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",
styles: {
textAlign:"right"
}},{
selector: "img,table,dl.wp-caption",
classes: "alignright"
}],strikethrough: {
inline: "del"
}},
relative_urls:false,
remove_script_host:false,
convert_urls:false,
browser_spellcheck:true,
fix_list_elements:true,
entities:"38,amp,60,lt,62,gt",
entity_encoding:"raw",
keep_styles:false,
cache_suffix:"wp-mce-4310-20160418",
preview_styles:"font-family font-size font-weight font-style text-decoration text-transform",
end_container_on_empty_block:true,
wpeditimage_disable_captions:false,
wpeditimage_html5_captions:true,
plugins:"charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview",
wp_lang_attr:"en-US",
content_css:$incl_url+"/css/dashicons.css,"+$incl_url+"/js/tinymce/skins/wordpress/wp-content.css",
selector:"#"+$name,
resize:"vertical",
menubar:false,
wpautop:false,
indent:false,
toolbar1:"bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,fullscreen,wp_adv",
toolbar2:"formatselect,underline,alignjustify,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",
toolbar3:"",
toolbar4:"",
tabfocus_elements:":prev,:next",
body_class:$name+" post-type-page post-status-publish locale-en-us"
};
tinyMCEPreInit.qtInit[$name]={
id:$name,
buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,more,close"
};
tinyMCEPreInit.ref={
plugins:"charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview",
theme:"modern",
language:"en"
};
if(($this.data('teeny')=='true')||($this.data('teeny')===true)){
tinyMCEPreInit.mceInit[$name].toolbar2=false;
}
if(($this.data('force-br')=='true')||($this.data('force-br')===true)){
tinyMCEPreInit.mceInit[$name].forced_root_block=false;
tinyMCEPreInit.mceInit[$name].force_br_newlines=true;
tinyMCEPreInit.mceInit[$name].force_p_newlines=false;
tinyMCEPreInit.mceInit[$name].convert_newlines_to_brs=true;
}
var init, id, $wrap;
for(id in tinyMCEPreInit.mceInit){
init=tinyMCEPreInit.mceInit[id];
$wrap=tinyMCE.$('#wp-' + id + '-wrap');
if(( $wrap.hasClass('tmce-active')||! tinyMCEPreInit.qtInit.hasOwnProperty(id))&&! init.wp_skip_init){
tinyMCE.init(init);
if(! window.wpActiveEditor){
window.wpActiveEditor=id;
}}
}
for(id in tinyMCEPreInit.qtInit){
quicktags(tinyMCEPreInit.qtInit[id]);
if(! window.wpActiveEditor){
window.wpActiveEditor=id;
}}
});
}};
SUPER.init_set_dropdown_placeholder=function($form){
if(typeof $form==='undefined') $form=$('.super-form');
$form.find('.super-dropdown-ui').each(function(){
var $this=$(this);
var $field=$this.parent('.super-field-wrapper').find('.super-shortcode-field');
var $first_item=$this.children('li:eq(1)');
var $value=$field.val();
if($value===''){
$value=$field.data('default-value');
}
if((typeof $value!=='undefined')&&($value!=='')){
$field.val($value);
var $new_placeholder='';
$value=$value.toString().split(',');
$.each($value, function(index, value){
value=$.trim(value).split(';')[0];
$this.children('li:not(.super-placeholder)').each(function(){
var $item_first_value=$(this).attr('data-value').split(';')[0];
if($item_first_value==value){
$(this).addClass('super-active');
if($new_placeholder===''){
$new_placeholder +=$(this).html();
}else{
$new_placeholder +=','+$(this).html();
}}
});
});
if($new_placeholder!=='') $this.children('.super-placeholder').html($new_placeholder);
}else{
$field.val('');
var $placeholder=$field.attr('placeholder');
if((typeof $placeholder!=='undefined')&&($placeholder!=='')){
$this.children('.super-placeholder').attr('data-value', '').html($placeholder);
}else{
if($this.children('.super-placeholder').html()===''){
$first_item.addClass('super-active');
$this.children('.super-placeholder').attr('data-value', $first_item.attr('data-value')).html($first_item.html());
}}
}});
};
SUPER.init_print_form=function($form, $submit_button){
var win=window.open('','printwindow');
var $html='';
var $print_file=$submit_button.find('input[name="print_file"]');
if((typeof $print_file.val()!=='undefined')&&($print_file.val()!=='')&&($print_file.val()!='0')){
var $file_id=$print_file.val();
var $data=SUPER.prepare_form_data($form);
$data=SUPER.after_form_data_collected_hook($data.data);
$.ajax({
url: super_common_i18n.ajaxurl,
type: 'post',
data: {
action: 'super_print_custom_html',
data: $data,
file_id: $file_id
},
success: function (result){
win.document.write(result);
win.print();
win.close();
return false;
},
error: function (xhr, ajaxOptions, thrownError){
console.log(xhr, ajaxOptions, thrownError);
alert('Failed to process data, please try again');
return false;
}});
}else{
var $css="";
$html=$css;
$html +='
';
$form.find('.super-shortcode-field').each(function(){
var $items='';
if(($(this).attr('name')=='hidden_form_id')||($(this).attr('name')=='id')) return true;
var $parent=$(this).parents('.super-shortcode:eq(0)');
$html +='';
$html +='';
$html +=$(this).data('email');
$html +=' | ';
$html +='';
if($parent.hasClass('super-radio')){
$html +=$parent.find('.super-active').text();
}else if($parent.hasClass('super-dropdown')){
$parent.find('.super-dropdown-ui .super-active').each(function(){
if($items===''){
$items +=$(this).text();
}else{
$items +=', '+$(this).text();
}});
$html +=$items;
}else if($parent.hasClass('super-checkbox')){
$parent.find('.super-active').each(function(){
if($items===''){
$items +=$(this).text();
}else{
$items +=', '+$(this).text();
}});
$html +=$items;
}else{
$html +=$(this).val();
}
$html +=' | ';
$html +='
';
});
$html +='
';
win.document.write($html);
win.print();
win.close();
}};
SUPER.init_clear_form=function($form){
$form.find('.super-shortcode.super-slider > .super-field-wrapper > *:not(.super-shortcode-field)').remove();
$form.find('.super-address-autopopulate').removeClass('super-autopopulate-init');
$form.find('.super-datepicker').removeClass('super-picker-initialized');
$form.find('.super-color .super-shortcode-field').removeClass('super-picker-initialized');
$form.find('.super-color .sp-replacer').remove();
$form.find('.super-auto-suggest').find('.super-dropdown-ui li').css('display','').removeClass('super-active');
$form.find('.super-overlap').removeClass('super-overlap');
$form.find('.super-tabs-menu .super-tabs-tab').removeClass('super-active');
$form.find('.super-tabs-menu .super-tabs-tab').each(function(){
if($(this).index()==0){
$(this).addClass('super-active');
}});
$form.find('.super-duplicate-column-fields').each(function(){
if($(this).index()>0){
$(this).remove();
}});
$form.find('.super-shortcode-field').each(function(){
if($(this).attr('name')=='hidden_form_id') return true;
var $element=$(this),
$dropdown,
$option,
$toggle_value,
$switch,
$value='',
$field=$element.parents('.super-field:eq(0)'),
$default_value=$element.data('default-value');
if($form.hasClass('super-duplicate-column-fields')){
if(typeof $element.attr('data-absolute-default')!=='undefined'){
$default_value=$element.attr('data-absolute-default');
}else{
$default_value='';
}}
if($field.hasClass('super-checkbox')||$field.hasClass('super-radio')){
$field.find('.super-field-wrapper > label').removeClass('super-active');
$field.find('.super-field-wrapper > label input').prop('checked', false);
$field.find('.super-field-wrapper > label.super-default-selected').addClass('super-active');
$field.find('.super-field-wrapper > label.super-default-selected input').prop('checked', true);
}
if($field.hasClass('super-toggle')){
$switch=$field.find('.super-toggle-switch');
if($default_value===0){
$switch.removeClass('super-active');
$toggle_value=$switch.find('.super-toggle-off').data('value');
}else{
$switch.addClass('super-active');
$toggle_value=$switch.find('.super-toggle-on').data('value');
}
$element.val($toggle_value);
return true;
}
if($field.hasClass('super-dropdown')){
$field.find('.super-dropdown-ui > li').removeClass('super-active');
$field.find('.super-dropdown-ui > li.super-default-selected').addClass('super-active');
if((typeof $default_value!=='undefined')&&($default_value!=='')){
$option=$field.find('.super-dropdown-ui > li[data-value="'+$default_value+'"]');
$field.find('.super-placeholder').html($option.text());
$option.addClass('super-active');
$element.val($default_value);
}else{
if($field.find('.super-dropdown-ui > li.super-active').length===0){
if((typeof $element.attr('placeholder')!=='undefined')&&($element.attr('placeholder')!=='')){
$field.find('.super-placeholder').html($element.attr('placeholder'));
$field.find('.super-dropdown-ui > li[data-value="'+$element.data('placeholder')+'"]').addClass('super-active');
}else{
$field.find('.super-placeholder').html($field.find('.super-dropdown-ui > li:eq(0)').text());
}
$element.val('');
}else{
var $new_value='';
var $new_placeholder='';
$field.find('.super-dropdown-ui > li.super-active').each(function(){
if($new_value===''){
$new_value +=$(this).data('value');
}else{
$new_value +=','+$(this).data('value');
}
if($new_placeholder===''){
$new_placeholder +=$(this).text();
}else{
$new_placeholder +=', '+$(this).text();
}});
$field.find('.super-placeholder').html($new_placeholder);
$element.val($new_value);
}}
return true;
}
if(typeof $default_value!=='undefined'){
$value=$default_value;
$element.val($value);
if($field.hasClass('super-slider')){
if($element.parent('.super-field-wrapper').children('.slider').length){
$element.simpleSlider("setValue", $value);
}
return true;
}
if($field.hasClass('super-rating')){
if($value===0){
$field.find('.super-rating-star').removeClass('super-active');
}else{
var $rating=$field.find('.super-rating-star:eq('+($value-1)+')');
if($rating.length){
$field.find('.super-rating-star').removeClass('super-active');
$rating.addClass('super-active');
$rating.prevAll('.super-rating-star').addClass('super-active');
}}
}}else{
if($field.hasClass('super-countries')){
var $placeholder=$element.attr('placeholder');
if(typeof $placeholder==='undefined'){
$dropdown=$field.find('.super-dropdown-ui');
$option=$field.find('.super-dropdown-ui > li:nth-child(2)');
$dropdown.children('li').removeClass('super-active');
$dropdown.children('.super-default-selected').addClass('super-active');
$dropdown.find('.super-placeholder').attr('data-value',$option.data('value')).html($option.html());
$element.val($option.data('value'));
}else{
$dropdown=$field.find('.super-dropdown-ui');
$dropdown.children('li').removeClass('super-active');
$dropdown.find('.super-placeholder').attr('data-value','').html($placeholder);
$element.val('');
}
return true;
}
if($field.hasClass('super-file')){
$field.find('.super-fileupload-files').html('');
$field.find('.super-progress-bar').attr('style','');
$element=$field.find('.super-active-files');
$element.val('');
return true;
}}
$element.val($value);
});
SUPER.after_field_change_blur_hook(undefined, $form);
SUPER.after_form_cleared_hook($form);
};
SUPER.populate_form_with_entry_data=function(result, $this, $form){
var $data=jQuery.parseJSON(result);
if($data!==false){
SUPER.init_clear_form($form);
var $dynamic_fields={};
$form.find('.super-duplicate-column-fields').each(function(){
var $first_field=$(this).find('.super-shortcode-field:eq(0)');
var $first_field_name=$first_field.attr('name');
$dynamic_fields[$first_field_name]=$first_field;
});
$.each($dynamic_fields, function(index, field){
var $i=2;
while(typeof $data[index+'_'+$i]!=='undefined'){
if($form.find('.super-shortcode-field[name="'+index+'_'+$i+'"]').length===0){
field.parents('.super-duplicate-column-fields:eq(0)').find('.super-add-duplicate').click();
}
$i++;
}});
var $updated_fields={};
$.each($data, function(index, v){
var $html='',
$files='',
$first_value,
$dropdown,
$element=$form.find('.super-shortcode-field[name="'+v.name+'"]'),
$field=$element.parents('.super-field:eq(0)'),
$item_first_value,
$set_field_value,
$option,
$options,
$wrapper,
$labels,
$input,
$rating;
if(typeof $element==='undefined'){
return true;
}
if($element.val()!=v.value){
$updated_fields[v.name]=$element;
}
$element.val(v.value);
if(v.type=='files'){
if((typeof v.files!=='undefined')&&(v.files.length!==0)){
$.each(v.files, function(fi, fv){
if(fi===0){
$files +=fv.value;
}else{
$files +=','+fv.value;
}
$element=$form.find('.super-active-files[name="'+fv.name+'"]');
$field=$element.parents('.super-field:eq(0)');
$html +='
';
});
$element.val($files);
$field.find('.super-fileupload-files').html($html);
$field.find('.super-fileupload').addClass('finished');
}else{
$field.find('.super-fileupload-files').html('');
$field.find('.super-progress-bar').attr('style','');
$element=$field.find('.super-active-files');
$element.val('');
}
return true;
}
if($field.hasClass('super-slider')){
$element.simpleSlider("setValue", v.value);
return true;
}
if($field.hasClass('super-auto-suggest')){
if(v.value!==''){
$first_value=v.value.split(';')[0];
$dropdown=$field.find('.super-dropdown-ui');
$set_field_value='';
$dropdown.children('li').removeClass('super-active');
$dropdown.children('li').each(function(){
$item_first_value=$(this).attr('data-value').split(';')[0];
if($item_first_value==$first_value){
$field.find('.super-field-wrapper').addClass('super-overlap');
$(this).addClass('super-active');
if($set_field_value===''){
$set_field_value +=$(this).text();
}else{
$set_field_value +=','+$(this).text();
}}
});
$element.val($set_field_value);
}else{
$field.find('.super-dropdown-ui > li').removeClass('super-active');
}}
if($field.hasClass('super-dropdown')){
if(v.value!==''){
$options=v.value.split(',');
$dropdown=$field.find('.super-dropdown-ui');
$dropdown.children('li').removeClass('super-active');
$set_field_value='';
$.each($options, function(index, v){
$dropdown.children('li:not(.super-placeholder)').each(function(){
$item_first_value=$(this).attr('data-value').split(';')[0];
if($item_first_value==v){
$(this).addClass('super-active');
if($set_field_value===''){
$set_field_value +=$item_first_value;
}else{
$set_field_value +=','+$item_first_value;
}}
});
});
$element.val($set_field_value);
}else{
$field.find('.super-dropdown-ui > li').removeClass('super-active');
$field.find('.super-dropdown-ui > li.super-default-selected').addClass('super-active');
}
SUPER.init_set_dropdown_placeholder();
return true;
}
if($field.hasClass('super-radio')){
$wrapper=$field.find('.super-field-wrapper');
$labels=$wrapper.children('label');
$input=$labels.children('input');
$labels.removeClass('super-active');
$input.prop('checked', false);
if(v.value!==''){
$labels.children('input[value="'+v.value+'"]').prop('checked', false);
$labels.children('input[value="'+v.value+'"]').parents('label:eq(0)').addClass('super-active');
}else{
$wrapper.find('label.super-default-selected').addClass('super-active');
$wrapper.find('label.super-default-selected input').prop('checked', true);
}
return true;
}
if($field.hasClass('super-checkbox')){
$wrapper=$field.find('.super-field-wrapper');
$labels=$wrapper.children('label');
$input=$labels.children('input');
$labels.removeClass('super-active');
$input.prop('checked', false);
if(v.value!==''){
$options=v.value.split(',');
$.each($options, function(index, v){
$labels.children('input[value="'+v+'"]').prop('checked', false);
$labels.children('input[value="'+v+'"]').parents('label:eq(0)').addClass('super-active');
});
}else{
$wrapper.children('label.super-default-selected').addClass('super-active');
$wrapper.children('label.super-default-selected input').prop('checked', true);
}
return true;
}
if($field.hasClass('super-rating')){
$rating=$field.find('.super-rating-star:eq('+(v.value-1)+')');
if($rating.length){
$field.find('.super-rating-star').removeClass('super-active');
$rating.addClass('super-active');
$rating.prevAll('.super-rating-star').addClass('super-active');
}
return true;
}
if($field.hasClass('super-countries')){
if(v.value!==''){
$options=v.value.split(',');
$dropdown=$field.find('.super-dropdown-ui');
$dropdown.children('li').removeClass('super-active');
$.each($options, function(index, v){
$dropdown.children('li[data-value="'+v+'"]').addClass('super-active');
});
}else{
var $placeholder=$element.attr('placeholder');
if(typeof $placeholder==='undefined'){
$dropdown=$field.find('.super-dropdown-ui');
$option=$field.find('.super-dropdown-ui > li:nth-child(2)');
$dropdown.children('li').removeClass('super-active');
$dropdown.children('.super-default-selected').addClass('super-active');
$dropdown.find('.super-placeholder').attr('data-value',$option.data('value')).html($option.html());
$element.val($option.data('value'));
}else{
$dropdown=$field.find('.super-dropdown-ui');
$dropdown.children('li').removeClass('super-active');
$dropdown.find('.super-placeholder').attr('data-value','').html($placeholder);
$element.val('');
}}
return true;
}});
$.each($updated_fields, function(index, field){
SUPER.after_field_change_blur_hook($(field));
});
}};
SUPER.populate_form_data_ajax=function($this){
var $order_id,
$value,
$skip,
$method,
$form=$this.parents('.super-form:eq(0)');
if($this.hasClass('super-wc-order-search')){
$value=$this.find('.super-active').data('value');
$order_id=$value.split(';')[0];
$skip=$this.find('.super-shortcode-field').data('wcoss');
if(typeof $skip==='undefined') $skip='';
$this.find('.super-field-wrapper').addClass('super-populating');
$form.addClass('super-populating');
$.ajax({
url: super_common_i18n.ajaxurl,
type: 'post',
data: {
action: 'super_populate_form_data',
order_id: $order_id,
skip: $skip
},
success: function (result){
SUPER.populate_form_with_entry_data(result, $this.find('.super-shortcode-field'), $form);
},
complete: function(){
$this.find('.super-field-wrapper').removeClass('super-populating');
$form.removeClass('super-populating');
},
error: function (xhr, ajaxOptions, thrownError){
console.log(xhr, ajaxOptions, thrownError);
alert('Failed to process data, please try again');
}});
}else{
$this.attr('data-typing', 'false');
$value=$this.val();
$method=$this.data('search-method');
$skip=$this.data('search-skip');
if(typeof $skip==='undefined') $skip='';
if($value.length>2){
$this.parents('.super-field-wrapper:eq(0)').addClass('super-populating');
$form.addClass('super-populating');
$.ajax({
url: super_common_i18n.ajaxurl,
type: 'post',
data: {
action: 'super_populate_form_data',
value: $value,
method: $method,
skip: $skip
},
success: function (result){
SUPER.populate_form_with_entry_data(result, $this, $form);
},
complete: function(){
$this.parents('.super-field-wrapper:eq(0)').removeClass('super-populating');
$form.removeClass('super-populating');
},
error: function (xhr, ajaxOptions, thrownError){
console.log(xhr, ajaxOptions, thrownError);
alert('Failed to process data, please try again');
}});
}}
};
SUPER.init_super_form_frontend=function(){
$('.super-shortcode-field[data-search="true"]:not(.super-dom-populated)').each(function(){
if($(this).val()!==''){
$(this).addClass('super-dom-populated');
SUPER.populate_form_data_ajax($(this));
}});
SUPER.init_text_editors();
SUPER.init_fileupload_fields();
SUPER.init_set_dropdown_placeholder($('.super-form:not(.super-rendered)'));
$('.super-field.super-radio').each(function(){
var $this=$(this);
var $value=$this.find('.super-shortcode-field').val();
if(typeof $value!=='undefined'){
$value=$value.split(',');
$this.find('input[type="radio"]').prop("checked", false);
$.each($value, function(index, value){
value=$.trim(value);
$this.find('input[type="radio"][value="'+value+'"]').prop("checked", true);
});
}});
$('.super-field.super-checkbox').each(function(){
var $this=$(this);
var $value=$this.find('.super-shortcode-field').val();
if(typeof $value!=='undefined'){
$value=$value.split(',');
$this.find('input[type="checkbox"]').prop("checked", false);
$.each($value, function(index, value){
value=$.trim(value);
$this.find('input[type="checkbox"][value="'+value+'"]').prop("checked", true);
});
}});
$('.super-shortcode-field[data-mask]').each(function(){
$(this).mask($(this).data('mask'));
});
$('.super-form').each(function(){
var $form=$(this),
$multipart={},
$multiparts=[],
$submit_button,
$button_html,
$button_name,
$button_clone,
$total=$form.find('.super-multipart').length,
$prev,
$next,
$progress,
$progress_steps,
$progress_bar,
$clone;
if($total!==0){
if(!$form.find('.super-multipart:eq(0)').hasClass('super-rendered')){
$form.find('.super-multipart:eq(0)').addClass('active').addClass('super-rendered');
$submit_button=$form.find('.super-form-button:last');
$clone=$submit_button.clone();
$($clone).appendTo($form.find('.super-multipart:last'));
$button_html=$submit_button.find('.super-button-name').html();
$button_name=$submit_button.find('.super-button-name').text();
$button_clone=$submit_button[0].outerHTML;
$submit_button.remove();
$($button_clone).appendTo($form.find('.super-multipart').not(':last')).removeClass('super-form-button').addClass('super-next-multipart').find('.super-button-name').html(super_common_i18n.directions.next);
$($button_clone).appendTo($form.find('.super-multipart').not(':first')).removeClass('super-form-button').addClass('super-prev-multipart').find('.super-button-name').html(super_common_i18n.directions.prev);
$form.find('.super-multipart').each(function(){
if(typeof $(this).data('prev-text')==='undefined'){
$prev=super_common_i18n.directions.prev;
}else{
$prev=$(this).data('prev-text');
}
if(typeof $(this).data('next-text')==='undefined'){
$next=super_common_i18n.directions.next;
}else{
$next=$(this).data('next-text');
}
$(this).find('.super-prev-multipart .super-button-name').html($prev);
$(this).find('.super-next-multipart .super-button-name').html($next);
$multipart={
name: $(this).data('step-name'),
description: $(this).data('step-description'),
icon: $(this).data('icon'),
};
$multiparts.push($multipart);
});
$progress_steps='
';
$.each($multiparts, function(index, value){
if($total==1){
$progress_steps +='- ';
}else{
if((index===0)&&($total!=(index+1))){
$progress_steps +='
- ';
}else{
if($total==(index+1)){
$progress_steps +='
- ';
}else{
$progress_steps +='
- ';
}}
}
$progress_steps +='';
$progress_steps +='';
$progress_steps +=''+(index+1)+'';
if(value.name!==''){
$progress_steps +=''+value.name+'';
}
if(value.description!==''){
$progress_steps +=''+value.description+'';
}
$progress_steps +='';
$progress_steps +='
';
});
$progress_steps +='
';
$progress=100 / $total;
$progress_bar='
';
$progress_bar +='
';
$progress_bar +='
';
$progress_bar +='
';
$progress_bar +='
';
if($form.find('.super-i18n-switcher').length!=0){
$($progress_steps).insertAfter($form.find('.super-i18n-switcher'));
$($progress_bar).insertAfter($form.find('.super-i18n-switcher'));
}else{
$form.prepend($progress_steps);
$form.prepend($progress_bar);
}}
}});
SUPER.init_super_responsive_form_fields();
SUPER.init_tooltips();
SUPER.init_distance_calculators();
SUPERreCaptcha();
SUPER.init_datepicker();
SUPER.init_masked_input();
SUPER.init_currency_input();
SUPER.init_colorpicker();
SUPER.init_button_colors();
SUPER.init_dropdowns();
SUPER.init_slider_field();
SUPER.google_maps_init();
SUPER.set_keyword_tags_width();
$(window).resize(function(){
SUPER.init_super_responsive_form_fields();
});
var $handle_columns_interval=setInterval(function(){
if(($('.super-form').length!=$('.super-form.super-rendered').length)||($('.super-form').length===0)){
SUPER.handle_columns();
}else{
clearInterval($handle_columns_interval);
}}, 100);
};
SUPER.set_keyword_tags_width=function($field, $counter, $max_tags){
if(typeof $field==='undefined'){
$field=$('.super-form .super-keyword-tags');
}
$field.each(function(){
var $this=$(this),
$width=$this.outerWidth(true),
$wrapper_width=$this.find('.super-field-wrapper').width(),
$icon_width=0,
$autosuggest,
$padding,
$total_width=0,
$input_margins,
$new_width,
$min_input_width,
$margin;
if($wrapper_width>=$width){
$icon_width=$this.find('.super-icon').outerWidth(true);
$width=$width-$icon_width;
}else{
$width=$wrapper_width;
}
$autosuggest=$this.find('.super-autosuggest-tags');
$autosuggest.children('div').css('margin-left','');
$padding=$autosuggest.innerWidth() - $autosuggest.width();
$width=$width - $padding + $icon_width;
$autosuggest.find('div > span').each(function(){
$total_width=$total_width + $(this).outerWidth(true);
});
$autosuggest.children('input').css('width','0px');
$input_margins=$autosuggest.children('input').outerWidth(true);
$new_width=$width-$total_width-$input_margins-3;
$autosuggest.children('input').css('width',$new_width+'px');
$min_input_width=parseFloat($autosuggest.width()/2).toFixed(0);
$min_input_width=parseFloat($min_input_width);
if($total_width>$min_input_width){
if($counter>=$max_tags){
$autosuggest.children('div').css('margin-left','');
}else{
$margin=$total_width - $min_input_width;
$autosuggest.children('div').css('margin-left',-$margin+'px');
}
$autosuggest.children('input').css('width',($min_input_width-$input_margins-3)+'px');
}else{
$autosuggest.children('div').css('margin-left','');
$autosuggest.children('input').css('width',$new_width+'px');
}});
};
SUPER.init_slider_field=function(){
$('.super-slider').each(function (){
var $this=$(this),
$field,
$steps,
$min,
$max,
$currency,
$format,
$value,
$decimals,
$thousand_separator,
$decimal_separator,
$regular_expression,
$wrapper,
$slider,
$number,
$amount,
$dragger,
$slider_width,
$amount_width,
$dragger_margin_left,
$offset_left,
$position;
if($this.find('.slider').length===0){
$field=$this.find('.super-shortcode-field');
$steps=$field.data('steps');
$min=$field.data('minnumber');
$max=$field.data('maxnumber');
$currency=$field.data('currency');
$format=$field.data('format');
$value=$field.val();
$decimals=$field.data('decimals');
$thousand_separator=$field.data('thousand-separator');
$decimal_separator=$field.data('decimal-separator');
$regular_expression='\\d(?=(\\d{' + (3||3) + '})+' + ($decimals > 0 ? '\\D':'$') + ')';
if($value<$min){
$value=$min;
}
$value=parseFloat($value).toFixed(Math.max(0, ~~$decimals));
$value=($decimal_separator ? $value.replace('.', $decimal_separator):$value).replace(new RegExp($regular_expression, 'g'), '$&' + ($thousand_separator||''));
$field.simpleSlider({
snap: true,
step: $steps,
range: [$min, $max],
animate: false
});
$wrapper=$field.parents('.super-field-wrapper:eq(0)');
$slider=$wrapper.find('.slider');
$wrapper.append('
'+$currency+''+$value+''+$format+'');
$slider_width=$slider.outerWidth(true);
$amount_width=$wrapper.children('.amount').outerWidth(true);
$position=$slider.find('.dragger').position();
if((($position.left+$amount_width) + 5) < $slider_width){
$wrapper.children('.amount').css('left', $position.left+'px');
}
$field.bind("slider:changed", function ($event, $data){
$number=parseFloat($data.value).toFixed(Math.max(0, ~~$decimals));
$number=($decimal_separator ? $number.replace('.', $decimal_separator):$number).replace(new RegExp($regular_expression, 'g'), '$&' + ($thousand_separator||''));
$amount=$wrapper.children('.amount');
$dragger=$data.el[0].querySelector('.dragger');
$amount.children('i').html($currency+''+($number)+''+$format);
setTimeout(function(){
$slider_width=$data.el[0].offsetWidth;
$amount_width=$amount[0].offsetWidth;
$dragger_margin_left=$dragger.style.marginLeft.replace('px','');
if($dragger_margin_left<0){
$dragger_margin_left=-$dragger_margin_left;
}
$offset_left=$dragger.offsetLeft + $dragger_margin_left;
if($offset_left<0){
$offset_left=0;
}
if($slider_width < ($offset_left + $amount_width)){
$amount.css('right', '0px');
$amount.css('left', 'inherit');
}else{
$amount.css('right', 'inherit');
$amount.css('left', $offset_left+'px');
}},1);
});
}});
$('.slider-field').each(function (){
var $this=$(this),
$field=$this.children('input'),
$steps=$field.data('steps'),
$min=$field.data('min'),
$max=$field.data('max');
if($this.children('.slider').length===0){
$field.simpleSlider({
snap: true,
step: $steps,
range: [$min, $max]
});
$field.show();
}});
};
SUPER.init_tooltips=function(){
if($.isFunction($.fn.tooltipster)){
$('.super-tooltip:not(.tooltipstered)').tooltipster({
contentAsHTML: true,
});
}};
SUPER.init_color_pickers=function(){
if($.isFunction($.fn.wpColorPicker)){
$('.super-color-picker').each(function(){
if($(this).find('.wp-picker-container').length===0){
$(this).children('input').wpColorPicker({
palettes: ['#F26C68', '#444444', '#6E7177', '#FFFFFF', '#000000']
});
}});
}};
SUPER.init_common_fields=function(){
SUPER.init_tooltips();
SUPER.init_datepicker();
SUPER.init_masked_input();
SUPER.init_currency_input();
SUPER.init_colorpicker();
SUPER.init_slider_field();
SUPER.init_button_colors();
SUPER.init_text_editors();
if(typeof SUPER.init_signature==='function'){
SUPER.init_signature();
}};
SUPER.init_super_responsive_form_fields=function(){
var $classes=[
'super-first-responsiveness',
'super-second-responsiveness',
'super-third-responsiveness',
'super-fourth-responsiveness',
'super-last-responsiveness'
];
var $window_classes=[
'super-window-first-responsiveness',
'super-window-second-responsiveness',
'super-window-third-responsiveness',
'super-window-fourth-responsiveness',
'super-window-last-responsiveness'
];
var $new_class='';
var $new_window_class='';
var $window_width=$(window).outerWidth(true);
$('.super-form').each(function(){
var $this=$(this);
var $width=$(this).outerWidth(true);
if($width > 0&&$width < 530){
SUPER.remove_super_form_classes($this,$classes);
$this.addClass($classes[0]);
$new_class=$classes[0];
}
if($width >=530&&$width < 760){
SUPER.remove_super_form_classes($this,$classes);
$this.addClass($classes[1]);
$new_class=$classes[1];
}
if($width >=760&&$width < 1200){
SUPER.remove_super_form_classes($this,$classes);
$this.addClass($classes[2]);
$new_class=$classes[2];
}
if($width >=1200&&$width < 1400){
SUPER.remove_super_form_classes($this,$classes);
$this.addClass($classes[3]);
$new_class=$classes[3];
}
if($width >=1400){
SUPER.remove_super_form_classes($this,$classes);
$this.addClass($classes[4]);
$new_class=$classes[4];
}
if($window_width > 0&&$window_width < 530){
SUPER.remove_super_form_classes($this,$window_classes);
$this.addClass($window_classes[0]);
$new_window_class=$window_classes[0];
}
if($window_width >=530&&$window_width < 760){
SUPER.remove_super_form_classes($this,$window_classes);
$this.addClass($window_classes[1]);
$new_window_class=$window_classes[1];
}
if($window_width >=760&&$window_width < 1200){
SUPER.remove_super_form_classes($this,$window_classes);
$this.addClass($window_classes[2]);
$new_window_class=$window_classes[2];
}
if($window_width >=1200&&$window_width < 1400){
SUPER.remove_super_form_classes($this,$window_classes);
$this.addClass($window_classes[3]);
$new_window_class=$window_classes[3];
}
if($window_width >=1400){
SUPER.remove_super_form_classes($this,$window_classes);
$this.addClass($window_classes[4]);
$new_window_class=$window_classes[4];
}
if($this.hasClass('super-rtl')){
if((!$this.hasClass('super-rtl-reversed'))&&($new_class=='super-first-responsiveness')){
$this.find('.super-grid').each(function(){
var $grid=$(this);
var $columns=$grid.children('div.super-column:not(.super-not-responsive)');
$grid.append($columns.get().reverse());
$grid.children('div.super-column:last-child').removeClass('first-column');
$grid.children('div.super-column:eq(0)').addClass('first-column');
});
$this.addClass('super-rtl-reversed');
}else{
if(($this.hasClass('super-rtl-reversed'))&&($new_class!='super-first-responsiveness')){
$this.find('.super-grid').each(function(){
var $grid=$(this);
var $columns=$grid.children('div.super-column:not(.super-not-responsive)');
$grid.append($columns.get().reverse());
$grid.children('div.super-column:last-child').removeClass('first-column');
$grid.children('div.super-column:eq(0)').addClass('first-column');
});
$this.removeClass('super-rtl-reversed');
}}
}});
SUPER.set_keyword_tags_width();
SUPER.after_responsive_form_hook($classes, $new_class, $window_classes, $new_window_class);
};
SUPER.init_field_filter_visibility=function($this){
var $nodes,
$name;
if(typeof $this==='undefined'){
$nodes=$('.super-elements-container .field.filter[data-filtervalue], .super-settings .super-field.filter[data-filtervalue]');
$nodes.addClass('hidden');
}else{
$name=$this.find('.element-field').attr('name');
$nodes=$('.super-elements-container .field[data-parent="'+$name+'"], .super-settings .super-field[data-parent="'+$name+'"]');
}
$nodes.each(function(){
var $this=$(this),
$container=$this.parents('.super-elements-container:eq(0)'),
$filtervalue=$this.data('filtervalue'),
$parent,
$value,
$visibility,
$filtervalues,
$string_value,
$match_found=false;
if($container.length===0){
$container=$this.parents('.super-settings:eq(0)');
}
$parent=$container.find('.element-field[name="'+$this.data('parent')+'"]');
$value=$parent.val();
if(typeof $value==='undefined') $value='';
$parent=$parent.parents('.field.filter:eq(0)');
$visibility=$parent.hasClass('hidden');
if($visibility===true){
$visibility='hidden';
}else{
$visibility='visible';
}
$filtervalues=$filtervalue.toString().split(',');
$string_value=$value.toString();
$.each($filtervalues, function(index, value){
if(value==$string_value){
$match_found=true;
}});
if(($value!=='')&&($match_found)&&($visibility!='hidden')){
$this.removeClass('hidden');
}else{
$this.addClass('hidden');
}
SUPER.init_field_filter_visibility($this);
});
};
SUPER.init_distance_calculators=function(){
$('.super-form .super-text .super-distance-calculator').each(function(){
var $this=$(this);
var $form=$this.parents('.super-form:eq(0)');
var $method=$this.data('distance-method');
if($method=='start'){
var $destination=$this.data('distance-destination');
var $destination_field=$form.find('.super-shortcode-field[name="'+$destination+'"]');
$destination_field.attr('data-distance-start',$this.attr('name'));
}});
};
SUPER.super_find_next_tab_field=function($field, $form, $next_tab_index){
var $next_tab_index_small_increment,
$next_field,
$next_field_small_increment,
$next_custom_field,
$custom_tab_index,
$hidden=false,
$parent;
if(typeof $next_tab_index==='undefined'){
$next_tab_index_small_increment=parseFloat(parseFloat($field.attr('data-super-tab-index'))+0.001).toFixed(3);
$next_tab_index=parseFloat($field.attr('data-super-tab-index'))+1;
}
if(typeof $field.attr('data-super-custom-tab-index')!=='undefined'){
$next_tab_index=parseFloat($field.attr('data-super-custom-tab-index'))+1;
}
$next_tab_index_small_increment=parseFloat($next_tab_index_small_increment);
$next_tab_index=parseFloat(parseFloat($next_tab_index).toFixed(0));
$next_field_small_increment=$form.find('.super-field[data-super-tab-index="'+$next_tab_index_small_increment+'"]');
if($next_field_small_increment.length){
$next_field=$next_field_small_increment;
}else{
$next_field=$form.find('.super-field[data-super-tab-index="'+$next_tab_index+'"]');
}
$next_custom_field=$form.find('.super-field[data-super-custom-tab-index="'+$next_tab_index+'"]');
if(($next_custom_field.length)&&(!$next_custom_field.hasClass('super-focus'))){
$next_field=$next_custom_field;
}
$custom_tab_index=$next_field.attr('data-super-custom-tab-index');
if(typeof $custom_tab_index!=='undefined'){
if($next_tab_index < parseFloat($custom_tab_index)){
$next_field=SUPER.super_find_next_tab_field($field, $form, $next_tab_index+1);
}}
$next_field.parents('.super-shortcode.super-column').each(function(){
if($(this).css('display')=='none'){
$hidden=true;
}});
if(( $next_field.css('display')=='none')||($next_field.hasClass('super-hidden'))){
$hidden=true;
}
$parent=$next_field.parents('.super-shortcode:eq(0)');
if(( $hidden===true)||(( $parent.css('display')=='none')&&(!$parent.hasClass('super-hidden')))){
$next_field=SUPER.super_find_next_tab_field($field, $form, $next_tab_index+1);
}
return $next_field;
};
SUPER.super_focus_next_tab_field=function(e, $next, $form, $skip_next){
if(typeof $skip_next!=='undefined'){
$next=$skip_next;
}else{
$next=SUPER.super_find_next_tab_field($next, $form);
}
$form.find('.super-focus *').blur();
$form.find('.super-focus').removeClass('super-focus');
$form.find('.super-focus-dropdown').removeClass('super-focus-dropdown');
$form.find('.super-color .super-shortcode-field').each(function(){
$(this).spectrum("hide");
});
if($next.hasClass('super-form-button')){
$next.addClass('super-focus');
SUPER.init_button_hover_colors($next);
$next.find('a').focus();
e.preventDefault();
return false;
}
if($next.hasClass('super-next-multipart')){
var keyCode=e.keyCode||e.which;
if(keyCode==9){
$next.click().addClass('super-focus');
SUPER.super_focus_next_tab_field(e, $next, $form);
}
e.preventDefault();
return false;
}
if($next.hasClass('super-color')){
$next.addClass('super-focus');
$next.find('.super-shortcode-field').spectrum('show');
e.preventDefault();
return false;
}
if(($next.hasClass('super-dropdown'))||($next.hasClass('super-countries'))){
$next.addClass('super-focus').addClass('super-focus-dropdown');
if($next.find('input[name="super-dropdown-search"]').length){
$next.find('input[name="super-dropdown-search"]').focus();
e.preventDefault();
return false;
}}else{
$next.addClass('super-focus');
}
$next.find('.super-shortcode-field').focus();
e.preventDefault();
return false;
};
jQuery(document).ready(function ($){
var $doc=$(document);
var $super_hp=$doc.find('input[name="super_hp"]');
window.setInterval(function(){
$super_hp.each(function(){
var hasValue=$(this).val().length > 0;
if(!hasValue){
if($(this).is("\\:-webkit-autofill")){
hasValue=true;
}}
if(hasValue){
$super_hp.val('');
}});
}, 1000);
$doc.on('change', '.super-form .super-text .super-distance-calculator', function(){
SUPER.calculate_distance($(this));
});
SUPER.init_field_filter_visibility();
$doc.on('change keyup keydown blur','.field-container.filter, .field.filter, .super-field.filter',function(){
SUPER.init_field_filter_visibility($(this));
});
function super_update_dropdown_value(e, $dropdown, $key){
var $input=$dropdown.find('.super-field-wrapper').children('input');
var $parent=$dropdown.find('.super-dropdown-ui');
var $placeholder=$parent.find('.super-placeholder');
var $selected=$parent.find('.super-active');
var $multiple=false;
if($parent.hasClass('multiple')) $multiple=true;
if($multiple===false){
var $value=$selected.attr('data-value');
var $name=$selected.attr('data-search-value');
$placeholder.html($name).attr('data-value',$value).addClass('super-active');
$parent.find('li').removeClass('super-active');
$selected.addClass('super-active');
$input.val($value);
}else{
var $max=$input.attr('data-maxlength');
var $min=$input.attr('data-minlength');
var $total=$parent.find('li.super-active:not(.super-placeholder)').length;
if($selected.hasClass('super-active')){
if($total>1){
if($total <=$min) return false;
$selected.removeClass('super-active');
}}else{
if($total >=$max) return false;
$selected.addClass('super-active');
}
var $names='';
var $values='';
$total=$parent.find('li.super-active:not(.super-placeholder)').length;
var $counter=1;
$parent.find('li.super-active:not(.super-placeholder)').each(function(){
if(($total==$counter)||($total==1)){
$names +=$(this).attr('data-search-value');
$values +=$(this).attr('data-value');
}else{
$names +=$(this).attr('data-search-value')+', ';
$values +=$(this).attr('data-value')+', ';
}
$counter++;
});
$placeholder.html($names);
$input.val($values);
}
if($key=='enter') $dropdown.removeClass('super-focus-dropdown').removeClass('super-string-found');
SUPER.after_dropdown_change_hook($input);
e.preventDefault();
}
$doc.on('click', '.super-field.super-currency',function(){
var $field=$(this);
var $form=$field.parents('.super-form:eq(0)');
$form.find('.super-focus').removeClass('super-focus');
$form.find('.super-focus-dropdown').removeClass('super-focus-dropdown');
$field.addClass('super-focus');
});
$doc.keydown(function(e){
var $field,
$form,
$dropdown,
$dropdown_ui,
$element,
$item,
$current,
$placeholder,
$next_index,
keyCode=e.keyCode||e.which;
if(keyCode==13){
$dropdown=$('.super-focus-dropdown');
if($dropdown.length){
super_update_dropdown_value(e, $dropdown, 'enter');
}else{
$element=$('.super-focus');
$form=$element.parents('.super-form:eq(0)');
if($form.data('disable-enter')===true){
e.preventDefault();
return false;
}
if(($element.length)&&(!$element.hasClass('super-textarea'))){
if(!$form.find('.super-form-button.super-loading').length){
SUPER.validate_form($form, $form.find('.super-form-button .super-button-wrap'), undefined, e, true);
}
e.preventDefault();
}}
}
if((keyCode==40)||(keyCode==38)){
$dropdown=$('.super-focus-dropdown');
if($dropdown.length){
$placeholder=$dropdown.find('.super-dropdown-ui .super-placeholder');
if(!$dropdown.find('.super-dropdown-ui .super-active').length){
$item=$dropdown.find('.super-dropdown-ui li:eq(1)');
if(keyCode==38){
$item=$dropdown.find('.super-dropdown-ui li:last-child');
}
$item.addClass('super-active');
$placeholder.attr('data-value', $item.data('value')).html($item.html());
}else{
$current=$dropdown.find('.super-dropdown-ui li.super-active');
if(keyCode==38){
$next_index=$current.index() - 1;
if($next_index===0){
$next_index=$dropdown.find('.super-dropdown-ui li:last-child').index();
}}else{
$next_index=$current.index() + 1;
}
$item=$dropdown.find('.super-dropdown-ui li:eq('+$next_index+')');
if($item.length===0){
$item=$dropdown.find('.super-dropdown-ui li:eq(1)');
}
$dropdown.find('.super-dropdown-ui li.super-active').removeClass('super-active');
$placeholder.attr('data-value', $item.data('value')).html($item.html());
$item.addClass('super-active');
}
$dropdown_ui=$dropdown.find('.super-dropdown-ui');
$dropdown_ui.scrollTop($dropdown_ui.scrollTop() - $dropdown_ui.offset().top + $item.offset().top - 50);
super_update_dropdown_value(e, $dropdown);
}}
if(keyCode==9){
$field=$('.super-field.super-focus');
if($field.length){
$form=$field.parents('.super-form:eq(0)');
SUPER.super_focus_next_tab_field(e, $field, $form);
}}
});
$doc.on('keyup', '.super-icon-search input', function(){
var $value=$(this).val();
var $icons=$(this).parents('.super-icon-field').children('.super-icon-list').children('i');
if($value===''){
$icons.css('display','inline-block');
}else{
$icons.each(function(){
if($(this).is('[class*="'+$value+'"]')){
$(this).css('display','inline-block');
}else{
$(this).css('display','none');
}});
}});
$doc.on('click','.super-icon-list i',function(){
if($(this).hasClass('active')){
$(this).parent().find('i').removeClass('active');
$(this).parents('.super-icon-field').find('input').val('');
}else{
$(this).parent().find('i').removeClass('active');
$(this).parents('.super-icon-field').find('input').val($(this).attr('class'));
$(this).addClass('active');
}});
var timeout=null;
$doc.on('keyup', '.super-text .super-shortcode-field[data-search="true"]', function(){
var $this=$(this);
if(timeout!==null){
clearTimeout(timeout);
}
timeout=setTimeout(function (){
SUPER.populate_form_data_ajax($this);
}, 1000);
});
var timeout2=null;
$doc.on('keyup', '.super-text .super-shortcode-field[data-wcosm]', function(){
var $this=$(this);
if(timeout2!==null){
clearTimeout(timeout2);
}
timeout2=setTimeout(function (){
var $value=$this.val();
var $method=$this.data('wcosm');
var $filterby=$this.data('wcosfb');
var $return_label=$this.data('wcosrl');
var $return_value=$this.data('wcosrv');
var $populate=$this.data('wcosp');
var $skip=$this.data('wcoss');
var $status=$this.data('wcosst');
var $form=$this.parents('.super-form:eq(0)');
if($value.length>0){
$this.parents('.super-field-wrapper:eq(0)').addClass('super-populating');
$form.addClass('super-populating');
$.ajax({
url: super_common_i18n.ajaxurl,
type: 'post',
data: {
action: 'super_search_wc_orders',
value: $value,
method: $method,
filterby: $filterby,
return_label: $return_label,
return_value: $return_value,
populate: $populate,
skip: $skip,
status: $status
},
success: function (result){
if(result!==''){
$this.parents('.super-shortcode:eq(0)').addClass('super-focus');
$this.parents('.super-shortcode:eq(0)').addClass('super-string-found');
}
var ul=$this.parents('.super-field-wrapper:eq(0)').children('.super-dropdown-ui');
if(ul.length){
ul.html(result);
}else{
$('
').appendTo($this.parents('.super-field-wrapper:eq(0)'));
}},
complete: function(){
$this.parents('.super-field-wrapper:eq(0)').removeClass('super-populating');
$form.removeClass('super-populating');
},
error: function (xhr, ajaxOptions, thrownError){
console.log(xhr, ajaxOptions, thrownError);
alert('Failed to process data, please try again');
}});
}}, 1000);
});
SUPER.init_slider_field();
SUPER.init_tooltips();
SUPER.init_distance_calculators();
SUPER.init_color_pickers();
SUPER.init_text_editors();
});
})(jQuery);