From daa806f0f0925e1df8cefe573cfcbc4138e5dd94 Mon Sep 17 00:00:00 2001 From: "brade%netscape.com" Date: Wed, 27 Mar 2002 01:35:32 +0000 Subject: [PATCH] fix editPage to use "win" for var instead of "window", look for emptyWindows and use it if possible (bug 104908, r=cmanske, sr=kin, a=dbaron) git-svn-id: svn://10.0.0.236/trunk@117540 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/editorApplicationOverlay.js | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/mozilla/editor/ui/composer/content/editorApplicationOverlay.js b/mozilla/editor/ui/composer/content/editorApplicationOverlay.js index 2978d692a3b..9283aa7c699 100644 --- a/mozilla/editor/ui/composer/content/editorApplicationOverlay.js +++ b/mozilla/editor/ui/composer/content/editorApplicationOverlay.js @@ -122,22 +122,42 @@ function editPage(url, launchWindow, delay) var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService(); var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator); var enumerator = windowManagerInterface.getEnumerator( "composer:html" ); + var emptyWindow; while ( enumerator.hasMoreElements() ) { - var window = windowManagerInterface.convertISupportsToDOMWindow( enumerator.getNext() ); - if ( window && window.editorShell) + var win = windowManagerInterface.convertISupportsToDOMWindow( enumerator.getNext() ); + if ( win && win.editorShell) { - if (window.editorShell.checkOpenWindowForURLMatch(url, window)) + if (win.editorShell.checkOpenWindowForURLMatch(url, window)) { // We found an editor with our url - window.focus(); + win.focus(); return; } + else if (!emptyWindow && win.PageIsEmptyAndUntouched()) + { + emptyWindow = win; + } } } + + if (emptyWindow) + { + // we have an empty window we can use + if (emptyWindow.IsInHTMLSourceMode()) + emptyWindow.FinishHTMLSource(); + emptyWindow.editorShell.LoadUrl(url); + emptyWindow.focus(); + emptyWindow.SetSaveAndPublishUI(url); + return; + } + // Create new Composer window if (delay) - launchWindow.delayedOpenWindow("chrome://editor/content", "chrome,all,dialog=no", url, charsetArg); + { + dump("delaying\n"); + launchWindow.delayedOpenWindow("chrome://editor/content", "chrome,all,dialog=no", url); + } else launchWindow.openDialog("chrome://editor/content", "_blank", "chrome,all,dialog=no", url, charsetArg);