destroy method

This commit is contained in:
Pavel Reznikov 2015-07-21 23:34:45 -07:00
commit ed29eed4a0
4 changed files with 23 additions and 6 deletions

View file

@ -31,6 +31,7 @@ Inspired by [gridster.js](http://gridster.net). Built with love.
- [cell_height(val)](#cell_heightval)
- [cell_width()](#cell_width)
- [commit()](#commit)
- [destroy()](#destroy)
- [disable()](#disable)
- [enable()](#enable)
- [get_cell_from_pixel(position)](#get_cell_from_pixelposition)
@ -255,6 +256,10 @@ Gets current cell width.
Finishes batch updates. Updates DOM nodes. You must call it after `batch_update`.
### destroy()
Destroys a grid instance.
### disable()
Disables widgets moving/resizing. This is a shortcut for:
@ -688,6 +693,7 @@ Changes
- fix closure compiler/linter warnings
- add `static_grid` option.
- add `min_width`/`min_height` methods (Thanks to @cvillemure)
- add `destroy` method (Thanks to @zspitzer)
#### v0.2.3 (2015-06-23)

19
dist/gridstack.js vendored
View file

@ -39,7 +39,9 @@
document.getElementsByTagName('head')[0].appendChild(style);
return style.sheet;
},
remove_stylesheet: function(id) {
$("STYLE[data-gs-id=" + id +"]").remove();
},
insert_css_rule: function(sheet, selector, rules, index) {
if (typeof sheet.insertRule === 'function') {
sheet.insertRule(selector + '{' + rules + '}', index);
@ -463,7 +465,7 @@
this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) -
this.opts.vertical_margin);
var on_resize_handler = function() {
this.on_resize_handler = function() {
if (self._is_one_column_mode()) {
if (one_column_mode)
return;
@ -506,8 +508,8 @@
}
};
$(window).resize(on_resize_handler);
on_resize_handler();
$(window).resize(this.on_resize_handler);
this.on_resize_handler();
};
GridStack.prototype._init_styles = function() {
@ -732,6 +734,15 @@
this._update_container_height();
};
GridStack.prototype.destroy = function() {
$(window).off("resize", this.on_resize_handler);
this.disable();
this.container.remove();
Utils.remove_stylesheet(this._styles_id);
if (this.grid)
this.grid = null;
};
GridStack.prototype.resizable = 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