From a75947d69f571d723552f926f94d195514a01cbd Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 12 Jun 2012 23:04:07 -0700 Subject: fixed document switching issues Signed-off-by: Valerio Virgillito --- .../layout/bread-crumb.reel/bread-crumb.js | 1 + js/controllers/selection-controller.js | 31 +++------------------- js/ninja.reel/ninja.html | 3 +-- js/tools/SelectionTool.js | 1 + 4 files changed, 7 insertions(+), 29 deletions(-) (limited to 'js') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index 2f493102..a3c743a4 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -105,6 +105,7 @@ exports.Breadcrumb = Montage.create(Component, { // TODO: This is bound 2 ways, update the internal property this.currentDocument.model.domContainer = this.containerElements[i].node; + this.application.ninja.selectionController.executeSelectElement(); } } }); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 6d982e69..b327bea4 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -34,13 +34,14 @@ exports.SelectionController = Montage.create(Component, { } if(this._currentDocument && this._currentDocument.currentView === "design") { - this.ignoreFlag = false; this._currentDocument.model._selection = this.application.ninja.selectedElements; -// this._currentDocument.model.selectionContainer = this.application.ninja._currentSelectedContainer; } this._currentDocument = value; + if(this._currentDocument && this._currentDocument.currentView === "design") { + this.selectedElements = this._currentDocument.model.selection; + } /* if(!value) { } else if(this._currentDocument.currentView === "design") { @@ -51,10 +52,6 @@ exports.SelectionController = Montage.create(Component, { } }, - ignoreFlag: { - value: true - }, - _selectedElements: { value: null }, @@ -64,21 +61,17 @@ exports.SelectionController = Montage.create(Component, { return this._selectedElements; }, set: function(value) { - if(this.currentDocument && this.currentDocument.currentView === "code") return; 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); } - - } } }, @@ -89,22 +82,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.addPropertyChangeListener("currentDocument.model.domContainer", this); - } - }, - - handleChange: { - value: function() { - if(this.ignoreFlag) { - if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) { - if(this.currentDocument.model.getProperty("domContainer") !== null) { - this.executeSelectElement(); - } - } - } else { - this.ignoreFlag = true; - } } }, @@ -134,7 +111,7 @@ exports.SelectionController = Montage.create(Component, { value: function(event) { var selected = [], childNodes = [], self = this; - childNodes = this.application.ninja.currentDocument.model.documentRoot.childNodes; + childNodes = this.currentDocument.model.domContainer.childNodes; childNodes = Array.prototype.slice.call(childNodes, 0); childNodes.forEach(function(item) { if(self.isNodeTraversable(item)) { diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index 00740ea9..405f57da 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -291,8 +291,7 @@ "selectionController": { "prototype": "js/controllers/selection-controller", "bindings" : { - "currentDocument": {"<-": "@documentList.selectedObjects.0"}, - "selectedElements": {"<-": "@documentList.selectedObjects.0.model.selection"} + "currentDocument": {"<-": "@documentList.selectedObjects.0"} } }, diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 493f4aa2..8b644d4a 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -228,6 +228,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } else { this.application.ninja.currentDocument.model.domContainer = this.application.ninja.currentDocument.model.documentRoot; } + this.application.ninja.selectionController.executeSelectElement(); } }, -- cgit v1.2.3