Commit 7ac8b2d8 authored by radiolips's avatar radiolips Committed by GitHub
Browse files

Merge pull request #675 from vigor-vlad/trashzone_improvement

"trashzone" improvement
parents 4dd0a897 96355a94
...@@ -77,13 +77,7 @@ ...@@ -77,13 +77,7 @@
JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) { JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) {
el = $(el); el = $(el);
if (opts === 'disable' || opts === 'enable') { el.droppable(opts);
el.droppable(opts);
} else {
el.droppable({
accept: opts.accept
});
}
return this; return this;
}; };
......
...@@ -623,6 +623,9 @@ ...@@ -623,6 +623,9 @@
disableResize: opts.disableResize || false, disableResize: opts.disableResize || false,
rtl: 'auto', rtl: 'auto',
removable: false, removable: false,
removableOptions: _.defaults(opts.removableOptions || {}, {
accept: '.' + opts.itemClass
}),
removeTimeout: 2000, removeTimeout: 2000,
verticalMarginUnit: 'px', verticalMarginUnit: 'px',
cellHeightUnit: 'px', cellHeightUnit: 'px',
...@@ -770,9 +773,7 @@ ...@@ -770,9 +773,7 @@
if (!self.opts.staticGrid && typeof self.opts.removable === 'string') { if (!self.opts.staticGrid && typeof self.opts.removable === 'string') {
var trashZone = $(self.opts.removable); var trashZone = $(self.opts.removable);
if (!this.dd.isDroppable(trashZone)) { if (!this.dd.isDroppable(trashZone)) {
this.dd.droppable(trashZone, { this.dd.droppable(trashZone, self.opts.removableOptions);
accept: '.' + self.opts.itemClass
});
} }
this.dd this.dd
.on(trashZone, 'dropover', function(event, ui) { .on(trashZone, 'dropover', function(event, ui) {
...@@ -781,6 +782,7 @@ ...@@ -781,6 +782,7 @@
if (node._grid !== self) { if (node._grid !== self) {
return; return;
} }
el.data('inTrashZone', true);
self._setupRemovingTimeout(el); self._setupRemovingTimeout(el);
}) })
.on(trashZone, 'dropout', function(event, ui) { .on(trashZone, 'dropout', function(event, ui) {
...@@ -789,6 +791,7 @@ ...@@ -789,6 +791,7 @@
if (node._grid !== self) { if (node._grid !== self) {
return; return;
} }
el.data('inTrashZone', false);
self._clearRemovingTimeout(el); self._clearRemovingTimeout(el);
}); });
} }
...@@ -1097,7 +1100,7 @@ ...@@ -1097,7 +1100,7 @@
} }
if (event.type == 'drag') { if (event.type == 'drag') {
if (x < 0 || x >= self.grid.width || y < 0 || (!self.grid.float && y > self.grid.getGridHeight())) { if (el.data('inTrashZone') || x < 0 || x >= self.grid.width || y < 0 || (!self.grid.float && y > self.grid.getGridHeight())) {
if (!node._temporaryRemoved) { if (!node._temporaryRemoved) {
if (self.opts.removable === true) { if (self.opts.removable === true) {
self._setupRemovingTimeout(el); self._setupRemovingTimeout(el);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment