From eff40602cac6821f8272177c24b6bf3de399f8b1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 17 May 2012 21:11:33 -0700 Subject: multiple documents - enable opening multiple documents and initial switching Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 71 +++++++++++++++++------------------ 1 file changed, 35 insertions(+), 36 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index cf46e73e..50874725 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -454,58 +454,57 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Open document callback _onOpenDocument: { value: function(doc){ - + var currentDocument; if(this.activeDocument) { // There is a document currently opened - - + currentDocument = this.activeDocument; //this.application.ninja.stage.stageView.showCodeViewBar(false); //this.application.ninja.stage.stageView.restoreAllPanels(); - // - /* - if(this.activeDocument.currentView === "design"){ - this.activeDocument.saveAppState(); - this.activeDocument.container.parentNode.style["display"] = "none"; - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.stageView.hideRulers(); - } + //this.activeDocument.saveAppState(); - this.activeDocument.container.style["display"] = "none"; - */ - - /* - this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design"){ - this.activeDocument.container.parentNode.style["display"] = "block"; - this.activeDocument.restoreAppState(); - }else{ - //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display = "none"; - } - - */ - // hide current document + // TODO: Do we need this? + //this.application.ninja.stage.hideCanvas(true); + //this.application.ninja.stage.stageView.hideRulers(); + + //this.activeDocument.restoreAppState(); } else { // There is no document opened - // Set the active document - this.activeDocument = doc; + // Show the rulers + // TODO: Move this indo design view + this.application.ninja.stage.stageView.showRulers(); // Show the canvas this.application.ninja.stage.hideCanvas(false); + } - // Show the rulers - // TODO: Move this indo design view - this.application.ninja.stage.stageView.showRulers(); - // Initialize the documentRoot styles - this.initializeRootStyles(doc.documentRoot); - // Flag to stop stylesheet dirty event - this._hackInitialStyles = false; + // Set the active document + this.activeDocument = doc; + + // Initialize the documentRoot styles + this.initializeRootStyles(doc.documentRoot); + // Flag to stop stylesheet dirty event + this._hackInitialStyles = false; + + this.switchDocuments(currentDocument, doc); + + NJevent("onOpenDocument", doc); + + //Setting opacity to be viewable after load + //doc.model.views.design.iframe.style.opacity = 1; + + } + }, + + switchDocuments: { + value: function(current, newDocument) { + newDocument.model.views.design.iframe.style.opacity = 1; - NJevent("onOpenDocument", doc); + if(current) { + current.model.views.design.hide(); } } }, -- cgit v1.2.3 From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 37 +++++++++++++++------------------- js/controllers/selection-controller.js | 4 ++-- 2 files changed, 18 insertions(+), 23 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 50874725..fc1f2c0f 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -459,16 +459,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // There is a document currently opened currentDocument = this.activeDocument; - //this.application.ninja.stage.stageView.showCodeViewBar(false); //this.application.ninja.stage.stageView.restoreAllPanels(); - - //this.activeDocument.saveAppState(); - - // TODO: Do we need this? - //this.application.ninja.stage.hideCanvas(true); - //this.application.ninja.stage.stageView.hideRulers(); - - //this.activeDocument.restoreAppState(); } else { // There is no document opened @@ -480,7 +471,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.hideCanvas(false); } - // Set the active document this.activeDocument = doc; @@ -489,22 +479,27 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // Flag to stop stylesheet dirty event this._hackInitialStyles = false; - this.switchDocuments(currentDocument, doc); - - NJevent("onOpenDocument", doc); - - //Setting opacity to be viewable after load - //doc.model.views.design.iframe.style.opacity = 1; - + this.switchDocuments(currentDocument, doc, true); } }, switchDocuments: { - value: function(current, newDocument) { - newDocument.model.views.design.iframe.style.opacity = 1; + value: function(currentDocument, newDocument, didCreate) { + + if(currentDocument) { + currentDocument.serializeDocument(); - if(current) { - current.model.views.design.hide(); + currentDocument.model.views.design.hide(); + } + + if(didCreate) { + newDocument.model.views.design.iframe.style.opacity = 1; + NJevent("onOpenDocument", newDocument); + } else { + this.activeDocument = newDocument; + newDocument.model.views.design.show(); + newDocument.deserializeDocument(); + NJevent("switchDocument"); } } }, 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, { handleSwitchDocument: { value: function() { - if(this.application.ninja.documentController.activeDocument.currentView === "design"){ +// if(this.application.ninja.documentController.activeDocument.currentView === "design"){ this._isDocument = this.application.ninja.selectedElements.length === 0; NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - } +// } } }, -- cgit v1.2.3 From e9dddef38507cafcf5702ce6a512b4005609acef Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 01:14:41 -0700 Subject: Fixing the save as paths Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index fc1f2c0f..ea4022b8 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -177,8 +177,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function(event) { var saveAsSettings = event._event.settings || {}; if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - saveAsSettings.fileName = this.activeDocument.name; - saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); + saveAsSettings.fileName = this.activeDocument.model.file.name; + saveAsSettings.folderUri = this.activeDocument.model.file.uri.substring(0, this.activeDocument.model.file.uri.lastIndexOf("/")); saveAsSettings.callback = this.saveAsCallback.bind(this); this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); } -- cgit v1.2.3 From 24d1873302b2fffc25d254e15e8aa36f59eedb88 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 01:36:05 -0700 Subject: fixed a switch documents bug where the layout was getting called before setting the container. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ea4022b8..f1523d87 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -492,6 +492,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, currentDocument.model.views.design.hide(); } + this.application.ninja.stage.clearAllCanvas(); + if(didCreate) { newDocument.model.views.design.iframe.style.opacity = 1; NJevent("onOpenDocument", newDocument); @@ -499,7 +501,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.activeDocument = newDocument; newDocument.model.views.design.show(); newDocument.deserializeDocument(); - NJevent("switchDocument"); + NJevent("onSwitchDocument"); } } }, -- cgit v1.2.3 From d878aa470074d5698a316512b513949fa22073f2 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Fri, 18 May 2012 15:23:15 -0700 Subject: Fixing save logic Moved dirty marker clearing code to model. --- js/controllers/document-controller.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index f1523d87..cf618360 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -145,18 +145,19 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function(event) { // if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ - // - this.activeDocument.model.save(this.testCallback.bind(this)); //this.fileSaveResult.bind(this) + //Currently we don't need a callback handler + //this.activeDocument.model.save(this.saveExecuted.bind(this)); + this.activeDocument.model.save(); } else { - //Error: + //Error: cloud not available and/or no active document } } }, - testCallback: { + //////////////////////////////////////////////////////////////////// + // + saveExecuted: { value: function (value) { - console.log(value); - //TODO: Move this to the model.save() - this.activeDocument.model.needsSave = false; + //File saved, any callbacks or events should go here } }, //////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From fdfba499f0b84360b96096fa866a981e96e8756c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 16:35:56 -0700 Subject: fixing the color chip for the document root Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 ++ js/controllers/elements/body-controller.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index f1523d87..7721d32d 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -489,6 +489,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(currentDocument) { currentDocument.serializeDocument(); + this.application.ninja.selectionController._selectionContainer = null; + currentDocument.model.views.design.propertiesPanel.clear(); currentDocument.model.views.design.hide(); } 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, { value: function(el, p) { switch(p) { case "background" : - return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", true, true)); + return this.application.ninja.colorController.getColorObjFromCss(this.application.ninja.stylesController.getElementStyle(el, "background-color", false, true)); case "border": return 0; case "height": -- cgit v1.2.3