1
0
mirror of https://github.com/MatMoul/quickdial-webext.git synced 2024-12-23 15:36:12 +00:00

Feature: Root folder path customization

This commit is contained in:
MatMoul 2017-10-21 16:53:39 +02:00
parent 938f1a0fde
commit 5a2c30e00f
5 changed files with 22 additions and 6 deletions

1
TODO
View File

@ -1,5 +1,4 @@
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 setting to lock title from update
Add a visual hint for multipage 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

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

@ -38,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 } );
browser.runtime.sendMessage( { cmd: app.Messages.Commands.gridNodesLoaded } ); 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 } );
}
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);
@ -212,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);
@ -228,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(); });
} }

View File

@ -483,7 +483,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%';

View File

@ -18,6 +18,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 +85,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(){