1 line
3.8 KiB
JavaScript
1 line
3.8 KiB
JavaScript
|
function ezTocTabToggle(e,t,c="eztoc-tabcontent",i="eztoc-tablinks"){var s,n,o;for(e.preventDefault(),n=document.getElementsByClassName(c),s=0;s<n.length;s++)n[s].style.display="none";for(o=document.getElementsByClassName(i),s=0;s<o.length;s++)o[s].className=o[s].className.replace(" active","");document.getElementById(t).style.display="block",e.target.className+=" active"}function eztocIsEmail(e){return/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(e)}function update_sticky_width_field(e){let t=jQuery("#eztoc-sticky").find("input[name='ez-toc-settings[sticky-toggle-width-custom]']");"custom"==e?jQuery(t).parents("tr").show(500):jQuery(t).parents("tr").hide(500)}function update_sticky_height_field(e){let t=jQuery("#eztoc-sticky").find("input[name='ez-toc-settings[sticky-toggle-height-custom]']");"custom"==e?jQuery(t).parents("tr").show(500):jQuery(t).parents("tr").hide(500)}jQuery(document).ready((function(e){var t=window.location.href;t.indexOf("#technical-support")>-1?e("#eztoc-technical").click():t.indexOf("#freevspro-support")>-1?e("#eztoc-freevspro").click():t.indexOf("#welcome")>-1?e("#eztoc-welcome").click():e("#eztoc-default").click(),e(".eztoc-send-query").on("click",(function(t){t.preventDefault();var c=e("#eztoc_query_message").val(),i=e("#eztoc_query_email").val();e("#saswp_query_premium_cus").val();""!=e.trim(c)&&""!=e.trim(i)&&1==eztocIsEmail(i)?e.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{action:"eztoc_send_query_message",message:c,email:i,eztoc_security_nonce:eztoc_admin_data.eztoc_security_nonce},success:function(t){"t"==t.status?(e(".eztoc-query-success").show(),e(".eztoc-query-error").hide()):(e(".eztoc-query-success").hide(),e(".eztoc-query-error").show())},error:function(e){console.log(e)}}):""==e.trim(c)&&""==e.trim(i)?alert("Please enter the message, email and select customer type"):(""==e.trim(c)&&alert("Please enter the message"),""==e.trim(i)&&alert("Please enter the email"),0==eztocIsEmail(i)&&alert("Please enter a valid email"))})),e("#subscribe-newsletter-form").on("submit",(function(t){t.preventDefault();var c=e("#subscribe-newsletter-form"),i=c.find('input[name="name"]').val(),s=c.find('input[name="email"]').val(),n=c.find('input[name="company"]').val();e.post(ajaxurl,{action:"eztoc_subscribe_newsletter",name:i,email:s,website:n,eztoc_security_nonce:eztoc_admin_data.eztoc_security_nonce},(function(e){}))})),e(".eztoc-set-pos-btn").hide(),e("[name='ez-toc-settings[fixedtoc]']").on("click",(function(t){e(this).is(":checked")?(e(".eztoc-set-pos-btn").show(),console.log("checkbox checked")):(e(".eztoc-set-pos-btn").hide(),console.log("checkbox unchecked"))}));let c=e("#eztoc-sticky").find("input[name='ez-toc-settings[sticky-toggle]']"),i=e("#eztoc-sticky").find("select[name='ez-toc-settings[sticky-toggle-width]']"),s=e("#eztoc-sticky").find("input[name='ez-toc-settings[sticky-toggle-width-custom]']"),n=e("#eztoc-sticky").find("select[name='ez-toc-settings[sticky-toggle-height]']"),o=e("#eztoc-sticky").find("input[name='ez-toc-settings[sticky-toggle-height-custom]']");0==e(c).prop("checked")&&e("#eztoc-sticky").find("tr:not(:first-child)").hide(500),e(document).on("change","input[name='ez-toc-settings[sticky-toggle]']",(function(){1==e(c).prop("checked")?(e("#eztoc-sticky").find("tr:not(:first-child)").show(500),""!=e(i).val()&&"custom"==e(i).val()||e(s).parents("tr").hide(),""!=e(n).val()&&"custom"==e(n).val()||e(o).parents("tr").hide()):e("#eztoc-sticky").find("tr:not(:first-child)").hide(500)})),update_sticky_width_field(i.val()),update_sticky_height_field(n.val()),e(document).on("change","select[name='ez-toc-settings[sticky-toggle-width]']",(function(){update_sticky_width_field(e(this).val())})),e(document).on("change","select[name='ez-toc-settings[sticky-toggle-height]']",(function(){update_sticky_height_field(e(this).val())}))}));
|