index of
/
home
/
thefkyzp
/
www
/
wp-content
/
plugins
/
fluentform
/
assets
/
js
/
File: /home/thefkyzp/www/wp-content/plugins/fluentform/assets/js/form-save-progress.js
(()=>{"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t){return function(t){if(Array.isArray(t))return n(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return n(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return n(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,a=new Array(e);n<e;n++)a[n]=t[n];return a}function a(n,a,f,r){var i=0,s="";f.stepAnimationDuration=parseInt(f.stepAnimationDuration);var o="yes"==a.find(".ff-step-container").attr("data-enable_step_data_persistency"),l=!1;o&&(l="yes"==a.find(".ff-step-container").attr("data-enable_step_page_resume"));var c=!!window.fluentFormVars.is_rtl,d=!1,u=function(){return window.fluentFormApp(a)},p=function(t){var e=t.response,a=t.step_completed,r=[];if(jQuery.each(e,(function(t,e){if(e){var a=Object.prototype.toString.call(e);if("[object Object]"===a){var i=jQuery("[data-name=".concat(t,"]"));if(i.length&&"tabular-element"===i.attr("data-type"))jQuery.each(e,(function(e,a){var f=jQuery('[name="'.concat(t,"[").concat(e,']\\[\\]"]'));f.length||(f=jQuery('[name="'.concat(t,"[").concat(e,']"]'))),jQuery.each(f,(function(t,e){var f=n(e).val();-1===jQuery.inArray(f,a)&&f!==a||n(e).prop("checked",!0).change()}))}));else if("chained-select"===i.attr("data-type")){var s={meta_key:i.find("select:first").attr("data-meta_key"),form_id:i.closest("form").attr("data-form_id"),action:"fluentform_get_chained_select_options",filter_options:"all",keys:e};jQuery.getJSON(f.ajaxUrl,s).then((function(t){jQuery.each(t,(function(t,n){var a=i.find("select[data-key='".concat(t,"']"));0!=a.attr("data-index")&&jQuery.each(n,(function(t,e){a.append(jQuery("<option />",{value:e,text:e}))})),a.attr("disabled",!1).val(e[t])}))}))}else jQuery.each(e,(function(e,n){jQuery('[name="'.concat(t,"[").concat(e,']"]')).val(n).change()}))}else if("[object Array]"===a){var o=jQuery("[name=".concat(t,"]"));if("file"==(o=(o=o.length?o:jQuery("[data-name=".concat(t,"]"))).length?o:jQuery("[name=".concat(t,"\\[\\]]"))).attr("type"))y(o,e);else if(o.prop("multiple"))if(n.isFunction(window.Choices)){var l=o.data("choicesjs");r.push({handler:l,values:e})}else o.val(e).change();else if("repeater_field"===o.attr("data-type")){var c=o.find("tbody"),d=o.attr("data-name");jQuery.each(e,(function(t,e){0!=t?c.find("tr:last").clone().appendTo(c).find(".ff-el-form-control").each((function(a,f){var r="ffrpt-"+(new Date).getTime()+a;n(f).val(e[a]),n(f).attr({id:r,name:"".concat(d,"[").concat(t,"][]"),value:e[a]}).change()})):c.find("tr:first .ff-el-form-control").each((function(t,a){n(a).val(e[t]).change()}))}))}else o.each((function(t,a){-1!=jQuery.inArray(n(a).val(),e)&&n(a).prop("checked",!0).change()}))}else{var u=jQuery("[name=".concat(t,"]"));if("radio"===u.prop("type")||"checkbox"===u.prop("type"))jQuery("[name=".concat(t,'][value="').concat(e,'"]')).prop("checked",!0).change();else{var p=u.closest(".ff-el-group").find(".fluentform-signature-pad");if(p.length){var v=p[0].getContext("2d"),m=new Image;m.src=e,m.onload=function(){v.drawImage(m,0,0)}}u.val(e).change()}}}})),r.length>0)for(var i=0;i<r.length;i++)r[i].handler.setValue(r[i].values).change();d=!0,l&&h(a,f.stepAnimationDuration,!0),d=!1},v=function(t,e){0!==t.length&&(n.each(t,(function(t,e){n(e).attr("data-step-number",t)})),t.on("click",(function(t){var a=u(),r=n(this),i=0;try{var s=r.data("step-number");if(isNaN(s))return;n.each(e,(function(t,e){if(i=t,t<s){var f=n(e).find(":input").not(":button").filter((function(t,e){return!n(e).closest(".has-conditions").hasClass("ff_excluded")}));f.length&&a.validate(f)}})),h(s,f.stepAnimationDuration,!0)}catch(t){if(!(t instanceof window.ffValidationError))throw t;h(i,f.stepAnimationDuration,!0),a.showErrorMessages(t.messages),a.scrollToFirstError(350)}})))},m=function(t){if(a.find(".ff-el-progress").length){var e=t.totalSteps,r=t.activeStep,i=100/e*(r+1),s=a.find(".ff-el-progress-title li"),o=a.find(".ff-step-header .ff-el-progress-bar"),l=o.find("span");o.css({width:i+"%"}),i?o.append(l.text(parseInt(i)+"%")):l.empty();var c=f.step_text,d=n(s[r]).text();c=c.replace("%activeStep%",r+1).replace("%totalStep%",e).replace("%stepTitle%",d),a.find(".ff-el-progress-status").html(c),s.css("display","none"),n(s[r]).css("display","inline")}},_=function(t){n(document).on("keydown",r+" .fluentform-step > .step-nav button",(function(t){9==t.which&&"next"==n(this).data("action")&&t.preventDefault()})),n(r).on("click",".fluentform-step .step-nav button, .fluentform-step .step-nav img",(function(e){var f=n(this).data("action"),r="next",s=n(this).closest(".fluentform-step"),o=u();if("next"==f){try{var l=s.find(":input").not(":button").filter((function(t,e){return!n(e).closest(".has-conditions").hasClass("ff_excluded")}));l.length&&o.validate(l),i++}catch(e){if(!(e instanceof window.ffValidationError))throw e;return o.showErrorMessages(e.messages),void o.scrollToFirstError(350)}a.trigger("ff_to_next_page",i),jQuery(document).trigger("ff_to_next_page",{step:i,form:a});var c=a.find(".fluentform-step");a.trigger("ff_render_dynamic_smartcodes",n(c[i]))}else i--,r="prev",a.trigger("ff_to_prev_page",i),jQuery(document).trigger("ff_to_prev_page",{step:i,form:a});var d="yes"!=a.find(".ff-step-container").attr("data-disable_auto_focus");h(i,t,d,r)}))},h=function(t,f){var l=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"next";n("div"+r+"_errors").empty(),i=t;var p=a.find(".ff-step-body"),v=a.find(".ff-step-titles li"),_=a.find(".fluentform-step"),h=_.length;a.offset().top,n("#wpadminbar");_.removeClass("active"),n(_[i]).addClass("active"),v.removeClass("ff_active ff_completed"),n.each(e(Array(i).keys()),(function(t){n(n(v[t])).addClass("ff_completed")})),n(v[i]).addClass("ff_active");var y=function(){if(!window.ff_disable_step_scroll){var t=a.find(".ff_step_start");if(window.ff_scroll_top_offset)var e=window.ff_scroll_top_offset;else e=t.offset().top-20;var r,i,s,o,l;(i=(r=t).offset().top,s=i+r.outerHeight(),o=n(window).scrollTop(),l=o+n(window).height(),s>o&&i<l)&&!window.ff_force_scroll||n("html, body").delay(f).animate({scrollTop:e},0)}},b={left:-100*i+"%"};switch(c&&(b={right:-100*i+"%"}),n(_[i]).closest(".ff-step-container").data("animation_type")){case"slide":p.animate(b,f,(function(){l&&y(),p.css({width:s})}));break;case"fade":p.css({opacity:0}),p.animate(b,f,(function(){l&&y(),p.css({width:s})})),p.animate({opacity:1},f);break;case"slide_down":p.hide(),p.css(b),p.slideDown(f);break;default:p.css(b)}if(o&&!d&!(0===i)&&g(a,i).then((function(t){console.log(t)})),m({activeStep:i,totalSteps:h}),_.last().hasClass("active"))a.find('button[type="submit"]').css("display","inline-block");else if(a.find('button[type="submit"]').css("display","none"),!window.ff_disable_auto_step){var w=0;a.find(".fluentform-step.active .ff_excluded").length&&(w=50),setTimeout((function(){var t=a.find(".fluentform-step.active"),e=a.find(".fluentform-step.active > div").length-1,n=a.find(".fluentform-step.active > .ff_excluded").length;a.find(".fluentform-step.active > .ff-t-container").length&&(e-=a.find(".fluentform-step.active > .ff-t-container").length,e+=a.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > div").length,n+=a.find(".fluentform-step.active > .ff-t-container > .ff-t-cell > .ff_excluded").length,a.find(".fluentform-step.active > .ff-t-container.ff_excluded").length&&(n-=a.find(".fluentform-step.active > .ff-t-container.ff_excluded").length,n-=a.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > .ff_excluded").length,n+=a.find(".fluentform-step.active > .ff-t-container.ff_excluded > .ff-t-cell > div").length)),e==n&&t.find(".step-nav button[data-action="+u+"], .step-nav img[data-action="+u+"]").click()}),w)}},g=function(t,e){var a=t.find(":input").filter((function(t,e){return!n(e).closest(".has-conditions").hasClass("ff_excluded")}));a.filter((function(t,e){var a=n(e);return a.parents().hasClass("ff_repeater_table")&&"select"==a.attr("type")&&!a.val()})).prepend("<option selected disabled />");var r=a.serialize();n.each(t.find("[type=file]"),(function(t,e){var a={},f=e.name+"[]";a[f]=[],n(e).closest("div").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each((function(t,e){a[f][t]=n(this).data("src")})),n.each(a,(function(t,e){if(e.length){var a={};a[t]=e,r+="&"+n.param(a),!0}}))}));var i={active_step:e,data:r,form_id:t.data("form_id"),action:"fluentform_step_form_save_data"};return jQuery.post(f.ajaxUrl,i)},y=function(e,a){var r=e.closest(".ff-el-input--content").find(".ff-uploaded-list");n.each(a,(function(e,a){a="object"===t(a)?a:{url:a,data_src:a};var i=n("<div/>",{class:"ff-upload-preview","data-src":a.data_src,style:"border: 1px solid rgb(111, 117, 125)"}),s=n("<div/>",{class:"ff-upload-thumb"});s.append(n("<div/>",{class:"ff-upload-preview-img",style:"background-image: url('".concat(b(a.url),"');")}));var o=n("<div/>",{class:"ff-upload-details"}),l=n("<span/>",{html:f.upload_completed_txt,class:"ff-upload-progress-inline-text ff-inline-block"}),c=a.url.substring(a.url.lastIndexOf("/")+1);c.includes("-ff-")&&(c=c.substring(c.lastIndexOf("-ff-")+4));var d=n("<div/>",{class:"ff-upload-filename",html:c}),u=n('\n\t\t\t\t\t\t\t\t\t<div class="ff-upload-progress-inline ff-el-progress">\n\t\t\t\t\t\t\t\t\t\t<div style="width: 100%;" class="ff-el-progress-bar"></div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t'),p=n("<span/>",{"data-href":"#",html:"×",class:"ff-upload-remove"}),v=n("<div>",{class:"ff-upload-filesize ff-inline-block",html:""}),m=n("<div>",{class:"ff-upload-error",style:"color:red;"});o.append(d,u,l,v,m,p),i.append(s,o),r.append(i)})),e.trigger("change_remaining",-a.length),e.trigger("change")},b=function(t){var e=t.split(/[#?]/)[0].split(".").pop().trim().toLowerCase();if(-1!=["jpg","jpeg","gif","png"].indexOf(e))return t;var n=document.createElement("canvas");n.width=60,n.height=60,n.style.zIndex=8,n.style.position="absolute",n.style.border="1px solid";var a=n.getContext("2d");return a.fillStyle="rgba(0, 0, 0, 0.2)",a.fillRect(0,0,60,60),a.font="13px Arial",a.fillStyle="white",a.textAlign="center",a.fillText(e,30,30,60),n.toDataURL()};return{init:function(){var t,e,r,l;o&&jQuery(document).ready((function(t){jQuery.getJSON(f.ajaxUrl,{form_id:a.data("form_id"),action:"fluentform_step_form_get_data"}).then((function(t){t&&p(t)}))})),a.find(".fluentform-step:first").find('.step-nav [data-action="prev"]').remove(),t=a.find(".ff-step-body"),e=a.find(".fluentform-step"),r=e.length,l=a.find(".ff-step-titles li"),s=100*r+"%",t.css({width:s}),e.css({width:100/r+"%"}),n(e[i]).addClass("active"),n(l[i]).addClass("active"),e.length&&!e.last().hasClass("active")&&a.find('button[type="submit"]').css("display","none"),m({activeStep:i,totalSteps:r}),_(f.stepAnimationDuration),v(l,e),function(){function t(t){if(1==t.closest(".fluentform-step.active").find(".ff-el-group:not(.ff_excluded):not(.ff-custom_html)").length)if(t.closest(".fluentform-step.active").find(".ff_excluded").length){var e=window.ffTransitionTimeOut||400;setTimeout((function(){t.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")}),e)}else t.closest(".fluentform-step.active").find(".ff-btn-next").trigger("click")}"yes"==a.find(".ff-step-container").attr("data-enable_auto_slider")&&(a.find(".ff-el-form-check-radio,.ff-el-net-label, .ff-el-ratings label").on("click",(function(){t(n(this))})),a.find("select").on("change",(function(){t(n(this))})))}()},updateSlider:h,populateFormDataAndSetActiveStep:p}}var f;(f=jQuery)(document.body).on("fluentform_init",(function(t,e,n){var r="."+n.form_instance,i=-1,s="no";if(f(r).hasClass("ff-form-has-save-progress")){f(r).hasClass("ff-form-has-steps")&&(e.on("ff_to_next_page",(function(t,e){s=e})),e.on("ff_to_prev_page",(function(t,e){s=e}))),f(r).find(".ff-btn-save-progress").each((function(t,n){var a=f(n);a.on("click",(function(t){var n,r=this;t.preventDefault(),a.addClass("ff-working");var o=e.find(":input").filter((function(t,e){return!f(e).closest(".has-conditions").hasClass("ff_excluded")}));o.filter((function(t,e){var n=f(e);return n.parents().hasClass("ff_repeater_table")&&"select"==n.attr("type")&&!n.val()})).prepend("<option selected disabled />");var l=o.serialize();f.each(e.find("[type=file]"),(function(t,e){var n={},a=e.name+"[]";n[a]=[],f(e).closest("div").find(".ff-uploaded-list").find(".ff-upload-preview[data-src]").each((function(t,e){n[a][t]=f(this).data("src")})),f.each(n,(function(t,e){if(e.length){var n={};n[t]=e,l+="&"+f.param(n)}}))})),i=null===(n=window.form_state_save_vars)||void 0===n?void 0:n.key;var c={source_url:window.form_state_save_vars.source_url,action:"fluentform_save_form_progress_with_link",data:l,form_id:e.data("form_id"),hash:i,active_step:s,nonce:window.form_state_save_vars.nonce,save_progress_btn_name:f(a).attr("name")},d=c.form_id+"_save_progress_msg",u="#"+d;jQuery.post(fluentFormVars.ajaxUrl,c).then((function(t){if(t){var n;i=t.data.hash,e.find(".ff-saved-state-link"),""!=(null===(n=t.data)||void 0===n?void 0:n.message)&&(f(u).length&&f(u).slideUp("fast"),f("<div/>",{id:d,class:"ff-message-success ff-el-group"}).html(t.data.message).insertBefore(a.closest(".ff-el-group")));var s=window.form_state_save_vars.copy_button||"Copy",o='<div class="ff-el-input--content">\n <div class="ff_input-group">\n <input readonly value="'.concat(t.data.saved_url,'" class="ff-el-form-control" >\n <div class="ff_input-group-append">\n <button class="ff-btn ff-btn-md ff_btn_style ff_btn_copy_link ff_input-group-text">').concat(s,"</button>\n </div>\n </div>\n </div>"),l=f("<div/>",{class:"ff-el-group ff-saved-state-input ff-saved-state-link ff-hide-group",html:o});f(r).closest(".ff-el-group").after(l),l.fadeIn();var c=window.form_state_save_vars.email_placeholder_str||"Your Email Here",p=window.form_state_save_vars.email_button||"Email";if(f(r).hasClass("ff_resume_email_enabled")){var v='<div class="ff-el-input--content">\n <div class="ff_input-group">\n <input type="email" class="ff-el-form-control" placeholder="'.concat(c,'" class="ff-el-form-control">\n <div class="ff_input-group-append">\n <button class="ff-btn ff-btn-md ff_btn_style ff_btn_is_email ff_input-group-text">').concat(p,"</button>\n </div>\n </div>\n </div>"),m=f("<div/>",{class:"ff-el-group ff-saved-state-input ff-email-address ff-hide-group",html:v});f(l).after(m),m.fadeIn()}}})).fail((function(t){f(u).length&&f(u).slideUp("fast"),f("<div/>",{id:d,class:"ff-message-success ff-el-group text-danger"}).html(t.responseJSON.data.message).insertBefore(a.closest(".ff-el-group"))})).always((function(){a.parent().hide()}))}))})),f(r).on("click",".ff_btn_copy_link",(function(t){t.preventDefault();var e=f(this).closest(".ff-el-input--content").find(".ff-el-form-control").val();navigator.clipboard.writeText(e);var n=window.form_state_save_vars.copy_success_button||"Copied";f(this).html("".concat(n))})),f(r).on("click",".ff_btn_is_email",(function(t){t.preventDefault();var n=f(this).closest(".ff-el-group"),a=f(this).closest(".ff-email-address").find("input").val();f(".ff-email-address").find("input").val("");var r=f(".ff-saved-state-link").find("input").val(),s={source_url:window.form_state_save_vars.source_url,action:"fluentform_email_progress_link",form_id:e.data("form_id"),to_email:a,link:r,hash:i,nonce:window.form_state_save_vars.nonce},o=s.form_id+"_save_progress_email_response",l="#"+o;jQuery.post(fluentFormVars.ajaxUrl,s).then((function(t){t&&(n.removeClass("ff-el-is-error"),f(l).length&&f(l).slideUp("fast"),f("<div/>",{id:o,class:"ff-message-success ff-el-group"}).html(t.data.response).insertAfter(n))})).fail((function(t){t&&(n.addClass("ff-el-is-error"),f(l).length&&f(l).slideUp("fast"),f("<div/>",{id:o,class:"ff-message-success ff-el-group text-danger"}).html(t.responseJSON.data.Error).insertAfter(n))}))}));var o=!1;void 0!==window.form_state_save_vars&&(o=window.form_state_save_vars.key),o&&(e.append('<input type="hidden" value="'.concat(o,'" class="__fluent_state_hash" name="__fluent_state_hash"/>')),jQuery.getJSON(fluentFormVars.ajaxUrl,{form_id:e.data("form_id"),action:"fluentform_get_form_state",hash:o,nonce:window.form_state_save_vars.nonce}).then((function(t){t&&a(f,e,window.fluentFormVars,r).populateFormDataAndSetActiveStep(t)})))}}))})();