Current File : /home/pacjaorg/www/kmm/media/com_languages/js/overrider.min.js |
/**
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/((r,e)=>{class o{constructor(){this.states={refreshing:!1,refreshed:!1,counter:0,searchString:"",searchType:"value"},this.spinner=e.getElementById("overrider-spinner"),this.spinnerBtn=e.getElementById("overrider-spinner-btn"),this.moreResults=e.getElementById("more-results"),this.moreResultsButton=e.getElementById("more-results-button"),this.resultsContainer=e.getElementById("results-container"),this.refreshStatus=e.getElementById("refresh-status")}refreshCache(){this.states.refreshing=!0,this.refreshStatus.classList.add("show"),r.request({url:"index.php?option=com_languages&task=strings.refresh&format=json",method:"POST",headers:{"Content-Type":"application/json"},onSuccess:t=>{t.error&&t.message&&alert(t.message),t.messages&&r.renderMessages(t.messages),this.refreshStatus.classList.remove("show"),this.states.refreshing=!1},onError:()=>{alert(r.Text._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),this.refreshStatus.classList.remove("show")}})}searchStrings(t){if(this.states.refreshing)return;const i=e.getElementById("jform_searchstring"),a=e.getElementById("jform_searchtype");if(t||(this.states.searchString=i.value,this.states.searchType=a.value||"value",[].slice.call(e.querySelectorAll(".language-results")).forEach(s=>{s.parentNode.removeChild(s)})),!this.states.searchString){i.classList.add("invalid");return}t?this.spinnerBtn.classList.add("show"):(this.moreResults.classList.remove("show"),[].slice.call(e.querySelectorAll("#results-container div.language-results")).forEach(s=>{s.parentNode.removeChild(s)}),this.resultsContainer.classList.add("show"),this.spinner.classList.add("show")),r.request({url:`index.php?option=com_languages&task=strings.search&format=json&searchstring=${this.states.searchString}&searchtype=${this.states.searchType}&more=${t}`,method:"POST",headers:{"Content-Type":"application/json"},onSuccess:n=>{const s=JSON.parse(n);s.error&&s.message&&alert(s.message),s.messages&&r.renderMessages(s.messages),s.data&&(s.data.results&&r.overrider.insertResults(s.data.results),s.data.more?(this.states.more=s.data.more,this.moreResultsButton.disabled=!1,this.moreResults.classList.add("show")):(this.moreResultsButton.disabled=!0,this.moreResults.classList.remove("show"))),this.spinnerBtn.classList.remove("show"),this.spinner.classList.remove("show")},onError:()=>{alert(r.Text._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),this.moreResultsButton.disabled=!0,this.moreResults.classList.remove("show"),this.resultsContainer.classList.remove("show")}})}insertResults(t){this.states.counter+=1;const i=e.createElement("div");if(i.setAttribute("id",`language-results${this.states.counter}`),i.classList.add("language-results"),i.classList.add("list-group"),i.classList.add("mb-2"),i.classList.add("show"),t.forEach((a,n)=>{const s=e.createElement("a");s.setAttribute("onclick",`Joomla.overrider.selectString(${this.states.counter}${n});`),s.setAttribute("href","#"),s.classList.add("list-group-item"),s.classList.add("list-group-item-action"),s.classList.add("flex-column"),s.classList.add("align-items-start");const l=e.createElement("div");l.setAttribute("id",`override_key${this.states.counter}${n}`),l.setAttribute("title",a.file),l.classList.add("result-key"),l.innerHTML=r.sanitizeHtml(a.constant);const h=e.createElement("div");h.setAttribute("id",`override_string${this.states.counter}${n}`),h.classList.add("result-string"),h.innerHTML=r.sanitizeHtml(a.string),s.appendChild(l),s.appendChild(h),i.appendChild(s)}),!t.length){const a=e.createElement("div");a.innerText=r.Text._("COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS"),i.appendChild(a)}this.moreResults&&this.moreResults.parentNode.insertBefore(i,this.moreResults)}selectString(t){e.getElementById("jform_key").value=e.getElementById(`override_key${t}`).innerHTML,e.getElementById("jform_override").value=e.getElementById(`override_string${t}`).innerHTML}}e.addEventListener("DOMContentLoaded",()=>{r.overrider=new o})})(Joomla,document);