Files
2026-04-28 15:13:50 +02:00

1 line
5.5 KiB
JavaScript

jQuery(document).ready(function(r){"use strict";function i(){r(".cmplz-panel.cmplz-remove-after-change").fadeTo(500,0).slideUp(500,function(){r(this).remove()})}function e(){r(".multiple-field").each(function(){var e=!0,t=(r(this).find("input[type=text]").each(function(){""===r(this).val()&&(e=!1)}),r(this).find("textarea").each(function(){""===r(this).val()&&(e=!1)}),r(this).closest(".cmplz-panel").find(".cmplz-multiple-field-validation i"));e?(t.removeClass("fa-times"),t.addClass("fa-check")):(t.addClass("fa-times"),t.removeClass("fa-check"))})}function t(){r(".cmplz-validate-multicheckbox").each(function(e){var t=[],i=!0,n=(r(this).find(":checkbox").each(function(e){t.push(r(this)),r(this).is(":checked")&&(i=!1)}),r(this).closest(".field-group").find(".cmplz-label"));i?(n.removeClass("valid-multicheckbox"),n.addClass("invalid-multicheckbox"),r.each(t,function(e,t){t.prop("required",!0),t.addClass("is-required")})):(n.removeClass("invalid-multicheckbox"),n.addClass("valid-multicheckbox"),r.each(t,function(e,t){t.prop("required",!1),t.removeClass("is-required")}))}),n()}function n(){var d,l=!0;r(".condition-check-1").each(function(e){for(var t=1;t<4;t++){var i="cmplz_"+r(this).data("condition-question-"+t);if("cmplz_undefined"==i)return;var n=r(this).data("condition-answer-"+t),c=r(this).find("input[type=checkbox]"),a=((c=(c=(c=c.length?c:r(this).find("input")).length?c:r(this).find("textarea")).length?c:r(this).find("select")).length&&c[0].hasAttribute("required")&&c.addClass("is-required"),l=-1===(n+="").indexOf("NOT ")||(n=n.replace("NOT ",""),!1),[]),a=-1!==n.indexOf(" OR ")?n.split(" OR "):[n],o=r(this),s=!1;if(a.forEach(function(e){d=function(e){{var t;return"text"==r('input[name="'+e+'"]').attr("type")?r('input[name^="'+e+'"]').val():(t=[],r('input[name="'+e+'"]:checked').each(function(){t[t.length]=r(this).val()}),t)}}(i),r('select[name="'+i+'"]').length&&(d=Array(r('select[name="'+i+'"]').val())),r('input[name="'+i+"["+e+']"]').length&&(d=(s=!!r('input[name="'+i+"["+e+']"]').is(":checked"),[])),l?s||-1!=d.indexOf(e)||d==e?(o.removeClass("cmplz-hidden"),c.hasClass("is-required")&&c.prop("required",!0),s=!0):(o.addClass("cmplz-hidden"),c.hasClass("is-required")&&c.prop("required",!1)):s||-1!=d.indexOf(e)||d==e?(o.addClass("cmplz-hidden"),c.hasClass("is-required")&&c.prop("required",!1)):(o.removeClass("cmplz-hidden"),c.hasClass("is-required")&&c.prop("required",!0),s=!0)}),!s)break}})}r(document).on("click",".cmplz-copy-shortcode",function(){var t,e,i=r(this).closest(".shortcode-container").find(".cmplz-shortcode").attr("id"),i=document.getElementById(i),n=window.getSelection(),c=(n.removeAllRanges(),document.createRange());c.selectNodeContents(i),n.addRange(c);try{t=document.execCommand("copy")}catch(e){t=!1}t&&((e=r(this).find(".cmplz-tooltip-icon")).addClass("copied"),setTimeout(function(){e.removeClass("copied")},1e3))}),r(".cmplz-trick a").hover(function(){r(this).find(".cmplz-bullet").css("background-color","#009fff"),r(this).find(".cmplz-trick a, .cmplz-tips-tricks-content").css("color","#009fff")},function(){r(this).find(".cmplz-bullet").css("background-color",""),r(this).find(".cmplz-trick a, .cmplz-tips-tricks-content").css("color","")}),window.setTimeout(function(){r(".cmplz-hide").fadeTo(500,0).slideUp(500,function(){r(this).remove()})},2e3),e(),r(document).on("keyup",".multiple-field input[type=text]",function(){e()}),r(document).on("keyup",".multiple-field textarea",function(){e()}),t(),r(":checkbox").change(t),r(document).on("change","input",function(e){n(),i()}),r(document).on("keyup","input",function(e){i()}),r(document).on("change","select",function(e){n(),i()}),r(document).on("change","textarea",function(e){n(),i()}),r(document).on("keyup","textarea",function(e){i()}),r(document).on("click","button",function(e){i()}),2==r("input[name=step]").val()&&setTimeout(function(){if("undefined"!=typeof tinymce)for(var e=0;e<tinymce.editors.length;e++)tinymce.editors[e].on("NodeChange keyup",function(e,t){i()})},5e3),r(document).on("cmplzRenderConditions",n),r(".cmplz-select2").length&&(r(".cmplz-select2").select2({tags:!0,width:"400px"}),r(".cmplz-select2-no-additions").select2({width:"400px"})),r(document).on("change",".cmplz-document-input",function(){r(".cmplz-document-field").length&&r(".cmplz-document-field").each(function(){var e=r(this).data("fieldname"),e=r("input[name="+e+"]:checked").val(),t=r(this).find(".cmplz-document-custom-url"),i=r(this).find(".cmplz-document-custom-page");"custom"===e?(i.show(),i.prop("required",!0)):(i.hide(),i.prop("required",!1)),"url"===e?(t.show(),t.prop("required",!0)):(t.hide(),t.prop("required",!1))})}),r(document).on("click","#cmplz-tcf-create_pages",function(){var t=r("#cmplz-tcf-create_pages"),i=(t.attr("disabled","disabled"),t.html()),n=(t.html('<div class="cmplz-loader "><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>'),{});r(".cmplz-create-page-title").each(function(){var e=n.hasOwnProperty(r(this).data("region"))?n[r(this).data("region")]:{};e[r(this).attr("name")]=r(this).val(),n[r(this).data("region")]=e}),r.ajax({type:"POST",url:complianz_tc_admin.admin_url,dataType:"json",data:{pages:JSON.stringify(n),action:"cmplz_tc_create_pages",nonce:complianz_tc_admin.nonce},success:function(e){e.success?(r(".cmplz-create-page-title").each(function(){r(this).removeClass("cmplz-deleted-page").addClass("cmplz-valid-page"),r(this).parent().find(".cmplz-icon").replaceWith(e.icon)}),t.text(e.new_button_text),t.removeAttr("disabled")):t.html(i)}})})});