From 8504b61aefb25fdab931f02c4568916d2bf8345c Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 2 Feb 2012 00:52:44 -0800 Subject: changes to open multiple code view tabs and switch between the code views, added nj-skinned css class for the buttons in file picker, new file dialog and save as dialog Signed-off-by: Ananya Sen --- js/stage/stage-view.reel/stage-view.js | 54 ++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) (limited to 'js/stage/stage-view.reel/stage-view.js') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 727c16eb..c0b0b83e 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -49,6 +49,8 @@ exports.StageView = Montage.create(Component, { // Temporary function to create a Codemirror text view createTextView: { value: function(doc) { + var documentController = this.application.ninja.documentController; + this.application.ninja.documentController._hideCurrentDocument(); this.application.ninja.currentDocument.container.parentNode.style["display"] = "none"; @@ -79,8 +81,8 @@ exports.StageView = Montage.create(Component, { lineNumbers: true, mode: type, onCursorActivity: function() { - this.application.ninja.documentController._codeEditor.editor.setLineClass(this.application.ninja.documentController._codeEditor.hline, null); - this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(this.application.ninja.documentController._codeEditor.editor.getCursor().line, "activeline"); + //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); + //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); } }); @@ -93,9 +95,15 @@ exports.StageView = Montage.create(Component, { switchCodeView:{ value: function(doc){ - + var documentController = this.application.ninja.documentController; this.application.ninja.documentController._hideCurrentDocument(); + this.application.ninja.documentController.activeDocument = doc; + + this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe + + + //remove any previous Codemirror div var codemirrorDiv = this.element.querySelector(".CodeMirror"); if(!!codemirrorDiv){ @@ -117,13 +125,49 @@ exports.StageView = Montage.create(Component, { lineNumbers: true, mode: type, onCursorActivity: function() { - this.application.ninja.documentController._codeEditor.editor.setLineClass(this.application.ninja.documentController._codeEditor.hline, null); - this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(this.application.ninja.documentController._codeEditor.editor.getCursor().line, "activeline"); + //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); + //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); } }); //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); } + }, + refreshCodeDocument:{ + value:function(doc){ + + } + }, + addCodeDocument:{ + value:function(doc){ + var type; + switch(doc.documentType) { + case "css" : + type = "css"; + break; + case "js" : + type = "javascript"; + break; + } + + var codeM = CodeMirror.fromTextArea(doc.textArea, { + lineNumbers: true, + mode: type, + onCursorActivity: function() { + //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); + //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); + } + }); + } + }, + removeCodeDocument:{ + value:function(){ + //remove any previous Codemirror div + var codemirrorDiv = this.element.querySelector(".CodeMirror"); + if(!!codemirrorDiv){ + codemirrorDiv.parentNode.removeChild(codemirrorDiv); + } + } } }); \ No newline at end of file -- cgit v1.2.3