add com..

This commit is contained in:
wlh
2015-01-07 22:49:23 +08:00
parent b690d5bdbf
commit e31afd76bb
14 changed files with 412 additions and 11 deletions
+41
View File
@@ -0,0 +1,41 @@
/*
* Mask: You can use the function in your project,
* when don't want the user to pay attention to inside information of DIV.
*/
(function(exports){
var Mask = function(id/*target element id*/, otherCssObj /*is a json obj, like css text*/){
var mask = document.getElementById(id);
var width = mask.offsetWidth;
var height = mask.offsetHeight;
this.div = document.createElement('div');
this.div.style.position = 'absolute';
this.div.style.left = mask.offsetLeft + 'px';
this.div.style.top = mask.offsetTop + 'px';
this.div.style.zIndex = 300;
this.div.style.width = width + 'px';
this.div.style.height = height + 'px';
this.div.style.backgroundColor = '#000';
this.div.style.opacity = 0.5; // 考虑
//add other css, like backgroundColor、border...
if(otherCssObj){
for(var key in otherCssObj){
this.div.style[key] = otherCssObj[key];
}
}
mask.appendChild(this.div);
this.div.style.display = 'none';
};
Mask.prototype.show = function(){
this.div.style.display = 'block';
};
Mask.prototype.hide = function(){
this.div.style.display = 'none';
};
exports.Mask = Mask;
})(window);