Simplify and compress code a bit.

This commit is contained in:
Jürg Lehni 2011-04-27 17:53:23 +01:00
parent 0700c51a85
commit 4bfc56bb6d

View file

@ -190,22 +190,15 @@ var Segment = this.Segment = Base.extend({
// If the selection state of the segment has changed, we need to let // If the selection state of the segment has changed, we need to let
// it's path know and possibly add or remove it from // it's path know and possibly add or remove it from
// document._selectedItems // document._selectedItems
if (wasSelected == !this._selectionState) { if (wasSelected != !!this._selectionState) {
var path = this._path, var path = this._path,
selectedItems = path._document._selectedItems; count = path._selectedSegmentCount
if (!this._selectionState) { += this._selectionState ? 1 : -1;
path._selectedSegmentCount--; if (count <= 1)
if (path._selectedSegmentCount == 0) path._document._selectItem(path, count == 1);
path._document._selectItem(path, false); }
} else {
path._selectedSegmentCount++;
if (path._selectedSegmentCount == 1)
path._document._selectItem(path, true);
}
}
}, },
// TODO: Port setSelected(selected) back to Scriptographer
isSelected: function() { isSelected: function() {
return this._isSelected(this._point); return this._isSelected(this._point);
}, },