← Back
Editing: backend-script.js
(()=>{var t={992:()=>{function t(t){t.append('<div class="wpcf7r_loader active"></div>')}function e(){jQuery(".wpcf7r_loader").remove()}jQuery(document).ready((function(){jQuery(".extensions").on("click",".promo-box .btn-activate",(function(t){t.preventDefault(),jQuery(this).parents(".promo-box").find(".serial").addClass("open")})),jQuery(".extensions").on("click",".promo-box .btn-close",(function(t){t.preventDefault(),jQuery(this).parents(".promo-box").find(".serial").removeClass("open")})),jQuery(".extensions").on("click",".promo-box .btn-activate-serial",(function(i){i.preventDefault();const n=jQuery(this).parents(".promo-box"),o=n.find(".serial-number").val();if(!o)return n.find(".serial-number").addClass("err"),!1;n.find(".serial-number").removeClass("err"),t(n),function(t,i){const n=t.data("extension");jQuery.ajax({type:"post",dataType:"json",url:ajaxurl,data:{action:"activate_wpcf7r_extension",extension_name:n,serial:i,wpcf7r_nonce:wpcf_get_nonce()},success:function(i){"undefined"!=i.extension_html&&i.extension_html?(t.replaceWith(i.extension_html),window.location.reload()):void 0!==i.error&&i.error&&(t.find(".err").remove(),t.append('<div class="err">'+i.error+"</div>")),e()}})}(n,o)})),jQuery(".extensions").on("click",".promo-box .btn-deactivate",(function(i){i.preventDefault();const n=jQuery(this).parents(".promo-box");t(n),function(t){const i=t.data("extension");jQuery.ajax({type:"post",dataType:"json",url:ajaxurl,data:{action:"deactivate_wpcf7r_extension",extension_name:i,wpcf7r_nonce:wpcf_get_nonce()},success:function(i){console.log(i),void 0!==i.error?jQuery(".actions").after('<div class="err">'+i.error+"</div>"):void 0!==i.extension_html&&t.replaceWith(i.extension_html),e()}})}(n)})),jQuery(".extensions").on("click",".promo-box .btn-update",(function(i){i.preventDefault();const n=jQuery(this).parents(".promo-box");t(n),function(t){const i=t.data("extension");jQuery.ajax({type:"post",dataType:"json",url:ajaxurl,data:{action:"wpcf7r_extension_update",extension_name:i,wpcf7r_nonce:wpcf_get_nonce()},success:function(i){"undefined"!=i.extension_html&&i.extension_html?t.replaceWith(i.extension_html):void 0!==i.error&&i.error&&jQuery(".actions").after('<div class="err">'+i.error+"</div>"),e()}})}(n)})),function(){const t=jQuery(".extensions-list .has-update").length;t&&jQuery("li#extensions-panel-tab a").append(' <span class="update-plugins wpcf7r-update-extensions"><span class="plugin-count">'+t+"</span></span>")}()}))}},e={};function i(n){var o=e[n];if(void 0!==o)return o.exports;var a=e[n]={exports:{}};return t[n](a,a.exports,i),a.exports}(()=>{"use strict";function t(t){this.rules={rules:{}},this.init=function(){this.addMethods(),t("#wpcf7-contact-form-editor form").validate({rules:this.rules,onfocusout:function(t){this.element(t)}})},this.addMethods=function(){this.nospaces(),this.englishAndNumbersOnly()},this.englishAndNumbersOnly=function(){t.validator.addMethod("validateenglishnumbers",(function(t,e){return this.optional(e)||/^[a-z0-9_\-," "]+$/i.test(t)}),"English and numbers only"),t.validator.addClassRules("validateenglishnumbers",{validateenglishnumbers:!0})},this.nospaces=function(){t.validator.addMethod("validatenospace",(function(t,e){return t.indexOf(" ")<0&&""!=t}),"No spaces please"),t.validator.addClassRules("validatenospace",{validatenospace:!0})},this.init()}let e;i(992),function(i){function n(){this.init=function(){this.setparams(),this.admin_field_handlers(),this.register_action_hooks(),this.hide_select_options(),this.init_draggable(),this.renumber_rows(),this.admin_validations=new t(i),this.init_select2(),this.init_media_field(),this.init_colorpickers(),this.mark_default_select_fields()},this.mark_default_select_fields=function(){i(".action-container select").each((function(){0!==i(this).val()&&i(this).val()||i(this).find("option:first-child").prop("selected","selected")}))},this.init_editors=function(t){"undefined"!=typeof tinymce&&t.find("textarea").map((function(){return this.id?this.id:null})).get().filter(Boolean).forEach((t=>{const e=function(){if("undefined"!=typeof tinyMCEPreInit&&"object"==typeof tinyMCEPreInit.mceInit&&Object.keys(tinyMCEPreInit.mceInit).length>0){const t=Object.keys(tinyMCEPreInit.mceInit).filter((t=>t.startsWith("editor-")));if(t.length>0)return tinyMCEPreInit.mceInit[t[0]]}return{plugins:"charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview",toolbar1:"formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,wp_more,spellchecker,fullscreen,wp_adv",toolbar2:"strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help",wpautop:!0,entity_encoding:"raw",convert_urls:!1,branding:!1,menubar:!1,fix_list_elements:!0,entities:"38,amp,60,lt,62,gt",end_container_on_empty_block:!0,relative_urls:!1,resize:"vertical",remove_script_host:!1,wpeditimage_html5_captions:!0,theme:"modern",keep_styles:!1,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"}}}}();e.selector=`#${t}`;const i={buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,more,close"};i.id=t,window.tinymce.init(e),window.quicktags(i)}))},this.init_colorpickers=function(){i("input.colorpicker").addClass("rendered").wpColorPicker()},this.setparams=function(){this.banner_selector=".wpcfr-banner-holder",this.add_and_selector=".add-condition",this.row_template_selector=".row-template",this.remove_and_selector=".qs-condition-actions .rcf7-delete-conditional-rule",this.add_group_button_selector=".wpcfr-add-group",this.rule_group_selector=".wpcfr-rule-group",this.edit_block_title_selector=".conditional-group-titles .dashicons-edit",this.cancel_block_title_selector=".conditional-group-titles .dashicons-no",this.save_block_title_edit_selector=".conditional-group-titles .dashicons-yes",this.tab_title_all_selector=".block-title",this.tab_title_selector=".block-title:not(.edit)",this.tab_title_active_selector=".block-title.active",this.active_tab_selector=".conditional-group-block.active",this.tab_inner_title=".conditional-group-block-title",this.new_block_counter=1,this.add_block_button_selector=".wpcf7r-add-block",this.blocks_container_selector=".conditional-group-blocks",this.remove_block_button_selector=".remove-block",this.group_row_value_select_selector=".group_row_value_select",this.group_select_field_selector=".wpcf7r-fields",this.open_tab_selector="#redirect-panel h3[data-tab-target]",this.show_action_selector=".actions-list .edit a",this.move_action_to_trash_selector=".actions-list .row-actions .trash a",this.dupicate_action_selector=".actions-list .row-actions .duplicate a",this.move_lead_to_trash_selector=".leads-list .trash a",this.custom_checkbox_selector=".wpcf7r-checkbox input",this.action_title_field=".wpcf7-redirect-post-title-fields",this.migrate_from_cf7_api_selector=".migrate-from-send-to-api",this.migrate_from_cf7_redirect_selector=".migrate-from-redirection",this.json_textarea_selector=".json-container",this.butify_button_selector=".wpcf7-redirect-butify",this.add_repeater_field_selector=".qs-repeater-action .dashicons-plus",this.remove_repeater_field_selector=".qs-repeater-action .dashicons-minus",this.api_test_button_selector=".wpcf7-redirect-test_button-fields",this.toggler_handler_selector=".actions-list [data-toggle] input",this.select_toggler_selector="[data-toggler-name]",this.select_action_selector='[name="new-action-selector"]',this.mailchimp_get_lists=".wpcf7-redirect-get_mailchimp_lists-fields",this.mailchimp_create_list=".wpcf7-redirect-create_list-fields",this.mailchimp_list_selector=".field-wrap-mailchimp_list_id select",this.tab_actions_selector='[href="#redirect-panel"]',this.pro_banner_submit_btn_selector=".btn-rp-submit",this.pro_banner_user_email_selecttor='[name="rp_user_email"]',this.new_group_counter=0,this.reset_all_button=".cf7-redirect-reset",this.new_row_counter=0,this.mail_tags_toggle=".mail-tags-title",this.validate_salesforce_app_details=".wpcf7-redirect-validate_connection-fields",this.debug_send_button_selector=".send-debug-info",this.close_popup_button_selector=".wpcfr-close-popup"},this.init_select2=function(t){i(".select2-field select:not(.rendered)").each((function(){i(".select2-field select:not(.rendered)").select2({width:"resolve"}).addClass("rendered")}))},this.init_media_field=function(){let t,e="";if(void 0===wp.media)return void console.log("no media support");const n=wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",multiple:!1});n.on("insert",(function(i){const o=n.state().get("selection").first().toJSON();t.hasClass("file-container")?t.find(".file-url").val(o.url):(t.find(".popup-image").remove(),t.prepend('<img src="'+o.url+'" alt="" style="max-width:100px;" class="popup-image"/>')),e.val(o.url).change()})),i(document.body).on("click",".image-uploader-btn",(function(o){o.preventDefault(),e=i(this).parent().find("input[type=hidden]"),t=i(this).parent(),n.open()})),i(document.body).on("click",".image-remove-btn, .input-remove-btn",(function(n){n.preventDefault(),e=i(this).parent().find("input[type=hidden]"),t=i(this).parent(),t.hasClass("file-container")?t.find(".file-url").val(""):t.find("img").remove(),e.val("")}))},this.beutify_json_and_css=function(t){t.preventDefault();const e=i(t.currentTarget).parents(".hidden-action"),n=e.find(".field-wrap-record_type select").val();this.remove_errors();const o=i("textarea",e);let a=o.val();try{if("json"==n){var s=jQuery.parseJSON(a);s&&(a=JSON.stringify(s,null,"\t"),a&&o.val(a))}else if("xml"==n){var r=jQuery.parseXML(a);if(r){var c=(new XMLSerializer).serializeToString(r);o.val(c)}}}catch(t){this.add_error(o,t)}},this.init_draggable=function(){var t=this;i("#the_list").sortable({items:".drag",axis:"y",helper:function(t,e){return e.children().children().each((function(){i(this).width(i(this).width())})),e},update:function(e,n){const o={order:i("#the_list").sortable("serialize")};t.make_ajax_call("wpcf7r_set_action_menu_order",o,"after_ajax_call");const a=i(n.item).data("actionid");i(n.item).after(i(".action-container[data-actionid="+a+"]")),t.renumber_rows()}})},this.replace_query_var=function(t,e,i){const n=new RegExp("([?&])"+e+"=.*?(&|$)","i"),o=-1!==t.indexOf("?")?"&":"?";return t.match(n)?t.replace(n,"$1"+e+"="+i+"$2"):t+o+e+"="+i},this.renumber_rows=function(){let t=1;i("#the_list tr .num:visible").each((function(){i(this).html(t),t++}))},this.register_action_hooks=function(){i(document.body).on("click",this.add_and_selector,this.add_and_row.bind(this)),i(document.body).on("click",this.remove_and_selector,this.remove_and_row.bind(this)),i(document.body).on("click",this.add_group_button_selector,this.add_new_group.bind(this)),i(document.body).on("click",this.edit_block_title_selector,this.edit_block_title.bind(this)),i(document.body).on("click",this.cancel_block_title_selector,this.cancel_block_title_edit.bind(this)),i(document.body).on("click",this.save_block_title_edit_selector,this.save_block_title_edit.bind(this)),i(document.body).on("click",this.tab_title_selector,this.switch_tab.bind(this)),i(document.body).on("click",this.add_block_button_selector,this.add_new_block.bind(this)),i(document.body).on("click",this.remove_block_button_selector,this.remove_block.bind(this)),i(document.body).on("change",this.group_row_value_select_selector,this.set_select_value.bind(this)),i(document.body).on("change",this.group_select_field_selector,this.show_field_options.bind(this)),i(document.body).on("click",this.open_tab_selector,this.show_hide_tab.bind(this)),i(document.body).on("click",this.show_action_selector,this.show_hide_action.bind(this)),i(document.body).on("click",this.move_action_to_trash_selector,this.move_post_to_trash.bind(this)),i(document.body).on("click",this.move_lead_to_trash_selector,this.move_post_to_trash.bind(this)),i(document.body).on("wpcf7r_after_ajax_call",this.after_ajax_call.bind(this)),i(document.body).on("change",this.custom_checkbox_selector,this.checkbox_changed.bind(this)),i(document.body).on("keyup",this.action_title_field,this.action_title_field_changed.bind(this)),i(document.body).on("click",this.migrate_from_cf7_api_selector,this.migrate_from_cf7_api.bind(this)),i(document.body).on("click",this.migrate_from_cf7_redirect_selector,this.migrate_from_cf7_api.bind(this)),i(document.body).on("click",this.butify_button_selector,this.beutify_json_and_css.bind(this)),i(document.body).on("click",this.add_repeater_field_selector,this.add_repeating_field.bind(this)),i(document.body).on("click",this.remove_repeater_field_selector,this.remove_repeating_field.bind(this)),i(document.body).on("click",this.api_test_button_selector,this.make_api_test_call.bind(this)),i(document.body).on("change",this.toggler_handler_selector,this.data_toggler.bind(this)),i(document.body).on("change",this.select_toggler_selector,this.select_toggler.bind(this)),i(document.body).on("click",this.mailchimp_get_lists,this.mailchimp_get_lists_handler.bind(this)),i(document.body).on("click",this.mailchimp_create_list,this.mailchimp_create_list_handler.bind(this)),i(document.body).on("change",this.mailchimp_list_selector,this.mailchimp_list_select_handler.bind(this)),i(document.body).on("click",this.reset_all_button,this.reset_all_settings.bind(this)),i(document.body).on("click",this.mail_tags_toggle,this.toggle_mail_tags.bind(this)),i(document.body).on("click",this.dupicate_action_selector,this.duplicate_action.bind(this)),i(document.body).on("click",this.close_popup_button_selector,this.close_popup.bind(this)),i(document.body).on("change",this.select_action_selector,this.select_action.bind(this)),i(document.body).on("change",".cf7r-rule-status",o)},this.close_popup=function(t){i(".wpcfr-popup-wrap").remove()},this.toggle_mail_tags=function(t){i(t.currentTarget).next().slideToggle("fast")},this.mailchimp_create_list_handler=function(t){const e=prompt("Please enter list name");null!=e&&this.mailchimp_get_lists_handler(t,e)},this.mailchimp_list_select_handler=function(t){const e=i(t.currentTarget).parents(".action-container").first();var n=e.find(".field-wrap-mailchimp_settings").data("lists");const o=e.find(this.mailchimp_list_selector).val(),a=(n=this.maybe_parse_json(n))[o].list_fields,s=e.find(".field-wrap-mailchimp_key select");i.each(s,(function(t,e){i(e).html(""),i(e).append(`<option value="">${window.rcf7Data.labels.selectField}</option>`),i.each(a,((t,n)=>{i(e).append('<option value="'+t+'">'+n+"</option>")}))}))},this.maybe_parse_json=function(t){let e="";try{e=JSON.parse(t)}catch(i){e=t}return e},this.mailchimp_get_lists_handler=function(t,e){const n=i(t.currentTarget),o=n.parents(".action-container").first();if(this.remove_errors(),!i(".wpcf7-redirect-mailchimp_api_key-fields").val())return this.add_error(".wpcf7-redirect-mailchimp_api_key-fields","Add your key and save the form"),!1;this.show_action_loader(n);const a={action_id:this.get_block_action_id(n),mailchimp_api_key:o.find(".wpcf7-redirect-mailchimp_api_key-fields").val(),list_name:e};this.make_ajax_call("wpcf7r_get_mailchimp_lists",a,"after_ajax_call")},this.show_action_loader=function(t){t.parents(".field-wrap-test_section").first(),this.show_loader(t.parents(".hidden-action").first())},this.select_toggler=function(t){const e=i(t.currentTarget),n=e.data("toggler-name"),o=e.val();i("."+n).hide(),o&&i("."+n+"_"+o).show()},this.select_action=function(t){"purchase"!==i(t.currentTarget).find(":selected").attr("data-action")?i("a.wpcf7-add-new-action").text("Add Action"):i("a.wpcf7-add-new-action").text("Get Addon")},this.data_toggler=function(t){const e=i(t.currentTarget),n=e.parents(".action-container").first(),o=e.parents("[data-toggle]").data("toggle");o&&n.find(o).slideToggle("fast")},this.make_api_test_call=function(t){t.preventDefault();const e=i(t.currentTarget),n=e.parents(".field-wrap-test_section").first();this.show_loader(e.parents(".hidden-action").first());const o={action_id:e.data("action_id"),cf7_id:e.data("cf7_id"),rule_id:e.data("ruleid"),data:n.find("input").serialize()};this.make_ajax_call("wpcf7r_make_api_test",o,"after_ajax_call")},this.remove_repeating_field=function(t){t.preventDefault(),i(t.currentTarget).parents(".qs-repeater-row").remove()},this.add_repeating_field=function(t){t.preventDefault();const e=i(t.currentTarget).parents("[data-repeater-template]");let n,o=e.find("[data-repeater-row-count]").last().data("repeater-row-count");o++;const a=e.data("repeater-template");try{n=JSON.parse(a)}catch(t){return void console.error("Failed to parse repeater template JSON:",t,"Template string:",a)}const s=this.replaceAll(n.template,"new_row",o);e.append(s),i(document.body).trigger("added-repeating-row",[e])},this.migrate_from_cf7_api=function(t){t.preventDefault();const e=i(t.currentTarget);this.show_loader(e.parents(".actions-list"));const n={post_id:e.data("id"),rule_id:e.data("ruleid"),action_type:e.data("migration-type")};this.make_ajax_call("wpcf7r_add_action",n,"after_ajax_call"),e.fadeOut((function(){i(this).remove()}))},this.action_title_field_changed=function(t){t.preventDefault();const e=i(t.currentTarget),n=this.get_block_action_id(e);i('.primary[data-actionid="'+n+'"] .column-post-title').html(e.val())},this.checkbox_changed=function(t){t.preventDefault();const e=i(t.currentTarget),n=e.is(":checked"),o=e.parents(".hidden-action");if(e.data("toggle-label")){const t=e.data("toggle-label");jQuery.each(t,(function(t,e){let i="";i=n?e[0]:e[1],o.find(t).html(i)}))}},this.add_new_action=function(t,e,n){const o={post_id:t,rule_id:e,action_type:n};this.remove_errors(),this.show_loader(i(".wpcf7r-tab-wrap-inner .actions-list")),i(".hidden-action").slideUp("fast"),this.make_ajax_call("wpcf7r_add_action",o,"after_ajax_call")},this.remove_errors=function(){i(".error-message").removeClass("error-message"),i(".error-label").remove()},this.add_error=function(t,e){i(t).addClass("error-message").after('<span class="error-label">'+e+"</span>")},this.show_loader=function(t){i(t).append('<div class="wpcf7r_loader"></div>'),i(".wpcf7r_loader").addClass("active")},this.hide_loader=function(){i(".wpcf7r_loader").fadeOut((function(){i(this).remove()}))},this.after_ajax_call=function(t,e,n,o){var a=this;let s;if("wpcf7r_delete_action"===o&&i(e).each((function(t,e){i('[data-actionid="'+e.post_id+'"]').fadeOut((function(){i(this).remove(),a.renumber_rows()})),i('[data-postid="'+e.post_id+'"]').fadeOut((function(){i(this).remove()}))})),"wpcf7r_add_action"===o||"wpcf7r_duplicate_action"===o){i("[data-wrapid="+e.rule_id+"] #the_list:visible").append(n.action_row);const t=i("[data-wrapid="+e.rule_id+"] #the_list > tr.action-container").last();a.init_select2(),a.renumber_rows(),a.init_colorpickers(),a.init_editors(t),Array.from(document.querySelectorAll("#the_list > tr:not(.action-container):has(.row-actions)")).at(-1)?.querySelector(".row-actions .edit a")?.click()}if("wpcf7r_reset_settings"===o&&window.location.reload(),"wpcf7r_make_api_test"===o&&(s=i("[data-actionid="+e.action_id+"] .field-wrap-test_section"),i("span.err").remove(),void 0!==n.status&&"failed"===n.status?i.each(n.invalid_fields,(function(t,e){s.find("."+t).append('<span class="err">'+e.reason+"</span>")})):i("body").append(n.html)),"wpcf7r_get_mailchimp_lists"===o){s=i("[data-actionid="+e.action_id+"]");const t=s.find(".field-wrap-mailchimp_list_id select"),o=s.find(".field-wrap-mailchimp_api_key");t.html(""),void 0!==n.error&&n.error?this.add_error(o,n.error):(s.find(".field-wrap-mailchimp_settings").attr("data-lists",JSON.stringify(n.lists)).data("lists",JSON.stringify(n.lists)),i.each(n.lists,(function(e,i){var n='<option value="'+i.list_id+'">'+i.list_name+"</option>";t.append(n)})),t.change())}this.hide_loader()},this.duplicate_action=function(t){t.preventDefault();const e=i(t.currentTarget);this.show_loader(e.parents("td"));const n={post_id:e.data("id"),form_id:i("#post_ID").val(),rule_id:e.data("ruleid")};this.make_ajax_call("wpcf7r_duplicate_action",n,"after_ajax_call")},this.move_post_to_trash=function(t){t.preventDefault();const e=i(t.currentTarget);this.show_loader(e.parents("td"));const n=[{post_id:e.data("id")}];this.make_ajax_call("wpcf7r_delete_action",n,"ater_ajax_delete")},this.show_hide_action=function(t){t.preventDefault();const e=i(t.currentTarget).parents("tr").next().find(".hidden-action");i(".hidden-action").not(e).slideUp("fast"),e.slideToggle("fast")},this.show_hide_tab=function(t){const e=i(t.currentTarget);var n=e.data("tab-target");e.toggleClass("active"),i("[data-tab="+n+"]").slideToggle("fast")},this.hide_select_options=function(t){i(".row-template .wpcf7r-fields").each((function(){i(this).trigger("change")}))},this.show_field_options=function(t){const e=i(t.currentTarget),n=e.parents(".row-template");let o="";e.val()&&(o=n.find(".group_row_value[data-rel="+e.val()+"]")),n.find(".group_row_value").hide(),o.length?(o.show(),n.find(".compare-options option").hide(),n.find(".compare-options option[data-comparetype=select]").show()):(n.find(".compare-options option").show(),n.find(".wpcf7-redirect-value").show())},this.set_select_value=function(t){const e=i(t.currentTarget);e.siblings(".wpcf7-redirect-value").val(e.val())},this.remove_block=function(t){t.preventDefault();const e=i(t.currentTarget).parents(".block-title").first();var n=e.data("rel");e.prev().click(),i(".conditional-group-block[data-block-id="+n+"]").remove(),i(".block-title[data-rel="+n+"]").remove()},this.add_new_block=function(t){this.new_block_counter++;const e=i(t.currentTarget),n=this.get_block_action_id(e);let o=wpcfr_template.block_html,a=wpcfr_template.block_title_html;o=this.replaceAll(o,"new_block","block_"+this.new_block_counter),o=this.replaceAll(o,"action_id",n),a=this.replaceAll(a,"new_block","block_"+this.new_block_counter),a=this.replaceAll(a,"action_id",n),i(this.tab_title_all_selector).last().after(a),i(this.blocks_container_selector).append(o),i(this.tab_title_all_selector).last().click()},this.switch_tab=function(t){t.preventDefault();const e=i(t.currentTarget);var n=e.data("rel"),o=i("[data-block-id="+n+"]");i(this.active_tab_selector).removeClass("active"),i(this.tab_title_active_selector).removeClass("active"),e.addClass("active"),o.addClass("active")},this.save_block_title_edit=function(t){t.preventDefault();const e=i(t.currentTarget);var n=e.data("rel"),o=i("[data-block-id="+n+"]");e.siblings("input").attr("readonly","readonly"),e.parent().removeClass("edit"),o.find(this.tab_inner_title).html(e.siblings("input").val())},this.cancel_block_title_edit=function(t){t.preventDefault();const e=i(t.currentTarget);var n=e.data("rel"),o=i("[data-block-id="+n+"]");e.siblings("input").val(e.siblings("input").data("original")).attr("readonly","readonly"),e.parent().removeClass("edit"),o.find(this.tab_inner_title).html(e.siblings("input").val())},this.edit_block_title=function(t){t.preventDefault();const e=i(t.currentTarget);e.parent().addClass("edit"),e.siblings("input").removeAttr("readonly")},this.add_new_group=function(t){t.preventDefault();const e=i(t.currentTarget);var n=this.get_block_action_id(e),o=e.parents(".conditional-group-blocks").find(".wpcfr-rule-groups");this.new_group_counter=o.find(".wpcfr-rule-group").length,this.new_group_counter++;let a=wpcfr_template.group_html;a=this.replaceAll(a,"group-new_group","group-"+this.new_group_counter),a=this.replaceAll(a,"new_group","group-"+this.new_group_counter),a=this.replaceAll(a,"new_block","block_1"),a=this.replaceAll(a,"action_id",n),o.append(a)},this.remove_and_row=function(t){t.preventDefault();const e=i(t.currentTarget);1==e.parents(this.rule_group_selector).find(".row-template").length?e.parents(this.rule_group_selector).remove():e.parents(this.row_template_selector).remove()},this.get_block_action_id=function(t){return t.parents("[data-actionid]").data("actionid")},this.add_and_row=function(t){t.preventDefault();const e=i(t.currentTarget),n=this.get_block_action_id(e),o=e.parents("[data-group-id]").first().data("group-id");if(!this.new_row_counter){const t=e.parents(".repeater-table");this.new_row_counter=t.find(".row-template").length}this.new_row_counter++;let a=wpcfr_template.row_html;a=this.replaceAll(a,"new_block","block_1"),a=this.replaceAll(a,"new_group",o),a=this.replaceAll(a,"new_row","row-"+this.new_row_counter),a=this.replaceAll(a,"action_id",n),e.parents("table").first().find("tbody").append(a)},this.replaceAll=function(t,e,i){return t.replace(new RegExp(e,"g"),i)},this.admin_fields_init=function(){i(".field-wrap input[type=checkbox],.field-wrap select").each((function(){i(this).is(":checked")&&i(this).siblings(".field-notice-hidden").removeClass("field-notice-hidden").addClass("field-notice-show")})),i(".wpcf7-redirect-after-sent-script").each((function(){i(this).val()&&i(this).siblings(".field-notice-danger").removeClass("field-notice-hidden")}))},this.admin_field_handlers=function(){this.admin_fields_init(),i(document.body).on("change",".field-wrap input[type=checkbox],.field-wrap select",(function(){i(this).is(":checked")?i(this).siblings(".field-notice-hidden").removeClass("field-notice-hidden").addClass("field-notice-show"):i(this).siblings(".field-notice-show").addClass("field-notice-hidden").removeClass("field-notice-show")})),i(document.body).on("keyup",".wpcf7-redirect-after-sent-script",(function(t){0!=i(this).val().length?i(this).siblings(".field-notice-danger").removeClass("field-notice-hidden"):i(this).siblings(".field-notice-danger").addClass("field-notice-hidden")})),i(document.body).on("change",".checkbox-radio-1",(function(){const t=i(this).is(":checked");i(".checkbox-radio-1").prop("checked",!1),t&&i(this).prop("checked",!0)}))},this.reset_all_settings=function(t){t.preventDefault(),confirm("Are you sure? this process will delete all of your plugin settings. There is no way back from this process!")&&this.make_ajax_call("wpcf7r_reset_settings",[])},this.make_ajax_call=function(t,e){jQuery.ajax({type:"post",dataType:"json",url:ajaxurl,data:{action:t,data:e,wpcf7r_nonce:jQuery("[name=actions-nonce]").val()?jQuery("[name=actions-nonce]").val():jQuery("[name=_wpcf7nonce]").val()},success:function(n){i(document.body).trigger("wpcf7r_after_ajax_call",[e,n,t])}})},this.init()}function o(t){const{actionId:e}=t.target.dataset,i=document.querySelector(`.field-wrap-action_status input[type="checkbox"][name*="[${e}]"]`);i&&(i.checked=t.target.checked)}i(document).ready((function(){if(e=new n,window.wpcf7_redirect_admin=e,i(document.body).trigger("wpcf7r-loaded",e),function(){const t=document.getElementById("rcf7-add-action-btn"),e=document.getElementById("rcf7-action-dropdown"),i=document.querySelectorAll(".rcf7-dropdown__action-item"),n=document.querySelector(".rcf7-dropdown__search-input");if(!t||!e)return;const o=t.dataset.id,a=t.dataset.ruleid;t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls","actionDropdown");const s=()=>{const i=e?.classList.contains("active");i||e?.classList.add("active"),e?.classList.remove("dropdown--top","dropdown--bottom");const n=t.getBoundingClientRect(),o=e.offsetHeight,a=window.innerHeight-n.bottom,s=n.top;e.style.bottom="",e.style.top="",a>=o||a>s?(e.style.top=n.height+10+"px",e.classList.add("dropdown--bottom")):(e.style.bottom=n.height+10+"px",e.classList.add("dropdown--top")),i||e.classList.remove("active")};t.addEventListener("click",(function(i){i.stopPropagation();const o="true"===t.getAttribute("aria-expanded");t.setAttribute("aria-expanded",!o),e.classList.contains("active")?e.classList.remove("active"):(e.classList.add("active"),s(),setTimeout((()=>n?.focus()),100))})),window.addEventListener("resize",(function(){e.classList.contains("active")&&s()})),document.addEventListener("click",(function(i){i.target&&(e.contains(i.target)||t.contains(i.target)||(e.classList.remove("active"),t.setAttribute("aria-expanded","false")))})),i.forEach((function(t){t.hasAttribute("disabled")||t.addEventListener("click",(function(t){const i=t.target?.getAttribute("data-action");window.wpcf7_redirect_admin.add_new_action(o,a,i),e.classList.remove("active")}))})),n?.addEventListener("input",(function(){const t=this.value.toLowerCase().trim();document.querySelectorAll(".rcf7-dropdown__category-section").forEach((function(e){let i=!1;e.querySelectorAll(".rcf7-dropdown__action-item").forEach((function(e){e.textContent.trim().toLowerCase().includes(t)||""===t?(e.style.display="flex",i=!0):e.style.display="none"})),e.querySelector(".rcf7-dropdown__category-header").style.display=i?"flex":"none"})),s()})),-1!==window.location.href.indexOf("wpcf7r-action-menu-open=true")&&setTimeout((()=>{t.click();const e=new URL(window.location.href);e.searchParams.delete("wpcf7r-action-menu-open"),window.history.replaceState({},"",e)}),100)}(),-1!==window.location.href.indexOf("wpcf7r-tab=true")){const t=i("#redirect-panel-tab");t.length&&t.trigger("click")}}))}(jQuery)})()})();
Save File
Cancel