зеркало из https://github.com/mozilla/gecko-dev.git
Bug 136901 toOpenWindowByType should never open multiple windows r=varga sr=bz
This commit is contained in:
Родитель
ef582a5d90
Коммит
dce8de5c63
|
@ -1181,34 +1181,9 @@ function BrowserOpenFileWindow()
|
|||
}
|
||||
}
|
||||
|
||||
// Set up a lame hack to avoid opening two bookmarks.
|
||||
// Could otherwise happen with two Ctrl-B's in a row.
|
||||
var gDisableBookmarks = false;
|
||||
function enableBookmarks()
|
||||
{
|
||||
gDisableBookmarks = false;
|
||||
}
|
||||
|
||||
function BrowserEditBookmarks()
|
||||
{
|
||||
// Use a single sidebar bookmarks dialog
|
||||
var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
|
||||
var bookmarksWindow = windowManager.getMostRecentWindow("bookmarks:manager");
|
||||
|
||||
if (bookmarksWindow) {
|
||||
bookmarksWindow.focus();
|
||||
} else {
|
||||
// while disabled, don't open new bookmarks window
|
||||
if (!gDisableBookmarks) {
|
||||
gDisableBookmarks = true;
|
||||
|
||||
open("chrome://communicator/content/bookmarks/bookmarksManager.xul", "_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
|
||||
setTimeout(enableBookmarks, 2000);
|
||||
}
|
||||
}
|
||||
toOpenWindowByType("bookmarks:manager", "chrome://communicator/content/bookmarks/bookmarksManager.xul");
|
||||
}
|
||||
|
||||
function updateCloseItems()
|
||||
|
@ -2194,40 +2169,9 @@ function StatusbarViewPopupManager() {
|
|||
"chrome,resizable=yes", hostPort, false);
|
||||
}
|
||||
|
||||
// Set up a lame hack to avoid opening two bookmarks.
|
||||
// Could otherwise happen with two Ctrl-B's in a row.
|
||||
var gDisableHistory = false;
|
||||
function enableHistory() {
|
||||
gDisableHistory = false;
|
||||
}
|
||||
|
||||
function toHistory()
|
||||
{
|
||||
// Use a single sidebar history dialog
|
||||
|
||||
var cwindowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
|
||||
var iwindowManager = Components.interfaces.nsIWindowMediator;
|
||||
var windowManager = cwindowManager.QueryInterface(iwindowManager);
|
||||
|
||||
var historyWindow = windowManager.getMostRecentWindow('history:manager');
|
||||
|
||||
if (historyWindow) {
|
||||
//debug("Reuse existing history window");
|
||||
historyWindow.focus();
|
||||
} else {
|
||||
//debug("Open a new history dialog");
|
||||
|
||||
if (true == gDisableHistory) {
|
||||
//debug("Recently opened one. Wait a little bit.");
|
||||
return;
|
||||
}
|
||||
gDisableHistory = true;
|
||||
|
||||
window.open( "chrome://communicator/content/history/history.xul", "_blank",
|
||||
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar" );
|
||||
setTimeout(enableHistory, 2000);
|
||||
}
|
||||
|
||||
toOpenWindowByType("history:manager", "chrome://communicator/content/history/history.xul");
|
||||
}
|
||||
|
||||
function checkTheme()
|
||||
|
|
|
@ -91,16 +91,24 @@ function toOpenWindow( aWindow )
|
|||
|
||||
function toOpenWindowByType( inType, uri )
|
||||
{
|
||||
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
|
||||
// Recently opened one.
|
||||
if (uri in window)
|
||||
return;
|
||||
|
||||
var windowManagerInterface = windowManager.QueryInterface(nsIWindowMediator);
|
||||
var windowManager = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(nsIWindowMediator);
|
||||
|
||||
var topWindow = windowManagerInterface.getMostRecentWindow( inType );
|
||||
|
||||
if ( topWindow )
|
||||
toOpenWindow(topWindow);
|
||||
else
|
||||
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
|
||||
var topWindow = windowManager.getMostRecentWindow( inType );
|
||||
|
||||
if ( topWindow )
|
||||
toOpenWindow( topWindow );
|
||||
else
|
||||
{
|
||||
function newWindowLoaded(event) {
|
||||
delete window[uri];
|
||||
}
|
||||
window[uri] = window.openDialog(uri, "", "all,dialog=no");
|
||||
window[uri].addEventListener("load", newWindowLoaded, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче