diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-10-02 19:36:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-02 19:36:38 +0200 |
commit | 01082d04fd0f812099f59120edd9ba3e71558a9e (patch) | |
tree | e4988b7fa85aea0b26b1ee7ef26726f96a5f80fc /apps | |
parent | c2ef47ee13799bf0b5a0dbe97e54a021c888d8eb (diff) | |
parent | df7e016104f284c29f9c8571d548b64008f1a626 (diff) | |
download | nextcloud-server-01082d04fd0f812099f59120edd9ba3e71558a9e.tar.gz nextcloud-server-01082d04fd0f812099f59120edd9ba3e71558a9e.zip |
Merge pull request #10909 from nextcloud/feature/noid/trash-add-droppable-zone
Added Trash-Dropzone to easily dispose of files and folders
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/css/files.scss | 3 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 8 | ||||
-rw-r--r-- | apps/files/js/navigation.js | 35 |
3 files changed, 46 insertions, 0 deletions
diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss index f93107fef84..5d8a20d86a6 100644 --- a/apps/files/css/files.scss +++ b/apps/files/css/files.scss @@ -105,6 +105,9 @@ .nav-icon-trashbin { @include icon-color('delete', 'files', $color-black); } +.nav-icon-trashbin-starred { + @include icon-color('delete', 'files', #ff0000); +} .nav-icon-deletedshares { @include icon-color('unshare', 'files', $color-black); } diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 154209ca975..c6e603e0c94 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 9fc2180c923..b3648fedc6c 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -64,6 +64,41 @@ _setupEvents: function () { this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); + + var trashElement=$(".nav-trashbin"); + + //this div is required to prefetch the icon, otherwise it takes a second to show up + trashElement.append("<div class='nav-icon-trashbin-starred'></div>") + trashElement.droppable({ + over: function( event, ui ) { + trashElement.addClass('dropzone-background') + }, + out: function( event, ui ) { + trashElement.removeClass('dropzone-background'); + }, + activate: function( event, ui ) { + var elem=trashElement.find("a").first(); + elem.addClass('nav-icon-trashbin-starred').removeClass('nav-icon-trashbin'); + }, + deactivate: function( event, ui ) { + var elem=trashElement.find("a").first(); + elem.addClass('nav-icon-trashbin').removeClass('nav-icon-trashbin-starred'); + }, + 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<item.length;i++){ + $selectedFiles.trigger("droppedOnTrash", item[i].getAttribute("data-file"), item[i].getAttribute("data-dir")); + } + } + } + }); }, /** |