From 2364c671ffc2953e3ee8dfdf037244de8fab3920 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:30:33 -0800 Subject: IKNINJA-1238 fix and fixing other js errors on switching and closing documents Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 21 ++++++++++++++++++++- js/controllers/selection-controller.js | 18 ++++++++++-------- js/stage/stage-view.reel/stage-view.js | 5 ++++- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 194496a6..1f8c58b0 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -61,7 +61,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("executeSaveAs", this, false); this.eventManager.addEventListener("executeSaveAll", this, false); - this.eventManager.addEventListener("recordStyleChanged", this, false); + this.eventManager.addEventListener("styleSheetDirty", this, false); } }, @@ -168,6 +168,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function (result) { if(result.status === 204){ this.activeDocument.needsSave = false; + if(this.application.ninja.currentDocument !== null){ + //clear Dirty StyleSheets for the saved document + this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); + } } } }, @@ -249,6 +253,15 @@ var DocumentController = exports.DocumentController = Montage.create(Component, }, //////////////////////////////////////////////////////////////////// // + saveAsCallback:{ + value:function(){ + //close current document + + //create a new file + } + }, + + //////////////////////////////////////////////////////////////////// openDocument: { value: function(doc) { @@ -506,5 +519,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function() { return "userDocument_" + (this._iframeCounter++); } + }, + + handleStyleSheetDirty:{ + value:function(){ + this.activeDocument.needsSave = true; } + } }); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 08eb018f..3f9d8514 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -91,15 +91,17 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { - this._selectedItems = this.application.ninja.selectedElements.slice(0); - if(this._selectedItems.length === 0 ){ - this._isDocument = true; - }else{ - this._isDocument = false; - } - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + if(this.application.ninja.documentController.activeDocument.currentView === "design"){ + this._selectedItems = this.application.ninja.selectedElements.slice(0); + if(this._selectedItems.length === 0 ){ + this._isDocument = true; + }else{ + this._isDocument = false; + } + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - this._selectionContainer = this.application.ninja.currentSelectedContainer; + this._selectionContainer = this.application.ninja.currentSelectedContainer; + } } }, diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 91047e51..ad67cada 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -125,6 +125,10 @@ exports.StageView = Montage.create(Component, { this.application.ninja.documentController.activeDocument = doc; + if(this.application.ninja.documentController.activeDocument.currentView === "design") { + this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; + } + this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe this.application.ninja.documentController._showCurrentDocument(); @@ -135,7 +139,6 @@ exports.StageView = Montage.create(Component, { if(this.application.ninja.documentController.activeDocument.currentView === "design") { this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe - this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; //reinitialize draw-util, snapmanager and view-util this.application.ninja.stage.stageDeps.reinitializeForSwitchDocument(); -- cgit v1.2.3