-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.html
371 lines (327 loc) · 18.3 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
<!DOCTYPE html>
<html>
<head>
<title>BootPopup - Popup dialog boxes for Bootstrap</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/kimbie-dark.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
<script src="dist/bootpopup.min.js"></script>
<style type="text/css">
body {
font-size: 1.65em;
}
.jumbotron {
padding-top: 90px;
background-color: cornsilk;
}
.jumbotron h1 {
text-shadow: 0 1px 2px dimgray;
}
.jumbotron .btn-success {
padding-left: 60px;
padding-right: 60px;
}
.navbar a img {
width: 18px;
}
.navbar a u {
color: #337ab7;
}
pre {
border: 1px solid black;
color: #eee;
background: #221a0f;
font-size: 15px;
font-weight: bold;
padding: 0;
}
pre code {
white-space: pre;
}
.hljs {
padding: 1em;
}
hr {
margin: 30px 0px 30px 0px;
border: none;
border-bottom: 1px dashed #eee;
}
#paypal-link {
padding-top: 12px;
padding-bottom: 12px;
}
#paypal-link > img {
width: 100%;
}
.bordered {
border: 10px solid red;
}
</style>
</head>
<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
<a class="navbar-brand text-capitalize" href="https://rigon.github.io/bootpopup/">BootPopup</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#home" data-scrollto="body,html">Home</a></li>
<li><a href="#how-to-use" data-scrollto="#how-to-use">How to Use</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Examples <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#alert" data-scrollto="#alert">Alert</a></li>
<li><a href="#confirm" data-scrollto="#confirm">Confirm</a></li>
<li><a href="#prompt" data-scrollto="#prompt">Prompt</a></li>
<li><a href="#customized" data-scrollto="#customized">Customized</a></li>
</ul>
</li>
<li><a href="https://github.com/rigon/bootpopup/blob/master/README.md#content">API <small class="glyphicon glyphicon-new-window"></small></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="https://rigon.us.to">by <u>rigon</u></a></li>
<li><a href="https://github.com/rigon/bootpopup"><img src="https://github.githubassets.com/favicons/favicon.png" /> Fork on GitHub</a></li>
<li><a href="#" id="paypal-link" title="Please donate - Help us to mantain this project!"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif"></a></li>
</ul>
</div>
</div>
</nav>
<!-- Main component for a primary marketing message or call to action -->
<div class="jumbotron text-center">
<h1>BootPopup</h1>
<p class="lead">Popup dialog boxes for Bootstrap.</p>
<p>
<a class="btn btn-lg btn-success" href="https://github.com/rigon/bootpopup/archive/master.zip">
<span class="glyphicon glyphicon-download-alt"></span> Download latest
</a>
</p>
<p>
<img src="https://static.npmjs.com/b0f1a8318363185cc2ea6a40ac23eeb2.png" width="16">
<small><a href="https://www.npmjs.com/package/bootpopup">Available via npm</a></small><br>
<img src="https://bower.io/img/bower-logo.svg" width="16">
<small><a href="https://bower.io/search/?q=bootpopup">Available via bower</a></small><br>
<img src="https://avatars1.githubusercontent.com/u/1781835" width="24">
<small>AMD support: require.js</small>
</p>
</p>
</div>
<div class="container">
<p class="lead">
<b>BootPopup</b> is a JavaScript library intended to simplify the task of creating
<a href="http://getbootstrap.com/javascript/#modals">Bootstrap modals</a>.
</p>
<p class="lead">Check out the <a href="#examples" data-scrollto="#examples">examples</a> to see how easy it is!</p>
<h1 id="how-to-use">How to Use</h1>
<p>You can <a href="https://github.com/rigon/bootpopup/archive/master.zip">download</a> and extract the
archive into your project folder, <b>or</b></p>
<p>Install BootPopup through npm (or bower if you are using it) with:</p>
<pre><code class="bash">npm install --save bootpopup</code></pre>
<p>Then, include BootPopup in your HTML document. BootPopup requires <a href="https://jquery.com/">jQuery</a> and <a href="http://getbootstrap.com">Bootstrap</a>:</p>
<pre><code class="html"><!-- jQuery and bootstrap -->
<link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.min.css" />
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- BootPopup -->
<script src="node_modules/bootpopup/bootpopup.min.js"></script></code></pre>
<p>See the full documentation about how to use BootPopup in the
<a href="https://github.com/rigon/bootpopup/blob/master/README.md#api">API section on GitHub <small class="glyphicon glyphicon-new-window"></small></a>
</p>
<h1 id="examples">Examples</h1>
<h2 id="alert">Alert</h2>
<p>A simple alert:</p>
<pre><code class="js">bootpopup.alert("You are now alerted by this message!");</code></pre>
<p><button id="example-alert-1" class="btn btn-primary">Run example</button></p><hr>
<p>An alert with custom title:</p>
<pre><code class="js">bootpopup.alert("You are now alerted by this message with a custom title!", "You are alerted");</code></pre>
<p><button id="example-alert-2" class="btn btn-primary">Run example</button></p><hr>
<h2 id="confirm">Confirm</h2>
<p>A simple confirm:</p>
<pre><code class="js">bootpopup.confirm("Do you confirm this message?");</code></pre>
<p><button id="example-confirm-1" class="btn btn-primary">Run example</button></p><hr>
<p>A confirm with a custom title:</p>
<pre><code class="js">bootpopup.confirm("Do you confirm this message with a custom title?", "Confirm this message");</code></pre>
<p><button id="example-confirm-2" class="btn btn-primary">Run example</button></p><hr>
<p>A confirm with a callback and response:</p>
<pre><code class="js">bootpopup.confirm("Do you confirm this message?", "Confirm this message", function(ans) { alert(ans); });</code></pre>
<p><button id="example-confirm-3" class="btn btn-primary">Run example</button></p><hr>
<p>Or if you want a callback without a custom title:</p>
<pre><code class="js">bootpopup.confirm("Do you confirm this message with a callback?", function(ans) { alert(ans); });</code></pre>
<p><button id="example-confirm-4" class="btn btn-primary">Run example</button></p><hr>
<h2 id="prompt">Prompt</h2>
<p>A simple prompt:</p>
<pre><code class="js">bootpopup.prompt("Name");</code></pre>
<p><button id="example-prompt-1" class="btn btn-primary">Run example</button></p><hr>
<p>A prompt with a custom type of data. This corresponds to <a href="https://www.w3schools.com/tags/att_input_type.asp">HTML input types</a>:</p>
<pre><code class="js">bootpopup.prompt("Age", "number");</code></pre>
<p><button id="example-prompt-2" class="btn btn-primary">Run example</button></p><hr>
<p>A prompt with a custom message:</p>
<pre><code class="js">bootpopup.prompt("Text", null, "Insert a random text:");</code></pre>
<p><button id="example-prompt-3" class="btn btn-primary">Run example</button></p><hr>
<p>Or if you want a callback without a custom title and message:</p>
<pre><code class="js">bootpopup.prompt("Text", function(data) { alert(data); });</code></pre>
<p><button id="example-prompt-4" class="btn btn-primary">Run example</button></p><hr>
<p>You can also request multiple values at same time, providing a list of values to input:</p>
<pre><code class="js">bootpopup.prompt([
{ label: "A text"},
{ label: "A number"},
"<hr>",
{ label: "A select", type: "select", name: "select", options: { a:"A", b:"B", c:"C" }},
{ label: "Select multiple", type: "select", name: "multiple", multiple: "multiple", options: { a:"A", b:"B", c:"C" }},
{ label: "Radios", type: "radio", name: "radios", options: { a:"A", b:"B", c:"C" }},
{ label: "A boolean", type: "checkbox", name: "boolean"},
],
function(data) { alert(JSON.stringify(data)); }
);</code></pre>
<p><button id="example-prompt-5" class="btn btn-primary">Run example</button></p><hr>
<h2 id="customized">Customized dialog</h2>
<p>BootPopup is also highly customizable, you can create a list of items to display very quickly. Then, you can
pick up the entered data from the callback very easily:</p>
<pre><code class="js">bootpopup({
title: "Add image",
size: "large",
showclose: false,
size_labels: "col-sm-2",
size_inputs: "col-sm-10",
content: [
{ p: {text: "Insert image info here:"}},
{ input: {type: "text", label: "Title", name: "title", id: "title", placeholder: "Description for image", value: "Common kingfisher"}},
{ url: {label: "Link", name: "link", id: "link", placeholder: "Hyperlink for image", value: "https://upload.wikimedia.org/wikipedia/commons/d/d2/Eisvogel_kingfisher.jpg"}},
{ checkbox: {label: "Add border to the image", name: "border", id: "border"}},
{ button: {name: "button", value: "Open image", class: "btn btn-info", onclick: function() {
bootpopup({
title: $('#title').val(),
content: [ { img: {src: $('#link').val(), id: 'image', width: '100%'}} ],
before: function(window) {
if($("#border").prop("checked"))
$("#image").addClass("bordered");
}
});
}
}}],
before: function(window) { alert("Before"); },
dismiss: function(event) { alert("Dismiss"); },
cancel: function(data, array, event) { alert("Cancel"); },
ok: function(data, array, event) { alert("OK\n" + JSON.stringify(data)); },
complete: function() { alert("Complete"); },
});</code></pre>
<p><button id="example-customized-1" class="btn btn-primary">Run example</button></p><hr>
<p>If the provided functionality is not enough for your case, you can simply mix your HTML:</p>
<pre><code class="js">bootpopup({
title: "Custom HTML",
content: [
'<h1>BootPopup</h1>',
'<p class="lead">Popup dialog boxes for Bootstrap.</p>',
'<b>BootPopup</b> is a JavaScript library intended to simplify the task of creating <a href="#">Bootstrap modals</a>',
'<p class="lead">Check out the <a href="#examples" data-scrollto="#examples">examples</a> to see how easy it is!</p>',
'Give us a rate 1-10:',
{ number: { label: "Rate", name: "rate", value: "11"}},
{ select: { label: "A select", name: "select", options: { a:"A", b:"B", c:"C" }}},
{ radio: { label: "Radios", name: "radios", options: { a:"A", b:"B", c:"C" }}}
],
cancel: function(data, array, event) { alert("Cancel"); },
ok: function(data, array, event) { alert("OK\n" + JSON.stringify(data)); },
complete: function() { alert("Complete"); },
});</code></pre>
<p><button id="example-customized-2" class="btn btn-primary">Run example</button></p><hr>
</div> <!-- /container -->
<script type="text/javascript">
$('a[data-scrollto]').click(function(event) {
//event.preventDefault();
var target = $(this).data('scrollto');
var position = $(target).offset().top - 70; // Target position - navbar height
$('html, body').animate({ scrollTop: position });
});
$("#example-alert-1").click(function() { bootpopup.alert("You are now alerted by this message!"); });
$("#example-alert-2").click(function() { bootpopup.alert("You are now alerted by this message with a custom title!", "You are alerted"); });
$("#example-confirm-1").click(function() { bootpopup.confirm("Do you confirm this message?"); });
$("#example-confirm-2").click(function() { bootpopup.confirm("Do you confirm this message with a custom title?", "Confirm this message"); });
$("#example-confirm-3").click(function() { bootpopup.confirm("Do you confirm this message?", "Confirm this message", function(ans) { alert(ans); }); });
$("#example-confirm-4").click(function() { bootpopup.confirm("Do you confirm this message with a callback?", function(ans) { alert(ans); }); });
$("#example-prompt-1").click(function() { bootpopup.prompt("Name"); });
$("#example-prompt-2").click(function() { bootpopup.prompt("Age", "number"); });
$("#example-prompt-3").click(function() { bootpopup.prompt("Text", null, "Insert a random text:"); });
$("#example-prompt-4").click(function() { bootpopup.prompt("Text", function(data) { alert(data); }); });
$("#example-prompt-5").click(function() { bootpopup.prompt([
{ label: "A text"},
{ label: "A number", type: "number"},
"<hr>",
{ label: "A select", type: "select", name: "select", options: { a:"A", b:"B", c:"C" }},
{ label: "Select multiple", type: "select", name: "multiple", multiple: "multiple", options: { a:"A", b:"B", c:"C" }},
{ label: "Radios", type: "radio", name: "radios", options: { a:"A", b:"B", c:"C" }},
{ label: "A boolean", type: "checkbox", name: "boolean"},
], function(data) { alert(JSON.stringify(data)); }); });
$("#example-customized-1").click(function() {
bootpopup({
title: "Add image",
size: "large",
showclose: false,
size_labels: "col-sm-2",
size_inputs: "col-sm-10",
content: [
{ p: {text: "Insert image info here:"}},
{ input: {type: "text", label: "Title", name: "title", id: "title", placeholder: "Description for image", value: "Common kingfisher"}},
{ url: {label: "Link", name: "link", id: "link", placeholder: "Hyperlink for image", value: "https://upload.wikimedia.org/wikipedia/commons/d/d2/Eisvogel_kingfisher.jpg"}},
{ checkbox: {label: "Add border to the image", name: "border", id: "border"}},
{ button: {name: "button", value: "Open image", class: "btn btn-info", onclick: function() {
bootpopup({
title: $('#title').val(),
content: [ { img: {src: $('#link').val(), id: "image", width: "100%" }} ],
before: function(window) {
if($('#border').prop('checked'))
$('#image').addClass("bordered");
}
});
}
}}
],
before: function(window) { alert("Before"); },
dismiss: function(event) { alert("Dismiss"); },
cancel: function(data, array, event) { alert("Cancel"); },
ok: function(data, array, event) { alert("OK\n" + JSON.stringify(data)); },
complete: function() { alert("Complete"); },
});
});
$("#example-customized-2").click(function() {
bootpopup({
title: "Custom HTML",
content: [
'<h1>BootPopup</h1>',
'<p class="lead">Popup dialog boxes for Bootstrap.</p>',
'<b>BootPopup</b> is a JavaScript library intended to simplify the task of creating <a href="#">Bootstrap modals</a>',
'<p class="lead">Check out the <a href="#examples" data-scrollto="#examples">examples</a> to see how easy it is!</p>',
'Give us a rate 1-10:',
{ number: { label: "Rate", name: "rate", value: "11" }},
{ select: { label: "A select", name: "select", options: { a:"A", b:"B", c:"C" }}},
{ radio: { label: "Radios", name: "radios", options: { a:"A", b:"B", c:"C" }}}
],
cancel: function(data, array, event) { alert("Cancel"); },
ok: function(data, array, event) { alert("OK\n" + JSON.stringify(data)); },
complete: function() { alert("Complete"); },
});
});
</script>
<script>hljs.highlightAll();</script>
<!-- PayPal Donations -->
<form id="paypal-form" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="VNE5MMV2EA2Z4">
</form>
<script type="text/javascript">
$("#paypal-link").click(function(event) {
event.preventDefault();
$("#paypal-form").submit();
});
</script>
</body>
</html>