CoreFiles by mySites.guru
joomla-toolbar-button.min.js4 lines, 2,229 bytes, from Joomla_6.2.0-alpha3-Alpha-Full_Package.zip
Raw History Compare with 6.2.0-alpha2
md5
7ee8dfaf1809a203963bd949124a1735
sha1
fb9bcf83ab4d20d2b9d5a8b463430f4a29ad1b57
sha256
9b348e7629683232430305ace6fadec5888d959a6e7ccf307e9c10b634adc3b3
/**
 * @copyright  (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */window.customElements.define("joomla-toolbar-button",class extends HTMLElement{get task(){return this.getAttribute("task")}get listSelection(){return this.hasAttribute("list-selection")}get form(){return this.getAttribute("form")}get formValidation(){return this.hasAttribute("form-validation")}get confirmMessage(){return this.getAttribute("confirm-message")}constructor(){if(super(),!Joomla)throw new Error("Joomla API is not properly initiated");this.confirmationReceived=!1,this.onChange=this.onChange.bind(this),this.executeTask=this.executeTask.bind(this)}connectedCallback(){this.buttonElement=this.querySelector("button, a"),this.buttonElement.addEventListener("click",this.executeTask);const t=this.form||"adminForm";if(this.formElement=document.getElementById(t),this.disabled=!1,this.listSelection&&this.setDisabled(!0),this.listSelection){if(!this.formElement)throw new Error(`The form "${t}" is required to perform the task, but the form was not found on the page.`);this.formElement.boxchecked.addEventListener("change",this.onChange)}}disconnectedCallback(){this.formElement.boxchecked&&this.formElement.boxchecked.removeEventListener("change",this.onChange),this.buttonElement.removeEventListener("click",this.executeTask)}onChange({target:t}){this.setDisabled(t.value<1)}setDisabled(t){this.disabled=!!t,this.buttonElement&&(this.disabled?(this.buttonElement.nodeName==="BUTTON"&&this.buttonElement.setAttribute("aria-disabled","true"),this.buttonElement.classList.add("disabled")):this.buttonElement.nodeName==="BUTTON"?(this.buttonElement.removeAttribute("aria-disabled"),this.buttonElement.classList.remove("disabled")):this.buttonElement.classList.remove("disabled"))}executeTask(){return this.disabled?!1:this.confirmMessage&&!this.confirmationReceived?(import("joomla.dialog").then(t=>t.default.confirm(this.confirmMessage,Joomla.Text._("WARNING","Warning"))).then(t=>{t&&(this.confirmationReceived=!0,this.buttonElement.click())}),!1):(this.confirmationReceived=!1,this.task&&Joomla.submitbutton(this.task,this.form,this.formValidation),!0)}});

The same content is in 2 releases, Joomla 6.2.0-alpha3 to 6.2.0-beta1. See them all, or every version of this file.