simpler rmClone

This commit is contained in:
Nicolas Stepien 2012-09-22 17:48:00 +02:00
parent da583628e2
commit 610ee5df38
2 changed files with 7 additions and 5 deletions

View File

@ -919,10 +919,12 @@
};
Post.prototype.rmClone = function(index) {
var i, _i, _ref;
var clone, _i, _len, _ref;
this.clones.splice(index, 1);
for (i = _i = index, _ref = this.clones.length; index <= _ref ? _i < _ref : _i > _ref; i = index <= _ref ? ++_i : --_i) {
this.clones[i].nodes.root.setAttribute('data-clone', i);
_ref = this.clones.slice(index);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
clone = _ref[_i];
clone.nodes.root.setAttribute('data-clone', index++);
}
};

View File

@ -718,8 +718,8 @@ class Post
new Clone @, context
rmClone: (index) ->
@clones.splice index, 1
for i in [index...@clones.length]
@clones[i].nodes.root.setAttribute 'data-clone', i
for clone in @clones[index..]
clone.nodes.root.setAttribute 'data-clone', index++
return
class Clone extends Post