diff options
Diffstat (limited to 'js/stage')
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.css | 2 | ||||
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.js | 96 |
2 files changed, 42 insertions, 56 deletions
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 @@ | |||
10 | left: 0px; | 10 | left: 0px; |
11 | margin: 0px; | 11 | margin: 0px; |
12 | padding: 0px; | 12 | padding: 0px; |
13 | background: black; | 13 | background-color: #ffffff; |
14 | width: 100%; | 14 | width: 100%; |
15 | height: 100%; | 15 | height: 100%; |
16 | /*display: none;*/ | 16 | /*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, { | |||
76 | // Temporary function to create a Codemirror text view | 76 | // Temporary function to create a Codemirror text view |
77 | createTextView: { | 77 | createTextView: { |
78 | value: function(doc) { | 78 | value: function(doc) { |
79 | var documentController = this.application.ninja.documentController; | 79 | //save current document |
80 | 80 | if(this.application.ninja.documentController.activeDocument.currentView === "code"){ | |
81 | this.application.ninja.documentController.activeDocument.save(true); | ||
82 | } | ||
81 | this.application.ninja.documentController._hideCurrentDocument(); | 83 | this.application.ninja.documentController._hideCurrentDocument(); |
82 | 84 | this.hideOtherDocuments(doc.uuid); | |
83 | this.application.ninja.currentDocument.container.parentNode.style["display"] = "none"; | ||
84 | |||
85 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | ||
86 | this.application.ninja.documentController.activeDocument = doc; | ||
87 | |||
88 | var type; | 85 | var type; |
89 | |||
90 | switch(doc.documentType) { | 86 | switch(doc.documentType) { |
91 | case "css" : | 87 | case "css" : |
92 | type = "css"; | 88 | type = "css"; |
@@ -96,15 +92,9 @@ exports.StageView = Montage.create(Component, { | |||
96 | break; | 92 | break; |
97 | } | 93 | } |
98 | 94 | ||
99 | //hide other Codemirror divs | ||
100 | this.hideOtherCodeView(doc.uuid); | ||
101 | |||
102 | |||
103 | //fix hack | 95 | //fix hack |
104 | document.getElementById("codeMirror_"+doc.uuid).style.display="block"; | 96 | document.getElementById("codeMirror_"+doc.uuid).style.display="block"; |
105 | 97 | ||
106 | |||
107 | |||
108 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { | 98 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { |
109 | lineNumbers: true, | 99 | lineNumbers: true, |
110 | mode: type, | 100 | mode: type, |
@@ -115,25 +105,20 @@ exports.StageView = Montage.create(Component, { | |||
115 | }); | 105 | }); |
116 | 106 | ||
117 | //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); | 107 | //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); |
118 | 108 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | |
119 | this.application.ninja.stage.hideCanvas(true); | 109 | this.application.ninja.documentController.activeDocument = doc; |
120 | 110 | this.application.ninja.stage.hideCanvas(true); | |
121 | } | 111 | } |
122 | }, | 112 | }, |
123 | 113 | ||
124 | 114 | ||
125 | 115 | ||
126 | switchCodeView:{ | 116 | switchDocument:{ |
127 | value: function(doc){ | 117 | value: function(doc){ |
128 | 118 | ||
129 | //if dirty SAVE codemirror into textarea | 119 | //if dirty SAVE codemirror into textarea |
130 | //this.application.ninja.documentController.activeDocument.editor.save(); | 120 | if(this.application.ninja.documentController.activeDocument.currentView === "code"){ |
131 | 121 | this.application.ninja.documentController.activeDocument.save(true); | |
132 | //remove the codemirror div | ||
133 | var codemirrorDiv = this.application.ninja.documentController.activeDocument.container.querySelector(".CodeMirror"); | ||
134 | if(!!codemirrorDiv){ | ||
135 | codemirrorDiv.parentNode.removeChild(codemirrorDiv); | ||
136 | this.application.ninja.documentController.activeDocument.editor = null; | ||
137 | } | 122 | } |
138 | 123 | ||
139 | this.application.ninja.documentController._hideCurrentDocument(); | 124 | this.application.ninja.documentController._hideCurrentDocument(); |
@@ -143,28 +128,29 @@ exports.StageView = Montage.create(Component, { | |||
143 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | 128 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe |
144 | this.application.ninja.documentController._showCurrentDocument(); | 129 | this.application.ninja.documentController._showCurrentDocument(); |
145 | 130 | ||
146 | var type; | 131 | if(this.application.ninja.documentController.activeDocument.currentView === "code"){ |
147 | switch(doc.documentType) { | 132 | var type; |
148 | case "css" : | 133 | switch(doc.documentType) { |
149 | type = "css"; | 134 | case "css" : |
150 | break; | 135 | type = "css"; |
151 | case "js" : | 136 | break; |
152 | type = "javascript"; | 137 | case "js" : |
153 | break; | 138 | type = "javascript"; |
154 | } | 139 | break; |
155 | 140 | } | |
156 | //add the codemirror div again for editting | ||
157 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { | ||
158 | lineNumbers: true, | ||
159 | mode: type, | ||
160 | onCursorActivity: function() { | ||
161 | //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); | ||
162 | //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); | ||
163 | } | ||
164 | }); | ||
165 | |||
166 | //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); | ||
167 | 141 | ||
142 | //add the codemirror div again for editting | ||
143 | doc.editor = CodeMirror.fromTextArea(doc.textArea, { | ||
144 | lineNumbers: true, | ||
145 | mode: type, | ||
146 | onCursorActivity: function() { | ||
147 | //documentController._codeEditor.editor.setLineClass(documentController._codeEditor.hline, null); | ||
148 | //documentController._codeEditor.hline = documentController._codeEditor.editor.setLineClass(documentController._codeEditor.editor.getCursor().line, "activeline"); | ||
149 | } | ||
150 | }); | ||
151 | |||
152 | //this.application.ninja.documentController._codeEditor.hline = this.application.ninja.documentController._codeEditor.editor.setLineClass(0, "activeline"); | ||
153 | } | ||
168 | 154 | ||
169 | } | 155 | } |
170 | }, | 156 | }, |
@@ -201,16 +187,16 @@ exports.StageView = Montage.create(Component, { | |||
201 | 187 | ||
202 | } | 188 | } |
203 | }, | 189 | }, |
204 | hideOtherCodeView:{ | 190 | hideOtherDocuments:{ |
205 | value:function(docUuid){ | 191 | value:function(docUuid){ |
206 | var i=0; | 192 | //use CodeMirror toTextArea() to remove editor and save content into textarea |
207 | if(this.element.hasChildNodes()){ | 193 | this.application.ninja.documentController._documents.forEach(function(aDoc){ |
208 | for(i=0;i<this.element.childNodes.length;i++){ | 194 | if(aDoc.currentView === "design"){ |
209 | if(this.element.childNodes[i].id !== ("codeMirror_"+docUuid)){ | 195 | aDoc.container.parentNode.style["display"] = "none"; |
210 | this.element.childNodes[i].style.display = "none"; | 196 | }else if((aDoc.currentView === "code") && (aDoc.uuid !== docUuid)){ |
211 | } | 197 | aDoc.container.style["display"] = "none"; |
212 | } | 198 | } |
213 | } | 199 | }, this); |
214 | } | 200 | } |
215 | } | 201 | } |
216 | }); \ No newline at end of file | 202 | }); \ No newline at end of file |