1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
</copyright> */
/**
@requires montage/core/core
@requires montage/ui/component
*/
var Montage = require("montage/core/core").Montage,
Component = require("montage/ui/component").Component;
exports.StageView = Montage.create(Component, {
_documents: {
value : []
},
docs: {
get: function() {
return this._documents;
},
set: function(value) {
//console.log(value);
}
},
didDraw:{
value: function() {
if(!this.application.ninja.documentController._textHolder) this.application.ninja.documentController._textHolder = this.element;
}
},
/**
* Public method
* Creates a textarea element which will contain the content of the opened text document.
*/
createTextAreaElement: {
value: function(uuid) {
var codeMirrorDiv = document.createElement("div");
codeMirrorDiv.id = "codeMirror_" + uuid;
codeMirrorDiv.style.display = "block";
this.element.appendChild(codeMirrorDiv);
var textArea = document.createElement("textarea");
textArea.id = "code";
textArea.name = "code";
codeMirrorDiv.appendChild(textArea);
return textArea;
}
},
/**
* Public method
* Creates a new instance of a code editor
*/
createTextView: {
value: function(doc) {
var type;
this.application.ninja.documentController._hideCurrentDocument();
this.hideOtherDocuments(doc.uuid);
switch(doc.documentType) {
case "css" :
type = "css";
break;
case "js" :
type = "javascript";
break;
case "html" :
type = "htmlmixed";
break;
case "json" :
type = "javascript";
break;
case "php" :
type = "php";
break;
case "pl" :
type = "perl";
break;
case "py" :
type = "python";
break;
case "rb" :
type = "ruby";
break;
case "xml" :
type = "xml";
break;
}
document.getElementById("codeMirror_"+doc.uuid).style.display="block";
doc.editor = this.application.ninja.codeEditorController.createEditor(doc, type, doc.documentType);
doc.editor.hline = doc.editor.setLineClass(0, "activeline");
this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
this.application.ninja.documentController.activeDocument = doc;
this.application.ninja.stage.hideCanvas(true);
document.getElementById("iframeContainer").style.display="none";//hide the iframe when switching to code view
this.showCodeViewBar(true);
this.application.ninja.codeEditorController.applySettings();
this.collapseAllPanels();
}
},
/**
* Public method
* Switches between documents. Document state data is saved and restored whereever applicable
*/
switchDocument:{
value: function(doc){
//focus editor
if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){
this.application.ninja.documentController.activeDocument.editor.focus();
this.showCodeViewBar(true);
this.application.ninja.codeEditorController.applySettings();
this.collapseAllPanels();
}
if(this.application.ninja.documentController.activeDocument.currentView === "design") {
this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe
this.application.ninja.stage.stageDeps.reinitializeForSwitchDocument();//reinitialize draw-util, snapmanager and view-util
this.showCodeViewBar(false);
this.restoreAllPanels();
}
NJevent("switchDocument");
}
},
/**
* Public method
* Switches between different views of a design document, like HTML design view, HTML code view
*/
switchDesignDocViews: {
value: function() {
//TODO
}
},
showRulers:{
value:function(){
this.application.ninja.rulerTop.style.display = "block";
this.application.ninja.rulerLeft.style.display = "block";
}
},
hideRulers:{
value:function(){
this.application.ninja.rulerTop.style.display = "none";
this.application.ninja.rulerLeft.style.display = "none";
}
},
showCodeViewBar:{
value:function(isCodeView){
if(isCodeView === true) {
this.application.ninja.editorViewOptions.element.style.display = "block";
this.application.ninja.documentBar.element.style.display = "none";
} else {
this.application.ninja.documentBar.element.style.display = "block";
this.application.ninja.editorViewOptions.element.style.display = "none";
}
}
},
collapseAllPanels:{
value:function(){
this.application.ninja.panelSplitter.collapse();
this.application.ninja.timelineSplitter.collapse();
this.application.ninja.toolsSplitter.collapse();
this.application.ninja.optionsSplitter.collapse();
}
},
restoreAllPanels:{
value:function(){
this.application.ninja.panelSplitter.restore();
this.application.ninja.timelineSplitter.restore();
this.application.ninja.toolsSplitter.restore();
this.application.ninja.optionsSplitter.restore();
}
},
applyTheme:{
value:function(themeClass){
this.element.className = "codeViewContainer "+themeClass;
}
}
});
|