navasena/wp-content/plugins/mailchimp-for-wp/assets/js/admin.js

1 line
35 KiB
JavaScript
Raw Permalink Normal View History

2024-07-31 13:12:38 +07:00
(()=>{var e={5359:()=>{const e=document.getElementById("mailchimp_api_key");e&&e.addEventListener("change",(function(){const t=document.createElement("p");t.className="mc4wp-red",t.innerText=window.mc4wp_vars.i18n.invalid_api_key,e.nextElementSibling.innerText===t.innerText&&e.nextElementSibling.parentElement.removeChild(e.nextElementSibling),e.value.match(/^[0-9a-zA-Z*]{32}-[a-z]{2}[0-9]{1,2}$/)||e.parentElement.insertBefore(t,e.nextElementSibling)}))},2458:(e,t,n)=>{const{mailchimp:r,i18n:o,ajaxurl:i,nonce:l}=window.mc4wp_vars,a=n(4862),s={working:!1,done:!1,success:!1};function c(e){e&&e.preventDefault(),s.working=!0,s.done=!1,a.request({method:"POST",url:`${i}?action=mc4wp_renew_mailchimp_lists&_wpnonce=${l}`,timeout:6e5}).then((function(e){s.success=!0,e&&window.setTimeout((function(){window.location.reload()}),3e3)})).catch((function(){s.success=!1})).finally((function(){s.working=!1,s.done=!0,a.redraw()}))}const u=document.getElementById("mc4wp-list-fetcher");u&&(r.api_connected&&0===r.lists.length&&c(),a.mount(u,{view:function(){return a("form",{method:"POST",onsubmit:c.bind(this)},[a("p",[a("input",{type:"submit",value:s.working?o.fetching_mailchimp_lists:o.renew_mailchimp_lists,className:"button",disabled:!!s.working}),a.trust(" &nbsp; "),s.working?[a("span.mc4wp-loader","Loading..."),a.trust(" &nbsp; ")]:"",s.done?[s.success?a("em.mc4wp-green",o.fetching_mailchimp_lists_done):a("em.mc4wp-red",o.fetching_mailchimp_lists_error)]:""])])}}))},5602:()=>{const e=window.mc4wp_vars.ajaxurl,t=document.getElementById("mc4wp-mailchimp-lists-overview");t&&t.addEventListener("click",(t=>{t.target.matches(".mc4wp-mailchimp-list")&&function(t){t.preventDefault();const n=t.target,r=n.parentElement.parentElement.nextElementSibling,o=n.getAttribute("data-list-id"),i=r.querySelector("div");if("none"===r.style.display){const t=new XMLHttpRequest;t.open("GET",e+"?action=mc4wp_get_list_details&format=html&ids="+o,!0),t.onload=function(){this.status>=400||(i.innerHTML=this.responseText)},t.send(null),r.style.display=""}else r.style.display="none"}(t)}))},7785:(e,t,n)=>{const r=document.getElementById("mc4wp-admin").querySelectorAll(".mc4wp-list-input"),o=window.mc4wp_vars.mailchimp.lists;let i=[];const l=new(n(9885));function a(){i=[];for(let e=0;e<r.length;e++){const t=r[e];("boolean"!=typeof t.checked||t.checked)&&"object"==typeof o[t.value]&&i.push(o[t.value])}return function(){const e=document.querySelectorAll(".lists--only-selected > *");for(let t=0;t<e.length;t++){const n=e[t].getAttribute("data-list-id"),r=i.filter((e=>e.id===n)).length>0;e[t].style.display=r?"":"none"}}(),l.emit("selectedLists.change",[i]),i}const s=document.getElementById("mc4wp-lists");s&&s.addEventListener("change",a),a(),e.exports={getSelectedLists:function(){return i},on:l.on.bind(l)}},1485:()=>{function e(e,t,n,r){if("radio"===n.type&&!n.checked)return;const o="checkbox"===n.type?n.checked:n.value,i=String(o)===String(r);t?(e.style.display=i?"":"none",e.style.visibility=i?"":"hidden"):(e.style.opacity=i?"":"0.4",e.style.pointerEvents=i?"":"none"),[].forEach.call(e.querySelectorAll("input,select,textarea:not([readonly])"),(function(e){e.readOnly=!i}))}[].forEach.call(document.querySelectorAll("[data-showif]"),(function(t){const n=JSON.parse(t.getAttribute("data-showif")),r=document.querySelectorAll('[name="'+n.element+'"]'),o=void 0===n.hide||n.hide;for(let i=0;i<r.length;i++)r[i].addEventListener("change",e.bind(null,t,o,r[i],n.value)),e(t,o,r[i],n.value)}))},4688:e=>{const t=document.getElementById("mc4wp-admin"),n=t.querySelectorAll(".mc4wp-tab"),r=t.querySelectorAll(".nav-tab"),o=t.querySelector('input[name="_wp_http_referer"]'),i=[].map.call(n,(e=>{const n=e.id.split("-").pop();return{id:n,title:e.querySelector("h2:first-of-type").textContent,element:e,nav:t.querySelectorAll(".nav-tab-"+n),open:u.bind(null,n)}}));function l(e){for(let t=0;t<i.length;t++)if(i[t].id===e)return i[t];throw new Error("get() called with invalid tab id: "+e)}function a(e){e.className=e.className.replace("nav-tab-active","")}function s(e){e.className+=" nav-tab-active",e.