diff options
author | Valerio Virgillito | 2012-05-29 00:35:18 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-29 00:35:18 -0700 |
commit | 0c9c719acb9381e147b90abbf733ad7eb3beb7f7 (patch) | |
tree | c50d4e0906c62386f6325f369edda9f1f0e697a1 /js/document/document-text.js | |
parent | 4c3aac5eabd93052b1554a03d78235215bb49db4 (diff) | |
parent | 58e454c828abf0b64fa62120359bcd78a0d34ac4 (diff) | |
download | ninja-0c9c719acb9381e147b90abbf733ad7eb3beb7f7.tar.gz |
Merge branch 'refs/heads/dom-architecture' into document-bindings-fix
Diffstat (limited to 'js/document/document-text.js')
-rwxr-xr-x | js/document/document-text.js | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/js/document/document-text.js b/js/document/document-text.js index bb63f5f8..811cc8ce 100755 --- a/js/document/document-text.js +++ b/js/document/document-text.js | |||
@@ -6,17 +6,16 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
6 | 6 | ||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
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 | TextDocumentModel = require("js/document/models/text").TextDocumentModel, | 11 | TextDocumentModel = require("js/document/models/text").TextDocumentModel, |
12 | CodeDocumentView = require("js/document/views/code").CodeDocumentView; | 12 | CodeDocumentView = require("js/document/views/code").CodeDocumentView; |
13 | //////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////// |
14 | // | 14 | // |
15 | exports.TextDocument = Montage.create(Component, { | 15 | exports.TextDocument = Montage.create(Component, { |
16 | //////////////////////////////////////////////////////////////////// | 16 | //////////////////////////////////////////////////////////////////// |
17 | // | 17 | // |
18 | hasTemplate: { | 18 | hasTemplate: { |
19 | enumerable: false, | ||
20 | value: false | 19 | value: false |
21 | }, | 20 | }, |
22 | //////////////////////////////////////////////////////////////////// | 21 | //////////////////////////////////////////////////////////////////// |
@@ -26,45 +25,47 @@ exports.TextDocument = Montage.create(Component, { | |||
26 | }, | 25 | }, |
27 | //////////////////////////////////////////////////////////////////// | 26 | //////////////////////////////////////////////////////////////////// |
28 | // | 27 | // |
29 | |||
30 | init:{ | 28 | init:{ |
31 | enumerable: false, | 29 | value: function(file, context, callback, view){ |
32 | value : function(file, context, callback, view){ | 30 | // |
33 | var codeDocumentView = CodeDocumentView.create(), container = null; | 31 | var codeDocumentView = CodeDocumentView.create(), container = null; //TODO: Why is this initilzied to null? |
34 | |||
35 | //Creating instance of Text Document Model | 32 | //Creating instance of Text Document Model |
36 | this.model = Montage.create(TextDocumentModel,{ | 33 | this.model = Montage.create(TextDocumentModel,{ |
37 | file: {value: file}, | 34 | file: {value: file}, |
38 | parentContainer: {value: document.getElementById("codeViewContainer")}, | 35 | parentContainer: {value: document.getElementById("codeViewContainer")}, //TODO: Remove reference to this element, should be dynamic |
39 | views: {value: {'code': codeDocumentView, 'design': null}} | 36 | views: {value: {'code': codeDocumentView, 'design': null}} //TODO: Add check if file might have design view, if so, then create it |
40 | }); | 37 | }); |
41 | 38 | //TODO: Add design view logic | |
39 | //Initilizing view(s) | ||
42 | codeDocumentView.initialize(this.model.parentContainer); | 40 | codeDocumentView.initialize(this.model.parentContainer); |
43 | 41 | //Checking for view specified | |
44 | codeDocumentView.textArea.value = file.content; | ||
45 | codeDocumentView.initializeTextView(file, this); | ||
46 | |||
47 | if (view === 'code') { | 42 | if (view === 'code') { |
48 | //TODO: Remove reference and use as part of model | 43 | //TODO: Remove reference and use as part of model |
49 | this.currentView = 'code'; | 44 | this.currentView = 'code'; |
50 | //Setting current view object to design | 45 | //Setting current view object to design |
51 | this.model.currentView = this.model.views.code; | 46 | this.model.currentView = this.model.views.code; |
47 | //Rendering view | ||
48 | codeDocumentView.textArea.value = file.content; | ||
49 | codeDocumentView.initializeTextView(file, this); | ||
50 | } else { | ||
51 | //Other view(s) logic goes here | ||
52 | } | 52 | } |
53 | 53 | //Checking if callback is needed | |
54 | 54 | if (callback) callback.call(context, this); | |
55 | callback.call(context, this); | ||
56 | } | 55 | } |
57 | }, | 56 | }, |
58 | //////////////////////////////////////////////////////////////////// | 57 | //////////////////////////////////////////////////////////////////// |
59 | // | 58 | // |
60 | closeDocument: { | 59 | closeDocument: { |
61 | value: function (context, callback) { | 60 | value: function (context, callback) { |
62 | var closed = this.model.close(null); | 61 | //Closing document and getting outcome |
63 | 62 | var closed = this.model.close(null); | |
64 | callback.call(context, this); | 63 | //Making callback if specified |
65 | } | 64 | if (callback) callback.call(context, this); |
66 | } | 65 | } |
67 | //////////////////////////////////////////////////////////////////// | 66 | } |
67 | //////////////////////////////////////////////////////////////////// | ||
68 | //////////////////////////////////////////////////////////////////// | ||
68 | }); | 69 | }); |
69 | //////////////////////////////////////////////////////////////////////// | 70 | //////////////////////////////////////////////////////////////////////// |
70 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | 71 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file |