aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
authorhwc4872012-05-31 17:11:08 -0700
committerhwc4872012-05-31 17:11:08 -0700
commit1c445cf5d905f79937998cf2f1115594ea8c1074 (patch)
tree35271ad7ffec86fde9102af3dd954fa3a2974582 /js/document/views
parent335ce503996e3ccbd2909086328d0a31fbd03370 (diff)
parent6042bdc5f2aada4412912fd01602d32c9088dc26 (diff)
downloadninja-1c445cf5d905f79937998cf2f1115594ea8c1074.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Conflicts: js/io/system/ninjalibrary.json
Diffstat (limited to 'js/document/views')
-rwxr-xr-xjs/document/views/base.js48
-rwxr-xr-xjs/document/views/code.js142
-rwxr-xr-xjs/document/views/design.js431
3 files changed, 611 insertions, 10 deletions
diff --git a/js/document/views/base.js b/js/document/views/base.js
index 50c0a78d..d13dce1a 100755
--- a/js/document/views/base.js
+++ b/js/document/views/base.js
@@ -7,15 +7,59 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7//////////////////////////////////////////////////////////////////////// 7////////////////////////////////////////////////////////////////////////
8// 8//
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component; 10 Component = require("montage/ui/component").Component,
11 UrlParser = require("js/document/helpers/url-parser").UrlParser;
11//////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////
12// 13//
13exports.BaseDocumentView = Montage.create(Component, { 14exports.BaseDocumentView = Montage.create(Component, {
14 //////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////
15 // 16 //
16 hasTemplate: { 17 hasTemplate: {
17 enumerable: false,
18 value: false 18 value: false
19 },
20 ////////////////////////////////////////////////////////////////////
21 //
22 urlParser: {
23 value: UrlParser
24 },
25 ////////////////////////////////////////////////////////////////////
26 //
27 _iframe: {
28 value: null
29 },
30 ////////////////////////////////////////////////////////////////////
31 //TODO: This should be renamed to better illustrate it's a container (iframe for design, div for code view)
32 iframe: {
33 get: function() {return this._iframe;},
34 set: function(value) {this._iframe= value;}
35 },
36 ////////////////////////////////////////////////////////////////////
37 //
38 show: {
39 value: function (callback) {
40 if (this.iframe) {
41 this.iframe.style.display = 'block';
42 this.iframe.style.opacity = 1;
43 } else {
44 console.log('Error: View has no iframe to show!');
45 }
46 //
47 if (callback) callback();
48 }
49 },
50 ////////////////////////////////////////////////////////////////////
51 //
52 hide: {
53 value: function (callback) {
54 if (this.iframe) {
55 this.iframe.style.display = 'none';
56 this.iframe.style.opacity = 0;
57 } else {
58 console.log('Error: View has no iframe to hide!');
59 }
60 //
61 if (callback) callback();
62 }
19 } 63 }
20 //////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////
21 //////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/views/code.js b/js/document/views/code.js
index cd3e02d4..0a0ff5c1 100755
--- a/js/document/views/code.js
+++ b/js/document/views/code.js
@@ -10,16 +10,150 @@ 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//
14exports.CodeDocumentView = Montage.create(BaseDocumentView, { 14exports.CodeDocumentView = Montage.create(BaseDocumentView, {
15 //////////////////////////////////////////////////////////////////// 15 ////////////////////////////////////////////////////////////////////
16 // 16 //
17 hasTemplate: { 17 hasTemplate: {
18 enumerable: false,
19 value: false 18 value: false
19 },
20 ////////////////////////////////////////////////////////////////////
21 //
22 _editor: {
23 value: null
24 },
25 ////////////////////////////////////////////////////////////////////
26 //
27 editor: {
28 get: function() {return this._editor;},
29 set: function(value) {this._editor = value;}
30 },
31 ////////////////////////////////////////////////////////////////////
32 //
33 _textArea: {
34 value: null
35 },
36 ////////////////////////////////////////////////////////////////////
37 //
38 textArea: {
39 get: function() {return this._textArea;},
40 set: function(value) {this._textArea = value;}
41 },
42 ////////////////////////////////////////////////////////////////////
43 //
44 _textViewContainer: {
45 value: null
46 },
47 ////////////////////////////////////////////////////////////////////
48 //
49 textViewContainer: {
50 get: function() {return this._textViewContainer;},
51 set: function(value) {this._textViewContainer = value;}
52 },
53 ////////////////////////////////////////////////////////////////////
54 //
55 initialize:{
56 value: function(parentContainer){
57 //create contianer
58 this.textViewContainer = document.createElement("div");
59 //this.textViewContainer.id = "codemirror_" + uuid;
60 this.textViewContainer.style.display = "block";
61 parentContainer.appendChild(this.textViewContainer);
62 //create text area
63 this.textArea = this.createTextAreaElement();
64 }
65 },
66 ////////////////////////////////////////////////////////////////////
67 //Creates a textarea element which will contain the content of the opened text document
68 createTextAreaElement: {
69 value: function() {
70 var textArea = document.createElement("textarea");
71 //textArea.id = "code";
72 //textArea.name = "code";
73 this.textViewContainer.appendChild(textArea);
74 //Returns textarea element
75 return textArea;
76 }
77 },
78 ////////////////////////////////////////////////////////////////////
79 //Creates a new instance of a code editor
80 initializeTextView: {
81 value: function(file, textDocument) {
82 //
83 var type;
84 //
85 if(this.activeDocument) {
86 //need to hide only if another document was open before
87 //this.application.ninja.documentController._hideCurrentDocument();
88 //this.hideOtherDocuments(doc.uuid);
89 }
90 //
91 switch(file.extension) {
92 case "css" :
93 type = "css";
94 break;
95 case "js" :
96 type = "javascript";
97 break;
98 case "html" :
99 type = "htmlmixed";
100 break;
101 case "json" :
102 type = "javascript";
103 break;
104 case "php" :
105 type = "php";
106 break;
107 case "pl" :
108 type = "perl";
109 break;
110 case "py" :
111 type = "python";
112 break;
113 case "rb" :
114 type = "ruby";
115 break;
116 case "xml" :
117 type = "xml";
118 break;
119 }
120 //
121 this.textViewContainer.style.display="block";
122 //
123 this.editor = this.application.ninja.codeEditorController.createEditor(this, type, file.extension, textDocument);
124 this.editor.hline = this.editor.setLineClass(0, "activeline");
125 }
126 },
127 ////////////////////////////////////////////////////////////////////
128 //
129 show: {
130 value: function (callback) {
131 //
132 this.textViewContainer.style.display = "block";
133 //
134 if (callback) callback();
135 }
136 },
137 ////////////////////////////////////////////////////////////////////
138 //
139 hide: {
140 value: function (callback) {
141 //
142 this.textViewContainer.style.display = "none";
143 //
144 if (callback) callback();
145 }
146 },
147 ////////////////////////////////////////////////////////////////////
148 //
149 applyTheme:{
150 value:function(themeClass){
151 //Todo: change for bucket structure of documents
152 this.textViewContainer.className = "codeViewContainer "+themeClass;
153 }
20 } 154 }
21 //////////////////////////////////////////////////////////////////// 155 ////////////////////////////////////////////////////////////////////
22 //////////////////////////////////////////////////////////////////// 156 ////////////////////////////////////////////////////////////////////
23}); 157});
24//////////////////////////////////////////////////////////////////////// 158////////////////////////////////////////////////////////////////////////
25//////////////////////////////////////////////////////////////////////// \ No newline at end of file 159//////////////////////////////////////////////////////////////////////// \ No newline at end of file
diff --git a/js/document/views/design.js b/js/document/views/design.js
index 84871257..c7313708 100755
--- a/js/document/views/design.js