/* # ----------------------------------------------------------------------------- # ~/assets/themes/j1/modules/dropdowns/js/dropdowns.min.js # MODIFIED DROPDOWN JS from project Materialize # Provides JS Core funtions for the J1 DROPDOWNS Module # # Product/Info: # https://jekyll.one # https://github.com/Dogfalo/materialize # # Copyright (C) 2023, 2024 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/j1-template/blob/main/LICENSE.md # ----------------------------------------------------------------------------- # TODO: # jadams, 2020-10-11: module needs to be rewitten to PURE jQuery # ----------------------------------------------------------------------------- */ "use strict";!function(e,t){var i={direction:"top",hoverEnabled:!0,toolbarEnabled:!1};e.fn.reverse=[].reverse;class o{constructor(e,t,i){t instanceof Element||console.error(Error(t+" is not an HTML Element"));var o=e.getInstance(t);o&&o.destroy(),this.el=t,this.$el=cash(t)}static init(e,t,i){var o=null;if(t instanceof Element)o=new e(t,i);else if(t&&(t.jquery||t.cash||t instanceof NodeList)){for(var n=[],s=0;s{this.close()},0):!i.closest(".dropdowns").length&&i.closest(".dropdown-content").length||setTimeout(()=>{this.close()},0),this.isTouchMoving=!1}_handleTriggerKeydown(e){e.which!==this.keys.ARROW_DOWN&&e.which!==this.keys.ENTER||this.isOpen||(e.preventDefault(),this.open())}_handleDocumentTouchmove(t){e(t.target).closest(".dropdown-content").length&&(this.isTouchMoving=!0)}_handleDropdownClick(e){if("false"!==this.options.onItemClick){this.executeFunctionByName(this.options.onItemClick,window,this)}}_handleDropdownKeydown(t){if(t.which===this.keys.TAB)t.preventDefault(),this.close();else if(t.which!==this.keys.ARROW_DOWN&&t.which!==this.keys.ARROW_UP||!this.isOpen)if(t.which===this.keys.ENTER&&this.isOpen){let t=this.dropdownEl.children[this.focusedIndex],i=e(t).find("a, button").first();i.length?i[0].click():t&&t.click()}else t.which===this.keys.ESC&&this.isOpen&&(t.preventDefault(),this.close());else{t.preventDefault();let e=t.which===this.keys.ARROW_DOWN?1:-1,i=this.focusedIndex,o=!1;do{if(i+=e,this.dropdownEl.children[i]&&-1!==this.dropdownEl.children[i].tabIndex){o=!0;break}}while(i=0);o&&(this.focusedIndex=i,this._focusFocusedItem())}let i=String.fromCharCode(t.which).toLowerCase();if(i&&-1===[9,13,27,38,40].indexOf(t.which)){this.filterQuery.push(i);let t=this.filterQuery.join(""),o=e(this.dropdownEl).find("li").filter(i=>0===e(i).text().toLowerCase().indexOf(t))[0];o&&(this.focusedIndex=e(o).index(),this._focusFocusedItem())}this.filterTimeout=setTimeout(this._resetFilterQueryBound,1e3)}_resetFilterQuery(){this.filterQuery=[]}_resetDropdownStyles(){this.$dropdownEl.css({display:"",width:"",height:"",left:"",top:"","transform-origin":"",transform:"",opacity:""})}_makeDropdownFocusable(){this.dropdownEl.tabIndex=0,e(this.dropdownEl).children().each(function(e){e.getAttribute("tabindex")||e.setAttribute("tabindex",0)})}_focusFocusedItem(){this.focusedIndex>=0&&this.focusedIndexr.spaceOnBottom?(l="bottom",i+=r.spaceOnTop,s-=r.spaceOnTop):i+=r.spaceOnBottom)),!r[a]){let e="left"===a?"right":"left";r[e]?a=e:r.spaceOnLeft>r.spaceOnRight?(a="right",o+=r.spaceOnLeft,n-=r.spaceOnLeft):(a="left",o+=r.spaceOnRight)}return"bottom"===l&&(s=s-t.height+(this.options.coverTrigger?e.height:0)),"right"===a&&(n=n-t.width+e.width),{x:n,y:s,verticalAlignment:l,horizontalAlignment:a,height:i,width:o}}_animateIn(){t.remove(this.dropdownEl),t({targets:this.dropdownEl,opacity:{value:[0,1],easing:"easeOutQuad"},scaleX:[.3,1],scaleY:[.3,1],duration:this.options.inDuration,easing:"easeOutQuint",complete:e=>{this.options.autoFocus&&this.dropdownEl.focus(),"function"==typeof this.options.onOpenEnd&&this.options.onOpenEnd.call(this,this.el)}})}_animateOut(){t.remove(this.dropdownEl),t({targets:this.dropdownEl,opacity:{value:0,easing:"easeOutQuint"},scaleX:.3,scaleY:.3,duration:this.options.outDuration,easing:"easeOutQuint",complete:e=>{this._resetDropdownStyles(),"function"==typeof this.options.onCloseEnd&&this.options.onCloseEnd.call(this,this.el)}})}_placeDropdown(){let e=this.options.constrainWidth?this.el.getBoundingClientRect().width:this.dropdownEl.getBoundingClientRect().width;this.dropdownEl.style.width=e+"px";let t=this._getDropdownPosition();this.dropdownEl.style.left=t.x+"px",this.dropdownEl.style.top=t.y+"px",this.dropdownEl.style.height=t.height+"px",this.dropdownEl.style.width=t.width+"px",this.dropdownEl.style.transformOrigin=`${"left"===t.horizontalAlignment?"0":"100%"} ${"top"===t.verticalAlignment?"0":"100%"}`}open(){if(!this.isOpen){this.isOpen=!0;for(var e="#"+(o=this).id+" li",t=document.querySelectorAll(e),i=0;i