芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/beyondbrightenterprise.com/media/system/js/fields/joomla-field-user.min.js
((t,e)=>{class i extends HTMLElement{constructor(){super(),this.onUserSelect="",this.onchangeStr="",this.buttonClick=this.buttonClick.bind(this),this.iframeLoad=this.iframeLoad.bind(this),this.modalClose=this.modalClose.bind(this),this.setValue=this.setValue.bind(this)}static get observedAttributes(){return["url","modal","modal-width","modal-height","input","input-name","button-select"]}get url(){return this.getAttribute("url")}set url(t){this.setAttribute("url",t)}get modalClass(){return this.getAttribute("modal")}set modalClass(t){this.setAttribute("modal",t)}get modalWidth(){return this.getAttribute("modal-width")}set modalWidth(t){this.setAttribute("modal-width",t)}get modalHeight(){return this.getAttribute("modal-height")}set modalHeight(t){this.setAttribute("modal-height",t)}get inputId(){return this.getAttribute("input")}set inputId(t){this.setAttribute("input",t)}get inputNameClass(){return this.getAttribute("input-name")}set inputNameClass(t){this.setAttribute("input-name",t)}get buttonSelectClass(){return this.getAttribute("button-select")}set buttonSelectClass(t){this.setAttribute("button-select",t)}connectedCallback(){this.modal=this.querySelector(this.modalClass),this.modalBody=this.querySelector(".modal-body"),this.input=this.querySelector(this.inputId),this.inputName=this.querySelector(this.inputNameClass),this.buttonSelect=this.querySelector(this.buttonSelectClass),this.modal&&window.bootstrap&&window.bootstrap.Modal&&!window.bootstrap.Modal.getInstance(this.modal)&&e.initialiseModal(this.modal,{isJoomla:!0}),this.buttonSelect&&(this.buttonSelect.addEventListener("click",this.modalOpen.bind(this)),this.modal.addEventListener("hide",this.removeIframe.bind(this)),this.onchangeStr=this.input.getAttribute("data-onchange"),this.onchangeStr&&(this.onUserSelect=new Function(this.onchangeStr),this.input.addEventListener("change",this.onUserSelect)))}disconnectedCallback(){this.onchangeStr&&this.input&&this.input.removeEventListener("change",this.onUserSelect),this.buttonSelect&&this.buttonSelect.removeEventListener("click",this),this.modal&&this.modal.removeEventListener("hide",this)}buttonClick({target:t}){this.setValue(t.getAttribute("data-user-value"),t.getAttribute("data-user-name")),this.modalClose()}iframeLoad(){const t=this.iframeEl.contentWindow.document;[].slice.call(t.querySelectorAll(".button-select")).forEach((t=>{t.addEventListener("click",this.buttonClick)}))}modalOpen(){this.removeIframe();const t=document.createElement("iframe");t.setAttribute("name","field-user-modal"),t.src=this.url.replace("{field-user-id}",this.input.getAttribute("id")),t.setAttribute("width",this.modalWidth),t.setAttribute("height",this.modalHeight),this.modalBody.appendChild(t),this.modal.open(),this.iframeEl=this.modalBody.querySelector("iframe"),this.iframeEl.addEventListener("load",this.iframeLoad)}modalClose(){e.Modal.getCurrent().close(),this.modalBody.innerHTML=""}removeIframe(){this.modalBody.innerHTML=""}setValue(t,e){this.input.setAttribute("value",t),this.inputName.setAttribute("value",e||t),this.input.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("change",{detail:{value:t,name:e},bubbles:!0}))}}t.define("joomla-field-user",i)})(customElements,Joomla);