-
Notifications
You must be signed in to change notification settings - Fork 8
/
modal.js
35 lines (31 loc) · 931 Bytes
/
modal.js
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
/**
* modal tag
*
* Syntax:
* {% modal customModalId [size=sm|lg] %}
* ...
* {% endmodal %}
*/
module.exports = function(ctx) {
return function rowTag(args, content) {
var sizes = {sm:true, lg:true};
content = ctx.render.renderSync({text: content, engine: 'markdown'});
var id = args[0];
var size;
for (var i = 1; i < args.length; i++) {
var val = args[i];
if (sizes[val]) {
size = val;
}
}
return '<div id="' + id + '" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">' +
'<div class="modal-dialog modal-' + size + '">' +
'<div class="modal-content">' +
'<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="$(\'#' + id + '\').modal(\'toggle\');">' +
'<span aria-hidden="true">×</span>' +
'</button>' +
content +
'</div>' +
'</div>';
};
};