@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.30 to 0.0.31
@@ -1,1 +0,1 @@ | ||
(function(s){typeof define=="function"&&define.amd?define(s):s()})(function(){"use strict";console.log("Mindbe UI");async function s(){const e=document.querySelectorAll(".accordion .item:not([disabled])");for(const t of e){if(t.getAttribute("listener"))return;t.setAttribute("listener",!0),t.addEventListener("click",()=>{const i=t.parentElement.querySelectorAll(".item:not([disabled])");for(const n of i)n!==t&&n.removeAttribute("open")})}}function r(e){const t=document.querySelectorAll("*[dropdown-trigger]");for(const i of t){const n=document.querySelector(`.dropdown[dropdown="${i.getAttribute("dropdown-trigger")}"]`);if(o({trigger:i,dropdown:n}),l({trigger:i,dropdown:n}),e)return;c({trigger:i,dropdown:n})}}function o({trigger:e,dropdown:t}){e.getAttribute("listener")||e.addEventListener("click",()=>{if(e.setAttribute("listener",!0),console.log("addShowEventDropdown"),t.classList.contains("visible")){t.classList.remove("visible");return}t.classList.add("visible"),u({trigger:e,dropdown:t})})}function c({trigger:e,dropdown:t}){document.addEventListener("click",i=>{console.log("addHideEventDropdown"),!e.contains(i.target)&&!t.contains(i.target)&&t.classList.remove("visible")})}function l({dropdown:e}){if(e.hasAttribute("static"))return;const t=e.querySelectorAll(".item");for(const i of t){if(i.getAttribute("listener"))return;i.setAttribute("listener",!0),i.addEventListener("click",()=>{console.log("addHideEventDropdownItems"),e.classList.remove("visible")})}}function u({trigger:e,dropdown:t}){const{top:i,left:n,right:d,height:f}=e.getBoundingClientRect(),{width:a,height:m}=t.getBoundingClientRect();if(t.hasAttribute("dropend")){t.style.setProperty("top",`${i}px`),t.style.setProperty("left",`${d}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${i}px`),t.style.setProperty("left",`${n-a}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${i-m}px`),t.style.setProperty("left",`${n}px`);return}t.style.setProperty("top",`${i+f}px`),t.style.setProperty("left",`${n}px`)}(function e(){if(document){document.addEventListener("DOMContentLoaded",t=>{s(),r()}),document.addEventListener("click",t=>{s(),r(!0)});return}setTimeout(()=>{e()},1e3)})();const p=""}); | ||
(function(o){typeof define=="function"&&define.amd?define(o):o()})(function(){"use strict";console.log("Mindbe UI"),function(){window&&document&&(window.onload=()=>{o(),s()},document.addEventListener("click",()=>{o(),s()}))}();async function o(){const e=document.querySelectorAll(".accordion .item");for(const t of e)t.onclick=()=>{const i=t.parentElement.querySelectorAll(".item:not([disabled])");for(const n of i)n!==t&&n.removeAttribute("open")}}function s(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const i=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);c({trigger:t,dropdown:i}),r({trigger:t,dropdown:i})}}function c({trigger:e,dropdown:t}){e.onclick=()=>{if(t.classList.contains("visible")){t.classList.remove("visible");return}t.classList.add("visible"),u({trigger:e,dropdown:t}),l({dropdown:t})}}function r({trigger:e,dropdown:t}){document.onclick=i=>{!e.contains(i.target)&&!t.contains(i.target)&&t.classList.remove("visible")}}function l({dropdown:e}){if(e.hasAttribute("static"))return;const t=e.querySelectorAll(".item");for(const i of t)i.onclick=()=>{e.classList.remove("visible")}}function u({trigger:e,dropdown:t}){const{top:i,left:n,right:f,height:a}=e.getBoundingClientRect(),{width:y,height:m}=t.getBoundingClientRect();if(t.hasAttribute("dropend")){t.style.setProperty("top",`${i}px`),t.style.setProperty("left",`${f}px`);return}if(t.hasAttribute("dropstart")){t.style.setProperty("top",`${i}px`),t.style.setProperty("left",`${n-y}px`);return}if(t.hasAttribute("dropup")){t.style.setProperty("top",`${i-m}px`),t.style.setProperty("left",`${n}px`);return}t.style.setProperty("top",`${i+a}px`),t.style.setProperty("left",`${n}px`)}const d=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.30", | ||
"version": "0.0.31", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
console.log("Mindbe UI"); | ||
(function init() { | ||
if (window && document) { | ||
window.onload = () => { | ||
Accordion(); | ||
Dropdown(); | ||
}; | ||
document.addEventListener("click", () => { | ||
Accordion(); | ||
Dropdown(); | ||
}); | ||
} | ||
})(); | ||
async function Accordion() { | ||
const items = document.querySelectorAll(".accordion .item:not([disabled])"); | ||
const items = document.querySelectorAll(".accordion .item"); | ||
for (const item of items) { | ||
if (item.getAttribute("listener")) return; | ||
item.setAttribute("listener", true); | ||
item.addEventListener("click", () => { | ||
item.onclick = () => { | ||
const itemsByAccordion = item.parentElement.querySelectorAll( | ||
@@ -20,7 +30,7 @@ ".item:not([disabled])" | ||
} | ||
}); | ||
}; | ||
} | ||
} | ||
function Dropdown(reload) { | ||
function Dropdown() { | ||
const triggers = document.querySelectorAll("*[dropdown-trigger]"); | ||
@@ -34,5 +44,2 @@ | ||
addShowEventDropdown({ trigger, dropdown }); | ||
addHideEventDropdownItems({ trigger, dropdown }); | ||
if (reload) return; | ||
addHideEventDropdown({ trigger, dropdown }); | ||
@@ -43,9 +50,3 @@ } | ||
function addShowEventDropdown({ trigger, dropdown }) { | ||
if (trigger.getAttribute("listener")) return; | ||
trigger.addEventListener("click", () => { | ||
trigger.setAttribute("listener", true); | ||
console.log("addShowEventDropdown"); | ||
trigger.onclick = () => { | ||
if (dropdown.classList.contains("visible")) { | ||
@@ -57,10 +58,11 @@ dropdown.classList.remove("visible"); | ||
setPositionDropdown({ trigger, dropdown }); | ||
}); | ||
addHideEventDropdownItems({ dropdown }); | ||
}; | ||
} | ||
function addHideEventDropdown({ trigger, dropdown }) { | ||
document.addEventListener("click", (event) => { | ||
console.log("addHideEventDropdown"); | ||
document.onclick = (event) => { | ||
const isOutsideClick = | ||
!trigger.contains(event.target) && !dropdown.contains(event.target); | ||
!trigger.contains(event.target) && !dropdown.contains(event.target); | ||
@@ -70,3 +72,3 @@ if (isOutsideClick) { | ||
} | ||
}); | ||
}; | ||
} | ||
@@ -76,13 +78,9 @@ | ||
if (dropdown.hasAttribute("static")) return; | ||
const items = dropdown.querySelectorAll(".item"); | ||
for (const item of items) { | ||
if (item.getAttribute("listener")) return; | ||
item.setAttribute("listener", true); | ||
item.addEventListener("click", () => { | ||
console.log("addHideEventDropdownItems"); | ||
item.onclick = () => { | ||
dropdown.classList.remove("visible"); | ||
}); | ||
}; | ||
} | ||
@@ -114,19 +112,1 @@ } | ||
} | ||
(function init() { | ||
if (document) { | ||
document.addEventListener("DOMContentLoaded", (e) => { | ||
Accordion(); | ||
Dropdown(); | ||
}); | ||
document.addEventListener("click", (e) => { | ||
Accordion(); | ||
Dropdown(true); | ||
}); | ||
return; | ||
} | ||
setTimeout(() => { | ||
init(); | ||
}, 1000); | ||
})(); |
Sorry, the diff of this file is not supported yet
43507
166