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

This commit is contained in:
cmanske%netscape.com 2001-01-12 22:31:16 +00:00
Родитель 6840989fca
Коммит 43b60cde06
3 изменённых файлов: 42 добавлений и 5 удалений

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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()
{