From 02270091eb1765c4246f16d3f8c02f8b341e8b57 Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Thu, 24 Mar 2022 15:45:58 -0600 Subject: [PATCH] window class added, not functional --- libs/blueui.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/libs/blueui.js b/libs/blueui.js index bf0c62f..9fece6d 100644 --- a/libs/blueui.js +++ b/libs/blueui.js @@ -28,9 +28,67 @@ class buiButton { constructor (name, myFunction) { this.root = document.createElement("span"); this.lable = document.createElement("span"); - this.root.setAttribute("class","bui_button_root"); + this.root.setAttribute("class","bui_button_root"+("string" == typeof name ? " "+name+"_button" : "")); this.lable.setAttribute("class","bui_button_lable"); + this.lable.innerText = "string" == typeof name ? name : ""; this.root.appendChild(this.lable); this.root.addEventListener("click", "function" == typeof myFunction ? myFunction : () => {}); } } + +function makeDraggable (targetNode, handleNode) {} + +function makeResizeable (targetNode, handleNode) {} + + +class buiWindow { + constructor (title="", height=100, width=100, min=false, close=true, dragable=true, sizeable=true) { + this.root = document.createElement("div"); + this.root.setAttribute("class","bui_window_root"); + this.titlebar = document.createElement("div"); + this.titlebar.setAttribute("class","bui_window_titlebar"); + this.title = document.createElement("span"); + this.title.setAttribute("class","bui_window_title"); + this.title.innerText = "string" == title ? title : ""; + this.titlebar.appendChild(this.title); + draggable = "boolean" == typeof draggable ? draggable : true; + if (draggable) { + makeDraggable(this.root, this.titlebar); + } + min = "boolean" == typeof min ? min : false; + close = "boolean" == typeof close ? close : false; + if (min || close) { + this.controls = document.createElement("span"); + this.controls.setAttribute("class","bui_window_controls"); + if (min) { + this.minimizeButton = new buiButton("_",this.minimize); + this.controls.appendChild(this.minimizeButton.root); + } + if (close) { + this.closeButton = new buiButton("X",this.close); + this.controls.appendChild(this.closeButton.root) + } + this.titlebar.appendChild(this.controls); + } + this.main = document.createElement("div"); + this.main.setAttribute("class","bui_window_main"); + this.content = document.createElement("div"); + this.content.setAttribute("class","bui_window_content"); + this.main.appendChild(this.content); + sizeable = "boolean" == typeof sizeable ? sizeable : true; + if (sizeable) { + this.resizeHandle = document.createElement("div"); + this.resizeHandle.setAttribute("class","bui_window_resize_handle"); + makeResizeable(this.content, this.resizeHandle); + this.main.appendChild(this.resizeHandle); + } + this.root.appendChild(this.titlebar); + this.root.appendChild(this.content); + } + + function minimize () { + } + + function close () { + } +}