Skip to content

Commit 6b63244

Browse files
authored
Merge pull request #2290 from adumesny/master
removed `GridStackOptions.dragInOptions` since `setupDragIn()`has it …
2 parents 5017de4 + 26ea3d6 commit 6b63244

12 files changed

+15
-45
lines changed

demo/static.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ <h1>Static vs can move/drag Demo</h1>
3636
cellHeight: 70,
3737
acceptWidgets: true,
3838
removable: true,
39-
// old way, use global setupDragIn() instead
40-
// dragIn: '.sidebar .grid-stack-item', // add draggable to class
41-
// dragInOptions: { appendTo: 'body', helper: 'clone' },
4239
staticGrid: true
4340
});
4441
addEvents(grid);

demo/two.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ <h1>Two grids demo</h1>
5959
cellHeight: 70,
6060
disableOneColumnMode: true,
6161
float: true,
62-
// dragIn: '.sidebar .grid-stack-item', // add draggable to class
63-
// dragInOptions: { appendTo: 'body', helper: 'clone' }, // clone
6462
removable: '.trash', // true or drag-out delete class
6563
// itemClass: 'with-lines', // test a custom additional class #2110
6664
acceptWidgets: function(el) { return true } // function example, but can also be: true | false | '.someClass' value

demo/web2.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ <h1>Advanced Demo</h1>
6161
let grid = GridStack.init({
6262
cellHeight: 70,
6363
acceptWidgets: true,
64-
dragIn: '.newWidget', // class that can be dragged from outside
65-
dragInOptions: { appendTo: 'body', helper: 'clone' }, // clone or can be your function
6664
removable: '#trash', // drag-out delete class
6765
});
66+
GridStack.setupDragIn('.newWidget', { appendTo: 'body', helper: 'clone' });
6867

6968
let items = [
7069
{x: 0, y: 0, w: 4, h: 2, content: '1'},

demo/website.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ <h1>Used by</h1>
371371
var advGrid = GridStack.init({
372372
margin: 5,
373373
acceptWidgets: true,
374-
dragIn: '.newWidget', // class that can be dragged from outside
375-
dragInOptions: { appendTo: 'body', helper: 'clone' },
376374
removable: '#trash',
377375
removeTimeout: 100
378-
}, '#advanced-grid');
379-
advGrid.load(advanced);
376+
}, '#advanced-grid')
377+
.load(advanced);
380378

379+
GridStack.setupDragIn('.newWidget', { appendTo: 'body', helper: 'clone' });
380+
381381
$('#search').on('submit', function (event) {
382382
event.preventDefault();
383383
var searchTerm = $('#searchTerm').val();

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ Change log
8888
* feat: [#2275](https://github.com/gridstack/gridstack.js/issues/2275) `setupDragIn()` now can take an array or elements (in addition to selector string) and optional parent root (for shadow DOM support)
8989
* fix: [#2234](https://github.com/gridstack/gridstack.js/issues/2234) `Utils.getElements('1')` (called by removeWidget() and others) now checks for digit 'selector' (becomes an id).
9090
* fix: [#2213](https://github.com/gridstack/gridstack.js/issues/2213) `destroy()` now removes event handlers too
91+
* break: (meant to be in v8) removed `GridStackOptions.dragInOptions` since `setupDragIn()`has it replaced since 4.0
9192

9293
## 8.0.0 (2023-04-29)
9394
* package is now ES2020 (TS exported files), webpack all.js still umd (better than commonjs for browsers), still have es5/ files unchanged (for now)

doc/README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,6 @@ gridstack.js API
9696
- `disableDrag` - disallows dragging of widgets (default: `false`).
9797
- `disableOneColumnMode` - Prevents the grid container from being displayed in "one column mode", even when the container's width is smaller than the value of oneColumnSize (default value of oneColumnSize is 768px). By default, this option is set to "false".
9898
- `disableResize` - disallows resizing of widgets (default: `false`).
99-
- `dragIn` - specify the class of items that can be dragged into grids
100-
* example: `dragIn: '.newWidget'`.
101-
* **Note**: if you have multiple grids, it's best to call `GridStack.setupDragIn()` with same params as it only need to be done once.
102-
- `dragInOptions` - options for items that can be dragged into grids - see `DDDragInOpt`
103-
* example `dragInOptions: { appendTo: 'body', helper: 'clone', handle: '.grid-stack-item-content' }`
104-
* **Note**: if you have multiple grids, it's best to call `GridStack.setupDragIn()` with same params as it only need to be done once.
105-
* **Note2**: instead of 'clone' you can also pass your own function (get passed the event).
10699
- `draggable` - allows to override draggable options - see `DDDragOpt`. (default: `{handle: '.grid-stack-item-content', appendTo: 'body', scroll: true}`)
107100
- `dragOut` to let user drag nested grid items out of a parent or not (default false) See [example](http://gridstackjs.com/demo/nested.html)
108101
- `engineClass` - the type of engine to create (so you can subclass) default to GridStackEngine
@@ -330,15 +323,15 @@ grids.forEach(...)
330323
* @param opt grids options used to initialize the grid, and list of children
331324
* see [nested.html](https://github.com/gridstack/gridstack.js/tree/master/demo/nested.html) demo
332325

333-
### `setupDragIn(dragIn?: string, dragInOptions?: DDDragInOpt)`
326+
### `setupDragIn(dragIn?: string | HTMLElement[], dragInOptions?: DDDragInOpt, root = document)`
334327

335328
* call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
336329
Called during `GridStack.init()` as options, but can also be called directly (last param are cached) in case the toolbar is dynamically create and needs to change later.
337-
* @param dragIn string selector (ex: `'.sidebar .grid-stack-item'`)
330+
* @param dragIn string selector (ex: `'.sidebar .grid-stack-item'`) or list of dom elements
338331
* @param dragInOptions options - see `DDDragInOpt`. (default: `{handle: '.grid-stack-item-content', appendTo: 'body'}`
332+
* @param root - default to document (for shadow dom support)
339333
but you will probably also want `helper: 'clone'` or your own callback function).
340334

341-
342335
### `GridStack.registerEngine(engineClass: typeof GridStackEngine)`
343336

344337
* call to specify global custom engine subclass - see instead `GridStackOptions.engineClass` if you only need to replace just one instance.

spec/e2e/html/1143_nested_acceptWidget_types.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ <h3>show dragging into sub grid</h3>
4949
let grid = GridStack.init({ acceptWidgets: '.otherWidgetType' }, '.grid-stack.outer');
5050
let gridNest = GridStack.init({
5151
acceptWidgets: '.newWidget',
52-
dragIn: '.newWidget', // class that can be dragged from outside
53-
dragInOptions: { appendTo: 'body', helper: 'clone' }, // clone or can be your function
5452
itemClass: 'sub',
5553
}, '.grid-stack.nested');
5654
gridNest.load([
@@ -61,6 +59,8 @@ <h3>show dragging into sub grid</h3>
6159
{x:0, y:1, w:3, content:'4'},
6260
{x:3, y:1, w:3, content:'5'},
6361
]);
62+
63+
GridStack.setupDragIn('.newWidget', { appendTo: 'body', helper: 'clone' });
6464

6565
grid.on('added removed change', function(e, items) {
6666
let str = '';

spec/e2e/html/1419-maxrow1-cant-insert.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@
6161
let options = {
6262
row: 1,
6363
cellHeight: 120,
64-
dragIn: '.sidebar .grid-stack-item', // class that can be dragged from outside
65-
dragInOptions: { appendTo: 'body', helper: 'clone' }, // clone or can be your function
6664
acceptWidgets: true
6765
};
6866
let grid = GridStack.init(options);
67+
GridStack.setupDragIn('.sidebar .grid-stack-item', { appendTo: 'body', helper: 'clone' });
6968
addEvents(grid);
7069
grid.addWidget({x: 0});
7170
</script>

spec/e2e/html/1571_drop_onto_full.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ <h1>drop onto full</h1>
8686
cellHeight: 70,
8787
disableOneColumnMode: true,
8888
float: false,
89-
dragIn: '.sidebar .grid-stack-item', // class that can be dragged from outside
90-
dragInOptions: { appendTo: 'body', helper: 'clone' }, // clone or can be your function
9189
removable: '.trash', // drag-out delete class
9290
acceptWidgets: function(el) { return true; } // function example, else can be simple: true | false | '.someClass' value
9391
};
92+
GridStack.setupDragIn('.sidebar .grid-stack-item', { appendTo: 'body', helper: 'clone' });
93+
9494
let grids = GridStack.initAll(options);
9595
grids[0].load([{x: 4, y: 0, w: 1, h: 1}])
9696
grids[1].load([{x: 0, y: 0, w: 6, h: 1}])

spec/e2e/html/1704_scroll_bar.html

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,12 @@
3636
<script type="text/javascript">
3737
let grids = GridStack.initAll({
3838
acceptWidgets: true,
39-
dragIn: ".newWidget", // class that can be dragged from outside
40-
dragOut: false,
41-
dragInOptions: {
42-
appendTo: "body",
43-
helper: "clone"
44-
},
4539
removable: "#trash", // drag-out delete class
4640
removeTimeout: 100,
4741
float: true,
4842
row: 3,
4943
});
44+
GridStack.setupDragIn('.newWidget', { appendTo: 'body', helper: 'clone' });
5045
// let items = [{x: 0, y: 0, content: "0"}];
5146
// grids.forEach(grid => grid.load(items));
5247
</script>

0 commit comments

Comments
 (0)