Skip to content

Commit a5e277d

Browse files
authored
Merge pull request #1714 from adumesny/master
JQ version and ES6
2 parents f7a9070 + 13ab5ff commit a5e277d

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

README.md

+19-5
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,27 @@ import 'gridstack/dist/h5/gridstack-dd-native';
8080
import 'gridstack/dist/jq/gridstack-dd-jqueryui';
8181
// OR nothing to get static grids (API driven, no user drag&drop)
8282
```
83+
84+
**Note**: `jquery` & `jquery-ui` are imported by name, so you will have to specify their location in your webpack (or equivalent) config file,
85+
which means you can possibly bring your own version
86+
```js
87+
alias: {
88+
'jquery': 'gridstack/dist/jq/jquery.js',
89+
'jquery-ui': 'gridstack/dist/jq/jquery-ui.js',
90+
'jquery.ui': 'gridstack/dist/jq/jquery-ui.js',
91+
'jquery.ui.touch-punch': 'gridstack/dist/jq/jquery.ui.touch-punch.js',
92+
},
93+
```
94+
8395
Alternatively in html
8496

8597
```html
8698
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
87-
<!-- HTML5 drag&drop (64k) -->
99+
<!-- HTML5 drag&drop (68k) -->
88100
<script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
89-
<!-- OR jquery-ui drag&drop (189k) -->
101+
<!-- OR jquery-ui drag&drop (193k) -->
90102
<script src="node_modules/gridstack/dist/gridstack-jq.js"></script>
91-
<!-- OR static grid (36k) -->
103+
<!-- OR static grid (38k) -->
92104
<script src="node_modules/gridstack/dist/gridstack-static.js"></script>
93105
```
94106

@@ -417,9 +429,11 @@ v4 is a complete re-write of the collision and drag in/out heuristics to fix som
417429
418430
# jQuery Application
419431
420-
We now have a native HTML5 drag'n'drop through the plugin system (default), but the jquery-ui version can be used instead. It will bundle `jquery` (3.5.1) + `jquery-ui` (1.12.1 minimal drag|drop|resize) + `jquery-ui-touch-punch` (1.0.8 for mobile support) in `gridstack-jq.js`. IFF you want to use gridstack-jq instead and your app needs to bring your own JQ version (only possible in 1.x), you should **instead** use v1.x and include `gridstack-poly.min.js` (optional IE support) + `gridstack.min.js` + `gridstack.jQueryUI.min.js` after you import your JQ libs. But note that there are issue with jQuery and ES6 import (see [1306](https://github.com/gridstack/gridstack.js/issues/1306)).
432+
We now have a native HTML5 drag'n'drop through the plugin system (default), but the jquery-ui version can be used instead. It will bundle `jquery` (3.5.1) + `jquery-ui` (1.12.1 minimal drag|drop|resize) + `jquery-ui-touch-punch` (1.0.8 for mobile support) in `gridstack-jq.js`.
433+
434+
**NOTE: in v1.x** IFF you want to use gridstack-jq instead and your app needs to bring your own JQ version, you should **instead** include `gridstack-poly.min.js` (optional IE support) + `gridstack.min.js` + `gridstack.jQueryUI.min.js` after you import your JQ libs. But note that there are issue with jQuery and ES6 import (see [1306](https://github.com/gridstack/gridstack.js/issues/1306)).
421435
422-
**NOTE**: v2.x / v3.x does not currently support importing GridStack Drag&Drop without also including our jquery + jquery-ui. Still trying to figure how to make that bundle possible. You will have to use 1.x for now, or use the HTML5 version (no jq).
436+
**NOTE 2: in v4.0.4+**: (not tested in v2.x / v3.x) for [1709](https://github.com/gridstack/gridstack.js/issues/1709) we now import jquery & jquery-ui by name, so ES6 module import need to specify location of those .js files, which means you might be able to bring your own version as well. See the include instructions.
423437
424438
As for events, you can still use `$(".grid-stack").on(...)` for the version that uses jquery-ui for things we don't support.
425439

doc/CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Change log
5858
when dragging an item at the bottom below others to make it easier to insert below.
5959
- fix [#1687](https://github.com/gridstack/gridstack.js/issues/1687) more fix for drag between 2 grids with `row / maxRow` broken in 4.x
6060
- fix export symbols .d.ts for `gridstack-h5.js | gridstack-jq.js | gridstack-static.js`
61+
- fix [#1709](https://github.com/gridstack/gridstack.js/issues/1709) correct info for using JQ version and ES6 (tested in Angular app)
6162

6263
## 4.0.3 (2021-3-28)
6364

src/jq/gridstack-dd-jqueryui.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ import { GridItemHTMLElement, DDDragInOpt } from '../types';
77
// export jq symbols see
88
// https://stackoverflow.com/questions/35345760/importing-jqueryui-with-typescript-and-requirejs
99
// https://stackoverflow.com/questions/33998262/jquery-ui-and-webpack-how-to-manage-it-into-module
10-
// TODO: let user bring their own jq or jq-ui version
11-
import * as $ from './jquery'; // compile this in... having issues TS/ES6 app would include instead
10+
//
11+
// Note: user should be able to bring their own by changing their webpack aliases like
12+
// alias: {
13+
// 'jquery': 'gridstack/dist/jq/jquery.js',
14+
// 'jquery-ui': 'gridstack/dist/jq/jquery-ui.js',
15+
// 'jquery.ui': 'gridstack/dist/jq/jquery-ui.js',
16+
// 'jquery.ui.touch-punch': 'gridstack/dist/jq/jquery.ui.touch-punch.js',
17+
// },
18+
import * as $ from 'jquery'; // compile this in... having issues TS/ES6 app would include instead
1219
export { $ };
13-
import './jquery-ui';
14-
import './jquery.ui.touch-punch'; // include for touch mobile devices
20+
import 'jquery-ui';
21+
import 'jquery.ui.touch-punch'; // include for touch mobile devices
1522

1623
// export our base class (what user should use) and all associated types
1724
export * from '../gridstack-dd';

webpack.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = {
2424
'jquery': '/src/jq/jquery.js',
2525
'jquery-ui': '/src/jq/jquery-ui.js',
2626
'jquery.ui': '/src/jq/jquery-ui.js',
27+
'jquery.ui.touch-punch' : '/src/jq/jquery.ui.touch-punch',
2728
}
2829
},
2930
output: {

0 commit comments

Comments
 (0)