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/stage/stage-view.reel/stage-view.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index cf7748fc..6f20b87b 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -95,9 +95,12 @@ exports.StageView = Montage.create(Component, { //fix hack document.getElementById("codeMirror_"+doc.uuid).style.display="block"; + var documentController = this.application.ninja.documentController; + doc.editor = CodeMirror.fromTextArea(doc.textArea, { lineNumbers: true, mode: type, + onChange: function(){doc.dirtyFlag=true;}, onCursorActivity: function() { //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); @@ -128,6 +131,8 @@ exports.StageView = Montage.create(Component, { this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe this.application.ninja.documentController._showCurrentDocument(); + var documentController = this.application.ninja.documentController; + if(this.application.ninja.documentController.activeDocument.currentView === "code"){ var type; switch(doc.documentType) { @@ -143,6 +148,7 @@ exports.StageView = Montage.create(Component, { doc.editor = CodeMirror.fromTextArea(doc.textArea, { lineNumbers: true, mode: type, + onChange: function(){doc.dirtyFlag=true;}, onCursorActivity: function() { //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); @@ -152,8 +158,15 @@ exports.StageView = Montage.create(Component, { //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); } + if(this.application.ninja.documentController.activeDocument.documentType === "htm" || this.application.ninja.documentController.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(); + } + } }, + refreshCodeDocument:{ value:function(doc){ @@ -198,5 +211,17 @@ exports.StageView = Montage.create(Component, { } }, this); } + }, + showRulers:{ + value:function(){ + this.application.ninja.rulerTop.style.display = "block"; + this.application.ninja.rulerLeft.style.display = "block"; + } + }, + hideRulers:{ + value:function(){ + this.application.ninja.rulerTop.style.display = "none"; + this.application.ninja.rulerLeft.style.display = "none"; + } } }); \ No newline at end of file -- cgit v1.2.3