1 |
2
|
Manuela
|
!function(e){"undefined"!=typeof module&&"object"==typeof exports?"undefined"!=typeof window?module.exports=e():module.exports=e:window.Dropdown=e()}(function(e){var t=function(e){this.menu="object"==typeof e?e:document.querySelector(e),this.init()};t.prototype={init:function(){this.actions(),this.menu.setAttribute("tabindex","0"),document.addEventListener("click",this.handle,!1)},actions:function(){var e=this;this.handle=function(t){for(var n=t.target||t.currentTarget,o=[],i=e.menu.parentNode.getElementsByTagName("*"),s=0,r=i.length||0;r>s;s++)r&&o.push(i[s]);if(n===e.menu||n.parentNode===e.menu)e.toggle(t);else{if(o&&o.indexOf(n)>-1)return;e.close()}/\#$/g.test(n.href)&&t.preventDefault()},this.toggle=function(e){/open/.test(this.menu.parentNode.className)?(this.close(),document.removeEventListener("keydown",this.key,!1)):(this.menu.parentNode.className+=" open",this.menu.setAttribute("aria-expanded",!0),document.addEventListener("keydown",this.key,!1))},this.key=function(t){27==t.which&&e.close()},this.close=function(){e.menu.parentNode.className=e.menu.parentNode.className.replace(" open",""),e.menu.setAttribute("aria-expanded",!1)}}};var n=document.querySelectorAll("[data-toggle=dropdown]"),o=0,i=n.length;for(o;i>o;o++)new t(n[o]);return t});
|