aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/document-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/document-controller.js')
-rwxr-xr-xjs/controllers/document-controller.js95
1 files changed, 47 insertions, 48 deletions
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js
index a795d652..86b1d057 100755
--- a/js/controllers/document-controller.js
+++ b/js/controllers/document-controller.js
@@ -146,18 +146,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
146 value: function(event) { 146 value: function(event) {
147 // 147 //
148 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 148 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
149 // 149 //Currently we don't need a callback handler
150 this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) 150 //this.activeDocument.model.save(this.saveExecuted.bind(this));
151 this.activeDocument.model.save();
151 } else { 152 } else {
152 //Error: 153 //Error: cloud not available and/or no active document
153 } 154 }
154 } 155 }
155 }, 156 },
156 testCallback: { 157 ////////////////////////////////////////////////////////////////////
158 //
159 saveExecuted: {
157 value: function (value) { 160 value: function (value) {
158 console.log(value); 161 //File saved, any callbacks or events should go here
159 //TODO: Move this to the model.save()
160 this.activeDocument.model.needsSave = false;
161 } 162 }
162 }, 163 },
163 //////////////////////////////////////////////////////////////////// 164 ////////////////////////////////////////////////////////////////////
@@ -178,8 +179,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
178 value: function(event) { 179 value: function(event) {
179 var saveAsSettings = event._event.settings || {}; 180 var saveAsSettings = event._event.settings || {};
180 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ 181 if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){
181 saveAsSettings.fileName = this.activeDocument.name; 182 saveAsSettings.fileName = this.activeDocument.model.file.name;
182 saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); 183 saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/"));
183 saveAsSettings.callback = this.saveAsCallback.bind(this); 184 saveAsSettings.callback = this.saveAsCallback.bind(this);
184 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); 185 this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings);
185 } 186 }
@@ -453,58 +454,56 @@ var DocumentController = exports.DocumentController = Montage.create(Component,
453 // Open document callback 454 // Open document callback
454 _onOpenDocument: { 455 _onOpenDocument: {
455 value: function(doc){ 456 value: function(doc){
456 457 var currentDocument;
457 if(this.activeDocument) { 458 if(this.activeDocument) {
458 // There is a document currently opened 459 // There is a document currently opened
460 currentDocument = this.activeDocument;
459 461
460
461
462 //this.application.ninja.stage.stageView.showCodeViewBar(false);
463 //this.application.ninja.stage.stageView.restoreAllPanels(); 462 //this.application.ninja.stage.stageView.restoreAllPanels();
464
465 //
466 /*
467 if(this.activeDocument.currentView === "design"){
468 this.activeDocument.saveAppState();
469 this.activeDocument.container.parentNode.style["display"] = "none";
470 this.application.ninja.stage.hideCanvas(true);
471 this.application.ninja.stage.stageView.hideRulers();
472 }
473
474 this.activeDocument.container.style["display"] = "none";
475 */
476
477 /*
478 this.activeDocument.container.style["display"] = "block";
479 if(this.activeDocument.currentView === "design"){
480 this.activeDocument.container.parentNode.style["display"] = "block";
481 this.activeDocument.restoreAppState();
482 }else{
483 //hide the iframe when switching to code view
484 document.getElementById("iframeContainer").style.display = "none";
485 }
486
487 */
488 // hide current document
489 } else { 463 } else {
490 // There is no document opened 464 // There is no document opened
491 465
492 // Set the active document 466 // Show the rulers
493 this.activeDocument = doc; 467 // TODO: Move this indo design view
468 this.application.ninja.stage.stageView.showRulers();
494 469
495 // Show the canvas 470 // Show the canvas
496 this.application.ninja.stage.hideCanvas(false); 471 this.application.ninja.stage.hideCanvas(false);
472 }
497 473
498 // Show the rulers 474 // Set the active document
499 // TODO: Move this indo design view 475 this.activeDocument = doc;
500 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;
501 481
502 // Initialize the documentRoot styles 482 this.switchDocuments(currentDocument, doc, true);
503 this.initializeRootStyles(doc.documentRoot); 483 }
504 // Flag to stop stylesheet dirty event 484 },
505 this._hackInitialStyles = false; 485
486 switchDocuments: {
487 value: function(currentDocument, newDocument, didCreate) {
488
489 if(currentDocument) {
490 currentDocument.serializeDocument();
506 491
507 NJevent("onOpenDocument", doc); 492 this.application.ninja.selectionController._selectionContainer = null;
493 currentDocument.model.views.design.propertiesPanel.clear();
494 currentDocument.model.views.design.hide();
495 }
496
497 this.application.ninja.stage.clearAllCanvas();
498
499 if(didCreate) {
500 newDocument.model.views.design.iframe.style.opacity = 1;
501 NJevent("onOpenDocument", newDocument);
502 } else {
503 this.activeDocument = newDocument;
504 newDocument.model.views.design.show();
505 newDocument.deserializeDocument();
506 NJevent("onSwitchDocument");
508 } 507 }
509 } 508 }
510 }, 509 },