Rename _cloning parameter to _preserve.

This commit is contained in:
Jürg Lehni 2013-04-19 11:54:16 -07:00
parent 50287cde96
commit 922b9b5bd0
3 changed files with 16 additions and 16 deletions

View file

@ -1378,9 +1378,9 @@ var Item = this.Item = Base.extend(Callback, {
* *
* @param {Item} item The item to be added as a child * @param {Item} item The item to be added as a child
*/ */
addChild: function(item, _cloning) { addChild: function(item, _preserve) {
// Pass on internal _cloning boolean, for CompoundPath#insertChild // Pass on internal _preserve boolean, for CompoundPath#insertChild
return this.insertChild(undefined, item, _cloning); return this.insertChild(undefined, item, _preserve);
}, },
/** /**
@ -1391,8 +1391,8 @@ var Item = this.Item = Base.extend(Callback, {
* @param {Number} index * @param {Number} index
* @param {Item} item The item to be appended as a child * @param {Item} item The item to be appended as a child
*/ */
insertChild: function(index, item, _cloning) { insertChild: function(index, item, _preserve) {
// _cloning parameter is not used here, but CompoundPath#insertChild() // _preserve parameter is not used here, but CompoundPath#insertChild()
// needs it. // needs it.
if (this._children) { if (this._children) {
item._remove(true); item._remove(true);
@ -1416,8 +1416,8 @@ var Item = this.Item = Base.extend(Callback, {
* *
* @param {Item[]} items The items to be added as children * @param {Item[]} items The items to be added as children
*/ */
addChildren: function(items, _cloning) { addChildren: function(items, _preserve) {
return this.insertChildren(this._children.length, items, _cloning); return this.insertChildren(this._children.length, items, _preserve);
}, },
/** /**
@ -1428,7 +1428,7 @@ var Item = this.Item = Base.extend(Callback, {
* @param {Number} index * @param {Number} index
* @param {Item[]} items The items to be appended as children * @param {Item[]} items The items to be appended as children
*/ */
insertChildren: function(index, items, _cloning) { insertChildren: function(index, items, _preserve) {
// We need to clone items because it might be // We need to clone items because it might be
// an Item#children array. Use Array.prototype.slice because // an Item#children array. Use Array.prototype.slice because
// in certain cases items is an arguments object // in certain cases items is an arguments object
@ -1437,7 +1437,7 @@ var Item = this.Item = Base.extend(Callback, {
length = children.length, length = children.length,
i = index; i = index;
for (var j = 0, l = items && items.length; j < l; j++) { for (var j = 0, l = items && items.length; j < l; j++) {
if (this.insertChild(i, items[j], _cloning)) { if (this.insertChild(i, items[j], _preserve)) {
// We need to keep track of how much the list actually grows, // We need to keep track of how much the list actually grows,
// bcause we might be removing and inserting into the same list, // bcause we might be removing and inserting into the same list,
// in which case the size would not chage. // in which case the size would not chage.
@ -1455,11 +1455,11 @@ var Item = this.Item = Base.extend(Callback, {
* @param {Item} item The item above which it should be inserted * @param {Item} item The item above which it should be inserted
* @return {Boolean} {@true it was inserted} * @return {Boolean} {@true it was inserted}
*/ */
insertAbove: function(item, _cloning) { insertAbove: function(item, _preserve) {
var index = item._index; var index = item._index;
if (item._parent == this._parent && index < this._index) if (item._parent == this._parent && index < this._index)
index++; index++;
return item._parent.insertChild(index, this, _cloning); return item._parent.insertChild(index, this, _preserve);
}, },
/** /**
@ -1468,11 +1468,11 @@ var Item = this.Item = Base.extend(Callback, {
* @param {Item} item The item above which it should be inserted * @param {Item} item The item above which it should be inserted
* @return {Boolean} {@true it was inserted} * @return {Boolean} {@true it was inserted}
*/ */
insertBelow: function(item, _cloning) { insertBelow: function(item, _preserve) {
var index = item._index; var index = item._index;
if (item._parent == this._parent && index > this._index) if (item._parent == this._parent && index > this._index)
index--; index--;
return item._parent.insertChild(index, this, _cloning); return item._parent.insertChild(index, this, _preserve);
}, },
/** /**

View file

@ -60,7 +60,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
this.addChildren(Array.isArray(arg) ? arg : arguments); this.addChildren(Array.isArray(arg) ? arg : arguments);
}, },
insertChild: function(index, item, _cloning) { insertChild: function(index, item, _preserve) {
// Only allow the insertion of paths // Only allow the insertion of paths
if (item._type !== 'path') if (item._type !== 'path')
return null; return null;
@ -69,7 +69,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath#
// to anti-clockwise orientation, so that they appear as holes, but // to anti-clockwise orientation, so that they appear as holes, but
// only if their orientation was not already specified before // only if their orientation was not already specified before
// (= _clockwise is defined). // (= _clockwise is defined).
if (!_cloning && item && item._clockwise === undefined) if (!_preserve && item && item._clockwise === undefined)
item.setClockwise(item._index == 0); item.setClockwise(item._index == 0);
return item; return item;
}, },

View file

@ -1069,7 +1069,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
// will happen below. // will happen below.
path = this; path = this;
} else if (index > 0) { } else if (index > 0) {
// Pass true for _cloning, in case of CompoundPath, to avoid // Pass true for _preserve, in case of CompoundPath, to avoid
// reversing of path direction, which would mess with segs! // reversing of path direction, which would mess with segs!
// Use _clone to copy over all other attributes, including style // Use _clone to copy over all other attributes, including style
path = this._clone(new Path().insertAbove(this, true)); path = this._clone(new Path().insertAbove(this, true));