diff options
Diffstat (limited to 'js/io/document/document-controller.js')
-rwxr-xr-x | js/io/document/document-controller.js | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/js/io/document/document-controller.js b/js/io/document/document-controller.js index 6f67b57c..16643a58 100755 --- a/js/io/document/document-controller.js +++ b/js/io/document/document-controller.js | |||
@@ -37,7 +37,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
37 | value: "function CodeMirror(place, givenOptions) {" + | 37 | value: "function CodeMirror(place, givenOptions) {" + |
38 | "// Determine effective options based on given values and defaults." + | 38 | "// Determine effective options based on given values and defaults." + |
39 | "var options = {}, defaults = CodeMirror.defaults; }" | 39 | "var options = {}, defaults = CodeMirror.defaults; }" |
40 | }, | 40 | }, |
41 | 41 | ||
42 | activeDocument: { | 42 | activeDocument: { |
43 | get: function() { | 43 | get: function() { |
@@ -45,7 +45,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
45 | }, | 45 | }, |
46 | set: function(doc) { | 46 | set: function(doc) { |
47 | if(this._activeDocument) this._activeDocument.isActive = false; | 47 | if(this._activeDocument) this._activeDocument.isActive = false; |
48 | 48 | ||
49 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); | 49 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); |
50 | 50 | ||
51 | this._activeDocument = doc; | 51 | this._activeDocument = doc; |
@@ -66,11 +66,20 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
66 | this.eventManager.addEventListener("executeSave", this, false); | 66 | this.eventManager.addEventListener("executeSave", this, false); |
67 | 67 | ||
68 | this.eventManager.addEventListener("recordStyleChanged", this, false); | 68 | this.eventManager.addEventListener("recordStyleChanged", this, false); |
69 | |||
70 | // Temporary testing opening a new file after Ninja has loaded | ||
71 | this.eventManager.addEventListener("executeNewProject", this, false); | ||
69 | } | 72 | } |
70 | }, | 73 | }, |
71 | 74 | ||
72 | handleAppLoaded: { | 75 | handleAppLoaded: { |
73 | value: function() { | 76 | value: function() { |
77 | //this.openDocument({"type": "html"}); | ||
78 | } | ||
79 | }, | ||
80 | |||
81 | handleExecuteNewProject: { | ||
82 | value: function() { | ||
74 | this.openDocument({"type": "html"}); | 83 | this.openDocument({"type": "html"}); |
75 | } | 84 | } |
76 | }, | 85 | }, |
@@ -107,9 +116,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
107 | 116 | ||
108 | if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view | 117 | if((newFileObj.fileExtension !== ".html") && (newFileObj.fileExtension !== ".htm")){//open code view |
109 | 118 | ||
110 | }else{ | 119 | } else { |
111 | //open design view | 120 | //open design view |
112 | } | 121 | } |
113 | } | 122 | } |
114 | }, | 123 | }, |
115 | 124 | ||
@@ -145,11 +154,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
145 | 154 | ||
146 | /** | 155 | /** |
147 | * Public method | 156 | * Public method |
148 | * doc contains: | ||
149 | * type : file type, like js, css, etc | ||
150 | * name : file name | ||
151 | * source : file content | ||
152 | * uri : file uri | ||
153 | */ | 157 | */ |
154 | openFileCallback:{ | 158 | openFileCallback:{ |
155 | value:function(response){ | 159 | value:function(response){ |
@@ -193,7 +197,6 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
193 | } | 197 | } |
194 | }, | 198 | }, |
195 | 199 | ||
196 | |||
197 | openProjectWithURI: { | 200 | openProjectWithURI: { |
198 | value: function(uri) { | 201 | value: function(uri) { |
199 | console.log("URI is: ", uri); | 202 | console.log("URI is: ", uri); |
@@ -225,7 +228,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
225 | 228 | ||
226 | this.textDocumentOpened(newDoc); | 229 | this.textDocumentOpened(newDoc); |
227 | 230 | ||
228 | } | 231 | } |
229 | 232 | ||
230 | // } catch (err) { | 233 | // } catch (err) { |
231 | // console.log("Could not open Document ", err); | 234 | // console.log("Could not open Document ", err); |
@@ -257,24 +260,24 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
257 | } | 260 | } |
258 | 261 | ||
259 | DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { | 262 | DocumentManager._codeEditor.editor = CodeMirror.fromTextArea(doc.textArea, { |
260 | lineNumbers: true, | 263 | lineNumbers: true, |
261 | mode: type, | 264 | mode: type, |
262 | onCursorActivity: function() { | 265 | onCursorActivity: function() { |
263 | DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); | 266 | DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.hline, null); |
264 | DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); | 267 | DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(DocumentManager._codeEditor.editor.getCursor().line, "activeline"); |
265 | } | 268 | } |
266 | }); | 269 | }); |
267 | DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); | 270 | DocumentManager._codeEditor.hline = DocumentManager._codeEditor.editor.setLineClass(0, "activeline"); |
268 | */ | 271 | */ |
269 | 272 | ||
270 | } | 273 | } |
271 | }, | 274 | }, |
272 | 275 | ||
273 | closeDocument: { | 276 | closeDocument: { |
274 | value: function(id) { | 277 | value: function(id) { |
275 | if(this.activeDocument.dirtyFlag === true){ | 278 | if(this.activeDocument.dirtyFlag === true){ |
276 | //if file dirty then alert user to save | 279 | //if file dirty then alert user to save |
277 | } | 280 | } |
278 | 281 | ||
279 | var doc = this._findDocumentByUUID(id); | 282 | var doc = this._findDocumentByUUID(id); |
280 | this._removeDocumentView(doc.container); | 283 | this._removeDocumentView(doc.container); |
@@ -399,9 +402,9 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
399 | this.application.ninja.stage.restoreScroll(); | 402 | this.application.ninja.stage.restoreScroll(); |
400 | this.application.ninja.stage.hideCanvas(false); | 403 | this.application.ninja.stage.hideCanvas(false); |
401 | this.application.ninja.stage.stageView.showRulers(); | 404 | this.application.ninja.stage.stageView.showRulers(); |
402 | } | ||
403 | } | 405 | } |
404 | } | 406 | } |
407 | } | ||
405 | }, | 408 | }, |
406 | 409 | ||
407 | _removeDocumentView: { | 410 | _removeDocumentView: { |
@@ -442,5 +445,5 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
442 | value: function() { | 445 | value: function() { |
443 | return "userDocument_" + (this._iframeCounter++); | 446 | return "userDocument_" + (this._iframeCounter++); |
444 | } | 447 | } |
445 | } | 448 | } |
446 | }); \ No newline at end of file | 449 | }); |