aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-05-18 09:52:15 -0700
committerJose Antonio Marquez2012-05-18 09:52:15 -0700
commit6c70c8bf28c2239d29f3abecc8a7ea59b2860bab (patch)
treec506b28bc82f74072f324d920105737726d5ecaf /js/controllers/document-controller.js
parent015df99dff8306f8839affd22cdd7689eb00e180 (diff)
parent24d1873302b2fffc25d254e15e8aa36f59eedb88 (diff)
downloadninja-6c70c8bf28c2239d29f3abecc8a7ea59b2860bab.tar.gz
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js78
1 files changed, 37 insertions, 41 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index cf46e73e..f1523d87 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -177,8 +177,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
177 value: function(event) { 177 value: function(event) {
178 var saveAsSettings = event._event.settings || {}; 178 var saveAsSettings = event._event.settings || {};
179 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 179 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
180 saveAsSettings.fileName = this.activeDocument.name; 180 saveAsSettings.fileName = this.activeDocument.model.file.name;
181 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); 181 saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/"));
182 saveAsSettings.callback = this.saveAsCallback.bind(this); 182 saveAsSettings.callback = this.saveAsCallback.bind(this);
183 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); 183 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings);
184 } 184 }
@@ -454,58 +454,54 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
454 // Open document callback 454 // Open document callback
455 _onOpenDocument: { 455 _onOpenDocument: {
456 value: function(doc){ 456 value: function(doc){
457 457 var currentDocument;
458 if(this.activeDocument) { 458 if(this.activeDocument) {
459 // There is a document currently opened 459 // There is a document currently opened
460 currentDocument = this.activeDocument;
460 461
461
462
463 //this.application.ninja.stage.stageView.showCodeViewBar(false);
464 //this.application.ninja.stage.stageView.restoreAllPanels(); 462 //this.application.ninja.stage.stageView.restoreAllPanels();
465
466 //
467 /*
468 if(this.activeDocument.currentView === "design"){
469 this.activeDocument.saveAppState();
470 this.activeDocument.container.parentNode.style["display"] = "none";
471 this.application.ninja.stage.hideCanvas(true);
472 this.application.ninja.stage.stageView.hideRulers();
473 }
474
475 this.activeDocument.container.style["display"] = "none";
476 */
477
478 /*
479 this.activeDocument.container.style["display"] = "block";
480 if(this.activeDocument.currentView === "design"){
481 this.activeDocument.container.parentNode.style["display"] = "block";
482 this.activeDocument.restoreAppState();
483 }else{
484 //hide the iframe when switching to code view
485 document.getElementById("iframeContainer").style.display = "none";
486 }
487
488 */
489 // hide current document
490 } else { 463 } else {
491 // There is no document opened 464 // There is no document opened
492 465
493 // Set the active document 466 // Show the rulers
494 this.activeDocument = doc; 467 // TODO: Move this indo design view
468 this.application.ninja.stage.stageView.showRulers();
495 469
496 // Show the canvas 470 // Show the canvas
497 this.application.ninja.stage.hideCanvas(false); 471 this.application.ninja.stage.hideCanvas(false);
472 }
498 473
499 // Show the rulers 474 // Set the active document
500 // TODO: Move this indo design view 475 this.activeDocument = doc;
501 this.application.ninja.stage.stageView.showRulers(); 476
477 // Initialize the documentRoot styles
478 this.initializeRootStyles(doc.documentRoot);
479 // Flag to stop stylesheet dirty event
480 this._hackInitialStyles = false;
481
482 this.switchDocuments(currentDocument, doc, true);
483 }
484 },
502 485
503 // Initialize the documentRoot styles 486 switchDocuments: {
504 this.initializeRootStyles(doc.documentRoot); 487 value: function(currentDocument, newDocument, didCreate) {
505 // Flag to stop stylesheet dirty event
506 this._hackInitialStyles = false;
507 488
508 NJevent("onOpenDocument", doc); 489 if(currentDocument) {
490 currentDocument.serializeDocument();
491
492 currentDocument.model.views.design.hide();
493 }
494
495 this.application.ninja.stage.clearAllCanvas();
496
497 if(didCreate) {
498 newDocument.model.views.design.iframe.style.opacity = 1;
499 NJevent("onOpenDocument", newDocument);
500 } else {
501 this.activeDocument = newDocument;
502 newDocument.model.views.design.show();
503 newDocument.deserializeDocument();
504 NJevent("onSwitchDocument");
509 } 505 }
510 } 506 }
511 }, 507 },