From 729bc48212d7244539c99ca206be673eed011115 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 6 Feb 2012 16:07:46 -0800 Subject: integrated save for the document tabs, detect codemirror history to show document dirty indicator. Signed-off-by: Ananya Sen --- js/io/document/document-controller.js | 19 +++++++++++++------ js/io/document/text-document.js | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'js/io/document') diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index 51575a24..1a5d6058 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js @@ -72,6 +72,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("appLoaded", this, false); this.eventManager.addEventListener("executeFileOpen", this, false); this.eventManager.addEventListener("executeNewFile", this, false); + this.eventManager.addEventListener("executeSave", this, false); } }, @@ -87,8 +88,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, pickerSettings.callback = this.openFileWithURI; pickerSettings.callbackScope = this; this.application.ninja.filePickerController.showFilePicker(pickerSettings); - - //this.openDocument({"type": "js", "source": this.tmpSourceForTesting}); } }, @@ -101,6 +100,12 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } }, + handleExecuteSave: { + value: function(event) { + this.activeDocument.save(); + } + }, + createNewFile:{ value:function(newFileObj){ //console.log(newFileObj);//contains the template uri and the new file uri @@ -240,7 +245,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //if file dirty then save if(this.activeDocument.dirtyFlag === true){ - this.activeDocument.save(true); + this.activeDocument.save(true /*remove the codemirror div after saving*/); this.activeDocument.dirtyFlag=false; } @@ -382,12 +387,13 @@ var DocumentController = exports.DocumentController = Montage.create(Component, _hideCurrentDocument: { value: function() { if(this.activeDocument) { - this.activeDocument.container.style["display"] = "none"; - if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ + if(this.activeDocument.currentView === "design"){ + this.application.ninja.stage.saveStageScroll(); this.activeDocument.container.parentNode.style["display"] = "none"; this.application.ninja.stage.hideCanvas(true); this.application.ninja.stage.stageView.hideRulers(); } + this.activeDocument.container.style["display"] = "none"; } } }, @@ -396,8 +402,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function() { if(this.activeDocument) { this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ + if(this.activeDocument.currentView === "design"){ this.activeDocument.container.parentNode.style["display"] = "block"; + this.application.ninja.stage.applySavedScroll(); this.application.ninja.stage.hideCanvas(false); this.application.ninja.stage.stageView.showRulers(); } diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index 683c513c..7db8e91a 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -100,6 +100,7 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} } + //console.log("$$$saved : "+this.uri+" : "+this.textArea.value); //persist to filesystem } } -- cgit v1.2.3