diff --git a/src/js/background.js b/src/js/background.js index 46d8494..c873b9a 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -276,15 +276,143 @@ app.ContextMenus.menuItemClicked = function(info, tab){ }); }; app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context menu in all pages + // Create Add Context menu for all pages if(app.settings.menuShowAdd){ - browser.contextMenus.create({ // Create Context menu + browser.contextMenus.create({ id: 'AddToQuickDial', title: browser.i18n.getMessage("menuAddToQuickDial"), contexts: ["all"], - documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*', 'ftp://*/*' ] - }, function(){}); - browser.contextMenus.onClicked.addListener(app.ContextMenus.menuItemClicked); + documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*', 'ftp://*/*' ], + onclick(info, tab) { app.ContextMenus.menuItemClicked(info, tab) } + }); } + // Create WebExt Page Context menu + browser.contextMenus.create({ + id: "pagemenu", + title: "Quick Dial", + documentUrlPatterns: [ 'moz-extension://*/dial', 'moz-extension://*/dial?*' ], + contexts: ["page"] + }); + browser.contextMenus.create({ + id: "pagemenunew", + parentId: "pagemenu", + title: browser.i18n.getMessage("menuNew") + }); + browser.contextMenus.create({ + parentId: "pagemenunew", + title: browser.i18n.getMessage("menuNewBookmark"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.createBookmark();" + }); + } + }); + browser.contextMenus.create({ + parentId: "pagemenunew", + title: browser.i18n.getMessage("menuNewFolder"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.createFolder();" + }); + } + }); + browser.contextMenus.create({ parentId: "pagemenu", type: "separator" }); + browser.contextMenus.create({ + parentId: "pagemenu", + title: browser.i18n.getMessage("menuSettings"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.editSettings();" + }); + } + }); + // Create WebExt Link Context menu + browser.contextMenus.create({ + id: "itemmenu", + title: "Quick Dial", + documentUrlPatterns: [ 'moz-extension://*/dial', 'moz-extension://*/dial?*' ], + contexts: ["link"] + }); + browser.contextMenus.create({ + id: "itemmenunew", + parentId: "itemmenu", + title: browser.i18n.getMessage("menuNew") + }); + browser.contextMenus.create({ + parentId: "itemmenunew", + title: browser.i18n.getMessage("menuNewBookmark"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.createBookmark();" + }); + } + }); + browser.contextMenus.create({ + parentId: "itemmenunew", + title: browser.i18n.getMessage("menuNewFolder"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.createFolder();" + }); + } + }); + browser.contextMenus.create({ parentId: "itemmenu", type: "separator" }); + browser.contextMenus.create({ + parentId: "itemmenu", + title: browser.i18n.getMessage("menuProperties"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.editProperties(window.dial._selectedItem);" + }); + } + }); + browser.contextMenus.create({ + parentId: "itemmenu", + title: browser.i18n.getMessage("menuRefreshItem"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.refreshNode(window.dial._selectedItem);" + }); + } + }); + browser.contextMenus.create({ + parentId: "itemmenu", + title: browser.i18n.getMessage("menuCaptureHere"), + visible: false, + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.captureHere(window.dial._selectedItem);" + }); + } + }); + browser.contextMenus.create({ + parentId: "itemmenu", + title: browser.i18n.getMessage("menuCapturePage"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.capturePage(window.dial._selectedItem);" + }); + } + }); + browser.contextMenus.create({ + parentId: "itemmenu", + title: browser.i18n.getMessage("menuDeleteItem"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.deleteNode();" + }); + } + }); + browser.contextMenus.create({ parentId: "itemmenu", type: "separator" }); + browser.contextMenus.create({ + parentId: "itemmenu", + title: browser.i18n.getMessage("menuSettings"), + onclick(info, tab) { + browser.tabs.executeScript(tab.id, { + code: "window.dial.editSettings();" + }); + } + }); }; app.ContextMenus.updateMenu = function(){ browser.contextMenus.onClicked.removeListener(app.ContextMenus.menuItemClicked); diff --git a/src/js/dial.js b/src/js/dial.js index 404cd31..7d9353d 100644 --- a/src/js/dial.js +++ b/src/js/dial.js @@ -163,10 +163,11 @@ app.GridNodes._changed = function(node){ dial.init = function(){ - dial.initMenus(); + //dial.initMenus(); dial.Title = document.createElement('title'); document.head.appendChild(dial.Title); }; +/* dial.initMenus = function(){ document.body.setAttribute('contextmenu', 'page'); dial.PageMenu = document.createElement('menu'); @@ -250,6 +251,7 @@ dial.initMenus = function(){ dial.ItemMenu.appendChild(dial.ItemMenuSettings); document.body.appendChild(dial.ItemMenu); } +*/ dial.initStyles = function(){ function applyImageMode(imageMode, target){ switch(imageMode){ @@ -328,6 +330,7 @@ dial.initGrid = function(){ link.appendChild(document.createElement('div')); link.onmousedown = function(){ dial._selectedItem = this; + /* if(dial._selectedItem.Node){ switch(dial._selectedItem.Node.type){ case app.GridNodes.GridNodeType.folder: @@ -339,6 +342,7 @@ dial.initGrid = function(){ break; } } + */ }; function dragstart_handler(ev) { diff --git a/src/manifest.json b/src/manifest.json index 9dc710d..1747650 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "Quick Dial", - "version": "0.1.19", + "version": "0.1.20", "author": "MatMoul", "homepage_url": "https://github.com/MatMoul/quickdial-webext", "developer": { @@ -43,7 +43,7 @@ "applications": { "gecko": { "id": "quickdial@matmoul.com", - "strict_min_version": "52.0" + "strict_min_version": "70.0" } },