1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2025-12-16 08:53:13 +00:00

16 Commits

17 changed files with 178 additions and 32 deletions

View File

@@ -1,2 +1,9 @@
# quickdial-webext # quickdial-webext
QuickDial is a WebExt Dial page for Firefox QuickDial is a WebExt Dial page for Firefox
[QuickDial on addons.mozilla.org](https://addons.mozilla.org/fr/firefox/addon/quick-dial/?src=search)
## Contribute and evolution :</br>
* [CONTRIBUTING.md](https://github.com/MatMoul/quickdial-webext/blob/develop/CONTRIBUTING.md)

3
TODO
View File

@@ -1,6 +1,5 @@
Add node settings popup
Add custom image (thumbnails)
Create style for popup Create style for popup
Add a visual hint for multipage
Need a best solution to update folder and bookmark when it are updated from Firefox Need a best solution to update folder and bookmark when it are updated from Firefox
Improve screenshot result Improve screenshot result
Add favicon support Add favicon support

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 KiB

After

Width:  |  Height:  |  Size: 535 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 187 KiB

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 335 KiB

After

Width:  |  Height:  |  Size: 532 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 369 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 KiB

After

Width:  |  Height:  |  Size: 364 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

After

Width:  |  Height:  |  Size: 430 KiB

View File

@@ -0,0 +1,67 @@
{
"extensionDescription": {
"message": "Quick Dial, una dial page inspirata a fast dial.",
"description": "Description of the extension."
},
"menuAddToQuickDial": {
"message": "Aggiungi a Quick Dial",
"description": "Text of add bookmark menu item."
},
"menuNew": {
"message": "Nuovo",
"description": "Text of new menu item."
},
"menuNewBookmark": {
"message": "Segnalibro",
"description": "Text of add bookmark menu item."
},
"AddBookmarkPrompt": {
"message": "Scrivi l'url del nuovo segnalibro:",
"description": "Text of the add bookmark prompt."
},
"menuNewFolder": {
"message": "Cartella",
"description": "Text of add folder menu item."
},
"AddFolderPrompt": {
"message": "Scrivi il nome della nuova cartella:",
"description": "Text of the add folder prompt."
},
"menuProperties": {
"message": "Proprietà",
"description": "Text of properties menu item."
},
"menuRefreshItem": {
"message": "Aggiorna",
"description": "Text of refresh menu item."
},
"menuCapturePage": {
"message": "Cattura in una nuova scheda",
"description": "Text of capture menu item."
},
"menuDeleteItem": {
"message": "Elimina",
"description": "Text of delete menu item."
},
"deleteItemConfimation": {
"message": "Eliminare $1?",
"description": "Text of delete confirmation."
},
"menuSettings": {
"message": "Impostazioni Quick Dial",
"description": "Text of settings menu item."
}
}

View File

@@ -33,16 +33,17 @@
<tr> <tr>
<td><span>Title :</span></td> <td><span>Title :</span></td>
<td><input id="Title" type="text" style="width:100%"></td> <td><input id="Title" type="text" style="width:100%"></td>
<td style="width:20px"><input id="TitleLocked" type="checkbox" title="Lock title"></td>
</tr> </tr>
<tr> <tr>
<td><span>Url :</span></td> <td><span>Url :</span></td>
<td><input id="Url" type="text" style="width:100%"></td> <td colspan="2"><input id="Url" type="text" style="width:100%"></td>
</tr> </tr>
<tr> <tr>
<td><span>Image :</span></td> <td><span>Image :</span></td>
<td> <td colspan="2">
<button id="ImageReset">Reset</button> <button id="ImageReset">Reset</button>
<button id="ImageDefault">Default</button> <button id="ImageDefault">Default</button>
<button class="hidden" id="ImageRefresh">Refresh</button> <button class="hidden" id="ImageRefresh">Refresh</button>
@@ -52,7 +53,7 @@
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td><div id="ImagePreview" style="width: 300px; height: 180px;"></div></td> <td colspan="2"><div id="ImagePreview" style="width: 300px; height: 180px;"></div></td>
</tr> </tr>

View File

@@ -15,7 +15,7 @@
.Tab .TabSpace { width: 100%; border-bottom: solid 1px #505050; } .Tab .TabSpace { width: 100%; border-bottom: solid 1px #505050; }
.Tab .TabButton { border: solid 1px #505050; padding: 2px 6px 2px 6px; cursor: default; } .Tab .TabButton { border: solid 1px #505050; padding: 2px 6px 2px 6px; cursor: default; }
.Tab .TabButtonActive { border: solid 1px #505050; border-bottom: none; padding: 2px 6px 2px 6px; cursor: default; } .Tab .TabButtonActive { border: solid 1px #505050; border-bottom: none; padding: 2px 6px 2px 6px; cursor: default; }
.Tab>div { padding: 8px; height: 330px; border-left: solid 1px #505050; border-bottom: solid 1px #505050; border-right: solid 1px #505050; } .Tab>div { padding: 8px; height: 350px; border-left: solid 1px #505050; border-bottom: solid 1px #505050; border-right: solid 1px #505050; }
</style> </style>
</head> </head>
<body id="body"> <body id="body">
@@ -82,6 +82,12 @@
</td> </td>
</tr> </tr>
</table> </table>
<table style="width:100%;">
<tr>
<td><span>Root Folder :</span></td>
<td><input id="GridRoot" type="text" style="width:100%;"></td>
</tr>
</table>
</div> </div>
<div class="hidden"> <div class="hidden">
<table> <table>

View File

@@ -10,6 +10,7 @@ app.init = function(){ // Init module
app.GridNodes.sync(app.node, app.settings.grid.root, function(){ app.GridNodes.sync(app.node, app.settings.grid.root, function(){
browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded }); browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded });
app.Bookmarks.initListener(); app.Bookmarks.initListener();
app.ContextMenus.initMenu();
}); });
}); });
}; };
@@ -37,11 +38,17 @@ app.Messages.init = function(){ // Init Messages Listeners
sendResponse(app.settings); sendResponse(app.settings);
break; break;
case app.Messages.Commands.setSettings: case app.Messages.Commands.setSettings:
let rootChanged = (app.settings.grid.root!=request.settings.grid.root);
app.settings = request.settings; app.settings = request.settings;
app.Settings.save(); app.Settings.save();
sendResponse(app.settings); sendResponse(app.settings);
browser.runtime.sendMessage( { cmd: app.Messages.Commands.settingsChanged } ); browser.runtime.sendMessage( { cmd: app.Messages.Commands.settingsChanged } );
if(rootChanged){
app.node = { children: [] };
app.GridNodes.sync(app.node, app.settings.grid.root, function(){ browser.runtime.sendMessage({ cmd: app.Messages.Commands.gridNodesLoaded }); });
} else {
browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } ); browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
}
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);
@@ -188,11 +195,13 @@ app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context m
id: 'AddToQuickDial', id: 'AddToQuickDial',
title: browser.i18n.getMessage("menuAddToQuickDial"), title: browser.i18n.getMessage("menuAddToQuickDial"),
contexts: ["all"], contexts: ["all"],
documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*' ] documentUrlPatterns: [ 'http://*/*', 'https://*/*', 'file://*/*', 'ftp://*/*' ]
}, function(){}); }, function(){});
browser.contextMenus.onClicked.addListener(function(info, tab) { // Context menu click event browser.contextMenus.onClicked.addListener(function(info, tab) { // Context menu click event
//if (info.menuItemId == "AddToQuickDial") if (info.menuItemId == "AddToQuickDial")
//app.GridNodes.createBookmark(app.settings.grid.node, info.pageUrl, tab.title, function(){}); app.GridNodes.createBookmark(app.node, info.pageUrl, tab.title, function(){
browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } );
});
}); });
} }
@@ -209,7 +218,9 @@ app.Bookmarks.initListener = function(){ // (Called from app.init) (/!\ Need fil
} }
app.Bookmarks.load = function(rootPath, callback){ // Load root bookmark and create it if not exist app.Bookmarks.load = function(rootPath, callback){ // Load root bookmark and create it if not exist
if(!callback) return; if(!callback) return;
browser.bookmarks.getSubTree('menu________').then(function(bookmarkItems){ var root = 'menu________';
if(rootPath.substr(0,1)=='/') root = 'root________';
browser.bookmarks.getSubTree(root).then(function(bookmarkItems){
function getChildItem(bookmarkItem, path, callback){ function getChildItem(bookmarkItem, path, callback){
if(path.length == 0){ if(path.length == 0){
callback(bookmarkItem); callback(bookmarkItem);
@@ -225,7 +236,8 @@ app.Bookmarks.load = function(rootPath, callback){ // Load root bookmark and cre
return getChildItem(bookmarkItem, path.substr(bookmarkItem.title.length + 1), callback); return getChildItem(bookmarkItem, path.substr(bookmarkItem.title.length + 1), callback);
}, function(){ callback(); }); }, function(){ callback(); });
} }
getChildItem(bookmarkItems[0], rootPath, callback); if(rootPath.substr(0,1)=='/') getChildItem(bookmarkItems[0], rootPath.substr(1), callback);
else getChildItem(bookmarkItems[0], rootPath, callback);
}, function(){ callback(); }); }, function(){ callback(); });
} }
@@ -360,6 +372,7 @@ app.GridNodes.sync = function(gridNode, rootPath, callback){ // Sync GridNodes w
if(! gridNode.children) gridNode.children = []; if(! gridNode.children) gridNode.children = [];
else { else {
for(var i=gridNode.children.length-1; i>=0; i--){ for(var i=gridNode.children.length-1; i>=0; i--){
if(!gridNode.children[i]) gridNode.children[i] = { type: app.GridNodes.GridNodeType.empty };
if(gridNode.children[i].type==app.GridNodes.GridNodeType.empty){ if(gridNode.children[i].type==app.GridNodes.GridNodeType.empty){
EmptyNodes.unshift(gridNode.children[i]); EmptyNodes.unshift(gridNode.children[i]);
} else { } else {
@@ -448,6 +461,7 @@ app.GridNodes.getNodeWithParents = function(id){
app.GridNodes.updateNode = function(gridNode, value, callback){ app.GridNodes.updateNode = function(gridNode, value, callback){
if(value){ if(value){
if(value.title) gridNode.title = value.title; if(value.title) gridNode.title = value.title;
if(value.titleLocked!=null) gridNode.titleLocked = value.titleLocked;
if(value.image) gridNode.image = value.image; if(value.image) gridNode.image = value.image;
else delete gridNode.image; else delete gridNode.image;
if(gridNode.type == app.GridNodes.GridNodeType.bookmark && value.url && gridNode.url != value.url){ if(gridNode.type == app.GridNodes.GridNodeType.bookmark && value.url && gridNode.url != value.url){
@@ -483,14 +497,16 @@ app.GridNodes.setNodeIndex = function(gridNode, index, newIndex, callback){ // S
} }
app.GridNodes.createBookmark = function(gridNode, url, title, callback){ // Create a new Bookmark in a GridNode. callback(gridNode, newGridNode) app.GridNodes.createBookmark = function(gridNode, url, title, callback){ // Create a new Bookmark in a GridNode. callback(gridNode, newGridNode)
browser.bookmarks.onCreated.removeListener(app.Bookmarks._onCreated); browser.bookmarks.onCreated.removeListener(app.Bookmarks._onCreated);
var prefix = '';
if(url.indexOf('://')<0) prefix = 'http://';
browser.bookmarks.create({ browser.bookmarks.create({
parentId: gridNode.id, parentId: gridNode.id,
title: title || url, title: title || url,
url: url url: prefix + url
}).then(function(bookmarkItem){ }).then(function(bookmarkItem){
if(!gridNode) return; // ??? Why this method are called a second time with gridNode = null ??? if(!gridNode) return; // ??? Why this method are called a second time with gridNode = null ???
browser.bookmarks.onCreated.addListener(app.Bookmarks._onCreated); browser.bookmarks.onCreated.addListener(app.Bookmarks._onCreated);
var newGridNode = { id: bookmarkItem.id, type: app.GridNodes.GridNodeType.bookmark, url: url, title }; var newGridNode = { id: bookmarkItem.id, type: app.GridNodes.GridNodeType.bookmark, url: prefix + url, title };
var EmptyCellFound = false; var EmptyCellFound = false;
for(var i=0; i<gridNode.children.length; i++){ for(var i=0; i<gridNode.children.length; i++){
if(gridNode.children[i].type == app.GridNodes.GridNodeType.empty){ if(gridNode.children[i].type == app.GridNodes.GridNodeType.empty){
@@ -564,7 +580,7 @@ app.GridNodes.refreshNode = function(gridNode, callback){ // Refresh content of
case app.GridNodes.GridNodeType.bookmark: case app.GridNodes.GridNodeType.bookmark:
app.SiteInfos.fromFrame(gridNode.url, function(infos){ app.SiteInfos.fromFrame(gridNode.url, function(infos){
if(infos){ if(infos){
gridNode.title = infos.title; if(gridNode.titleLocked!=true) gridNode.title = infos.title;
gridNode.image = infos.screenshot; gridNode.image = infos.screenshot;
} else { } else {
gridNode.image = '0'; gridNode.image = '0';
@@ -600,7 +616,7 @@ app.GridNodes.capturePage = function(gridNode, callback){
case app.GridNodes.GridNodeType.bookmark: case app.GridNodes.GridNodeType.bookmark:
app.SiteInfos.fromNewTab(gridNode.url, function(infos){ app.SiteInfos.fromNewTab(gridNode.url, function(infos){
if(infos){ if(infos){
gridNode.title = infos.title; if(gridNode.titleLocked!=true) gridNode.title = infos.title;
gridNode.image = infos.screenshot; gridNode.image = infos.screenshot;
} else { } else {
gridNode.image = '0'; gridNode.image = '0';

View File

@@ -79,10 +79,22 @@ app.Messages.init = function(){
}); });
}; };
app.Messages.getSettings = function(callback){ app.Messages.getSettings = function(callback){
browser.runtime.getBackgroundPage().then(function(page){
if(page){
if(callback) callback(page.app.settings);
} else {
browser.runtime.sendMessage({ cmd: app.Messages.Commands.getSettings }).then(callback, callback); browser.runtime.sendMessage({ cmd: app.Messages.Commands.getSettings }).then(callback, callback);
}
});
}; };
app.Messages.getNode = function(path, callback){ app.Messages.getNode = function(path, callback){
browser.runtime.getBackgroundPage().then(function(page){
if(page){
if(callback) callback(page.app.GridNodes.getNode(page.app.node, dial.path.substr(1)));
} else {
browser.runtime.sendMessage({ cmd: app.Messages.Commands.getNode, path: path }).then(callback); browser.runtime.sendMessage({ cmd: app.Messages.Commands.getNode, path: path }).then(callback);
}
});
}; };
app.Messages.setNodeIndex = function(index, newIndex, callback){ app.Messages.setNodeIndex = function(index, newIndex, callback){
browser.runtime.sendMessage({ cmd: app.Messages.Commands.setNodeIndex, path: dial.path, index: index, newIndex: newIndex }).then(callback); browser.runtime.sendMessage({ cmd: app.Messages.Commands.setNodeIndex, path: dial.path, index: index, newIndex: newIndex }).then(callback);
@@ -209,7 +221,7 @@ dial.initMenus = function(){
document.body.appendChild(dial.ItemMenu); document.body.appendChild(dial.ItemMenu);
} }
dial.initStyles = function(){ dial.initStyles = function(){
if(dial.Style) document.head.removeChild(dial.Style); var oldStyle = dial.Style;
dial.Style = document.createElement('style'), StyleSheet; dial.Style = document.createElement('style'), StyleSheet;
document.head.appendChild(dial.Style); document.head.appendChild(dial.Style);
dial.styles = {}; dial.styles = {};
@@ -234,9 +246,10 @@ dial.initStyles = function(){
dial.styles.grid.linkFolder = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Folder :first-child { background-image: ' + app.settings.grid.folderIcon + '; background-repeat: no-repeat; background-size: 100% 100%; }')].style; dial.styles.grid.linkFolder = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Folder :first-child { background-image: ' + app.settings.grid.folderIcon + '; background-repeat: no-repeat; background-size: 100% 100%; }')].style;
dial.styles.grid.linkBookmark = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Bookmark :first-child { background-repeat: no-repeat; background-size: 100% 100%; }')].style; dial.styles.grid.linkBookmark = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.Bookmark :first-child { background-repeat: no-repeat; background-size: 100% 100%; }')].style;
dial.styles.grid.linkBookmarkLoading = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.BookmarkLoading :first-child { background-image: url("' + app.settings.grid.cells.loadingIcon + '"); background-repeat: no-repeat; background-position: center center; }')].style; dial.styles.grid.linkBookmarkLoading = dial.Style.sheet.cssRules[dial.Style.sheet.insertRule('.Grid td>a.BookmarkLoading :first-child { background-image: url("' + app.settings.grid.cells.loadingIcon + '"); background-repeat: no-repeat; background-position: center center; }')].style;
if(oldStyle) document.head.removeChild(oldStyle);
}; };
dial.initGrid = function(){ dial.initGrid = function(){
if(dial.Grid) document.body.removeChild(dial.Grid); var oldGrid = dial.Grid;
dial.Grid = document.createElement('table'); dial.Grid = document.createElement('table');
var grid = document.createElement('table'); var grid = document.createElement('table');
dial.Grid.className = 'Grid'; dial.Grid.className = 'Grid';
@@ -257,13 +270,25 @@ dial.initGrid = function(){
link.onmousedown = function(){ dial._selectedItem = this; }; link.onmousedown = function(){ dial._selectedItem = this; };
function dragstart_handler(ev) { function dragstart_handler(ev) {
if(!ev.target.Node){
ev.preventDefault();
return;
}
var index = (dial.page - 1) * (app.settings.grid.rows * app.settings.grid.columns) + +(ev.target.parentElement.getAttribute('gridindex')); var index = (dial.page - 1) * (app.settings.grid.rows * app.settings.grid.columns) + +(ev.target.parentElement.getAttribute('gridindex'));
if(app.settings.grid.backNode && dial.path != '/') index -= dial.page; if(app.settings.grid.backNode && dial.path != '/') index -= dial.page;
ev.dataTransfer.setData("text/plain", index); ev.dataTransfer.setData("text/plain", index);
} }
function dragover_handler(ev) { function dragover_handler(ev) {
ev.preventDefault(); ev.preventDefault();
ev.dataTransfer.dropEffect = "move" if(app.settings.grid.backNode && dial.path != '/'){
var gridIndex = 0;
if(ev.target.tagName == 'DIV') gridIndex = +(ev.target.parentElement.parentElement.getAttribute('gridindex'));
else gridIndex = +(ev.target.getAttribute('gridindex'));
if(gridIndex==0) ev.dataTransfer.dropEffect = "none";
else ev.dataTransfer.dropEffect = "move";
} else {
ev.dataTransfer.dropEffect = "move";
}
} }
function drop_handler(ev) { function drop_handler(ev) {
ev.preventDefault(); ev.preventDefault();
@@ -276,7 +301,7 @@ dial.initGrid = function(){
EndIndex = (dial.page - 1) * (app.settings.grid.rows * app.settings.grid.columns) + +(ev.target.getAttribute('gridindex')); EndIndex = (dial.page - 1) * (app.settings.grid.rows * app.settings.grid.columns) + +(ev.target.getAttribute('gridindex'));
} }
if(app.settings.grid.backNode && dial.path != '/') EndIndex -= dial.page; if(app.settings.grid.backNode && dial.path != '/') EndIndex -= dial.page;
app.Messages.setNodeIndex(StartIndex, EndIndex); if(StartIndex != EndIndex) app.Messages.setNodeIndex(StartIndex, EndIndex);
} }
link.draggable = true; link.draggable = true;
link.ondragstart = dragstart_handler; link.ondragstart = dragstart_handler;
@@ -286,6 +311,7 @@ dial.initGrid = function(){
} }
document.body.appendChild(dial.Grid); document.body.appendChild(dial.Grid);
dial.updateGridLayout(); dial.updateGridLayout();
if(oldGrid) document.body.removeChild(oldGrid);
return dial.Grid; return dial.Grid;
}; };
dial.updateGridLayout = function(){ dial.updateGridLayout = function(){
@@ -328,8 +354,10 @@ dial.populateGrid = function(){
populateFolder = function(link, node){ populateFolder = function(link, node){
link.Node = node; link.Node = node;
link.className = 'Folder'; link.className = 'Folder';
if(node.image) link.childNodes[0].style.backgroundImage = 'url(' + node.image + ')'; if(node.image){
else link.childNodes[0].style.backgroundImage = ''; if(node.image.indexOf('url(')>=0) link.childNodes[0].style.backgroundImage = node.image;
else link.childNodes[0].style.backgroundImage = 'url(' + node.image + ')';
} else link.childNodes[0].style.backgroundImage = '';
link.childNodes[1].innerText = node.title; link.childNodes[1].innerText = node.title;
if(dial.path) link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(dial.path + node.title); if(dial.path) link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(dial.path + node.title);
else link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(node.title); else link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(node.title);
@@ -340,7 +368,8 @@ dial.populateGrid = function(){
link.Node = node; link.Node = node;
if(node.image){ if(node.image){
link.className = 'Bookmark'; link.className = 'Bookmark';
link.childNodes[0].style.backgroundImage = 'url(' + node.image + ')'; if(node.image.indexOf('url(')>=0) link.childNodes[0].style.backgroundImage = node.image;
else link.childNodes[0].style.backgroundImage = 'url(' + node.image + ')';
} else { } else {
link.className = 'BookmarkLoading'; link.className = 'BookmarkLoading';
link.childNodes[0].style.backgroundImage = ''; link.childNodes[0].style.backgroundImage = '';
@@ -457,7 +486,7 @@ dial.PopupPanel = function(width, height, modal){ // PopupPanel Object
} }
dial.editSettings = function(){ dial.editSettings = function(){
var popup = new dial.PopupPanel(500, 420, true); var popup = new dial.PopupPanel(500, 440, true);
var iframe = document.createElement('iframe'); var iframe = document.createElement('iframe');
iframe.style.width = '100%'; iframe.style.width = '100%';
iframe.style.height = '100%'; iframe.style.height = '100%';
@@ -469,6 +498,7 @@ dial.editSettings = function(){
iframe.src = '/html/settings.html'; iframe.src = '/html/settings.html';
iframe.popup = popup; iframe.popup = popup;
popup.popup(); popup.popup();
iframe.focus();
} }
dial.editProperties = function(selectedItem){ dial.editProperties = function(selectedItem){
@@ -484,4 +514,5 @@ dial.editProperties = function(selectedItem){
iframe.src = '/html/properties.html?id=' + selectedItem.Node.id; iframe.src = '/html/properties.html?id=' + selectedItem.Node.id;
iframe.popup = popup; iframe.popup = popup;
popup.popup(); popup.popup();
iframe.focus();
} }

View File

@@ -7,6 +7,13 @@ document.addEventListener("DOMContentLoaded", function(event) {
}); });
app.init = function(){ app.init = function(){
document.addEventListener('keyup', function(e){
switch(e.key){
case 'Escape':
window.frameElement.popup.close();
break;
}
});
app.Messages.getSettings(function(settings){ app.Messages.getSettings(function(settings){
app.settings = settings; app.settings = settings;
app.Messages.getNodeByID(new URL(window.location).searchParams.get('id'), function(node){ app.Messages.getNodeByID(new URL(window.location).searchParams.get('id'), function(node){
@@ -16,18 +23,21 @@ app.init = function(){
ImagePreview.style.backgroundSize = '100% 100%'; ImagePreview.style.backgroundSize = '100% 100%';
switch(node.type){ switch(node.type){
case app.GridNodes.GridNodeType.folder: case app.GridNodes.GridNodeType.folder:
TitleLocked.parentNode.style.display = 'none';
Url.parentNode.parentNode.style.display = 'none'; Url.parentNode.parentNode.style.display = 'none';
if(node.image){ if(node.image){
if(node.image.indexOf('url(')>0) Image = node.image; if(node.image.indexOf('url(')>=0) Image = node.image;
else Image = 'url(' + node.image + ')'; else Image = 'url(' + node.image + ')';
} else Image = null; } else Image = null;
if(Image==null) ImagePreview.style.backgroundImage = app.settings.grid.folderIcon; if(Image==null) ImagePreview.style.backgroundImage = app.settings.grid.folderIcon;
else ImagePreview.style.backgroundImage = Image; else ImagePreview.style.backgroundImage = Image;
break; break;
case app.GridNodes.GridNodeType.bookmark: case app.GridNodes.GridNodeType.bookmark:
TitleLocked.checked = (node.titleLocked==true);
ImageDefault.style.display = 'none'; ImageDefault.style.display = 'none';
Url.value = node.url; Url.value = node.url;
Image = 'url(' + node.image + ')'; if(node.image.indexOf('url(')>=0) Image = node.image;
else Image = 'url(' + node.image + ')';
ImagePreview.style.backgroundImage = Image; ImagePreview.style.backgroundImage = Image;
break; break;
} }
@@ -90,7 +100,7 @@ app.init = function(){
app.Messages.updateNode(app.node.id, { title: Title.value, image: Image }) app.Messages.updateNode(app.node.id, { title: Title.value, image: Image })
break; break;
case app.GridNodes.GridNodeType.bookmark: case app.GridNodes.GridNodeType.bookmark:
app.Messages.updateNode(app.node.id, { title: Title.value, url: Url.value, image: Image }) app.Messages.updateNode(app.node.id, { title: Title.value, titleLocked: TitleLocked.checked, url: Url.value, image: Image })
break; break;
} }
} }

View File

@@ -10,6 +10,13 @@ document.addEventListener("DOMContentLoaded", function(event) {
app.init = function(){ app.init = function(){
document.addEventListener('keyup', function(e){
switch(e.key){
case 'Escape':
window.frameElement.popup.close();
break;
}
});
app.Messages.getSettings(function(settings){ app.Messages.getSettings(function(settings){
app.settings = settings; app.settings = settings;
BackgroundColor.value = app.settings.backgroundColor; BackgroundColor.value = app.settings.backgroundColor;
@@ -18,6 +25,7 @@ app.init = function(){
BackgroundPreview.style.backgroundImage = app.settings.backgroundImage; BackgroundPreview.style.backgroundImage = app.settings.backgroundImage;
BackgroundPreview.style.backgroundRepeat = 'no-repeat'; BackgroundPreview.style.backgroundRepeat = 'no-repeat';
BackgroundPreview.style.backgroundSize = '100% 100%'; BackgroundPreview.style.backgroundSize = '100% 100%';
GridRoot.value = app.settings.grid.root;
GridRows.value = app.settings.grid.rows; GridRows.value = app.settings.grid.rows;
GridMargins.value = app.settings.grid.margin; GridMargins.value = app.settings.grid.margin;
GridColumns.value = app.settings.grid.columns; GridColumns.value = app.settings.grid.columns;
@@ -84,6 +92,7 @@ app.init = function(){
else app.settings.grid.cells.titleBackgroundColor = GridCellsTitleBackgroundColor.value; else app.settings.grid.cells.titleBackgroundColor = GridCellsTitleBackgroundColor.value;
if(GridCellsTitleBackgroundTransparentHover.checked == true) app.settings.grid.cells.titleBackgroundColorHover = null; if(GridCellsTitleBackgroundTransparentHover.checked == true) app.settings.grid.cells.titleBackgroundColorHover = null;
else app.settings.grid.cells.titleBackgroundColorHover = GridCellsTitleBackgroundColorHover.value; else app.settings.grid.cells.titleBackgroundColorHover = GridCellsTitleBackgroundColorHover.value;
app.settings.grid.root = GridRoot.value;
browser.runtime.sendMessage( { cmd: app.Messages.Commands.setSettings, settings: app.settings } ); browser.runtime.sendMessage( { cmd: app.Messages.Commands.setSettings, settings: app.settings } );
} }
BtnCancel.onclick = function(){ BtnCancel.onclick = function(){

View File

@@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "Quick Dial", "name": "Quick Dial",
"version": "0.1.3", "version": "0.1.5",
"author": "MatMoul", "author": "MatMoul",
"homepage_url": "https://github.com/MatMoul/quickdial-webext", "homepage_url": "https://github.com/MatMoul/quickdial-webext",
"developer": { "developer": {