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

Feature: Lock settings for image on tiles

This commit is contained in:
MatMoul 2017-11-24 22:36:53 +01:00
parent 63569851d8
commit ddbd2f40c8
3 changed files with 25 additions and 14 deletions

View File

@ -43,7 +43,7 @@
<tr> <tr>
<td><span>Image :</span></td> <td><span>Image :</span></td>
<td colspan="2"> <td>
<select id="ImageMode"> <select id="ImageMode">
<option value="-1">Default</option> <option value="-1">Default</option>
<option value="0">Stretch</option> <option value="0">Stretch</option>
@ -57,6 +57,7 @@
<button class="hidden" id="ImageCapture">Capture</button> <button class="hidden" id="ImageCapture">Capture</button>
<input id="ImageFile" type="file" style="width:180px;"> <input id="ImageFile" type="file" style="width:180px;">
</td> </td>
<td style="width:20px"><input id="ImageLocked" type="checkbox" title="Lock image"></td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>

View File

@ -544,8 +544,11 @@ 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.titleLocked!=null) gridNode.titleLocked = value.titleLocked;
if(value.image) gridNode.image = value.image; if(value.imageLocked!=null) gridNode.imageLocked = value.imageLocked;
else delete gridNode.image; if(gridNode.imageLocked == false){
if(value.image) gridNode.image = value.image;
else delete gridNode.image;
}
if(value.imageMode || value.imageMode == 0) { if(value.imageMode || value.imageMode == 0) {
if(value.imageMode == -1) delete gridNode.imageMode; if(value.imageMode == -1) delete gridNode.imageMode;
else gridNode.imageMode = value.imageMode; else gridNode.imageMode = value.imageMode;
@ -688,12 +691,15 @@ app.GridNodes.refreshNode = function(gridNode, callback){ // Refresh content of
break; break;
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(gridNode.imageLocked!=true){
if(gridNode.titleLocked!=true) gridNode.title = infos.title; if(infos){
gridNode.image = infos.screenshot; if(gridNode.titleLocked!=true) gridNode.title = infos.title;
} else { gridNode.image = infos.screenshot;
gridNode.image = '0'; } else {
gridNode.image = '0';
}
} }
delete gridNode.__isLoading; delete gridNode.__isLoading;
app.GridNodes.saveNode(gridNode); app.GridNodes.saveNode(gridNode);
if(callback) callback(infos); if(callback) callback(infos);
@ -728,11 +734,13 @@ app.GridNodes.capturePage = function(gridNode, callback){
break; break;
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(gridNode.imageLocked!=true){
if(gridNode.titleLocked!=true) gridNode.title = infos.title; if(infos){
gridNode.image = infos.screenshot; if(gridNode.titleLocked!=true) gridNode.title = infos.title;
} else { gridNode.image = infos.screenshot;
gridNode.image = '0'; } else {
gridNode.image = '0';
}
} }
delete gridNode.__isLoading; delete gridNode.__isLoading;
app.GridNodes.saveNode(gridNode); app.GridNodes.saveNode(gridNode);

View File

@ -26,6 +26,7 @@ app.init = function(){
switch(node.type){ switch(node.type){
case app.GridNodes.GridNodeType.folder: case app.GridNodes.GridNodeType.folder:
TitleLocked.parentNode.style.display = 'none'; TitleLocked.parentNode.style.display = 'none';
ImageLocked.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;
@ -36,6 +37,7 @@ app.init = function(){
break; break;
case app.GridNodes.GridNodeType.bookmark: case app.GridNodes.GridNodeType.bookmark:
TitleLocked.checked = (node.titleLocked==true); TitleLocked.checked = (node.titleLocked==true);
ImageLocked.checked = (node.imageLocked==true);
ImageDefault.style.display = 'none'; ImageDefault.style.display = 'none';
Url.value = node.url; Url.value = node.url;
if(node.image.indexOf('url(')>=0) Image = node.image; if(node.image.indexOf('url(')>=0) Image = node.image;
@ -102,7 +104,7 @@ app.init = function(){
app.Messages.updateNode(app.node.id, { title: Title.value, image: Image, imageMode: +(ImageMode.value) }) app.Messages.updateNode(app.node.id, { title: Title.value, image: Image, imageMode: +(ImageMode.value) })
break; break;
case app.GridNodes.GridNodeType.bookmark: case app.GridNodes.GridNodeType.bookmark:
app.Messages.updateNode(app.node.id, { title: Title.value, titleLocked: TitleLocked.checked, url: Url.value, image: Image, imageMode: +(ImageMode.value) }) app.Messages.updateNode(app.node.id, { title: Title.value, titleLocked: TitleLocked.checked, imageLocked: ImageLocked.checked, url: Url.value, image: Image, imageMode: +(ImageMode.value) })
break; break;
} }
} }