Skip to content

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

Tags are now colored in the fileopener

uggrock36f790e9012e
diff --git a/data/icons/icon32.png b/data/icons/icon32.png
index 0b0bbeebc..6771fd727 100644
Binary files a/data/icons/icon32.png and b/data/icons/icon32.png differ
diff --git a/data/js/fileopener.js b/data/js/fileopener.js
index 65f8cb729..a7215c86d 100644
--- a/data/js/fileopener.js
+++ b/data/js/fileopener.js
@@ -127,7 +127,6 @@ define(function(require, exports, module) {
function constructFileViewerUI(filePath) {
// Adding tag buttons to the filetoolbox
- var tags = TSCORE.TagUtils.extractTags(filePath);
var title = TSCORE.TagUtils.extractTitle(filePath);
var fileExtension = TSCORE.TagUtils.extractFileExtension(filePath);
@@ -145,31 +144,22 @@ define(function(require, exports, module) {
// Generate tag & ext buttons
$( "#fileTags" ).empty();
- $( "#fileTags" ).append($('<button>', {
- title: "Opens context menu for "+fileExtension,
- tag: fileExtension,
- "class": "btn btn-small btn-info extTagButton",
- text: fileExtension+" "
- })
- .click( function() {
- TSCORE.selectedTag = fileExtension;
- })
- .dropdown( 'attach' , '#extensionMenu' )
- .append($("<span>", { class: "caret"}))
- );
-
- for (var i=0; i < tags.length; i++) {
- $( "#fileTags" ).append($("<button>", {
- "class": "btn btn-success btn-small tagButton",
- tag: tags[i],
- filepath: filePath,
- title: "Opens context menu for "+tags[i],
- text: tags[i]+" "
- })
- .append($("<span>", { class: "caret"}))
- );
- };
-
+
+ // Appending ext button
+ $( "#fileTags" ).append(TSCORE.generateExtButton(fileExtension,filePath));
+
+ // Appending tag buttons
+ var tags = TSCORE.TagUtils.extractTags(filePath);
+ var tagString = "";
+ tags.forEach(function (value, index) {
+ if(index == 0) {
+ tagString = value;
+ } else {
+ tagString = tagString + "," +value;
+ }
+ })
+ $( "#fileTags" ).append(TSCORE.generateTagButtons(tagString,filePath));
+
$( "#tagsContainer" ).droppable({
greedy: "true",
accept: ".tagButton",
@@ -188,6 +178,12 @@ define(function(require, exports, module) {
TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
})
.dropdown( 'attach' , '#tagMenu' );
+
+ $('.extTagButton', $( "#fileTags" ))
+ .click( function() {
+ TSCORE.selectedTag = fileExtension;
+ })
+ .dropdown( 'attach' , '#extensionMenu' );
// Clear filetoolbox
$( "#filetoolbox" ).empty();
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index 7f482f6b9..008dfe724 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -250,20 +250,16 @@ define(function(require, exports, module) {
}
// Helper function generating tag buttons
- function generateTagButtons(commaSeparatedTags, fileName, filePath) {
+ function generateTagButtons(commaSeparatedTags, filePath) {
//console.log("Creating tags...");
var tagString = ""+commaSeparatedTags;
var wrapper = $('<span>');
- if(filePath == undefined) {
- filePath = TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+fileName;
- }
if(tagString.length > 0) {
var tags = tagString.split(",");
for (var i=0; i < tags.length; i++) {
wrapper.append($('<button>', {
title: "Opens context menu for "+tags[i],
tag: tags[i],
- filename: fileName,
filepath: filePath,
"class": "btn btn-small tagButton",
text: tags[i]+" ",
@@ -290,17 +286,13 @@ define(function(require, exports, module) {
}
// Helper function generating file extension button
- function generateExtButton(fileExtension, fileName, filePath) {
+ function generateExtButton(fileExtension, filePath) {
//console.log("Creating ext button...");
var wrapper = $('<span>');
- if(filePath == undefined) {
- filePath = TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+fileName;
- }
if(fileExtension.length > 0) {
wrapper.append($('<button>', {
title: "Opens context menu for "+fileExtension,
tag: fileExtension,
- filename: fileName,
filepath: filePath,
"class": "btn btn-small extTagButton",
text: fileExtension+" "