forked from ethereum/meteor-package-elements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal.js
84 lines (67 loc) · 1.85 KB
/
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
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
/**
Template Controllers
@module Templates
*/
/**
The modal placeholder template.
@class [template] dapp_modalPlaceholder
@constructor
*/
Template["dapp_modalPlaceholder"].onCreated(function() {});
Template["dapp_modalPlaceholder"].helpers({
/**
The modal template, set manualy
@method (modalTemplate)
*/
modalTemplate: function() {
return EthElements.Modal._current.get() ? "dapp_modal" : false;
},
/**
The modal templates data, set manualy
@method (modalData)
*/
modalData: function() {
return EthElements.Modal._current.get();
}
});
/**
The modal wrapper template.
If you pass "closePath" in the data context, it will use this path, when the modal overlay is clicked.
@class [template] dapp_modal
@constructor
*/
/**
Look the scrolling of the body
@method rendered
*/
Template["dapp_modal"].onCreated(function() {
$("body").addClass("disable-scroll blur");
});
/**
Remove look of scrolling from the body
@method rendered
*/
Template["dapp_modal"].onDestroyed(function() {
$("body").removeClass("disable-scroll blur");
});
Template["dapp_modal"].events({
/**
Hide the modal on click. If the data context has the property "closePath",
it will route to this one instead of going back in the browser history.
If the "closeable" is FALSE, it won't close the modal, when clicking the overlay.
@event click .dapp-modal-overlay
*/
"click .dapp-modal-overlay": function(e, template) {
// hide the modal
if (
$(e.target).hasClass("dapp-modal-overlay") &&
template.data.closeable !== false
) {
if (template.data.closePath && typeof Router !== "undefined") {
if (typeof Router !== "undefined") Router.go(template.data.closePath);
if (typeof FlowRouter !== "undefined")
FlowRouter.go(template.data.closePath);
} else EthElements.Modal.hide();
}
}
});