aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js72
-rwxr-xr-xjs/controllers/selection-controller.js1
2 files changed, 9 insertions, 64 deletions
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, {
31 return this._currentDocument; 31 return this._currentDocument;
32 }, 32 },
33 set : function(value) { 33 set : function(value) {
34 if (value === this._currentDocument || value.getProperty("currentView") !== "design") { 34 if (value === this._currentDocument) {
35 return; 35 return;
36 } 36 }
37 37
@@ -41,7 +41,13 @@ exports.DocumentController = Montage.create(Component, {
41 41
42 this._currentDocument = value; 42 this._currentDocument = value;
43 43
44 this._currentDocument.model.currentView.show(); 44 if(!value) {
45
46 } else {
47 this._currentDocument.model.currentView.show();
48 }
49
50
45 51
46 } 52 }
47 }, 53 },
@@ -323,7 +329,7 @@ exports.DocumentController = Montage.create(Component, {
323 329
324 closeFile: { 330 closeFile: {
325 value: function(document) { 331 value: function(document) {
326 document.closeDocument(this, this.onCloseFile); 332 document.closeDocument(this.application.ninja, this.application.ninja.closeFile);
327 } 333 }
328 }, 334 },
329 335
@@ -357,39 +363,6 @@ exports.DocumentController = Montage.create(Component, {
357 } 363 }
358 }, 364 },
359 365
360 closeDocument: {
361 value: function(id) {
362 var doc = this._findDocumentByUUID(id);
363
364 var closeDocumentIndex = this._findIndexByUUID(id);
365 this._documents.splice(this._findIndexByUUID(id), 1);
366
367 if(this.activeDocument.uuid === id && this._documents.length > 0) {//closing the active document tab
368 var nextDocumentIndex = -1 ;
369 if((this._documents.length > 0) && (closeDocumentIndex === 0)){
370 nextDocumentIndex = 0;
371 }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){
372 nextDocumentIndex = closeDocumentIndex - 1;
373 }
374 this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]);
375 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();}
376 doc.container.parentNode.removeChild(doc.container);
377 }else if(this._documents.length === 0){
378 // See above
379 }else{//closing inactive document tab - just clear DOM
380 if(typeof doc.pauseAndStopVideos !== "undefined"){
381 doc.pauseAndStopVideos();
382 }
383 doc.container.parentNode.removeChild(doc.container);
384 }
385
386 NJevent("closeDocument", doc.uri);
387
388 doc=null;
389 }
390 },
391
392
393 _onOpenTextDocument: { 366 _onOpenTextDocument: {
394 value: function(doc) { 367 value: function(doc) {
395 368
@@ -462,32 +435,5 @@ exports.DocumentController = Montage.create(Component, {
462 } 435 }
463 } 436 }
464 } 437 }
465 },
466
467 /**
468 * VIEW Related Methods
469 */
470
471 // PRIVATE
472 _findDocumentByUUID: {
473 value: function(uuid) {
474 var len = this._documents.length;
475 for(var i = 0; i < len; i++) {
476 if(this._documents[i].uuid === uuid) return this._documents[i];
477 }
478
479 return false;
480 }
481 },
482
483 _findIndexByUUID: {
484 value: function(uuid) {
485 var len = this._documents.length;
486 for(var i = 0; i < len; i++) {
487 if(this._documents[i].uuid === uuid) return i;
488 }
489
490 return false;
491 }
492 } 438 }
493}); 439});
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, {
45 this.eventManager.addEventListener("elementReplaced", this, false); 45 this.eventManager.addEventListener("elementReplaced", this, false);
46 this.eventManager.addEventListener("selectAll", this, false); 46 this.eventManager.addEventListener("selectAll", this, false);
47 this.eventManager.addEventListener("switchDocument", this, false); 47 this.eventManager.addEventListener("switchDocument", this, false);
48 this.eventManager.addEventListener("closeDocument", this, false);
49 } 48 }
50 }, 49 },
51 50