toggle windows
This commit is contained in:
@@ -28,10 +28,19 @@ const global_chat = new GlobalChat();
|
|||||||
|
|
||||||
// Actions UI
|
// Actions UI
|
||||||
document.getElementById("login").addEventListener("click", () => {
|
document.getElementById("login").addEventListener("click", () => {
|
||||||
loginWindow.show();
|
// Toggle login window visibility
|
||||||
|
if (loginWindow.main && loginWindow.main.style.display !== "none") {
|
||||||
|
loginWindow.hide();
|
||||||
|
} else {
|
||||||
|
loginWindow.show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("global_chat").addEventListener("click", () => {
|
document.getElementById("global_chat").addEventListener("click", () => {
|
||||||
console.log("showing");
|
// Toggle global chat visibility
|
||||||
|
if (global_chat.main && global_chat.main.style.display !== "none") {
|
||||||
|
global_chat.hide();
|
||||||
|
} else {
|
||||||
global_chat.show();
|
global_chat.show();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ export class fenetre {
|
|||||||
this.main.style.color = "white";
|
this.main.style.color = "white";
|
||||||
this.main.style.zIndex = "100";
|
this.main.style.zIndex = "100";
|
||||||
this.main.style.display = "none";
|
this.main.style.display = "none";
|
||||||
|
// Mark windows for layout management (side-by-side when multiple open)
|
||||||
|
this.main.classList.add("trans-window");
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
this.header = document.createElement("div");
|
this.header = document.createElement("div");
|
||||||
@@ -38,11 +40,43 @@ export class fenetre {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
|
// If no other windows are open, center this window
|
||||||
|
const openWindows = Array.from(document.querySelectorAll(".trans-window"))
|
||||||
|
.filter(el => el.style.display !== "none");
|
||||||
|
|
||||||
|
if (openWindows.length === 0) {
|
||||||
|
this.main.style.left = "50%";
|
||||||
|
this.main.style.top = "50%";
|
||||||
|
this.main.style.transform = "translate(-50%, -50%)";
|
||||||
|
} else if (openWindows.length === 1) {
|
||||||
|
// Layout two windows side-by-side: left and right
|
||||||
|
const other = openWindows[0];
|
||||||
|
other.style.left = "15%";
|
||||||
|
other.style.top = "50%";
|
||||||
|
other.style.transform = "translate(-50%, -50%)";
|
||||||
|
|
||||||
|
this.main.style.left = "65%";
|
||||||
|
this.main.style.top = "50%";
|
||||||
|
this.main.style.transform = "translate(-50%, -50%)";
|
||||||
|
} else {
|
||||||
|
// Fallback: center if more than two windows are open
|
||||||
|
this.main.style.left = "50%";
|
||||||
|
this.main.style.top = "50%";
|
||||||
|
this.main.style.transform = "translate(-50%, -50%)";
|
||||||
|
}
|
||||||
this.main.style.display = "block";
|
this.main.style.display = "block";
|
||||||
}
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
this.main.style.display = "none";
|
this.main.style.display = "none";
|
||||||
|
// If only one window remains visible, center it
|
||||||
|
const visibles = Array.from(document.querySelectorAll(".trans-window"))
|
||||||
|
.filter(el => el.style.display !== "none");
|
||||||
|
if (visibles.length === 1) {
|
||||||
|
const w = visibles[0];
|
||||||
|
w.style.left = "50%";
|
||||||
|
w.style.top = "50%";
|
||||||
|
w.style.transform = "translate(-50%, -50%)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user