From 9e4ee2470726e3334eb47d904a6f4079d4ed7aef Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 17:01:39 -0800 Subject: IKNINJA-1270: fixed browser crashing when you close a document while playing a video then wait for a while Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 9 +++++++++ js/controllers/selection-controller.js | 13 +++++++++++++ 2 files changed, 22 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index e29148c9..de080167 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -363,14 +363,23 @@ var DocumentController = exports.DocumentController = Montage.create(Component, nextDocumentIndex = closeDocumentIndex - 1; } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); + doc.stopVideos(); this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ + if(typeof this.activeDocument.pauseVideos !== "undefined"){ + this.activeDocument.pauseVideos(true); + } this.activeDocument = null; this._removeDocumentView(doc.container); this.application.ninja.stage.stageView.hideRulers(); document.getElementById("iframeContainer").style.display="block"; this.application.ninja.stage.hideCanvas(true); + }else{//closing inactive document tab - just clear DOM + if(typeof doc.pauseVideos !== "undefined"){ + doc.pauseVideos(true); + } + this._removeDocumentView(doc.container); } NJevent("closeDocument", doc.uri); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 3f9d8514..49bf42b6 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -48,6 +48,7 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("deleteSelection", this, false); this.eventManager.addEventListener("switchDocument", this, false); + this.eventManager.addEventListener("closeDocument", this, false); // defaultEventManager.addEventListener( "undo", this, false); // defaultEventManager.addEventListener( "redo", this, false); } @@ -105,6 +106,18 @@ exports.SelectionController = Montage.create(Component, { } }, + handleCloseDocument:{ + value: function() { + //clear selections if all documents are closed + if(this.application.ninja.documentController._documents.length === 0){ + this._selectedItems.length =0; + this.application.ninja.selectedElements.length =0; + this._isDocument = true; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + } + } + }, + handleElementAdded: { value: function(event) { this.executeSelectElement(event.detail); -- cgit v1.2.3