-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.html
246 lines (219 loc) · 7.28 KB
/
demo.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
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>jQuery Doom Windows</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="assets/doom_windows_style.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript" src="assets/jquery.doomWindows.js"></script>
</head>
<body>
<h1>jQuery Doom Windows</h1>
<h2>How To</h2>
<ol>
<li>Include the doom_windows_style.css style</li>
<li>Include the jquery.doomWindows.js file</li>
<li>Make windows: dWindow('<img src="http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=14&size=400x400&sensor=false" alt="Google Maps" width="400" height="400" />')</li>
</ol>
<h2>Examples and implementation</h2>
<h3>View Google Maps window</h3>
<p><button id="view-map-bt">View map</button></p>
<pre>
$('#view-map-bt').click(function () {
dWindow('<img src="http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=14&size=400x400&sensor=false"
alt="Google Maps" width="400" height="400" />');
});
</pre>
<p>or:</p>
<pre>
$('#view-map-bt').click(function () {
$('<img src="http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=14&size=400x400&sensor=false"
alt="Google Maps" width="400" height="400" />').doomWindows({buttons:false, buttonClick: function (btType, win) {btType === 'close' && win.close();}});
});
</pre>
<h3>Confirm window</h3>
<p><button id="delete-bt">Delete item</button></p>
<pre>
$('#view-map-bt').click(function () {
dConfirm('Are you sure you want to delete this item?', function (btType, win) {
(btType === 'no' || btType === 'close') && win.close();
if (btType === 'yes') {
// some ajax to delete item here
win.close();
dAlert('Item deleted!');
}
});
});
</pre>
<h3>Alert window</h3>
<p><button id="alert-bt">Rase an error</button></p>
<pre>
$('#alert-bt').click(function () {
dAlert('Omg! A fake error occured! Do not panic!');
});
</pre>
<h3>Load remote content with Ajax</h3>
<p><a href="remote_example.html" id="remote-bt" titl="Load Sign In form">Display remote data</a></p>
<pre>
$('#remote-bt').click(function () {
dWindow(false, {
ajaxUrl: $(this).attr('href'),
cacheAjaxResult: true,
wrapperId: 'log-in-window',
minHeight: 317,
minWidth: 430
});
return false;
});
</pre>
<h2>Options</h2>
<dl>
<dt><b>styles</b> ({position: 'absolute', 'z-index': 999, top: false, left: false}):</dt>
<dd>
Window default styles.
</dd>
<dt><b>width</b> ('auto'):</dt>
<dd>
Set up a custom width of the window.
</dd>
<dt><b>height</b> ('auto'):</dt>
<dd>
Set up a custom height of the window.
</dd>
<dt><b>minWidth</b> ('auto'):</dt>
<dd>
Set up a custom min-width style.
</dd>
<dt><b>minHeight</b> ('auto'):</dt>
<dd>
Set up a custom min-height style.
</dd>
<dt><b>overlay:</b> (true):</dt>
<dd>
Show or hide window overlay.
</dd>
<dt><b>wrapp:</b> (true):</dt>
<dd>
Buy default the content is wrapped in a div of 'doom-win' class.
</dd>
<dt><b>wrapperClass</b> ('doom-win'):</dt>
<dd>
Set the deafult wrapper class.
</dd>
<dt><b>wrapperId</b> (false):</dt>
<dd>
Give a unique id to your window so it's easier to style it.
</dd>
<dt><b>wrapperHtml</b> ('<div><div class="doom-win-content"></div></div>'):</dt>
<dd>
Set up a custom html window wrapper.
</dd>
<dt><b>buttons</b> ({ok:'Ok'}):</dt>
<dd>
Bottom buttons and button text.
</dd>
<dt><b>headerButtons</b> ({close:'Close'}):</dt>
<dd>
Header buttons and button text.
</dd>
<dt><b>buttonsTranslate</b> ([]):</dt>
<dd>
Text translate for buttons.
</dd>
<dt><b>buttonsTranslate</b> ('<div class="doom-win-bt-cnt-header"><ul class="doom-win-bt-list">{buttons}</ul></div>'):</dt>
<dd>
Header buttons html wrapper structure.
</dd>
<dt><b>buttonsWrapperHtml</b> ('<div class="doom-win-bt-cnt"><ul class="doom-win-bt-list">{buttons}</ul></div>'):</dt>
<dd>
Bottom buttons html wrapper structure.
</dd>
<dt><b>buttonHtml</b> ('<li class="doom-win-bt-{buttonType}"><button data-type="{buttonType}"><span>{buttonText}</span></button></li>'):</dt>
<dd>
Message button HTML structure.
</dd>
<dt><b>buttonClick</b> (null):</dt>
<dd>
A callback function when for all the buttons. Get the buttons key (ok, close, yes, no) and the window object as args. I.e.: function (btType, win) {btType === 'close' && win.close();}
</dd>
<dt><b>eventsNamespace</b> (null):</dt>
<dd>
A namespace for the gobal window events. Normally it's preffiled automatically on window create and it's unique for each window.
</dd>
<dt><b>closeOnEsc</b> (true):</dt>
<dd>
Close window on Escape keyboard button click.
</dd>
<dt><b>onClose</b> (null):</dt>
<dd>
Callback on window close.
</dd>
<dt><b>onEsc</b> (function () {$(this).close();}):</dt>
<dd>
Callback for closing window on Esc button hit.
</dd>
<dt><b>closeOnSideClick</b> (true):</dt>
<dd>
Close window on overlay click.
</dd>
<dt><b>onSideClick</b> (function () {$(this).close();}):</dt>
<dd>
Callback for closing window on overlay click.
</dd>
<dt><b>ajaxUrl</b> (null):</dt>
<dd>
Set the ajax url if you want to load content remotely.
</dd>
<dt><b>afterAjax</b> (null, winContent):</dt>
<dd>
After ajax callback function. Gets the ajax response and the window container as args.
</dd>
<dt><b>ajaxData</b> (null):</dt>
<dd>
Set some custome request query params for ajax.
</dd>
<dt><b>cacheAjaxResult</b> (false):</dt>
<dd>
Set this if you want the ajax content to be cached in the browser.
</dd>
<dt><b>onShow</b> (null):</dt>
<dd>
Callback function after the window is created and displayed.
</dd>
</dl>
<script type="text/javascript">
$(document).ready(function () {
// Show Google Maps in a window
$('#view-map-bt').click(function () {
dWindow('<img src="http://maps.google.com/maps/api/staticmap?center=40.714728,-73.998672&zoom=14&size=400x400&sensor=false" alt="Google Maps" width="400" height="400" />');
});
// Confirm item deletion
$('#delete-bt').click(function () {
dConfirm('Are you sure you want to delete this item?', function (btType, win) {
(btType === 'no' || btType === 'close') && win.close();
if (btType === 'yes') {
// some ajax to delete item here
win.close();
dAlert('Item deleted!');
}
});
});
// Alert a error message
$('#alert-bt').click(function () {
dAlert('Omg! A fake error occured! Do not panic!');
});
// Load remote content with Ajax
$('#remote-bt').click(function () {
dWindow(false, {
ajaxUrl: $(this).attr('href'),
cacheAjaxResult: true,
wrapperId: 'log-in-window',
minHeight: 317,
minWidth: 430
});
return false;
});
});
</script>
</body>
</html>