-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathOverlay.js
83 lines (54 loc) · 1.52 KB
/
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
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
(function (WL) {
if (window.top !== window.top) {
return;
}
if (!WL) {
window.WL = {};
WL = window.WL;
}
var overlayId = 'wunderlist_overlay';
function showOverlay (postData) {
var existing = document.getElementById(overlayId);
if (!existing) {
var frame = document.createElement('iframe');
frame.allowtransparency = 'true';
frame.scrolling = 'no';
frame.id = overlayId;
frame.name = overlayId;
frame.style.cssText = WL.buildCss();
frame.src = WL.buildUrl(postData);
frame.onload = function () {
$('body').css({
'overflow': 'hidden'
});
frame.style.opacity = 1;
setTimeout(function () {
frame.style.cssText = WL.buildCss({
'opacity': 1,
'transitionSpeed': 50
});
}, 0);
};
document.body.appendChild(frame);
var close = function close (ev) {
if (ev.data === 'close_wunderlist') {
frame.style.opacity = 0;
setTimeout(function () {
frame.src = 'about:blank';
frame.onload = function () {
$('body').css({
'overflow': ''
});
window.removeEventListener('message', close, false);
frame.parentNode.removeChild(frame);
frame = null;
};
}, 500);
}
};
window.addEventListener('message', close, false);
}
}
// exports
WL.showOverlay = showOverlay;
})(window.WL);