Skip to content

Commit

Permalink
dev changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mblithium committed Nov 29, 2023
1 parent c11fbaa commit 61a8468
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/apps/configurations/configurations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ swdeapp.swdeApp_configuration = function (args) {

HTMLELEMENT.innerHTML = `
<h1>Configurações</h1>
<p>Note que o projeto está em desenvolvimento e não está completo.</p>
<p>Please note that the project is under development and is not complete. Access the github repository <a href="https://github.com/mblithium/SpaceWebDE" target="_blank">here</a>.</p>
<label name="swdeAppConfig_wallpaper">
Wallpaper:
</label>
Expand Down
15 changes: 14 additions & 1 deletion lib/components/taskbar/taskbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ function taskbarOpenedApps() {
let elem = swdeCreateHTML(`
<div class="openedapps"></div>
`);
console.log(elem)

function getWindow(window) { return document.body.querySelector(String(window)); }

Expand All @@ -106,6 +105,20 @@ function taskbarOpenedApps() {
let icon = selectWindow.querySelector(".swde-window-icon img").src
let item = swdeCreateHTML(`<img src="${icon}">`)

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);
}

Expand Down
1 change: 0 additions & 1 deletion lib/components/window/window.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
}
.swde-window-action__minimize {
background-color: rgb(238, 224, 146);
display: none;
}

.swde-window-action__maximize {
Expand Down
52 changes: 51 additions & 1 deletion lib/components/window/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
function createWindow (appinfo, args) {
const swdewindow = document.createElement("div");
swdewindow.style = "display: block;";
swdewindow.className = "swde-window";
swdewindow.zIndex = 10;

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand All @@ -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);

/**
Expand Down

0 comments on commit 61a8468

Please sign in to comment.