Merge pull request #187 from boreal-is/master

Add an API to set minWidth and minHeight to a node
This commit is contained in:
Pavel Reznikov 2015-07-20 16:49:48 -07:00
commit cbb0c28a4e
2 changed files with 50 additions and 0 deletions

View file

@ -36,6 +36,8 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
- [get_cell_from_pixel(position)](#get_cell_from_pixelposition)
- [is_area_empty(x, y, width, height)](#is_area_emptyx-y-width-height)
- [locked(el, val)](#lockedel-val)
- [min_width(el, val)](#min_widthel-val)
- [min_height(el, val)](#min_heightel-val)
- [remove_widget(el, detach_node)](#remove_widgetel-detach_node)
- [remove_all()](#remove_all)
- [resize(el, width, height)](#resizeel-width-height)
@ -292,6 +294,20 @@ Locks/unlocks widget.
- `el` - widget to modify.
- `val` - if `true` widget will be locked.
### min_width(el, val)
Set the minWidth for a widget.
- `el` - widget to modify.
- `val` - A numeric value of the number of columns
### min_height(el, val)
Set the minHeight for a widget.
- `el` - widget to modify.
- `val` - A numeric value of the number of rows
### remove_widget(el, detach_node)
Removes widget from the grid.

View file

@ -797,6 +797,40 @@
return this;
};
GridStack.prototype.min_height = function (el, val) {
el = $(el);
el.each(function (index, el) {
el = $(el);
var node = el.data('_gridstack_node');
if (typeof node == 'undefined' || node == null) {
return;
}
if(!isNaN(val)){
node.min_height = (val || false);
el.attr('data-gs-min-height', val);
}
});
return this;
};
GridStack.prototype.min_width = function (el, val) {
el = $(el);
el.each(function (index, el) {
el = $(el);
var node = el.data('_gridstack_node');
if (typeof node == 'undefined' || node == null) {
return;
}
if(!isNaN(val)){
node.min_width = (val || false);
el.attr('data-gs-min-width', val);
}
});
return this;
};
GridStack.prototype._update_element = function(el, callback) {
el = $(el).first();
var node = el.data('_gridstack_node');