forked from grigio/meteor-overlay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlay.js
38 lines (35 loc) · 973 Bytes
/
overlay.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
Template.overlay.helpers({
animation: function (argument) {
return Session.get('overlay-animation') || 'left-to-right';
},
data:function () {
return Session.get('overlay-data');
},
overlayVisible: function() {
return Session.get('overlay-visible');
},
currentOverlay: function (argument) {
return Session.get('overlay');
}
});
Template.overlay.events({
'click .js-overlay-close':function () {
Overlay.hide();
}
});
// API
Overlay = {
show: function (template, data) {
console.log(data);
var data = data || {};
if (data.closeable === undefined) data.closeable = true;
_.extend(data, {isInOverlay:true});
Session.set('overlay-data', data);
Session.set('overlay', template);
Session.set('overlay-animation', data.animation);
Session.set('overlay-visible', true);
},
hide: function () {
Session.set('overlay-visible', false);
}
}