Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a set_static method for the grid + add a static class to the container #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
- [locked(el, val)](#lockedel-val)
- [min_width(el, val)](#min_widthel-val)
- [min_height(el, val)](#min_heightel-val)
- [movable(el, val)](#movableel-val)
- [move(el, x, y)](#moveel-x-y)
- [remove_widget(el, detach_node)](#remove_widgetel-detach_node)
- [remove_all()](#remove_all)
- [resize(el, width, height)](#resizeel-width-height)
- [move(el, x, y)](#moveel-x-y)
- [resizable(el, val)](#resizableel-val)
- [movable(el, val)](#movableel-val)
- [set_static(val)](#set_staticstatic_value)
- [update(el, x, y, width, height)](#updateel-x-y-width-height)
- [will_it_fit(x, y, width, height, auto_position)](#will_it_fitx-y-width-height-auto_position)
- [Utils](#utils)
Expand Down Expand Up @@ -132,7 +133,7 @@ $(function () {
- `min_width` - minimal width. If window width is less, grid will be shown in one-column mode (default: `768`)
- `placeholder_class` - class for placeholder (default: `'grid-stack-placeholder'`)
- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`)
- `static_grid` - makes grid static (default `false`). If true widgets are not movable/resizable. You don't even need jQueryUI draggable/resizable.
- `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.
- `vertical_margin` - vertical gap size (default: `20`)
- `width` - amount of columns (default: `12`)

Expand Down Expand Up @@ -313,6 +314,22 @@ Set the minHeight for a widget.
- `el` - widget to modify.
- `val` - A numeric value of the number of rows

### movable(el, val)

Enables/Disables moving.

- `el` - widget to modify
- `val` - if `true` widget will be draggable.

### move(el, x, y)

Changes widget position

Parameters:

- `el` - widget to move
- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored.

### remove_widget(el, detach_node)

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

### move(el, x, y)

Changes widget position

Parameters:

- `el` - widget to move
- `x`, `y` - new position. If value is `null` or `undefined` it will be ignored.

### resizable(el, val)

Enables/Disables resizing.

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

### movable(el, val)
### set_static(static_value)

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

- `el` - widget to modify
- `val` - if `true` widget will be draggable.
- `static_value` - if `true` the grid become static.

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

Expand Down
18 changes: 18 additions & 0 deletions src/gridstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@
this.opts.is_nested = is_nested;

this.container.addClass(this.opts._class);

this._set_static_class();

if (is_nested) {
this.container.addClass('grid-stack-nested');
}
Expand Down Expand Up @@ -946,6 +949,21 @@
return this.grid.is_area_empty(x, y, width, height);
};

GridStack.prototype.set_static = function(static_value) {
this.opts.static_grid = (static_value === true);
this._set_static_class();
};

GridStack.prototype._set_static_class = function() {
var static_class_name = 'grid-stack-static';

if (this.opts.static_grid === true) {
this.container.addClass(static_class_name);
} else {
this.container.removeClass(static_class_name);
}
};

scope.GridStackUI = GridStack;

scope.GridStackUI.Utils = Utils;
Expand Down