From 2aee19a4ba664ad826f1e15fc78a82099e6da1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 31 Jan 2019 16:38:18 +0100 Subject: [PATCH 01/12] Remove hack to prefetch the starred trash icon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 6ad7f32938 SVG icons are directly embedded in "icons-vars.css", so the starred trash icon is now loaded along with the regular trash icon all at once. Therefore it is not needed to explicitly prefetch it using a hidden div. Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/navigation.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index acfda3b6ce..f749bf5dd5 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -66,9 +66,6 @@ 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("") trashElement.droppable({ over: function( event, ui ) { trashElement.addClass('dropzone-background') From 47937a50626bf017d8575a8974f140b3acf818a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 31 Jan 2019 17:46:41 +0100 Subject: [PATCH 02/12] Remove leftover from a WIP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/filelist.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index a4402caa7c..60d708515e 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -364,7 +364,6 @@ var self=this; this.$fileList.on("droppedOnTrash", function (event, filename, directory) { - //self.fileActions.triggerAction('Favorite', self.getModelForFile(file), self); self.do_delete(filename, directory) }); From dd91c4e500b1c6049d2af03d126b7f48d3b90621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 31 Jan 2019 17:59:50 +0100 Subject: [PATCH 03/12] Remove duplicated variable declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/filelist.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 60d708515e..88cb453bd4 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -362,7 +362,6 @@ $.event.trigger({type: "droppedOnTrash"}); - var self=this; this.$fileList.on("droppedOnTrash", function (event, filename, directory) { self.do_delete(filename, directory) }); From 72a424d4c843c019301a1ee61e6ed8bc0f60913f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 31 Jan 2019 18:53:27 +0100 Subject: [PATCH 04/12] Remove unneeded triggering of event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "droppedOnTrash" event was being triggered when the file list was initialized, but it should be triggered only when the user actually drops a file on the trash bin. Besides that, the event had no effect; only the file list handles it, but as it was not triggered on any element it ended being triggered on the document, and thus not handled. Moreover, even if it had been triggered on the file list it would have been done before the handler was set, so it would not have been handled anyway. And even if it had been handled no data was provided, so the handler would have failed. In conclusion, triggering the event there was not needed, and thus it was removed. Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/filelist.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 88cb453bd4..66965eab52 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -360,8 +360,6 @@ this.$fileList.on('click','td.filename>a.name, td.filesize, td.date', _.bind(this._onClickFile, this)); - $.event.trigger({type: "droppedOnTrash"}); - this.$fileList.on("droppedOnTrash", function (event, filename, directory) { self.do_delete(filename, directory) }); From 96bc1397b1d03d52da1befb685f331be5183e782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 31 Jan 2019 19:00:06 +0100 Subject: [PATCH 05/12] Add missing trailing ";" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/filelist.js | 2 +- apps/files/js/navigation.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 66965eab52..44d607ada4 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -361,7 +361,7 @@ this.$fileList.on('click','td.filename>a.name, td.filesize, td.date', _.bind(this._onClickFile, this)); this.$fileList.on("droppedOnTrash", function (event, filename, directory) { - self.do_delete(filename, directory) + self.do_delete(filename, directory); }); this.$fileList.on('change', 'td.selection>.selectCheckBox', _.bind(this._onClickFileCheckbox, this)); diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index f749bf5dd5..877b3184a5 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -62,13 +62,13 @@ * Setup UI events */ _setupEvents: function () { - this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) + this.$el.on('click', 'li a', _.bind(this._onClickItem, this)); this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); var trashElement=$(".nav-trashbin"); trashElement.droppable({ over: function( event, ui ) { - trashElement.addClass('dropzone-background') + trashElement.addClass('dropzone-background'); }, out: function( event, ui ) { trashElement.removeClass('dropzone-background'); @@ -219,7 +219,7 @@ */ setInitialQuickaccessSettings: function () { var quickAccessKey = this.$quickAccessListKey; - var quickAccessMenu = document.getElementById(quickAccessKey) + var quickAccessMenu = document.getElementById(quickAccessKey); if (quickAccessMenu) { var list = quickAccessMenu.getElementsByTagName('li'); this.QuickSort(list, 0, list.length - 1); From 75edcad54914a0c092fcf2eda5c22c379c93d71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 31 Jan 2019 19:09:15 +0100 Subject: [PATCH 06/12] Replace double quotes with single quotes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/filelist.js | 2 +- apps/files/js/navigation.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 44d607ada4..685cb03fed 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -360,7 +360,7 @@ this.$fileList.on('click','td.filename>a.name, td.filesize, td.date', _.bind(this._onClickFile, this)); - this.$fileList.on("droppedOnTrash", function (event, filename, directory) { + 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 877b3184a5..8ef9342aea 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -65,7 +65,7 @@ this.$el.on('click', 'li a', _.bind(this._onClickItem, this)); this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); - var trashElement=$(".nav-trashbin"); + var trashElement=$('.nav-trashbin'); trashElement.droppable({ over: function( event, ui ) { trashElement.addClass('dropzone-background'); @@ -74,24 +74,24 @@ trashElement.removeClass('dropzone-background'); }, activate: function( event, ui ) { - var elem=trashElement.find("a").first(); + 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(); + 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) { + if (ui.helper.find('tr').size()===1) { var $tr = $selectedFiles.closest('tr'); - $selectedFiles.trigger("droppedOnTrash", $tr.attr("data-file"), $tr.attr('data-dir')); + $selectedFiles.trigger('droppedOnTrash', $tr.attr('data-file'), $tr.attr('data-dir')); }else{ - var item = ui.helper.find("tr"); + var item = ui.helper.find('tr'); for(var i=0; i Date: Thu, 31 Jan 2019 19:13:08 +0100 Subject: [PATCH 07/12] Make code format more consistent with the rest of the file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/navigation.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 8ef9342aea..94d247b575 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -65,32 +65,31 @@ this.$el.on('click', 'li a', _.bind(this._onClickItem, this)); this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); - var trashElement=$('.nav-trashbin'); + var trashElement = $('.nav-trashbin'); trashElement.droppable({ - over: function( event, ui ) { + over: function (event, ui) { trashElement.addClass('dropzone-background'); }, - out: function( event, ui ) { + out: function (event, ui) { trashElement.removeClass('dropzone-background'); }, - activate: function( event, ui ) { - var elem=trashElement.find('a').first(); + 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(); + deactivate: function (event, ui) { + var elem = trashElement.find('a').first(); elem.addClass('nav-icon-trashbin').removeClass('nav-icon-trashbin-starred'); }, - drop: function( event, ui ) { - + drop: function (event, ui) { var $selectedFiles = $(ui.draggable); - if (ui.helper.find('tr').size()===1) { + if (ui.helper.find('tr').size() === 1) { var $tr = $selectedFiles.closest('tr'); $selectedFiles.trigger('droppedOnTrash', $tr.attr('data-file'), $tr.attr('data-dir')); - }else{ + } else { var item = ui.helper.find('tr'); - for(var i=0; i Date: Thu, 31 Jan 2019 19:49:22 +0100 Subject: [PATCH 08/12] Use full names instead of abbreviations in variable names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/navigation.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 94d247b575..6f09124a88 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -65,21 +65,21 @@ this.$el.on('click', 'li a', _.bind(this._onClickItem, this)); this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); - var trashElement = $('.nav-trashbin'); - trashElement.droppable({ + var trashBinElement = $('.nav-trashbin'); + trashBinElement.droppable({ over: function (event, ui) { - trashElement.addClass('dropzone-background'); + trashBinElement.addClass('dropzone-background'); }, out: function (event, ui) { - trashElement.removeClass('dropzone-background'); + trashBinElement.removeClass('dropzone-background'); }, activate: function (event, ui) { - var elem = trashElement.find('a').first(); - elem.addClass('nav-icon-trashbin-starred').removeClass('nav-icon-trashbin'); + var element = trashBinElement.find('a').first(); + element.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'); + var element = trashBinElement.find('a').first(); + element.addClass('nav-icon-trashbin').removeClass('nav-icon-trashbin-starred'); }, drop: function (event, ui) { var $selectedFiles = $(ui.draggable); From 8680ced1aea4128c5aa1e1e2490259f6501f30bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 31 Jan 2019 20:35:20 +0100 Subject: [PATCH 09/12] Unify handling of dropping one file or several files on the trash bin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a single file was dropped on the trash bin the file information was gotten from the original element in the file list. When several files were dropped on the trash bin the file information was gotten from the helper elements being dragged around. The helper element also contain the needed file information when a single file is being dragged, so the handling was unified to always get the file information from the helper elements. As the handling of several files is the same as before there is still the issue of only deleting those files shown in the drag helper instead of all the selected files. Signed-off-by: Daniel Calviño Sánchez --- apps/files/js/navigation.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 6f09124a88..538865ad5b 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -84,14 +84,13 @@ 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')); - } + // FIXME: when there are a lot of selected files the helper + // contains only a subset of them; the list of selected + // files should be gotten from the file list instead to + // ensure that all of them are removed. + 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')); } } }); From ad407f64bd64834f425de7cfb0db781ec634a44f Mon Sep 17 00:00:00 2001 From: fnuesse Date: Fri, 7 Dec 2018 18:33:05 +0100 Subject: [PATCH 10/12] Fix drop zone shadow Signed-off-by: fnuesse --- apps/files/css/files.scss | 8 +++++++- apps/files/js/navigation.js | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss index 502f8ea1f7..9b6f06cbc0 100644 --- a/apps/files/css/files.scss +++ b/apps/files/css/files.scss @@ -727,7 +727,13 @@ table.dragshadow td.size { .breadcrumb .canDrop > a, #filestable tbody tr.canDrop { - background-color: rgb(179, 230, 255); + background-color: rgba( $color-primary, .3 ); +} +.dropzone-background { + background-color: rgba( $color-primary, .3 ); + :hover{ + box-shadow: none !important; + } } diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index 538865ad5b..de0053e2e9 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -82,6 +82,8 @@ element.addClass('nav-icon-trashbin').removeClass('nav-icon-trashbin-starred'); }, drop: function (event, ui) { + trashBinElement.removeClass('dropzone-background'); + var $selectedFiles = $(ui.draggable); // FIXME: when there are a lot of selected files the helper From 4b32e1c6ab26409b7b4e6fb4e37d032af28298c9 Mon Sep 17 00:00:00 2001 From: fnuesse Date: Fri, 7 Dec 2018 18:33:05 +0100 Subject: [PATCH 11/12] Extract variable for yellow color in icons Signed-off-by: fnuesse --- apps/files/css/files.scss | 2 +- core/css/icons.scss | 4 ++-- core/css/variables.scss | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss index 9b6f06cbc0..80e88e16aa 100644 --- a/apps/files/css/files.scss +++ b/apps/files/css/files.scss @@ -704,7 +704,7 @@ table.dragshadow td.size { background-image: none; } & .icon-starred { - @include icon-color('star-dark', 'actions', 'FC0', 1, true); + @include icon-color('star-dark', 'actions', $color-yellow, 1, true); } } diff --git a/core/css/icons.scss b/core/css/icons.scss index d761c3a974..222b505b3a 100644 --- a/core/css/icons.scss +++ b/core/css/icons.scss @@ -282,13 +282,13 @@ img, object, video, button, textarea, input, select, div[contenteditable='true'] &:focus { @include icon-color('star', 'actions', $color-black, 1, true); } - @include icon-color('star-dark', 'actions', 'FC0', 1, true); + @include icon-color('star-dark', 'actions', $color-yellow, 1, true); } .icon-star { &:hover, &:focus { - @include icon-color('star-dark', 'actions', 'FC0', 1, true); + @include icon-color('star-dark', 'actions', $color-yellow, 1, true); } } diff --git a/core/css/variables.scss b/core/css/variables.scss index 404fa8743f..d3592032e5 100644 --- a/core/css/variables.scss +++ b/core/css/variables.scss @@ -53,6 +53,7 @@ $color-success: #46ba61; // used for svg $color-white: #fff; $color-black: #000; +$color-yellow: #FC0; // rgb(118, 118, 118) / #767676 // min. color contrast for normal text on white background according to WCAG AA From f13b3ab4aee79eeb949f5a6641e772ca71d10fbf Mon Sep 17 00:00:00 2001 From: fnuesse Date: Fri, 7 Dec 2018 18:33:05 +0100 Subject: [PATCH 12/12] Add drop zone for favorites quick access in navigation Signed-off-by: fnuesse --- apps/files/css/files.scss | 3 +++ apps/files/js/filelist.js | 4 ++++ apps/files/js/navigation.js | 41 +++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss index 80e88e16aa..62f4431dbb 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 685cb03fed..232b47857b 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 de0053e2e9..f8f15394ef 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')); + } + } + }); }, /**