From 32f04f6162b904bbfea08859ec077546798897ae Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Thu, 28 Apr 2011 11:54:26 +0200 Subject: [PATCH] Document: implement selectAll() and deselectAll(). --- src/document/Document.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/document/Document.js b/src/document/Document.js index f2e975d4..3dd00a0a 100644 --- a/src/document/Document.js +++ b/src/document/Document.js @@ -80,6 +80,26 @@ var Document = this.Document = Base.extend({ } }, + /** + * Selects all items in the document. + */ + selectAll: function() { + // TODO: is using for var i in good practice? + // or should we use Base.each? (JP) + for (var i = 0, l = this.layers.length; i < l; i++) + this.layers[i].setSelected(true); + }, + + /** + * Deselects all selected items in the document. + */ + deselectAll: function() { + // TODO: is using for var i in good practice? + // or should we use Base.each? (JP) + for (var i in this._selectedItems) + this._selectedItems[i].setSelected(false); + }, + draw: function() { if (this.canvas) { var ctx = this.context;