-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
362 lines (326 loc) · 17.5 KB
/
index.html
File metadata and controls
362 lines (326 loc) · 17.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OS/2 Warp CSS</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="os2-warp.css">
</head>
<body>
<div class="desktop-icon" style="top: 50px; left: 50px;">
<div class="icon-image folder-icon"></div>
<span>Folder</span>
</div>
<div class="desktop-icon" style="top: 150px; left: 50px;">
<div class="icon-image program-icon"></div>
<span>Program</span>
</div>
<!-- Main Window -->
<div class="window active" style="position: absolute; top: 100px; left: 200px; z-index: 2;">
<div class="title-bar">
<div class="title-bar-left">
<div class="title-button system-menu"></div>
<div class="title-bar-text">OS/2 Warp Components</div>
</div>
<div class="title-bar-right">
<div class="title-button hide-button"></div>
<div class="title-button max-button"></div>
</div>
</div>
<div class="menu-bar">
<span><u>F</u>ile</span>
<span><u>E</u>dit</span>
<span><u>H</u>elp</span>
<span><a href="../index.html" style="color: inherit; text-decoration: none;">Home</a></span>
</div>
<div class="window-body">
<div class="content">
<div class="tab-control">
<div class="tab-list">
<div class="tab active" data-tab="1">Controls</div>
<div class="tab" data-tab="2">More Controls</div>
</div>
<div class="tab-panel active" data-tab="1">
<fieldset>
<legend>Group Box</legend>
<p>Here are some controls:</p>
<input type="text" value="Some text...">
<br><br>
<label>
<input type="checkbox" checked>
<span>A Checkbox</span>
</label>
<br><br>
<select>
<option>Choice 1</option>
<option>Choice 2</option>
<option>Choice 3</option>
</select>
</fieldset>
</div>
<div class="tab-panel" data-tab="2">
<p>Disabled controls:</p>
<input type="text" value="Disabled" disabled>
<br><br>
<button disabled>Disabled</button>
</div>
</div>
<br>
<div class="button-bar">
<button class="default" id="showModal">Show Modal</button>
<button>Cancel</button>
</div>
</div>
</div>
<div class="status-bar">
<div class="status-panel">Ready</div>
<div class="status-panel"></div>
</div>
</div>
<!-- Inactive Window -->
<div class="window" style="position: absolute; top: 250px; left: 450px; z-index: 1;">
<div class="title-bar">
<div class="title-bar-left">
<div class="title-button system-menu"></div>
<div class="title-bar-text">Resizable Window</div>
</div>
<div class="title-bar-right">
<div class="title-button hide-button"></div>
<div class="title-button max-button"></div>
</div>
</div>
<div class="window-body">
<div class="content">
<p>This window can be resized.</p>
<p>Drag the borders or corners.</p>
</div>
<div class="resize-handle nw-resize"></div>
<div class="resize-handle n-resize"></div>
<div class="resize-handle ne-resize"></div>
<div class="resize-handle w-resize"></div>
<div class="resize-handle e-resize"></div>
<div class="resize-handle sw-resize"></div>
<div class="resize-handle s-resize"></div>
<div class="resize-handle se-resize"></div>
</div>
<!-- Modal Dialog -->
<div id="modalDialog" class="window"
style="position: absolute; top: 200px; left: 300px; z-index: 100; display: none;">
<div class="title-bar">
<div class="title-bar-left">
<div class="title-button system-menu"></div>
<span class="title-text">Information</span>
</div>
<div class="title-bar-right">
<div class="title-button hide-button"></div>
</div>
</div>
<div class="window-body">
<div class="content">
<div style="display: flex; align-items: center;">
<div class="dialog-icon info-icon"></div>
<p style="margin-left: 10px;">This is an information message from OS/2 Warp.</p>
</div>
<div class="button-bar">
<button class="os2-button default-button" id="closeModal">OK</button>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const windows = document.querySelectorAll('.window');
let topZ = windows.length; // Start z-index from the count of initial windows
const activateWindow = (win) => {
// Only activate if not a modal dialog (which should always be on top)
if (win.id === 'modalDialog') return;
// Remove active class from all non-modal windows
windows.forEach(w => {
if (w.id !== 'modalDialog') {
w.classList.remove('active');
}
});
// Add active class to clicked window
win.classList.add('active');
// Bring window to front
win.style.zIndex = ++topZ;
};
// --- Window Dragging and Activation ---
let isDragging = false;
let dragOffsetX, dragOffsetY;
let currentDragWindow = null;
let isResizing = false;
let resizeHandle = null;
let startX, startY;
let startWidth, startHeight, startLeft, startTop;
let currentResizeWindow = null;
windows.forEach(win => {
const titleBar = win.querySelector('.title-bar');
const resizeHandles = win.querySelectorAll('.resize-handle');
// --- Window Activation ---
// For non-modal windows, activate on mousedown anywhere in the window
if (win.id !== 'modalDialog') {
win.addEventListener('mousedown', () => activateWindow(win));
}
// --- Window Dragging (only for title bars) ---
if (titleBar) { // Ensure titleBar exists
titleBar.addEventListener('mousedown', (e) => {
// Prevent dragging if click is on a title button
if (e.target.closest('.title-button')) {
e.stopPropagation(); // Stop propagation to prevent dragging
return;
}
activateWindow(win); // Activate window on drag start
currentDragWindow = win;
isDragging = true;
dragOffsetX = e.clientX - win.offsetLeft;
dragOffsetY = e.clientY - win.offsetTop;
win.style.cursor = 'move';
e.preventDefault(); // Prevent text selection etc.
});
}
// --- Window Resizing ---
resizeHandles.forEach(handle => {
handle.addEventListener('mousedown', (e) => {
e.stopPropagation(); // Prevent activating window or dragging
activateWindow(win); // Activate window on resize start
currentResizeWindow = win;
isResizing = true;
resizeHandle = handle;
startX = e.clientX;
startY = e.clientY;
startWidth = win.offsetWidth;
startHeight = win.offsetHeight;
startLeft = win.offsetLeft;
startTop = win.offsetTop;
win.style.cursor = handle.style.cursor; // Set resize cursor
e.preventDefault();
});
});
});
document.addEventListener('mousemove', (e) => {
if (isDragging && currentDragWindow) {
let newLeft = e.clientX - dragOffsetX;
let newTop = e.clientY - dragOffsetY;
// Basic boundary checks (don't drag off screen entirely)
if (newLeft < -currentDragWindow.offsetWidth + 50) newLeft = -currentDragWindow.offsetWidth + 50;
if (newTop < -currentDragWindow.offsetHeight + 50) newTop = -currentDragWindow.offsetHeight + 50;
if (newLeft > window.innerWidth - 50) newLeft = window.innerWidth - 50;
if (newTop > window.innerHeight - 50) newTop = window.innerHeight - 50;
currentDragWindow.style.left = newLeft + 'px';
currentDragWindow.style.top = newTop + 'px';
} else if (isResizing && currentResizeWindow) {
const minWidth = 200;
const minHeight = 100;
let newWidth = startWidth;
let newHeight = startHeight;
let newLeft = startLeft;
let newTop = startTop;
const deltaX = e.clientX - startX;
const deltaY = e.clientY - startY;
if (resizeHandle.classList.contains('e-resize')) {
newWidth = Math.max(minWidth, startWidth + deltaX);
}
if (resizeHandle.classList.contains('s-resize')) {
newHeight = Math.max(minHeight, startHeight + deltaY);
}
if (resizeHandle.classList.contains('w-resize')) {
newWidth = Math.max(minWidth, startWidth - deltaX);
if (newWidth === minWidth) {
newLeft = startLeft + startWidth - minWidth;
} else {
newLeft = startLeft + deltaX;
}
}
if (resizeHandle.classList.contains('n-resize')) {
newHeight = Math.max(minHeight, startHeight - deltaY);
if (newHeight === minHeight) {
newTop = startTop + startHeight - minHeight;
} else {
newTop = startTop + deltaY;
}
}
if (resizeHandle.classList.contains('se-resize')) {
newWidth = Math.max(minWidth, startWidth + deltaX);
newHeight = Math.max(minHeight, startHeight + deltaY);
}
if (resizeHandle.classList.contains('sw-resize')) {
newWidth = Math.max(minWidth, startWidth - deltaX);
newHeight = Math.max(minHeight, startHeight + deltaY);
if (newWidth === minWidth) newLeft = startLeft + startWidth - minWidth;
else newLeft = startLeft + deltaX;
}
if (resizeHandle.classList.contains('ne-resize')) {
newWidth = Math.max(minWidth, startWidth + deltaX);
newHeight = Math.max(minHeight, startHeight - deltaY);
if (newHeight === minHeight) newTop = startTop + startHeight - minHeight;
else newTop = startTop + deltaY;
}
if (resizeHandle.classList.contains('nw-resize')) {
newWidth = Math.max(minWidth, startWidth - deltaX);
newHeight = Math.max(minHeight, startHeight - deltaY);
if (newWidth === minWidth) newLeft = startLeft + startWidth - minWidth;
else newLeft = startLeft + deltaX;
if (newHeight === minHeight) newTop = startTop + startHeight - minHeight;
else newTop = startTop + deltaY;
}
currentResizeWindow.style.width = newWidth + 'px';
currentResizeWindow.style.height = newHeight + 'px';
currentResizeWindow.style.left = newLeft + 'px';
currentResizeWindow.style.top = newTop + 'px';
}
});
document.addEventListener('mouseup', () => {
if (isDragging) {
isDragging = false;
if (currentDragWindow) {
currentDragWindow.style.cursor = 'grab'; // Reset cursor
currentDragWindow = null;
}
}
if (isResizing) {
isResizing = false;
if (currentResizeWindow) {
currentResizeWindow.style.cursor = 'default'; // Reset cursor
resizeHandle = null;
currentResizeWindow = null;
}
}
});
// --- Tab Switching ---
document.querySelectorAll('.tab-control').forEach(tabControl => {
const tabs = tabControl.querySelectorAll('.tab');
const tabPanels = tabControl.querySelectorAll('.tab-panel');
tabs.forEach(tab => {
tab.addEventListener('click', (e) => {
const tabId = e.target.dataset.tab;
tabs.forEach(t => t.classList.remove('active'));
tabPanels.forEach(p => p.classList.remove('active'));
e.target.classList.add('active');
tabControl.querySelector(`.tab-panel[data-tab="${tabId}"]`).classList.add('active');
});
});
});
// --- Modal Dialog Logic ---
const modalDialog = document.getElementById('modalDialog');
const showModalButton = document.getElementById('showModal');
const closeModalButton = document.getElementById('closeModal');
if (showModalButton) {
showModalButton.addEventListener('click', () => {
modalDialog.style.display = 'flex'; // Show modal
modalDialog.style.zIndex = ++topZ; // Bring to front
modalDialog.classList.add('active'); // Make it active (even though it's always top)
});
}
if (closeModalButton) {
closeModalButton.addEventListener('click', () => {
modalDialog.style.display = 'none'; // Hide modal
modalDialog.classList.remove('active'); // Remove active class
});
}
});
</script>
</body>
</html>