|
67 | 67 |
|
68 | 68 | this.nodes = items || [];
|
69 | 69 | this.onchange = onchange || function () {};
|
| 70 | + |
| 71 | + this._update_counter = 0; |
| 72 | + this._float = this.float; |
| 73 | + }; |
| 74 | + |
| 75 | + GridStackEngine.prototype.batch_update = function () { |
| 76 | + this._update_counter = 1; |
| 77 | + this.float = true; |
| 78 | + }; |
| 79 | + |
| 80 | + GridStackEngine.prototype.commit = function () { |
| 81 | + this._update_counter = 0; |
| 82 | + if (this._update_counter == 0) { |
| 83 | + this.float = this._float; |
| 84 | + this._pack_nodes(); |
| 85 | + this._notify(); |
| 86 | + } |
70 | 87 | };
|
71 | 88 |
|
72 | 89 | GridStackEngine.prototype._fix_collisions = function (node) {
|
|
188 | 205 | };
|
189 | 206 |
|
190 | 207 | GridStackEngine.prototype._notify = function () {
|
| 208 | + if (this._update_counter) { |
| 209 | + return; |
| 210 | + } |
191 | 211 | var deleted_nodes = Array.prototype.slice.call(arguments, 1).concat(this.get_dirty_nodes());
|
192 | 212 | deleted_nodes = deleted_nodes.concat(this.get_dirty_nodes());
|
193 | 213 | this.onchange(deleted_nodes);
|
|
502 | 522 | };
|
503 | 523 |
|
504 | 524 | GridStack.prototype._update_container_height = function () {
|
| 525 | + if (this.grid._update_counter) { |
| 526 | + return; |
| 527 | + } |
505 | 528 | this.container.height(this.grid.get_grid_height() * (this.opts.cell_height + this.opts.vertical_margin) - this.opts.vertical_margin);
|
506 | 529 | };
|
507 | 530 |
|
|
522 | 545 | height: el.attr('data-gs-height'),
|
523 | 546 | max_width: el.attr('data-gs-max-width'),
|
524 | 547 | min_width: el.attr('data-gs-min-width'),
|
525 |
| - max_height: el.attr('data-gs-max-height') || 100, |
| 548 | + max_height: el.attr('data-gs-max-height'), |
526 | 549 | min_height: el.attr('data-gs-min-height'),
|
527 | 550 | auto_position: Utils.toBool(el.attr('data-gs-auto-position')),
|
528 | 551 | no_resize: Utils.toBool(el.attr('data-gs-no-resize')),
|
|
751 | 774 | });
|
752 | 775 | };
|
753 | 776 |
|
| 777 | + GridStack.prototype.update = function (el, x, y, width, height) { |
| 778 | + this._update_element(el, function (el, node) { |
| 779 | + x = (x != null && typeof x != 'undefined') ? x : node.x; |
| 780 | + y = (y != null && typeof y != 'undefined') ? y : node.y; |
| 781 | + width = (width != null && typeof width != 'undefined') ? width : node.width; |
| 782 | + height = (height != null && typeof height != 'undefined') ? height : node.height; |
| 783 | + |
| 784 | + this.grid.move_node(node, x, y, width, height); |
| 785 | + }); |
| 786 | + }; |
| 787 | + |
754 | 788 | GridStack.prototype.cell_height = function (val) {
|
755 | 789 | if (typeof val == 'undefined') {
|
756 | 790 | return this.opts.cell_height;
|
|
778 | 812 | return {x: Math.floor(relativeLeft / column_width), y: Math.floor(relativeTop / row_height)};
|
779 | 813 | };
|
780 | 814 |
|
| 815 | + GridStack.prototype.batch_update = function () { |
| 816 | + this.grid.batch_update(); |
| 817 | + }; |
| 818 | + |
| 819 | + GridStack.prototype.commit = function () { |
| 820 | + this.grid.commit(); |
| 821 | + this._update_container_height() |
| 822 | + }; |
| 823 | + |
781 | 824 | scope.GridStackUI = GridStack;
|
782 | 825 |
|
783 | 826 | scope.GridStackUI.Utils = Utils;
|
|
0 commit comments