From 4937b39fb0cf542f57cdadc7d1e2ed9798f7ef87 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 15 Feb 2012 16:09:14 -0800 Subject: fixes to document tabbing Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index f397ace7..b1a22c1b 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -34,17 +34,17 @@ DocumentController = exports.DocumentController = Montage.create(Component, { return this._activeDocument; }, set: function(doc) { - if(this._activeDocument) this._activeDocument.isActive = false; - - if(this._documents.indexOf(doc) === -1) this._documents.push(doc); + if(!!this._activeDocument) this._activeDocument.isActive = false; this._activeDocument = doc; - this._activeDocument.isActive = true; + if(!!this._activeDocument){ - if(!!this._activeDocument.editor){ - this._activeDocument.editor.focus(); + if(this._documents.indexOf(doc) === -1) this._documents.push(doc); + this._activeDocument.isActive = true; + if(!!this._activeDocument.editor){ + this._activeDocument.editor.focus(); + } } - } }, @@ -184,7 +184,7 @@ DocumentController = exports.DocumentController = Montage.create(Component, { switch (doc.extension) { case 'html': case 'html': //Open in designer view - Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument); + Montage.create(HTMLDocument).initialize(doc, Uuid.generate(), this._createIframeElement(), this._onOpenDocument.bind(this)); break; default: //Open in code view @@ -250,7 +250,6 @@ DocumentController = exports.DocumentController = Montage.create(Component, { } var doc = this._findDocumentByUUID(id); - this._removeDocumentView(doc.container); var closeDocumentIndex = this._findIndexByUUID(id); this._documents.splice(this._findIndexByUUID(id), 1); @@ -263,8 +262,11 @@ DocumentController = exports.DocumentController = Montage.create(Component, { nextDocumentIndex = closeDocumentIndex - 1; } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); + this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ - //if there are no documents to switch to then just show the iframeContainer + this.activeDocument = null; + this._removeDocumentView(doc.container); + this.application.ninja.stage.stageView.hideRulers(); document.getElementById("iframeContainer").style.display="block"; } } @@ -275,11 +277,15 @@ DocumentController = exports.DocumentController = Montage.create(Component, { _onOpenDocument: { value: function(doc){ //var data = DocumentManager.activeDocument; - //DocumentManager._hideCurrentDocument(); - //stageManagerModule.stageManager.toggleCanvas(); + this._hideCurrentDocument(); + this.application.ninja.stage.stageView.hideOtherDocuments(doc.uuid); + + this.application.ninja.stage.hideCanvas(false); + + this.activeDocument = doc; - DocumentController.activeDocument = doc; + this._showCurrentDocument(); NJevent("onOpenDocument", doc); // appDelegateModule.MyAppDelegate.onSetActiveDocument(); -- cgit v1.2.3