Skip to content

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

Tag visualization realization exchanged with modified jqueryui accordion

uggrocke1c0c9ff1d64
diff --git a/data/css/settings.png b/data/css/settings.png
new file mode 100644
index 000000000..928d505ce
Binary files /dev/null and b/data/css/settings.png differ
diff --git a/data/css/settingsHover.png b/data/css/settingsHover.png
new file mode 100644
index 000000000..f09ab062c
Binary files /dev/null and b/data/css/settingsHover.png differ
diff --git a/data/css/tagspaces.less b/data/css/tagspaces.less
index 8ec5900ed..8657bb699 100644
--- a/data/css/tagspaces.less
+++ b/data/css/tagspaces.less
@@ -300,13 +300,32 @@ span.dynatree-icon {
}
-#dirTree, #tagGroups {
+#dirTree {
overflow: hidden;
}
-/*#tagGroups ul.dynatree-container a:focus, #tagGroups span.dynatree-focused a:link {
- background-color: #00AA00;
-}*/
+.tagGroupTitle {
+ padding-left: 15px;
+ background-image: url('arrow-down.png');
+ background-repeat: no-repeat;
+ background-position: left;
+}
+
+.tagGroupSettings {
+ float: right;
+ width: 20px;
+ background-image: url('settings.png');
+ background-repeat: no-repeat;
+ background-position: left;
+}
+
+.tagGroupSettings:hover {
+ background-image: url('settingsHover.png');
+}
+
+#tagGroups {
+ overflow: auto;
+}
#tagGroups ul.dynatree-container a, #tagGroups ul.dynatree-container a:hover {
padding: 1px;
diff --git a/data/index.html b/data/index.html
index 7cc21ab11..9140fe7ca 100644
--- a/data/index.html
+++ b/data/index.html
@@ -287,23 +287,19 @@
<li action="removeTag" title=""><a href="javascript:void(0);"><span class="ui-icon ui-icon-trash"></span>Remove Tag</a></li>
</ul>
- <ul class="contextMenu" id="tagTreeMenu">
+ <ul id="tagTreeMenu" class="dropdown-menu has-tip">
<li action="addTagToFile" title="Add current tag to the selected files"><a href="javascript:void(0);"><span class="ui-icon ui-icon-tag"></span>Tag Selected Files</a></li>
<li action="addTagAsFilter" title="Set current tag as a filter criteria"><a href="javascript:void(0);"><span class="ui-icon ui-icon-search"></span>Set As Filter</a></li>
<li action="editTag" title="Edit current tag"><a href="javascript:void(0);"><span class="ui-icon ui-icon-wrench"></span>Edit</a></li>
<li action="deleteTag" title="Delete the tag from the taggroup"><a href="javascript:void(0);"><span class="ui-icon ui-icon-trash"></span>Delete</a></li>
- <!--li><hr></li>
- <li action="closeMenu" title=""><a href="javascript:void(0);"><span class="ui-icon ui-icon-close"></span>Close Menu</a></li-->
</ul>
- <ul class="contextMenu" id="tagGroupMenu">
- <li action="toggleTagGroup" title="Opens or Close the selected tagroup"><a href="javascript:void(0);">Toggle Taggroup</a></li>
+ <ul id="tagGroupMenu" class="dropdown-menu has-tip">
+ <!--li action="toggleTagGroup" title="Opens or Close the selected tagroup"><a href="javascript:void(0);">Toggle Taggroup</a></li-->
<li action="createNewTag" title="Creates new tag"><a href="javascript:void(0);"><span class="ui-icon ui-icon-tag"></span>Create Tag</a></li>
<li action="duplicateTagGroup" title="Duplicate current tagroup"><a href="javascript:void(0);"><span class="ui-icon ui-icon-copy"></span>Duplicate Taggroup</a></li>
<li action="editTagGroup" title="Edit current tagroup"><a href="javascript:void(0);"><span class="ui-icon ui-icon-wrench"></span>Edit Taggroup</a></li>
<li action="deleteTagGroup" title="Delete current tagroup"><a href="javascript:void(0);"><span class="ui-icon ui-icon-trash"></span>Delete Taggroup</a></li>
- <!--li><hr></li>
- <li action="closeMenu" title=""><a href="javascript:void(0);"><span class="ui-icon ui-icon-close"></span>Close Menu</a></li-->
</ul>
</div>
</body>
diff --git a/data/js/main.js b/data/js/main.js
index 15baaa999..4fb7e0031 100644
--- a/data/js/main.js
+++ b/data/js/main.js
@@ -43,7 +43,7 @@ var initApp = function(){
function() {
TagsUI.initContextMenus();
TagsUI.initDialogs();
- TagsUI.initTagTree();
+ //TagsUI.initTagTree();
BasicViewsUI.initContextMenus();
BasicViewsUI.initFileTagViews();
@@ -77,8 +77,7 @@ var initApp = function(){
DirectoriesUI.initFavorites();
- //TODO sometimes by a new start of the browser the add-on hangs here, complaining method addChild is not there...
- $("#tagGroups").dynatree("getRoot").addChild(TSSETTINGS.Settings["tagGroups"]);
+ TagsUI.generateTagGroups();
// TODO workarround for a bug
$("#dirTree").css("display", "block");
diff --git a/data/js/messaging.mozilla.js b/data/js/messaging.mozilla.js
index 9a0d446cf..c06bdf9d2 100644
--- a/data/js/messaging.mozilla.js
+++ b/data/js/messaging.mozilla.js
@@ -18,7 +18,7 @@ document.documentElement.addEventListener("addon-message1", function(event) {
TSSETTINGS.updateSettingMozillaPreferences(message.content);
DirectoriesUI.initFavorites();
- TagsUI.updateTagGroups();
+ TagsUI.generateTagGroups();
} catch (ex) {
console.debug("Exception while getting setting from firefox failed "+ex)
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index 063502408..6fb71f331 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -208,6 +208,28 @@ TSSETTINGS.deleteTag = function(tagData) {
TSSETTINGS.saveSettings();
}
+TSSETTINGS.getTagData = function(tagTitle, parentKey) {
+ for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
+ if(TSSETTINGS.Settings["tagGroups"][i].key == parentKey) {
+ for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
+ if(TSSETTINGS.Settings["tagGroups"][i]["children"][j].title == tagTitle) {
+ return TSSETTINGS.Settings["tagGroups"][i]["children"][j];
+ break;
+ }
+ }
+ }
+ }
+}
+
+TSSETTINGS.getTagGroupData = function(tagGroupKey) {
+ for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
+ if(TSSETTINGS.Settings["tagGroups"][i].key == tagGroupKey) {
+ return TSSETTINGS.Settings["tagGroups"][i];
+ break;
+ }
+ }
+}
+
TSSETTINGS.deleteTagGroup = function(tagData) {
for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
if(TSSETTINGS.Settings["tagGroups"][i].key == tagData.key) {
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index 54c853a87..a358df3f9 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -211,7 +211,7 @@ TagsUI.initDialogs = function() {
buttons: {
"Delete tag from taggroup": function() {
TSSETTINGS.deleteTag(UIAPI.selectedTagData);
- TagsUI.updateTagGroups();
+ TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -228,7 +228,7 @@ TagsUI.initDialogs = function() {
buttons: {
"Delete": function() {
TSSETTINGS.deleteTagGroup(UIAPI.selectedTagData);
- TagsUI.updateTagGroups();
+ TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -246,7 +246,7 @@ TagsUI.initDialogs = function() {
"Save": function() {
// TODO complete the functionality for smart tags
TSSETTINGS.editTag(UIAPI.selectedTagData, $( "#tagName" ).val() )
- TagsUI.updateTagGroups();
+ TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -263,7 +263,7 @@ TagsUI.initDialogs = function() {
buttons: {
"Create tag": function() {
TSSETTINGS.createTag(UIAPI.selectedTagData, $( "#newTagName" ).val() )
- TagsUI.updateTagGroups();
+ TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -280,7 +280,7 @@ TagsUI.initDialogs = function() {
buttons: {
"Duplicate taggroup": function() {
TSSETTINGS.duplicateTagGroup(UIAPI.selectedTagData, $( "#newTagGroupName" ).val(), $( "#newTagGroupKey" ).val() )
- TagsUI.updateTagGroups();
+ TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -297,7 +297,7 @@ TagsUI.initDialogs = function() {
buttons: {
"Save": function() {
TSSETTINGS.editTagGroup(UIAPI.selectedTagData, $( "#tagGroupName" ).val() )
- TagsUI.updateTagGroups();
+ TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -307,55 +307,67 @@ TagsUI.initDialogs = function() {
});
}
-TagsUI.updateTagGroups = function() {
- console.debug("Updating TagGroups tree..."); //+JSON.stringify(TSSETTINGS.Settings["tagGroups"]));
- var tagTree = $("#tagGroups").dynatree("getRoot")
- tagTree.removeChildren();
- tagTree.addChild(TSSETTINGS.Settings["tagGroups"]);
-}
-
-TagsUI.initTagTree = function() {
- // Init the tag tree / taggroups module
- $("#tagGroups").dynatree({
- clickFolderMode: 1,
- onClick: function(node, event) {
- if(!node.data.isFolder) {
- // var jsnode = $.ui.dynatree.getNode(this);
- UIAPI.selectedTag = node.data.title;
- UIAPI.selectedTagData = node.data;
- UIAPI.selectedTagData.parentKey = node.parent.data.key;
- $("#tagGroupMenu").hide();
- $("#tagTreeMenu").show().position({
- my: "left top",
- at: "left bottom",
- of: $("a", $(node.li))
- });
- $( document ).one( "click", function() {
- $("#tagTreeMenu").hide();
- });
- return false;
- } else {
- UIAPI.selectedTag = node.data.title;
- UIAPI.selectedTagData = node.data;
- UIAPI.selectedTagData.parentKey = undefined;
- $("#tagTreeMenu").hide();
- $("#tagGroupMenu").show().position({
- my: "left top",
- at: "left bottom",
- of: $("a", $(node.li))
- });
- $( document ).one( "click", function() {
- $("#tagGroupMenu").hide();
- });
- return false;
- }
- },
- onDblClick: function(node, event) {
- node.toggleExpand();
- },
- });
+TagsUI.generateTagGroups = function() {
+ console.debug("Generating TagGroups...");
+ $("#tagGroups").empty();
+ $("#tagGroups").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")
+ for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
+ $("#tagGroups").append($("<h3>", {
+ class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"
+ })
+ .hover(function() { $(this).toggleClass("ui-state-hover"); })
+ .append($("<span>", {
+ class: "tagGroupTitle",
+ text: TSSETTINGS.Settings["tagGroups"][i].title,
+ })
+ .click(function() {
+ $(this)
+ .parent().toggleClass("ui-accordion-header-active ui-state-active ui-state-default ui-corner-bottom").end()
+ .parent().next().toggleClass("ui-accordion-content-active").toggle();
+ return false;
+ })
+ )
+ .append($("<span>", {
+ class: "tagGroupSettings",
+ tag: TSSETTINGS.Settings["tagGroups"][i].title,
+ key: TSSETTINGS.Settings["tagGroups"][i].key,
+ title: "Taggroup options",
+ text: "-",
+ })
+ .dropdown( 'attach' , '#tagGroupMenu' )
+ .click( function(event) {
+ //console.debug("Clicked in taggroup setting");
+ UIAPI.selectedTag = $(this).attr("tag");
+ UIAPI.selectedTagData = TSSETTINGS.getTagGroupData($(this).attr("key"));
+ UIAPI.selectedTagData.parentKey = undefined;
+ })
+ )
+ );
+
+ var tagButtons = $("<div>").appendTo( "#tagGroups" );
+ tagButtons.attr("style","margin: 0px; padding: 5px;");
+ tagButtons.addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")
+ tagButtons.hide();
+ for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
+ tagButtons.append($("<button>", {
+ class: "tagButton",
+ tag: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,
+ parentKey: TSSETTINGS.Settings["tagGroups"][i].key,
+ title: "Opens context menu for "+TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,
+ text: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,
+ })
+ .click( function() {
+ UIAPI.selectedTag = $(this).attr("tag");
+ UIAPI.selectedTagData = TSSETTINGS.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
+ UIAPI.selectedTagData.parentKey = $(this).attr("parentKey");
+ })
+ .dropdown( 'attach' , '#tagTreeMenu' )
+ );
+ }
+ }
}
+// TODO evtl. move to Fileviewer.js
TagsUI.openTagMenu = function(tagButton, tag, fileName) {
BasicViewsUI.clearSelectedFiles();
$(tagButton).parent().parent().toggleClass("selectedRow");