[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/fields/ -> joomla-field-fancy-select-es5.min.js (source)

   1  !function(){"use strict";function e(e,t){for(var c=0;c<t.length;c++){var n=t[c];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(e){return(t=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function o(e,t,i){return(o=n()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var i=new(Function.bind.apply(e,o));return n&&c(i,n.prototype),i}).apply(null,arguments)}function i(e){var n="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||(i=e,-1===Function.toString.call(i).indexOf("[native code]")))return e;var i;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,s)}function s(){return o(e,arguments,t(this).constructor)}return s.prototype=Object.create(e.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),c(s,e)})(e)}window.customElements.define("joomla-field-fancy-select",function(t){var n,o;function i(){var e;if((e=t.call(this)||this).keyCode={ENTER:13},!Joomla)throw new Error("Joomla API is not properly initiated");if(!window.Choices)throw new Error("JoomlaFieldFancySelect requires Choices.js to work");return e.choicesCache={},e.activeXHR=null,e.choicesInstance=null,e.isDisconnected=!1,e}o=t,(n=i).prototype=Object.create(o.prototype),n.prototype.constructor=n,c(n,o);var s,r,a,l=i.prototype;return l.connectedCallback=function(){var e=this;if(window.Choices||"complete"===document.readyState)this.doConnect();else{window.addEventListener("load",(function t(){e.doConnect(),window.removeEventListener("load",t)}))}},l.doConnect=function(){var e=this;if(this.select=this.querySelector("select"),!this.select)throw new Error("JoomlaFieldFancySelect requires <select> 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),Object.defineProperty(s,"prototype",{writable:!1}),i}(i(HTMLElement)))}();


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer