aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorJose Antonio Marquez Russo2012-02-24 15:44:57 -0800
committerJose Antonio Marquez Russo2012-02-24 15:44:57 -0800
commit97c0efb645b1e0488112c1b7bfd7fa4864eae3dc (patch)
treeae6c6587af2ab5ec34f86ac05d342ecf8ebfc0c7 /js/stage
parentc916a2a5fec0c96bd1c6f56af82543da9b69c33c (diff)
parentb056b4bef5982466d80d72e5cbb31e63087990e1 (diff)
downloadninja-97c0efb645b1e0488112c1b7bfd7fa4864eae3dc.tar.gz
Merge pull request #19 from ananyasen/FileIO
FileIO branch pull request
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/layout.js5
-rwxr-xr-xjs/stage/stage-deps.js38
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js21
-rwxr-xr-xjs/stage/stage.reel/stage.js14
4 files changed, 58 insertions, 20 deletions
diff --git a/js/stage/layout.js b/js/stage/layout.js
index a94dd10c..de4c67c1 100755
--- a/js/stage/layout.js
+++ b/js/stage/layout.js
@@ -98,6 +98,11 @@ exports.Layout = Montage.create(Component, {
98 98
99 handleSelectionChange: { 99 handleSelectionChange: {
100 value: function(event) { 100 value: function(event) {
101
102 if(this.application.ninja.documentController.activeDocument === null){
103 return;
104 }
105
101 // Make an array copy of the line node list which is not an array like object 106 // Make an array copy of the line node list which is not an array like object
102 this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); 107 this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0);
103 108
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js
index d46e2b81..16f2c652 100755
--- a/js/stage/stage-deps.js
+++ b/js/stage/stage-deps.js
@@ -23,6 +23,10 @@ exports.StageDeps = Montage.create(Component, {
23 value: snapManager 23 value: snapManager
24 }, 24 },
25 25
26 drawUtils: {
27 value: drawUtils
28 },
29
26 currentStage: { 30 currentStage: {
27 value: null 31 value: null
28 }, 32 },
@@ -129,19 +133,47 @@ exports.StageDeps = Montage.create(Component, {
129 viewUtils.setRootElement(this.currentStage.parentNode); 133 viewUtils.setRootElement(this.currentStage.parentNode);
130 viewUtils.setStageElement(this.currentStage); 134 viewUtils.setStageElement(this.currentStage);
131 135
132 drawUtils.setDrawingSurfaceElement(this.stage.canvas);
133 drawUtils.setSourceSpaceElement( this.currentStage );
134 drawUtils.setWorkingPlane( workingPlane );
135 drawUtils.viewUtils = viewUtils; 136 drawUtils.viewUtils = viewUtils;
136 drawUtils.snapManager = snapManager; 137 drawUtils.snapManager = snapManager;
137 drawUtils.ElementPlanes = ElementPlanes; 138 drawUtils.ElementPlanes = ElementPlanes;
138 139
140 snapManager._isCacheInvalid=true;
141
142 snapManager.setupDragPlaneFromPlane ( workingPlane );
143
144 DrawingToolBase.stage = this.currentStage;
145 DrawingToolBase.stageComponent = this.stage;
146
147 drawUtils.initializeFromDocument();
148 }
149 },
150
151 reinitializeForSwitchDocument: {
152 value: function() {
153
154 workingPlane = Vector.create( [0,0,1,0] );
155
156 snapManager.setCurrentStage(this.currentStage);
157
158 viewUtils.setCurrentDocument(this.currentDocument);
159 viewUtils.setRootElement(this.currentStage.parentNode);
160 viewUtils.setStageElement(this.currentStage);
161
162 drawUtils.viewUtils = viewUtils;
163 drawUtils.snapManager = snapManager;
164 drawUtils.ElementPlanes = ElementPlanes;
165
166 snapManager._isCacheInvalid=true;
167
139 snapManager.setupDragPlaneFromPlane ( workingPlane ); 168 snapManager.setupDragPlaneFromPlane ( workingPlane );
140 169
141 DrawingToolBase.stage = this.currentStage; 170 DrawingToolBase.stage = this.currentStage;
142 DrawingToolBase.stageComponent = this.stage; 171 DrawingToolBase.stageComponent = this.stage;
143 172
173 drawUtils.initializeFromDocument();
144 } 174 }
145 } 175 }
146 176
177
178
147}); \ No newline at end of file 179}); \ 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 dc9980f0..91047e51 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -118,14 +118,9 @@ exports.StageView = Montage.create(Component, {
118 } 118 }
119 }, 119 },
120 120
121 121 //called for switching between html documents
122
123 switchDocument:{ 122 switchDocument:{
124 value: function(doc){ 123 value: function(doc){
125 //save editor cursor position
126 if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){
127 this.application.ninja.documentController.activeDocument.hline = this.application.ninja.documentController.activeDocument.editor.getCursor(true);
128 }
129 this.application.ninja.documentController._hideCurrentDocument(); 124 this.application.ninja.documentController._hideCurrentDocument();
130 125
131 this.application.ninja.documentController.activeDocument = doc; 126 this.application.ninja.documentController.activeDocument = doc;
@@ -133,22 +128,26 @@ exports.StageView = Montage.create(Component, {
133 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe 128 this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe
134 this.application.ninja.documentController._showCurrentDocument(); 129 this.application.ninja.documentController._showCurrentDocument();
135 130
136 var documentController = this.application.ninja.documentController; 131 //focus current document
137
138 //restore editor cursor position
139 if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ 132 if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){
140 this.application.ninja.documentController.activeDocument.editor.setCursor(this.application.ninja.documentController.activeDocument.hline);
141 document.getElementById("codeMirror_"+this.application.ninja.documentController.activeDocument.uuid).getElementsByClassName("CodeMirror")[0].focus(); 133 document.getElementById("codeMirror_"+this.application.ninja.documentController.activeDocument.uuid).getElementsByClassName("CodeMirror")[0].focus();
142 } 134 }
143 135
144 if(this.application.ninja.documentController.activeDocument.currentView === "design") { 136 if(this.application.ninja.documentController.activeDocument.currentView === "design") {
145 this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe 137 this.application.ninja.stage._scrollFlag = true; // TODO HACK to prevent type error on Hide/Show Iframe
146 this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; 138 this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument;
139
140 //reinitialize draw-util, snapmanager and view-util
141 this.application.ninja.stage.stageDeps.reinitializeForSwitchDocument();
142
143 //this.application.ninja.stage.layout.reinitializeForSwitchDocument();
147 144
148 // TODO dispatch event here 145 // TODO dispatch event here
149 // appDelegateModule.MyAppDelegate.onSetActiveDocument(); 146 // appDelegateModule.MyAppDelegate.onSetActiveDocument();
150 } 147 }
151 148
149 NJevent("switchDocument");
150
152 } 151 }
153 }, 152 },
154 153
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 8d664f25..9784f14d 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -37,6 +37,10 @@ exports.Stage = Montage.create(Component, {
37 get: function() { return this.stageDeps.snapManager; } 37 get: function() { return this.stageDeps.snapManager; }
38 }, 38 },
39 39
40 drawUtils: {
41 get: function() { return this.stageDeps.drawUtils; }
42 },
43
40 resizeCanvases: { 44 resizeCanvases: {
41 get: function() { 45 get: function() {
42 return this._resizeCanvases; 46 return this._resizeCanvases;
@@ -144,12 +148,12 @@ exports.Stage = Montage.create(Component, {
144 148
145 userContentLeft: { 149 userContentLeft: {
146 get: function() { return this._userContentLeft; }, 150 get: function() { return this._userContentLeft; },
147 set: function(value) { this._userContentLeft = value; } 151 set: function(value) { this._userContentLeft = value;}
148 }, 152 },
149 153
150 userContentTop: { 154 userContentTop: {
151 get: function() { return this._userContentTop; }, 155 get: function() { return this._userContentTop; },
152 set: function(value) { this._userContentTop = value; } 156 set: function(value) { this._userContentTop = value;}
153 }, 157 },
154 158
155 userContentBorder: { 159 userContentBorder: {
@@ -435,12 +439,11 @@ exports.Stage = Montage.create(Component, {
435 */ 439 */
436 handleScroll: { 440 handleScroll: {
437 value: function() { 441 value: function() {
438
439 this._scrollLeft = this._iframeContainer.scrollLeft; 442 this._scrollLeft = this._iframeContainer.scrollLeft;
440 this._scrollTop = this._iframeContainer.scrollTop; 443 this._scrollTop = this._iframeContainer.scrollTop;
441 444
442 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; 445 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
443 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; 446 this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
444 447
445 // Need to clear the snap cache and set up the drag plane 448 // Need to clear the snap cache and set up the drag plane
446 //snapManager.setupDragPlaneFromPlane( workingPlane ); 449 //snapManager.setupDragPlaneFromPlane( workingPlane );
@@ -448,7 +451,6 @@ exports.Stage = Montage.create(Component, {
448 451
449 this.needsDraw = true; 452 this.needsDraw = true;
450 this.layout.draw(); 453 this.layout.draw();
451
452 //this._toolsList.action("DrawHandles"); 454 //this._toolsList.action("DrawHandles");
453 455
454 } 456 }