// ----------------------------------------------------------------------------
// winman.js
// Window Management helper functions
// ----------------------------------------------------------------------------
var vcchldwin;
var dlgwin;
var vchlpwin;
// Alert the user if the indicator needs to be saved
function checkindicator() {
if (document.vcapp && document.vcapp.needsSaving) {
if (document.vcapp.needsSaving()) {
return confirm(W23_IND_CHANGED_MSG);
//return confirm('Click OK to continue without saving your changes or Cancel to return so you can save.');
}
}
// The indicator does not need to be saved. Return true so that the HREF
// link is followed.
return true;
}
// ----------------------------------------------------------------------------
// Window Open methods
// ----------------------------------------------------------------------------
function showdlg ( loc ) {
var sz = "width=800,height=450,resizable=no,scrollbars=yes,screenX=100,screenY=100,top=100,left=100";
dlgwin = window.open ( loc, "dlgwin", sz+",menubar=no,status=no,location=no" );
if (!dlgwin.opener) { dlgwin.opener = self; }
}
function showchild ( loc ) {
var sz = "resizable=yes,width=810,height=600,screenX=0,screenY=0,top=0,left=0";
vcchldwin = window.open ( loc, "vcchldwin", sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!vcchldwin.opener) { vcchldwin.opener = self; }
}
function userwin ( loc ) {
var sz = "resizable=no,width=810,height=600,screenX=0,screenY=0,top=0,left=0";
vcchldwin = window.open ( loc, "vcchldwin", sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!vcchldwin.opener) { vcchldwin.opener = self; }
}
function indicatorwin ( loc ) {
var sz = "resizable=yes,width=810,height=600,screenX=0,screenY=0,top=0,left=0";
vcchldwin = window.open ( loc, "vcchldwin", sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!vcchldwin.opener) { vcchldwin.opener = self; }
}
function indicatorpreviewwin ( loc ) {
var sz = "resizable=yes,width=810,height=600,screenX=0,screenY=0,top=0,left=0";
vcchldwin = window.open ( loc, "vcchldwin", sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!vcchldwin.opener) { vcchldwin.opener = self; }
}
function viewwiz ( loc ) {
var sz = "resizable=yes,width=810,height=600,screenX=0,screenY=0,top=0,left=0";
vcchldwin = window.open ( loc, "vcchldwin", sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!vcchldwin.opener) { vcchldwin.opener = self; }
}
function showHelp ( loc, ctx ) {
var sz = "width=400,height=600,resizable=yes,screenX=100,screenY=100,top=100,left=100";
vchlpwin = window.open ( loc+"?context="+ctx, "vchlpwin", sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!vchlpwin.opener) { vchlpwin.opener = self; }
}
function showDemo ( loc ) {
vcdemowin = window.open ( "", "robodemowin", "fullscreen=0,scrollbars=1,resizable=1" )
vcdemowin.moveTo ( 0, 0 )
vcdemowin.resizeTo ( 1024, 768 )
//vcdemowin.resizeBy ( 15, 0 )
var htmlString =
" "+
"
"+
""+
"
"+
"";
vcdemowin.document.open ();
vcdemowin.document.write ( htmlString )
vcdemowin.document.close ()
}
function viewtypewin ( loc, tgt ) {
var features;
features = "resizable=yes,menubar=no,status=no,location=no,";
if ( tgt == 'vta' ) {
features += "width=790,height=411";
} else if ( tgt == 'vt2a' ) {
features += "width=790,height=397";
} else if ( tgt == 'vthm' ) {
features += "width=790,height=364";
} else if ( tgt == 'vt3a' ) {
features += "width=790,height=427";
} else if ( tgt == 'types' ) {
features += "width=808,height=600,scrollbars=yes";
} else {
features += "width=790,height=600";
}
var newwin = window.open ( loc, tgt, features );
if (!newwin.opener) { newwin.opener = self; }
}
// ----------------------------------------------------------------------------
// this will be called from java client to affect bringing up the url in another
// window.
// ----------------------------------------------------------------------------
function j2jexec ( loc, tgt ) {
if ( loc.indexOf ( "closewin" ) == 0 ) {
closewin ( 'vca_home.jsp' );
} else {
if ( tgt == "viewwiz" ) {
viewwiz ( loc );
} else if ( tgt == "repwin" ) {
var sz = "resizable=yes,width=810,height=600,screenX=0,screenY=0,top=0,left=0";
var newwin = window.open ( loc, tgt, sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!newwin.opener) { newwin.opener = self; }
} else if ( tgt == "prtwin" ) {
var sz = "resizable=yes,width=725,height=600,screenX=0,screenY=0,top=0,left=0";
var newwin = window.open ( loc, tgt, sz+",menubar=no,status=no,location=no,scrollbars=yes" );
if (!newwin.opener) { newwin.opener = self; }
} else {
var sz = "resizable=yes,width=800,height=500,screenX=0,screenY=0,top=0,left=0";
var newwin = window.open ( loc, tgt, sz+",menubar=no,status=no,location=no" );
if (!newwin.opener) { newwin.opener = self; }
}
}
}
function showincurrent ( loc ) {
window.location.replace ( loc );
}
// ----------------------------------------------------------------------------
// Window close methods
// ----------------------------------------------------------------------------
function closewin ( loc ) {
//alert ( loc );
var tgt;
if ( window.opener ) {
tgt = window.opener;
//alert ( "window has an opener:"+tgt.location );
} else {
tgt = window;
//alert ( "window has NO opener:"+tgt.location );
}
if ( loc.length <= 0 ) {
tgt.location.reload ();
} else {
tgt.location.replace ( loc );
}
if ( window.opener )
window.close ();
}
function closethischild () {
if ( window.opener )
window.close ();
}
// ----------------------------------------------------------------------------
// this will allow javascript to call the java client to perform client actions
// ----------------------------------------------------------------------------
function sendaction ( action ) {
document.vcapp.performSubstitutedVCAction ( action, true );
//document.vcapp.performVCAction ( action );
}
// ----------------------------------------------------------------------------
// Window resizing
// ----------------------------------------------------------------------------
function getContentWidth ( win ) {
if ( win == null ) { return null; }
var width = -1;
if ( win.document.body && win.document.body.scrollWidth ) {
width = win.document.body.scrollWidth;
//alert ( win.document.body.scrollWidth );
} else if ( win.document.documentElement && win.document.documentElement.scrollWidth ) {
//alert ( "document.documentElement" );
width = win.document.documentElement.scrollWidth;
}
return width;
}
function getContentHeight ( win ) {
if ( win == null ) { return null; }
var height = -1;
if ( win.document.body && win.document.body.scrollHeight ) {
height = win.document.body.scrollHeight;
} else if ( win.document.documentElement && win.document.documentElement.scrollHeight ) {
height = win.document.documentElement.scrollHeight;
}
return height;
}
function getWindowWidth ( win ) {
if ( win == null ) { return null; }
var width = -1;
if ( win.innerWidth && ( typeof ( win.innerWidth ) == 'number' ) ) {
//Non-IE
width = win.innerWidth;
} else {
if ( document.documentElement && document.documentElement.clientWidth ) {
//IE 6+ in 'standards compliant mode'
width = document.documentElement.clientWidth;
} else {
if ( document.body && document.body.clientWidth ) {
//IE 4 compatible
width = document.body.clientWidth;
}
}
}
return width;
}
function getWindowHeight ( win ) {
if ( win == null ) { return null; }
var height = -1;
if ( win.innerHeight && ( typeof ( win.innerHeight ) == 'number' ) ) {
//Non-IE
height = win.innerHeight;
} else {
if ( document.documentElement && document.documentElement.clientHeight ) {
//IE 6+ in 'standards compliant mode'
height = document.documentElement.clientHeight;
} else {
if ( document.body && document.body.clientHeight ) {
//IE 4 compatible
height = document.body.clientHeight;
}
}
}
return height;
}
function getWindowX ( win ) {
if ( win == null ) { return null; }
var x = 0;
if ( win.screenX && ( typeof ( win.screenX ) == 'number' ) ) {
x = win.screenX; // NN 4+
} else if ( win.screenLeft && ( typeof ( win.screenLeft ) == 'number' ) ) {
x = win.screenLeft - 4; // IE 5+
}
return x;
}
function getWindowY ( win ) {
if ( win == null ) { return null; }
var y = 0;
if ( win.screenY && ( typeof ( win.screenY ) == 'number' ) ) {
y = win.screenY; // NN 4+
} else if ( win.screenTop && ( typeof ( win.screenTop ) == 'number' ) ) {
y = win.screenTop; // IE 5+
}
return y;
}
//
// TODO:
// - IE: adjust for window title bar
// - adjust x position for scrollbar
// - NN6+: find soln for intermittent operation. Navigator intermittently
// reports content dimensions the same as the window.
//
function resizewin ( win ) {
if ( win == null || win.closed ) { return; }
// if we can obtain content dimensions, continue
if ( (win.document.body && win.document.body.scrollHeight) ||
(win.document.documentElement && win.document.documentElement.scrollHeight) ) {
var APPDEFWIDTH = 800;
var APPDEFHEIGHT = 600;
var contentWidth = getContentWidth ( win );
var contentHeight = getContentHeight ( win );
var windowWidth = getWindowWidth ( win );
var windowHeight = getWindowHeight ( win );
var windowX = getWindowX ( win );
var windowY = getWindowY ( win );
var reposition = false;
var x = 0;
var y = 0;
var dw = 0;
var dh = 0;
if ( contentWidth == null || contentWidth < 0 ) { contentWidth = APPDEFWIDTH; }
if ( contentHeight == null || contentHeight < 0 ) { contentHeight = APPDEFHEIGHT; }
if ( windowWidth == null || windowWidth < 0 ) { windowWidth = APPDEFWIDTH; }
if ( windowHeight == null || windowHeight < 0 ) { windowHeight = APPDEFHEIGHT; }
if ( contentWidth > win.screen.availWidth ) {
contentWidth = win.screen.availWidth;
}
if ( contentHeight > win.screen.availHeight ) {
contentHeight = win.screen.availHeight;
}
//alert( contentWidth + ' x ' + contentHeight );
if ( ( windowX + contentWidth ) > win.screen.availWidth ) {
reposition = true;
x = win.screen.availWidth - contentWidth;
} else {
if ( windowX < 0 ) {
reposition = true;
x = 0;
} else {
x = windowX;
}
}
if ( ( windowY + contentHeight ) > win.screen.availHeight ) {
reposition = true;
y = win.screen.availHeight - contentHeight;
} else {
if ( windowY < 0 ) {
reposition = true;
y = 0;
} else {
y = windowY;
}
}
if ( reposition ) {
win.moveTo ( x, y );
}
dw = contentWidth - windowWidth;
dh = contentHeight - windowHeight;
win.resizeBy ( dw, dh );
}
}