Skip to content

Commit 0c66cec

Browse files
authored
Merge branch 'master' into master
2 parents c3d97f7 + b9c8cec commit 0c66cec

File tree

103 files changed

+2318
-17048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+2318
-17048
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
dist/*
22
demo/*
33
spec/*
4-
src/jq/*.js

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ coverage
66
dist
77
node_modules
88
.vscode
9+
.idea/

Gruntfile.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = function(grunt) {
22
grunt.loadNpmTasks('grunt-sass');
33
grunt.loadNpmTasks('grunt-contrib-cssmin');
44
grunt.loadNpmTasks('grunt-contrib-copy');
5-
grunt.loadNpmTasks('grunt-contrib-uglify');
5+
// grunt.loadNpmTasks('grunt-contrib-uglify');
66
grunt.loadNpmTasks('grunt-eslint');
77
grunt.loadNpmTasks('grunt-contrib-watch');
88
grunt.loadNpmTasks('grunt-protractor-runner');
@@ -45,21 +45,18 @@ module.exports = function(grunt) {
4545
}
4646
}
4747
},
48-
uglify: {
49-
options: {
50-
sourceMap: true,
51-
output: {
52-
comments: 'some'
53-
}
54-
},
55-
dist: {
56-
files: {
57-
'dist/jq/jquery.js': 'src/jq/jquery.js',
58-
'dist/jq/jquery-ui.js': 'src/jq/jquery-ui.js',
59-
'dist/jq/jquery.ui.touch-punch.js': 'src/jq/jquery.ui.touch-punch.js',
60-
}
61-
}
62-
},
48+
// uglify: {
49+
// options: {
50+
// sourceMap: true,
51+
// output: {
52+
// comments: 'some'
53+
// }
54+
// },
55+
// dist: {
56+
// files: {
57+
// }
58+
// }
59+
// },
6360
eslint: {
6461
target: ['*.js', 'src/*.js']
6562
},
@@ -107,6 +104,6 @@ module.exports = function(grunt) {
107104
});
108105

109106
grunt.registerTask('lint', ['eslint']);
110-
grunt.registerTask('default', ['sass', 'cssmin', /*'eslint',*/ 'copy', 'uglify']);
107+
grunt.registerTask('default', ['sass', 'cssmin', /*'eslint',*/ 'copy', /*'uglify'*/]);
111108
grunt.registerTask('e2e-test', ['connect', 'protractor_webdriver', 'protractor']);
112109
};

ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Subject of the issue
22
Describe your issue here.
3-
If unsure if library bug, or questions use slack channel instead: https://gridstackjs.troolee.com/
3+
If unsure if library bug, or questions use slack channel instead: https://gridstackjs.slack.com/
44

55
## Your environment
66
* version of gridstack.js AND if using HTML5 vs Jquery plugin (v3+) - DON'T SAY LATEST as that doesn't mean anything a month/year from now.

README.md

Lines changed: 69 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# gridstack.js
22

33
[![NPM version](https://img.shields.io/npm/v/gridstack.svg)](https://www.npmjs.com/package/gridstack)
4-
[![Dependency Status](https://david-dm.org/gridstack/gridstack.js.svg)](https://david-dm.org/gridstack/gridstack.js)
5-
[![devDependency Status](https://david-dm.org/gridstack/gridstack.js/dev-status.svg)](https://david-dm.org/gridstack/gridstack.js#info=devDependencies)
64
[![Coverage Status](https://coveralls.io/repos/github/gridstack/gridstack.js/badge.svg?branch=develop)](https://coveralls.io/github/gridstack/gridstack.js?branch=develop)
75
[![downloads](https://img.shields.io/npm/dm/gridstack.svg)](https://www.npmjs.com/package/gridstack)
86

@@ -17,21 +15,19 @@ If you find this lib useful, please donate [PayPal](https://www.paypal.me/alaind
1715
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/alaind831)
1816
[![Donate](https://img.shields.io/badge/Donate-Venmo-g.svg)](https://www.venmo.com/adumesny)
1917

20-
Join us on Slack: https://gridstackjs.troolee.com
21-
22-
[![Slack Status](https://gridstackjs.troolee.com/badge.svg)](https://gridstackjs.troolee.com)
18+
Join us on Slack: https://gridstackjs.slack.com
2319

20+
<!-- [![Slack Status](https://gridstackjs.com/badge.svg)](https://gridstackjs.slack.com) -->
2421
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2522
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
2623
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
2724

28-
- [Demo and examples](#demo-and-examples)
25+
- [Demo and API Documentation](#demo-and-api-documentation)
2926
- [Usage](#usage)
3027
- [Install](#install)
3128
- [Include](#include)
3229
- [Basic usage](#basic-usage)
3330
- [Requirements](#requirements)
34-
- [API Documentation](#api-documentation)
3531
- [Extend Library](#extend-library)
3632
- [Extend Engine](#extend-engine)
3733
- [Change grid columns](#change-grid-columns)
@@ -46,17 +42,18 @@ Join us on Slack: https://gridstackjs.troolee.com
4642
- [Migrating to v3](#migrating-to-v3)
4743
- [Migrating to v4](#migrating-to-v4)
4844
- [Migrating to v5](#migrating-to-v5)
45+
- [Migrating to v6](#migrating-to-v6)
46+
- [Migrating to v7](#migrating-to-v7)
4947
- [jQuery Application](#jquery-application)
5048
- [Changes](#changes)
5149
- [The Team](#the-team)
5250

5351
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
5452

5553

56-
# Demo and examples
57-
58-
Please visit http://gridstackjs.com and [these demos](http://gridstackjs.com/demo/)
54+
# Demo and API Documentation
5955

56+
Please visit http://gridstackjs.com and [these demos](http://gridstackjs.com/demo/), and complete [API documentation](https://github.com/gridstack/gridstack.js/tree/master/doc)
6057

6158
# Usage
6259

@@ -76,44 +73,21 @@ ES6 or Typescript
7673
```js
7774
import 'gridstack/dist/gridstack.min.css';
7875
import { GridStack } from 'gridstack';
79-
// THEN to get HTML5 drag&drop
80-
import 'gridstack/dist/h5/gridstack-dd-native';
81-
// OR to get legacy jquery-ui drag&drop (support Mobile touch devices, h5 does not yet)
82-
import 'gridstack/dist/jq/gridstack-dd-jqueryui';
83-
// OR nothing to get static grids (API driven, no user drag&drop)
84-
```
85-
86-
**Note**: `jquery` & `jquery-ui` are imported by name, so you will have to specify their location in your webpack (or equivalent) config file,
87-
which means you can possibly bring your own version
88-
```js
89-
alias: {
90-
'jquery': 'gridstack/dist/jq/jquery.js',
91-
'jquery-ui': 'gridstack/dist/jq/jquery-ui.js',
92-
'jquery.ui': 'gridstack/dist/jq/jquery-ui.js',
93-
'jquery.ui.touch-punch': 'gridstack/dist/jq/jquery.ui.touch-punch.js',
94-
},
9576
```
9677

97-
Alternatively (single combined file) in html
78+
Alternatively (single combined file, notice the -all.js) in html
9879

9980
```html
10081
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
101-
<!-- HTML5 drag&drop (70k) -->
102-
<script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
103-
<!-- OR jquery-ui drag&drop (195k) -->
104-
<script src="node_modules/gridstack/dist/gridstack-jq.js"></script>
105-
<!-- OR static grid (40k) -->
106-
<script src="node_modules/gridstack/dist/gridstack-static.js"></script>
82+
<script src="node_modules/gridstack/dist/gridstack-all.js"></script>
10783
```
10884

109-
**Note**: the API is the same, regardless of the plugin (or lack thereof) so you can switch at any time. The Jquery version will export $ that it bundles and currently the only one to support mobile/touch devices through `jquery.ui.touch-punch` (h5 version is planned). Read more at [migrating to v3](#migrating-to-v3)
110-
111-
**Note2**: IE support was dropped in v2, but restored in v4.4 by an external contributor (I have no interest in testing+supporting obsolete browser so this might break in the future).
85+
**Note**: IE support was dropped in v2, but restored in v4.4 by an external contributor (I have no interest in testing+supporting obsolete browser so this likely will break again in the future).
11286
You can use the es5 files and polyfill (larger) for older browser instead. For example:
11387
```html
11488
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
11589
<script src="node_modules/gridstack/dist/es5/gridstack-poly.js"></script>
116-
<script src="node_modules/gridstack/dist/es5/gridstack-jq.js"></script>
90+
<script src="node_modules/gridstack/dist/es5/gridstack-all.js"></script>
11791
```
11892

11993

@@ -160,16 +134,13 @@ grid.load(serializedData);
160134
GridStack.init();
161135
```
162136

137+
...or see list of all [API and options](https://github.com/gridstack/gridstack.js/tree/master/doc) available.
138+
163139
see [jsfiddle sample](https://jsfiddle.net/adumesny/jqhkry7g) as running example too.
164140

165141
## Requirements
166142

167-
GridStack no longer requires external dependencies as of v1.0.0 (lodash was removed in v0.5.0 and jquery API in v1.0.0). v3.0.0 is a complete HTML5 re-write which removes all jquery dependency (still available for legacy apps). All you need to include now is `gridstack-h5.js` and `gridstack.min.css` (layouts are done using CSS column based %).
168-
169-
## API Documentation
170-
171-
Documentation can be found [here](https://github.com/gridstack/gridstack.js/tree/master/doc).
172-
143+
GridStack no longer requires external dependencies as of v1.0.0 (lodash was removed in v0.5.0 and jquery API in v1.0.0). v3 is a complete HTML5 re-write removing need for jquery (still available for legacy apps). v6 is native mouse and touch event for mobile support, and no longer have jquery-ui version. All you need to include now is `gridstack-all.js` and `gridstack.min.css` (layouts are done using CSS column based %).
173144

174145
## Extend Library
175146

@@ -217,14 +188,15 @@ GridStack makes it very easy if you need [1-12] columns out of the box (default
217188
GridStack.init( {column: N} );
218189
```
219190

220-
2) include `gridstack-extra.css` if **N < 12** (else custom CSS - see next). Without these, things will not render/work correctly.
191+
2) also include `gridstack-extra.css` if **N < 12** (else custom CSS - see next). Without these, things will not render/work correctly.
221192
```html
222-
<link href="node_modules/gridstack/dist/gridstack-extra.css" rel="stylesheet"/>
193+
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
194+
<link href="node_modules/gridstack/dist/gridstack-extra.min.css" rel="stylesheet"/>
223195

224196
<div class="grid-stack">...</div>
225197
```
226198

227-
Note: class `.grid-stack-N` will automatically be added and we include `gridstack-extra.css` which defines CSS for grids with custom [2-11] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
199+
Note: class `.grid-stack-N` will automatically be added and we include `gridstack-extra.min.css` which defines CSS for grids with custom [2-11] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
228200

229201
See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.html) with 6 columns
230202

@@ -266,15 +238,15 @@ Better yet, here is a SASS code snippet which can make life much easier (Thanks
266238
267239
$gridstack-columns: 12;
268240
269-
min-width: math.div(100%, $gridstack-columns);
241+
min-width: 100%/$gridstack-columns;
270242
271243
@for $i from 0 through $gridstack-columns {
272-
&[gs-w='#{$i}'] { width: math.div(100%, $gridstack-columns) * $i; }
273-
&[gs-x='#{$i}'] { left: math.div(100%, $gridstack-columns) * $i; }
274-
&[gs-min-w='#{$i}'] { min-width: math.div(100%, $gridstack-columns) * $i; }
275-
&[gs-max-w='#{$i}'] { max-width: math.div(100%, $gridstack-columns) * $i; }
244+
&[gs-w='#{$i}'] { width: (100% / $gridstack-columns) * $i; }
245+
&[gs-x='#{$i}'] { left: (100% / $gridstack-columns) * $i; }
246+
&[gs-min-w='#{$i}'] { min-width: (100% / $gridstack-columns) * $i; }
247+
&[gs-max-w='#{$i}'] { max-width: (100% / $gridstack-columns) * $i; }
276248
}
277-
}
249+
}
278250
```
279251

280252
you can also use the SASS [src/gridstack-extra.scss](https://github.com/gridstack/gridstack.js/tree/master/src/gridstack-extra.scss) included in NPM package and modify to add more columns.
@@ -303,21 +275,19 @@ GridStack.init({
303275

304276
## Touch devices support
305277

306-
gridstack v3.2 jq version compiles touch support (html5 version does not yet support `touchmove` events. This will be added in a future release), so it works out of the box, no need for anything.
307-
You **used** to need [jQuery UI Touch Punch](https://github.com/RWAP/jquery-ui-touch-punch) to make jQuery UI Draggable/Resizable
308-
work on touch-based devices (now distributed as `dist/jq/jquery.ui.touch-punch.js` for reference).
278+
gridstack v6+ now support mobile out of the box, with the addition of native touch event (along with mouse event) for drag&drop and resize.
279+
Older versions (3.2+) required the jq version with added touch punch, but doesn't work well with nested grids.
309280

310-
311-
This option will be useful:
281+
This option is now the default:
312282

313283
```js
314284
let options = {
315-
alwaysShowResizeHandle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
285+
alwaysShowResizeHandle: 'mobile' // which defaults to /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
316286
};
317287
GridStack.init(options);
318288
```
319289

320-
See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html). If you're still experiencing issues on touch devices please check [#444](https://github.com/gridstack/gridstack.js/issues/444)
290+
See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html).
321291

322292
# gridstack.js for specific frameworks
323293

@@ -465,9 +435,48 @@ make sure to read v4 migration first!
465435
v5 does not have any breaking changes from v4, but a focus on nested grids in h5 mode:
466436
You can now drag in/out of parent into nested child, with new API parameters values. See the release notes.
467437
438+
## Migrating to v6
439+
440+
the API did not really change from v5, but a complete re-write of Drag&Drop to use native `mouseevent` (instead of HTML draggable=true which is buggy on Mac Safari, and doesn't work on mobile devices) and `touchevent` (mobile), and we no longer have jquery ui option (wasn't working well for nested grids, didn't want to maintain legacy lib).
441+
442+
The main difference is you only need to include gridstack.js and get D&D (desktop and mobile) out of the box for the same size as h5 version.
443+
444+
## Migrating to v7
445+
446+
New addition, no API breakage per say. See release notes about creating sub-grids on the fly.
447+
468448
# jQuery Application
469449
470-
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.13.1 minimal drag|drop|resize) + `jquery-ui-touch-punch` (1.0.8 for mobile support) in `gridstack-jq.js`.
450+
This is **old and no longer apply to v6+**. You'll need to use v5.1.1 and before
451+
452+
```js
453+
import 'gridstack/dist/gridstack.min.css';
454+
import { GridStack } from 'gridstack';
455+
import 'gridstack/dist/jq/gridstack-dd-jqueryui';
456+
```
457+
**Note**: `jquery` & `jquery-ui` are imported by name, so you will have to specify their location in your webpack (or equivalent) config file,
458+
which means you can possibly bring your own version
459+
```js
460+
alias: {
461+
'jquery': 'gridstack/dist/jq/jquery.js',
462+
'jquery-ui': 'gridstack/dist/jq/jquery-ui.js',
463+
'jquery.ui': 'gridstack/dist/jq/jquery-ui.js',
464+
'jquery.ui.touch-punch': 'gridstack/dist/jq/jquery.ui.touch-punch.js',
465+
},
466+
```
467+
Alternatively (single combined file) in html
468+
469+
```html
470+
<link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
471+
<!-- HTML5 drag&drop (70k) -->
472+
<script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
473+
<!-- OR jquery-ui drag&drop (195k) -->
474+
<script src="node_modules/gridstack/dist/gridstack-jq.js"></script>
475+
<!-- OR static grid (40k) -->
476+
<script src="node_modules/gridstack/dist/gridstack-static.js"></script>
477+
```
478+
479+
We 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.13.1 minimal drag|drop|resize) + `jquery-ui-touch-punch` (1.0.8 for mobile support) in `gridstack-jq.js`.
471480
472481
**NOTE: in v4, v3**: we ES6 module import jquery & jquery-ui by name, so you 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.
473482

demo/angular-ngFor.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
/**
22
* Example using Angular ngFor to loop through items and create DOM items
33
*/
4-
import {
5-
Component,
6-
AfterViewInit,
7-
Input,
8-
ViewChildren,
9-
QueryList,
10-
} from "@angular/core";
114

12-
import { GridStack, GridStackWidget } from "gridstack";
13-
import "gridstack/dist/h5/gridstack-dd-native";
5+
import { Component, AfterViewInit, Input, ViewChildren, QueryList } from "@angular/core";
146
import { Subject, zip } from "rxjs";
157

8+
import { GridStack, GridStackWidget } from 'gridstack';
9+
1610
@Component({
1711
selector: "app-angular-ng-for-test",
1812
template: `
19-
<button (click)="add()">add item</button
20-
><button (click)="delete()">remove item</button
21-
><button (click)="change()">modify item</button>
13+
<button (click)="add()">add item</button>
14+
<button (click)="delete()">remove item</button>
15+
<button (click)="change()">modify item</button>
2216
<div class="grid-stack">
2317
<!-- using angular templating to create DOM, otherwise an easier way is to simply call grid.load(items) -->
2418
<div
@@ -40,18 +34,9 @@ import { Subject, zip } from "rxjs";
4034
// !!!IMPORTANT!!! Import this through your styles.scss or angular.json! This is just for demo purposes
4135
:host {
4236
::ng-deep {
43-
@import "gridstack/dist/gridstack.min";
37+
@import "demo";
4438
}
4539
}
46-
.grid-stack {
47-
margin: 15px;
48-
background-color: #d66666;
49-
min-height: calc(100vh - 50px);
50-
}
51-
52-
.grid-stack-item {
53-
border: 1px solid #d1d1d1;
54-
}
5540
`,
5641
],
5742
})

demo/angular.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import { Component, OnInit } from '@angular/core';
55

66
import { GridStack, GridStackWidget } from 'gridstack';
7-
import 'gridstack/dist/h5/gridstack-dd-native';
87

98
@Component({
109
selector: 'app-angular-test',

demo/anijs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<link rel="stylesheet" href="https://anijs.github.io/lib/anicollection/anicollection.css" />
1010
<link rel="stylesheet" href="demo.css"/>
1111

12-
<script src="../dist/gridstack-h5.js"></script>
12+
<script src="../dist/gridstack-all.js"></script>
1313
<script src="https://cdnjs.cloudflare.com/ajax/libs/AniJS/0.9.3/anijs.js"></script>
1414
</head>
1515
<body>

demo/canvasJS.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>CanvasJS grid demo</title>
55

66
<link rel="stylesheet" href="demo.css"/>
7-
<script src="../dist/gridstack-jq.js"></script>
7+
<script src="https://cdn.jsdelivr.net/npm/gridstack@5.1.1/dist/gridstack-jq.js"></script>
88
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
99

1010
<style type="text/css">

demo/cell-height.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<title>cell height demo</title>
88

99
<link rel="stylesheet" href="demo.css"/>
10-
<script src="../dist/gridstack-h5.js"></script>
10+
<script src="../dist/gridstack-all.js"></script>
1111
<style type="text/css">
1212
.container {
1313
background-color: lightblue;

0 commit comments

Comments
 (0)