diff options
-rwxr-xr-x | js/document/document-text.js | 59 | ||||
-rwxr-xr-x | js/document/views/code.js | 56 | ||||
-rwxr-xr-x | js/document/views/design.js | 6 | ||||
-rw-r--r-- | js/io/system/ninjalibrary.js | 135 | ||||
-rwxr-xr-x | js/panels/properties.reel/properties.js | 4 |
5 files changed, 114 insertions, 146 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 |
diff --git a/js/document/views/code.js b/js/document/views/code.js index 66d1c702..0a0ff5c1 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js | |||
@@ -10,15 +10,13 @@ var Montage = require("montage/core/core").Montage, | |||
10 | Component = require("montage/ui/component").Component, | 10 | Component = require("montage/ui/component").Component, |
11 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; | 11 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; |
12 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
13 | // | 13 | // |
14 | var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentView, { | 14 | exports.CodeDocumentView = Montage.create(BaseDocumentView, { |
15 | //////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////// |
16 | // | 16 | // |
17 | hasTemplate: { | 17 | hasTemplate: { |
18 | enumerable: false, | ||
19 | value: false | 18 | value: false |
20 | }, | 19 | }, |
21 | |||
22 | //////////////////////////////////////////////////////////////////// | 20 | //////////////////////////////////////////////////////////////////// |
23 | // | 21 | // |
24 | _editor: { | 22 | _editor: { |
@@ -28,7 +26,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie | |||
28 | // | 26 | // |
29 | editor: { | 27 | editor: { |
30 | get: function() {return this._editor;}, | 28 | get: function() {return this._editor;}, |
31 | set: function(value) {this._editor= value;} | 29 | set: function(value) {this._editor = value;} |
32 | }, | 30 | }, |
33 | //////////////////////////////////////////////////////////////////// | 31 | //////////////////////////////////////////////////////////////////// |
34 | // | 32 | // |
@@ -39,7 +37,7 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie | |||
39 | // | 37 | // |
40 | textArea: { | 38 | textArea: { |
41 | get: function() {return this._textArea;}, | 39 | get: function() {return this._textArea;}, |
42 | set: function(value) {this._textArea= value;} | 40 | set: function(value) {this._textArea = value;} |
43 | }, | 41 | }, |
44 | //////////////////////////////////////////////////////////////////// | 42 | //////////////////////////////////////////////////////////////////// |
45 | // | 43 | // |
@@ -50,14 +48,10 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie | |||
50 | // | 48 | // |
51 | textViewContainer: { | 49 | textViewContainer: { |
52 | get: function() {return this._textViewContainer;}, | 50 | get: function() {return this._textViewContainer;}, |
53 | set: function(value) {this._textViewContainer= value;} | 51 | set: function(value) {this._textViewContainer = value;} |
54 | }, | 52 | }, |
55 | //////////////////////////////////////////////////////////////////// | 53 | //////////////////////////////////////////////////////////////////// |
56 | // | 54 | // |
57 | |||
58 | /** | ||
59 | * Public method | ||
60 | */ | ||
61 | initialize:{ | 55 | initialize:{ |
62 | value: function(parentContainer){ | 56 | value: function(parentContainer){ |
63 | //create contianer | 57 | //create contianer |
@@ -65,42 +59,35 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie | |||
65 | //this.textViewContainer.id = "codemirror_" + uuid; | 59 | //this.textViewContainer.id = "codemirror_" + uuid; |
66 | this.textViewContainer.style.display = "block"; | 60 | this.textViewContainer.style.display = "block"; |
67 | parentContainer.appendChild(this.textViewContainer); | 61 | parentContainer.appendChild(this.textViewContainer); |
68 | |||
69 | //create text area | 62 | //create text area |
70 | this.textArea = this.createTextAreaElement(); | 63 | this.textArea = this.createTextAreaElement(); |
71 | } | 64 | } |
72 | }, | 65 | }, |
73 | 66 | //////////////////////////////////////////////////////////////////// | |
74 | /** | 67 | //Creates a textarea element which will contain the content of the opened text document |
75 | * Public method | ||
76 | * Creates a textarea element which will contain the content of the opened text document. | ||
77 | */ | ||
78 | createTextAreaElement: { | 68 | createTextAreaElement: { |
79 | value: function() { | 69 | value: function() { |
80 | var textArea = document.createElement("textarea"); | 70 | var textArea = document.createElement("textarea"); |
81 | // textArea.id = "code"; | 71 | //textArea.id = "code"; |
82 | // textArea.name = "code"; | 72 | //textArea.name = "code"; |
83 | this.textViewContainer.appendChild(textArea); | 73 | this.textViewContainer.appendChild(textArea); |
84 | 74 | //Returns textarea element | |
85 | return textArea; | 75 | return textArea; |
86 | } | 76 | } |
87 | }, | 77 | }, |
88 | //////////////////////////////////////////////////////////////////// | 78 | //////////////////////////////////////////////////////////////////// |
89 | // | 79 | //Creates a new instance of a code editor |
90 | /** | ||
91 | * Public method | ||
92 | * Creates a new instance of a code editor | ||
93 | */ | ||
94 | initializeTextView: { | 80 | initializeTextView: { |
95 | value: function(file, textDocument) { | 81 | value: function(file, textDocument) { |
82 | // | ||
96 | var type; | 83 | var type; |
97 | 84 | // | |
98 | if(this.activeDocument) { | 85 | if(this.activeDocument) { |
99 | //need to hide only if another document was open before | 86 | //need to hide only if another document was open before |
100 | // this.application.ninja.documentController._hideCurrentDocument(); | 87 | //this.application.ninja.documentController._hideCurrentDocument(); |
101 | // this.hideOtherDocuments(doc.uuid); | 88 | //this.hideOtherDocuments(doc.uuid); |
102 | } | 89 | } |
103 | 90 | // | |
104 | switch(file.extension) { | 91 | switch(file.extension) { |
105 | case "css" : | 92 | case "css" : |
106 | type = "css"; | 93 | type = "css"; |
@@ -130,18 +117,18 @@ var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentVie | |||
130 |