From 37ae3e9fbb74a11fbec4e2f7d7467d749c069e83 Mon Sep 17 00:00:00 2001 From: "davidm%netscape.com" Date: Sun, 18 Jul 1999 23:46:28 +0000 Subject: [PATCH] Add cycle window function git-svn-id: svn://10.0.0.236/trunk@40054 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/suite/browser/navigator.js | 60 +++++++++++++++++++ .../browser/resources/content/navigator.js | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/mozilla/suite/browser/navigator.js b/mozilla/suite/browser/navigator.js index d4ebcdddb13..ca6dcadc894 100644 --- a/mozilla/suite/browser/navigator.js +++ b/mozilla/suite/browser/navigator.js @@ -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" ); + } +} diff --git a/mozilla/xpfe/browser/resources/content/navigator.js b/mozilla/xpfe/browser/resources/content/navigator.js index d4ebcdddb13..ca6dcadc894 100644 --- a/mozilla/xpfe/browser/resources/content/navigator.js +++ b/mozilla/xpfe/browser/resources/content/navigator.js @@ -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" ); + } +}