aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorArmen Kesablyan2012-05-23 14:34:58 -0700
committerArmen Kesablyan2012-05-23 14:34:58 -0700
commitc21db7f1e4a0582777bdb5366df5d023a915b779 (patch)
treec4d29cb4686101d4a480ae836d20187879cf5400 /js/stage
parent3ed95247e9ea4b0a7833401ed6809647b7c4acbf (diff)
parent1a7e347810401e6262d9d7bad1c3583e6773993b (diff)
downloadninja-c21db7f1e4a0582777bdb5366df5d023a915b779.tar.gz
Merge branch 'refs/heads/dom-architecture' into binding
Conflicts: js/data/panels-data.js Signed-off-by: Armen Kesablyan <armen@motorola.com>
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/stage-deps.js73
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js154
-rwxr-xr-xjs/stage/stage.reel/stage.html3
-rwxr-xr-xjs/stage/stage.reel/stage.js144
4 files changed, 86 insertions, 288 deletions
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js
index 1825eb06..0d53696b 100755
--- a/js/stage/stage-deps.js
+++ b/js/stage/stage-deps.js
@@ -11,8 +11,7 @@ var Montage = require("montage/core/core").Montage,
11 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, 11 drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils,
12 ElementPlanes = require("js/helper-classes/3D/element-planes").ElementPlanes, 12 ElementPlanes = require("js/helper-classes/3D/element-planes").ElementPlanes,
13 MathUtilsClass = require("js/helper-classes/3D/math-utils").MathUtilsClass, 13 MathUtilsClass = require("js/helper-classes/3D/math-utils").MathUtilsClass,
14 VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, 14 VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils;
15 DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase;
16 15
17exports.StageDeps = Montage.create(Component, { 16exports.StageDeps = Montage.create(Component, {
18 viewUtils: { 17 viewUtils: {
@@ -27,24 +26,6 @@ exports.StageDeps = Montage.create(Component, {
27 value: drawUtils 26 value: drawUtils
28 }, 27 },
29 28
30 currentStage: {
31 value: null
32 },
33
34 _currentDocument: {
35 value: null
36 },
37
38 currentDocument: {
39 get: function() { return this._currentDocument; },
40 set: function(value) {
41 if(value) {
42 this._currentDocument = value;
43 this.currentStage = value.documentRoot;
44 }
45 }
46 },
47
48 _userContentLeft: { 29 _userContentLeft: {
49 value: null 30 value: null
50 }, 31 },
@@ -74,8 +55,9 @@ exports.StageDeps = Montage.create(Component, {
74 deserializedFromTemplate: { 55 deserializedFromTemplate: {
75 value: function() { 56 value: function() {
76 57
77 this.eventManager.addEventListener( "appLoaded", this, false); 58 this.eventManager.addEventListener("appLoaded", this, false);
78 this.eventManager.addEventListener( "openDocument", this, false); 59 this.eventManager.addEventListener("openDocument", this, false);
60 this.eventManager.addEventListener("switchDocument", this, false);
79 61
80 // Initialize Deps 62 // Initialize Deps
81 // HACK 63 // HACK
@@ -112,7 +94,9 @@ exports.StageDeps = Montage.create(Component, {
112 // bind the snap properties to the snap manager 94 // bind the snap properties to the snap manager
113 snapManager.bindSnap(); 95 snapManager.bindSnap();
114 96
115 97 drawUtils.viewUtils = viewUtils;
98 drawUtils.snapManager = snapManager;
99 drawUtils.ElementPlanes = ElementPlanes;
116 } 100 }
117 }, 101 },
118 102
@@ -121,53 +105,22 @@ exports.StageDeps = Montage.create(Component, {
121 105
122 workingPlane = [0,0,1,0]; 106 workingPlane = [0,0,1,0];
123 107
124 snapManager.setCurrentStage(this.currentStage); 108 snapManager.reload2DCache();
125 109 snapManager.setupDragPlaneFromPlane (workingPlane);
126 viewUtils.setCurrentDocument(this.currentDocument);
127 viewUtils.setRootElement(this.currentStage.parentNode);
128 viewUtils.setStageElement(this.currentStage);
129
130 drawUtils.viewUtils = viewUtils;
131 drawUtils.snapManager = snapManager;
132 drawUtils.ElementPlanes = ElementPlanes;
133
134 snapManager._isCacheInvalid=true;
135
136 snapManager.setupDragPlaneFromPlane ( workingPlane );
137
138 DrawingToolBase.stage = this.currentStage;
139 DrawingToolBase.stageComponent = this.stage;
140 110
141 drawUtils.initializeFromDocument(); 111 drawUtils.initializeFromDocument();
142 } 112 }
143 }, 113 },
144 114
145 reinitializeForSwitchDocument: { 115 handleSwitchDocument: {
146 value: function() { 116 value: function(){
147
148 workingPlane = [0,0,1,0]; 117 workingPlane = [0,0,1,0];
149 118
150 snapManager.setCurrentStage(this.currentStage); 119 snapManager.setupDragPlaneFromPlane (workingPlane);
120 snapManager.reload2DCache();
151 121
152 viewUtils.setCurrentDocument(this.currentDocument);
153 viewUtils.setRootElement(this.currentStage.parentNode);
154 viewUtils.setStageElement(this.currentStage);
155
156 drawUtils.viewUtils = viewUtils;
157 drawUtils.snapManager = snapManager;
158 drawUtils.ElementPlanes = ElementPlanes;
159
160 snapManager._isCacheInvalid=true;
161
162 snapManager.setupDragPlaneFromPlane ( workingPlane );
163
164 DrawingToolBase.stage = this.currentStage;
165 DrawingToolBase.stageComponent = this.stage;
166 122
167 drawUtils.initializeFromDocument(); 123 drawUtils.initializeFromDocument();
168 } 124 }
169 } 125 }
170
171
172
173}); \ No newline at end of file 126}); \ No newline at end of file
diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js
index ba94fadf..2c129ee2 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -33,107 +33,10 @@ exports.StageView = Montage.create(Component, {
33 33
34 /** 34 /**
35 * Public method 35 * Public method
36 * Creates a textarea element which will contain the content of the opened text document.
37 */
38 createTextAreaElement: {
39 value: function(uuid) {
40 var codeMirrorDiv = document.createElement("div");
41 codeMirrorDiv.id = "codeMirror_" + uuid;
42 codeMirrorDiv.style.display = "block";
43 this.element.appendChild(codeMirrorDiv);
44
45 var textArea = document.createElement("textarea");
46 textArea.id = "code";
47 textArea.name = "code";
48 codeMirrorDiv.appendChild(textArea);
49
50 return textArea;
51 }
52 },
53
54 /**
55 * Public method
56 * Creates a new instance of a code editor
57 */
58 createTextView: {
59 value: function(doc) {
60 var type;
61 this.application.ninja.documentController._hideCurrentDocument();
62 this.hideOtherDocuments(doc.uuid);
63
64 switch(doc.documentType) {
65 case "css" :
66 type = "css";
67 break;
68 case "js" :
69 type = "javascript";
70 break;
71 case "html" :
72 type = "htmlmixed";
73 break;
74 case "json" :
75 type = "javascript";
76 break;
77 case "php" :
78 type = "php";
79 break;
80 case "pl" :
81 type = "perl";
82 break;
83 case "py" :
84 type = "python";
85 break;
86 case "rb" :
87 type = "ruby";
88 break;
89 case "xml" :
90 type = "xml";
91 break;
92 }
93 document.getElementById("codeMirror_"+doc.uuid).style.display="block";
94
95 doc.editor = this.application.ninja.codeEditorController.createEditor(doc, type, doc.documentType);
96 doc.editor.hline = doc.editor.setLineClass(0, "activeline");
97
98 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
99 this.application.ninja.documentController.activeDocument = doc;
100 this.application.ninja.stage.hideCanvas(true);
101 document.getElementById("iframeContainer").style.display="none";//hide the iframe when switching to code view
102
103 this.showCodeViewBar(true);
104 this.application.ninja.codeEditorController.applySettings();
105 this.collapseAllPanels();
106 }
107 },
108
109 /**
110 * Public method
111 * Switches between documents. Document state data is saved and restored whereever applicable 36 * Switches between documents. Document state data is saved and restored whereever applicable
112 */ 37 */
113 switchDocument:{ 38 switchDocument:{
114 value: function(doc){ 39 value: function(doc){
115 this.application.ninja.documentController._hideCurrentDocument();
116 this.application.ninja.documentController.activeDocument = doc;
117
118 if(this.application.ninja.documentController.activeDocument.currentView === "design") {
119 this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument;
120 }
121
122 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
123
124
125// this.application.ninja.documentController._showCurrentDocument();
126 // Inline function below
127