From 61a84681155d2764b105509bf836959a9fe3282e Mon Sep 17 00:00:00 2001 From: Matheus Bastos Date: Wed, 29 Nov 2023 20:03:23 -0300 Subject: [PATCH] dev changes --- lib/apps/configurations/configurations.js | 2 +- lib/components/taskbar/taskbar.js | 15 ++++++- lib/components/window/window.css | 1 - lib/components/window/window.js | 52 ++++++++++++++++++++++- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/lib/apps/configurations/configurations.js b/lib/apps/configurations/configurations.js index 44fdc39..0d57dce 100644 --- a/lib/apps/configurations/configurations.js +++ b/lib/apps/configurations/configurations.js @@ -4,7 +4,7 @@ swdeapp.swdeApp_configuration = function (args) { HTMLELEMENT.innerHTML = `

Configurações

-

Note que o projeto está em desenvolvimento e não está completo.

+

Please note that the project is under development and is not complete. Access the github repository here.

diff --git a/lib/components/taskbar/taskbar.js b/lib/components/taskbar/taskbar.js index ac20d57..37bf093 100644 --- a/lib/components/taskbar/taskbar.js +++ b/lib/components/taskbar/taskbar.js @@ -96,7 +96,6 @@ function taskbarOpenedApps() { let elem = swdeCreateHTML(`
`); - console.log(elem) function getWindow(window) { return document.body.querySelector(String(window)); } @@ -106,6 +105,20 @@ function taskbarOpenedApps() { let icon = selectWindow.querySelector(".swde-window-icon img").src let item = swdeCreateHTML(``) + item.addEventListener("click", () => { + const winstyle = document.querySelector(`${windowid}`).style.display; + + if (winstyle == "block") { + document.querySelector(`${windowid}`).classList.add("windowclosed"); + setTimeout(() => { + document.querySelector(`${windowid}`).classList.remove("windowclosed"); + document.querySelector(`${windowid}`).style.display = "none"; + }, 600) + } else { + document.querySelector(`${windowid}`).style.display = "block"; + } + }) + elem.appendChild(item); } diff --git a/lib/components/window/window.css b/lib/components/window/window.css index 4424b54..ab543ec 100644 --- a/lib/components/window/window.css +++ b/lib/components/window/window.css @@ -85,7 +85,6 @@ } .swde-window-action__minimize { background-color: rgb(238, 224, 146); - display: none; } .swde-window-action__maximize { diff --git a/lib/components/window/window.js b/lib/components/window/window.js index b90ba0b..50e2f28 100644 --- a/lib/components/window/window.js +++ b/lib/components/window/window.js @@ -11,6 +11,7 @@ */ function createWindow (appinfo, args) { const swdewindow = document.createElement("div"); + swdewindow.style = "display: block;"; swdewindow.className = "swde-window"; swdewindow.zIndex = 10; @@ -110,6 +111,21 @@ function createWindow (appinfo, args) { } } + swdewindow.querySelector(".swde-window-action__minimize").addEventListener("click", (e) => { + const targetStyle = e.target.offsetParent.offsetParent.style; + const winstyle = swdewindow.style.display; + + if (winstyle == "block") { + swdewindow.classList.add("windowclosed"); + setTimeout(() => { + swdewindow.classList.remove("windowclosed"); + swdewindow.style.display = "none"; + }, 600) + } else { + swdewindow.style.display = "block"; + } + }) + swdewindow.querySelector(".swde-window-action__maximize").addEventListener("click", (e) => { const targetStyle = e.target.offsetParent.offsetParent.style; toggleFullscreen(targetStyle, "minimize_maximize_btn"); @@ -153,7 +169,38 @@ function createWindow (appinfo, args) { }, true) - document.addEventListener('mouseup', function() { isDown = false; }, true); + document.addEventListener('mouseup', function(event) { + isDown = false; + console.log(swdewindow.style.top) + const normalize = /(%|px|vw|vh)/g + const desktop = { + width: document.querySelector("#desktop").clientWidth, + height: document.querySelector("#desktop").clientHeight, + } + const values = { + top: Number(swdewindow.style.top.replaceAll(normalize, "")), + left: Number(swdewindow.style.left.replaceAll(normalize, "")), + right: Number(swdewindow.style.right.replaceAll(normalize, "")), + bottom: Number(swdewindow.style.bottom.replaceAll(normalize, "")), + width: swdewindow.getBoundingClientRect().width, + } + + /* Window area */ + if (values.top < 0) { swdewindow.style.top = 0; } + if (values.left < 0 - (values.width / 2)) { + swdewindow.style.left = 0; + swdewindow.style.top = 0; + swdewindow.style.width = "50%"; + swdewindow.style.height = "100%"; + } + if (values.left > document.body.clientWidth - values.width) { + swdewindow.style.top = 0; + swdewindow.style.width = "50%"; + swdewindow.style.height = "100%"; + swdewindow.style.left = (document.body.clientWidth - swdewindow.getBoundingClientRect().width) + "px" + } + + }, true); document.addEventListener('mousemove', function(event) { event.preventDefault(); @@ -170,8 +217,11 @@ function createWindow (appinfo, args) { swdewindow.style.left = (mousePosition.x + offset[0]) + 'px'; swdewindow.style.top = (mousePosition.y + offset[1]) + 'px'; + swdewindow.style.width = "70%"; + swdewindow.style.height = "90%"; } + }, true); /**