TagSpaces is an offline, open source, document manager with tagging support
Opening of a directory from the context menu implemented New algorith for the directory browsing implemented
uggrock8daf1c3ce6f5
diff --git a/data/index.html b/data/index.htmlindex 762c51f41..f6ee77dd3 100644--- a/data/index.html+++ b/data/index.html@@ -306,7 +306,7 @@<ul id="directoryMenu" class="dropdown-menu has-tip"><li action="reloadDirectory" title="Reload directory"><a href="javascript:void(0);"><span class="ui-icon ui-icon-refresh"></span>Reload Directory</a></li><li action="createDirectory" title="Creates a new subdirectory"><a href="javascript:void(0);"><span class="ui-icon ui-icon-document"></span>New Subdirectory</a></li>- <li action="openDirectory" title="Opens the directoriy in the default file browser"><a href="javascript:void(0);"><span class="ui-icon ui-icon-folder-open"></span>Show Containing Folder</a></li>+ <li action="openDirectory" title="Opens the directoriy in the default file browser"><a href="javascript:void(0);"><span class="ui-icon ui-icon-folder-open"></span>Show Folder</a></li></ul></div></body>diff --git a/data/js/directories.ui.js b/data/js/directories.ui.jsindex 29597631e..221bf4058 100644--- a/data/js/directories.ui.js+++ b/data/js/directories.ui.js@@ -140,27 +140,62 @@ DirectoriesUI.setDirectoryCollapse = function(directoryPath, collapsed) {DirectoriesUI.navigateToDirectory = function(directoryPath) {console.log("Navigating to directory: "+directoryPath);- var directoryFound = false;+ // Cleaning the directory path from \\ \ and /+ if( (directoryPath.lastIndexOf('/')+1 == directoryPath.length) || (directoryPath.lastIndexOf('\\')+1 == directoryPath.length)) {+ directoryPath = directoryPath.substring(0,directoryPath.length-1);+ }+ if( (directoryPath.lastIndexOf('\\\\')+1 == directoryPath.length)) {+ directoryPath = directoryPath.substring(0,directoryPath.length-2);+ }++ var directoryFoundOn = -1;for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {if(DirectoriesUI.directoryHistory[i].key == directoryPath) {DirectoriesUI.directoryHistory[i].collapsed = false;- directoryFound = true;+ directoryFoundOn = i;} else {DirectoriesUI.directoryHistory[i].collapsed = true;}}- // TODO find index of currentPath and splice the array+ // Removes the history only if it is a completely new file+// if(DirectoriesUI.directoryHistory.length > 0) {+// var lastDirectoryInHistory = DirectoriesUI.directoryHistory[DirectoriesUI.directoryHistory.length-1];+// if(lastDirectoryInHistory['key'].indexOf(directoryPath) < 0) {+ if(directoryFoundOn >= 0) {+ var diff = DirectoriesUI.directoryHistory.length - (directoryFoundOn+1);+ if(diff > 0) {+ DirectoriesUI.directoryHistory.splice(directoryFoundOn+1, diff);+ }+ }+// }+// }// If directory path not in history then add it to the history- if(!directoryFound) {+ if(directoryFoundOn < 0) {+ var parentLocation = directoryPath.substring(0, directoryPath.lastIndexOf(UIAPI.getDirSeparator()));+ var parentFound = -1;+ for(var i=0; i < DirectoriesUI.directoryHistory.length; i++) {+ if(DirectoriesUI.directoryHistory[i].key == parentLocation) {+ parentFound = i;+ }+ }+ if(parentFound >= 0) {+ var diff = DirectoriesUI.directoryHistory.length - (parentFound+1);+ if(diff > 0) {+ DirectoriesUI.directoryHistory.splice(parentFound+1, diff);+ }+ }++ var locationTitle = directoryPath.substring(directoryPath.lastIndexOf(UIAPI.getDirSeparator())+1,directoryPath.length);DirectoriesUI.directoryHistory.push({- "title": directoryPath.substring(directoryPath.lastIndexOf(UIAPI.getDirSeparator())+1,directoryPath.length),+ "title": locationTitle,"key" : directoryPath,"collapsed" : false,- });+ });}+UIAPI.currentPath = directoryPath;IOAPI.getSubdirs(directoryPath);IOAPI.listDirectory(directoryPath);@@ -231,6 +266,9 @@ DirectoriesUI.initContextMenus = function() {case "createDirectory":$( "#dialog-dircreate" ).dialog("open");break;+ case "openDirectory":+ IOAPI.openDirectory(DirectoriesUI.dir4ContextMenu);+ break;}}});