Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File drop highlight #83

Merged
merged 9 commits into from
Jun 15, 2016
16 changes: 16 additions & 0 deletions apps/files/css/files.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,23 @@
}

.app-files #app-content {
transition: background-color 0.3s ease;
overflow-x: hidden;
}

.file-drag, .file-drag #filestable tbody tr, .file-drag #filestable tbody tr:hover {
transition: background-color 0.3s ease!important;
background-color: rgb(179, 230, 255)!important;
}

.app-files #app-content.dir-drop, .file-drag #filestable tbody tr, .file-drag #filestable tbody tr:hover{
background-color: rgba(0, 0, 0, 0)!important;
}

.app-files #app-content.dir-drop #filestable tbody tr.dropping-to-dir{
background-color: rgb(179, 230, 255)!important;
}

/* icons for sidebar */
.nav-icon-files {
background-image: url('../img/folder.svg');
Expand Down Expand Up @@ -113,6 +127,7 @@
}

#filestable tbody tr {
transition: background-color 0.3s ease;
background-color: #fff;
height: 40px;
}
Expand All @@ -125,6 +140,7 @@
#filestable tbody tr.selected,
#filestable tbody tr.searchresult,
table tr.mouseOver td {
transition: background-color 0.3s ease;
background-color: #f8f8f8;
}
tbody a { color:#000; }
Expand Down
4 changes: 4 additions & 0 deletions apps/files/css/mobile.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
@media only screen and (max-width: 768px) {

.app-files #app-content.dir-drop{
background-color: rgba(255, 255, 255, 1)!important;
}

/* don’t require a minimum width for files table */
#body-user #filestable {
min-width: initial !important;
Expand Down
26 changes: 24 additions & 2 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ OC.Upload = {
var self = this;
if ( $('#file_upload_start').exists() ) {
var file_upload_param = {
dropZone: $('#content'), // restrict dropZone to content div
dropZone: $('#app-content'), // restrict dropZone to app-content div
pasteZone: null,
autoUpload: false,
sequentialUploads: true,
Expand Down Expand Up @@ -494,7 +494,7 @@ OC.Upload = {
* @param {object} e
* @param {object} data
*/
done:function(e, data) {
done: function(e, data) {
OC.Upload.log('done', e, data);
// handle different responses (json or body from iframe for ie)
var response;
Expand Down Expand Up @@ -667,7 +667,29 @@ OC.Upload = {
OC.Upload._hideProgressBar();
}
});
fileupload.on('fileuploaddragover', function(e){
$('#app-content').addClass('file-drag');

var filerow = $(e.delegatedEvent.target).closest('tr');

if(!filerow.hasClass('dropping-to-dir')){
$('.dropping-to-dir').removeClass('dropping-to-dir');
$('.dir-drop').removeClass('dir-drop');
$('.icon-filetype-folder-drag-accept').removeClass('icon-filetype-folder-drag-accept');
}

if(filerow.attr('data-type') === 'dir'){
$('#app-content').addClass('dir-drop');
filerow.addClass('dropping-to-dir');
filerow.find('.thumbnail').addClass('icon-filetype-folder-drag-accept');
}
});
fileupload.on('fileuploaddragleave fileuploaddrop', function (){
$('#app-content').removeClass('file-drag');
$('.dropping-to-dir').removeClass('dropping-to-dir');
$('.dir-drop').removeClass('dir-drop');
$('.icon-filetype-folder-drag-accept').removeClass('icon-filetype-folder-drag-accept');
});
} else {
// for all browsers that don't support the progress bar
// IE 8 & 9
Expand Down
8 changes: 5 additions & 3 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2514,20 +2514,22 @@
var self = this;

// handle upload events
var fileUploadStart = this.$el.find('#file_upload_start');
var fileUploadStart = this.$el;
var delegatedElement = '#file_upload_start';

// detect the progress bar resize
fileUploadStart.on('resized', this._onResize);

fileUploadStart.on('fileuploaddrop', function(e, data) {
fileUploadStart.on('fileuploaddrop', delegatedElement, function(e, data) {
OC.Upload.log('filelist handle fileuploaddrop', e, data);

if (self.$el.hasClass('hidden')) {
// do not upload to invisible lists
return false;
}

var dropTarget = $(e.originalEvent.target);
var dropTarget = $(e.delegatedEvent.target);

// check if dropped inside this container and not another one
if (dropTarget.length
&& !self.$el.is(dropTarget) // dropped on list directly
Expand Down
Loading