From 31b094ee21102f99a4021d505bc3a28527c9e23d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 30 May 2012 01:33:20 -0700 Subject: Fixing the close document. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 72 +++++----------------------------- js/controllers/selection-controller.js | 1 - 2 files changed, 9 insertions(+), 64 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index eba950b9..4f122b3b 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -31,7 +31,7 @@ exports.DocumentController = Montage.create(Component, { return this._currentDocument; }, set : function(value) { - if (value === this._currentDocument || value.getProperty("currentView") !== "design") { + if (value === this._currentDocument) { return; } @@ -41,7 +41,13 @@ exports.DocumentController = Montage.create(Component, { this._currentDocument = value; - this._currentDocument.model.currentView.show(); + if(!value) { + + } else { + this._currentDocument.model.currentView.show(); + } + + } }, @@ -323,7 +329,7 @@ exports.DocumentController = Montage.create(Component, { closeFile: { value: function(document) { - document.closeDocument(this, this.onCloseFile); + document.closeDocument(this.application.ninja, this.application.ninja.closeFile); } }, @@ -357,39 +363,6 @@ exports.DocumentController = Montage.create(Component, { } }, - closeDocument: { - value: function(id) { - var doc = this._findDocumentByUUID(id); - - var closeDocumentIndex = this._findIndexByUUID(id); - this._documents.splice(this._findIndexByUUID(id), 1); - - if(this.activeDocument.uuid === id && this._documents.length > 0) {//closing the active document tab - var nextDocumentIndex = -1 ; - if((this._documents.length > 0) && (closeDocumentIndex === 0)){ - nextDocumentIndex = 0; - }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ - nextDocumentIndex = closeDocumentIndex - 1; - } - this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); - if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();} - doc.container.parentNode.removeChild(doc.container); - }else if(this._documents.length === 0){ - // See above - }else{//closing inactive document tab - just clear DOM - if(typeof doc.pauseAndStopVideos !== "undefined"){ - doc.pauseAndStopVideos(); - } - doc.container.parentNode.removeChild(doc.container); - } - - NJevent("closeDocument", doc.uri); - - doc=null; - } - }, - - _onOpenTextDocument: { value: function(doc) { @@ -462,32 +435,5 @@ exports.DocumentController = Montage.create(Component, { } } } - }, - - /** - * VIEW Related Methods - */ - - // PRIVATE - _findDocumentByUUID: { - value: function(uuid) { - var len = this._documents.length; - for(var i = 0; i < len; i++) { - if(this._documents[i].uuid === uuid) return this._documents[i]; - } - - return false; - } - }, - - _findIndexByUUID: { - value: function(uuid) { - var len = this._documents.length; - for(var i = 0; i < len; i++) { - if(this._documents[i].uuid === uuid) return i; - } - - return false; - } } }); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 0d34ff25..848355da 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -45,7 +45,6 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("elementReplaced", this, false); this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("switchDocument", this, false); - this.eventManager.addEventListener("closeDocument", this, false); } }, -- cgit v1.2.3