Implement Project#clear().

This commit is contained in:
Jürg Lehni 2013-04-22 22:48:36 -07:00
parent 885d75296d
commit 1b61e4333c
2 changed files with 11 additions and 0 deletions

View file

@ -73,6 +73,9 @@ var Layer = this.Layer = Group.extend(/** @lends Layer# */{
if (this._parent)
return this.base(notify);
if (this._index != null) {
if (this._project.activeLayer === this)
this._project.activeLayer = this.getNextSibling()
|| this.getPreviousSibling();
Base.splice(this._project.layers, null, this._index, 1);
// Tell project we need a redraw. This is similar to _changed()
// mechanism.

View file

@ -85,6 +85,14 @@ var Project = this.Project = PaperScopeItem.extend(/** @lends Project# */{
* @function
*/
// DOCS: Project#clear()
clear: function() {
for (var i = 0; i < this.layers.length; i++)
this.layers[i].remove();
this.symbols = [];
},
/**
* Removes this project from the {@link PaperScope#projects} list, and also
* removes its view, if one was defined.