D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
hrfiudwx
/
enterpriseuplift.com
/
wp-content
/
plugins
/
themify-updater
/
js
/
Filename :
themify-upgrader.js
back
Copy
var ThemifyUpdater;(($,e,t)=>{"use strict";(ThemifyUpdater={showAlert(){$(".themify_updater_alert").addClass("busy").fadeIn(800)},hideAlert(e){e="error"===e?"error":"done",$(".themify_updater_alert").removeClass("busy").addClass(e).delay(800).fadeOut(800,(function(){$(this).removeClass(e)}))},events(){$("#themify-updater-search .clear-search").on("click",(function(){$(this).prev().val(""),$(t).trigger("themify_update_promo")})),$("#themify-updater-search .promo-search").on("input",(function(){var e=$(this),t=e.val().toLowerCase(),i=e.siblings(".clear-search");""!=t&&$(".theme-list li").length>0&&$(".theme-list li").each((function(){var e=$(this);1==e.is(":visible")&&e.find(".theme-title h3").text().toLowerCase().indexOf(t)>-1?e.show():e.hide().parent().append(e)})),""==t?i.click().hide():i.show()})),ThemifyUpdater.updateThemeBtn(),$("#wpbody").on("click","a.themify-updater",(function(e){if(e.preventDefault(),$(this).hasClass("themify-updater-stop"))$(this).closest(".notifications").after('<div id="themifyUpdateRrror" class="notice notice-error is-dismissible">'+themify_upgrader_license.error_message+"</div>");else if(confirm(themify_upgrader.check_backup)){var t=$(this),i=t.closest(".notifications"),a=t.data("update_type"),r={slug:t.data("plugin"),action:a.substring(0,a.length-1),_ajax_nonce:t.data("nonce"),t:"",username:"",password:"",connection_type:"",public_key:"",private_key:""};"update-plugins"===a&&(r.plugin=t.data("base")),$.ajax({url:ajaxurl,type:"POST",data:r,beforeSend(){ThemifyUpdater.showAlert()},success(e){(e="string"==typeof e?JSON.parse(e):e).success?(ThemifyUpdater.hideAlert(),setTimeout((()=>{location.reload()}),1500)):(ThemifyUpdater.hideAlert("error"),i.siblings("#themifyUpdateRrror").length>0&&i.siblings("#themifyUpdateRrror").remove(),i.after('<div id="themifyUpdateRrror" class="notice notice-error is-dismissible">'+e.data.errorMessage+"</div>"))},error(){ThemifyUpdater.hideAlert("error")}})}})),$(".themify_updater_changelogs").on("click",(function(e){e.preventDefault();var t=$(this).data("changelog");$(".themify-updater-promt-box .show-error").hide(),$(".themify_updater_alert").addClass("busy").fadeIn(300),$(".themify_updater_promt_overlay,.themify-updater-promt-box").fadeIn(300),$('<iframe src="'+t+'" />').on("load",(()=>{$(".themify_updater_alert").removeClass("busy").fadeOut(300)})).prependTo(".themify-updater-promt-box"),$(".themify-updater-promt-box").addClass("show-changelog"),$(".themify_updater_promt_overlay").one("click",(function(e){$(this).fadeOut(300),$(".themify-updater-promt-box").fadeOut(300).find("iframe").remove()}))})),$(".notifications .notification-group span:first-child").on("click",(function(e){e.preventDefault(),$(this).siblings().slideToggle()})),$(t).on("themify_updater_init_batch",(()=>{t.getElementsByClassName("themify-updater-batch-wrap").length>0&&ThemifyUpdater.initBatchInstaller()}))},initBatchInstaller(){const e=t.querySelector(".themify-updater-batch-install"),i=e.querySelector(".themify-updater-batch-install .batch-install-enable");e.style.display="block",i.addEventListener("change",(()=>{t.body.classList.toggle("themify-updater-batch-mode")})),e.querySelector(".themify-updater-batch-install-btn").addEventListener("click",(function(){const e=t.querySelectorAll(".themify-updater-batch-checkbox:checked"),i=e.length;if(0===i)return void alert("Please select at least on item to install.");let a={};for(let t=i-1;t>-1;t--){let i=this.dataset.update+"?action="+e[t].dataset.action+"-"+this.dataset.type+"&"+this.dataset.type+"="+e[t].dataset.slug+"&_wpnonce="+e[t].dataset.nonce;if("upgrade"===e[t].dataset.action){let a=e[t].parentNode.nextElementSibling;const r=a&&a.value?a.value:"";i+="&themify_theme_downgrade=1",a.selectedOptions[0].hasAttribute("data-latest")||(i+="&version="+r),""!==r&&(e[t].dataset.title=e[t].dataset.title+" "+r)}a[e[t].dataset.title]=i}ThemifyUpdater.bulkInstall(a,ThemifyUpdater.initModal())}));const a=t.querySelector(".batch-install-all input"),r=t.querySelectorAll(".theme-post:not([style^=display]) .themify-updater-batch-checkbox"),h=function(){this.closest(".themify-updater-batch-wrap").classList.toggle("batch-checked")};for(let e=r.length-1;e>-1;e--)r[e].addEventListener("change",h);a.addEventListener("change",(function(){const e=this.checked,i=t.querySelectorAll(".theme-post:not([style^=display]) .themify-updater-batch-checkbox");for(let t=i.length-1;t>-1;t--){i[t].checked=e;const a=i[t].closest(".themify-updater-batch-wrap").classList;e?a.add("batch-checked"):a.remove("batch-checked")}const a=t.querySelector(".plugin-category .active");a&&(e?a.dataset.checked=e:a.dataset.checked&&delete a.dataset.checked)}))},bulkInstall(e,i){const a=Object.keys(e),r=t.createElement("li"),h=t.createElement("span");r.appendChild(t.createTextNode(themify_upgrader.installing)),h.className="themify-updater-batch-name",h.innerText=a[0]+" ",r.appendChild(h),r.className="themify-updater-batch-installing",i.appendChild(r),fetch(e[a[0]],{headers:new Headers({"X-Requested-With":"XMLHttpRequest"})}).then((e=>e.text())).then((o=>{const n=(new DOMParser).parseFromString(o,"text/html").querySelector(".wrap a[href*=activate]");if(r.innerHTML="",r.appendChild(h),!i.dataset.activate&&n){const e=t.createElement("a");e.href=n.href,e.className="themify-updater-batch-activate",e.innerText=themify_upgrader.activate_lnk,r.appendChild(e)}else r.appendChild(t.createTextNode(themify_upgrader.installed));if(r.classList.remove("themify-updater-batch-installing"),r.classList.add("themify-updater-batch-installed"),delete e[a[0]],a.length>1)ThemifyUpdater.bulkInstall(e,i);else{i.parentNode.querySelector(".themify-updater-modal-loading").remove();const e=i.nextElementSibling;if(i.dataset.activate&&n){const i=t.createElement("a");i.className="themify-updater-modal-activate themify-updater-button",i.href=n.href,i.innerText=themify_upgrader.activate,e.appendChild(i)}const a=t.createElement("div");a.className="themify-updater-modal-done themify-updater-button",a.setAttribute("onclick","location.reload()"),a.innerText=themify_upgrader.done,e.appendChild(a)}})).catch((e=>{console.warn("Update error.",e)}))},initModal(e){t.getElementById("wpbody-content").style.pointerEvents="none",t.body.style.overflow="hidden";const i=t.createElement("div");i.className="themify-updater-modal tf_scrollbar";const a=t.createElement("ul");a.className="themify-updater-bulk-list tf_scrollbar",!0===e&&(a.dataset.activate=!0),i.appendChild(a);const r=t.createElement("div");r.className="themify-updater-modal-loading",i.appendChild(r);const h=t.createElement("div");return h.className="themify-updater-modal-btns",i.appendChild(h),t.body.appendChild(i),i.addEventListener("click",(e=>{const i=e.target;if("A"===i.tagName&&i.classList.contains("themify-updater-batch-activate")){if(e.preventDefault(),e.stopPropagation(),i.dataset.loading)return;ThemifyUpdater.showAlert(),fetch(i.href,{headers:new Headers({"X-Requested-With":"XMLHttpRequest"})}).then((e=>e.text())).then((e=>{ThemifyUpdater.hideAlert(),delete i.dataset.loading,i.parentNode.replaceChild(t.createTextNode(themify_upgrader.activated),i)})).catch((e=>{ThemifyUpdater.hideAlert("error"),delete i.dataset.loading}))}})),a},updateThemeBtn(){$(".upgrade-theme-button").on("click",(function(i){i.preventDefault(),i.stopPropagation();const a=this,r=t.getElementById("themeversiontoreinstall");if(!a.dataset.loading){var h=JSON.parse(atob($(i.target).data("install"))),o=r.value,n=h.url+"?",c=o?parseInt((""+o[0]).trim()):null;if(null!==c&&c<7&&"undefined"!=typeof themify_vars){if((themify_vars.theme_v?parseInt((""+themify_vars.theme_v[0]).trim()):0)>=7&&!confirm(themify_upgrader.v7_message))return}for(var d in delete h.url,h)n+=d+"="+h[d]+"&";n+="themify-theme=1",0!==r.selectedIndex&&(n+="&version="+o),ThemifyUpdater.showAlert(),fetch(n,{headers:new Headers({"X-Requested-With":"XMLHttpRequest"})}).then((e=>e.text())).then((t=>{ThemifyUpdater.hideAlert(),delete a.dataset.loading,e.location.reload()})).catch((e=>{ThemifyUpdater.hideAlert("error"),delete a.dataset.loading}))}}))}}).events()})(jQuery,window,document);