-
Notifications
You must be signed in to change notification settings - Fork 8
/
modalbtn.js
40 lines (37 loc) · 971 Bytes
/
modalbtn.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
36
37
38
39
40
/**
* modal button tag
*
* Syntax:
* {% modalbtn customModalId text [color=primary] [size=def|sm|lg] [outline|block] %}
*/
var colors = {primary:true, secondary:true, success:true, danger:true, warning:true, info:true, light:true, dark:true, link:true};
var sizes = {sm:true, lg:true};
var types = {outline:true, block:true};
module.exports = function(args, content) {
var id = args[0];
var text = args[1];
var style = "secondary";
var size;
var type;
for (var i = 2; i < args.length; i++) {
var val = args[i];
if (types[val]) {
type = val;
} else if(sizes[val]) {
size = val;
} else if(colors[val]) {
style = val;
}
}
// btn-outline-primary
if (type === "outline") {
style = type + "-" + style;
}
if (type === "block") {
style = style + " btn-block";
}
if (size) {
style = style + " btn-" + size;
}
return '<button class="btn btn-' + style + '" data-toggle="modal" data-target="#' + id + '">' + text + '</button>'
};