From dd932e17942a2e2d078c43db8a453d78e9e346fe Mon Sep 17 00:00:00 2001 From: samiahmedsiddiqui Date: Wed, 5 Aug 2020 00:14:49 +0500 Subject: [PATCH] Fix JS error --- frontend/js/script-form.js | 2 +- frontend/js/script-form.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/js/script-form.js b/frontend/js/script-form.js index 72eca0d..3c51092 100644 --- a/frontend/js/script-form.js +++ b/frontend/js/script-form.js @@ -52,7 +52,7 @@ function updateMetaBox() { } isSaving = editPost.isSavingMetaBoxes(); - if (!isSaving || isSaving !== lastIsSaving) { + if (isSaving !== lastIsSaving && !isSaving) { var postId = wp.data.select("core/editor").getEditedPostAttribute("id"); var xhttp = new XMLHttpRequest(); diff --git a/frontend/js/script-form.min.js b/frontend/js/script-form.min.js index dee7f4e..49dfdde 100644 --- a/frontend/js/script-form.min.js +++ b/frontend/js/script-form.min.js @@ -1 +1 @@ -var getHomeURL=document.getElementById("custom_permalinks_home_url"),getPermalink=document.getElementById("custom_permalink"),editPost="",isSaving="",lastIsSaving=!1;function focusPermalinkField(){"use strict";var e=document.getElementById("custom-permalinks-post-slug");e&&(e.style.color="#000")}function blurPermalinkField(){"use strict";var e=document.getElementById("custom-permalinks-post-slug"),t=document.getElementById("original-permalink");e&&(getPermalink.value=e.value,""!==e.value&&e.value!==t.value||(e.value=t.value,e.style.color="#ddd"))}function updateMetaBox(){"use strict";if(editPost){var e=document.getElementsByClassName("edit-post-post-link__preview-label");if(e&&e[0]&&e[0].parentNode.classList.add("cp-permalink-hidden"),!(isSaving=editPost.isSavingMetaBoxes())||isSaving!==lastIsSaving){var t=wp.data.select("core/editor").getEditedPostAttribute("id"),a=new XMLHttpRequest;lastIsSaving=isSaving,a.onreadystatechange=function(){if(4===a.readyState&&200===a.status){var e,t=JSON.parse(a.responseText),n=document.getElementById("custom-permalinks-add");getPermalink.value=t.custom_permalink,""===t.custom_permalink&&(t.custom_permalink=t.original_permalink),e=t.preview_permalink?getHomeURL.value+t.preview_permalink:getHomeURL.value+t.custom_permalink,document.getElementById("custom-permalinks-post-slug").value=t.custom_permalink,document.getElementById("original-permalink").value=t.original_permalink,document.querySelector("#view-post-btn a")&&(document.querySelector("#view-post-btn a").href=e),document.querySelector("a.editor-post-preview")&&(document.querySelector("a.editor-post-preview").href=e),n&&"add"===n.value&&(document.getElementById("custom-permalinks-edit-box").style.display=""),document.querySelector(".components-notice__content a")&&(document.querySelector(".components-notice__content a").href="/"+t.custom_permalink)}},a.open("GET",getHomeURL.value+"/wp-json/custom-permalinks/v1/get-permalink/"+t,!0),a.setRequestHeader("Cache-Control","private, max-age=0, no-cache"),a.send()}lastIsSaving=isSaving}}function hideDefaultPermalink(){"use strict";var e=document.getElementsByClassName("edit-post-post-link__preview-label");e&&e[0]&&e[0].parentNode.classList.add("cp-permalink-hidden")}function permalinkContentLoaded(){"use strict";var e=document.getElementsByClassName("edit-post-post-link__preview-label"),t=document.getElementById("custom-permalinks-edit-box"),n=document.getElementById("custom-permalinks-post-slug");if(n&&(n.addEventListener("focus",focusPermalinkField),n.addEventListener("blur",blurPermalinkField)),""===document.querySelector("#custom-permalinks-edit-box .inside").innerHTML.trim()&&(t.style.display="none"),wp.data){var a=document.getElementById("custom-permalinks-add"),i=document.querySelectorAll(".edit-post-sidebar .components-panel__header"),s=0,o=i.length;if(a&&"add"===a.value&&(t.style.display="none"),editPost=wp.data.select("core/edit-post"),wp.data.subscribe(updateMetaBox),e&&e[0]&&e[0].parentNode.classList.add("cp-permalink-hidden"),t.classList.contains("closed")&&t.classList.remove("closed"),i&&0