|
472 | 472 | return this;
|
473 | 473 | };
|
474 | 474 |
|
| 475 | + GridStack.prototype._update_element = function (el, callback) { |
| 476 | + el = $(el).first(); |
| 477 | + var node = el.data('_gridstack_node'); |
| 478 | + if (typeof node == 'undefined') { |
| 479 | + return; |
| 480 | + } |
| 481 | + |
| 482 | + var self = this; |
| 483 | + |
| 484 | + self.grid.clean_nodes(); |
| 485 | + self.grid.begin_update(node); |
| 486 | + |
| 487 | + callback.call(this, el, node); |
| 488 | + |
| 489 | + self._update_container_height(); |
| 490 | + self.container.trigger('change', [self.grid.get_dirty_nodes()]); |
| 491 | + |
| 492 | + self.grid.end_update(); |
| 493 | + |
| 494 | + self.grid._sort_nodes(); |
| 495 | + _.each(self.grid.nodes, function (node) { |
| 496 | + node.el.detach(); |
| 497 | + self.container.append(node.el); |
| 498 | + }); |
| 499 | + }; |
| 500 | + |
| 501 | + GridStack.prototype.resize = function (el, width, height) { |
| 502 | + this._update_element(el, function (el, node) { |
| 503 | + width = (width != null && typeof width != 'undefined') ? width : node.width; |
| 504 | + height = (height != null && typeof height != 'undefined') ? height : node.height; |
| 505 | + |
| 506 | + this.grid.move_node(node, node.x, node.y, width, height); |
| 507 | + }); |
| 508 | + }; |
| 509 | + |
| 510 | + GridStack.prototype.move = function (el, x, y) { |
| 511 | + this._update_element(el, function (el, node) { |
| 512 | + x = (x != null && typeof x != 'undefined') ? x : node.x; |
| 513 | + y = (y != null && typeof y != 'undefined') ? y : node.y; |
| 514 | + |
| 515 | + this.grid.move_node(node, x, y, node.width, node.height); |
| 516 | + }); |
| 517 | + }; |
| 518 | + |
475 | 519 | scope.GridStackUI = GridStack;
|
476 | 520 |
|
477 | 521 | $.fn.gridstack = function (opts) {
|
|
0 commit comments