diff --git a/src/html/settings.html b/src/html/settings.html
index ef49df6..8fe4c90 100644
--- a/src/html/settings.html
+++ b/src/html/settings.html
@@ -58,6 +58,10 @@
Preview : |
|
+
+ Show "Add to ..." : |
+ |
+
diff --git a/src/js/background.js b/src/js/background.js
index b782b4b..84e07b4 100644
--- a/src/js/background.js
+++ b/src/js/background.js
@@ -49,6 +49,7 @@ app.Messages.init = function(){ // Init Messages Listeners
} else {
browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
}
+ app.ContextMenus.updateMenu();
break;
case app.Messages.Commands.getNodeByID:
var nodes = app.GridNodes.getNodeWithParents(request.id);
@@ -107,6 +108,7 @@ app.Settings.init = function(callback){ // Load settings and nodes
backgroundColor: '#3c4048',
backgroundImage: null,
backgroundMode: 0,
+ menuShowAdd: true,
grid: {
margin: 10,
rows: 4,
@@ -211,6 +213,9 @@ app.Settings.init = function(callback){ // Load settings and nodes
data.settings.grid.ratioX = 4;
data.settings.grid.ratioY = 3;
}
+ if(!(data.settings.menuShowAdd == true) && !(data.settings.menuShowAdd == false)){
+ data.settings.menuShowAdd = true;
+ }
//app.Settings.save();
}
app.settings = data.settings;
@@ -229,25 +234,32 @@ app.Settings.save = function(callback){ // Save settings
browser.storage.local.set(data).then(function(){
if(callback) callback();
}, function(){ console.log('Error saving settings'); });
-}
+};
app.init();
app.ContextMenus = {} // ContextMenu helper Object
-app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context menu in all pages
- browser.contextMenus.create({ // Create Context menu
- id: 'AddToQuickDial',
- title: browser.i18n.getMessage("menuAddToQuickDial"),
- contexts: ["all"],
- documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*', 'ftp://*/*' ]
- }, function(){});
- browser.contextMenus.onClicked.addListener(function(info, tab) { // Context menu click event
- if (info.menuItemId == "AddToQuickDial")
- app.GridNodes.createBookmark(app.node, info.pageUrl, tab.title, function(){
- browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
- });
+app.ContextMenus.menuItemClicked = function(info, tab){
+ if (info.menuItemId == "AddToQuickDial") app.GridNodes.createBookmark(app.node, info.pageUrl, tab.title, function(){
+ browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
});
-}
+};
+app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context menu in all pages
+ if(app.settings.menuShowAdd){
+ browser.contextMenus.create({ // Create Context menu
+ id: 'AddToQuickDial',
+ title: browser.i18n.getMessage("menuAddToQuickDial"),
+ contexts: ["all"],
+ documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*', 'ftp://*/*' ]
+ }, function(){});
+ browser.contextMenus.onClicked.addListener(app.ContextMenus.menuItemClicked);
+ }
+};
+app.ContextMenus.updateMenu = function(){
+ browser.contextMenus.onClicked.removeListener(app.ContextMenus.menuItemClicked);
+ browser.contextMenus.removeAll();
+ app.ContextMenus.initMenu();
+};
app.Bookmarks = {} // Bookmarks helper object
app.Bookmarks._onCreated = function(){ app.GridNodes.sync(app.node, app.settings.grid.root, function(){ browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded }); }); }
diff --git a/src/js/settings.js b/src/js/settings.js
index 2a3c92b..83f89ec 100644
--- a/src/js/settings.js
+++ b/src/js/settings.js
@@ -19,6 +19,7 @@ app.init = function(){
});
app.Messages.getSettings(function(settings){
app.settings = settings;
+ MenuShowAdd.checked = app.settings.menuShowAdd;
BackgroundColor.value = app.settings.backgroundColor;
BackgroundImage = app.settings.backgroundImage;
BackgroundMode.value = app.settings.backgroundMode;
@@ -79,6 +80,7 @@ app.init = function(){
window.frameElement.popup.close();
}
BtnApply.onclick = function(){
+ app.settings.menuShowAdd = MenuShowAdd.checked;
app.settings.backgroundColor = BackgroundColor.value;
app.settings.backgroundImage = BackgroundImage;
app.settings.backgroundMode = +(BackgroundMode.value);