forked from kylefox/jquery-modal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
382 lines (306 loc) · 13.2 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
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
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../jquery.modal.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="../jquery.modal.css" type="text/css" media="screen" />
<script src="highlight/highlight.pack.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8"> hljs.initHighlightingOnLoad(); </script>
<link rel="stylesheet" href="highlight/github.css" type="text/css" media="screen" />
<link href='http://fonts.googleapis.com/css?family=Roboto:300,700' rel='stylesheet' type='text/css'>
<style type="text/css" media="screen">
html { background: #ddd; }
body { font: normal 18px/1.6 'Open Sans', "Helvetica Neue", Arial, sans-serif; font-weight: 300; color: #777; padding: 2em 5%; width: 80%; max-width: 900px; margin: 0 auto; background: #fff; }
small { color: #aaa; }
h1,h2,h3,h4 { color: #444; font-weight: 700; font-size: 1.6em; letter-spacing: -1px; }
a { color: #0086B3; font-weight: 700; }
a:hover { color: #000; }
p code, li code {background:#ffffcc; color: #444; }
pre { font-size: 12px; line-height: 18px; }
pre code { overflow: scroll; padding: 1em; border-radius: 10px; }
hr { height: 10px; background: #eee; border: none; }
table {width:100%;border-collapse:collapse;}
td { border: 1px solid #eee; padding: 15px; }
td pre { margin: 0; }
/* Example 2 (login form) */
.login_form.modal {
border-radius: 0;
line-height: 18px;
padding: 0;
font-family: "Lucida Grande", Verdana, sans-serif;
}
.login_form h3 {
margin: 0;
padding: 10px;
color: #fff;
font-size: 14px;
background: -moz-linear-gradient(top, #2e5764, #1e3d47);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #1e3d47),color-stop(1, #2e5764));
}
.login_form.modal p { padding: 20px 30px; border-bottom: 1px solid #ddd; margin: 0;
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #eee),color-stop(1, #fff));
overflow: hidden;
}
.login_form.modal p:last-child { border: none; }
.login_form.modal p label { float: left; font-weight: bold; color: #333; font-size: 13px; width: 110px; line-height: 22px; }
.login_form.modal p input[type="text"],
.login_form.modal p input[type="password"] {
font: normal 12px/18px "Lucida Grande", Verdana;
padding: 3px;
border: 1px solid #ddd;
width: 200px;
}
.part {
display: none;
}
</style>
<title>jQuery Modal</title>
</head>
<body>
<h1>jQuery Modal</h1>
<p><em>the simplest modal you ever did see.</em> – <a href="http://github.com/kylefox/jquery-modal">Code on GitHub »</a></p>
<ul>
<li>Automatic binding using HTML semantics</li>
<li>No images & light-weight <small>(about 1k minified)</small></li>
<li>Simple markup makes it easy to style</li>
<li>Attach custom behaviour using <a href="http://api.jquery.com/category/events/">jQuery events</a></li>
<li>Close with click or ESC key</li>
<li>Works in every single browser known to man (including Lynx)</li>
</ul>
<hr />
<h2>Example 1: Open & Close with links</h2>
<ol>
<li>Embed modal HTML in document <small>(and hide it)</small></li>
<li>Create a link with <code>rel="modal:open"</code> and set the <code>href</code> attribute to the modal's DOM id.</li>
</ol>
<pre><code><!DOCTYPE html>
<html>
<head>
</style>
<!-- Don't forget to include jQuery ;) -->
<script src="jquery.modal.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<!-- Modal HTML embedded directly into document -->
<div id="ex1" style="display:none;">
<p>Thanks for clicking. That felt good. <a href="#" rel="modal:close">Close</a> or press ESC</p>
</div>
<!-- Link to open the modal -->
<p><a href="#ex1" rel="modal:open">Open Modal</a></p>
</body>
</html>
</code></pre>
<!-- Link to open the modal -->
<p>Demo: <a href="#ex1" rel="modal:open">Open Modal</a></p>
<!-- Modal HTML embedded directly into document -->
<div class="modal" id="ex1" style="display:none;">
<p>Thanks for clicking. That felt good. <br />Click <a href="#" rel="modal:close">close</a>, click the overlay, or press ESC</p>
</div>
<hr />
<h2>Example 2: styled login form & events</h2>
<p>This <a href="#ex2" rel="modal:open">example</a> demonstrates how visually customizable the modal is.</p>
<!-- Modal HTML embedded directly into document -->
<form action="" class="login_form modal" id="ex2" style="display:none;">
<h3>Please login to continue</h3>
<p><label>Username:</label><input type="text" /></p>
<p><label>Password:</label><input type="password" /></p>
<p><input type="submit" value="Login" /></p>
</form>
<hr />
<h2>Example 3: resizing</h2>
<p>This <a href="#ex3" rel="modal:open">example</a> shows how <code>resize()</code> can be invoked on a modal.</p>
<div id="ex3" class="modal">
<p><a id="more" href="#more">More!</a></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>
<hr />
<h2>Example 4: AJAX</h2>
<p>This <a href="ajax.html" rel="modal:open">first example</a> uses <code>rel="modal:open"</code> to automatically load the page contents into a modal via AJAX:</p>
<pre><code><a href="ajax.html" rel="modal:open">example</a></code></pre>
<p>This <a href="ajax2.html" id="manual-ajax">second example</a> shows how you can manually load AJAX pages into a modal. Note that the AJAX response must be wrapped in a div with class <code>modal</code>:</p>
<pre><code><!-- Normal link --><br/><a href="ajax.html" id="manual-ajax">second example</a></code></pre>
<pre><code>// Open modal in AJAX callback
$('#manual-ajax').click(function(event) {
event.preventDefault();
$.get(this.href, function(html) {
$(html).appendTo('body').modal();
});
});</code></pre>
<pre><code><!-- AJAX response must be wrapped in the modal's root class. --><br/><div class="modal"><br/> <p>Second AJAX Example!</p><br/></div></pre></code>
<p>If you want more spinner styles, check out <a href="http://ajaxload.info/">ajaxload.info</a>.</p>
<hr />
<h2>Example 5: the un-closable window</h2>
<p>
This <a href="#ex5">example</a> demonstrates how to disable the default methods of closing the modal:
<pre><code> $("#sticky").modal({
escapeClose: false,
clickClose: false,
showClose: false
});</code></pre>
</p>
<div id="ex5" class="modal">
<p>If you do this, be sure to provide the user with an alternate method of <a href="#" rel="modal:close">closing the window.</a></p>
</div>
<hr />
<h2>Example 6: Multiple Modals</h2>
<p>This <a href="#ex6-1" rel="modal:open">example</a> shows how only one modal can be open at a time. If you open a new modal while an existing modal is open, the existing modal is closed first. If you need to manage state (ie: for step by step wizards) you'll need to do that yourself.</p>
<div class="modal" id="ex6-1" style="display:none;">
<p>I'm the first modal. <a href="#ex6-2" rel="modal:open">Open second modal...</a></p>
</div>
<div class="modal" id="ex6-2" style="display:none;">
<p>I'm the second modal. <a href="#ex6-3" rel="modal:open">Open third modal...</a></p>
</div>
<div class="modal" id="ex6-3" style="display:none;">
<p>I'm the third modal. You get the idea.</p>
</div>
<hr />
<h2>Example 7: Fade Transitions</h2>
<p>This <a href="#ex7">example</a> shows how you can do a simple fade by specifying the <code>fadeDuration</code> option.</p>
<pre><code> $("#fade").modal({
fadeDuration: 100
});</code></pre>
<p>You can also use <code>fadeDelay</code> to control the point during the overlay's fade in at which the modal fades in. For <a href="#ex8">example</a>, to fade in the modal when the overlay transition is 50% complete:</p>
<pre><code> $("#fade").modal({
fadeDuration: 1000,
fadeDelay: 0.50
});</code></pre>
<p>The default value is <code>1.0</code>, meaning the window transition begins once the overlay transition has finished. Values greater than <code>1.0</code> mean there is a delay between the completed overlay transition and the start of the window transition, <a href="#ex9">example</a>:</p>
<pre><code> $("#fade").modal({
fadeDuration: 1000,
fadeDelay: 1.75 // Will fade in 750ms after the overlay finishes.
});</code></pre>
<p><small>Tip: set <code>fadeDelay: 0</code> to have the overlay and window fade in simultaneously.</small></p>
<p>In the spirit of keeping this library small, fading is the only supported transition. When the modal is closed, both the overal and window transition out simultaneously.</p>
<div id="ex7" class="modal">
<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. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div id="ex8" class="modal">
<p>This modal starts fading in once the overlay is 50% faded in.</p>
</div>
<div id="ex9" class="modal">
<p>This modal starts fading in well after the overlay has finished transitioning.</p>
</div>
<hr/>
<h2>Example 10: Custom Class for Close Button</h2>
<p>
This <a href="#ex10">example</a> demonstrates how to add extra classes to the close button (for custom styles for the close button):
</p>
<pre><code> $("#custom-close").modal({
closeClass: 'icon-remove',
closeText: '!'
});</code></pre>
<p>And then of course your custom CSS</p>
<pre><code>.modal a.close-modal[class*="icon-"] {
top: -10px;
right: -10px;
width: 20px;
height: 20px;
color: #fff;
line-height: 1.25;
text-align: center;
text-decoration: none;
text-indent: 0;
background: #900;
border: 2px solid #fff;
-webkit-border-radius: 26px;
-moz-border-radius: 26px;
-o-border-radius: 26px;
-ms-border-radius: 26px;
-moz-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
-webkit-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
}</code></pre>
<div id="ex10" class="modal">
<p>This modal has a fancy-shmancy close button.</p>
</div>
<style type="text/css">
.modal a.close-modal[class*="icon-"] {
top: -10px;
right: -10px;
width: 20px;
height: 20px;
color: #fff;
line-height: 1.25;
text-align: center;
text-decoration: none;
text-indent: 0;
background: #900;
border: 2px solid #fff;
-webkit-border-radius: 26px;
-moz-border-radius: 26px;
-o-border-radius: 26px;
-ms-border-radius: 26px;
-moz-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
-webkit-box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
box-shadow: 1px 1px 5px rgba(0,0,0,0.5);
}
</style>
<script type="text/javascript" charset="utf-8">
$(function() {
function log_modal_event(event, modal) {
if(typeof console != 'undefined' && console.log) console.log("[event] " + event.type);
};
$(document).on($.modal.BEFORE_BLOCK, log_modal_event);
$(document).on($.modal.BLOCK, log_modal_event);
$(document).on($.modal.BEFORE_OPEN, log_modal_event);
$(document).on($.modal.OPEN, log_modal_event);
$(document).on($.modal.BEFORE_CLOSE, log_modal_event);
$(document).on($.modal.CLOSE, log_modal_event);
$(document).on($.modal.AJAX_SEND, log_modal_event);
$(document).on($.modal.AJAX_SUCCESS, log_modal_event);
$(document).on($.modal.AJAX_COMPLETE, log_modal_event);
$('#more').click(function() {
$(this).parent().after($(this).parent().next().clone());
$.modal.resize();
return false;
});
$('#manual-ajax').click(function(event) {
event.preventDefault();
$.get(this.href, function(html) {
$(html).appendTo('body').modal();
});
});
$('a[href="#ex5"]').click(function(event) {
event.preventDefault();
$(this).modal({
escapeClose: false,
clickClose: false,
showClose: false
});
});
$('a[href="#ex7"]').click(function(event) {
event.preventDefault();
$(this).modal({
fadeDuration: 250
});
});
$('a[href="#ex8"]').click(function(event) {
event.preventDefault();
$(this).modal({
fadeDuration: 1000,
fadeDelay: 0.50
});
});
$('a[href="#ex9"]').click(function(event) {
event.preventDefault();
$(this).modal({
fadeDuration: 1000,
fadeDelay: 1.75
});
});
$('a[href="#ex10"]').click(function(event){
event.preventDefault();
$(this).modal({
closeClass: 'icon-remove',
closeText: '!'
});
});
});
</script>
</body>
</html>