芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/media.2/system/js/fields/joomla-field-simple-color-es5.min.js
!function(){"use strict";function e(e,t){for(var n=0;n
'+r+""),e.buttons.push(i)}));var t=document.createElement("button");t.setAttribute("class","btn-close"),t.setAttribute("type","button"),t.innerHTML=Joomla.sanitizeHtml(this.textClose),this.buttons.push(t);var n=this.select.value,o="";"none"===n&&(o+=" nocolor",n="transparent"),this.icon=document.createElement("button"),o&&this.icon.setAttribute("class",o);var i="simple-color-"+Math.random().toString(36).substr(2,10);this.icon.setAttribute("type","button"),this.icon.setAttribute("tabindex","0"),this.icon.style.backgroundColor=n,this.icon.innerHTML=Joomla.sanitizeHtml('
'+this.textSelect+"
"),this.icon.id=i,this.select.insertAdjacentElement("beforebegin",this.icon),this.icon.addEventListener("click",this.show.bind(this)),this.panel=document.createElement("div"),this.panel.classList.add("simplecolors-panel"),this.panel.setAttribute("aria-labelledby",i),this.hide=this.hide.bind(this),this.colorSelect=this.colorSelect.bind(this),this.buttons.forEach((function(t){t.classList.contains("btn-close")?t.addEventListener("click",e.hide):t.addEventListener("click",e.colorSelect),e.panel.insertAdjacentElement("beforeend",t)})),this.appendChild(this.panel),this.focusableElements=[].slice.call(this.panel.querySelectorAll(this.focusableSelectors.join())),this.keys=this.keys.bind(this),this.hide=this.hide.bind(this),this.mousedown=this.mousedown.bind(this)},u.show=function(){document.addEventListener("mousedown",this.hide),this.addEventListener("keydown",this.keys),this.panel.addEventListener("mousedown",this.mousedown),this.panel.setAttribute("data-open","");var e=this.panel.querySelector("button");e&&e.focus()},u.hide=function(){document.removeEventListener("mousedown",this.hide,!1),this.removeEventListener("keydown",this.keys),this.panel.hasAttribute("data-open")&&this.panel.removeAttribute("data-open"),this.icon.focus()},u.colorSelect=function(e){var t="",n="",o="";e.target.classList.contains("nocolor")?(t="none",n="transparent",o="nocolor"):(t=this.rgb2hex(e.target.style.backgroundColor),n=t),this.buttons.forEach((function(e){e.classList.contains("active")&&e.classList.remove("active")})),e.target.classList.add("active"),this.icon.classList.remove("nocolor"),this.icon.setAttribute("class",o),this.icon.style.backgroundColor=n,this.select.dispatchEvent(new Event("change")),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0})),this.hide(),this.options.forEach((function(e){e.selected&&e.removeAttribute("selected"),e.value===n&&e.setAttribute("selected","")}))},u.keys=function(e){if(e.keyCode===i&&this.hide(),e.keyCode===o){var t=this.focusableElements.indexOf(document.activeElement);!e.shiftKey||0!==t&&-1!==t||(this.focusableElements[this.focusableElements.length-1].focus(),e.preventDefault()),e.shiftKey||t!==this.focusableElements.length-1||(this.focusableElements[0].focus(),e.preventDefault())}},u.mousedown=function(e){e.stopPropagation(),e.preventDefault()},u.getColorName=function(e){var t=e;if(4===e.length){var n=e.split("");t=n[0]+n[1]+n[1]+n[2]+n[2]+n[3]+n[3]}for(var o in a)if(a.hasOwnProperty(o)&&t.toLowerCase()===a[o])return o;return this.textColor+" "+e.replace("#","").split("").join(", ")},u.rgb2hex=function(e){var t=function(e){return("0"+parseInt(e,10).toString(16)).slice(-2)},n=e.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return"#"+t(n[1])+t(n[2])+t(n[3])},f=l,d=[{key:"observedAttributes",get:function(){return["text-select","text-color","text-close","text-transparent"]}}],(c=[{key:"textSelect",get:function(){return this.getAttribute("text-select")}},{key:"textColor",get:function(){return this.getAttribute("text-color")}},{key:"textClose",get:function(){return this.getAttribute("text-close")}},{key:"textTransp",get:function(){return this.getAttribute("text-transparent")}}])&&e(f.prototype,c),d&&e(f,d),l}(r(HTMLElement));t.define("joomla-field-simple-color",s)}(customElements)}();