diff options
-rw-r--r-- | js/controllers/code-editor-controller.js | 47 | ||||
-rwxr-xr-x | js/controllers/document-controller.js | 67 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.html | 5 | ||||
-rwxr-xr-x | js/ninja.reel/ninja.js | 6 |
4 files changed, 64 insertions, 61 deletions
diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js index e7163bd8..d0b1f179 100644 --- a/js/controllers/code-editor-controller.js +++ b/js/controllers/code-editor-controller.js | |||
@@ -9,11 +9,34 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | Component = require("montage/ui/component").Component; | 10 | Component = require("montage/ui/component").Component; |
11 | 11 | ||
12 | var CodeEditorController = exports.CodeEditorController = Montage.create(Component, { | 12 | exports.CodeEditorController = Montage.create(Component, { |
13 | hasTemplate: { | 13 | hasTemplate: { |
14 | value: false | 14 | value: false |
15 | }, | 15 | }, |
16 | 16 | ||
17 | _currentDocument: { | ||
18 | value : null | ||
19 | }, | ||
20 | |||
21 | currentDocument : { | ||
22 | get : function() { | ||
23 | return this._currentDocument; | ||
24 | }, | ||
25 | set : function(value) { | ||
26 | if (value === this._currentDocument) { | ||
27 | return; | ||
28 | } | ||
29 | |||
30 | this._currentDocument = value; | ||
31 | |||
32 | if(!value) { | ||
33 | |||
34 | } else if(this._currentDocument.currentView === "code") { | ||
35 | this.applySettings(); | ||
36 | } | ||
37 | } | ||
38 | }, | ||
39 | |||
17 | _codeEditor : { | 40 | _codeEditor : { |
18 | value:null | 41 | value:null |
19 | }, | 42 | }, |
@@ -213,22 +236,22 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
213 | 236 | ||
214 | autoFormatSelection:{ | 237 | autoFormatSelection:{ |
215 | value: function(){ | 238 | value: function(){ |
216 | var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.model.views.code.editor); | 239 | var range = this.getSelectedRange(this.currentDocument.model.views.code.editor); |
217 | this.application.ninja.documentController.activeDocument.model.views.code.editor.autoFormatRange(range.from, range.to); | 240 | this.currentDocument.model.views.code.editor.autoFormatRange(range.from, range.to); |
218 | } | 241 | } |
219 | }, | 242 | }, |
220 | 243 | ||
221 | commentSelection:{ | 244 | commentSelection:{ |
222 | value: function(isComment){ | 245 | value: function(isComment){ |
223 | var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.model.views.code.editor); | 246 | var range = this.getSelectedRange(this.currentDocument.model.views.code.editor); |
224 | this.application.ninja.documentController.activeDocument.model.views.code.editor.commentRange(isComment, range.from, range.to); | 247 | this.currentDocument.model.views.code.editor.commentRange(isComment, range.from, range.to); |
225 | } | 248 | } |
226 | }, | 249 | }, |
227 | 250 | ||
228 | handleThemeSelection:{ | 251 | handleThemeSelection:{ |
229 | value: function(){ | 252 | value: function(){ |
230 | this.application.ninja.documentController.activeDocument.model.views.code.editor.setOption("theme", this.editorTheme); | 253 | this.currentDocument.model.views.code.editor.setOption("theme", this.editorTheme); |
231 | this.application.ninja.documentController.activeDocument.model.views.code.applyTheme("cm-s-"+this.editorTheme); | 254 | this.currentDocument.model.views.code.applyTheme("cm-s-"+this.editorTheme); |
232 | } | 255 | } |
233 | }, | 256 | }, |
234 | 257 | ||
@@ -236,10 +259,10 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
236 | value:function(value){ | 259 | value:function(value){ |
237 | var originalFont=13,originalLineHeight=16; | 260 | var originalFont=13,originalLineHeight=16; |
238 | this._zoomFactor = value; | 261 | this._zoomFactor = value; |
239 | this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.style.fontSize = ""+((value/100)*originalFont)+"px"; | 262 | this.currentDocument.model.views.code.textViewContainer.style.fontSize = ""+((value/100)*originalFont)+"px"; |
240 | this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.style.cursor = "text"; | 263 | this.currentDocument.model.views.code.textViewContainer.style.cursor = "text"; |
241 | this.application.ninja.documentController.activeDocument.model.views.code.textViewContainer.querySelector(".CodeMirror").style.lineHeight = ""+((value/100)*originalLineHeight)+"px"; | 264 | this.currentDocument.model.views.code.textViewContainer.querySelector(".CodeMirror").style.lineHeight = ""+((value/100)*originalLineHeight)+"px"; |
242 | this.application.ninja.documentController.activeDocument.model.views.code.editor.refresh();//refresh editor display for xoom | 265 | this.currentDocument.model.views.code.editor.refresh();//refresh editor display for xoom |
243 | } | 266 | } |
244 | }, | 267 | }, |
245 | 268 | ||
@@ -248,7 +271,7 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone | |||
248 | //set theme | 271 | //set theme |
249 | this.handleThemeSelection(); | 272 | this.handleThemeSelection(); |
250 | //check autocomplete support | 273 | //check autocomplete support |
251 | this.handleCodeCompletionSupport(this.application.ninja.documentController.activeDocument.model.file.extension); | 274 | this.handleCodeCompletionSupport(this.currentDocument.model.file.extension); |
252 | //set zoom | 275 | //set zoom |
253 | this.handleZoom(this._zoomFactor); | 276 | this.handleZoom(this._zoomFactor); |
254 | } | 277 | } |
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 4f122b3b..e059e7e1 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -18,6 +18,14 @@ exports.DocumentController = Montage.create(Component, { | |||
18 | value: false | 18 | value: false |
19 | }, | 19 | }, |
20 | 20 | ||
21 | iframeContainer: { | ||
22 | value: null | ||
23 | }, | ||
24 | |||
25 | codeContainer: { | ||
26 | value: null | ||
27 | }, | ||
28 | |||
21 | documents: { | 29 | documents: { |
22 | value: [] | 30 | value: [] |
23 | }, | 31 | }, |
@@ -42,13 +50,15 @@ exports.DocumentController = Montage.create(Component, { | |||
42 | this._currentDocument = value; | 50 | this._currentDocument = value; |
43 | 51 | ||
44 | if(!value) { | 52 | if(!value) { |
45 | 53 | document.getElementById("iframeContainer").style.display = "block"; | |
46 | } else { | 54 | document.getElementById("codeViewContainer").style.display = "block"; |
55 | } else if(this._currentDocument.currentView === "design") { | ||
56 | this._currentDocument.model.currentView.show(); | ||
57 | } else { | ||
58 | document.getElementById("iframeContainer").style.display = "none"; | ||
47 | this._currentDocument.model.currentView.show(); | 59 | this._currentDocument.model.currentView.show(); |
48 | } | 60 | } |
49 | 61 | ||
50 | |||
51 | |||
52 | } | 62 | } |
53 | }, | 63 | }, |
54 | 64 | ||
@@ -64,7 +74,13 @@ exports.DocumentController = Montage.create(Component, { | |||
64 | this.eventManager.addEventListener("executeFileCloseAll", this, false); | 74 | this.eventManager.addEventListener("executeFileCloseAll", this, false); |
65 | } | 75 | } |
66 | }, | 76 | }, |
67 | 77 | ||
78 | didCreate: { | ||
79 | value: function() { | ||
80 | this.iframeContainer = document.getElementById("iframeContainer"); | ||
81 | this.codeContainer = document.getElementById("codeViewContainer"); | ||
82 | } | ||
83 | }, | ||
68 | 84 | ||
69 | //TODO: Ensure these APIs are not needed | 85 | //TODO: Ensure these APIs are not needed |
70 | redirectRequests: { | 86 | redirectRequests: { |
@@ -333,47 +349,6 @@ exports.DocumentController = Montage.create(Component, { | |||
333 | } | 349 | } |
334 | }, | 350 | }, |
335 | 351 | ||
336 | onCloseFile: { | ||
337 | value: function(doc) { | ||
338 | var previousFocusedDocument; | ||
339 | |||
340 | // this._documents.splice(this._documents.indexOf(doc), 1); | ||
341 | this.application.ninja.docController.removeObjects(this._documents.indexOf(doc)); | ||
342 | |||
343 | if(this._documents.length > 0) { | ||
344 | previousFocusedDocument = this._documents[this._documents.length - 1]; | ||
345 | this.activeDocument = previousFocusedDocument; | ||
346 | this.switchDocuments(this.activeDocument, previousFocusedDocument, false); | ||
347 | } else { | ||
348 | this.activeDocument = null; | ||
349 | this.application.ninja.stage.hideRulers(); | ||
350 | |||
351 | this.application.ninja.stage.hideCanvas(true); | ||
352 | } | ||
353 | |||
354 | //TODO: Use references for those instead of calling getElementById | ||
355 | if(this._documents.length === 0){ | ||
356 | document.getElementById("iframeContainer").style.display="block"; | ||
357 | document.getElementById("codeViewContainer").style.display="block"; | ||
358 | } | ||
359 | |||
360 | NJevent("closeDocument", doc.model.file.uri); | ||
361 | |||
362 | //TODO: Delete object here | ||
363 | } | ||
364 | }, | ||
365 | |||
366 | _onOpenTextDocument: { | ||
367 | value: function(doc) { | ||
368 | |||
369 | // Main DIFFERENCE -- | ||
370 | // TODO: Implement Code View here | ||
371 | //document.getElementById("iframeContainer").style.display = "none"; | ||
372 | //this.application.ninja.codeEditorController.applySettings(); | ||
373 | |||
374 | } | ||
375 | }, | ||
376 | |||
377 | switchDocuments: { | 352 | switchDocuments: { |
378 | value: function(currentDocument, newDocument, didCreate) { | 353 | value: function(currentDocument, newDocument, didCreate) { |
379 | 354 | ||
diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index ab4eed84..d9bebc36 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html | |||
@@ -345,7 +345,10 @@ | |||
345 | }, | 345 | }, |
346 | 346 | ||
347 | "codeEditorController": { | 347 | "codeEditorController": { |
348 | "prototype": "js/controllers/code-editor-controller" | 348 | "prototype": "js/controllers/code-editor-controller", |
349 | "bindings": { | ||
350 | "currentDocument": {"<-": "@documentList.selectedObjects.0"} | ||