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 ++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) (limited to 'js/controllers') 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; + } } }, -- cgit v1.2.3