Merge commit 'c02c2a36d18333a20081235aeba7b38ae91a3b39'
This commit is contained in:
commit
78058d9cbe
|
@ -454,6 +454,7 @@ Changes
|
|||
- add `removable`/`removeTimeout`
|
||||
- add `detachGrid` parameter to `destroy` method ([#216](https://github.com/troolee/gridstack.js/issues/216))
|
||||
- add `useOffset` parameter to `getCellFromPixel` method ([#237](https://github.com/troolee/gridstack.js/issues/237))
|
||||
- add `minWidth`, `maxWidth`, `minHeight`, `maxHeight`, `id` parameters to `addWidget` ([#188](https://github.com/troolee/gridstack.js/issues/188))
|
||||
|
||||
#### v0.2.4 (2016-02-15)
|
||||
|
||||
|
|
17
dist/gridstack.js
vendored
17
dist/gridstack.js
vendored
|
@ -50,7 +50,7 @@
|
|||
createStylesheet: function(id) {
|
||||
var style = document.createElement('style');
|
||||
style.setAttribute('type', 'text/css');
|
||||
style.setAttribute('data-gs-id', id);
|
||||
style.setAttribute('data-gs-style-id', id);
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = '';
|
||||
} else {
|
||||
|
@ -61,7 +61,7 @@
|
|||
},
|
||||
|
||||
removeStylesheet: function(id) {
|
||||
$('STYLE[data-gs-id=' + id + ']').remove();
|
||||
$('STYLE[data-gs-style-id=' + id + ']').remove();
|
||||
},
|
||||
|
||||
insertCSSRule: function(sheet, selector, rules, index) {
|
||||
|
@ -681,7 +681,7 @@
|
|||
|
||||
GridStack.prototype._initStyles = function() {
|
||||
if (this._stylesId) {
|
||||
$('[data-gs-id="' + this._stylesId + '"]').remove();
|
||||
Utils.removeStylesheet(this._stylesId);
|
||||
}
|
||||
this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed();
|
||||
this._styles = Utils.createStylesheet(this._stylesId);
|
||||
|
@ -801,7 +801,8 @@
|
|||
noResize: Utils.toBool(el.attr('data-gs-no-resize')),
|
||||
noMove: Utils.toBool(el.attr('data-gs-no-move')),
|
||||
locked: Utils.toBool(el.attr('data-gs-locked')),
|
||||
el: el
|
||||
el: el,
|
||||
id: el.attr('data-gs-id')
|
||||
});
|
||||
el.data('_gridstack_node', node);
|
||||
|
||||
|
@ -985,13 +986,19 @@
|
|||
}
|
||||
};
|
||||
|
||||
GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition) {
|
||||
GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition, minWidth, maxWidth,
|
||||
minHeight, maxHeight, id) {
|
||||
el = $(el);
|
||||
if (typeof x != 'undefined') { el.attr('data-gs-x', x); }
|
||||
if (typeof y != 'undefined') { el.attr('data-gs-y', y); }
|
||||
if (typeof width != 'undefined') { el.attr('data-gs-width', width); }
|
||||
if (typeof height != 'undefined') { el.attr('data-gs-height', height); }
|
||||
if (typeof autoPosition != 'undefined') { el.attr('data-gs-auto-position', autoPosition ? 'yes' : null); }
|
||||
if (typeof minWidth != 'undefined') { el.attr('data-gs-min-width', minWidth); }
|
||||
if (typeof maxWidth != 'undefined') { el.attr('data-gs-max-width', maxWidth); }
|
||||
if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); }
|
||||
if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); }
|
||||
if (typeof id != 'undefined') { el.attr('data-gs-id', id); }
|
||||
this.container.append(el);
|
||||
this._prepareElement(el);
|
||||
this._updateContainerHeight();
|
||||
|
|
4
dist/gridstack.min.js
vendored
4
dist/gridstack.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/gridstack.min.map
vendored
2
dist/gridstack.min.map
vendored
File diff suppressed because one or more lines are too long
|
@ -17,7 +17,7 @@ gridstack.js API
|
|||
- [disable(event)](#disableevent)
|
||||
- [enable(event)](#enableevent)
|
||||
- [API](#api)
|
||||
- [addWidget(el, x, y, width, height, autoPosition)](#addwidgetel-x-y-width-height-autoposition)
|
||||
- [addWidget(el[, x, y, width, height, autoPosition, minWidth, maxWidth, minHeight, maxHeight, id])](#addwidgetel-x-y-width-height-autoposition-minwidth-maxwidth-minheight-maxheight-id)
|
||||
- [batchUpdate()](#batchupdate)
|
||||
- [cellHeight()](#cellheight)
|
||||
- [cellHeight(val)](#cellheightval)
|
||||
|
@ -174,16 +174,21 @@ $('.grid-stack').on('enable', function(event) {
|
|||
|
||||
## API
|
||||
|
||||
### addWidget(el, x, y, width, height, autoPosition)
|
||||
### addWidget(el[, x, y, width, height, autoPosition, minWidth, maxWidth, minHeight, maxHeight, id])
|
||||
|
||||
Creates new widget and returns it.
|
||||
|
||||
Parameters:
|
||||
|
||||
- `el` - widget to add
|
||||
- `x`, `y`, `width`, `height` - widget position/dimensions (Optional)
|
||||
- `x`, `y`, `width`, `height` - widget position/dimensions (optional)
|
||||
- `autoPosition` - if `true` then `x`, `y` parameters will be ignored and widget will be places on the first available
|
||||
position
|
||||
position (optional)
|
||||
- `minWidth` minimum width allowed during resize/creation (optional)
|
||||
- `maxWidth` maximum width allowed during resize/creation (optional)
|
||||
- `minHeight` minimum height allowed during resize/creation (optional)
|
||||
- `maxHeight` maximum height allowed during resize/creation (optional)
|
||||
- `id` value for `data-gs-id` (optional)
|
||||
|
||||
Widget will be always placed even if result height is more than actual grid height. You need to use `willItFit` method
|
||||
before calling `addWidget` for additional check.
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
createStylesheet: function(id) {
|
||||
var style = document.createElement('style');
|
||||
style.setAttribute('type', 'text/css');
|
||||
style.setAttribute('data-gs-id', id);
|
||||
style.setAttribute('data-gs-style-id', id);
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = '';
|
||||
} else {
|
||||
|
@ -61,7 +61,7 @@
|
|||
},
|
||||
|
||||
removeStylesheet: function(id) {
|
||||
$('STYLE[data-gs-id=' + id + ']').remove();
|
||||
$('STYLE[data-gs-style-id=' + id + ']').remove();
|
||||
},
|
||||
|
||||
insertCSSRule: function(sheet, selector, rules, index) {
|
||||
|
@ -681,7 +681,7 @@
|
|||
|
||||
GridStack.prototype._initStyles = function() {
|
||||
if (this._stylesId) {
|
||||
$('[data-gs-id="' + this._stylesId + '"]').remove();
|
||||
Utils.removeStylesheet(this._stylesId);
|
||||
}
|
||||
this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed();
|
||||
this._styles = Utils.createStylesheet(this._stylesId);
|
||||
|
@ -801,7 +801,8 @@
|
|||
noResize: Utils.toBool(el.attr('data-gs-no-resize')),
|
||||
noMove: Utils.toBool(el.attr('data-gs-no-move')),
|
||||
locked: Utils.toBool(el.attr('data-gs-locked')),
|
||||
el: el
|
||||
el: el,
|
||||
id: el.attr('data-gs-id')
|
||||
});
|
||||
el.data('_gridstack_node', node);
|
||||
|
||||
|
@ -985,13 +986,19 @@
|
|||
}
|
||||
};
|
||||
|
||||
GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition) {
|
||||
GridStack.prototype.addWidget = function(el, x, y, width, height, autoPosition, minWidth, maxWidth,
|
||||
minHeight, maxHeight, id) {
|
||||
el = $(el);
|
||||
if (typeof x != 'undefined') { el.attr('data-gs-x', x); }
|
||||
if (typeof y != 'undefined') { el.attr('data-gs-y', y); }
|
||||
if (typeof width != 'undefined') { el.attr('data-gs-width', width); }
|
||||
if (typeof height != 'undefined') { el.attr('data-gs-height', height); }
|
||||
if (typeof autoPosition != 'undefined') { el.attr('data-gs-auto-position', autoPosition ? 'yes' : null); }
|
||||
if (typeof minWidth != 'undefined') { el.attr('data-gs-min-width', minWidth); }
|
||||
if (typeof maxWidth != 'undefined') { el.attr('data-gs-max-width', maxWidth); }
|
||||
if (typeof minHeight != 'undefined') { el.attr('data-gs-min-height', minHeight); }
|
||||
if (typeof maxHeight != 'undefined') { el.attr('data-gs-max-height', maxHeight); }
|
||||
if (typeof id != 'undefined') { el.attr('data-gs-id', id); }
|
||||
this.container.append(el);
|
||||
this._prepareElement(el);
|
||||
this._updateContainerHeight();
|
||||
|
|
Loading…
Reference in a new issue