aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/layout.js2
-rwxr-xr-xjs/stage/stage-deps.js83
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js170
-rwxr-xr-xjs/stage/stage.reel/stage.js201
4 files changed, 157 insertions, 299 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js
index 0a76dbe5..9c5e2167 100755
--- a/js/stage/layout.js
+++ b/js/stage/layout.js
@@ -156,7 +156,7 @@ exports.Layout = Montage.create(Component, {
156 drawTagOutline: { 156 drawTagOutline: {
157 value: function (item) { 157 value: function (item) {
158 158
159 if(!item || (item.nodeType !== 1)) return; 159 if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return;
160 160
161 // TODO Bind the layoutview mode to the current document 161 // TODO Bind the layoutview mode to the current document
162 // var mode = this.application.ninja.currentDocument.layoutMode; 162 // var mode = this.application.ninja.currentDocument.layoutMode;
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js
index a71b77be..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 },
@@ -52,7 +33,7 @@ exports.StageDeps = Montage.create(Component, {
52 userContentLeft: { 33 userContentLeft: {
53 get: function() { return this._userContentLeft; }, 34 get: function() { return this._userContentLeft; },
54 set: function(value) { 35 set: function(value) {
55 if(value) { 36 if(value != null) {
56 viewUtils.setUserContentLeft(value); 37 viewUtils.setUserContentLeft(value);
57 } 38 }
58 } 39 }
@@ -65,7 +46,7 @@ exports.StageDeps = Montage.create(Component, {
65 userContentTop: { 46 userContentTop: {
66 get: function() { return this._userContentTop; }, 47 get: function() { return this._userContentTop; },
67 set: function(value) { 48 set: function(value) {
68 if(value) { 49 if(value != null) {
69 viewUtils.setUserContentTop(value); 50 viewUtils.setUserContentTop(value);
70 } 51 }
71 } 52 }
@@ -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
@@ -95,12 +77,6 @@ exports.StageDeps = Montage.create(Component, {
95 handleAppLoaded: { 77 handleAppLoaded: {
96 value: function() { 78 value: function() {
97 79
98 Object.defineBinding(this, "currentDocument", {
99 boundObject: this.application.ninja,
100 boundObjectPropertyPath: "currentDocument",
101 oneway: true
102 });
103
104 Object.defineBinding(this, "userContentLeft", { 80 Object.defineBinding(this, "userContentLeft", {
105 boundObject: this.stage, 81 boundObject: this.stage,
106 boundObjectPropertyPath: "_userContentLeft", 82 boundObjectPropertyPath: "_userContentLeft",
@@ -118,7 +94,9 @@ exports.StageDeps = Montage.create(Component, {
118 // bind the snap properties to the snap manager 94 // bind the snap properties to the snap manager
119 snapManager.bindSnap(); 95 snapManager.bindSnap();
120 96
121 97 drawUtils.viewUtils = viewUtils;
98 drawUtils.snapManager = snapManager;
99 drawUtils.ElementPlanes = ElementPlanes;
122 } 100 }
123 }, 101 },
124 102
@@ -127,53 +105,22 @@ exports.StageDeps = Montage.create(Component, {
127 105
128 workingPlane = [0,0,1,0]; 106 workingPlane = [0,0,1,0];
129 107
130 snapManager.setCurrentStage(this.currentStage); 108 snapManager.reload2DCache();
131 109 snapManager.setupDragPlaneFromPlane (workingPlane);
132 viewUtils.setCurrentDocument(this.currentDocument);
133 viewUtils.setRootElement(this.currentStage.parentNode);
134 viewUtils.setStageElement(this.currentStage);
135
136 drawUtils.viewUtils = viewUtils;
137 drawUtils.snapManager = snapManager;
138 drawUtils.ElementPlanes = ElementPlanes;
139
140 snapManager._isCacheInvalid=true;
141
142 snapManager.setupDragPlaneFromPlane ( workingPlane );
143
144 DrawingToolBase.stage = this.currentStage;
145 DrawingToolBase.stageComponent = this.stage;
146 110
147 drawUtils.initializeFromDocument(); 111 drawUtils.initializeFromDocument();
148 } 112 }
149 }, 113 },
150 114
151 reinitializeForSwitchDocument: { 115 handleSwitchDocument: {
152 value: function() { 116 value: function(){
153
154 workingPlane = [0,0,1,0]; 117 workingPlane = [0,0,1,0];
155 118
156 snapManager.setCurrentStage(this.currentStage); 119 snapManager.setupDragPlaneFromPlane (workingPlane);
157 120 snapManager.reload2DCache();
158 viewUtils.setCurrentDocument(this.currentDocument);
159 viewUtils.setRootElement(this.currentStage.parentNode);
160 viewUtils.setStageElement(this.currentStage);
161 121
162 drawUtils.viewUtils = viewUtils;
163 drawUtils.snapManager = snapManager;
164 drawUtils.ElementPlanes = ElementPlanes;
165
166 snapManager._isCacheInvalid=true;
167
168 snapManager.setupDragPlaneFromPlane ( workingPlane );
169
170 DrawingToolBase.stage = this.currentStage;
171 DrawingToolBase.stageComponent = this.stage;
172 122
173 drawUtils.initializeFromDocument(); 123 drawUtils.initializeFromDocument();
174 } 124 }
175 } 125 }
176
177
178
179}); \ 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 518c3bdd..2c129ee2 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -25,122 +25,20 @@ exports.StageView = Montage.create(Component, {
25 } 25 }
26 }, 26 },
27 27
28 templateDidLoad: {
29 value: function() {
30 this.eventManager.addEventListener("appLoaded", this, false);
31 }
32 },
33
34 didDraw:{ 28 didDraw:{
35 value: function() { 29 value: function() {
36 if(!this.application.ninja.documentController._textHolder) this.application.ninja.documentController._textHolder = this.element; 30 if(!this.application.ninja.documentController._textHolder) this.application.ninja.documentController._textHolder = this.element;
37 } 31 }
38 }, 32 },
39 33
40 handleAppLoaded: {
41 value: function() {
42
43 // Don't bind for now
44 /*
45 Object.defineBinding(this, "docs", {
46 boundObject: this.application.ninja.documentController,
47 boundObjectPropertyPath: "_documents"
48 });
49 */
50
51 }
52 },
53
54 /**
55 * Public method
56 * Creates a textarea element which will contain the content of the opened text document.
57 */
58 createTextAreaElement: {
59 value: function(uuid) {
60 var codeMirrorDiv = document.createElement("div");
61 codeMirrorDiv.id = "codeMirror_" + uuid;
62 codeMirrorDiv.style.display = "block";
63 this.element.appendChild(codeMirrorDiv);
64
65 var textArea = document.createElement("textarea");
66 textArea.id = "code";
67 textArea.name = "code";
68 codeMirrorDiv.appendChild(textArea);
69
70 return textArea;
71 }
72 },
73
74 /**
75 * Public method
76 * Creates a new instanc