UNPKG

madosel

Version:

The most and fast advanced responsive html front-end framework.

9 lines 1.94 kB
/*! * Madosel Dropdown 1.0.0-alpha12 * Copyright 2020-2021 Kenan Gündoğan * https://www.madosel.com * Licensed under MIT https://github.com/kenangundogan/madosel/blob/master/LICENSE * Released under the MIT License */ document.addEventListener("DOMContentLoaded",(function(){!function(){var t=document.querySelectorAll(".dropdown-container");function o(t){t.dropdownContainers.forEach((function(t){var o=t.querySelector(".dropdown-list"),n=o.getAttribute("data-position");o.classList.remove("show",n),o.style.height=""}))}t.forEach((function(n){var d,e=n.querySelector(".dropdown-btn"),a=n.querySelector(".dropdown-list"),i=a.getAttribute("data-position"),s=e.getAttribute("data-target"),r=a.id,p=a.getAttribute("data-height");""!=i&&null!=i||(i="bottom"),""!=p&&null!=p||(p=""),(d={dropdownContainers:t,dropdownBtn:e,dropdownList:a,dataPosition:i,dataHeight:p,dataTarget:s,id:r}).dropdownBtn.addEventListener("click",(function(){d.dropdownList.classList.forEach((function(t){"show"==t?o(d):d.id==d.dataTarget&&(o(d),"top"==d.dataPosition?(d.dropdownList.style.transform="translate(0px, -".concat(d.dropdownBtn.offsetHeight,"px)"),d.dropdownList.style.inset="auto auto 0px 0px"):"bottom"==d.dataPosition?(d.dropdownList.style.transform="translate(0px, ".concat(d.dropdownBtn.offsetHeight,"px)"),d.dropdownList.style.inset="0px auto auto 0px"):"right"==d.dataPosition?(d.dropdownList.style.transform="translate(".concat(d.dropdownBtn.offsetWidth,"px, 0px)"),d.dropdownList.style.inset="0px auto auto 0px"):"left"==d.dataPosition&&(d.dropdownList.style.transform="translate(-".concat(d.dropdownBtn.offsetWidth,"px, 0px)"),d.dropdownList.style.inset="0px 0px auto auto"),d.dropdownList.classList.add("show",d.dataPosition),d.dropdownList.style.height="".concat(d.dataHeight,"px"))}))})),document.addEventListener("keydown",(function(t){"Escape"!==t.key&&"Esc"!==t.key||o(d)}))}))}()})); //# sourceMappingURL=madosel-dropdown.min.js.map