-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
196 lines (182 loc) · 6.57 KB
/
index.html
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
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<!--meta http-equiv="refresh" content="1;url="-->
<title>Draggable and Risizable Dialog Box</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="ZulNs">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="robots" content="all">
<meta name="copyright" content="ZulNs">
<link rel="icon" href="favicon.svg" type="image/svg+xml" />
<!--link rel="icon" href="favicon.png" type="image/png" /-->
<!--link rel="icon" href="favicon.ico" type="image/x-icon" /-->
<style>
body {
width: 100%;
height: 800px;
font-family: Verdana, sans-serif;
font-size: 12px;
color: #333;
background: #eee;
}
</style>
</head>
<body>
<h1>Draggable and Resizable Dialog Box</h1>
<p>Source: <a href="https://github.com/ZulNs/Draggable-Resizable-Dialog" target="_blank">https://github.com/ZulNs/Draggable-Resizable-Dialog</a></p>
<style>
.show-button {
height: 36px;
font-size: 1.2em;
cursor: pointer;
color: #fff;
background: #39c;
}
.show-button:disabled {
cursor: default;
color: #aaa;
background: #069;
}
.status-bar {
width: 200px;
padding: 6px 8px;
font-size: 1.2em;
color: #fff;
background: #e80;
border: 1px solid #aaa;
}
</style>
<p>To move, start dragging from the title bar of the dialog box.</p>
<p>To resize, start dragging from any edge or any corner of the dialog box.</p>
<!-- First Dialog Box -->
<link rel="stylesheet" href="draggable-resizable-dialog.css" />
<script type="text/javascript" src="draggable-resizable-dialog.js"></script>
<p><button id="show-dialog" class="show-button" onclick="showDialog();">Show Dialog</button></p>
<p id="dialog-status" class="status-bar">Dialog hidden...</p>
<script>
_showDialogButton = document.getElementById('show-dialog');
_statusDialog = document.getElementById('dialog-status');
var dialog;
function showDialog() {
_statusDialog.textContent = 'Dialog showed...';
_showDialogButton.disabled = true;
if (!dialog) {
var id = 'dialog';
// Instanciate the Dialog Box
dialog = new DialogBox(id, callbackDialog);
}
// Show Dialog Box
dialog.showDialog();
// Receive result from Dialog Box
function callbackDialog(btnName) {
_showDialogButton.disabled = false;
_showDialogButton.focus();
if (btnName == 'close')
_statusDialog.textContent = 'Dialog hidden...';
else
_statusDialog.textContent = btnName + ' button clicked...';
}
}
</script>
<!-- The Dialog Box requires elements with class "dialog" "titlebar" and "content" for styling and selection.
If you add buttons you need additional elements with class "buttonpane" and "buttonset".
width and height are optional.
-->
<div id="dialog" class="dialog" style="min-width:400px; min-height:280px;">
<div class="titlebar">Dialog Title...</div>
<button name="close"><!-- enter symbol here like × or 🛈 or use the default X if empty --></button>
<div class="content">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="buttonpane">
<div class="buttonset">
<button name="ok">OK</button>
<button name="cancel">Cancel</button>
</div>
</div>
</div>
<!-- Let's try another Dialog Box with many buttons -->
<p><button id="show-buttons" class="show-button" onclick="showButtons();">Show Buttons</button></p>
<p id="buttons-status" class="status-bar" >Buttons hidden...</p>
<script>
_showButtonsButton = document.getElementById('show-buttons');
_statusButtons = document.getElementById('buttons-status');
var buttonsBox;
function showButtons() {
_statusButtons.textContent = 'Buttons showed...';
_showButtonsButton.disabled = true;
if (!buttonsBox) {
var id = 'buttonsBox';
// Instanciate the Dialog Box
buttonsBox = new DialogBox(id, callbackButtons);
}
// Show DialogBox
buttonsBox.showDialog();
// Receive result from DialogBox
function callbackButtons(btnName) {
_showButtonsButton.disabled = false;
_showButtonsButton.focus();
if (btnName == 'close')
_statusButtons.textContent = 'Buttons hidden...';
else
_statusButtons.textContent = btnName + ' button clicked...';
}
}
</script>
<div id="buttonsBox" class="dialog">
<div class="titlebar">Decision...</div>
<button name="close"><!-- enter symbol here like × or 🛈 or use the default X if empty --></button>
<div class="content">
<p>It's your decision!</p>
</div>
<div class="buttonpane">
<div class="buttonset">
<button name="Button1">Button 1</button>
<button name="Button2">Button 2</button>
<button name="Button3">Button 3</button>
<button name="Button4">Button 4</button>
<button name="Button5">Button 5</button>
<button name="Button6">Button 6</button>
<button name="Button7">Button 7</button>
<button name="Button8">Button 8</button>
<button name="Button9">Button 9</button>
</div>
</div>
</div>
<!-- Finally show a small Info Box with modified styling -->
<p><button id="show-info" class="show-button" onclick="showInfo();">Show Info</button></p>
<script>
var infoBox;
function showInfo() {
if (!infoBox) infoBox = new DialogBox("infoBox");
infoBox.showDialog();
}
</script>
<style>
#infoBox.dialog {
background: #999;
}
#infoBox.dialog .titlebar,
#infoBox.dialog .buttonset button {
background: #4AD;
}
#infoBox.dialog .buttonset button.active {
background: #2b8;
border-color: #eee;
}
</style>
<div id="infoBox" class="dialog">
<div class="titlebar">Info...</div>
<button name="close">🛈</button>
<div class="content"><p>Got it!</p></div>
</div>
<!-- end -->
<p>Have fun!</p>
</body>
</html>