Skip to content

Commit 96355a9

Browse files
author
Vlad
committed
made the "trashzone" configurable through the "removableOptions". All the jq ui options should be supported now
added an "inTrashZone" flag to fix a problem when there is an overlapping between the grid and the "trashzone" PS I'm not very experienced in github / jq plugins, hope I didn't break anything... if accepted the information about "removableOptions" parameter should be added to the readme doc
1 parent fa4f2d0 commit 96355a9

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/gridstack.jQueryUI.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,7 @@
7777

7878
JQueryUIGridStackDragDropPlugin.prototype.droppable = function(el, opts) {
7979
el = $(el);
80-
if (opts === 'disable' || opts === 'enable') {
81-
el.droppable(opts);
82-
} else {
83-
el.droppable({
84-
accept: opts.accept
85-
});
86-
}
80+
el.droppable(opts);
8781
return this;
8882
};
8983

src/gridstack.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,9 @@
603603
disableResize: opts.disableResize || false,
604604
rtl: 'auto',
605605
removable: false,
606+
removableOptions: _.defaults(opts.removableOptions || {}, {
607+
accept: '.' + opts.itemClass
608+
}),
606609
removeTimeout: 2000,
607610
verticalMarginUnit: 'px',
608611
cellHeightUnit: 'px',
@@ -750,9 +753,7 @@
750753
if (!self.opts.staticGrid && typeof self.opts.removable === 'string') {
751754
var trashZone = $(self.opts.removable);
752755
if (!this.dd.isDroppable(trashZone)) {
753-
this.dd.droppable(trashZone, {
754-
accept: '.' + self.opts.itemClass
755-
});
756+
this.dd.droppable(trashZone, self.opts.removableOptions);
756757
}
757758
this.dd
758759
.on(trashZone, 'dropover', function(event, ui) {
@@ -761,6 +762,7 @@
761762
if (node._grid !== self) {
762763
return;
763764
}
765+
el.data('inTrashZone', true);
764766
self._setupRemovingTimeout(el);
765767
})
766768
.on(trashZone, 'dropout', function(event, ui) {
@@ -769,6 +771,7 @@
769771
if (node._grid !== self) {
770772
return;
771773
}
774+
el.data('inTrashZone', false);
772775
self._clearRemovingTimeout(el);
773776
});
774777
}
@@ -1071,7 +1074,7 @@
10711074
}
10721075

10731076
if (event.type == 'drag') {
1074-
if (x < 0 || x >= self.grid.width || y < 0 || (!self.grid.float && y > self.grid.getGridHeight())) {
1077+
if (el.data('inTrashZone') || x < 0 || x >= self.grid.width || y < 0 || (!self.grid.float && y > self.grid.getGridHeight())) {
10751078
if (!node._temporaryRemoved) {
10761079
if (self.opts.removable === true) {
10771080
self._setupRemovingTimeout(el);

0 commit comments

Comments
 (0)