|
191 | 191 | GridStackEngine.prototype._prepare_node = function(node, resizing) {
|
192 | 192 | node = _.defaults(node || {}, {width: 1, height: 1, x: 0, y: 0 });
|
193 | 193 |
|
194 |
| - node.x = parseInt('' + node.x); |
195 |
| - node.y = parseInt('' + node.y); |
196 |
| - node.width = parseInt('' + node.width); |
197 |
| - node.height = parseInt('' + node.height); |
| 194 | + node.x = parseInt('' + node.x, 10); |
| 195 | + node.y = parseInt('' + node.y, 10); |
| 196 | + node.width = parseInt('' + node.width, 10); |
| 197 | + node.height = parseInt('' + node.height, 10); |
198 | 198 | node.auto_position = node.auto_position || false;
|
199 | 199 | node.no_resize = node.no_resize || false;
|
200 | 200 | node.no_move = node.no_move || false;
|
|
337 | 337 | if (typeof node.max_width != 'undefined') width = Math.min(width, node.max_width);
|
338 | 338 | if (typeof node.max_height != 'undefined') height = Math.min(height, node.max_height);
|
339 | 339 | if (typeof node.min_width != 'undefined') width = Math.max(width, node.min_width);
|
340 |
| - if (typeof node.min_height != 'undefined') height = Math.max(height, node.min_height); |
| 340 | + if (typeof node.min_height != 'undefined') height = (node.minimized ? height : Math.max(height, node.min_height)); |
341 | 341 |
|
342 | 342 | if (node.x == x && node.y == y && node.width == width && node.height == height) {
|
343 | 343 | return false;
|
|
384 | 384 | return columns;
|
385 | 385 | };
|
386 | 386 |
|
| 387 | + GridStackEngine.prototype.get_column_by_x = function(x) { |
| 388 | + var columns = this.get_nodes_by_column(); |
| 389 | + return columns[x]; |
| 390 | + }; |
| 391 | + |
| 392 | + GridStackEngine.prototype.get_node_by_coords = function(x, y) { |
| 393 | + var selected_column = this.get_column_by_x(x); |
| 394 | + if (selected_column) { |
| 395 | + var target_node = selected_column |
| 396 | + .find(function(node) { return node.y == y; }); |
| 397 | + return target_node; |
| 398 | + } |
| 399 | + }; |
| 400 | + |
387 | 401 | GridStackEngine.prototype.column_overflows = function(column) {
|
388 | 402 | var column_height = _(column).map(function(node) {
|
389 | 403 | return node.y + node.height;
|
|
412 | 426 | node.x,
|
413 | 427 | node.y,
|
414 | 428 | node.width,
|
415 |
| - node.height-3) |
| 429 | + node.height-3); |
416 | 430 | });
|
417 | 431 | }
|
418 | 432 | });
|
|
423 | 437 | return everything_fits;
|
424 | 438 | };
|
425 | 439 |
|
| 440 | + GridStackEngine.prototype.focus_on_node_at = function(x, y, minimize_others) { |
| 441 | + var target_node = this.get_node_by_coords(x, y); |
| 442 | + |
| 443 | + if (minimize_others) { |
| 444 | + |
| 445 | + } |
| 446 | + |
| 447 | + this.expand_node(target_node); |
| 448 | + // var self = this; |
| 449 | + // var selected_column = this.get_column_by_x(x); |
| 450 | + // if (selected_column) { |
| 451 | + // var target_node = this.get_node_by_coords(x, y); |
| 452 | + // |
| 453 | + // if (target_node) { |
| 454 | + // if (minimize_others) { |
| 455 | + // selected_column |
| 456 | + // .filter(function(node) { return node.y != y; }) |
| 457 | + // .forEach(function(node) { |
| 458 | + // self.minimize_node(node); |
| 459 | + // }); |
| 460 | + // } |
| 461 | + // |
| 462 | + // this.move_node(target_node, x, y, target_node.width, self.height * 10, true); |
| 463 | + // } |
| 464 | + // } |
| 465 | + }; |
| 466 | + |
| 467 | + GridStackEngine.prototype.minimize_node_at = function(x, y) { |
| 468 | + var target_node = this.get_node_by_coords(x, y); |
| 469 | + this.minimize_node(target_node); |
| 470 | + }; |
| 471 | + |
| 472 | + GridStackEngine.prototype.minimize_node = function(node) { |
| 473 | + node.minimized = true; |
| 474 | + |
| 475 | + node.expanded_height = node.height; |
| 476 | + node.expanded_min_height = node.min_height; |
| 477 | + |
| 478 | + node.el.attr('data-gs-min-height', 5); |
| 479 | + node.min_height = 5; |
| 480 | + |
| 481 | + this.move_node(node, node.x, node.y, node.width, node.min_height); |
| 482 | + }; |
| 483 | + |
| 484 | + GridStackEngine.prototype.expand_node = function(node) { |
| 485 | + if (node.minimized) { |
| 486 | + delete node.minimized; |
| 487 | + |
| 488 | + var restore_height = node.expanded_height; |
| 489 | + delete node.expanded_height; |
| 490 | + |
| 491 | + node.min_height = node.expanded_min_height; |
| 492 | + delete node.expanded_min_height; |
| 493 | + node.el.attr('data-gs-min-height', node.min_height); |
| 494 | + |
| 495 | + this.move_node(node, node.x, node.y, node.width, restore_height); |
| 496 | + } |
| 497 | + }; |
| 498 | + |
426 | 499 | GridStackEngine.prototype.begin_update = function(node) {
|
427 | 500 | _.each(this.nodes, function(n) {
|
428 | 501 | n._orig_y = n.y;
|
|
922 | 995 | };
|
923 | 996 |
|
924 | 997 | GridStack.prototype.min_height = function (el, val) {
|
925 |
| - el = $(el); |
926 |
| - el.each(function (index, el) { |
927 |
| - el = $(el); |
928 |
| - var node = el.data('_gridstack_node'); |
929 |
| - if (typeof node == 'undefined' || node == null) { |
930 |
| - return; |
931 |
| - } |
| 998 | + el = $(el); |
| 999 | + el.each(function (index, el) { |
| 1000 | + el = $(el); |
| 1001 | + var node = el.data('_gridstack_node'); |
| 1002 | + if (typeof node == 'undefined' || node == null) { |
| 1003 | + return; |
| 1004 | + } |
932 | 1005 |
|
933 |
| - if(!isNaN(val)){ |
934 |
| - node.min_height = (val || false); |
935 |
| - el.attr('data-gs-min-height', val); |
936 |
| - } |
937 |
| - }); |
938 |
| - return this; |
939 |
| - }; |
| 1006 | + if(!isNaN(val)){ |
| 1007 | + node.min_height = (val || false); |
| 1008 | + el.attr('data-gs-min-height', val); |
| 1009 | + } |
| 1010 | + }); |
| 1011 | + return this; |
| 1012 | + }; |
940 | 1013 |
|
941 | 1014 | GridStack.prototype.min_width = function (el, val) {
|
942 | 1015 | el = $(el);
|
|
952 | 1025 | el.attr('data-gs-min-width', val);
|
953 | 1026 | }
|
954 | 1027 | });
|
955 |
| - return this; |
| 1028 | + return this; |
956 | 1029 | };
|
957 | 1030 |
|
958 | 1031 | GridStack.prototype._update_element = function(el, callback) {
|
|
1080 | 1153 | return false;
|
1081 | 1154 | };
|
1082 | 1155 |
|
| 1156 | + GridStack.prototype.focus_on_node_at = function(x, y, minimize_others) { |
| 1157 | + this.grid.focus_on_node_at(x, y, minimize_others); |
| 1158 | + }; |
| 1159 | + |
| 1160 | + GridStack.prototype.minimize_node_at = function(x, y) { |
| 1161 | + this.grid.minimize_node_at(x, y); |
| 1162 | + }; |
| 1163 | + |
1083 | 1164 | GridStack.prototype.set_static = function(static_value) {
|
1084 | 1165 | this.opts.static_grid = (static_value === true);
|
1085 | 1166 | this._set_static_class();
|
|
0 commit comments