Skip to content

Commit 1301006

Browse files
committed
v13.0.5
1 parent bfe57ac commit 1301006

File tree

6 files changed

+89
-4
lines changed

6 files changed

+89
-4
lines changed

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "13.0.4",
3+
"version": "13.0.5",
44
"main": "build/index.js",
55
"scripts": {
66
"start": "webpack serve",

published/13.0.5/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GleapAdminManager.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import { loadIcon } from "./UI";
2+
13
export default class GleapAdminManager {
24
libraryInstance = null;
35
lastUrl = undefined;
46
injectedFrame = false;
57
gleapFrameContainer = null;
8+
gleapCollapseUI = null;
9+
injectedCollapseUI = false;
610
gleapFrame = null;
711
configData = null;
812
status = "navigate";
@@ -64,6 +68,7 @@ export default class GleapAdminManager {
6468
self.libraryInstance = new window.GleapHelper.default();
6569
if (self.libraryInstance) {
6670
self.libraryInstance.onElementPicked = (selector) => {
71+
self.toggleCollapseUI(true);
6772
self.sendMessageToTourBuilder({
6873
name: "element-picked",
6974
data: {
@@ -73,6 +78,7 @@ export default class GleapAdminManager {
7378
};
7479

7580
self.injectFrame();
81+
self.injectCollapseUI();
7682
self.setFrameHeight("loading");
7783
}
7884
}
@@ -176,6 +182,49 @@ export default class GleapAdminManager {
176182
} catch (e) { }
177183
}
178184

185+
toggleCollapseUI = (onlyIfActive = false) => {
186+
const COLLAPSE_UI_ACTIVE_CLASS = "gleap-admin-collapse-ui-active";
187+
const FRAME_CONTAINER_ACTIVE_CLASS = "gleap-admin-frame-container-active";
188+
189+
// Helper function to check if an element has an active class
190+
const isActive = (element, activeClass) => element && element.classList.contains(activeClass);
191+
192+
// Check if onlyIfActive is true and if the UI elements are already inactive
193+
if (onlyIfActive && (!isActive(this.gleapCollapseUI, COLLAPSE_UI_ACTIVE_CLASS) || !isActive(this.gleapFrameContainer, FRAME_CONTAINER_ACTIVE_CLASS))) {
194+
return; // Return early without toggling the UI
195+
}
196+
197+
// Toggle the UI elements
198+
if (this.gleapCollapseUI) {
199+
this.gleapCollapseUI.classList.toggle(COLLAPSE_UI_ACTIVE_CLASS);
200+
}
201+
if (this.gleapFrameContainer) {
202+
this.gleapFrameContainer.classList.toggle(FRAME_CONTAINER_ACTIVE_CLASS);
203+
}
204+
}
205+
206+
injectCollapseUI = () => {
207+
if (this.injectedCollapseUI) {
208+
return;
209+
}
210+
this.injectedCollapseUI = true;
211+
212+
// Inject widget HTML.
213+
var elem = document.createElement("div");
214+
elem.className =
215+
"gleap-admin-collapse-ui";
216+
elem.innerHTML = `<div class="gleap-admin-collapse-ui-icon">
217+
${loadIcon("arrowdown")}
218+
</div>`;
219+
document.body.appendChild(elem);
220+
221+
this.gleapCollapseUI = elem;
222+
223+
elem.addEventListener("click", () => {
224+
this.toggleCollapseUI();
225+
});
226+
}
227+
179228
injectFrame = () => {
180229
if (this.injectedFrame) {
181230
return;

src/UI.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1690,13 +1690,48 @@ export const injectStyledCSS = (
16901690
border-radius: 8px;
16911691
}
16921692
1693+
.gleap-admin-collapse-ui {
1694+
z-index: ${zIndexBase + 35};
1695+
cursor: pointer;
1696+
position: fixed;
1697+
bottom: 75px;
1698+
right: 20px;
1699+
width: 32px;
1700+
height: 32px;
1701+
border-radius: 100%;
1702+
background-color: #fff;
1703+
display: flex;
1704+
justify-content: center;
1705+
align-items: center;
1706+
box-shadow: rgba(0, 0, 0, 0.16) 0px 10px 36px 0px, rgba(0, 0, 0, 0.06) 0px 0px 0px 1px;
1707+
}
1708+
1709+
.gleap-admin-collapse-ui svg {
1710+
width: 20px;
1711+
height: 14px;
1712+
margin-top: 6px;
1713+
fill: #000 !important;
1714+
}
1715+
1716+
.gleap-admin-collapse-ui-active {
1717+
bottom: 20px !important;
1718+
}
1719+
1720+
.gleap-admin-collapse-ui-active svg {
1721+
transform: rotate(180deg);
1722+
}
1723+
1724+
.gleap-admin-frame-container-active {
1725+
display: none !important;
1726+
}
1727+
16931728
.gleap-admin-frame-container {
16941729
position: fixed;
16951730
bottom: 0px;
16961731
left: 0px;
16971732
right: 0px;
16981733
width: 100vw;
1699-
z-index: 2147483730;
1734+
z-index: ${zIndexBase + 40};
17001735
}
17011736
17021737
.gleap-admin-frame {

0 commit comments

Comments
 (0)