Add cycle window function

git-svn-id: svn://10.0.0.236/trunk@40054 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
davidm%netscape.com 1999-07-18 23:46:28 +00:00
parent ca20d842e8
commit 37ae3e9fbb
2 changed files with 120 additions and 0 deletions

View File

@ -922,3 +922,63 @@ function ShowWindowFromResource( node )
desiredWindow.focus();
}
}
function CycleWindow( inType, inChromeURL )
{
var windowManager = Components.classes['component://netscape/rdf/datasource?name=window-mediator'].getService();
dump("got window Manager \n");
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
dump("got interface \n");
var desiredWindow = null;
topWindowOfType = windowManagerInterface.GetMostRecentWindow( inType );
topWindow = windowManagerInterface.GetMostRecentWindow( null );
dump( "got windows \n");
if ( topWindowOfType != topWindow )
{
dump( "first not top so give focus \n");
topWindowOfType.focus();
return;
}
if ( topWindowOfType == null )
{
dump( " no windows of this type so create a new one \n");
window.open( inChromeURL, "","chrome" );
}
var enumerator = windowManagerInterface.GetEnumerator( inType );
firstWindow = windowManagerInterface.ConvertISupportsToDOMWindow ( enumerator.GetNext() );
if ( firstWindow == topWindowOfType )
{
dump( "top most window is first window \n");
firstWindow = null;
}
else
{
dump("find topmost window \n");
while ( enumerator.HasMoreElements() )
{
var nextWindow = windowManagerInterface.ConvertISupportsToDOMWindow ( enumerator.GetNext() );
if ( nextWindow == topWindowOfType )
break;
}
}
desiredWindow = firstWindow;
if ( enumerator.HasMoreElements() )
{
dump( "Give focus to next window in the list \n");
desiredWindow = windowManagerInterface.ConvertISupportsToDOMWindow ( enumerator.GetNext() );
}
if ( desiredWindow )
{
desiredWindow.focus();
dump("focusing window \n");
}
else
{
dump("open window \n");
window.open( inChromeURL, "","chrome" );
}
}

View File

@ -922,3 +922,63 @@ function ShowWindowFromResource( node )
desiredWindow.focus();
}
}
function CycleWindow( inType, inChromeURL )
{
var windowManager = Components.classes['component://netscape/rdf/datasource?name=window-mediator'].getService();
dump("got window Manager \n");
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
dump("got interface \n");
var desiredWindow = null;
topWindowOfType = windowManagerInterface.GetMostRecentWindow( inType );
topWindow = windowManagerInterface.GetMostRecentWindow( null );
dump( "got windows \n");
if ( topWindowOfType != topWindow )
{
dump( "first not top so give focus \n");
topWindowOfType.focus();
return;
}
if ( topWindowOfType == null )
{
dump( " no windows of this type so create a new one \n");
window.open( inChromeURL, "","chrome" );
}
var enumerator = windowManagerInterface.GetEnumerator( inType );
firstWindow = windowManagerInterface.ConvertISupportsToDOMWindow ( enumerator.GetNext() );
if ( firstWindow == topWindowOfType )
{
dump( "top most window is first window \n");
firstWindow = null;
}
else
{
dump("find topmost window \n");
while ( enumerator.HasMoreElements() )
{
var nextWindow = windowManagerInterface.ConvertISupportsToDOMWindow ( enumerator.GetNext() );
if ( nextWindow == topWindowOfType )
break;
}
}
desiredWindow = firstWindow;
if ( enumerator.HasMoreElements() )
{
dump( "Give focus to next window in the list \n");
desiredWindow = windowManagerInterface.ConvertISupportsToDOMWindow ( enumerator.GetNext() );
}
if ( desiredWindow )
{
desiredWindow.focus();
dump("focusing window \n");
}
else
{
dump("open window \n");
window.open( inChromeURL, "","chrome" );
}
}