Opening a URL in editor always checks for existing window, b=64129, r=mjudge, sr=sfraser

git-svn-id: svn://10.0.0.236/trunk@84895 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
cmanske%netscape.com 2001-01-12 22:31:16 +00:00
parent 0760355aeb
commit 415d88791c
3 changed files with 42 additions and 5 deletions

View File

@ -92,7 +92,9 @@ function open()
window.opener.delayedOpenWindow(getBrowserURL(), "all,dialog=no", dialog.input.value);
break;
case "2":
window.opener.delayedOpenWindow("chrome://editor/content", "chrome,all,dialog=no", dialog.input.value);
// editPage is in utilityOverlay.js (all editor openers with URL should use this)
// 3rd param tells editPage to use "delayedOpenWindow"
editPage(dialog.input.value, window.opener, true);
break;
}
}

View File

@ -101,10 +101,7 @@
return true;
}
function editPage(url)
{
window.openDialog( "chrome://editor/content", "_blank", "chrome,all,dialog=no", url );
}
//Note: "function editPage(url)" was moved to utilityOverlay.js
function findParentNode(node, parentNode)
{

View File

@ -402,6 +402,44 @@ function NewEditorFromDraft()
// XXX not implemented
}
// Any non-editor window wanting to create an editor with a URL
// should use this instead of "window.openDialog..."
// We must always find an existing window with requested URL
// (When calling from a dialog, "launchWindow" is dialog's "opener"
// and we need a delay to let dialog close)
function editPage(url, launchWindow, delay)
{
// User may not have supplied a window
if (!launchWindow)
launchWindow = window;
var windowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
if (!windowManager) return;
var windowManagerInterface = windowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
if ( !windowManagerInterface ) return;
var enumerator = windowManagerInterface.getEnumerator( "composer:html" );
if ( !enumerator ) return;
while ( enumerator.hasMoreElements() )
{
var window = windowManagerInterface.convertISupportsToDOMWindow( enumerator.getNext() );
if ( window && window.editorShell)
{
if (window.editorShell.checkOpenWindowForURLMatch(url, window))
{
// We found an editor with our url
window.focus();
return;
}
}
}
// Create new Composer window
if (delay)
launchWindow.delayedOpenWindow("chrome://editor/content", "chrome,all,dialog=no", url);
else
launchWindow.openDialog("chrome://editor/content", "_blank", "chrome,all,dialog=no", url);
}
function helpMenuCreate()
{