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

View File

@ -15,7 +15,7 @@
<div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/desktop.png');"></div> <div class="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/desktop.png');"></div>
<div class="FileTileTitle NoClick">Home</div> <div class="FileTileTitle NoClick">Home</div>
</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="FileTileIcon NoClick" style="background-image: url('./res/sys/wde/icons/trash.png');"></div>
<div class="FileTileTitle NoClick">Close</div> <div class="FileTileTitle NoClick">Close</div>
</div> </div>