summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorfnuesse <felix.nuesse@t-online.de>2018-12-07 18:33:05 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-02-01 01:45:03 +0100
commitf13b3ab4aee79eeb949f5a6641e772ca71d10fbf (patch)
treeb35d75bed4963397efbbc2fd5869de05dbb4dcb1 /apps
parent4b32e1c6ab26409b7b4e6fb4e37d032af28298c9 (diff)
downloadnextcloud-server-f13b3ab4aee79eeb949f5a6641e772ca71d10fbf.tar.gz
nextcloud-server-f13b3ab4aee79eeb949f5a6641e772ca71d10fbf.zip
Add drop zone for favorites quick access in navigation
Signed-off-by: fnuesse <felix.nuesse@t-online.de>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/css/files.scss3
-rw-r--r--apps/files/js/filelist.js4
-rw-r--r--apps/files/js/navigation.js41
3 files changed, 48 insertions, 0 deletions
diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss
index 80e88e16aaf..62f4431dbbb 100644
--- a/apps/files/css/files.scss
+++ b/apps/files/css/files.scss
@@ -120,6 +120,9 @@
.nav-icon-deletedshares {
@include icon-color('unshare', 'files', $color-black);
}
+.nav-icon-favorites-starred {
+ @include icon-color('star-dark', 'actions', $color-yellow, 2, true);
+}
#app-navigation .nav-files a.nav-icon-files {
width: auto;
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 685cb03fed9..232b47857bb 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -360,6 +360,10 @@
this.$fileList.on('click','td.filename>a.name, td.filesize, td.date', _.bind(this._onClickFile, this));
+ this.$fileList.on("droppedOnFavorites", function (event, file) {
+ self.fileActions.triggerAction('Favorite', self.getModelForFile(file), self);
+ });
+
this.$fileList.on('droppedOnTrash', function (event, filename, directory) {
self.do_delete(filename, directory);
});
diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js
index de0053e2e91..f8f15394ef0 100644
--- a/apps/files/js/navigation.js
+++ b/apps/files/js/navigation.js
@@ -224,6 +224,47 @@
var list = quickAccessMenu.getElementsByTagName('li');
this.QuickSort(list, 0, list.length - 1);
}
+
+ var favoritesListElement = $(quickAccessMenu).parent();
+ favoritesListElement.droppable({
+ over: function (event, ui) {
+ favoritesListElement.addClass('dropzone-background');
+ },
+ out: function (event, ui) {
+ favoritesListElement.removeClass('dropzone-background');
+ },
+ activate: function (event, ui) {
+ var element = favoritesListElement.find('a').first();
+ element.addClass('nav-icon-favorites-starred').removeClass('nav-icon-favorites');
+ },
+ deactivate: function (event, ui) {
+ var element = favoritesListElement.find('a').first();
+ element.addClass('nav-icon-favorites').removeClass('nav-icon-favorites-starred');
+ },
+ drop: function (event, ui) {
+ favoritesListElement.removeClass('dropzone-background');
+
+ var $selectedFiles = $(ui.draggable);
+
+ if (ui.helper.find('tr').size() === 1) {
+ var $tr = $selectedFiles.closest('tr');
+ if ($tr.attr("data-favorite")) {
+ return;
+ }
+ $selectedFiles.trigger('droppedOnFavorites', $tr.attr('data-file'));
+ } else {
+ // FIXME: besides the issue described for dropping on
+ // the trash bin, for favoriting it is not possible to
+ // use the data from the helper; due to some bugs the
+ // tags are not always added to the selected files, and
+ // thus that data can not be accessed through the helper
+ // to prevent triggering the favorite action on an
+ // already favorited file (which would remove it from
+ // favorites).
+ OC.Notification.showTemporary(t('files', 'You can only favorite a single file or folder at a time'));
+ }
+ }
+ });
},
/**