-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (41 loc) · 1.01 KB
/
index.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
var Css = require('cl-css').Css;
/**
* Constrcutor
* @param {Number} zIndex Description
* @return {Element} description
*/
function Overlay(opt) {
var opt = opt || {};
opt.zIndex = opt.zIndex || '200';
opt.trans = opt.trans || '0.6';
if(document.getElementsByClassName('cl-overlay').length > 0) return;
var ol = this.el = document.body.appendChild(createOverlay(opt.zIndex, opt.trans));
}
/**
* @param {Number} zIndex Description
* @return {Element} description
*/
function createOverlay(zIndex, trans) {
var CSS = {
'top': '0',
'left': '0',
'width': '100%',
'height': '100%',
'background': 'rgba(0,0,0,' + trans + ')',
'z-index': zIndex,
'position': 'fixed'
};
var el = document.createElement('div');
el.classList.add('cl-overlay');
Css(el, CSS);
return el;
};
/**
* @return {void} description
*/
Overlay.prototype.remove = function() {
document.body.removeChild(this.el)
};
module.exports = {
Overlay: Overlay
};