Skip to content

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

Enabling drag&drop of files in tag & search views

uggrocke308490b4db2
diff --git a/data/css/tagspaces.less b/data/css/tagspaces.less
index fb0817d12..decaecc6e 100644
--- a/data/css/tagspaces.less
+++ b/data/css/tagspaces.less
@@ -167,6 +167,7 @@ li hr {
.fileButton {
padding: 1px;
+ background-color: #E5E5E5;
padding-left: 1px;
padding-right: 12px;
font-weight: normal;
@@ -182,7 +183,7 @@ li hr {
.fileTitleButton {
padding: 1px;
- background: transparent url("arrow-down.png") no-repeat right;
+ background-color: #E5E5E5;
padding-left: 1px;
padding-right: 12px;
font-weight: normal;
@@ -191,6 +192,7 @@ li hr {
text-align: left;
margin: 1px;
border: #ddd solid 1px;
+ .arrowDownImage;
.roundedTagCorners;
}
diff --git a/data/ext/view.basic.js b/data/ext/view.basic.js
index b2a6eb6f6..dcace2367 100644
--- a/data/ext/view.basic.js
+++ b/data/ext/view.basic.js
@@ -255,6 +255,15 @@ exports.load = function load() {
.dropdown( 'attach' , '#fileMenu' );
fileTable.$('.fileTitleButton')
+ .draggable({
+ cancel:false,
+ appendTo: "body",
+ helper: "clone",
+ revert: true,
+ start: function() {
+ selectFile(this, $(this).attr("filepath"));
+ }
+ })
.click( function() {
selectFile(this, $(this).attr("filepath"));
} )
diff --git a/data/ext/view.search.js b/data/ext/view.search.js
index 2fb5e4453..3e3d044c6 100644
--- a/data/ext/view.search.js
+++ b/data/ext/view.search.js
@@ -207,9 +207,18 @@ exports.updateIndexData = function updateIndexData(index) {
} );
fileTable.$('.fileTitleButton')
+ .draggable({
+ cancel:false,
+ appendTo: "body",
+ helper: "clone",
+ revert: true,
+ start: function() {
+ selectFile(this, $(this).attr("filepath"));
+ }
+ })
.click( function() {
selectFile(this, $(this).attr("title"));
- } )
+ } )
.dropdown( 'attach' , '#fileMenu' );
fileTable.$('.extTagButton')
diff --git a/data/js/directories.ui.js b/data/js/directories.ui.js
index d9f0ed4a4..91242267a 100644
--- a/data/js/directories.ui.js
+++ b/data/js/directories.ui.js
@@ -76,14 +76,14 @@ DirectoriesUI.generateDirPath = function() {
text: DirectoriesUI.directoryHistory[i].title,
})
.droppable({
- accept: ".fileButton",
+ accept: '.fileTitleButton,.fileButton',
hoverClass: "dirButtonActive",
drop: function( event, ui ) {
- var fileName = ui.draggable.attr("title");
+ var filePath = ui.draggable.attr("filepath");
+ var fileName = TSAPI.extractFileName(filePath);
var targetDir = $(this).attr("key");
- console.log("Moving file: "+fileName+" to "+targetDir);
- IOAPI.renameFile(UIAPI.currentPath+TSAPI.getDirSeparator()+fileName, targetDir+TSAPI.getDirSeparator()+fileName);
- IOAPI.listDirectory(UIAPI.currentPath);
+ console.log("Moving file: "+filePath+" to "+targetDir);
+ IOAPI.renameFile(filePath, targetDir+TSAPI.getDirSeparator()+fileName);
}
})
.click(function() {
@@ -119,15 +119,14 @@ DirectoriesUI.generateDirPath = function() {
text: DirectoriesUI.directoryHistory[i]["children"][j].title,
})
.droppable({
- accept: ".fileButton",
+ accept: ".fileTitleButton,.fileButton",
hoverClass: "dirButtonActive",
drop: function( event, ui ) {
- var fileName = ui.draggable.attr("title");
+ var filePath = ui.draggable.attr("filepath");
+ var fileName = TSAPI.extractFileName(filePath);
var targetDir = $(this).attr("key");
- console.log("Moving file: "+fileName+" to "+targetDir);
- IOAPI.renameFile(UIAPI.currentPath+TSAPI.getDirSeparator()+fileName, targetDir+TSAPI.getDirSeparator()+fileName);
- IOAPI.listDirectory(UIAPI.currentPath);
- UIAPI.closeFileViewer();
+ console.log("Moving file: "+filePath+" to "+targetDir);
+ IOAPI.renameFile(filePath, targetDir+TSAPI.getDirSeparator()+fileName);
}
})
.click( function() {