From 39f96b015be93aa6ea1b1864f7cccf7c4edb1680 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sun, 15 Oct 2017 00:25:12 +0200 Subject: [PATCH] Feature: Add Default button on node properties --- src/html/properties.html | 1 + src/js/background.js | 1 + src/js/properties.js | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/html/properties.html b/src/html/properties.html index 87747b8..a2ea6db 100644 --- a/src/html/properties.html +++ b/src/html/properties.html @@ -44,6 +44,7 @@ Image : + diff --git a/src/js/background.js b/src/js/background.js index d19fd42..cb4a212 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -453,6 +453,7 @@ app.GridNodes.updateNode = function(gridNode, value, callback){ delete gridNode.image; } if(value.image) gridNode.image = value.image; + else delete gridNode.image; app.GridNodes.saveNode(gridNode); } if(callback) callback(gridNode); diff --git a/src/js/properties.js b/src/js/properties.js index 57ff7c1..c17d946 100644 --- a/src/js/properties.js +++ b/src/js/properties.js @@ -20,11 +20,12 @@ app.init = function(){ if(node.image){ if(node.image.indexOf('url(')>0) Image = node.image; else Image = 'url(' + node.image + ')'; - } else Image = app.settings.grid.folderIcon; - - ImagePreview.style.backgroundImage = Image; + } else Image = null; + if(Image==null) ImagePreview.style.backgroundImage = app.settings.grid.folderIcon; + else ImagePreview.style.backgroundImage = Image; break; case app.GridNodes.GridNodeType.bookmark: + ImageDefault.style.display = 'none'; Url.value = node.url; Image = 'url(' + node.image + ')'; ImagePreview.style.backgroundImage = Image; @@ -49,6 +50,17 @@ app.init = function(){ } }; + ImageDefault.onclick = function(){ + switch(node.type){ + case app.GridNodes.GridNodeType.folder: + Image = null; + ImagePreview.style.backgroundImage = app.settings.grid.folderIcon; + break; + case app.GridNodes.GridNodeType.bookmark: + break; + } + }; + ImageFile.onclick = function(){ this.value = null;