-
Notifications
You must be signed in to change notification settings - Fork 1
/
dialog.js
46 lines (37 loc) · 1.38 KB
/
dialog.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
'use strict';
var Dialog = (function(){
function Dialog(dialogId) {
this.dialogId = dialogId;
this.dialogContainer = document.getElementById(dialogId);
this.dialogBackground = document.querySelector(
"#" + dialogId + " .dialog-background");
this.dialogContent = document.querySelector(
"#" + dialogId + " .dialog-content");
};
Dialog.prototype.show = function() {
this.dialogContainer.style.opacity = 0;
this.dialogContainer.style.display = 'block';
var e = $(this.dialogContent);
var top = e[0].scrollHeight
+ parseInt(e.css('margin-top')) + parseInt(e.css('margin-bottom'));
this.dialogContent.style.top = "-" + top + "px";
this.dialogContainer.style.opacity = 1;
this.dialogBackground.classList.add('dialog-show-background');
this.dialogBackground.onclick = function() {
this.hide();
}.bind(this);
setTimeout(function() {
this.dialogContent.classList.add('dialog-show-content');
}.bind(this), 300);
};
Dialog.prototype.hide = function() {
this.dialogContent.classList.remove('dialog-show-content');
setTimeout(function() {
this.dialogBackground.classList.remove('dialog-show-background');
}.bind(this), 500);
setTimeout(function() {
this.dialogContainer.style.display = 'none';
}.bind(this), 500);
};
return Dialog;
})();