-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
412 lines (356 loc) · 17.4 KB
/
index.html
File metadata and controls
412 lines (356 loc) · 17.4 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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WindowMaker.css Demo</title>
<link rel="stylesheet" href="NeXTSTEP.css">
</head>
<body>
<div class="window">
<div class="title-bar">
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
<div class="title-bar-text">Window Title</div>
<div class="title-bar-controls">
<button aria-label="Maximize"></button>
<button aria-label="Minimize"></button>
</div>
</div>
<div class="window-body">
<p>This is the content of the window.</p>
<br>
<input type="text" value="Text input field"><br><br>
<label>
<input type="checkbox" checked> Checkbox
</label><br><br>
<div>
<label>
<input type="radio" name="radio-group" checked> Radio 1
</label>
<label>
<input type="radio" name="radio-group"> Radio 2
</label>
</div><br>
<select>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select><br><br>
<textarea rows="4"
cols="40">This is a NeXTSTEP-style textarea. You can type multiple lines here.</textarea><br><br>
<div style="height: 100px; overflow: auto; border: 1px solid #7B7B7B; padding: 5px;">
<p>This is some scrollable content to demonstrate the custom scrollbars.</p>
<p>Line 1</p>
<p>Line 2</p>
<p>Line 3</p>
<p>Line 4</p>
<p>Line 5</p>
<p>Line 6</p>
<p>Line 7</p>
<p>Line 8</p>
<p>Line 9</p>
<p>Line 10</p>
</div><br>
<div class="ns-tabs">
<div class="ns-tab-headers">
<button class="ns-tab-button ns-tab-active" data-tab="tab1">Tab 1</button>
<button class="ns-tab-button" data-tab="tab2">Tab 2</button>
</div>
<div class="ns-tab-content">
<div id="tab1" class="ns-tab-pane ns-tab-active">
<p>Content for Tab 1. This is the first tab pane.</p>
</div>
<div id="tab2" class="ns-tab-pane">
<p>Content for Tab 2. This is the second tab pane.</p>
</div>
</div>
</div><br>
<div class="ns-progress-bar">
<div class="ns-progress-fill" style="width: 50%;"></div>
</div><br>
<p style="text-align: center;">
<button class="ns-button">OK</button>
<button class="ns-button" id="show-alert-button">Show Alert</button>
<button class="ns-button" onclick="window.location.href='../index.html'">Back to Gallery</button>
</p>
</div>
<div class="ns-resize-handle"></div>
</div>
<div class="ns-modal-overlay" style="display: none;"></div>
<div class="alert-dialog window" style="display: none;">
<div class="title-bar">
<div class="title-bar-controls">
<button aria-label="Close"></button>
</div>
<div class="title-bar-text">Alert!</div>
<div class="title-bar-controls">
<button aria-label="Maximize"></button>
<button aria-label="Minimize"></button>
</div>
</div>
<div class="window-body" style="text-align: center;">
<p>This is a NeXTSTEP-style alert message.</p>
<br>
<button id="alert-ok-button">OK</button>
</div>
</div>
<div class="ns-dock">
<div class="ns-dock-icon">
<div class="ns-icon-image"></div>
<div class="ns-icon-title">Icon 1</div>
</div>
<div class="ns-dock-icon">
<div class="ns-icon-image"></div>
<div class="ns-icon-title">Icon 2</div>
</div>
</div>
<div class="ns-desktop-icon" style="top: 20px; left: 20px;">
<div class="ns-icon-image"></div>
<div class="ns-icon-title">My App</div>
</div>
<div class="ns-desktop-icon" style="top: 100px; left: 20px;">
<div class="ns-icon-image"></div>
<div class="ns-icon-title">Files</div>
</div>
<div class="ns-menu" id="context-menu" style="display: none;">
<ul>
<li><a href="#">Menu Item 1</a></li>
<li><a href="#">Another Item</a></li>
<li class="separator">
<hr>
</li>
<li><a href="#">A Third One</a></li>
</ul>
</div>
<div class="ns-window-menu ns-menu" id="window-context-menu" style="display: none;">
<ul>
<li class="ns-menu-minimize"><a href="#">Minimize</a></li>
<li class="ns-menu-maximize"><a href="#">Maximize</a></li>
<li class="separator">
<hr>
</li>
<li class="ns-menu-close"><a href="#">Close</a></li>
</ul>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const menu = document.getElementById('context-menu');
let windowCounter = 0;
document.body.addEventListener('contextmenu', (e) => {
e.preventDefault();
menu.style.display = 'block';
menu.style.left = e.pageX + 'px';
menu.style.top = e.pageY + 'px';
});
document.addEventListener('click', (e) => {
if (menu.style.display === 'block') {
menu.style.display = 'none';
}
});
// Function to set a window as active
const activateWindow = (targetWindow) => {
document.querySelectorAll('.ns-window').forEach(win => {
win.classList.remove('ns-window-active');
win.style.zIndex = 10; // Default z-index for inactive
});
targetWindow.classList.add('ns-window-active');
targetWindow.style.zIndex = 20; // Bring to front
};
// Function to set up dragging, resizing, and activation for a given window
const setupWindowInteractions = (windowElement) => {
const titleBar = windowElement.querySelector('.ns-title-bar');
let isDragging = false;
let offsetX, offsetY;
// Activate the window on any click within it
windowElement.addEventListener('mousedown', () => activateWindow(windowElement));
titleBar.addEventListener('mousedown', (e) => {
isDragging = true;
offsetX = e.clientX - windowElement.getBoundingClientRect().left;
offsetY = e.clientY - windowElement.getBoundingClientRect().top;
windowElement.style.cursor = 'grabbing';
});
document.addEventListener('mousemove', (e) => {
if (!isDragging) return;
windowElement.style.left = (e.clientX - offsetX) + 'px';
windowElement.style.top = (e.clientY - offsetY) + 'px';
});
document.addEventListener('mouseup', () => {
isDragging = false;
windowElement.style.cursor = 'grab';
});
// Resizing functionality
const resizeHandle = windowElement.querySelector('.ns-resize-handle');
let isResizing = false;
let initialX, initialY, initialWidth, initialHeight;
resizeHandle.addEventListener('mousedown', (e) => {
e.stopPropagation(); // Prevent dragging from starting
isResizing = true;
initialX = e.clientX;
initialY = e.clientY;
initialWidth = windowElement.offsetWidth;
initialHeight = windowElement.offsetHeight;
windowElement.style.cursor = 'se-resize';
});
document.addEventListener('mousemove', (e) => {
if (!isResizing) return;
const newWidth = initialWidth + (e.clientX - initialX);
const newHeight = initialHeight + (e.clientY - initialY);
// Set minimum width and height
windowElement.style.width = Math.max(newWidth, 200) + 'px';
windowElement.style.height = Math.max(newHeight, 100) + 'px';
});
document.addEventListener('mouseup', () => {
isResizing = false;
windowElement.style.cursor = 'default';
});
// Minimize/Maximize/Restore functionality
const minimizeButton = windowElement.querySelector('.ns-button-minimize');
const maximizeButton = windowElement.querySelector('.ns-button-maximize');
let isMaximized = false;
let originalWindowRect = {}; // To store position and size before maximizing
minimizeButton.addEventListener('click', (e) => {
e.stopPropagation(); // Prevent activating window
windowElement.style.display = 'none';
// In a real scenario, you'd add this to a taskbar
});
maximizeButton.addEventListener('click', (e) => {
e.stopPropagation(); // Prevent activating window
if (isMaximized) {
// Restore
windowElement.style.top = originalWindowRect.top + 'px';
windowElement.style.left = originalWindowRect.left + 'px';
windowElement.style.width = originalWindowRect.width + 'px';
windowElement.style.height = originalWindowRect.height + 'px';
isMaximized = false;
} else {
// Maximize
originalWindowRect = {
top: windowElement.offsetTop,
left: windowElement.offsetLeft,
width: windowElement.offsetWidth,
height: windowElement.offsetHeight
};
windowElement.style.top = '0';
windowElement.style.left = '0';
windowElement.style.width = '100vw'; // Viewport width
windowElement.style.height = '100vh'; // Viewport height
isMaximized = true;
}
});
// Window Context Menu
const windowContextMenu = document.getElementById('window-context-menu');
titleBar.addEventListener('contextmenu', (e) => {
e.preventDefault();
e.stopPropagation(); // Prevent desktop context menu
windowContextMenu.style.display = 'block';
windowContextMenu.style.left = e.pageX + 'px';
windowContextMenu.style.top = e.pageY + 'px';
// Attach actions to menu items
windowContextMenu.querySelector('.ns-menu-minimize').onclick = () => { minimizeButton.click(); windowContextMenu.style.display = 'none'; };
windowContextMenu.querySelector('.ns-menu-maximize').onclick = () => { maximizeButton.click(); windowContextMenu.style.display = 'none'; };
windowContextMenu.querySelector('.ns-menu-close').onclick = () => { windowElement.remove(); windowContextMenu.style.display = 'none'; };
});
document.addEventListener('click', () => {
if (windowContextMenu.style.display === 'block') {
windowContextMenu.style.display = 'none';
}
});
};
// Function to create a new window
const createWindow = (title, contentHtml) => {
windowCounter++;
const newWindow = document.createElement('div');
newWindow.className = 'ns-window';
newWindow.id = `window-${windowCounter}`;
newWindow.style.left = `${50 + (windowCounter * 20)}px`; // Offset new windows
newWindow.style.top = `${50 + (windowCounter * 20)}px`;
newWindow.innerHTML = `
<div class="ns-title-bar">
<div class="ns-button-close"></div>
<div class="ns-title"><span>${title}</span></div>
<div class="ns-button-maximize"></div>
<div class="ns-button-minimize"></div>
</div>
<div class="ns-content">
${contentHtml}
</div>
<div class="ns-resize-handle"></div>
`;
document.body.appendChild(newWindow);
setupWindowInteractions(newWindow);
activateWindow(newWindow);
};
// Setup interactions for the initial window
setupWindowInteractions(document.querySelector('.ns-window'));
activateWindow(document.querySelector('.ns-window'));
// Dock icon click handlers
document.querySelectorAll('.ns-dock-icon').forEach((icon, index) => {
icon.addEventListener('click', () => {
createWindow(`Dock App ${index + 1}`, `<p>This is content for dock app ${index + 1}.</p><p style="text-align: center;"><button class="ns-button">Launch</button></p>`);
});
});
// Desktop icon click handlers
document.querySelectorAll('.ns-desktop-icon').forEach((icon, index) => {
icon.addEventListener('click', () => {
createWindow(`Desktop App ${index + 1}`, `<p>This is content for desktop app ${index + 1}.</p><p style="text-align: center;"><button class="ns-button">Open</button></p>`);
});
});
// Add functionality for close buttons (delegation for dynamically created windows)
document.addEventListener('click', (e) => {
if (e.target.classList.contains('ns-button-close')) {
const windowToClose = e.target.closest('.ns-window');
if (windowToClose) {
windowToClose.remove();
}
}
});
// Alert Dialog functionality
const alertDialog = document.querySelector('.ns-alert-dialog');
const modalOverlay = document.querySelector('.ns-modal-overlay');
const showAlertButton = document.getElementById('show-alert-button');
const alertOkButton = document.getElementById('alert-ok-button');
// Function to close the alert dialog
const closeAlertDialog = () => {
modalOverlay.style.display = 'none';
alertDialog.style.display = 'none';
};
if (showAlertButton) {
showAlertButton.addEventListener('click', () => {
modalOverlay.style.display = 'block';
alertDialog.style.display = 'block';
});
}
if (alertOkButton) {
alertOkButton.addEventListener('click', (e) => {
e.stopPropagation(); // Prevent other click listeners from interfering
closeAlertDialog();
});
}
// Also close dialog if its own close button is clicked (delegation)
document.addEventListener('click', (e) => {
if (e.target.closest('.ns-alert-dialog') && e.target.classList.contains('ns-button-close')) {
e.stopPropagation(); // Prevent other click listeners from interfering
closeAlertDialog();
}
});
// Tab switching functionality
document.querySelectorAll('.ns-tabs').forEach(tabContainer => {
tabContainer.querySelectorAll('.ns-tab-button').forEach(button => {
button.addEventListener('click', () => {
// Deactivate all buttons and panes in this container
tabContainer.querySelectorAll('.ns-tab-button').forEach(btn => btn.classList.remove('ns-tab-active'));
tabContainer.querySelectorAll('.ns-tab-pane').forEach(pane => pane.classList.remove('ns-tab-active'));
// Activate clicked button
button.classList.add('ns-tab-active');
// Activate corresponding pane
const targetTabId = button.dataset.tab;
tabContainer.querySelector(`#${targetTabId}`).classList.add('ns-tab-active');
});
});
});
});
</script>
</body>
</html>