Skip to content

Commit d647399

Browse files
author
Alain Dumesny
authored
Merge branch 'develop' into bugfix/1015
2 parents 6fcb05a + c5bb259 commit d647399

34 files changed

+5635
-1009
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
dist/*.js
22
demo/*
33
spec/*
4+
src/jquery-ui.js
5+
src/jquery-ui.min.js

Gruntfile.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ module.exports = function(grunt) {
3838
'dist/gridstack.js': ['src/gridstack.js'],
3939
'dist/gridstack.d.ts': ['src/gridstack.d.ts'],
4040
'dist/gridstack.jQueryUI.js': ['src/gridstack.jQueryUI.js'],
41+
'dist/gridstack.poly.js': ['src/gridstack.poly.js'],
42+
'dist/jquery-ui.js': ['src/jquery-ui.js'],
43+
'dist/jquery-ui.min.js': ['src/jquery-ui.min.js'],
4144
}
4245
}
4346
},
@@ -52,7 +55,8 @@ module.exports = function(grunt) {
5255
files: {
5356
'dist/gridstack.min.js': ['src/gridstack.js'],
5457
'dist/gridstack.jQueryUI.min.js': ['src/gridstack.jQueryUI.js'],
55-
'dist/gridstack.all.js': ['src/gridstack.js', 'src/gridstack.jQueryUI.js']
58+
'dist/gridstack.poly.min.js': ['src/gridstack.poly.js'],
59+
'dist/gridstack.all.js': ['src/gridstack.poly.js', 'src/gridstack.js', 'src/jquery-ui.js', 'src/gridstack.jQueryUI.js']
5660
}
5761
}
5862
},

README.md

Lines changed: 62 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com
1919
- [Demo and examples](#demo-and-examples)
2020
- [Usage](#usage)
2121
- [Requirements](#requirements)
22-
- [Using gridstack.js with jQuery UI](#using-gridstackjs-with-jquery-ui)
2322
- [Install](#install)
2423
- [Basic usage](#basic-usage)
2524
- [Migrating to v0.3.0](#migrating-to-v030)
2625
- [API Documentation](#api-documentation)
2726
- [Touch devices support](#touch-devices-support)
2827
- [gridstack.js for specific frameworks](#gridstackjs-for-specific-frameworks)
29-
- [Change grid width](#change-grid-width)
30-
- [Extra CSS](#extra-css)
31-
- [Different grid widths](#different-grid-widths)
28+
- [Change grid columns](#change-grid-columns)
29+
- [Custom columns CSS](#custom-columns-css)
3230
- [Override resizable/draggable options](#override-resizabledraggable-options)
33-
- [IE8 support](#ie8-support)
3431
- [Changes](#changes)
3532
- [The Team](#the-team)
3633

@@ -48,36 +45,43 @@ Usage
4845

4946
## Requirements
5047

51-
* [jQuery](http://jquery.com) (>= 3.1.0)
52-
* `Array.prototype.find` for IE and older browsers ([core.js](https://github.com/zloirock/core-js#ecmascript-6-array) allows to include specific polyfills)
48+
* [jQuery](http://jquery.com) (>= 1.8)
49+
* `Array.prototype.find`, and `Number.isNaN()` for IE and older browsers.
50+
* Note: as of v0.5.4 We supply a separate `gridstack.poly.js` for that
51+
(part of `gridstack.all.js`) or you can look at other pollyfills
52+
([core.js](https://github.com/zloirock/core-js#ecmascript-6-array) and [mozilla.org](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)).
5353

54-
#### Using gridstack.js with jQuery UI
54+
Using gridstack.js with jQuery UI
5555

56-
* [jQuery UI](http://jqueryui.com) (>= 1.12.0). Minimum required components: Core, Widget, Mouse, Draggable, Resizable
56+
* [jQuery UI](http://jqueryui.com) (>= 1.12.0). Minimum required components: Draggable, Droppable, Resizable (Widget, Mouse, core).
57+
* Note: as of v0.5.4 we include this subset as `jquery-ui.js` (and min.js) which is part of `gridstack.all.js`. If you wish to bring your own lib, include the individual gridstack parts instead of all.js
5758
* (Optional) [jquery-ui-touch-punch](https://github.com/furf/jquery-ui-touch-punch) for touch-based devices support
5859

5960
## Install
6061

61-
* In the browser:
62+
* Using CDN (minimized):
6263

6364
```html
64-
<link rel="stylesheet" href="gridstack.css" />
65-
<script src="gridstack.js"></script>
66-
<script src="gridstack.jQueryUI.js"></script>
65+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@latest/dist/gridstack.min.css" />
66+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/gridstack@latest/dist/gridstack.all.js"></script>
6767
```
6868

69-
* Using CDN:
69+
* Using CDN (debug):
7070

7171
```html
72-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@0.5.2/dist/gridstack.min.css" />
73-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/gridstack@0.5.2/dist/gridstack.min.js"></script>
74-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/gridstack@0.5.2/dist/gridstack.jQueryUI.min.js"></script>
72+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@latest/dist/gridstack.css" />
73+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/gridstack@latest/dist/gridstack.js"></script>
74+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/gridstack@latest/dist/jquery-ui.js"></script>
75+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/gridstack@latest/dist/gridstack.jQueryUI.js"></script>
7576
```
7677

77-
* Using bower:
78+
* or local:
7879

79-
```bash
80-
$ bower install gridstack
80+
```html
81+
<link rel="stylesheet" href="gridstack.css" />
82+
<script src="gridstack.js"></script>
83+
<script src="jquery-ui.js"></script>
84+
<script src="gridstack.jQueryUI.js"></script>
8185
```
8286

8387
* Using npm:
@@ -88,21 +92,23 @@ $ bower install gridstack
8892
$ npm install gridstack
8993
```
9094

91-
You can download source and build and use `dist` directory as well for latest non published code.
95+
* Using bower:
96+
97+
```bash
98+
$ bower install gridstack
99+
```
100+
101+
You can also download source and build and use `dist` directory as well for latest non published code.
92102

93103
## Basic usage
94104

95105
```html
96106
<div class="grid-stack">
97-
<div class="grid-stack-item"
98-
data-gs-x="0" data-gs-y="0"
99-
data-gs-width="4" data-gs-height="2">
100-
<div class="grid-stack-item-content"></div>
107+
<div class="grid-stack-item">
108+
<div class="grid-stack-item-content">Item 1</div>
101109
</div>
102-
<div class="grid-stack-item"
103-
data-gs-x="4" data-gs-y="0"
104-
data-gs-width="4" data-gs-height="4">
105-
<div class="grid-stack-item-content"></div>
110+
<div class="grid-stack-item" data-gs-width="2">
111+
<div class="grid-stack-item-content">Item 2 wider</div>
106112
</div>
107113
</div>
108114

@@ -174,10 +180,31 @@ If you're still experiencing issues on touch devices please check [#444](https:/
174180
- ember: [gridstack-ember](https://github.com/yahoo/ember-gridstack)
175181

176182

177-
## Change grid width
183+
## Change grid columns
184+
185+
GridStack makes it very easy if you need [1-12] columns out of the box (default is 12), but you always need **2 things** if you need to customize this:
186+
187+
1) Change the `column` grid option when creating a grid to your number N
188+
```js
189+
$('.grid-stack').gridstack( {column: N} );
190+
```
191+
192+
2) include `gridstack-extra.css` if **N < 12** (else custom CSS - see next). Without these, things will not render/work correctly.
193+
```html
194+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/gridstack@latest/dist/gridstack-extra.css"/>
178195

179-
To change grid width (columns count), to addition to `width` option, CSS rules
180-
for `.grid-stack-item[data-gs-width="X"]` and `.grid-stack-item[data-gs-x="X"]` have to be changed accordingly.
196+
<div class="grid-stack grid-stack-N">...</div>
197+
```
198+
199+
Note `grid-stack-N` class was added, and extra CSS.
200+
201+
`gridstack-extra.css` (and `gridstack-extra.min.css`) defines CSS for grids with custom [1-12] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
202+
203+
See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.html) with 6 columns
204+
205+
## Custom columns CSS
206+
207+
If you need > 12 columns or want to generate the CSS manually (else see above) you will need to generate CSS rules for `.grid-stack-item[data-gs-width="X"]` and `.grid-stack-item[data-gs-x="X"]`.
181208

182209
For instance for 3-column grid you need to rewrite CSS to be:
183210

@@ -205,13 +232,15 @@ For 4-column grid it should be:
205232

206233
and so on.
207234

208-
Here is a SASS code snippet which can make life easier (Thanks to @ascendantofrain, [#81](https://github.com/gridstack/gridstack.js/issues/81) and @StefanM98, [#868](https://github.com/gridstack/gridstack.js/issues/868)):
235+
Better yet, here is a SASS code snippet which can make life much easier (Thanks to @ascendantofrain, [#81](https://github.com/gridstack/gridstack.js/issues/81) and @StefanM98, [#868](https://github.com/gridstack/gridstack.js/issues/868)) and you can use sites like [sassmeister.com](https://www.sassmeister.com/) to generate the CSS for you instead:
209236

210237
```sass
211238
.grid-stack > .grid-stack-item {
212239
213240
$gridstack-columns: 12;
214241
242+
min-width: (100% / $gridstack-columns);
243+
215244
@for $i from 1 through $gridstack-columns {
216245
&[data-gs-width='#{$i}'] { width: (100% / $gridstack-columns) * $i; }
217246
&[data-gs-x='#{$i}'] { left: (100% / $gridstack-columns) * $i; }
@@ -221,25 +250,6 @@ Here is a SASS code snippet which can make life easier (Thanks to @ascendantofra
221250
}
222251
```
223252

224-
Or you can include `gridstack-extra.css`. See below for more details.
225-
226-
## Extra CSS
227-
228-
There are few extra CSS batteries in `gridstack-extra.css` (`gridstack-extra.min.css`).
229-
230-
### Different grid widths
231-
232-
You can use other than 12 grid width:
233-
234-
```html
235-
<div class="grid-stack grid-stack-N">...</div>
236-
```
237-
```javascript
238-
$('.grid-stack').gridstack({width: N});
239-
```
240-
241-
See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.html)
242-
243253
## Override resizable/draggable options
244254

245255
You can override default `resizable`/`draggable` options. For instance to enable other then bottom right resizing handle
@@ -255,59 +265,6 @@ $('.grid-stack').gridstack({
255265

256266
Note: It's not recommended to enable `nw`, `n`, `ne` resizing handles. Their behaviour may be unexpected.
257267

258-
## IE8 support
259-
260-
Support of IE8 is quite limited and is not a goal at this time. As far as IE8 doesn't support DOM Level 2 I cannot manipulate with
261-
CSS stylesheet dynamically. As a workaround you can do the following:
262-
263-
- Create `gridstack-ie8.css` for your configuration (sample for grid with cell height of 60px can be found [here](https://gist.github.com/gridstack/6edfea5857f4cd73e6f1)).
264-
- Include this CSS:
265-
266-
```html
267-
<!--[if lt IE 9]>
268-
<link rel="stylesheet" href="gridstack-ie8.css"/>
269-
<![endif]-->
270-
```
271-
272-
- You can use this python script to generate such kind of CSS:
273-
274-
```python
275-
#!/usr/bin/env python
276-
277-
height = 60
278-
margin = 20
279-
N = 100
280-
281-
print '.grid-stack > .grid-stack-item { min-height: %(height)spx }' % {'height': height}
282-
283-
for i in range(N):
284-
h = height * (i + 1) + margin * i
285-
print '.grid-stack > .grid-stack-item[data-gs-height="%(index)s"] { height: %(height)spx }' % {'index': i + 1, 'height': h}
286-
287-
for i in range(N):
288-
h = height * (i + 1) + margin * i
289-
print '.grid-stack > .grid-stack-item[data-gs-min-height="%(index)s"] { min-height: %(height)spx }' % {'index': i + 1, 'height': h}
290-
291-
for i in range(N):
292-
h = height * (i + 1) + margin * i
293-
print '.grid-stack > .grid-stack-item[data-gs-max-height="%(index)s"] { max-height: %(height)spx }' % {'index': i + 1, 'height': h}
294-
295-
for i in range(N):
296-
h = height * i + margin * i
297-
print '.grid-stack > .grid-stack-item[data-gs-y="%(index)s"] { top: %(height)spx }' % {'index': i , 'height': h}
298-
```
299-
300-
There are at least two more issues with gridstack in IE8 with jQueryUI resizable (it seems it doesn't work) and
301-
droppable. If you have any suggestions about support of IE8 you are welcome here: https://github.com/gridstack/gridstack.js/issues/76
302-
303-
<!-- fixed in 0.5.0 with #643 ?
304-
## Use with require.js
305-
306-
If you're using require.js and a single file jQueryUI please check out this
307-
[Stackoverflow question](http://stackoverflow.com/questions/35582945/redundant-dependencies-with-requirejs) to get it
308-
working properly.
309-
-->
310-
311268
Changes
312269
=====
313270

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gridstack",
3-
"version": "0.5.2-dev",
3+
"version": "0.5.4",
44
"homepage": "https://github.com/gridstack/gridstack.js",
55
"authors": [
66
"Pavel Reznikov <pashka.reznikov@gmail.com>",

0 commit comments

Comments
 (0)