update gridstack.js

This commit is contained in:
Pavel Reznikov 2014-12-05 18:29:52 -08:00
commit a37fd745dd

View file

@ -174,6 +174,9 @@
for (var i = 0; ; ++i) {
var x = i % this.width, y = Math.floor(i / this.width);
if (x + node.width > this.width) {
continue;
}
if (!_.find(this.nodes, function (n) {
return Utils.is_intercepted({x: x, y: y, width: node.width, height: node.height}, n);
})) {
@ -216,6 +219,20 @@
return clone.get_grid_height() <= this.height;
};
GridStackEngine.prototype.can_be_placed_with_respect_to_height = function (node) {
if (!this.height)
return true;
var clone = new GridStackEngine(
this.width,
null,
this.float,
0,
_.map(this.nodes, function (n) { return $.extend({}, n) }));
clone.add_node(node);
return clone.get_grid_height() <= this.height;
};
GridStackEngine.prototype.move_node = function (node, x, y, width, height, no_pack) {
if (typeof x != 'number') x = node.x;
if (typeof y != 'number') y = node.y;
@ -489,7 +506,7 @@
else {
this.container.removeClass('grid-stack-animate');
}
}
};
GridStack.prototype.add_widget = function (el, x, y, width, height, auto_position) {
el = $(el);
@ -503,6 +520,11 @@
this._update_container_height();
};
GridStack.prototype.will_it_fit = function (x, y, width, height, auto_position) {
var node = {x: x, y: y, width: width, height: height, auto_position: auto_position};
return this.grid.can_be_placed_with_respect_to_height(node);
};
GridStack.prototype.remove_widget = function (el) {
el = $(el);
var node = el.data('_gridstack_node');