Working close button

This commit is contained in:
cyber-dream 2023-04-13 21:28:37 +03:00
parent 10a7cf9301
commit c1bed6e2cd
2 changed files with 32 additions and 20 deletions

View File

@ -32,12 +32,16 @@ class WebDesktopEnvironment{
.then((html) => {
mobileDesktop.innerHTML = html
WebDesktopEnvironment.LoadApp("finder", () =>{
console.log("lel")
new FileView("/kek", mobileDesktop.querySelector(".FileTileView"), Finder.Click)
mobileDesktop.querySelector('#about-me').addEventListener('click', (event) => {
//TODO Do not allow launch second instance
WebDesktopEnvironment.Open("personal-properties", [])
})
mobileDesktop.querySelector('#mobile-dekstop-close').addEventListener('click', (event) => {
// console.log('close')
WebDesktopEnvironment.CloseFocusedWindow()
})
})
})
.catch((error) => {
@ -137,6 +141,12 @@ class WebDesktopEnvironment{
window.remove()
}
static CloseFocusedWindow() {
if (document.body.querySelector('#windows-layer').childElementCount > 1){
document.body.querySelector('#windows-layer').lastElementChild.remove()
}
}
/**
* @param {string} html
*/
@ -189,27 +199,29 @@ class WindowsCompositor{
//TODO refactor this to dynamic add/remove listeners
constructor(){
this.windowLayer = document.body.querySelector('#windows-layer')
addEventListener("mousedown", (event) => {
this.xPosInit = event.offsetX
this.yPosInit = event.offsetY
if (!WebDesktopEnvironment.isMobile) {
addEventListener("mousedown", (event) => {
this.xPosInit = event.offsetX
this.yPosInit = event.offsetY
this.bringWindowToFront(event.target.closest('.StandartApplicationWindow'))
this.bringWindowToFront(event.target.closest('.StandartApplicationWindow'))
this.catchClick(event)
this.catchClick(event)
})
addEventListener("mouseup", (event) => {
this.movingElement = null
this.xPosInit = 0
})
addEventListener("mousemove", (event) => {
if (this.movingElement != null) {
this.dragElement(this.movingElement, event.clientX - this.xPosInit, event.clientY - this.yPosInit)
} else {
}
})
})
addEventListener("mouseup", (event) => {
this.movingElement = null
this.xPosInit = 0
})
addEventListener("mousemove", (event) => {
if (this.movingElement != null) {
this.dragElement(this.movingElement, event.clientX - this.xPosInit, event.clientY - this.yPosInit)
} else {
}
})
}
}
/**

View File

@ -15,7 +15,7 @@
<div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/desktop.png');"></div>
<div class="FileTileTitle NoClick">Home</div>
</div>
<div id="Home" class="FileTile">
<div id="mobile-dekstop-close" class="FileTile">
<div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/trash.png');"></div>
<div class="FileTileTitle NoClick">Close</div>
</div>