<!-- lang: js -->
/**
* Masker V0.2
* Last Update:2011-01-27
*
* FOR: IE6,IE7,IE8,Firefox
* Usage:
* cv.ui.masker.mask();
* cv.ui.masker.unmask();
*/
(function(){
var resize_function=function(){
var css={};
css.width=cv.ui.masker._bwidth;
css.height=cv.ui.masker._bheight;
cv.Cache.get("cv_mask").css(css);
};
var _default={
css:{
opacity:0.55,
background:"#fff"
}
};
cv.ui.masker={
isShown:false,
mask:function(options){
var $=jQuery;
var thix=cv.ui.masker;
if(thix.isShown)return;
options = $.extend(true,{},_default, options);
var mask=cv.Cache.get("cv_mask",function(){
//init
$(window).resize(function(){
if(cv.ui.masker.isShown)return;
cv.Cache.get("cv_mask").css({
width: thix._bwidth(),
height: thix._bheight()
});
});
return $("<div id='cv_mask' class='cv_mask'></div>").appendTo('body').bgiframe();
});
//cv.Cache.get end
/*if ($.browser.msie) {
w= document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
} else {
w= thix._bwidth();
}
h= thix._bheight();*/
thix.isShown=true;
options.css.width=thix._bwidth();
options.css.height=thix._bheight();
options.css.visibility="visible";
mask.css(options.css);
$(window).bind("resize",resize_function);
},
unmask:function(){
cv.ui.masker.isShown=false;
cv.Cache.get("cv_mask").css({
visibility:"hidden",
width:0,
height:0
});
jQuery(window).unbind("resize",resize_function);
},
//取得遮照高度
_bheight:function() {
var $=jQuery;
if ($.browser.msie && $.browser.version < 7) {
var scrollHeight = Math.max(
document.documentElement.scrollHeight,
document.body.scrollHeight
);
var offsetHeight = Math.max(
document.documentElement.offsetHeight,
document.body.offsetHeight
);
if (scrollHeight < offsetHeight) {
return $(window).height();
} else {
return scrollHeight;
}
} else {
return $(document).height();
}
},
//取得遮照宽度
_bwidth:function() {
var $=jQuery;
if ($.browser.msie && $.browser.version < 7) {
var scrollWidth = Math.max(
document.documentElement.scrollWidth,
document.body.scrollWidth
);
var offsetWidth = Math.max(
document.documentElement.offsetWidth,
document.body.offsetWidth
);
if (scrollWidth < offsetWidth) {
return $(window).width();
} else {
return scrollWidth;
}
} else {
return $(document).width();
}
}
};
})();
转载于:https://my.oschina.net/wrean/blog/126897