Focus window in command line handler
This commit is contained in:
parent
a8631f760a
commit
00fdeb3bf9
1 changed files with 9 additions and 4 deletions
|
@ -80,11 +80,16 @@ ZoteroCommandLineHandler.prototype = {
|
|||
if(param) {
|
||||
var uri = cmdLine.resolveURI(param);
|
||||
if(uri.schemeIs("zotero")) {
|
||||
// Don't open a new window
|
||||
cmdLine.preventDefault = true;
|
||||
|
||||
Components.classes["@mozilla.org/network/protocol;1?name=zotero"]
|
||||
// Check for existing window and focus it
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow("navigator:browser");
|
||||
if(win) {
|
||||
cmdLine.preventDefault = true;
|
||||
win.focus();
|
||||
Components.classes["@mozilla.org/network/protocol;1?name=zotero"]
|
||||
.createInstance(Components.interfaces.nsIProtocolHandler).newChannel(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue