|
1450 | 1450 | node.resizeHandles = el.attr('data-gs-resize-handles'); |
1451 | 1451 | node.id = el.attr('data-gs-id'); |
1452 | 1452 | return node; |
1453 | | - } |
| 1453 | + }; |
1454 | 1454 |
|
1455 | 1455 | GridStack.prototype.setAnimation = function(enable) { |
1456 | 1456 | if (enable) { |
|
1519 | 1519 | if (detachNode !== false) { |
1520 | 1520 | delete this.grid._layouts; |
1521 | 1521 | // remove our data structure before list gets emptied and DOM elements stay behind |
1522 | | - this.grid.nodes.forEach(node => { node.el.removeData('_gridstack_node'); }); |
| 1522 | + this.grid.nodes.forEach(function(node) { node.el.removeData('_gridstack_node') }); |
1523 | 1523 | } |
1524 | 1524 | this.grid.removeAll(detachNode); |
1525 | 1525 | this._triggerRemoveEvent(); |
|
1833 | 1833 |
|
1834 | 1834 | // cache the current layout in case they want to go back (like 12 -> 1 -> 12) as it requires original data |
1835 | 1835 | var copy = [nodes.length]; |
1836 | | - nodes.forEach((n, i) => copy[i] = Utils.clone(n)); // clone to preserve _id that gets reset during removal, and changing x,y,w,h live objects |
| 1836 | + nodes.forEach(function(n, i) {copy[i] = Utils.clone(n)}); // clone to preserve _id that gets reset during removal, and changing x,y,w,h live objects |
1837 | 1837 | this.grid._layouts = this.grid._layouts || {}; |
1838 | 1838 | this.grid._layouts[oldColumn] = copy; |
1839 | 1839 |
|
1840 | 1840 | // see if we have cached prev values and if so re-use those nodes that are still current... |
1841 | 1841 | var newNodes = []; |
1842 | 1842 | var cacheNodes = this.grid._layouts[column] || []; |
1843 | | - cacheNodes.forEach(cacheNode => { |
1844 | | - var j = nodes.findIndex(n => n && n._id === cacheNode._id); |
| 1843 | + cacheNodes.forEach(function(cacheNode) { |
| 1844 | + var j = nodes.findIndex(function(n) {return n && n._id === cacheNode._id}); |
1845 | 1845 | if (j !== -1) { |
1846 | 1846 | newNodes.push(cacheNode); // still current, use cache info |
1847 | 1847 | nodes[j] = null; |
1848 | 1848 | } |
1849 | 1849 | }); |
1850 | 1850 | // ...and add any extra non-cached ones |
1851 | 1851 | var ratio = column / oldColumn; |
1852 | | - nodes.forEach(node => { |
| 1852 | + nodes.forEach(function(node) { |
1853 | 1853 | if (!node) return; |
1854 | 1854 | newNodes.push($.extend({}, node, {x: Math.round(node.x * ratio), width: Math.round(node.width * ratio) || 1})); |
1855 | 1855 | }); |
|
1859 | 1859 | // (batch mode will set float=true so we can position anywhere and do gravity relayout after) |
1860 | 1860 | this.batchUpdate(); |
1861 | 1861 | this.grid.removeAll(false); // 'false' = leave DOm elements behind |
1862 | | - newNodes.forEach(node => { |
| 1862 | + newNodes.forEach(function(node) { |
1863 | 1863 | var newNode = this.addWidget(node.el, node).data('_gridstack_node'); |
1864 | 1864 | newNode._id = node._id; // keep same ID so we can re-use caches |
1865 | 1865 | newNode._dirty = true; |
1866 | | - }); |
| 1866 | + }, this); |
1867 | 1867 | this.grid._removedNodes = []; // prevent add/remove from being called (kept DOM) only change event |
1868 | 1868 | this.grid._addedNodes = []; |
1869 | 1869 | this.commit(); |
|
0 commit comments