////call the following from <body onload="load()">
////required so that background blur is dimensioned correctly (with respect to scroll issues with browser)
////enable js to be called after ajax postback
function loadAjaxHandlers() {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
//will process during the initialization of the postback
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(
function() {
SetWaitDimensions();
}
)
}
function ShowWait(progressControlId) {
SetWaitDimensions();
document.getElementById(progressControlId).style.display = 'block';
}
//set dimensions of blur element, positions progress box
function SetWaitDimensions() {
if (document.getElementById) {
var blur = document.getElementById('OuterTableCellOverlay');
var progress = document.getElementById('InnerTableCellOverlay');
progress.style.width = '444px';
progress.style.height = '100px';
var vp = getViewport();
var dm = getElementDimensions(document.body);
var sp = getScrollPosition();
if (vp.height > dm.height)
blur.style.height = vp.height + 'px';
else
blur.style.height = dm.height + 'px';
blur.style.width = '100%';
blur.style.top = (sp.y + ((vp.height - dm.height) / 3)) + 'px';
blur.style.left = (sp.x + ((vp.width - dm.width) / 2)) + 'px';
progress.style.top = document.documentElement.clientHeight / 3 - progress.style.height.replace('px', '') / 2 + 'px';
progress.style.left = document.body.offsetWidth / 2 - progress.style.width.replace('px', '') / 2 + 'px';
}
}
//returns view port dimensions
function getViewport() {
var v = { width: 0, height: 0 };
if (window.innerHeight) {
v.height = window.innerHeight;
v.width = window.innerWidth;
} else if (document.documentElement.clientHeight) {
v.height = document.documentElement.clientHeight;
v.width = document.documentElement.clientWidth;
} else {
v.height = document.body.clientHeight;
v.width = document.body.clientWidth;
}
return v;
}
//returns dimensions of element
function getElementDimensions(el) {
var dim = { width: 0, height: 0 };
dim.width = el.offsetWidth;
dim.height = el.offsetHeight;
return dim;
}
//returns window scroll position
function getScrollPosition() {
var pos = { x: 0, y: 0 };
pos.x = window.pageXOffset ? window.pageXOffset : document.documentElement.scrollLeft;
pos.y = window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop;
return pos;
}