aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-15 23:34:52 -0700
committerValerio Virgillito2012-05-15 23:34:52 -0700
commit2b21e91a3343229bb87179e08be1e532fcf9b8f9 (patch)
tree5ae1e660d0e307fda84c3be6a66c243904d75225 /js/controllers/document-controller.js
parent012a6e8fa8bfb56e1a50f3b2fc6058f3651701a2 (diff)
parent9db5c446337e266fd604eac79ec39c840ffebbbe (diff)
downloadninja-2b21e91a3343229bb87179e08be1e532fcf9b8f9.tar.gz
Merge pull request #237 from mencio/dom-architecture
Dom architecture - Fixed closing and opening a document
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js66
1 files changed, 42 insertions, 24 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index 48ceb21b..fba9fad5 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -33,6 +33,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
33 value: false 33 value: false
34 }, 34 },
35 35
36 _hackInitialStyles: {
37 value: true
38 },
39
36 _activeDocument: { value: null }, 40 _activeDocument: { value: null },
37 _iframeCounter: { value: 1, enumerable: false }, 41 _iframeCounter: { value: 1, enumerable: false },
38 _iframeHolder: { value: null, enumerable: false }, 42 _iframeHolder: { value: null, enumerable: false },
@@ -44,8 +48,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
44 return this._activeDocument; 48 return this._activeDocument;
45 }, 49 },
46 set: function(doc) { 50 set: function(doc) {
47 if(!!this._activeDocument){ this._activeDocument.isActive = false;} 51// if(!!this._activeDocument){ this._activeDocument.isActive = false;}
52
48 this._activeDocument = doc; 53 this._activeDocument = doc;
54
49 if(!!this._activeDocument){ 55 if(!!this._activeDocument){
50 if(this._documents.indexOf(doc) === -1) this._documents.push(doc); 56 if(this._documents.indexOf(doc) === -1) this._documents.push(doc);
51 this._activeDocument.isActive = true; 57 this._activeDocument.isActive = true;
@@ -213,13 +219,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
213 handleExecuteFileClose:{ 219 handleExecuteFileClose:{
214 value: function(event) { 220 value: function(event) {
215 if (this.activeDocument) { 221 if (this.activeDocument) {
216 this.activeDocument.closeDocument(); 222// this.activeDocument.closeDocument();
223 this.closeFile(this.activeDocument);
217 } 224 }
218 /*
219if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
220 this.closeDocument(this.activeDocument.uuid);
221 }
222*/
223 } 225 }
224 }, 226 },
225 //////////////////////////////////////////////////////////////////// 227 ////////////////////////////////////////////////////////////////////
@@ -448,7 +450,32 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
448 */ 450 */
449 451
450 } 452 }
451 }, 453 },
454
455 closeFile: {
456 value: function(document) {
457 document.closeDocument(this, this.onCloseFile);
458 }
459 },
460
461 onCloseFile: {
462 value: function(doc) {
463
464 this._documents.splice(this._documents.indexOf(doc), 1);
465
466 this._activeDocument = null;
467
468 this.application.ninja.stage.stageView.hideRulers();
469
470// document.getElementById("iframeContainer").style.display="block";
471
472 this.application.ninja.stage.hideCanvas(true);
473
474
475 NJevent("closeDocument", doc.model.file.uri);
476 //TODO: Delete object here
477 }
478 },
452 479
453 closeDocument: { 480 closeDocument: {
454 value: function(id) { 481 value: function(id) {
@@ -468,15 +495,7 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
468 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();} 495 if(typeof doc.stopVideos !== "undefined"){doc.stopVideos();}
469 this._removeDocumentView(doc.container); 496 this._removeDocumentView(doc.container);
470 }else if(this._documents.length === 0){ 497 }else if(this._documents.length === 0){
471 if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ 498 // See above
472 this.activeDocument.pauseAndStopVideos();
473 }
474 this.activeDocument = null;
475 this._removeDocumentView(doc.container);
476 this.application.ninja.stage.stageView.hideRulers();
477 document.getElementById("iframeContainer").style.display="block";
478
479 this.application.ninja.stage.hideCanvas(true);
480 }else{//closing inactive document tab - just clear DOM 499 }else{//closing inactive document tab - just clear DOM
481 if(typeof doc.pauseAndStopVideos !== "undefined"){ 500 if(typeof doc.pauseAndStopVideos !== "undefined"){
482 doc.pauseAndStopVideos(); 501 doc.pauseAndStopVideos();
@@ -515,6 +534,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
515 534
516 this.application.ninja.stage.stageView.showCodeViewBar(false); 535 this.application.ninja.stage.stageView.showCodeViewBar(false);
517 this.application.ninja.stage.stageView.restoreAllPanels(); 536 this.application.ninja.stage.stageView.restoreAllPanels();
537
538 // Flag to stop stylesheet dirty event
539 this._hackInitialStyles = false;
518 } 540 }
519 }, 541 },
520 542
@@ -552,12 +574,6 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
552 /** 574 /**
553 * VIEW Related Methods 575 * VIEW Related Methods
554 */ 576 */
555 // PUBLIC
556 ShowActiveDocument: {
557 value: function() {
558 this.activeDocument.iframe.style.opacity = 1.0;
559 }
560 },
561 577
562 // PRIVATE 578 // PRIVATE
563 _findDocumentByUUID: { 579 _findDocumentByUUID: {
@@ -656,7 +672,9 @@ if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){
656 672
657 handleStyleSheetDirty:{ 673 handleStyleSheetDirty:{
658 value:function(){ 674 value:function(){
659// this.activeDocument.model.needsSave = true; 675 if(!this._hackInitialStyles) {
676 this.activeDocument.model.needsSave = true;
677 }
660 } 678 }
661 }, 679 },
662 680