Current File : /home/pacjaorg/wpt.pacja.org/km/media/plg_system_shortcut/js/shortcut.min.js |
((i,o)=>{if(!o)throw new Error("Joomla API is not properly initialised");o.addShortcut=(e,t)=>{hotkeys(e,"joomla",s=>{s.preventDefault(),s.stopPropagation(),s.stopImmediatePropagation(),t.call()})},o.addClickShortcut=(e,t)=>{o.addShortcut(e,()=>{const s=i.querySelector(t);s&&s.click()})},o.addFocusShortcut=(e,t)=>{o.addShortcut(e,()=>{const s=i.querySelector(t);s&&s.focus()})},o.addLinkShortcut=(e,t)=>{o.addShortcut(e,()=>{window.location.href=t})};const a=()=>{hotkeys.filter=e=>{const t=e.target||e.srcElement,{tagName:s}=t;return t.type==="checkbox"?!0:!(t.isContentEditable||s==="INPUT"||s==="SELECT"||s==="TEXTAREA")}},n=()=>{hotkeys("J",e=>{hotkeys.getScope()!=="joomla"&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),hotkeys.setScope("joomla"),setTimeout(()=>{hotkeys.setScope(!1)},o.getOptions("plg_system_shortcut.timeout",2e3)))})},l=()=>{const e=i.querySelector(".com_cpanel .container-main");if(e){const t=i.createElement("section");t.className="content pt-4",t.insertAdjacentHTML("beforeend",o.Text._("PLG_SYSTEM_SHORTCUT_OVERVIEW_HINT")),e.appendChild(t)}},h=e=>{const t=new Map;Object.values(e).forEach(r=>{if(!r.shortcut||!r.title)return;let c=[];t.has(r.shortcut)?(c=t.get(r.shortcut),c.push(r.title)):c=[r.title],t.set(r.shortcut,c)});let s="<dl>";t.forEach((r,c)=>{s+="<div>",s+='<dt class="d-inline-block"><kbd>J</kbd>',c.split("+").forEach(d=>{s+=` ${o.Text._("PLG_SYSTEM_SHORTCUT_THEN")} <kbd>${d.trim()}</kbd>`}),s+="</dt>",r.forEach(d=>{s+=`<dd class="d-inline-block ms-1">${d}</dd>`}),s+="</div>"}),s+="</dl>";const p=`
<div class="modal fade" id="shortcutOverviewModal" tabindex="-1" role="dialog" data-bs-backdrop="static" aria-labelledby="shortcutOverviewModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 id="shortcutOverviewModalLabel" class="modal-title">
${o.Text._("PLG_SYSTEM_SHORTCUT_OVERVIEW_TITLE")}
</h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="${o.Text._("JCLOSE")}"></button>
</div>
<div class="modal-body p-3">
<p>${o.Text._("PLG_SYSTEM_SHORTCUT_OVERVIEW_DESC")}</p>
<div class="mb-3">
${s}
</div>
</div>
</div>
</div>
</div>
`;i.body.insertAdjacentHTML("beforeend",p);const u=new bootstrap.Modal(i.getElementById("shortcutOverviewModal"),{keyboard:!0,backdrop:!0});hotkeys("X","joomla",()=>u.show())};i.addEventListener("DOMContentLoaded",()=>{const e=o.getOptions("plg_system_shortcut.shortcuts");Object.values(e).forEach(t=>{!t.shortcut||!t.selector||(t.selector.startsWith("/")||t.selector.startsWith("http://")||t.selector.startsWith("www.")?o.addLinkShortcut(t.shortcut,t.selector):t.selector.includes("input")?o.addFocusShortcut(t.shortcut,t.selector):o.addClickShortcut(t.shortcut,t.selector))}),i.querySelector("nav")&&(h(e),l()),a(),n()})})(document,Joomla);