diff --git a/dist/bundle.js b/dist/bundle.js index b4aa191..6720593 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -76,7 +76,6 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac \*******************************/ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { - eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ WindowManager: () => (/* binding */ WindowManager)\n/* harmony export */ });\n/* harmony import */ var _utils_svg__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils/svg */ \"./src/utils/svg.js\");\n\r\n\r\nclass WindowManager {\r\n constructor() {\r\n this.desktop = document.getElementById('desktop');\r\n }\r\n\r\n createWindow(title, url) {\r\n const windowFrame = document.createElement('div');\r\n windowFrame.className = 'window-frame container-fill';\r\n // @TODO\r\n windowFrame.style.position = 'absolute';\r\n// windowFrame.style.top = '10%';\r\n// windowFrame.style.left = '10%';\r\n\r\n\r\n\r\n const titleBar = document.createElement('div');\r\n titleBar.className = 'title-bar';\r\n\r\n const titleText = document.createElement('span');\r\n titleText.className = 'title-text';\r\n titleText.textContent = title;\r\n\r\n const controls = document.createElement('div');\r\n controls.className = 'window-controls';\r\n\r\n const minimizeBtn = document.createElement('button');\r\n minimizeBtn.className = 'minimize-btn';\r\n minimizeBtn.innerHTML = _utils_svg__WEBPACK_IMPORTED_MODULE_0__.svgMinimize;\r\n minimizeBtn.onclick = () => {\r\n windowFrame.classList.toggle('minimized');\r\n };\r\n\r\n const maximizeBtn = document.createElement('button');\r\n maximizeBtn.className = 'maximize-btn';\r\n maximizeBtn.innerHTML = _utils_svg__WEBPACK_IMPORTED_MODULE_0__.svgMaximize;\r\n maximizeBtn.onclick = () => {\r\n windowFrame.classList.toggle('maximized');\r\n };\r\n\r\n const closeBtn = document.createElement('button');\r\n closeBtn.className = 'close-btn';\r\n closeBtn.innerHTML = _utils_svg__WEBPACK_IMPORTED_MODULE_0__.svgClose;\r\n closeBtn.onclick = () => {\r\n this.desktop.removeChild(windowFrame);\r\n };\r\n\r\n controls.appendChild(minimizeBtn);\r\n controls.appendChild(maximizeBtn);\r\n controls.appendChild(closeBtn);\r\n\r\n titleBar.appendChild(titleText);\r\n titleBar.appendChild(controls);\r\n\r\n const contentFrame = document.createElement('iframe');\r\n contentFrame.className = 'content-frame';\r\n contentFrame.src = url;\r\n\r\n windowFrame.appendChild(titleBar);\r\n windowFrame.appendChild(contentFrame);\r\n\r\n this.desktop.appendChild(windowFrame);\r\n\r\n this.makeWindowDraggable(windowFrame, titleBar);\r\n }\r\n\r\n makeWindowDraggable(windowFrame, titleBar) {\r\n let isDragging = false;\r\n let offsetX, offsetY;\r\n\r\n titleBar.addEventListener('mousedown', (e) => {\r\n isDragging = true;\r\n offsetX = e.clientX - windowFrame.getBoundingClientRect().left;\r\n offsetY = e.clientY - windowFrame.getBoundingClientRect().top;\r\n document.addEventListener('mousemove', onMouseMove);\r\n document.addEventListener('mouseup', onMouseUp);\r\n });\r\n\r\n const onMouseMove = (e) => {\r\n if (isDragging) {\r\n windowFrame.style.left = `${e.clientX - offsetX}px`;\r\n windowFrame.style.top = `${e.clientY - offsetY}px`;\r\n }\r\n };\r\n\r\n const onMouseUp = () => {\r\n isDragging = false;\r\n document.removeEventListener('mousemove', onMouseMove);\r\n document.removeEventListener('mouseup', onMouseUp);\r\n };\r\n }\r\n}\r\n\n\n//# sourceURL=webpack://astroos/./src/window_manager.js?"); /***/ })