mirror of
https://github.com/MatMoul/quickdial-webext.git
synced 2024-12-23 07:26:11 +00:00
Feature: Option to diable context menu items
This commit is contained in:
parent
88b6a8d45d
commit
63569851d8
@ -58,6 +58,10 @@
|
||||
<td>Preview :</td>
|
||||
<td><div id="BackgroundPreview" style="width: 300px; height: 180px;"></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Show "Add to ..." :</td>
|
||||
<td><input id="MenuShowAdd" type="checkbox"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="hidden">
|
||||
|
@ -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.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(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 } );
|
||||
});
|
||||
});
|
||||
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 }); }); }
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user