Merge commit 'a04a2477439c520ad74bcfe3a7bf502b98df3f89'

This commit is contained in:
d 2016-08-16 15:19:03 -04:00
commit 56801119c2
6 changed files with 42 additions and 33 deletions

View file

@ -476,8 +476,9 @@ Changes
#### v0.2.6-dev (Development version)
- update requirements to the latest versions
- fix jQuery `size()`
- update requirements to the latest versions of jQuery and jquery-ui.
- fix jQuery `size()` ([#486](https://github.com/troolee/gridstack.js/issues/486)).
- update _notify to allow detach ([#411](https://github.com/troolee/gridstack.js/issues/411)).
#### v0.2.5 (2016-03-02)

17
dist/gridstack.js vendored
View file

@ -281,12 +281,14 @@
};
GridStackEngine.prototype._notify = function() {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = typeof args[0] === 'undefined' ? [] : [args[0]];
args[1] = typeof args[1] === 'undefined' ? true : args[1];
if (this._updateCounter) {
return;
}
var deletedNodes = Array.prototype.slice.call(arguments, 0);
deletedNodes = deletedNodes.concat(this.getDirtyNodes());
this.onchange(deletedNodes);
var deletedNodes = args[0].concat(this.getDirtyNodes());
this.onchange(deletedNodes, args[1]);
};
GridStackEngine.prototype.cleanNodes = function() {
@ -345,9 +347,7 @@
node._id = null;
this.nodes = _.without(this.nodes, node);
this._packNodes();
if (detachNode) {
this._notify(node);
}
this._notify(node, detachNode);
};
GridStackEngine.prototype.canMoveNode = function(node, x, y, width, height) {
@ -578,10 +578,11 @@
this._initStyles();
this.grid = new GridStackEngine(this.opts.width, function(nodes) {
this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) {
detachNode = typeof detachNode === 'undefined' ? true : detachNode;
var maxHeight = 0;
_.each(nodes, function(n) {
if (n._id === null) {
if (detachNode && n._id === null) {
if (n.el) {
n.el.remove();
}

10
dist/gridstack.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -176,21 +176,31 @@ describe('gridstack engine', function() {
expect(spy.callback).toHaveBeenCalledWith([
engine.nodes[0],
engine.nodes[1]
]);
], true);
});
it('should by called with extra passed dirty nodes', function() {
var n1 = {idx: -1},
n2 = {idx: -2};
it('should by called with extra passed node to be removed', function() {
var n1 = {idx: -1};
engine._notify(n1, n2);
engine._notify(n1);
expect(spy.callback).toHaveBeenCalledWith([
n1,
n2,
engine.nodes[0],
engine.nodes[1]
]);
], true);
});
it('should by called with extra passed node to be removed and should maintain false parameter', function() {
var n1 = {idx: -1};
engine._notify(n1, false);
expect(spy.callback).toHaveBeenCalledWith([
n1,
engine.nodes[0],
engine.nodes[1]
], false);
});
});

View file

@ -281,12 +281,14 @@
};
GridStackEngine.prototype._notify = function() {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = typeof args[0] === 'undefined' ? [] : [args[0]];
args[1] = typeof args[1] === 'undefined' ? true : args[1];
if (this._updateCounter) {
return;
}
var deletedNodes = Array.prototype.slice.call(arguments, 0);
deletedNodes = deletedNodes.concat(this.getDirtyNodes());
this.onchange(deletedNodes);
var deletedNodes = args[0].concat(this.getDirtyNodes());
this.onchange(deletedNodes, args[1]);
};
GridStackEngine.prototype.cleanNodes = function() {
@ -345,9 +347,7 @@
node._id = null;
this.nodes = _.without(this.nodes, node);
this._packNodes();
if (detachNode) {
this._notify(node);
}
this._notify(node, detachNode);
};
GridStackEngine.prototype.canMoveNode = function(node, x, y, width, height) {
@ -578,10 +578,11 @@
this._initStyles();
this.grid = new GridStackEngine(this.opts.width, function(nodes) {
this.grid = new GridStackEngine(this.opts.width, function(nodes, detachNode) {
detachNode = typeof detachNode === 'undefined' ? true : detachNode;
var maxHeight = 0;
_.each(nodes, function(n) {
if (n._id === null) {
if (detachNode && n._id === null) {
if (n.el) {
n.el.remove();
}