engram-popup 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,57 +1 @@
1
- function h() {
2
- const l = document.querySelectorAll("[data-engram-button]");
3
- if (console.log(l.length), !l || l.length < 1) return;
4
- let i = null;
5
- const r = document.querySelectorAll(["[data-engram-popup]"]);
6
- console.log(r[0]);
7
- for (let e = 0; e < l.length; e++)
8
- l[e].addEventListener("click", () => {
9
- const n = l[e].getAttribute("data-engram-button");
10
- i != n && s().then((o) => {
11
- console.log(o), o === !0 && c(n);
12
- });
13
- });
14
- function c(e) {
15
- let n = null;
16
- for (let o = 0; o < r.length; o++) {
17
- let t = r[o].getAttribute("data-engram-popup");
18
- if (e === t) {
19
- n = r[o];
20
- break;
21
- }
22
- }
23
- n ? d(n) : alert(`popup container with name ${e} dont finded`);
24
- }
25
- function d(e) {
26
- let n = e.cloneNode(!0);
27
- i = n.getAttribute("data-engram-popup");
28
- let o = n.getAttribute("data-engram-theme") ?? "white";
29
- n.getAttribute("data-engram-animation");
30
- let t = document.createElement("div"), p = document.createElement("div");
31
- p.classList.add("engram-popup__close"), t.classList.add("engram-popup"), o == "white" ? t.classList.add("engram-popup--theme-white") : o == "black" ? t.classList.add("engram-popup--theme-black") : t.classList.add("engram-popup--theme-white"), n.removeAttribute("data-engram-popup"), t.appendChild(p), t.appendChild(n), t.style.visibility = "hidden", document.body.appendChild(t);
32
- let g = t.clientHeight, u = window.innerHeight;
33
- console.log(u), t.style.visibility = "", t.style.transform = `translateY(${+u / 2 - +g / 2}px)`, p.addEventListener("click", m), setTimeout(() => {
34
- document.addEventListener("click", a);
35
- }, 0);
36
- }
37
- function a(e) {
38
- e.target.closest(".engram-popup") || (s(), console.log("click outside"));
39
- }
40
- function m() {
41
- let e = this.closest(".engram-popup");
42
- e.style.transform = "translateY(110vh)", setTimeout(() => {
43
- e.style.visibility = "", e.remove(), i = null, document.removeEventListener("click", a), console.log("close current popup");
44
- }, 500);
45
- }
46
- function s() {
47
- const e = Array.from(document.querySelectorAll(".engram-popup"));
48
- if (document.removeEventListener("click", a), e.length < 1) return Promise.resolve(!0);
49
- const n = e.map((o) => new Promise((t, p) => {
50
- o.style.transform = "translateY(110vh)", setTimeout(() => {
51
- o.style.visibility = "", o.remove(), i = null, t();
52
- }, 500);
53
- }));
54
- return Promise.all(n).then(() => !0);
55
- }
56
- }
57
- h();
1
+
@@ -1,2 +1,2 @@
1
- (function(l){typeof define=="function"&&define.amd?define(l):l()})((function(){"use strict";var l=document.createElement("style");l.textContent=`[data-engram-popup]{display:none}.engram-popup{width:600px;z-index:999;background:#fff;border-radius:20px;position:fixed;box-shadow:0 0 10px #0000001a;left:calc(50% - 300px);padding:30px;transform:translateY(110vh);transition:all ease .5s}.engram-popup--theme-black{background:#222}.engram-popup__close{position:absolute;width:35px;height:35px;border-radius:100px;display:flex;align-items:center;justify-content:center;background:#ccc;right:10px;top:10px;cursor:pointer}
2
- /*$vite$:1*/`,document.head.appendChild(l);function d(){const i=document.querySelectorAll("[data-engram-button]");if(console.log(i.length),!i||i.length<1)return;let p=null;const r=document.querySelectorAll(["[data-engram-popup]"]);console.log(r[0]);for(let e=0;e<i.length;e++)i[e].addEventListener("click",()=>{const n=i[e].getAttribute("data-engram-button");p!=n&&u().then(o=>{console.log(o),o===!0&&m(n)})});function m(e){let n=null;for(let o=0;o<r.length;o++){let t=r[o].getAttribute("data-engram-popup");if(e===t){n=r[o];break}}n?g(n):alert(`popup container with name ${e} dont finded`)}function g(e){let n=e.cloneNode(!0);p=n.getAttribute("data-engram-popup");let o=n.getAttribute("data-engram-theme")??"white";n.getAttribute("data-engram-animation");let t=document.createElement("div"),a=document.createElement("div");a.classList.add("engram-popup__close"),t.classList.add("engram-popup"),o=="white"?t.classList.add("engram-popup--theme-white"):o=="black"?t.classList.add("engram-popup--theme-black"):t.classList.add("engram-popup--theme-white"),n.removeAttribute("data-engram-popup"),t.appendChild(a),t.appendChild(n),t.style.visibility="hidden",document.body.appendChild(t);let f=t.clientHeight,c=window.innerHeight;console.log(c),t.style.visibility="",t.style.transform=`translateY(${+c/2-+f/2}px)`,a.addEventListener("click",h),setTimeout(()=>{document.addEventListener("click",s)},0)}function s(e){e.target.closest(".engram-popup")||(u(),console.log("click outside"))}function h(){let e=this.closest(".engram-popup");e.style.transform="translateY(110vh)",setTimeout(()=>{e.style.visibility="",e.remove(),p=null,document.removeEventListener("click",s),console.log("close current popup")},500)}function u(){const e=Array.from(document.querySelectorAll(".engram-popup"));if(document.removeEventListener("click",s),e.length<1)return Promise.resolve(!0);const n=e.map(o=>new Promise((t,a)=>{o.style.transform="translateY(110vh)",setTimeout(()=>{o.style.visibility="",o.remove(),p=null,t()},500)}));return Promise.all(n).then(()=>!0)}}d()}));
1
+ (function(e){typeof define=="function"&&define.amd?define(e):e()})((function(){"use strict";var e=document.createElement("style");e.textContent=`[data-engram-popup]{display:none}.engram-popup{width:600px;z-index:999;background:#fff;border-radius:20px;position:fixed;box-shadow:0 0 10px #0000001a;left:calc(50% - 300px);padding:30px;transform:translateY(110vh);transition:all ease .5s}.engram-popup--theme-black{background:#222}.engram-popup__close{position:absolute;width:35px;height:35px;border-radius:100px;display:flex;align-items:center;justify-content:center;background:#ccc;right:10px;top:10px;cursor:pointer}
2
+ /*$vite$:1*/`,document.head.appendChild(e)}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "engram-popup",
3
3
  "private": false,
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",