From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 00:34:40 -0700 Subject: document bindings phase 1 - using array controller to bind the current document to all ninja components - removed open document event - removed references to the document controller Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 61 +++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 75bffc5c..db8bdf51 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -20,6 +20,41 @@ exports.SelectionController = Montage.create(Component, { } }, + _currentDocument: { + value : null, + enumerable : false + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + this._currentDocument = value; + + if(this._currentDocument.currentView === "design") { + + /* + this._isDocument = true; + + if(currentSelectionArray) { + this.application.ninja.selectedElements = currentSelectionArray; + if(currentSelectionArray.length) { + this._isDocument = false; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); + } + } + + this._selectionContainer = this.application.ninja.currentSelectedContainer; + */ + } + } + }, + /* * Bound property to the ninja currentSelectedContainer */ @@ -52,32 +87,6 @@ exports.SelectionController = Montage.create(Component, { } }, - /** - * Get the current document selection array. If nothing is selected the currentSelectionArray should be null - */ - handleOpenDocument: { - value: function() { - // Handle initializing the selection array here. - this.initWithDocument([]); - } - }, - - initWithDocument: { - value: function(currentSelectionArray) { - this._isDocument = true; - - if(currentSelectionArray) { - this.application.ninja.selectedElements = currentSelectionArray; - if(currentSelectionArray.length) { - this._isDocument = false; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); - } - } - - this._selectionContainer = this.application.ninja.currentSelectedContainer; - } - }, - handleSwitchDocument: { value: function() { // if(this.application.ninja.documentController.activeDocument.currentView === "design"){ -- cgit v1.2.3 From 4fa08fe2ce439a5f5c248c568f72d3828ee11b36 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 29 May 2012 11:43:55 -0700 Subject: fix for the document tab close button and rulers on initial document Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 40 +--------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index db8bdf51..0d34ff25 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -20,44 +20,7 @@ exports.SelectionController = Montage.create(Component, { } }, - _currentDocument: { - value : null, - enumerable : false - }, - - currentDocument : { - get : function() { - return this._currentDocument; - }, - set : function(value) { - if (value === this._currentDocument) { - return; - } - - this._currentDocument = value; - - if(this._currentDocument.currentView === "design") { - - /* - this._isDocument = true; - - if(currentSelectionArray) { - this.application.ninja.selectedElements = currentSelectionArray; - if(currentSelectionArray.length) { - this._isDocument = false; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); - } - } - - this._selectionContainer = this.application.ninja.currentSelectedContainer; - */ - } - } - }, - - /* - * Bound property to the ninja currentSelectedContainer - */ + // Bound property to the ninja currentSelectedContainer _selectionContainer: { value: null }, @@ -77,7 +40,6 @@ exports.SelectionController = Montage.create(Component, { deserializedFromTemplate: { value: function() { - this.eventManager.addEventListener("openDocument", this, false); this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementsRemoved", this, false); this.eventManager.addEventListener("elementReplaced", this, false); -- cgit v1.2.3 From 31b094ee21102f99a4021d505bc3a28527c9e23d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 01:33:20 -0700 Subject: Fixing the close document. Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 0d34ff25..848355da 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -45,7 +45,6 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("elementReplaced", this, false); this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("switchDocument", this, false); - this.eventManager.addEventListener("closeDocument", this, false); } }, -- cgit v1.2.3 From e1fe603a7c002073f8ac13623f8cc8dc43efb59d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 10:27:46 -0700 Subject: fixing selection when switching documents Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 64 ++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 10 deletions(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 848355da..a219c597 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -20,6 +20,60 @@ exports.SelectionController = Montage.create(Component, { } }, + _currentDocument: { + value : null + }, + + currentDocument : { + get : function() { + return this._currentDocument; + }, + set : function(value) { + if (value === this._currentDocument) { + return; + } + + if(this._currentDocument) { + this._currentDocument.model.selection = this.application.ninja.selectedElements; + this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; + } + + this._currentDocument = value; + + if(!value) { + } else if(this._currentDocument.currentView === "design") { + } else { + } + + } + }, + + _selectedElements: { + value: null + }, + + selectedElements: { + get: function() { + return this._selectedElements; + }, + set: function(value) { + if(value) { + this._selectedElements = value; + + this.application.ninja.selectedElements = this._selectedElements; + this.application.ninja._currentSelectedContainer = this._selectionContainer = this.application.ninja.currentDocument.model.documentRoot; + + if(this._selectedElements.length === 0) { + this.executeSelectElement(); + } else { + this.executeSelectElement(this._selectedElements); + } + + + } + } + }, + // Bound property to the ninja currentSelectedContainer _selectionContainer: { value: null @@ -44,16 +98,6 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("elementsRemoved", this, false); this.eventManager.addEventListener("elementReplaced", this, false); this.eventManager.addEventListener("selectAll", this, false); - this.eventManager.addEventListener("switchDocument", this, false); - } - }, - - handleSwitchDocument: { - value: function() { -// if(this.application.ninja.documentController.activeDocument.currentView === "design"){ - this._isDocument = this.application.ninja.selectedElements.length === 0; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); -// } } }, -- cgit v1.2.3 From ffe6c157279e115f4658d8c66622085f05cfbf43 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 31 May 2012 15:27:03 -0700 Subject: fixing the switching between various types of documents Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index a219c597..28c0f3d3 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -33,17 +33,19 @@ exports.SelectionController = Montage.create(Component, { return; } - if(this._currentDocument) { + if(this._currentDocument && this._currentDocument.currentView === "design") { this._currentDocument.model.selection = this.application.ninja.selectedElements; this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; } this._currentDocument = value; + /* if(!value) { } else if(this._currentDocument.currentView === "design") { } else { } + */ } }, @@ -57,6 +59,8 @@ exports.SelectionController = Montage.create(Component, { return this._selectedElements; }, set: function(value) { + if(this.currentDocument && this.currentDocument.currentView === "code") return; + if(value) { this._selectedElements = value; -- cgit v1.2.3 From 75fc82ce49d6f1eb05dc950b46292d42b5856005 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 1 Jun 2012 16:19:04 -0700 Subject: fixing some selection container changes and the breadcrumb not drawing initially Signed-off-by: Valerio Virgillito --- js/controllers/selection-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/controllers/selection-controller.js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 28c0f3d3..4bca0755 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -34,7 +34,7 @@ exports.SelectionController = Montage.create(Component, { } if(this._currentDocument && this._currentDocument.currentView === "design") { - this._currentDocument.model.selection = this.application.ninja.selectedElements; + this._currentDocument.model._selection = this.application.ninja.selectedElements; this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; } -- cgit v1.2.3