Skip to content

Commit 5e06c68

Browse files
committed
Merged changes
2 parents 231bc8c + 5bbd8d5 commit 5e06c68

14 files changed

+2954
-259
lines changed

README.md

Lines changed: 77 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,38 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
3131
- [cell_height(val)](#cell_heightval)
3232
- [cell_width()](#cell_width)
3333
- [commit()](#commit)
34+
- [destroy()](#destroy)
3435
- [disable()](#disable)
3536
- [enable()](#enable)
3637
- [get_cell_from_pixel(position)](#get_cell_from_pixelposition)
3738
- [is_area_empty(x, y, width, height)](#is_area_emptyx-y-width-height)
3839
- [locked(el, val)](#lockedel-val)
40+
- [min_width(el, val)](#min_widthel-val)
41+
- [min_height(el, val)](#min_heightel-val)
42+
- [movable(el, val)](#movableel-val)
43+
- [move(el, x, y)](#moveel-x-y)
3944
- [remove_widget(el, detach_node)](#remove_widgetel-detach_node)
4045
- [remove_all()](#remove_all)
4146
- [resize(el, width, height)](#resizeel-width-height)
42-
- [move(el, x, y)](#moveel-x-y)
4347
- [resizable(el, val)](#resizableel-val)
44-
- [movable(el, val)](#movableel-val)
48+
- [set_static(static_value)](#set_staticstatic_value)
4549
- [update(el, x, y, width, height)](#updateel-x-y-width-height)
4650
- [will_it_fit(x, y, width, height, auto_position)](#will_it_fitx-y-width-height-auto_position)
4751
- [Utils](#utils)
4852
- [GridStackUI.Utils.sort(nodes, dir, width)](#gridstackuiutilssortnodes-dir-width)
4953
- [Touch devices support](#touch-devices-support)
5054
- [Use with knockout.js](#use-with-knockoutjs)
5155
- [Change grid width](#change-grid-width)
56+
- [Extra CSS](#extra-css)
57+
- [Different grid widths](#different-grid-widths)
5258
- [Save grid to array](#save-grid-to-array)
5359
- [Load grid from array](#load-grid-from-array)
5460
- [Override resizable/draggable options](#override-resizabledraggable-options)
5561
- [IE8 support](#ie8-support)
5662
- [Nested grids](#nested-grids)
5763
- [Changes](#changes)
58-
- [v0.2.3 (development version)](#v023-development-version)
64+
- [v0.2.4 (development version)](#v024-development-version)
65+
- [v0.2.3 (2015-06-23)](#v023-2015-06-23)
5966
- [v0.2.2 (2014-12-23)](#v022-2014-12-23)
6067
- [v0.2.1 (2014-12-09)](#v021-2014-12-09)
6168
- [v0.2.0 (2014-11-30)](#v020-2014-11-30)
@@ -126,6 +133,7 @@ $(function () {
126133
- `min_width` - minimal width. If window width is less, grid will be shown in one-column mode (default: `768`)
127134
- `placeholder_class` - class for placeholder (default: `'grid-stack-placeholder'`)
128135
- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`)
136+
- `static_grid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable. A CSS class `grid-stack-static` is also added to the container.
129137
- `vertical_margin` - vertical gap size (default: `20`)
130138
- `width` - amount of columns (default: `12`)
131139

@@ -152,7 +160,7 @@ to completely lock the widget.
152160

153161
### onchange(items)
154162

155-
Occurs when widgets change their position/size
163+
Occurs when adding/removing widgets or existing widgets change their position/size
156164

157165
```javascript
158166
var serialize_widget_map = function (items) {
@@ -249,6 +257,10 @@ Gets current cell width.
249257

250258
Finishes batch updates. Updates DOM nodes. You must call it after `batch_update`.
251259

260+
### destroy()
261+
262+
Destroys a grid instance.
263+
252264
### disable()
253265

254266
Disables widgets moving/resizing. This is a shortcut for:
@@ -288,6 +300,36 @@ Locks/unlocks widget.
288300
- `el` - widget to modify.
289301
- `val` - if `true` widget will be locked.
290302

303+
### min_width(el, val)
304+
305+
Set the minWidth for a widget.
306+
307+
- `el` - widget to modify.
308+
- `val` - A numeric value of the number of columns
309+
310+
### min_height(el, val)
311+
312+
Set the minHeight for a widget.
313+
314+
- `el` - widget to modify.
315+
- `val` - A numeric value of the number of rows
316+
317+
### movable(el, val)
318+
319+
Enables/Disables moving.
320+
321+
- `el` - widget to modify
322+
- `val` - if `true` widget will be draggable.
323+
324+
### move(el, x, y)
325+
326+
Changes widget position
327+
328+
Parameters:
329+
330+
- `el` - widget to move
331+
- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored.
332+
291333
### remove_widget(el, detach_node)
292334

293335
Removes widget from the grid.
@@ -310,28 +352,18 @@ Parameters:
310352
- `el` - widget to resize
311353
- `width`, `height` - new dimensions. If value is `null` or `undefined` it will be ignored.
312354

313-
### move(el, x, y)
314-
315-
Changes widget position
316-
317-
Parameters:
318-
319-
- `el` - widget to move
320-
- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored.
321-
322355
### resizable(el, val)
323356

324357
Enables/Disables resizing.
325358

326359
- `el` - widget to modify
327360
- `val` - if `true` widget will be resizable.
328361

329-
### movable(el, val)
362+
### set_static(static_value)
330363

331-
Enables/Disables moving.
364+
Toggle the grid static state. Also toggle the `grid-stack-static` class.
332365

333-
- `el` - widget to modify
334-
- `val` - if `true` widget will be draggable.
366+
- `static_value` - if `true` the grid become static.
335367

336368
### update(el, x, y, width, height)
337369

@@ -519,6 +551,25 @@ Here is a SASS code snipped which can make life easier (Thanks to @ascendantofra
519551
}
520552
```
521553

554+
Or you can include `gridstack-extra.css`. See below for more details.
555+
556+
## Extra CSS
557+
558+
There are few extra CSS batteries in `gridstack-extra.css` (`gridstack-extra.min.css`).
559+
560+
### Different grid widths
561+
562+
You can use other than 12 grid width:
563+
564+
```html
565+
<div class="grid-stack grid-stack-N">...</div>
566+
```
567+
```javascript
568+
$('.grid-stack').gridstack({width: N});
569+
```
570+
571+
See example: [2 grids demo](http://troolee.github.io/gridstack.js/demo/two.html)
572+
522573
## Save grid to array
523574

524575
Because gridstack doesn't track any kind of user-defined widget id there is no reason to make serialization to be part
@@ -644,8 +695,16 @@ See example: [Nested grid demo](http://troolee.github.io/gridstack.js/demo/neste
644695
Changes
645696
=======
646697

647-
#### v0.2.3 (development version)
698+
#### v0.2.4 (development version)
699+
700+
- fix closure compiler/linter warnings
701+
- add `static_grid` option.
702+
- add `min_width`/`min_height` methods (Thanks to @cvillemure)
703+
- add `destroy` method (Thanks to @zspitzer)
704+
705+
#### v0.2.3 (2015-06-23)
648706

707+
- gridstack-extra.css
649708
- add support of lodash.js
650709
- add `is_area_empty` method
651710
- nested grids

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.2.2",
3+
"version": "0.2.3",
44
"homepage": "https://github.com/troolee/gridstack.js",
55
"authors": [
66
"Pavel Reznikov <pashka.reznikov@gmail.com>"

demo/serialization.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ <h1>Serialization demo</h1>
5656
<script type="text/javascript">
5757
$(function () {
5858
var options = {
59+
static_grid: true
5960
};
6061
$('.grid-stack').gridstack(options);
6162

demo/two.html

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<!--[if lt IE 9]>
5+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
6+
<![endif]-->
7+
8+
<meta charset="utf-8">
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<title>Two grids demo</title>
12+
13+
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
14+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css"/>
15+
<link rel="stylesheet" href="../dist/gridstack.css"/>
16+
<link rel="stylesheet" href="../dist/gridstack-extra.css"/>
17+
18+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
19+
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
20+
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
21+
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
22+
<script src="../dist/gridstack.js"></script>
23+
24+
<style type="text/css">
25+
#grid1 {
26+
background: lightgoldenrodyellow;
27+
}
28+
29+
#grid2 {
30+
background: lightcyan;
31+
}
32+
33+
.grid-stack-item-content {
34+
color: #2c3e50;
35+
text-align: center;
36+
background-color: #18bc9c;
37+
}
38+
</style>
39+
</head>
40+
<body>
41+
<div class="container-fluid">
42+
<h1>Two grids demo</h1>
43+
44+
<div class="row">
45+
<div class="col-md-6">
46+
<div class="grid-stack grid-stack-6" id="grid1">
47+
</div>
48+
</div>
49+
<div class="col-md-6">
50+
<div class="grid-stack grid-stack-6" id="grid2">
51+
</div>
52+
</div>
53+
</div>
54+
</div>
55+
56+
57+
<script type="text/javascript">
58+
$(function () {
59+
var options = {
60+
width: 6,
61+
float: true
62+
};
63+
$('#grid1').gridstack(options);
64+
$('#grid2').gridstack(options);
65+
66+
var items = [
67+
{x: 0, y: 0, width: 2, height: 2},
68+
{x: 3, y: 1, width: 1, height: 2},
69+
{x: 4, y: 1, width: 1, height: 1},
70+
{x: 2, y: 3, width: 3, height: 1},
71+
{x: 2, y: 5, width: 1, height: 1}
72+
];
73+
74+
$('.grid-stack').each(function () {
75+
var grid = $(this).data('gridstack');
76+
77+
_.each(items, function (node) {
78+
grid.add_widget($('<div><div class="grid-stack-item-content" /><div/>'),
79+
node.x, node.y, node.width, node.height);
80+
}, this);
81+
});
82+
});
83+
</script>
84+
</body>
85+
</html>

0 commit comments

Comments
 (0)