@contactstudio/mindbeui
Advanced tools
Comparing version 0.0.88 to 0.0.90
@@ -1,1 +0,1 @@ | ||
(function(c){typeof define=="function"&&define.amd?define(c):c()})(function(){"use strict";console.log("Mindbe UI");function c(){const e=document.querySelectorAll("[tooltip]");for(const t of e)t.onmouseenter=({target:o})=>{const{top:n,left:d}=document.body.getBoundingClientRect(),{top:u,left:r}=t.getBoundingClientRect(),i=document.createElement("div");i.innerHTML=o.getAttribute("tooltip"),i.classList.add("tooltip");const f=r-d,g=u-n-35;i.style.setProperty("top",`${g}px`),i.style.setProperty("left",`${f}px`),document.body.append(i)},t.onmouseleave=()=>{document.querySelector("div.tooltip").remove()}}function m(){const e=document.querySelectorAll(".accordion .item");for(const t of e)t.onclick=()=>{if(!t)return;const o=t.parentElement.querySelectorAll(".item");for(const n of o)n!==t&&n.removeAttribute("open")}}function p(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const o=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);w({trigger:t,dropdown:o})}}function w({trigger:e,dropdown:t}){e.onclick=()=>{D({dropdown:t}),E({dropdown:t}),s({trigger:e,dropdown:t}),window.onresize=()=>{s({trigger:e,dropdown:t})},document.onscroll=()=>{s({trigger:e,dropdown:t})},x({trigger:e,dropdown:t}),L({trigger:e,dropdown:t})}}function D({dropdown:e}){const t=document.querySelectorAll("*[dropdown]");for(const o of t)e!==o&&l({dropdown:o})}function E({dropdown:e}){e.classList.toggle("visible"),e.classList.contains("visible")||a()}function L({trigger:e,dropdown:t}){document.onclick=o=>{!e.contains(o.target)&&!t.contains(o.target)&&l({dropdown:t})}}function x({trigger:e,dropdown:t}){const o=t.querySelectorAll(".item");for(const n of o)n.onclick=()=>{if(t.hasAttribute("static")){setTimeout(()=>{s({trigger:e,dropdown:t})},0);return}l({dropdown:t})}}function s({trigger:e,dropdown:t}){const{top:o,bottom:n,left:d,right:u}=e.getBoundingClientRect(),{width:r,height:i}=t.getBoundingClientRect(),{width:f,height:g,top:y,left:b}=document.body.getBoundingClientRect(),h=u-b,q=d-b,v=n-y,C=o-y,T=h+r>f,A=v+i>g;A||t.style.setProperty("top",`${v}px`),A&&t.style.setProperty("top",`${C-i}px`),T||t.style.setProperty("left",`${q}px`),T&&t.style.setProperty("left",`${h-r}px`)}function l({dropdown:e}){e.classList.remove("visible"),a()}function a(){window.onresize=()=>{},document.onscroll=()=>{}}(function(){window&&document&&(document.addEventListener("DOMContentLoaded",()=>{c(),m(),p()}),document.addEventListener("click",()=>{c(),m(),p()}))})();const S=""}); | ||
(function(c){typeof define=="function"&&define.amd?define(c):c()})(function(){"use strict";console.log("Mindbe UI");function c(){const e=document.querySelectorAll("[tooltip]");for(const t of e)t.onmouseenter=({target:o})=>{const{top:n,left:u}=document.body.getBoundingClientRect(),{top:f,left:r}=t.getBoundingClientRect(),i=document.createElement("div");i.innerHTML=o.getAttribute("tooltip"),i.classList.add("tooltip"),document.body.append(i);const g=r-u;i.style.setProperty("left",`${g}px`);const m=i.offsetHeight,l=f-n-m-5;i.style.setProperty("top",`${l}px`)},t.onmouseleave=()=>{document.querySelector("div.tooltip").remove()}}function p(){const e=document.querySelectorAll(".accordion .item");for(const t of e)t.onclick=()=>{if(!t)return;const o=t.parentElement.querySelectorAll(".item");for(const n of o)n!==t&&n.removeAttribute("open")}}function a(){const e=document.querySelectorAll("*[dropdown-trigger]");for(const t of e){const o=document.querySelector(`.dropdown[dropdown="${t.getAttribute("dropdown-trigger")}"]`);w({trigger:t,dropdown:o})}}function w({trigger:e,dropdown:t}){e.onclick=()=>{D({dropdown:t}),E({dropdown:t}),s({trigger:e,dropdown:t}),window.onresize=()=>{s({trigger:e,dropdown:t})},document.onscroll=()=>{s({trigger:e,dropdown:t})},x({trigger:e,dropdown:t}),L({trigger:e,dropdown:t})}}function D({dropdown:e}){const t=document.querySelectorAll("*[dropdown]");for(const o of t)e!==o&&d({dropdown:o})}function E({dropdown:e}){e.classList.toggle("visible"),e.classList.contains("visible")||y()}function L({trigger:e,dropdown:t}){document.onclick=o=>{!e.contains(o.target)&&!t.contains(o.target)&&d({dropdown:t})}}function x({trigger:e,dropdown:t}){const o=t.querySelectorAll(".item");for(const n of o)n.onclick=()=>{if(t.hasAttribute("static")){setTimeout(()=>{s({trigger:e,dropdown:t})},0);return}d({dropdown:t})}}function s({trigger:e,dropdown:t}){const{top:o,bottom:n,left:u,right:f}=e.getBoundingClientRect(),{width:r,height:i}=t.getBoundingClientRect(),{width:g,height:m,top:l,left:h}=document.body.getBoundingClientRect(),b=f-h,q=u-h,v=n-l,C=o-l,T=b+r>g,A=v+i>m;A||t.style.setProperty("top",`${v}px`),A&&t.style.setProperty("top",`${C-i}px`),T||t.style.setProperty("left",`${q}px`),T&&t.style.setProperty("left",`${b-r}px`)}function d({dropdown:e}){e.classList.remove("visible"),y()}function y(){window.onresize=()=>{},document.onscroll=()=>{}}(function(){window&&document&&(document.addEventListener("DOMContentLoaded",()=>{c(),p(),a()}),document.addEventListener("click",()=>{c(),p(),a()}))})();const S=""}); |
{ | ||
"name": "@contactstudio/mindbeui", | ||
"version": "0.0.88", | ||
"version": "0.0.90", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "dist/mindbeui.js", |
@@ -13,12 +13,13 @@ console.log("Mindbe UI"); | ||
const div = document.createElement("div"); | ||
div.innerHTML = target.getAttribute("tooltip"); | ||
div.classList.add("tooltip"); | ||
document.body.append(div); | ||
const left = leftTarget - scrollLeft; | ||
const top = topTarget - scrollTop - 35; | ||
div.style.setProperty("left", `${left}px`); | ||
const divHeight = div.offsetHeight; | ||
const top = topTarget - scrollTop - divHeight - 5; | ||
div.style.setProperty("top", `${top}px`); | ||
div.style.setProperty("left", `${left}px`); | ||
document.body.append(div); | ||
}; | ||
@@ -25,0 +26,0 @@ item.onmouseleave = () => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
26
257
49283