From 1b61e4333cc257036558ad1be4662485627a644b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 22 Apr 2013 22:48:36 -0700 Subject: [PATCH] Implement Project#clear(). --- src/item/Layer.js | 3 +++ src/project/Project.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/item/Layer.js b/src/item/Layer.js index 58de1751..ff2afaf0 100644 --- a/src/item/Layer.js +++ b/src/item/Layer.js @@ -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. diff --git a/src/project/Project.js b/src/project/Project.js index c6021acd..094cb7bc 100644 --- a/src/project/Project.js +++ b/src/project/Project.js @@ -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.