Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 3caef5d

Browse files
authored
Merge pull request #23 from Laaouatni/popup-created-automatically-wihout-write-it-in-html
fix: #22 Popup created automatically wihout write it in html
2 parents 5e2d85f + e148ec9 commit 3caef5d

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

gcode/index.html

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
</head>
99
<body>
1010
<div id="app">
11-
<div id="tooltip" role="tooltip">
12-
<span>hello waaaaaaa</span>
13-
14-
<div id="arrow"></div>
15-
</div>
16-
1711
<section id="hello"></section>
1812
</div>
1913

@@ -60,6 +54,7 @@
6054
top: var(--line-top);
6155
left: var(--line-left);
6256
transform: rotate(var(--line-rotate));
57+
z-index: var(--line-zIndex);
6358
}
6459

6560
.Gline::before {
@@ -86,8 +81,7 @@
8681
position: absolute;
8782
top: 50%;
8883
right: 0;
89-
transform: translate(0, -50%);
90-
z-index: 5 !important;
84+
transform: translate(50%, -50%);
9185
}
9286

9387
.Gline::before {

gcode/src/API/GcodeApi/Gsimulator/Gcss/CssFloatPopup/CssFloatPopup.js

+27-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
1-
import updatePopup from "./other/Methods/updatePopup/updatePopup";
1+
import updatePopup from "./other/Methods/updatePopup/updatePopup.js";
22

33
export default class CssFloatPopup {
4+
static popup;
5+
static span;
6+
static arrow;
7+
8+
static {
9+
CssFloatPopup.popup = document.createElement("div");
10+
CssFloatPopup.span = document.createElement("span");
11+
CssFloatPopup.arrow = document.createElement("div");
12+
13+
CssFloatPopup.popup.id = "tooltip";
14+
CssFloatPopup.popup.role = "tooltip";
15+
16+
CssFloatPopup.span.style.setProperty("white-space", "pre");
17+
18+
CssFloatPopup.arrow.id = "arrow";
19+
20+
CssFloatPopup.popup.appendChild(CssFloatPopup.span);
21+
CssFloatPopup.popup.appendChild(CssFloatPopup.arrow);
22+
}
23+
424
constructor(_obj) {
525
this.obj = _obj;
626

727
this.button = this.obj.button;
8-
this.popup = this.obj.popup;
9-
this.arrow = this.obj.arrow ?? this.obj.popup.querySelector("#arrow");
10-
11-
this.popupText = this.popup.querySelector("span");
28+
29+
this.popup = CssFloatPopup.popup;
30+
this.arrow = CssFloatPopup.arrow;
31+
this.span = CssFloatPopup.span;
1232

1333
this.addDefaultStyles();
1434
this.addEvents();
@@ -20,7 +40,7 @@ export default class CssFloatPopup {
2040

2141
showPopup() {
2242
this.popup.style.display = "block";
23-
this.popupText.textContent = `${this.button.dataset.after}`;
43+
this.span.textContent = `${this.button.dataset.line}`;
2444
updatePopup(this);
2545
}
2646

@@ -49,7 +69,7 @@ export default class CssFloatPopup {
4969
this.popup.style.setProperty(key, this.PopupValuesArray[index]);
5070
});
5171

52-
this.popupText.style.setProperty("white-space", "pre");
72+
this.span.style.setProperty("white-space", "pre");
5373
}
5474

5575
styleArrow() {

gcode/src/API/GcodeApi/Gsimulator/Gcss/CssLine/CssLine.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export default class CssLine {
66
constructor(_CurrentObj, _index) {
77
this.index = _index;
88
this.lineElement = document.createElement("div");
9-
this.popupEl = document.querySelector("#tooltip");
109

1110
this.currentObj = _CurrentObj;
1211
this.previusObj = GcodeAPI.array[this.index - 1 > 0 ? this.index - 1 : 0];
@@ -34,7 +33,6 @@ export default class CssLine {
3433

3534
this.createPopup({
3635
button: this.lineElement,
37-
popup: this.popupEl
3836
});
3937

4038
}
@@ -59,6 +57,7 @@ export default class CssLine {
5957
top: `${this.smallestPos.y}px`,
6058
rotate: `${this.lineAngle}deg`,
6159
backgroundColor: "red",
60+
zIndex: `${GcodeAPI.array.length - this.index}`
6261
};
6362

6463
this.stylesKeysArray = Object.keys(this.lineStylesObj);
@@ -74,7 +73,7 @@ export default class CssLine {
7473
this.lineElement.classList.add("Gline");
7574
this.lineElement.setAttribute("key", this.index);
7675
this.lineElement.setAttribute(
77-
"data-after",
76+
"data-line",
7877
`${JSON.stringify({
7978
length: this.lineLength,
8079
x: this.currentObj.x,

gcode/src/API/GcodeApi/Gsimulator/Gcss/Gcss.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Gsimulator from "../Gsimulator.js";
22
import GcodeAPI from "../../GcodeAPI_main/GcodeAPI.js";
33
import CssLine from "./CssLine/CssLine.js";
4+
import CssFloatPopup from "./CssFloatPopup/CssFloatPopup.js";
45

56
export default class Gcss extends Gsimulator {
67
constructor(_GcssObj) {
@@ -14,6 +15,8 @@ export default class Gcss extends Gsimulator {
1415
document.querySelector("#app") ??
1516
document.body;
1617

18+
this.parentHtmlContainer.appendChild(CssFloatPopup.popup);
19+
1720
this.create();
1821
}
1922

0 commit comments

Comments
 (0)