From 272c5f74f4ce76fec9cbe360817bf23639307d3a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Sun, 5 Feb 2012 19:20:37 -0800 Subject: changes to show document dirty indicator on editing code view, and to remove dirty indicator on save. Signed-off-by: Ananya Sen --- js/io/document/base-document.js | 5 ----- js/io/document/document-controller.js | 34 ++++++++-------------------------- js/io/document/html-document.js | 23 ++++++++++++++--------- js/io/document/text-document.js | 1 + 4 files changed, 23 insertions(+), 40 deletions(-) (limited to 'js/io/document') diff --git a/js/io/document/base-document.js b/js/io/document/base-document.js index ecc92447..918b51ad 100755 --- a/js/io/document/base-document.js +++ b/js/io/document/base-document.js @@ -31,11 +31,6 @@ var BaseDocument = exports.BaseDocument = Montage.create(Montage, { set: function(value) { this._uri = value; } }, - externalUri: { - get: function() { return this._externalUri; }, - set: function(value) { this._externalUri = value; } - }, - documentType: { get: function() { return this._documentType; }, set: function(value) { this._documentType = value; } diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index ca6b4533..51575a24 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js @@ -239,45 +239,25 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function(id) { //if file dirty then save + if(this.activeDocument.dirtyFlag === true){ + this.activeDocument.save(true); + this.activeDocument.dirtyFlag=false; + } var doc = this._findDocumentByUUID(id); this._removeDocumentView(doc.container); + var closeDocumentIndex = this._findIndexByUUID(id); this._documents.splice(this._findIndexByUUID(id), 1); if(this.activeDocument.uuid === id && this._documents.length > 0) { - - var closeDocumentIndex = this._findIndexByUUID(id); var nextDocumentIndex = -1 ; if((this._documents.length > 0) && (closeDocumentIndex === 0)){ nextDocumentIndex = 1; }else if((this._documents.length > 0) && (closeDocumentIndex > 0)){ nextDocumentIndex = closeDocumentIndex - 1; } - - //remove the codemirror div if this is for a code view - /////test - - ////end- test - - this.switchDocument(this._documents[0].uuid); - - } - } - }, - - switchDocument: { - value: function(id) { - this._hideCurrentDocument(); - this.activeDocument = this._findDocumentByUUID(id); - - this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - this._showCurrentDocument(); - - if(this.activeDocument.documentType === "htm" || this.activeDocument.documentType === "html") { - this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe - // TODO dispatch event here -// appDelegateModule.MyAppDelegate.onSetActiveDocument(); + this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); } } }, @@ -406,6 +386,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ this.activeDocument.container.parentNode.style["display"] = "none"; this.application.ninja.stage.hideCanvas(true); + this.application.ninja.stage.stageView.hideRulers(); } } } @@ -418,6 +399,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(this.activeDocument.currentView === "design" || this.activeDocument.currentView === "design"){ this.activeDocument.container.parentNode.style["display"] = "block"; this.application.ninja.stage.hideCanvas(false); + this.application.ninja.stage.stageView.showRulers(); } } } diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js index da1bbe4a..8e1eb614 100755 --- a/js/io/document/html-document.js +++ b/js/io/document/html-document.js @@ -449,17 +449,22 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base */ save:{ value:function(removeCodeMirrorDivFlag){ - if(this.currentView === "design"){ - //generate html and save - }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ - if(removeCodeMirrorDivFlag === true){ - this.codeViewDocument.save(true); - }else{ - this.codeViewDocument.save(); + try{ + if(this.currentView === "design"){ + //generate html and save + }else if((this.currentView === "code") && (this.codeViewDocument !== null)){ + if(removeCodeMirrorDivFlag === true){ + this.codeViewDocument.save(true); + }else{ + this.codeViewDocument.save(); + } + //persist to filesystem } - //persist to filesystem + this.dirtyFlag=false; + }catch(e){ + console.log("Error while saving "+this.uri); + console.log(e.stack); } - } } }); \ No newline at end of file diff --git a/js/io/document/text-document.js b/js/io/document/text-document.js index a768779f..683c513c 100755 --- a/js/io/document/text-document.js +++ b/js/io/document/text-document.js @@ -95,6 +95,7 @@ var TextDocument = exports.TextDocument = Montage.create(baseDocumentModule.Base save:{ value:function(removeCodeMirrorDivFlag){ this.editor.save(); + this.dirtyFlag=false; if(removeCodeMirrorDivFlag === true){ var codemirrorDiv = this.textArea.parentNode.querySelector(".CodeMirror"); if(!!codemirrorDiv){codemirrorDiv.parentNode.removeChild(codemirrorDiv);} -- cgit v1.2.3