509318396
!function(t){"use strict";function e(){t("#bdthemes-templates-builder-modal").show()}function o(){t("#bdthemes-templates-builder-modal form")[0].reset(),t("#bdthemes-templates-builder-modal form .template_id").val(""),n(1)}function a(e){t("#bdthemes-templates-builder-modal form .bdt-modal-submit-btn").val(e)}function i(e){t(".input-error").removeClass("input-error")}function n(e){var o=1==e;t("#template_status").val(o?"1":"0"),t("#template_status_switcher").toggleClass("bdt-active",o).attr("aria-checked",o),t(".bdt-switcher-status-text").text(o?"Active":"Inactive")}function r(){t.ajax({url:ajaxurl,method:"post",data:{action:"bdthemes_builder_dismiss_promo",nonce:window.ElementPackConfigBuilder.nonce}})}function d(e){var o=e.val();if(t(".bdt-ultimate-store-kit-promotion").remove(),["product|single","product|archive","product|cart","product|checkout","product|myaccount","product|thankyou","product|orders","product|shop","product|category","product|tag"].includes(o)){var a=o.split("|")[1];({single:"Single Product Page",archive:"Product Archive Page",cart:"Cart Page",checkout:"Checkout Page",myaccount:"My Account Page",thankyou:"Thank You Page",orders:"Orders Page",shop:"Shop Page",category:"Category Page",tag:"Tag Page"})[a]||(a.charAt(0).toUpperCase(),a.slice(1));window.ElementPackConfigBuilder.promoShown||(window.ElementPackConfigBuilder.promoShown=!0,t("body").append('
'),t("#bdt-popup-close, #bdt-ultimate-store-kit-popup").on("click",(function(e){e.target===this&&(t("#bdt-ultimate-store-kit-popup").remove(),r())})),t(document).on("keyup.ultimateStoreKitPopup",(function(e){27===e.keyCode&&(t("#bdt-ultimate-store-kit-popup").remove(),t(document).off("keyup.ultimateStoreKitPopup"),r())})))}}t(document).on("click","#bdthemes-templates-builder-modal .bdt-modal-close-button",(function(e){t("#bdthemes-templates-builder-modal").hide()})),t(document).on("click","body.post-type-bdt-template-builder a.page-title-action",(function(t){t.preventDefault(),o(),a("Create Template"),e()})),t(document).on("submit","#bdthemes-templates-builder-modal form",(function(e){e.preventDefault();var o=t(this).serialize();i(),t.ajax({url:ajaxurl,dataType:"json",method:"post",cache:!1,data:{action:"bdthemes_builder_create_template",data:o},success:function(t){window.location.href=t.data.redirect},error:function(e){422==e.status&&t.each(e.responseJSON.data.errors_arr,(function(e,o){t("#bdthemes-templates-builder-modal #"+e).addClass("input-error")}))}})})),t(document).on("click","body.post-type-bdt-template-builder .row-actions .bdt-edit-action a",(function(r){r.preventDefault(),i(),o(),a("Update Template");var d=t(this).parents(".column-title");t.ajax({url:ajaxurl,dataType:"json",method:"post",data:{action:"bdthemes_builder_get_edit_template",template_id:t(this).data("id"),nonce:window.ElementPackConfigBuilder.nonce},success:function(o){o.success&&(t("#bdthemes-templates-builder-modal form .template_id").val(o.data.id).change(),t("#bdthemes-templates-builder-modal form #template_name").val(o.data.name).change(),t("#bdthemes-templates-builder-modal form #template_type").val(o.data.type).change(),n(o.data.status),"themes|header"!==o.data.type&&"themes|footer"!==o.data.type||(t(".bdt-header-footer-option-container").show(),t(".bdt-template-modalinput-condition_a").val(o.data.condition_a).change(),t(".bdt-template-modalinput-condition_singular").val(o.data.condition_singular).change())),d.find(".hidden").attr("id").split("_")[1];var a=t(".bdt-template-modalinput-condition_singular_id");t.ajax({url:window.ElementPackConfigBuilder.resturl+"get-singular-list",dataType:"json",data:{ids:String(o.data.condition_singular_id)||""}}).then((function(e){null!==e&&e.results.length>0&&(a.html(" "),t.each(e.results,(function(t,e){var o=new Option(e.text,e.id,!0,!0);a.append(o).trigger("change")})))})),e()},error:function(t){}})})),t(document).ready((function(){t("#bdthemes-templates-builder-modal form #template_type").on("change",(function(){"themes|header"===t(this).val()||"themes|footer"===t(this).val()?t(".bdt-header-footer-option-container").show():t(".bdt-header-footer-option-container").hide(),d(t(this))})),t(".bdt-template-modalinput-condition_singular_id").select2({ajax:{url:window.ElementPackConfigBuilder.resturl+"get-singular-list",dataType:"json",data:function(t){return{s:t.term}}},cache:!0,placeholder:"--",dropdownParent:t(".bdt-template-modalinput-condition_singular-container")}),t(document).on("change",".bdt-template-modalinput-condition_a",(function(e){var o=t(this).val(),a=t(".bdt-template-modalinput-condition_singular-container");"singular"===o?a.show():a.hide()})),t(".bdt-template-modalinput-condition_singular").on("change",(function(){var e=t(this).val(),o=t(".bdt-template-modalinput-condition_singular_id-container");"selective"===e?o.show():o.hide()})),t("#template_status_switcher").on("click",(function(){n("1"==t("#template_status").val()?0:1)})).on("keydown",(function(e){" "!==e.key&&"Enter"!==e.key||(e.preventDefault(),t(this).click())}))}))}(jQuery);