From 1daf146c849a0a8dbd2b61b14218c9a39bdee3a7 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 3 Feb 2012 17:22:48 -0800 Subject: added editor tab save while switching code view tabs, integrated new file dialog with io mediator to open the new file in a new tab Signed-off-by: Ananya Sen --- js/stage/stage-view.reel/stage-view.css | 2 +- js/stage/stage-view.reel/stage-view.js | 96 ++++++++++++++------------------- 2 files changed, 42 insertions(+), 56 deletions(-) (limited to 'js/stage/stage-view.reel') diff --git a/js/stage/stage-view.reel/stage-view.css b/js/stage/stage-view.reel/stage-view.css index f15f74a0..f00a5f8a 100755 --- a/js/stage/stage-view.reel/stage-view.css +++ b/js/stage/stage-view.reel/stage-view.css @@ -10,7 +10,7 @@ left: 0px; margin: 0px; padding: 0px; - background: black; + background-color: #ffffff; width: 100%; height: 100%; /*display: none;*/ diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index d8e1e46b..cf7748fc 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -76,17 +76,13 @@ exports.StageView = Montage.create(Component, { // Temporary function to create a Codemirror text view createTextView: { value: function(doc) { - var documentController = this.application.ninja.documentController; - + //save current document + if(this.application.ninja.documentController.activeDocument.currentView === "code"){ + this.application.ninja.documentController.activeDocument.save(true); + } this.application.ninja.documentController._hideCurrentDocument(); - - this.application.ninja.currentDocument.container.parentNode.style["display"] = "none"; - - this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - this.application.ninja.documentController.activeDocument = doc; - + this.hideOtherDocuments(doc.uuid); var type; - switch(doc.documentType) { case "css" : type = "css"; @@ -96,15 +92,9 @@ exports.StageView = Montage.create(Component, { break; } - //hide other Codemirror divs - this.hideOtherCodeView(doc.uuid); - - //fix hack document.getElementById("codeMirror_"+doc.uuid).style.display="block"; - - doc.editor = CodeMirror.fromTextArea(doc.textArea, { lineNumbers: true, mode: type, @@ -115,25 +105,20 @@ exports.StageView = Montage.create(Component, { }); //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); - - this.application.ninja.stage.hideCanvas(true); - + this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe + this.application.ninja.documentController.activeDocument = doc; + this.application.ninja.stage.hideCanvas(true); } }, - switchCodeView:{ + switchDocument:{ value: function(doc){ //if dirty SAVE codemirror into textarea - //this.application.ninja.documentController.activeDocument.editor.save(); - - //remove the codemirror div - var codemirrorDiv = this.application.ninja.documentController.activeDocument.container.querySelector(".CodeMirror"); - if(!!codemirrorDiv){ - codemirrorDiv.parentNode.removeChild(codemirrorDiv); - this.application.ninja.documentController.activeDocument.editor = null; + if(this.application.ninja.documentController.activeDocument.currentView === "code"){ + this.application.ninja.documentController.activeDocument.save(true); } this.application.ninja.documentController._hideCurrentDocument(); @@ -143,28 +128,29 @@ 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 type; - switch(doc.documentType) { - case "css" : - type = "css"; - break; - case "js" : - type = "javascript"; - break; - } - - //add the codemirror div again for editting - doc.editor = 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"); - } - }); - - //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); + if(this.application.ninja.documentController.activeDocument.currentView === "code"){ + var type; + switch(doc.documentType) { + case "css" : + type = "css"; + break; + case "js" : + type = "javascript"; + break; + } + //add the codemirror div again for editting + doc.editor = 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"); + } + }); + + //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); + } } }, @@ -201,16 +187,16 @@ exports.StageView = Montage.create(Component, { } }, - hideOtherCodeView:{ + hideOtherDocuments:{ value:function(docUuid){ - var i=0; - if(this.element.hasChildNodes()){ - for(i=0;i --- js/stage/stage-view.reel/stage-view.css | 1 + 1 file changed, 1 insertion(+) (limited to 'js/stage/stage-view.reel') diff --git a/js/stage/stage-view.reel/stage-view.css b/js/stage/stage-view.reel/stage-view.css index f00a5f8a..ce7072c7 100755 --- a/js/stage/stage-view.reel/stage-view.css +++ b/js/stage/stage-view.reel/stage-view.css @@ -13,6 +13,7 @@ background-color: #ffffff; width: 100%; height: 100%; + overflow:auto; /*display: none;*/ } -- cgit v1.2.3