Added focusing windows on click, only effects draggable windows
This commit is contained in:
parent
95efa891ab
commit
c6314709ef
@ -82,6 +82,6 @@ body > .bui_window_root {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.active_window {
|
||||
.focus_window {
|
||||
z-index: 1000;
|
||||
}
|
||||
|
@ -99,6 +99,11 @@ function makeResizeable (targetNode, handleNode) {
|
||||
}
|
||||
}
|
||||
|
||||
function focus_window (window_element) {
|
||||
var old_focus = Array.from(document.getElementsByClassName("focus_window"));
|
||||
old_focus.forEach(e => e.classList.remove("focus_window"));
|
||||
window_element.classList.add("focus_window");
|
||||
}
|
||||
|
||||
class buiWindow {
|
||||
constructor (title="", height=100, width=100, min=false, close=true, draggable=true, sizeable=true) {
|
||||
@ -113,6 +118,7 @@ class buiWindow {
|
||||
draggable = "boolean" == typeof draggable ? draggable : true;
|
||||
if (draggable) {
|
||||
makeDraggable(this.root, this.titlebar);
|
||||
this.root.addEventListener("click", this.focus, {useCapture: true});
|
||||
}
|
||||
min = "boolean" == typeof min ? min : false;
|
||||
close = "boolean" == typeof close ? close : false;
|
||||
@ -147,6 +153,8 @@ class buiWindow {
|
||||
this.root.appendChild(this.main);
|
||||
}
|
||||
|
||||
focus () { focus_window(this); }
|
||||
|
||||
minimize () {
|
||||
var current = this.content.style.display == "none" ? "revert" : "none";
|
||||
this.content.style.display = current;
|
||||
|
Loading…
x
Reference in New Issue
Block a user