-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
404 lines (322 loc) · 13.9 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
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@voerro/vue-modal</title>
<link rel="stylesheet" href="demo/css/bulma.min.css">
<style>
html { overflow-y: auto; }
[v-cloak] { display: none; }
</style>
</head>
<body>
<section class="hero is-info">
<div class="hero-body">
<div class="container">
<h1 class="title">@voerro/vue-modal</h1>
<h2 class="subtitle">
A flexible & responsive modal component for Vue.js 2 by
<a href="http://voerro.com">Voerro</a>
</h2>
<p>
<a href="https://github.com/voerro/vue-modal" target="_blank">
View on Github
</a>
</p>
</div>
</div>
</section>
<div id="voerro-vue-modal-demo-vqk6etkfjrcpsjg5" class="container" style="padding: 2rem;">
<modal :dismissible="dynamicDismissible"
:header="dynamicHeader"></modal>
<h3 class="is-size-3" style="margin-bottom: 1rem;">Dynamic Modals</h3>
<div class="field">
<label class="label">Modal Title</label>
<div class="control">
<input class="input" type="text" v-model="dynamicTitle">
</div>
</div>
<div class="field">
<label class="label">Modal Body</label>
<div class="control">
<textarea class="textarea" v-model="dynamicBody" rows="6"></textarea>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" v-model="dynamicDismissible"> Dismissible
</label>
</div>
</div>
<div class="field">
<div class="control">
<label class="checkbox">
<input type="checkbox" v-model="dynamicHeader"> Header
</label>
</div>
</div>
<p>
<button class="button is-primary" @click="showDynamicModal">Generate Modal</button>
</p>
<h4 class="is-size-4" style="margin: 1rem 0;">Customize Buttons</h4>
<p style="margin: 1rem 0;">Modals can have as many buttons as you need, each with a unique handler/action. A button without a handler simply closes the modal.</p>
<p>
<button class="button is-primary" @click="showModalTwoButtons">Two Buttons</button>
<button class="button is-primary" @click="showModalThreeButtons">Three Buttons</button>
<button class="button is-primary" @click="showModalLotsaButtons">Lotsa Buttons</button>
<button class="button is-primary" @click="showModalNoButtons">No Buttons At All</button>
</p>
<hr>
<h3 class="is-size-3" style="margin-bottom: 1rem;">
Loading Modal's Body via AJAX
</h3>
<p style="margin: 1rem 0;">This works as a regular modal, except you need to provide a URL to fetch the content instead of a body.</p>
<div class="field">
<label class="label">Modal Body URL</label>
<div class="control">
<input class="input" type="text" v-model="ajaxUrl">
</div>
</div>
<p>
<button class="button is-primary" @click="showAjaxModal">Generate Modal</button>
</p>
<hr>
<h3 class="is-size-3" style="margin-bottom: 1rem;">Inline Modals</h3>
<modal id="inline" v-cloak>
<template slot="title">Inline Title</template>
<div slot="body">This body, as well as the title, are stored directly within the HTML of your page.</div>
<div slot="footer">You can put something else in the footer if you don't need the buttons (or provide the buttons via options like with dynamically generated modals)</div>
</modal>
<modal id="inline-two" v-cloak>
<template slot="title">Inline 2</template>
<div slot="body">This is a different inline modal with a different id. Don't include the footer slot if you don't need it.</div>
</modal>
<modal id="inline-with-buttons" v-cloak>
<template slot="title">Inline 3</template>
<div slot="body">The buttons for this modal are generated dynamically.</div>
</modal>
<p style="margin: 1rem 0;">You can also define multiple modals inline with Vue slots. Each modal should have a unique id. Open this page's source code and find the two <modal> blocks defining these modals if you want to see how it works.</p>
<p>
<button class="button is-primary" @click="showInlineModal">Show Modal One</button>
<button class="button is-primary" @click="showInlineModalTwo">Show Modal Two</button>
<button class="button is-primary" @click="showInlineModalWithButtons">Show Modal Three</button>
</p>
<hr>
<h3 class="is-size-3" style="margin-bottom: 1rem;">
Hiding Modals Programmatically
</h3>
<p>
<button class="button is-primary" @click="showAndHideGeneratedModal">Hide Dynamically Generated Modal After 2 Seconds</button>
<button class="button is-primary" @click="showAndHideInlineModal">Hide Inline Modal After 2 Seconds</button>
</p>
<hr>
<h3 class="is-size-3" style="margin-bottom: 1rem;">
Options
</h3>
<p style="margin: 1rem 0;"><b>Undismissible Modals</b>. An undismissible modal can not be dismissed by pressing on the close button or on the overlay outside the modal. An action (a button click) is required to close the modal.</p>
<p>
<button class="button is-primary" @click="showUndismissibleModal">Show Modal</button>
</p>
<p style="margin: 1rem 0;">
<b>No Header</b>
</p>
<p>
<button class="button is-primary" @click="showModalWithoutHeader">Show Modal</button>
</p>
<p style="margin: 1rem 0;">
<b>Prevent Default Button's Action</b>. By default the active modal will be closed after you press on any of the buttons (even if that button has a handler). Luckily, you can prevent that.
</p>
<p>
<button class="button is-primary" @click="showModalPreventDefaultAction">Show Modal</button>
</p>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.min.js"></script>
<script src="dist/build.js"></script>
<script>
new Vue({
el: '#voerro-vue-modal-demo-vqk6etkfjrcpsjg5',
components: { Modal },
data: {
dynamicTitle: 'A title',
dynamicBody: `<p>Put some content here.</p>
<p>By the way, <b>HTML</b> is <em>also supported</em>!</p>
<p style="text-align:center">
<img src="https://vuejs.org/images/logo.png" style="height: 5rem;">
</p>`,
ajaxUrl: 'demo/ajax.html',
dynamicDismissible: true,
dynamicHeader: true,
},
methods: {
showDynamicModal () {
VoerroModal.show({
title: this.dynamicTitle,
body: this.dynamicBody,
buttons: [
{
text: 'Ok'
}
]
});
},
showModalTwoButtons () {
VoerroModal.show({
title: 'Two Buttons',
body: 'This one has two buttons!',
buttons: [
{
text: 'Ok',
handler: function () {
alert('You pressed ok!');
}
},
{
text: 'Cancel'
}
]
});
},
showModalThreeButtons() {
VoerroModal.show({
title: 'How About Three Buttons?',
body: 'Not bad...',
buttons: [
{
text: 'Yes',
handler: function () {
alert('You pressed yes!');
}
},
{
text: 'Maybe',
handler: function () {
alert('You pressed maybe...');
}
},
{
text: 'No',
handler: function () {
alert('You pressed no :(');
}
}
]
});
},
showModalLotsaButtons() {
VoerroModal.show({
title: 'How Many Buttons Do You Need?',
body: 'You can have as many as you need. Each button has the same width.',
buttons: [
{ text: 'You', },
{ text: 'Can' },
{ text: 'Have' },
{ text: 'As' },
{ text: 'Many' },
{ text: 'Buttons' },
{ text: 'As' },
{ text: 'You' },
{ text: 'Need' }
]
});
},
showModalNoButtons() {
VoerroModal.show({
title: 'No Buttons At All',
body: 'No buttons here, move on...',
dismissible: true
});
},
showAjaxModal() {
VoerroModal.show({
title: 'Fetching the Body via AJAX',
bodyUrl: this.ajaxUrl,
buttons: [
{
text: 'Yep!'
}
]
});
},
showInlineModal () {
VoerroModal.show('inline');
},
showInlineModalTwo () {
VoerroModal.show('inline-two');
},
showInlineModalWithButtons () {
VoerroModal.show('inline-with-buttons', {
buttons: [
{
text: 'Nice!',
handler: () => {
alert('I know, right?');
}
},
{ text: 'Close' }
]
});
},
showAndHideGeneratedModal () {
VoerroModal.show({
title: 'VoerroModal.hide()',
body: 'This will disappear in 2 seconds...'
});
setTimeout(function () {
VoerroModal.hide();
}, 2000);
},
showAndHideInlineModal () {
VoerroModal.show('inline-two');
setTimeout(function () {
VoerroModal.hide('inline-two');
}, 2000);
},
showUndismissibleModal () {
VoerroModal.show({
title: "U Can't Close This",
body: 'The only way to close this modal is to press on one of the buttons. This forces your users to take an action.',
buttons: [
{
text: 'I Agree'
},
{
text: 'I Don\'t Agree'
}
],
dismissible: false
});
},
showModalWithoutHeader () {
VoerroModal.show({
body: 'This modal\'s header is completely hidden.',
buttons: [
{
text: 'Ok'
}
],
header: false
});
},
showModalPreventDefaultAction () {
VoerroModal.show({
body: 'This modal won\'t automatically close after you press "Ok". You can close the modal manually whenever is appropriate.',
buttons: [
{
text: 'Ok',
preventDefault: true,
handler: () => {
alert('Performing an action...');
}
},
{ text: 'Cancel' }
],
header: false
});
}
}
});
</script>
</body>
</html>