|
|
|
|
|
|
|
nv.utils.windowSize = function() {
|
|
|
|
// Sane defaults
|
|
|
|
var size = {width: 640, height: 480};
|
|
|
|
|
|
|
|
// Earlier IE uses Doc.body
|
|
|
|
if (document.body && document.body.offsetWidth) {
|
|
|
|
size.width = document.body.offsetWidth;
|
|
|
|
size.height = document.body.offsetHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IE can use depending on mode it is in
|
|
|
|
if (document.compatMode=='CSS1Compat' &&
|
|
|
|
document.documentElement &&
|
|
|
|
document.documentElement.offsetWidth ) {
|
|
|
|
size.width = document.documentElement.offsetWidth;
|
|
|
|
size.height = document.documentElement.offsetHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Most recent browsers use
|
|
|
|
if (window.innerWidth && window.innerHeight) {
|
|
|
|
size.width = window.innerWidth;
|
|
|
|
size.height = window.innerHeight;
|
|
|
|
}
|
|
|
|
return (size);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Easy way to bind multiple functions to window.onresize
|
|
|
|
// TODO: give a way to remove a function after its bound, other than removing alkl of them
|
|
|
|
nv.utils.windowResize = function(fun){
|
|
|
|
var oldresize = window.onresize;
|
|
|
|
|
|
|
|
window.onresize = function(e) {
|
|
|
|
if (typeof oldresize == 'function') oldresize(e);
|
|
|
|
fun(e);
|
|
|
|
}
|
|
|
|
}
|