aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/stage-deps.js73
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js22
-rwxr-xr-xjs/stage/stage.reel/stage.html3
-rwxr-xr-xjs/stage/stage.reel/stage.js77
4 files changed, 35 insertions, 140 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 e8f29306..139fa032 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -37,28 +37,6 @@ exports.StageView = Montage.create(Component, {
37 */ 37 */
38 switchDocument:{ 38 switchDocument:{
39 value: function(doc){ 39 value: function(doc){
40 this.application.ninja.documentController._hideCurrentDocument();
41 this.application.ninja.documentController.activeDocument = doc;
42
43 if(this.application.ninja.documentController.activeDocument.currentView === "design") {
44 this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument;
45 }
46
47 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
48
49
50// this.application.ninja.documentController._showCurrentDocument();
51 // Inline function below
52 if(this.activeDocument) {
53 this.activeDocument.container.style["display"] = "block";
54 if(this.activeDocument.currentView === "design"){
55 this.activeDocument.container.parentNode.style["display"] = "block";
56 this.activeDocument.restoreAppState();
57 } else {
58 //hide the iframe when switching to code view
59 document.getElementById("iframeContainer").style.display = "none";
60 }
61 }
62 40
63 41
64 //focus editor 42 //focus editor
diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html
index 88cd6149..30c3d231 100755
--- a/js/stage/stage.reel/stage.html
+++ b/js/stage/stage.reel/stage.html
@@ -22,9 +22,6 @@
22 "prototype": "js/stage/stage-deps", 22 "prototype": "js/stage/stage-deps",
23 "properties": { 23 "properties": {
24 "stage": {"@": "owner"} 24 "stage": {"@": "owner"}
25 },
26 "bindings": {
27 "currentDocument": {"<-": "@owner.activeDocument"}
28 } 25 }
29 }, 26 },
30 27
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index cac99326..73d3aaf4 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -108,7 +108,6 @@ exports.Stage = Montage.create(Component, {
108 // We will set this to false while moving objects to improve performance 108 // We will set this to false while moving objects to improve performance
109 showSelectionBounds: { value: true }, 109 showSelectionBounds: { value: true },
110 110
111 _documentRoot: { value: null },
112 _viewport: { value: null }, 111 _viewport: { value: null },
113 _documentOffsetLeft: { value: 0 }, 112 _documentOffsetLeft: { value: 0 },
114 _documentOffsetTop: { value: 0 }, 113 _documentOffsetTop: { value: 0 },
@@ -121,11 +120,6 @@ exports.Stage = Montage.create(Component, {
121 _maxHorizontalScroll: { value: 0 }, 120 _maxHorizontalScroll: { value: 0 },
122 _maxVerticalScroll: { value: 0 }, 121 _maxVerticalScroll: { value: 0 },
123 122
124 documentRoot: {
125 get: function () { return this._documentRoot; },
126 set: function(value) { this._documentRoot = value; }
127 },
128
129 viewport: { 123 viewport: {
130 get: function () { return this._viewport; }, 124 get: function () { return this._viewport; },
131 set: function(value) { this._viewport = value; } 125 set: function(value) { this._viewport = value; }
@@ -195,10 +189,7 @@ exports.Stage = Montage.create(Component, {
195 set: function(value) { 189 set: function(value) {
196 this._userPaddingLeft = value; 190 this._userPaddingLeft = value;
197 this._documentOffsetLeft = -value; 191 this._documentOffsetLeft = -value;
198 if(!this._documentRoot) { 192 this.application.ninja.currentDocument.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px";
199 this._documentRoot = this.application.ninja.currentDocument.documentRoot;
200 }
201 this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px";
202 this.userContentLeft = this._documentOffsetLeft; 193 this.userContentLeft = this._documentOffsetLeft;
203 this.updatedStage = true; 194 this.updatedStage = true;
204 } 195 }
@@ -209,10 +200,7 @@ exports.Stage = Montage.create(Component, {
209 set: function(value) { 200 set: function(value) {
210 this._userPaddingTop = value; 201 this._userPaddingTop = value;
211 this._documentOffsetTop = -value; 202 this._documentOffsetTop = -value;
212 if(!this._documentRoot) { 203 this.application.ninja.currentDocument.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px";
213 this._documentRoot = this.application.ninja.currentDocument.documentRoot;
214 }
215 this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px";
216 this.userContentTop = this._documentOffsetTop; 204 this.userContentTop = this._documentOffsetTop;
217 this.updatedStage = true; 205 this.updatedStage = true;
218 } 206 }
@@ -287,46 +275,17 @@ exports.Stage = Montage.create(Component, {
287 this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ;