From 7283884c39df537694b21419a3ea9e3ca7793b4b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 23 Feb 2012 13:43:35 -0800 Subject: switch html document - re-initialize draw-utils and snap-manager on opening a document and while switching documents Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 6 +++--- js/controllers/elements/element-controller.js | 6 +++++- js/controllers/selection-controller.js | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 48e33267..f323ed99 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -321,7 +321,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Event Detail: Contains the current ActiveDocument _onOpenDocument: { value: function(doc){ - //var data = DocumentManager.activeDocument; + this.application.ninja.currentDocument = doc; this._hideCurrentDocument(); this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); @@ -405,7 +405,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function() { if(this.activeDocument) { if(this.activeDocument.currentView === "design"){ - this.application.ninja.stage.saveScroll(); + this.activeDocument.saveAppState(); this.activeDocument.container.parentNode.style["display"] = "none"; this.application.ninja.stage.hideCanvas(true); this.application.ninja.stage.stageView.hideRulers(); @@ -422,7 +422,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument.container.style["display"] = "block"; if(this.activeDocument.currentView === "design"){ this.activeDocument.container.parentNode.style["display"] = "block"; - this.application.ninja.stage.restoreScroll(); + this.activeDocument.restoreAppState(); this.application.ninja.stage.hideCanvas(false); this.application.ninja.stage.stageView.showRulers(); }else{ diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index ac14def4..d6f2bc56 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -27,7 +27,11 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, getProperty: { value: function(el, prop, fallbackOnComputed, isStageElement) { - return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement); + if(el.nodeType !== 3){ + return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement); + }else{ + return null; + } } }, diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index d69b53e0..f50762f3 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -58,6 +58,7 @@ exports.SelectionController = Montage.create(Component, { handleOpenDocument: { value: function() { // Handle initializing the selection array here. + this.initWithDocument([]); } }, @@ -70,6 +71,14 @@ exports.SelectionController = Montage.create(Component, { if(currentSelectionArray.length >= 1) { this._selectedItems = currentSelectionArray; this._isDocument = false; + + + + this.application.ninja.selectedElements = currentSelectionArray; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + + + } } -- cgit v1.2.3