|
1 | 1 | (function () { |
2 | 2 | "use strict"; |
3 | 3 |
|
4 | | - var CLOSE_SVG = |
5 | | - '<svg width="28" height="28" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">' + |
6 | | - '<path fill-rule="evenodd" clip-rule="evenodd" d="M12 2C6.47 2 2 6.47 2 12C2 17.53 6.47 22 12 22C17.53 22 22 17.53 22 12C22 6.47 17.53 2 12 2ZM17 15.59L15.59 17L12 13.41L8.41 17L7 15.59L10.59 12L7 8.41L8.41 7L12 10.59L15.59 7L17 8.41L13.41 12L17 15.59Z"/>' + |
7 | | - "</svg>"; |
| 4 | + function attachBehavior(el) { |
| 5 | + if (!el) return; |
| 6 | + |
| 7 | + var closeBtn = el.querySelector(".close-btn"); |
| 8 | + if (closeBtn) { |
| 9 | + closeBtn.addEventListener("click", function () { |
| 10 | + el.classList.add("kanvas-corner-popup--hiding"); |
| 11 | + el.addEventListener( |
| 12 | + "transitionend", |
| 13 | + function () { |
| 14 | + el.remove(); |
| 15 | + }, |
| 16 | + { once: true } |
| 17 | + ); |
| 18 | + }); |
| 19 | + } |
8 | 20 |
|
9 | | - function img(cls, file) { |
10 | | - return '<img class="' + cls + '" src="/images/banner-transitions/' + file + '" alt="" />'; |
| 21 | + if (typeof window.initKanvasTransition === "function") { |
| 22 | + var c = el.querySelector(".kanvas-transition-container"); |
| 23 | + if (c) window.initKanvasTransition(c); |
| 24 | + } |
11 | 25 | } |
12 | 26 |
|
13 | | - function buildPopup() { |
14 | | - var el = document.createElement("div"); |
15 | | - el.setAttribute("role", "dialog"); |
16 | | - el.setAttribute("aria-label", "Kanvas Collaboration Popup"); |
17 | | - el.className = "kanvas-corner-popup"; |
18 | | - var bgFile = "empty-dark.svg"; |
19 | | - var svcFile = "service-interface-partial-colorMode.svg"; |
20 | | - var ingressFile = "ingress-gateway-partial-colorMode.svg"; |
21 | | - var kubernetesFile = "kubernetes-partial-colorMode.svg"; |
22 | | - var podFile = "pod-partial-colorMode.svg"; |
23 | | - var prometheusFile = "prometheus-partial-colorMode.svg"; |
24 | | - var arrowsFile = "supporting-arrows.svg"; |
25 | | - |
26 | | - el.innerHTML = |
27 | | - '<div class="popup"><div class="popup-inner">' + |
28 | | - '<button class="close-btn" aria-label="Close popup">' + CLOSE_SVG + "</button>" + |
29 | | - '<a class="popup-content-link" href="https://kanvas.new/" target="_blank" rel="noopener noreferrer">' + |
30 | | - '<div class="popup-text"><h4>Build solutions together</h4><h1>Collaborate with the team</h1></div>' + |
31 | | - '<div class="kanvas-transition-container">' + |
32 | | - '<div class="canvas-grid"></div>' + |
33 | | - '<img class="kanvas-canvas-bg" src="/images/banner-transitions/' + bgFile + '" alt="" />' + |
34 | | - '<div class="kanvas-layer">' + img("kanvas-service-interface", svcFile) + "</div>" + |
35 | | - '<div class="kanvas-layer">' + img("kanvas-ingress-gateway", ingressFile) + "</div>" + |
36 | | - '<div class="kanvas-layer">' + img("kanvas-kubernetes", kubernetesFile) + "</div>" + |
37 | | - '<div class="kanvas-layer">' + img("kanvas-pod", podFile) + "</div>" + |
38 | | - '<div class="kanvas-layer">' + img("kanvas-prometheus", prometheusFile) + "</div>" + |
39 | | - img("kanvas-supporting-arrows", arrowsFile) + |
40 | | - "</div>" + |
41 | | - '<div class="try-it-text"><span>Try it now at </span><strong>kanvas.new</strong></div>' + |
42 | | - "</a>" + |
43 | | - '<a class="explore-playground-button" href="https://kanvas.new/" target="_blank" rel="noopener noreferrer">Access Kanvas</a>' + |
44 | | - "</div></div>"; |
45 | | - |
46 | | - el.querySelector(".close-btn").addEventListener("click", function () { |
47 | | - el.classList.add("kanvas-corner-popup--hiding"); |
48 | | - el.addEventListener("transitionend", function () { |
49 | | - el.remove(); |
50 | | - }, { once: true }); |
51 | | - }); |
| 27 | + function show() { |
| 28 | + var el = document.getElementById("kanvas-corner-popup"); |
| 29 | + if (!el) return; |
52 | 30 |
|
53 | | - return el; |
54 | | - } |
| 31 | + attachBehavior(el); |
55 | 32 |
|
56 | | - function show() { |
57 | | - var el = buildPopup(); |
58 | | - document.body.appendChild(el); |
59 | 33 | requestAnimationFrame(function () { |
60 | | - requestAnimationFrame(function () { el.classList.add("kanvas-corner-popup--visible"); }); |
| 34 | + requestAnimationFrame(function () { |
| 35 | + el.classList.add("kanvas-corner-popup--visible"); |
| 36 | + }); |
61 | 37 | }); |
62 | | - if (typeof window.initKanvasTransition === "function") { |
63 | | - var c = el.querySelector(".kanvas-transition-container"); |
64 | | - if (c) window.initKanvasTransition(c); |
65 | | - } |
66 | 38 | } |
67 | 39 |
|
68 | 40 | function init() { |
|
0 commit comments