in trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Window.js [84:423]
function openWindow(
parentWindow,
srcURL,
windowName,
features,
isModal,
kind,
closeCallback
)
{
if (parentWindow)
{
// default modality if none specified
if (isModal == (void 0))
isModal = false;
// if the kind isn't specified, default the kind off of the modality
if (!kind)
{
kind = (isModal) ? "dialog" : "document";
}
// default the window name to "_blank" if no
// name is specified, in order to guarantee that a new window is
// opened
if (!windowName)
windowName = "_blank";
//
// pick the correct defaults and overrides
//
var defaults = _featureDefaults[kind];
if (defaults == (void 0))
{
kind = "document";
defaults = _featureDefaults[kind];
}
var overrides = (isModal)
? _modalFeatureOverrides
: _modelessFeatureOverrides;
// determine the avialable features
var agentFeatures = (_agent.isIE)
? _ieFeatures
: _nnFeatures;
// we'll be hammering the features object, so make a copy
var featuresCopy = null;
if (features)
{
featuresCopy = new Object();
for (var f in features)
{
featuresCopy[f] = features[f];
}
}
//
// build up the feature string
//
var featureString = "";
// loop through the available features for this platform
for (var featureName in agentFeatures)
{
// get the overridden value of the feature
var featureValue = overrides[featureName];
if (featureValue == (void 0))
{
// get the value of the feature if it isn't overridden
if (featuresCopy)
{
featureValue = featuresCopy[featureName];
delete featuresCopy[featureName];
}
// if no value, get the default value, if any
if (featureValue == (void 0))
featureValue = defaults[featureName];
}
if (featureValue != (void 0))
{
// check if this is a boolean value
var isBoolean = _booleanFeatures[featureName] != (void 0);
// output the value
if (featureValue || !isBoolean)
{
// add the feature name
featureString += featureName;
// add the value for nonboolean features
if (!isBoolean)
{
featureString += "=" + featureValue;
}
// add separator between this and the next
featureString += ",";
}
}
}
// Now tack on all the extra features that the user has requested.
// These may or may not have meaning to the browser's implementation of
// window.open().
for (var f in featuresCopy)
{
featureString += f;
if (featuresCopy[f])
featureString += "=" + featuresCopy[f];
featureString += ",";
}
// trim off last separator
if (featureString.length != 0)
{
featureString = featureString.substring(0, featureString.length - 1);
}
// register the closing callback
if (closeCallback)
{
_setDependent(parentWindow, windowName, closeCallback);
}
// open an empty window
var newWindow = parentWindow.open(srcURL, windowName, featureString);
// Check for popup blockers.
// This will certainly all change, but now (early 2005) the popup blockers
// work thusly:
//
// Google: The return value from window.open is null.
// Safari: The return value from window.open is null.
// FireFox: The return value from window.open is a valid object
// with no properties.
// Yahoo!: The return value from window.open is a valid object which
// throws an exception when you try to do anything with it.
var usableWindow = false;
if (newWindow != null)
{
var propCount = 0;
try
{
for (p in newWindow)
{
propCount++;
break;
}
// if (propCount == 0) this is Firefox popup blocker
if (propCount > 0)
usableWindow = true;
}
catch (e)
{
// Yahoo! toolbar throws an exception when you try to access any of the
// new window's properties.
}
}
// else this is the Safari or Google Toolbar popup blocker
if (!usableWindow)
{
_setDependent(parentWindow, windowName, (void 0));
if (_AdfWindowOpenError != null)
alert(_AdfWindowOpenError);
return;
}
// detect the bogus ie4 and turn off modal windows
var atMostIE4 = _agent.atMost("ie", 4.99);
var alphaFilter = false;
// document of the parent window
var parentDoc = parentWindow.document;
// body of the parent window
var parentBody = parentDoc.body;
if (isModal && !atMostIE4)
{
if (_agent.atLeast("ie", 4) || _agent.isSafari)
{
var dimmer = parentDoc.getElementById("_trDialogDimmer");
if (dimmer == null)
{
// Display a div over the browser viewport that will give the entire page the appearance
// of being disabled:
dimmer = parentDoc.createElement("div");
dimmer.id = "_trDialogDimmer";
var dimmerStyle = dimmer.style;
dimmerStyle.position = "absolute";
dimmerStyle.zIndex = "32000";
dimmerStyle.backgroundColor = "#FFFFFF";
// prefer opacity usage
if (dimmerStyle.opacity != 'undefined') {
dimmerStyle.opacity = "0.5";
} else if (dimmerStyle.filter != 'undefined') {
dimmerStyle.filter = "alpha(opacity=50)";
}
// Position the dimmer element, account for scrolling:
var docElement = parentDoc.documentElement;
var width = Math.max(docElement.offsetWidth, docElement.scrollWidth);
var height = Math.max(docElement.offsetHeight, docElement.scrollHeight);
dimmerStyle.width = width + "px";
dimmerStyle.height = height + "px";
dimmerStyle.top = "0px";
dimmerStyle.left = "0px";
// Add the dimmer element to the body:
parentBody.appendChild(dimmer);
alphaFilter = true;
}
}
// Capture mouse events. Note: we special-case IE/Windows,
// and only apply the capture after window.open() has been
// called. See below for details.
// XXXSafari: What to do for Safari?
if (_agent.isGecko)
{
// this should work, but doesn't appear to
if (parentBody != (void 0))
_addModalCaptureGecko(parentBody);
}
parentWindow.onfocus = _onModalFocus;
}
// Apply mouse capture for IE/Windows. Starting in IE 6.0.2800,
// if we apply the capture before calling window.open(), the capture
// is lost immediately when the secondary window receives the
// focus. To make matters worse, the _onModalFocus handler that
// we register on the parent window is no longer invoked (not
// sure why?!). The end result is that the user can interact
// with the parent window even when a modal child is displayed.
// Delaying our setCapture() call until after window.open()
// seems to work around the problem.
if (isModal && (_agent.atLeast("ie", 5) && _agent.isWindows))
{
_addModalCaptureIE(parentBody);
// Set up an onlosecapture handler so that we can
// restore the capture if we unexpectedly lose it.
// this code has been removed as it caused IE to "lock up" when
// IE7 is set to force new windows to open in tabs instead of new
// windows.
//parentBody.onlosecapture = _onModalLoseCapture;
// Popup blockers!
// BUG 4428033 - ECM: MENUS BECOM DISABLED AFTER RAISING A DIALOG
// FROM A COMMANDMENUITEM
// When a popup blocker is installed, the onunload event is often
// not delivered to listeners attached in the scope of the opened
// modal window. However, onunload events _are_ delivered to
// listeners attached in the opener context.
//
// However, this onunload event listing is only permitted within the
// same scripting domain. We should really verify if the domains match
// or not, but relative URLs are always in the same domain, so just
// test for absolute URLs instead.
//
// A quick check for absolute URL is to test the presence of an
// unescaped colon.
//
var isAbsolute = (srcURL != null && srcURL.indexOf(':') != -1);
if (!isAbsolute)
{
var removeCapture = new Function("e", "_removeModalCaptureIE(window.document.body)");
// IE 11 bug
if(newWindow.attachEvent) {
newWindow.attachEvent("onunload", removeCapture);
} else {
newWindow.addEventListener("onunload", removeCapture);
}
}
}
/*
// create the content for the window. We use a frameset so that
// the content can change without firing the window close event.
var realSrcURL = "<html>";
//realSrcURL += "<head><scr";
//realSrcURL += 'ipt src="/images/jsLibs/Window.js"></head>';
realSrcURL += '<frameset rows="100%,*" border="0" onunload="_checkUnload(event)"><frame src="' +
srcURL +
'"></frameset></html>';
newWindow.document.write(realSrcURL);
newWindow.document.close();
*/
if (isModal && !atMostIE4)
{
_setDependent(parentWindow, "modalWindow", newWindow);
}
// If there are any poll commands registered, they should be deactivated when the
// modal window gets launched. They need to be reactivated upon closing the
// modal dependent using _pollWhenModalDependentCloses().
// Cleaner alternative to _pollWhenModalDependentCloses() could have been to use a
// registered callback like _checkUnload(), _onModalFocus(), _onModalLoseCapture().
// But none of these were reliable for either of...
// 1. One of them is to workaround IE grabbing focus on parent
// while dialog launch in progress.
// 2. Does not get called when dialog is dismissed using the close
// button on the window, particularly for case of dialogs
// launched using openWindow().
if (isModal && self._pollManager)
{
_pollManager.deactivateAll();
_pollWhenModalDependentCloses();
}
// make the active window
newWindow.focus();
// Set up a timer to make sure that we reset the alpha filter.
if (alphaFilter)
{
parentWindow.setTimeout("_clearBodyModalEffects('alpha')", 1000);
}
return newWindow;
}
else
{
return null;
}
}