Current File : /home/pacjaorg/.trash/media.1/com_associations/js/sidebyside.min.js
/**
 * @copyright   (C) 2017 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");const hideElements=t=>{t.forEach(e=>{const o=document.getElementById(e);o&&o.classList.add("hidden")})},createOption=(t,e)=>{const o=document.createElement("option");return o.value=t,o.innerText=e,o};document.body.addEventListener("click",({target:t})=>{if(t.id==="toggle-left-panel"){const e=t.getAttribute("data-hide-reference"),o=t.getAttribute("data-show-reference");t.innerText===e?t.innerText=o:t.innerText=e,document.getElementById("left-panel").classList.toggle("hidden"),document.getElementById("right-panel").classList.toggle("full-width")}}),document.body.addEventListener("change",({target:t})=>{if(t.id==="jform_itemlanguage"){const e=document.getElementById("target-association"),o=t.value;o!==""&&typeof o<"u"?(e.setAttribute("data-action",o.split(":")[2]),e.setAttribute("data-id",o.split(":")[1]),e.setAttribute("data-language",o.split(":")[0]),document.body.appendChild(document.createElement("joomla-core-loader")),e.src=`${e.getAttribute("data-editurl")}&task=${e.getAttribute("data-item")}.${e.getAttribute("data-action")}&id=${e.getAttribute("data-id")}`):(hideElements(["toolbar-target","toolbar-copy","select-change","remove-assoc"]),e.setAttribute("data-action",""),e.setAttribute("data-id","0"),e.setAttribute("data-language",""),e.src="")}}),document.getElementById("reference-association").addEventListener("load",({target:t})=>{let e=Joomla.getOptions("targetSrc",!1);if(e){e=e.split("&amp;").join("&"),document.getElementById("target-association").setAttribute("src",e),Joomla.loadOptions({targetSrc:!1});return}document.getElementById("target-association").setAttribute("src",document.getElementById("target-association").getAttribute("src"));const o=t.contentDocument.body||t.contentWindow.document.body;if(o.querySelector("#jform_id")&&o.querySelector("#jform_id").value!==t.getAttribute("data-id")){const c=document.getElementById("target-association");c.src=`${c.getAttribute("data-editurl")}&task=${c.getAttribute("data-item")}.edit&id=${o.querySelector("#jform_id").value}`,t.src=`${t.getAttribute("data-editurl")}&task=${t.getAttribute("data-item")}.edit&id=${t.getAttribute("data-id")}`}o.querySelector("#jform_language")&&o.querySelector("#jform_language").setAttribute("disabled","disabled");const n=o.querySelector("#associations .btn");n&&n.remove();const a=document.querySelectorAll("#jform_itemlanguage option");a&&a.forEach(c=>{const l=c.value.split(":");if(typeof l[0]<"u"){const u=l[0].replace(/-/,"_"),m=o.querySelector(`#jform_associations_${u}_id`);if(m&&m.value===""){const g=document.getElementById("reference-association");g.hasAttribute("data-no-assoc")&&(o.querySelector(`#jform_associations_${u}_name`).value=g.getAttribute("data-no-assoc"))}}});const i=document.querySelector("joomla-core-loader");i&&i.parentNode.removeChild(i)}),document.getElementById("target-association").addEventListener("load",({target:t})=>{if(t.getAttribute("src")!==""){document.getElementById("toolbar-target").classList.remove("hidden"),document.getElementById("toolbar-copy").classList.remove("hidden"),document.getElementById("select-change").classList.remove("hidden");const e=t.getAttribute("data-language"),o=t.getAttribute("data-id"),n=t.contentDocument.body||t.contentWindow.document.body,a=n.querySelector("#jform_id").value||"0",i=document.getElementById("reference-association"),c=n.querySelector("#associations");if(c&&c.classList.contains("active")&&(n.querySelector('a[href="#associations"]').parentNode.classList.remove("active"),c.classList.remove("active"),n.querySelector(".nav-tabs li").classList.add("active"),n.querySelector(".tab-content .tab-pane").classList.add("active")),n.querySelector("#jform_language")&&(n.querySelector("#jform_language").value=e,n.querySelector("#jform_language").setAttribute("disabled","disabled")),a==="0")document.getElementById("select-change-text").innerHTML=Joomla.sanitizeHtml(document.getElementById("select-change").getAttribute("data-select"));else{document.getElementById("select-change-text").innerHTML=Joomla.sanitizeHtml(document.getElementById("select-change").getAttribute("data-change")),document.getElementById("remove-assoc").classList.remove("hidden"),document.getElementById("remove-assoc").classList.add("toolbar-copy");const b=document.getElementById("target-id").value,s=b===""?a:`${b},${a}`;if(document.getElementById("target-id").value=s,a!==o){const S=document.querySelector(`#jform_itemlanguage option[value^="${e}:${o}:add"]`);S&&(S.value=`${e}:${a}:edit`),t.setAttribute("data-id",a),t.setAttribute("data-action","edit")}const d=i.contentDocument.body||i.contentWindow.document.body,_=e.replace(/-/,"_"),f=n.querySelector(`#jform_${i.getAttribute("data-title")}`).value,p=d.querySelector(`#jform_associations_${_}_id`);p&&(p.value=a);const A=d.querySelector(`#jform_associations_${_}_name`);A&&(A.value=f);const E=d.querySelector(`#jform_associations_${_}`);E&&(E.appendChild(createOption(a,f)),E.value=a)}const l=i.getAttribute("data-id"),u=i.getAttribute("data-language").replace(/-/,"_"),m=i.getAttribute("data-title-value"),g=n.querySelector(`#jform_associations_${u}_id`);g&&(g.value=l);const v=n.querySelector(`#jform_associations_${u}_name`);v&&(v.value=m);let r=n.querySelector(`#jform_associations_${u}`);r&&(r.appendChild(createOption(l,m)),r.value=l),document.querySelectorAll("#jform_itemlanguage option").forEach(b=>{const s=b.value.split(":");if(typeof s[1]<"u"&&s[1]!=="0"){const d=s[0].replace(/-/,"_");n.querySelector(`#jform_associations_${d}_id`)&&(n.querySelector(`#jform_associations_${d}_id`).value=s[1]),r=n.querySelector(`#jform_associations_${d}`),r&&(r.appendChild(createOption(s[1],"")),r.value=s[1])}});const y=document.querySelector("joomla-core-loader");y&&y.parentNode.removeChild(y)}}),Joomla.submitbutton=t=>{if(t==="association.cancel")Joomla.submitform(t);else if(t==="copy"){document.body.appendChild(document.createElement("joomla-core-loader"));const e=document.getElementById("target-association").getAttribute("data-language"),o=window.frames["reference-association"].document.getElementById("jform_language");o.removeAttribute("disabled"),o.value=e,window.frames["reference-association"].Joomla.submitbutton(`${document.getElementById("adminForm").getAttribute("data-associatedview")}.save2copy`)}else if(t==="undo-association"){const e=document.getElementById("reference-association"),o=document.getElementById("target-association"),n=e.getAttribute("data-language").replace(/-/,"_"),a=o.getAttribute("data-language").replace(/-/,"_"),i=e.contentDocument.body||e.contentWindow.document.body,c=o.contentDocument.body||o.contentWindow.document.body,l=i.querySelector(`#jform_associations_${a}_id`);l&&(l.value="");const u=i.querySelector(`#jform_associations_${a}_name`);u&&(u.value="");const m=i.querySelector(`#jform_associations_${a}`);m&&(m.value=""),document.querySelectorAll("#jform_itemlanguage option").forEach(_=>{let f=_.value.split(":")[0];if(f){f=f.replace(/-/,"_");const p=c.querySelector(`#jform_associations_${f}_id`);p&&(p.value="");const A=c.querySelector(`#jform_associations_${f}`);A&&(A.value="")}});const g=c.querySelector(`#jform_associations_${n}_id`);g&&(g.value="");const v=c.querySelector(`#jform_associations_${n}_name`);v&&(v.value="");const r=c.querySelector(`#jform_associations_${n}`);r&&(r.value="");const y=document.getElementById("jform_itemlanguage"),b=y.value,s=a.replace(/_/,"-"),d=document.querySelector(`#jform_itemlanguage option[value="${b}"]`);d&&(d.value=`${s}:0:add`),y.value="",y.dispatchEvent(new CustomEvent("change",{bubbles:!0,cancelable:!0})),Joomla.submitbutton("reference")}else{const e=document.getElementById(`${t}-association`),n=(e.contentDocument.body||e.contentWindow.document.body).querySelector("#jform_language");n&&n.removeAttribute("disabled"),window.frames[`${t}-association`].Joomla.submitbutton(`${document.getElementById("adminForm").getAttribute("data-associatedview")}.apply`)}return!1},hideElements(["toolbar-target","toolbar-copy"]);
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!