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