diff --git a/resources/wde.js b/resources/wde.js index ba614cd..d767a84 100644 --- a/resources/wde.js +++ b/resources/wde.js @@ -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 { + + } + }) + } } /** diff --git a/templates/base/mobile-desktop.tmpl b/templates/base/mobile-desktop.tmpl index e8e11e3..61cbfe8 100644 --- a/templates/base/mobile-desktop.tmpl +++ b/templates/base/mobile-desktop.tmpl @@ -15,7 +15,7 @@
Home
-
+
Close