Skip to content

Commit

Permalink
Starting Zotero 6 Mac support
Browse files Browse the repository at this point in the history
  • Loading branch information
frianasoa committed Apr 24, 2024
1 parent cd2df75 commit 1aa6560
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 17 deletions.
3 changes: 2 additions & 1 deletion bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async function waitForZotero() {
function listenForMainWindowEvents() {
mainWindowListener = {
onOpenWindow: function (aWindow) {
Zotero.debug('windowListener:onOpenWindow');
let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
async function onload() {
Expand Down Expand Up @@ -256,7 +257,7 @@ function onMainWindowLoad({ window }) {
ZeNotes.addToWindow(window);
}

function onMainWindowUnload({ window }) {
function onMainWindowUnload({window}) {
ZeNotes.removeFromWindow(window);
}

Expand Down
41 changes: 33 additions & 8 deletions core/menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Menu = {
window: null,
menu: null,
toolsmenu: null,
menubar: null,
opentab() {
var title = "All documents";
var collection = Zotero.getActiveZoteroPane().getSelectedCollection();
Expand All @@ -15,17 +18,29 @@ Menu = {
}
Ui.opentab("chrome:https://ze-notes/content/notes/notes.xhtml", title);
},

mainmenu(w){
var showmain = Prefs.get("add-to-menu");
showmain = showmain==true || showmain=="true";

if(this.menubar!=null)
{
if(Zotero.isMac)
{
this.menubar.insertBefore(this.menu, this.toolsmenu);
}
return;
}
else
{
w.onfocus = function(e){Zotero.ZeNotes.Menu.mainmenu(e.target)};
}

let stringBundle = Services.strings.createBundle(
'chrome:https://ze-notes/locale/zenotes.properties'
);
let document = w.document;



if(document.getElementById("zenotes-menu-main")!=null)
{
return;
Expand All @@ -41,17 +56,27 @@ Menu = {
// Add menu in front of tools
var toolsmenu = document.getElementById("toolsMenu");

if(Prefs.get("remove-menu", false)==true || Prefs.get("remove-menu", false)=="true")
if(toolsmenu)
{
toolsmenu.querySelector("menupopup").appendChild(menu);
// menubar.insertBefore(menu, toolsmenu);
if(Prefs.get("remove-menu", false)==true || Prefs.get("remove-menu", false)=="true")
{
toolsmenu.querySelector("menupopup").appendChild(menu);
}
else
{
menubar.insertBefore(menu, toolsmenu);
}
ZeNotes.storeAddedElement(menu);
}
else
{
menubar.insertBefore(menu, toolsmenu);
menubar.appendChild(menu);
}
ZeNotes.storeAddedElement(menu);

ZeNotes.storeAddedElement(toolsmenu);
this.menu = menu;
this.toolsmenu = toolsmenu;
this.menubar = menubar;

// Add popup
var menupopup = Zotero.createXULElement(document, "menupopup");
Expand Down
20 changes: 20 additions & 0 deletions core/zenotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,29 @@ ZeNotes = {
}
},

listen()
{
var listener = {
onOpenWindow: function (aWindow) {
let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
async function onload() {
domWindow.removeEventListener("load", onload, false);
if (domWindow.location.href !== "chrome:https://zotero/content/standalone/standalone.xul") {
return;
}
Zotero.ZeNotes.Menu.mainmenu(domWindow);
}
domWindow.addEventListener("load", onload, false);
}
};
Services.wm.addListener(listener);
},

async main() {
// Global properties are imported above in Zotero 6 and included automatically in
// Zotero 7
Zotero.ZeNotes.listen();
var host = new URL('https://foo.com/path').host;
this.log(`Host is ${host}`);

Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:name>ZeNotes</em:name>
<em:version>0.8.2</em:version>
<em:version>0.8.3</em:version>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:updateURL>https://raw.githubusercontent.com/frianasoa/zenotes/main/zenote-update.json</em:updateURL>
<em:homepageURL>https://github.com/frianasoa/zenotes</em:homepageURL>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Ze Notes",
"version": "0.8.2",
"version": "0.8.3",
"description": "Advanced notes manager",
"homepage_url": "https://github.com/frianasoa/zenotes",
"author": "Fanantenana Rianasoa Andriariniaina",
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"[email protected]": {
"updates": [
{
"version": "0.8.2",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.2/zenotes-v0.8.2.xpi",
"update_hash": "sha256:161db7c386da5513abeb1743ce1cbf51b671dc0b9e9e718a7025795e7b0758b0",
"version": "0.8.3",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.3/zenotes-v0.8.3.xpi",
"update_hash": "sha256:10baa90ededa873f32f5ebdb324a0f9ce919a81d07533ce7c3c2e9d70ff02e37",
"applications": {
"gecko": {
"strict_min_version": "60.0"
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<ns1:version>0.8.2</ns1:version>
<ns1:version>0.8.3</ns1:version>
<ns1:targetApplication>
<rdf:Description>
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>5.0.0</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.2/zenotes-v0.8.2.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.3/zenotes-v0.8.3.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand All @@ -20,7 +20,7 @@
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>4.999</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.2/zenotes-v0.8.2.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.3/zenotes-v0.8.3.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand Down

0 comments on commit 1aa6560

Please sign in to comment.