add maxWidth/maxHeight

This commit is contained in:
Pavel Reznikov 2016-02-17 19:03:21 -08:00
commit 02f0eba64d
5 changed files with 93 additions and 8 deletions

View file

@ -45,8 +45,10 @@ Join gridstack.js on Slack: https://gridstackjs.troolee.com
- [isAreaEmpty(x, y, width, height)](#isareaemptyx-y-width-height)
- [locked(el, val)](#lockedel-val)
- [makeWidget(el)](#makewidgetel)
- [minWidth(el, val)](#minwidthel-val)
- [maxHeight(el, val)](#maxheightel-val)
- [minHeight(el, val)](#minheightel-val)
- [maxWidth(el, val)](#maxwidthel-val)
- [minWidth(el, val)](#minwidthel-val)
- [movable(el, val)](#movableel-val)
- [move(el, x, y)](#moveel-x-y)
- [removeWidget(el, detachNode)](#removewidgetel-detachnode)
@ -380,19 +382,33 @@ var grid = $('.grid-stack').data('gridstack');
grid.makeWidget('gsi-1');
```
### minWidth(el, val)
### maxHeight(el, val)
Set the minWidth for a widget.
Set the `maxHeight` for a widget.
- `el` - widget to modify.
- `val` - A numeric value of the number of rows
### minHeight(el, val)
Set the `minHeight` for a widget.
- `el` - widget to modify.
- `val` - A numeric value of the number of rows
### maxWidth(el, val)
Set the `maxWidth` for a widget.
- `el` - widget to modify.
- `val` - A numeric value of the number of columns
### minHeight(el, val)
### minWidth(el, val)
Set the minHeight for a widget.
Set the `minWidth` for a widget.
- `el` - widget to modify.
- `val` - A numeric value of the number of rows
- `val` - A numeric value of the number of columns
### movable(el, val)
@ -787,8 +803,9 @@ Changes
#### v0.2.5-dev (Development version)
- `cell_height` and `vertical_margin` can now be string (e.g. '3em', '20px') (Thanks to @jlowcs)
- update names to respect js naming convention
- `cellHeight` and `verticalMargin` can now be string (e.g. '3em', '20px') (Thanks to @jlowcs)
- add `maxWidth`/`maxHeight` methods.
#### v0.2.4 (2016-02-15)

34
dist/gridstack.js vendored
View file

@ -991,6 +991,23 @@
return this;
};
GridStack.prototype.maxHeight = 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.maxHeight = (val || false);
el.attr('data-gs-max-height', val);
}
});
return this;
};
GridStack.prototype.minHeight = function(el, val) {
el = $(el);
el.each(function(index, el) {
@ -1008,6 +1025,23 @@
return this;
};
GridStack.prototype.maxWidth = 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.maxWidth = (val || false);
el.attr('data-gs-max-width', val);
}
});
return this;
};
GridStack.prototype.minWidth = function(el, val) {
el = $(el);
el.each(function(index, el) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -991,6 +991,23 @@
return this;
};
GridStack.prototype.maxHeight = 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.maxHeight = (val || false);
el.attr('data-gs-max-height', val);
}
});
return this;
};
GridStack.prototype.minHeight = function(el, val) {
el = $(el);
el.each(function(index, el) {
@ -1008,6 +1025,23 @@
return this;
};
GridStack.prototype.maxWidth = 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.maxWidth = (val || false);
el.attr('data-gs-max-width', val);
}
});
return this;
};
GridStack.prototype.minWidth = function(el, val) {
el = $(el);
el.each(function(index, el) {