1
|
|
|
/* |
2
|
|
|
* Bootstrap dialogs plugin |
3
|
|
|
*/ |
4
|
|
|
jaxon.dialogs.bootstrap = { |
5
|
|
|
show: function(args) { |
6
|
|
|
// Open modal |
7
|
|
|
BootstrapDialog.show({ |
8
|
|
|
...args.data, |
9
|
|
|
buttons: args.data.buttons.map(button => { |
10
|
|
|
return { |
11
|
|
|
...button, |
12
|
|
|
action: button.action === 'close' ? function(dialog){dialog.close();} : new Function(button.action), |
13
|
|
|
}; |
14
|
|
|
}), |
15
|
|
|
}); |
16
|
|
|
}, |
17
|
|
|
hide: function(args) { |
18
|
|
|
// Hide modal |
19
|
|
|
BootstrapDialog.closeAll(); |
20
|
|
|
}, |
21
|
|
|
alert: function(args) { |
22
|
|
|
var dataTypes = { |
23
|
|
|
success: BootstrapDialog.TYPE_SUCCESS, |
24
|
|
|
info: BootstrapDialog.TYPE_INFO, |
25
|
|
|
warning: BootstrapDialog.TYPE_WARNING, |
26
|
|
|
danger: BootstrapDialog.TYPE_DANGER |
27
|
|
|
}; |
28
|
|
|
args.data.type = dataTypes[args.data.type]; |
29
|
|
|
BootstrapDialog.alert(args.data); |
30
|
|
|
}, |
31
|
|
|
success: function(content, title) { |
32
|
|
|
BootstrapDialog.alert({type: BootstrapDialog.TYPE_SUCCESS, message: content, title: title}); |
33
|
|
|
}, |
34
|
|
|
info: function(content, title) { |
35
|
|
|
BootstrapDialog.alert({type: BootstrapDialog.TYPE_INFO, message: content, title: title}); |
36
|
|
|
}, |
37
|
|
|
warning: function(content, title) { |
38
|
|
|
BootstrapDialog.alert({type: BootstrapDialog.TYPE_WARNING, message: content, title: title}); |
39
|
|
|
}, |
40
|
|
|
error: function(content, title) { |
41
|
|
|
BootstrapDialog.alert({type: BootstrapDialog.TYPE_DANGER, message: content, title: title}); |
42
|
|
|
}, |
43
|
|
|
confirm: function(question, title, yesCallback, noCallback) { |
44
|
|
|
BootstrapDialog.confirm({ |
45
|
|
|
title: title, |
46
|
|
|
message: question, |
47
|
|
|
btnOKLabel: "<?php echo $this->yes ?>", |
48
|
|
|
btnCancelLabel: "<?php echo $this->no ?>", |
49
|
|
|
callback: function(res){ |
50
|
|
|
if(res) |
51
|
|
|
yesCallback(); |
52
|
|
|
else if(noCallback != undefined) |
53
|
|
|
noCallback(); |
54
|
|
|
} |
55
|
|
|
}); |
56
|
|
|
} |
57
|
|
|
}; |
58
|
|
|
|