PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.0.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.0.0
2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
thinkrank / assets / seo-quick-edit.js

seo-quick-edit.js in ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO 2.0.0, at assets/seo-quick-edit.js

1 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 !function(){"use strict";const e=window.thinkrankSeoQuickEdit;if(!e)return;const t=e.i18n||{};let n=null;function i(e,t,n){const i=document.createElement(e);return t&&(i.className=t),null!=n&&""!==n&&(i.textContent=n),i}function o(t,n){const i=new window.FormData;return i.append("action",t),i.append("nonce",e.nonce),Object.keys(n).forEach(function(e){i.append(e,n[e])}),window.fetch(e.ajaxUrl,{method:"POST",credentials:"same-origin",body:i}).then(function(e){return e.json()})}function a(){n&&(document.removeEventListener("keydown",r),n.overlay.remove(),n.trigger&&document.body.contains(n.trigger)&&n.trigger.focus(),n=null)}function r(e){"Escape"===e.key&&a()}function d(e){const t=i("div","thinkrank-qe-field"),n=i("div","thinkrank-qe-field-top"),o=i("label","thinkrank-qe-label",e.label);let a;return o.setAttribute("for",e.id),n.appendChild(o),e.textarea?(a=document.createElement("textarea"),a.rows=3):(a=document.createElement("input"),a.type="text"),a.id=e.id,a.className="thinkrank-qe-input",a.value=e.value||"",e.placeholder&&(a.placeholder=e.placeholder),e.maxLength&&(a.maxLength=e.maxLength),e.counterMax&&n.appendChild(function(e,t){const n=i("span","thinkrank-qe-counter");function o(){const i=e.value.length;n.textContent=i+"/"+t,n.classList.toggle("is-over",i>t)}return e.addEventListener("input",o),o(),n}(a,e.counterMax)),t.appendChild(n),t.appendChild(a),(e.helpers||[]).forEach(function(e){e&&t.appendChild(i("p","thinkrank-qe-help",e))}),{wrap:t,control:a}}function l(n,r){const l=n.els.body,s=n.els.footer;l.textContent="",s.textContent="",r.post_title&&!n.els.heading.querySelector(".thinkrank-qe-post-title")&&n.els.heading.appendChild(i("p","thinkrank-qe-post-title",r.post_title));const c=d({id:"thinkrank-qe-seo-title",label:t.seoTitle,value:r.seo_title,placeholder:r.effective_title,maxLength:80,counterMax:e.titleMax,helpers:[t.seoTitleHelp,""===r.seo_title?t.inheritedHint:""]}),p=d({id:"thinkrank-qe-meta-description",label:t.metaDescription,value:r.meta_description,placeholder:r.effective_description,textarea:!0,maxLength:320,counterMax:e.descriptionMax,helpers:[t.metaDescriptionHelp,""===r.meta_description?t.inheritedHint:""]}),h=d({id:"thinkrank-qe-focus-keywords",label:t.focusKeywords,value:(r.focus_keywords||[]).join(", "),helpers:[(u=t.focusKeywordsHelp,k=r.keyword_limit,String(u).replace("%d",k))]});var u,k;l.appendChild(c.wrap),l.appendChild(p.wrap),l.appendChild(h.wrap);const f=i("p","thinkrank-qe-error");if(f.hidden=!0,l.appendChild(f),r.edit_link){const e=i("a","thinkrank-qe-edit-link",t.editFull);e.href=r.edit_link,s.appendChild(e)}const v=i("div","thinkrank-qe-actions"),m=i("button","thinkrank-qe-btn thinkrank-qe-btn-ghost",t.cancel);m.type="button",m.addEventListener("click",a);const g=i("button","thinkrank-qe-btn thinkrank-qe-btn-primary",t.save);g.type="button",g.addEventListener("click",function(){g.disabled=!0,g.textContent=t.saving,f.hidden=!0,o(e.actionSave,{post_id:n.postId,seo_title:c.control.value,meta_description:p.control.value,focus_keywords:h.control.value}).then(function(e){if(!e||!e.success)throw new Error(e&&e.data&&e.data.message||"");e.data.column_html&&n.cell&&(n.cell.innerHTML=e.data.column_html),a()}).catch(function(e){g.disabled=!1,g.textContent=t.save,f.textContent=e&&e.message||t.saveError,f.hidden=!1})}),v.appendChild(m),v.appendChild(g),s.appendChild(v),c.control.focus(),c.control.setSelectionRange(c.control.value.length,c.control.value.length)}document.addEventListener("click",function(d){const s=d.target.closest(".thinkrank-qe-trigger");s&&(d.preventDefault(),function(d){n&&a();const s=d.getAttribute("data-post-id"),c=d.closest(".column-thinkrank_seo_overview"),p=function(){const e=i("div","thinkrank-qe-overlay"),n=i("div","thinkrank-qe-modal");n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("aria-label",t.modalTitle);const o=i("div","thinkrank-qe-header"),r=i("div","thinkrank-qe-heading");r.appendChild(i("h2","thinkrank-qe-title",t.modalTitle));const d=i("button","thinkrank-qe-close");d.type="button",d.setAttribute("aria-label",t.close),d.innerHTML='<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M1 1l12 12M13 1L1 13" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>',d.addEventListener("click",a),o.appendChild(r),o.appendChild(d);const l=i("div","thinkrank-qe-body"),s=i("div","thinkrank-qe-footer");return n.appendChild(o),n.appendChild(l),n.appendChild(s),e.appendChild(n),e.addEventListener("mousedown",function(t){t.target===e&&a()}),{overlay:e,modal:n,body:l,footer:s,heading:r}}();n={postId:s,cell:c,trigger:d,overlay:p.overlay,els:p},document.body.appendChild(p.overlay),document.addEventListener("keydown",r),void 0===d.dataset.effectiveTitle?(p.body.appendChild(i("div","thinkrank-qe-loading")),o(e.actionGet,{post_id:s}).then(function(e){if(n&&n.postId===s){if(!e||!e.success)throw new Error(e&&e.data&&e.data.message||"");l(n,e.data)}}).catch(function(e){if(!n||n.postId!==s)return;n.els.body.textContent="";const o=i("p","thinkrank-qe-error",e&&e.message||t.loadError);n.els.body.appendChild(o)})):l(n,function(t,n){const i=t.dataset;let o=(i.focusKeywords||"").split(",").map(function(e){return e.trim()}).filter(Boolean);const a=n&&n.querySelector(".thinkrank-focus-keyword-display");if(a&&void 0!==a.dataset.keyword){const e=a.dataset.keyword.trim(),t=o.slice(1);o=e?[e].concat(t):t}return{post_title:i.postTitle||"",seo_title:i.seoTitle||"",meta_description:i.metaDescription||"",effective_title:i.effectiveTitle||"",effective_description:i.effectiveDescription||"",focus_keywords:o,keyword_limit:parseInt(e.keywordLimit,10)||5,edit_link:i.editLink||""}}(d,c))}(s))})}();