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

7 Commits

12 changed files with 41 additions and 13 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)

5
TODO
View File

@@ -1,6 +1,7 @@
Add node settings popup
Add custom image (thumbnails)
Create style for popup Create style for popup
Add a setting to customize bookmark root folder
Add a setting to lock title from update
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

@@ -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();
}); });
}); });
}; };
@@ -188,11 +189,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 } );
});
}); });
} }
@@ -360,6 +363,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 {
@@ -483,14 +487,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){

View File

@@ -209,7 +209,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 +234,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 +258,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();
@@ -286,6 +299,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(){

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.4",
"author": "MatMoul", "author": "MatMoul",
"homepage_url": "https://github.com/MatMoul/quickdial-webext", "homepage_url": "https://github.com/MatMoul/quickdial-webext",
"developer": { "developer": {