Skip to content

TagSpaces is an offline, open source, document manager with tagging support

basic editing of the tag colors implemented

uggrock61cd74b7479b
diff --git a/data/index.html b/data/index.html
index 012156ff3..f3a5109c4 100644
--- a/data/index.html
+++ b/data/index.html
@@ -15,6 +15,7 @@
<link rel="stylesheet" type="text/css" href="libs/jsoneditor/jsoneditor.css">
<link rel="stylesheet" type="text/css" href="libs/jquerydropdown/jquery.dropdown.css">
<link rel="stylesheet" type="text/css" href="libs/bootstrap/css/bootstrap.css">
+ <link rel="stylesheet" type="text/css" href="libs/pickacolor/css/pick-a-color-1.1.7.min.css">
<link rel="stylesheet" type="text/css" href="css/tagspaces.css">
</head>
<body style="background-color: lightgray;">
@@ -275,11 +276,23 @@
</div>
<div class="modal-body form-horizontal">
<div class="control-group">
- <label class="control-label" for="tagInTreeName">Tag Name</label>
+ <label class="control-label" for="tagInTreeName">Name</label>
<div class="controls">
<input type="text" name="tagInTreeName" id="tagInTreeName" />
</div>
</div>
+ <div class="control-group">
+ <label class="control-label" for="tagColor">Color</label>
+ <div class="controls">
+ <input type="text" name="tagColor" id="tagColor" value="green" placeholder="green" class="pick-a-color" />
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="tagTextColor">Text Color</label>
+ <div class="controls">
+ <input type="text" name="tagTextColor" id="tagTextColor" value="white" placeholder="white" class="pick-a-color"/>
+ </div>
+ </div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index f54dde17c..42669745c 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -90,6 +90,8 @@ define(function(require, exports, module) {
{
"title":"book",
"type":"plain",
+ "color":"#F00",
+ "textcolor":"#0F0",
},
{
"title":"paper",
@@ -255,18 +257,17 @@ define(function(require, exports, module) {
return false;
}
- // Not used
- var findTag = function(tagName, tagGroupKey) {
+ // Returns the tag information from the setting for a given tag
+ var findTag = function(tagName) {
for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
- if(exports.Settings["tagGroups"][i].key == tagGroupKey) {
- // console.log("Current taggroup "+exports.Settings["tagGroups"][i].key);
+// if(exports.Settings["tagGroups"][i].key == tagGroupKey) {
for(var j=0; j < exports.Settings["tagGroups"][i]["children"].length; j++) {
// console.log("Current tagname "+exports.Settings["tagGroups"][i]["children"][j].title);
if(exports.Settings["tagGroups"][i]["children"][j].title == tagName) {
return exports.Settings["tagGroups"][i]["children"][j];
}
}
- }
+// }
}
return false;
}
@@ -329,12 +330,14 @@ define(function(require, exports, module) {
saveSettings();
}
- var editTag = function(tagData, newTagName) {
+ var editTag = function(tagData, newTagName, newColor, newTextColor) {
for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
if(exports.Settings["tagGroups"][i].key == tagData.parentKey) {
for(var j=0; j < exports.Settings["tagGroups"][i]["children"].length; j++) {
if(exports.Settings["tagGroups"][i]["children"][j].title == tagData.title) {
exports.Settings["tagGroups"][i]["children"][j].title = newTagName;
+ exports.Settings["tagGroups"][i]["children"][j].color = newColor;
+ exports.Settings["tagGroups"][i]["children"][j].textcolor = newTextColor;
break;
}
}
@@ -575,6 +578,7 @@ define(function(require, exports, module) {
exports.deleteTagGroup = deleteTagGroup;
exports.editTag = editTag;
exports.createTag = createTag;
+ exports.findTag = findTag;
exports.moveTag = moveTag
exports.editTagGroup = editTagGroup;
exports.moveTagGroup = moveTagGroup;
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index 9e8fd6060..e8c9370f0 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -95,7 +95,12 @@ define(function(require, exports, module) {
function initDialogs() {
$( "#editTagInTreeButton" ).click( function() {
- TSCORE.Config.editTag(TSCORE.selectedTagData, $( "#tagInTreeName" ).val() )
+ TSCORE.Config.editTag(
+ TSCORE.selectedTagData,
+ $( "#tagInTreeName" ).val(),
+ $( "#tagColor" ).val(),
+ $( "#tagTextColor" ).val()
+ )
generateTagGroups();
});
@@ -217,7 +222,8 @@ define(function(require, exports, module) {
"tag": TSCORE.Config.Settings["tagGroups"][i]["children"][j].title,
"parentKey": TSCORE.Config.Settings["tagGroups"][i].key,
"title": "Opens context menu for "+TSCORE.Config.Settings["tagGroups"][i]["children"][j].title,
- "text": TSCORE.Config.Settings["tagGroups"][i]["children"][j].title+" ",
+ "text": TSCORE.Config.Settings["tagGroups"][i]["children"][j].title+" ",
+ "style": generateTagStyle(TSCORE.Config.Settings["tagGroups"][i]["children"][j]),
})
.click( function() {
TSCORE.selectedTag = $(this).attr("tag");
@@ -260,7 +266,8 @@ define(function(require, exports, module) {
filename: fileName,
filepath: filePath,
"class": "btn btn-small btn-success tagButton",
- text: tags[i]+" "
+ text: tags[i]+" ",
+ style: generateTagStyle(TSCORE.Config.findTag(tags[i]))
})
.append("<span class='caret'/>")
);
@@ -269,6 +276,19 @@ define(function(require, exports, module) {
return wrapper.html();
}
+ // Get the color for a tag
+ function generateTagStyle(tagObject) {
+ var tagStyle = "";
+ if(tagObject.color != undefined) {
+ var textColor = tagObject.textcolor;
+ if(textColor == undefined) {
+ textColor = "white";
+ }
+ tagStyle = "color: "+textColor+" !important; background-color: "+tagObject.color+" !important;"
+ }
+ return tagStyle;
+ }
+
// Helper function generating file extension button
function generateExtButton(fileExtension, fileName, filePath) {
//console.log("Creating ext button...");
@@ -307,7 +327,27 @@ define(function(require, exports, module) {
}
function showTagEditInTreeDialog() {
- $( "#tagInTreeName" ).val(TSCORE.selectedTagData.title);
+ $( "#tagInTreeName" ).val(TSCORE.selectedTagData.title);
+ if(TSCORE.selectedTagData.color == undefined) {
+ $( "#tagColor" ).val($( "#tagColor" ).attr("placeholder"));
+ } else {
+ $( "#tagColor" ).val(TSCORE.selectedTagData.color);
+ }
+ if(TSCORE.selectedTagData.textcolor == undefined) {
+ $( "#tagTextColor" ).val($( "#tagTextColor" ).attr("placeholder"));
+ } else {
+ $( "#tagTextColor" ).val(TSCORE.selectedTagData.textcolor);
+ }
+ /*$( "#tagColor" ).pickAColor({
+ showSpectrum : true,
+ showSavedColors : true,
+ saveColorsPerElement : true,
+ fadeMenuToggle : true,
+ showAdvanced : true,
+ showHexInput : true,
+ showBasicColors : true
+ });
+ $( "#tagTextColor" ).pickAColor();*/
$( '#dialogEditInTreeTag' ).modal({show: true});
}