aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/document-controller.js78
-rwxr-xr-xjs/controllers/selection-controller.js4
2 files changed, 39 insertions, 43 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 },
diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js
index 6e40abb5..1092615a 100755
--- a/js/controllers/selection-controller.js
+++ b/js/controllers/selection-controller.js
@@ -81,10 +81,10 @@ exports.SelectionController = Montage.create(Component, {
81 81
82 handleSwitchDocument: { 82 handleSwitchDocument: {
83 value: function() { 83 value: function() {
84 if(this.application.ninja.documentController.activeDocument.currentView === "design"){ 84// if(this.application.ninja.documentController.activeDocument.currentView === "design"){
85 this._isDocument = this.application.ninja.selectedElements.length === 0; 85 this._isDocument = this.application.ninja.selectedElements.length === 0;
86 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); 86 NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} );
87 } 87// }
88 } 88 }
89 }, 89 },
90 90