(mountEl, client, useActivateButton)
| 35 | } |
| 36 | |
| 37 | function activateView(mountEl, client, useActivateButton) { |
| 38 | if (!useActivateButton) { |
| 39 | mount(mountEl, client); |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | const enableWidgetButton = document.createElement("button"); |
| 44 | enableWidgetButton.appendChild(document.createTextNode("Activate")); |
| 45 | enableWidgetButton.setAttribute("class", "enable-widget-button"); |
| 46 | |
| 47 | enableWidgetButton.addEventListener("click", () => |
| 48 | fadeOutElementThenCallback(enableWidgetButton, () => { |
| 49 | { |
| 50 | mountEl.removeChild(enableWidgetButton); |
| 51 | mountEl.setAttribute("class", "interactive widget-container"); |
| 52 | mountWithLayoutServer(mountEl, serverInfo); |
| 53 | } |
| 54 | }), |
| 55 | ); |
| 56 | |
| 57 | function fadeOutElementThenCallback(element, callback) { |
| 58 | { |
| 59 | var op = 1; // initial opacity |
| 60 | var timer = setInterval(function () { |
| 61 | { |
| 62 | if (op < 0.001) { |
| 63 | { |
| 64 | clearInterval(timer); |
| 65 | element.style.display = "none"; |
| 66 | callback(); |
| 67 | } |
| 68 | } |
| 69 | element.style.opacity = op; |
| 70 | element.style.filter = "alpha(opacity=" + op * 100 + ")"; |
| 71 | op -= op * 0.5; |
| 72 | } |
| 73 | }, 50); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | mountEl.appendChild(enableWidgetButton); |
| 78 | } |
| 79 | |
| 80 | function triggerIfInViewport(element, callback) { |
| 81 | const observer = new window.IntersectionObserver( |
no test coverage detected