TagSpaces is an offline, open source, document manager with tagging support
Refactoring
uggrock3b8ead590656
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.jsindex 202e11033..49de0842b 100644--- a/data/js/tags.ui.js+++ b/data/js/tags.ui.js@@ -21,6 +21,19 @@ TagsUI.initContextMenus = function() {}});+ $( "#extensionMenu" ).menu({+ select: function( event, ui ) {+ console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);+ switch (ui.item.attr( "action" )) {+ case "addTagAsFilter":+ $( this ).hide();+ $("#filterBox").val(UIAPI.selectedTag);+ UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);+ break;+ }+ }+ });+// Context menu for the tags in the file table and the file viewer$( "#tagMenu" ).menu({select: function( event, ui ) {@@ -44,9 +57,6 @@ TagsUI.initContextMenus = function() {$( this ).hide();TSAPI.removeTag(UIAPI.selectedTag);break;- case "closeMenu":- $( this).hide();- break;}}});@@ -64,8 +74,7 @@ TagsUI.initContextMenus = function() {UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);break;case "editTag":- // TODO Consider smart tags- $( "#tagName" ).val(UIAPI.selectedTagData.title);+ $( "#tagName" ).val(UIAPI.selectedTag);$( "#dialog-tagedit" ).dialog( "open" );break;case "deleteTag":@@ -97,6 +106,37 @@ TagsUI.initContextMenus = function() {}}});++ $( "#fileMenu" ).menu({+ select: function( event, ui ) {+ var commandName = ui.item.attr( "action" );+ switch (commandName) {+ case "addTag":+ console.debug("Adding tag...");+ $("#tags").val("");+ $( "#dialogAddTags" ).dialog( "open" );+ break;+ case "openFile":+ console.debug("Opening file...");+ UIAPI.openFile(UIAPI.currentPath+UIAPI.getDirSeparator()+UIAPI.selectedFiles[0]);+ break;+ case "openDirectory":+ console.debug("Opening parent directory...");+ IOAPI.openDirectory(UIAPI.currentPath);+ break;+ case "renameFile":+ console.debug("Renaming file...");+ $( "#dialog-filerename" ).dialog( "open" );+ break;+ case "deleteFile":+ console.debug("Deleting file...");+ $( "#dialog-confirmdelete" ).dialog( "open" );+ break;+ default:+ break;+ }+ }+ });}TagsUI.initDialogs = function() {@@ -233,7 +273,6 @@ TagsUI.initDialogs = function() {modal: true,buttons: {"Save": function() {- // TODO complete the functionality for smart tagsTSSETTINGS.editTag(UIAPI.selectedTagData, $( "#tagName" ).val() )TagsUI.generateTagGroups();$( this ).dialog( "close" );@@ -364,16 +403,57 @@ TagsUI.generateTagGroups = function() {});}-// TODO evtl. move to Fileviewer.jsTagsUI.openTagMenu = function(tagButton, tag, fileName) {- UIAPI.ViewManager.clearSelectedFiles();- $(tagButton).parent().parent().toggleClass("selectedRow");-UIAPI.currentFilename = fileName;UIAPI.selectedFiles.push(UIAPI.currentFilename);-UIAPI.selectedTag = tag;- UIAPI.currentFilename = fileName;+}++// Helper function user by basic and search views+TagsUI.generateTagButtons = function(commaSeparatedTags, fileExtension, fileName) {+ console.debug("Creating tags...");+ var tagString = ""+commaSeparatedTags;+ var wrapper = $('<span>');+ if(fileExtension.length > 0) {+ wrapper.append($('<button>', {+ title: "Opens context menu for "+fileExtension,+ tag: fileExtension,+ filename: fileName,+ class: "extTagButton",+ text: fileExtension+ }));+ }+ 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,+ class: "tagButton",+ text: tags[i]+ }));+ }+ }+ return wrapper.html();+}++// Helper function user by basic and search views+TagsUI.buttonizeTitle = function(title, fileName) {+ return $('<span>').append($('<button>', {+ title: fileName,+ class: 'fileTitleButton',+ text: title+' '+ })).html();+}++// Helper function user by basic and search views+TagsUI.buttonizeFileName = function(fileName) {+ return $('<span>').append($('<button>', {+ title: fileName,+ class: 'fileButton',+ text: fileName+ })).html();}//});\ No newline at end of file