芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/media.9/system/js/fields/joomla-field-fancy-select-es5.min.js
!function(){"use strict";function e(e,t){for(var c=0;c
element to work");if(this.choicesInstance)this.isDisconnected&&(this.choicesInstance.init(),this.isDisconnected=!1);else{if(this.isDisconnected=!1,this.select.multiple&&this.placeholder){var t=document.createElement("option");t.setAttribute("placeholder",""),t.textContent=this.placeholder,this.select.appendChild(t)}if(this.choicesInstance=new Choices(this.select,{placeholderValue:this.placeholder,searchPlaceholderValue:this.searchPlaceholder,removeItemButton:!0,searchFloor:this.minTermLength,searchResultLimit:parseInt(this.select.dataset.maxResults,10)||10,renderChoiceLimit:parseInt(this.select.dataset.maxRender,10)||-1,shouldSort:!1,fuseOptions:{threshold:.3},noResultsText:Joomla.Text._("JGLOBAL_SELECT_NO_RESULTS_MATCH","No results found"),noChoicesText:Joomla.Text._("JGLOBAL_SELECT_NO_RESULTS_MATCH","No results found"),itemSelectText:Joomla.Text._("JGLOBAL_SELECT_PRESS_TO_SELECT","Press to select"),classNames:{button:"choices__button_joomla"}}),this.allowCustom){var c=this.choicesInstance._highlightChoice;this.choicesInstance._highlightChoice=function(t){t&&c.call(e.choicesInstance,t)},this.addEventListener("mouseleave",(function(){e.choicesInstance.dropdown.isActive&&(Array.from(e.choicesInstance.dropdown.element.querySelectorAll("."+e.choicesInstance.config.classNames.highlightedState)).forEach((function(t){t.classList.remove(e.choicesInstance.config.classNames.highlightedState),t.setAttribute("aria-selected","false")})),e.choicesInstance._highlightPosition=0)})),this.addEventListener("keydown",(function(t){if(t.keyCode===e.keyCode.ENTER&&t.target===e.choicesInstance.input.element&&(t.preventDefault(),!e.choicesInstance._highlightPosition&&t.target.value&&!e.choicesInstance.dropdown.element.querySelector("."+e.choicesInstance.config.classNames.highlightedState))){var c=t.target.value.toLowerCase(),n=!1;if(e.choicesInstance.config.choices.some((function(e){return(e.value.toLowerCase()===c||e.label.toLowerCase()===c)&&(n=e.value,!0)})),!1===n&&Object.keys(e.choicesCache).some((function(t){return(t.toLowerCase()===c||e.choicesCache[t].toLowerCase()===c)&&(n=t,!0)})),!1!==n)return e.choicesInstance.setChoiceByValue(n),t.target.value=null,void e.choicesInstance.hideDropdown();e.choicesInstance.setChoices([{value:e.newItemPrefix+t.target.value,label:t.target.value,selected:!0,customProperties:{value:t.target.value}}],"value","label",!1),e.choicesCache[t.target.value]=t.target.value,t.target.value=null,e.choicesInstance.hideDropdown()}}))}if(this.remoteSearch&&this.url){this.choicesInstance.config.choices.forEach((function(t){e.choicesCache[t.value]=t.label}));var n=null;this.select.addEventListener("search",(function(){clearTimeout(n),n=setTimeout(e.requestLookup.bind(e),300)}))}}},l.disconnectedCallback=function(){this.choicesInstance&&(this.choicesInstance.destroy(),this.isDisconnected=!0),this.activeXHR&&(this.activeXHR.abort(),this.activeXHR=null)},l.requestLookup=function(){var e=this,t=this.url;t+=-1===t.indexOf("?")?"?":"&",t+=encodeURIComponent(this.termKey)+"="+encodeURIComponent(this.choicesInstance.input.value),this.activeXHR&&this.activeXHR.abort(),this.activeXHR=Joomla.request({url:t,onSuccess:function(t){e.activeXHR=null;var c=t?JSON.parse(t):[];if(c.length){for(var n,o=c.length-1;o>=0;o--)(n=c[o]).value=""+n.value,e.choicesCache[n.value]?c.splice(o,1):e.choicesCache[n.value]=n.text;c.length&&e.choicesInstance.setChoices(c,"value","text",!1)}},onError:function(){e.activeXHR=null}})},l.disableAllOptions=function(){var e=this.choicesInstance._store.choices;e.forEach((function(t,c){e[c].disabled=!0,e[c].selected=!1})),this.choicesInstance.clearStore(),this.choicesInstance.setChoices(e,"value","label",!0)},l.enableAllOptions=function(){var e=this.choicesInstance._store.choices,t=this.choicesInstance.getValue(!0);e.forEach((function(t,c){e[c].disabled=!1})),this.choicesInstance.clearStore(),this.choicesInstance.setChoices(e,"value","label",!0),this.value=t},l.disableByValue=function(e){var t=this.choicesInstance._store.choices,c=this.choicesInstance.getValue(!0);t.forEach((function(c,n){c.value===e&&(t[n].disabled=!0,t[n].selected=!1)}));var n=c.indexOf(e);n>-1&&c.slice(n,1),this.choicesInstance.clearStore(),this.choicesInstance.setChoices(t,"value","label",!0),this.value=c},l.enableByValue=function(e){var t=this.choicesInstance._store.choices,c=this.choicesInstance.getValue(!0);t.forEach((function(c,n){c.value===e&&(t[n].disabled=!1)})),this.choicesInstance.clearStore(),this.choicesInstance.setChoices(t,"value","label",!0),this.value=c},s=i,(r=[{key:"allowCustom",get:function(){return this.hasAttribute("allow-custom")}},{key:"remoteSearch",get:function(){return this.hasAttribute("remote-search")}},{key:"url",get:function(){return this.getAttribute("url")}},{key:"termKey",get:function(){return this.getAttribute("term-key")||"term"}},{key:"minTermLength",get:function(){return parseInt(this.getAttribute("min-term-length"),10)||1}},{key:"newItemPrefix",get:function(){return this.getAttribute("new-item-prefix")||""}},{key:"placeholder",get:function(){return this.getAttribute("placeholder")}},{key:"searchPlaceholder",get:function(){return this.getAttribute("search-placeholder")}},{key:"value",get:function(){return this.choicesInstance.getValue(!0)},set:function(e){this.choicesInstance.setChoiceByValue(e)}}])&&e(s.prototype,r),a&&e(s,a),i}(i(HTMLElement)))}();