From 2b0fbf7b89b3b7dc6a1382169ee4899a17e12bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20N=C3=BCsse?= Date: Tue, 28 Aug 2018 18:21:46 +0200 Subject: [PATCH] Added Trash-Dropzone to easily dispose of files and folders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Felix NĂ¼sse --- apps/files/js/filelist.js | 8 ++++++++ apps/files/js/navigation.js | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 154209ca97..c6e603e0c9 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -342,6 +342,14 @@ this.$fileList.on('click','td.filename>a.name, td.filesize, td.date', _.bind(this._onClickFile, this)); + $.event.trigger({type: "droppedOnTrash"}); + + var self=this; + this.$fileList.on("droppedOnTrash", function (event, filename, directory) { + //self.fileActions.triggerAction('Favorite', self.getModelForFile(file), self); + self.do_delete(filename, directory) + }); + this.$fileList.on('change', 'td.selection>.selectCheckBox', _.bind(this._onClickFileCheckbox, this)); this.$el.on('show', _.bind(this._onShow, this)); this.$el.on('urlChanged', _.bind(this._onUrlChanged, this)); diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 9fc2180c92..d8b249411f 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -64,6 +64,23 @@ _setupEvents: function () { this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); + + $(".nav-trashbin").droppable({ + drop: function( event, ui ) { + + var $selectedFiles = $(ui.draggable); + + if (ui.helper.find("tr").size()===1) { + var $tr = $selectedFiles.closest('tr'); + $selectedFiles.trigger("droppedOnTrash", $tr.attr("data-file"), $tr.attr('data-dir')); + }else{ + var item = ui.helper.find("tr"); + for(var i=0; i