-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmain.js
51 lines (29 loc) · 968 Bytes
/
main.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
41
42
43
44
45
46
47
48
49
50
51
var $soloModal = null // Used when allowMultiple = false.
// The public API.
Modal = {
allowMultiple: false,
show: function(templateName, data, options){
if($soloModal == null || this.allowMultiple){
var parentNode = document.body
var view = Blaze.renderWithData(Template[templateName], data, parentNode)
var domRange = view._domrange // TODO: Don't violate against the public API.
var $modal = domRange.$('.modal')
$modal.on('shown.bs.modal', function(event){
$modal.find('[autofocus]').focus()
})
$modal.on('hidden.bs.modal', function(event){
Blaze.remove(view)
$soloModal = null
})
$soloModal = $modal
$modal.modal(options ? options : {})
}
},
hide: function(/* optional */ template){
if(template instanceof Blaze.TemplateInstance){
template.$('.modal').modal('hide')
}else if($soloModal != null){
$soloModal.modal('hide')
}
}
}