mirror of
https://github.com/MatMoul/quickdial-webext.git
synced 2024-12-23 15:36:12 +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>Preview :</td>
|
||||||
<td><div id="BackgroundPreview" style="width: 300px; height: 180px;"></div></td>
|
<td><div id="BackgroundPreview" style="width: 300px; height: 180px;"></div></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Show "Add to ..." :</td>
|
||||||
|
<td><input id="MenuShowAdd" type="checkbox"></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
|
@ -49,6 +49,7 @@ app.Messages.init = function(){ // Init Messages Listeners
|
|||||||
} else {
|
} else {
|
||||||
browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
|
browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
|
||||||
}
|
}
|
||||||
|
app.ContextMenus.updateMenu();
|
||||||
break;
|
break;
|
||||||
case app.Messages.Commands.getNodeByID:
|
case app.Messages.Commands.getNodeByID:
|
||||||
var nodes = app.GridNodes.getNodeWithParents(request.id);
|
var nodes = app.GridNodes.getNodeWithParents(request.id);
|
||||||
@ -107,6 +108,7 @@ app.Settings.init = function(callback){ // Load settings and nodes
|
|||||||
backgroundColor: '#3c4048',
|
backgroundColor: '#3c4048',
|
||||||
backgroundImage: null,
|
backgroundImage: null,
|
||||||
backgroundMode: 0,
|
backgroundMode: 0,
|
||||||
|
menuShowAdd: true,
|
||||||
grid: {
|
grid: {
|
||||||
margin: 10,
|
margin: 10,
|
||||||
rows: 4,
|
rows: 4,
|
||||||
@ -211,6 +213,9 @@ app.Settings.init = function(callback){ // Load settings and nodes
|
|||||||
data.settings.grid.ratioX = 4;
|
data.settings.grid.ratioX = 4;
|
||||||
data.settings.grid.ratioY = 3;
|
data.settings.grid.ratioY = 3;
|
||||||
}
|
}
|
||||||
|
if(!(data.settings.menuShowAdd == true) && !(data.settings.menuShowAdd == false)){
|
||||||
|
data.settings.menuShowAdd = true;
|
||||||
|
}
|
||||||
//app.Settings.save();
|
//app.Settings.save();
|
||||||
}
|
}
|
||||||
app.settings = data.settings;
|
app.settings = data.settings;
|
||||||
@ -229,25 +234,32 @@ app.Settings.save = function(callback){ // Save settings
|
|||||||
browser.storage.local.set(data).then(function(){
|
browser.storage.local.set(data).then(function(){
|
||||||
if(callback) callback();
|
if(callback) callback();
|
||||||
}, function(){ console.log('Error saving settings'); });
|
}, function(){ console.log('Error saving settings'); });
|
||||||
}
|
};
|
||||||
|
|
||||||
app.init();
|
app.init();
|
||||||
|
|
||||||
app.ContextMenus = {} // ContextMenu helper Object
|
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
|
app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context menu in all pages
|
||||||
|
if(app.settings.menuShowAdd){
|
||||||
browser.contextMenus.create({ // Create Context menu
|
browser.contextMenus.create({ // Create Context menu
|
||||||
id: 'AddToQuickDial',
|
id: 'AddToQuickDial',
|
||||||
title: browser.i18n.getMessage("menuAddToQuickDial"),
|
title: browser.i18n.getMessage("menuAddToQuickDial"),
|
||||||
contexts: ["all"],
|
contexts: ["all"],
|
||||||
documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*', 'ftp://*/*' ]
|
documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*', 'ftp://*/*' ]
|
||||||
}, function(){});
|
}, function(){});
|
||||||
browser.contextMenus.onClicked.addListener(function(info, tab) { // Context menu click event
|
browser.contextMenus.onClicked.addListener(app.ContextMenus.menuItemClicked);
|
||||||
if (info.menuItemId == "AddToQuickDial")
|
|
||||||
app.GridNodes.createBookmark(app.node, info.pageUrl, tab.title, function(){
|
|
||||||
browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
app.ContextMenus.updateMenu = function(){
|
||||||
|
browser.contextMenus.onClicked.removeListener(app.ContextMenus.menuItemClicked);
|
||||||
|
browser.contextMenus.removeAll();
|
||||||
|
app.ContextMenus.initMenu();
|
||||||
|
};
|
||||||
|
|
||||||
app.Bookmarks = {} // Bookmarks helper object
|
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 }); }); }
|
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.Messages.getSettings(function(settings){
|
||||||
app.settings = settings;
|
app.settings = settings;
|
||||||
|
MenuShowAdd.checked = app.settings.menuShowAdd;
|
||||||
BackgroundColor.value = app.settings.backgroundColor;
|
BackgroundColor.value = app.settings.backgroundColor;
|
||||||
BackgroundImage = app.settings.backgroundImage;
|
BackgroundImage = app.settings.backgroundImage;
|
||||||
BackgroundMode.value = app.settings.backgroundMode;
|
BackgroundMode.value = app.settings.backgroundMode;
|
||||||
@ -79,6 +80,7 @@ app.init = function(){
|
|||||||
window.frameElement.popup.close();
|
window.frameElement.popup.close();
|
||||||
}
|
}
|
||||||
BtnApply.onclick = function(){
|
BtnApply.onclick = function(){
|
||||||
|
app.settings.menuShowAdd = MenuShowAdd.checked;
|
||||||
app.settings.backgroundColor = BackgroundColor.value;
|
app.settings.backgroundColor = BackgroundColor.value;
|
||||||
app.settings.backgroundImage = BackgroundImage;
|
app.settings.backgroundImage = BackgroundImage;
|
||||||
app.settings.backgroundMode = +(BackgroundMode.value);
|
app.settings.backgroundMode = +(BackgroundMode.value);
|
||||||
|
Loading…
Reference in New Issue
Block a user