Merge pull request #22341 from owncloud/pellaeon-pr-breadcrumb-filelist-overlap-drop

Handle case when breadcrumb and filelist item overlap and both receive a drop
This commit is contained in:
Vincent Petry 2016-05-13 17:12:36 +02:00
commit 88da2966b4
2 changed files with 19 additions and 0 deletions

View File

@ -39,6 +39,8 @@
} }
if (options.onDrop) { if (options.onDrop) {
this.onDrop = options.onDrop; this.onDrop = options.onDrop;
this.onOver = options.onOver;
this.onOut = options.onOut;
} }
if (options.getCrumbUrl) { if (options.getCrumbUrl) {
this.getCrumbUrl = options.getCrumbUrl; this.getCrumbUrl = options.getCrumbUrl;
@ -60,6 +62,8 @@
breadcrumbs: [], breadcrumbs: [],
onClick: null, onClick: null,
onDrop: null, onDrop: null,
onOver: null,
onOut: null,
/** /**
* Sets the directory to be displayed as breadcrumb. * Sets the directory to be displayed as breadcrumb.
@ -127,6 +131,8 @@
if (this.onDrop) { if (this.onDrop) {
this.$el.find('.crumb:not(.last)').droppable({ this.$el.find('.crumb:not(.last)').droppable({
drop: this.onDrop, drop: this.onDrop,
over: this.onOver,
out: this.onOut,
tolerance: 'pointer' tolerance: 'pointer'
}); });
} }

View File

@ -271,6 +271,12 @@
// if dropping on folders is allowed, then also allow on breadcrumbs // if dropping on folders is allowed, then also allow on breadcrumbs
if (this._folderDropOptions) { if (this._folderDropOptions) {
breadcrumbOptions.onDrop = _.bind(this._onDropOnBreadCrumb, this); breadcrumbOptions.onDrop = _.bind(this._onDropOnBreadCrumb, this);
breadcrumbOptions.onOver = function() {
self.$el.find('td.filename.ui-droppable').droppable('disable');
}
breadcrumbOptions.onOut = function() {
self.$el.find('td.filename.ui-droppable').droppable('enable');
}
} }
this.breadcrumb = new OCA.Files.BreadCrumb(breadcrumbOptions); this.breadcrumb = new OCA.Files.BreadCrumb(breadcrumbOptions);
@ -785,6 +791,13 @@
} }
this.move(_.pluck(files, 'name'), targetPath); this.move(_.pluck(files, 'name'), targetPath);
// re-enable td elements to be droppable
// sometimes the filename drop handler is still called after re-enable,
// it seems that waiting for a short time before re-enabling solves the problem
setTimeout(function() {
self.$el.find('td.filename.ui-droppable').droppable('enable');
}, 10);
}, },
/** /**