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