diff options
author | Jose Antonio Marquez | 2012-05-22 14:47:02 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-22 14:47:02 -0700 |
commit | c5dad8ddc94b2e1c80565dfee072bda88e8880da (patch) | |
tree | 122197204fff1b8adccfc089d6e6869e8c310550 /js/document/views | |
parent | fe3b8f2d556c1919e4ad504f7f895f6c400d84d2 (diff) | |
parent | 9b6da637d9654727426c6d78f17e3804bbd84ce5 (diff) | |
download | ninja-c5dad8ddc94b2e1c80565dfee072bda88e8880da.tar.gz |
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Conflicts:
js/document/document-html.js
Diffstat (limited to 'js/document/views')
-rwxr-xr-x | js/document/views/base.js | 2 | ||||
-rwxr-xr-x | js/document/views/code.js | 152 |
2 files changed, 151 insertions, 3 deletions
diff --git a/js/document/views/base.js b/js/document/views/base.js index d1c65b5e..db72cc60 100755 --- a/js/document/views/base.js +++ b/js/document/views/base.js | |||
@@ -39,6 +39,7 @@ exports.BaseDocumentView = Montage.create(Component, { | |||
39 | value: function (callback) { | 39 | value: function (callback) { |
40 | if (this.iframe) { | 40 | if (this.iframe) { |
41 | this.iframe.style.display = 'block'; | 41 | this.iframe.style.display = 'block'; |
42 | this.iframe.style.opacity = 1; | ||
42 | } else { | 43 | } else { |
43 | console.log('Error: View has no iframe to show!'); | 44 | console.log('Error: View has no iframe to show!'); |
44 | } | 45 | } |
@@ -52,6 +53,7 @@ exports.BaseDocumentView = Montage.create(Component, { | |||
52 | value: function (callback) { | 53 | value: function (callback) { |
53 | if (this.iframe) { | 54 | if (this.iframe) { |
54 | this.iframe.style.display = 'none'; | 55 | this.iframe.style.display = 'none'; |
56 | this.iframe.style.opacity = 0; | ||
55 | } else { | 57 | } else { |
56 | console.log('Error: View has no iframe to hide!'); | 58 | console.log('Error: View has no iframe to hide!'); |
57 | } | 59 | } |
diff --git a/js/document/views/code.js b/js/document/views/code.js index cd3e02d4..66d1c702 100755 --- a/js/document/views/code.js +++ b/js/document/views/code.js | |||
@@ -11,15 +11,161 @@ var Montage = require("montage/core/core").Montage, | |||
11 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; | 11 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; |
12 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
13 | // | 13 | // |
14 | exports.CodeDocumentView = Montage.create(BaseDocumentView, { | 14 | var CodeDocumentView = exports.CodeDocumentView = Montage.create(BaseDocumentView, { |
15 | //////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////// |
16 | // | 16 | // |
17 | hasTemplate: { | 17 | hasTemplate: { |
18 | enumerable: false, | 18 | enumerable: false, |
19 | value: false | 19 | value: false |
20 | }, | ||
21 | |||
22 | //////////////////////////////////////////////////////////////////// | ||
23 | // | ||
24 | _editor: { | ||
25 | value: null | ||
26 | }, | ||
27 | //////////////////////////////////////////////////////////////////// | ||
28 | // | ||
29 | editor: { | ||
30 | get: function() {return this._editor;}, | ||
31 | set: function(value) {this._editor= value;} | ||
32 | }, | ||
33 | //////////////////////////////////////////////////////////////////// | ||
34 | // | ||
35 | _textArea: { | ||
36 | value: null | ||
37 | }, | ||
38 | //////////////////////////////////////////////////////////////////// | ||
39 | // | ||
40 | textArea: { | ||
41 | get: function() {return this._textArea;}, | ||
42 | set: function(value) {this._textArea= value;} | ||
43 | }, | ||
44 | //////////////////////////////////////////////////////////////////// | ||
45 | // | ||
46 | _textViewContainer: { | ||
47 | value: null | ||
48 | }, | ||
49 | //////////////////////////////////////////////////////////////////// | ||
50 | // | ||
51 | textViewContainer: { | ||
52 | get: function() {return this._textViewContainer;}, | ||
53 | set: function(value) {this._textViewContainer= value;} | ||
54 | }, | ||
55 | //////////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | |||
58 | /** | ||
59 | * Public method | ||
60 | */ | ||
61 | initialize:{ | ||
62 | value: function(parentContainer){ | ||
63 | //create contianer | ||
64 | this.textViewContainer = document.createElement("div"); | ||
65 | //this.textViewContainer.id = "codemirror_" + uuid; | ||
66 | this.textViewContainer.style.display = "block"; | ||
67 | parentContainer.appendChild(this.textViewContainer); | ||
68 | |||
69 | //create text area | ||
70 | this.textArea = this.createTextAreaElement(); | ||
71 | } | ||
72 | }, | ||
73 | |||
74 | /** | ||
75 | * Public method | ||
76 | * Creates a textarea element which will contain the content of the opened text document. | ||
77 | */ | ||
78 | createTextAreaElement: { | ||
79 | value: function() { | ||
80 | var textArea = document.createElement("textarea"); | ||
81 | // textArea.id = "code"; | ||
82 | // textArea.name = "code"; | ||
83 | this.textViewContainer.appendChild(textArea); | ||
84 | |||
85 | return textArea; | ||
86 | } | ||
87 | }, | ||
88 | //////////////////////////////////////////////////////////////////// | ||
89 | // | ||
90 | /** | ||
91 | * Public method | ||
92 | * Creates a new instance of a code editor | ||
93 | */ | ||
94 | initializeTextView: { | ||
95 | value: function(file, textDocument) { | ||
96 | var type; | ||
97 | |||
98 | if(this.activeDocument) { | ||
99 | //need to hide only if another document was open before | ||
100 | // this.application.ninja.documentController._hideCurrentDocument(); | ||
101 | // this.hideOtherDocuments(doc.uuid); | ||
102 | } | ||
103 | |||
104 | switch(file.extension) { | ||
105 | case "css" : | ||
106 | type = "css"; | ||
107 | break; | ||
108 | case "js" : | ||
109 | type = "javascript"; | ||
110 | break; | ||
111 | case "html" : | ||
112 | type = "htmlmixed"; | ||
113 | break; | ||
114 | case "json" : | ||
115 | type = "javascript"; | ||
116 | break; | ||
117 | case "php" : | ||
118 | type = "php"; | ||
119 | break; | ||
120 | case "pl" : | ||
121 | type = "perl"; | ||
122 | break; | ||
123 | case "py" : | ||
124 | type = "python"; | ||
125 | break; | ||
126 | case "rb" : | ||
127 | type = "ruby"; | ||
128 | break; | ||
129 | case "xml" : | ||
130 | type = "xml"; | ||
131 | break; | ||
132 | } | ||
133 | this.textViewContainer.style.display="block"; | ||
134 | |||
135 | this.editor = this.application.ninja.codeEditorController.createEditor(this, type, file.extension, textDocument); | ||
136 | this.editor.hline = this.editor.setLineClass(0, "activeline"); | ||
137 | |||
138 | |||
139 | } | ||
140 | }, | ||
141 | //////////////////////////////////////////////////////////////////// | ||
142 | // | ||
143 | show: { | ||
144 | value: function (callback) { | ||
145 | this.textViewContainer.style.display = "block"; | ||
146 | // | ||
147 | if (callback) callback(); | ||
148 | } | ||
149 | }, | ||
150 | //////////////////////////////////////////////////////////////////// | ||
151 | // | ||
152 | hide: { | ||
153 | value: function (callback) { | ||
154 | this.textViewContainer.style.display = "none"; | ||
155 | // | ||
156 | if (callback) callback(); | ||
157 | } | ||
158 | }, | ||
159 | //////////////////////////////////////////////////////////////////// | ||
160 | // | ||
161 | applyTheme:{ | ||
162 | value:function(themeClass){ | ||
163 | //Todo: change for bucket structure of documents | ||
164 | this.textViewContainer.className = "codeViewContainer "+themeClass; | ||
165 | } | ||
20 | } | 166 | } |
21 | //////////////////////////////////////////////////////////////////// | 167 | //////////////////////////////////////////////////////////////////////// |
22 | //////////////////////////////////////////////////////////////////// | 168 | //////////////////////////////////////////////////////////////////////// |
23 | }); | 169 | }); |
24 | //////////////////////////////////////////////////////////////////////// | 170 | //////////////////////////////////////////////////////////////////////// |
25 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file | 171 | //////////////////////////////////////////////////////////////////////// \ No newline at end of file |