From d4771c5f0db55f49aff74cc047718c4264f11490 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 19 Feb 2013 16:27:16 -0500 Subject: [PATCH] Focus preferences window if already showing Previously, if the prefwindow was behind another window, nothing would happen when opening the preferences. --- chrome/content/zotero/zoteroPane.js | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index d632ff8394..763ece7d83 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -2596,12 +2596,30 @@ var ZoteroPane = new function() pane: paneID, action: action }; - window.openDialog('chrome://zotero/content/preferences/preferences.xul', - 'zotero-prefs', - 'chrome,titlebar,toolbar,centerscreen,' - + Zotero.Prefs.get('browser.preferences.instantApply', true) ? 'dialog=no' : 'modal', - io - ); + + var win = null; + // If window is already open, just focus it + if (!action) { + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + var enumerator = wm.getEnumerator("zotero:pref"); + if (enumerator.hasMoreElements()) { + var win = enumerator.getNext(); + win.focus(); + if (paneID) { + var pane = win.document.getElementsByAttribute('id', paneID)[0]; + pane.parentElement.showPane(pane); + } + } + } + if (!win) { + window.openDialog('chrome://zotero/content/preferences/preferences.xul', + 'zotero-prefs', + 'chrome,titlebar,toolbar,centerscreen,' + + Zotero.Prefs.get('browser.preferences.instantApply', true) ? 'dialog=no' : 'modal', + io + ); + } }