Current File : /home/pacjaorg/wpt.pacja.org/km/media/plg_installer_webinstaller/js/client-es5.min.js |
(function(){"use strict";/**
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/if(!Joomla)throw new Error("Joomla API is not properly initialised");var L={button:["type"],input:["type","name","placeholder","inputmode"],select:["name"],option:["value","selected"]},e={view:"dashboard",id:0,ordering:"",version:"current",list:0,options:Joomla.getOptions("plg_installer_webinstaller",{})},u,y=function(){function o(){}var i=o.prototype;return i.initialise=function(){var t=this;e.loaded=1;var n=document.getElementById("uploadform-web-cancel");n.addEventListener("click",function(){document.getElementById("uploadform-web").classList.add("hidden"),e.list&&document.querySelector(".list-view")&&document.querySelector(".list-view").click()});var a=document.getElementById("uploadform-web-install");a.addEventListener("click",function(){e.options.installFrom===4?t.submitButtonUrl():t.submitButtonWeb()}),this.loadweb(e.options.base_url+"index.php?format=json&option=com_apps&view=dashboard"),this.clickforlinks()},i.loadweb=function(t){var n=this;if(!t)return!1;var a=new RegExp(e.options.base_url),c=/^index\.php/;if(!(a.test(t)||c.test(t)))return window.open(t,"_blank"),!1;var E=t+"&product="+e.options.product+"&release="+e.options.release+"&dev_level="+e.options.dev_level+"&list="+(e.list?"list":"grid")+"&lang="+e.options.language,h=document.getElementById("com-apps-ordering"),w=document.getElementById("com-apps-filter-joomla-version");return e.ordering!==""&&h&&h.value&&(e.ordering=h.value,E+="&ordering="+e.ordering),e.version!==""&&w&&w.value&&(e.version=w.value,E+="&filter_version="+e.version),o.showLoadingLayer(),new Promise(function(f,m){Joomla.request({url:E,onSuccess:function(l){var s;try{s=JSON.parse(l)}catch{throw new Error("Failed to parse JSON")}document.getElementById("web-loader")&&document.getElementById("web-loader").classList.add("hidden");var p=document.getElementById("jed-container");p.innerHTML=Joomla.sanitizeHtml(s.data.html,L),document.getElementById("com-apps-searchbox").addEventListener("keypress",function(d){var I=d.which;I===13&&n.initiateSearch()}),document.getElementById("search-extensions").addEventListener("click",function(){n.initiateSearch()}),document.getElementById("search-reset").addEventListener("click",function(){var d=document.getElementById("com-apps-searchbox");d.value="",n.initiateSearch(),document.getElementById("search-reset").setAttribute("disabled","disabled")}),document.getElementById("com-apps-searchbox").value===""&&document.getElementById("search-reset").setAttribute("disabled","disabled"),document.getElementById("search-reset").innerHTML=Joomla.sanitizeHtml(Joomla.Text._("JSEARCH_FILTER_CLEAR"));var b=document.getElementById("com-apps-ordering"),g=document.getElementById("com-apps-filter-joomla-version");b&&b.addEventListener("change",function(){var d=b.selectedIndex;e.ordering=b.options[d].value,n.installfromwebajaxsubmit()}),g&&g.addEventListener("change",function(){var d=g.selectedIndex;e.version=g.options[d].value,n.installfromwebajaxsubmit()}),e.options.installfrom_url!==""&&o.installfromweb(e.options.installfrom_url),f()},onError:function(l){var s=document.getElementById("web-loader-error"),p=document.getElementById("web-loader");l.responseText&&s&&(s.innerHTML=Joomla.sanitizeHtml(l.responseText)),p&&(p.classList.add("hidden"),s.classList.remove("hidden")),Joomla.renderMessages({danger:[Joomla.Text._("PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING_ERROR")]},"#web-loader-error"),m()}})}).finally(function(){var f=document.getElementById("joomlaapsinstallatinput");if(f&&(f.value=e.options.installat_url),n.clickforlinks(),o.clicker(),e.view!=="extension"&&[].slice.call(document.querySelectorAll("div.load-extension")).forEach(function(l){l.addEventListener("click",function(s){s.preventDefault(),n.processLinkClick(l.getAttribute("data-url"))}),l.setAttribute("href","#")}),e.view==="extension"){var m=document.getElementById("install-extension"),v=document.getElementById("install-extension-from-external");m&&m.addEventListener("click",function(){o.installfromweb(m.getAttribute("data-downloadurl"),m.getAttribute("data-name")),document.getElementById("uploadform-web-install").scrollIntoView({behavior:"smooth",block:"start"})}),v&&v.addEventListener("click",function(){var l=v.getAttribute("data-downloadurl"),s=window.confirm(Joomla.Text._("PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL").replace("[SITEURL]",l));s===!0&&(document.getElementById("adminForm").setAttribute("action",l),document.querySelector("input[name=task]").setAttribute("disabled",!0),document.querySelector("input[name=install_directory]").setAttribute("disabled",!0),document.querySelector("input[name=install_url]").setAttribute("disabled",!0),document.querySelector("input[name=installtype]").setAttribute("disabled",!0),document.querySelector("input[name=filter_search]").setAttribute("disabled",!0),document.getElementById("adminForm").submit())})}e.list&&document.querySelector(".list-view")&&document.querySelector(".list-view").click(),o.hideLoadingLayer()}),!0},i.clickforlinks=function(){var t=this;[].slice.call(document.querySelectorAll("a.transcode")).forEach(function(n){var a=n.getAttribute("href");n.addEventListener("click",function(c){c.preventDefault(),t.processLinkClick(a)}),n.setAttribute("href","#")})},i.initiateSearch=function(){document.getElementById("search-reset").removeAttribute("disabled"),e.view="dashboard",this.installfromwebajaxsubmit()},i.installfromwebajaxsubmit=function(){var t="&view="+e.view;if(e.id&&(t+="&id="+e.id),document.getElementById("com-apps-searchbox").value){var n=encodeURI(document.getElementById("com-apps-searchbox").value.toLowerCase().replace(/ +/g,"_").replace(/[^a-z0-9-_]/g,"").trim());t+="&filter_search="+n}var a=document.getElementById("com-apps-ordering"),c=document.getElementById("com-apps-filter-joomla-version");e.ordering!==""&&a&&a.value&&(e.ordering=a.value),e.ordering&&(t+="&ordering="+e.ordering),e.version!==""&&c&&c.value&&(e.version=c.value),e.version&&(t+="&filter_version="+e.version),this.loadweb(e.options.base_url+"index.php?format=json&option=com_apps"+t)},i.processLinkClick=function(t){var n=new RegExp(e.options.base_url),a=/^index\.php/;n.test(t)||a.test(t)?(e.view=t.replace(/^.+[&?]view=(\w+).*$/,"$1"),e.view==="dashboard"?e.id=0:e.view==="category"&&(e.id=t.replace(/^.+[&?]id=(\d+).*$/,"$1")),this.loadweb(e.options.base_url+t)):this.loadweb(t)},o.showLoadingLayer=function(){document.getElementById("web").appendChild(document.createElement("joomla-core-loader"))},o.hideLoadingLayer=function(){var t=document.querySelector("#web joomla-core-loader");t.parentNode.removeChild(t)},o.clicker=function(){document.querySelector(".grid-view")&&document.querySelector(".grid-view").addEventListener("click",function(){e.list=0,document.querySelector(".list-container").classList.add("hidden"),document.querySelector(".grid-container").classList.remove("hidden"),document.getElementById("btn-list-view").classList.remove("active"),document.getElementById("btn-grid-view").classList.remove("active")}),document.querySelector(".list-view")&&document.querySelector(".list-view").addEventListener("click",function(){e.list=1,document.querySelector(".grid-container").classList.add("hidden"),document.querySelector(".list-container").classList.remove("hidden"),document.getElementById("btn-grid-view").classList.remove("active"),document.getElementById("btn-list-view").classList.add("active")})},o.installfromweb=function(t,n){return n===void 0&&(n=null),t?(document.getElementById("install_url").value=t,document.getElementById("uploadform-web-url").innerText=t,n?(document.getElementById("uploadform-web-name").innerText=n,document.getElementById("uploadform-web-name-label").classList.remove("hidden")):document.getElementById("uploadform-web-name-label").classList.add("hidden"),document.getElementById("uploadform-web").classList.remove("hidden"),!0):(Joomla.renderMessages({warning:[Joomla.Text._("PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN")]}),!1)},i.submitButtonUrl=function(){var t=document.getElementById("adminForm");if(t.install_url.value===""||t.install_url.value==="http://"||t.install_url.value==="https://")Joomla.renderMessages({warning:[Joomla.Text._("COM_INSTALLER_MSG_INSTALL_ENTER_A_URL")]});else{var n=document.getElementById("loading");n&&n.classList.remove("hidden"),t.installtype.value="url",t.submit()}},i.submitButtonWeb=function(){var t=document.getElementById("adminForm");t.install_url.value!==""||t.install_url.value!=="http://"||t.install_url.value!=="https://"?this.submitButtonUrl():t.install_url.value===""?Joomla.renderMessages({warning:[Joomla.apps.options.btntxt]}):(document.querySelector("#appsloading").classList.remove("hidden"),t.installtype.value="web",t.submit())},o}();customElements.whenDefined("joomla-tab").then(function(){var o=document.getElementById("myTab"),i=o.querySelector("button[aria-controls=web]");i&&(e.options.installfromon&&i.click(),i.hasAttribute("aria-expanded")&&i.getAttribute("aria-expanded")==="true"&&!u&&(u=new y,u.initialise()),e.options.installfrom_url!==""&&i.click(),i.addEventListener("joomla.tab.shown",function(){u||(u=new y,u.initialise())}))})})();