diff options
author | Ananya Sen | 2012-02-23 13:43:35 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-23 13:43:35 -0800 |
commit | 7283884c39df537694b21419a3ea9e3ca7793b4b (patch) | |
tree | bd48aebcfdb2ba36721360a47c1654f22b9f75b6 /js/stage | |
parent | dbf0ca5637a3bca87c21c65ada47f8a4d794f78c (diff) | |
download | ninja-7283884c39df537694b21419a3ea9e3ca7793b4b.tar.gz |
switch html document - re-initialize draw-utils and snap-manager on opening a document and while switching documents
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/stage')
-rwxr-xr-x | js/stage/stage-deps.js | 38 | ||||
-rwxr-xr-x | js/stage/stage-view.reel/stage-view.js | 14 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 4 |
3 files changed, 31 insertions, 25 deletions
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index d46e2b81..316a5bb0 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 | }, |
@@ -119,29 +123,31 @@ exports.StageDeps = Montage.create(Component, { | |||
119 | }, | 123 | }, |
120 | 124 | ||
121 | handleOpenDocument: { | 125 | handleOpenDocument: { |
122 | value: function() { | 126 | value: function() { |
127 | |||
128 | workingPlane = Vector.create( [0,0,1,0] ); | ||
123 | 129 | ||
124 | workingPlane = Vector.create( [0,0,1,0] ); | 130 | snapManager.setCurrentStage(this.currentStage); |
125 | 131 | ||
126 | snapManager.setCurrentStage(this.currentStage); | 132 | viewUtils.setCurrentDocument(this.currentDocument); |
133 | viewUtils.setRootElement(this.currentStage.parentNode); | ||
134 | viewUtils.setStageElement(this.currentStage); | ||
127 | 135 | ||
128 | viewUtils.setCurrentDocument(this.currentDocument); | 136 | drawUtils.viewUtils = viewUtils; |
129 | viewUtils.setRootElement(this.currentStage.parentNode); | 137 | drawUtils.snapManager = snapManager; |
130 | viewUtils.setStageElement(this.currentStage); | 138 | drawUtils.ElementPlanes = ElementPlanes; |
131 | 139 | ||
132 | drawUtils.setDrawingSurfaceElement(this.stage.canvas); | 140 | snapManager._isCacheInvalid=true; |
133 | drawUtils.setSourceSpaceElement( this.currentStage ); | ||
134 | drawUtils.setWorkingPlane( workingPlane ); | ||
135 | drawUtils.viewUtils = viewUtils; | ||
136 | drawUtils.snapManager = snapManager; | ||
137 | drawUtils.ElementPlanes = ElementPlanes; | ||
138 | 141 | ||
139 | snapManager.setupDragPlaneFromPlane ( workingPlane ); | 142 | snapManager.setupDragPlaneFromPlane ( workingPlane ); |
140 | 143 | ||
141 | DrawingToolBase.stage = this.currentStage; | 144 | DrawingToolBase.stage = this.currentStage; |
142 | DrawingToolBase.stageComponent = this.stage; | 145 | DrawingToolBase.stageComponent = this.stage; |
143 | 146 | ||
147 | drawUtils.initializeFromDocument(); | ||
148 | } | ||
144 | } | 149 | } |
145 | } | 150 | |
151 | |||
146 | 152 | ||
147 | }); \ No newline at end of file | 153 | }); \ 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..0b688c75 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js | |||
@@ -122,10 +122,6 @@ exports.StageView = Montage.create(Component, { | |||
122 | 122 | ||
123 | switchDocument:{ | 123 | switchDocument:{ |
124 | value: function(doc){ | 124 | 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(); | 125 | this.application.ninja.documentController._hideCurrentDocument(); |
130 | 126 | ||
131 | this.application.ninja.documentController.activeDocument = doc; | 127 | this.application.ninja.documentController.activeDocument = doc; |
@@ -133,17 +129,17 @@ exports.StageView = Montage.create(Component, { | |||
133 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe | 129 | this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe |
134 | this.application.ninja.documentController._showCurrentDocument(); | 130 | this.application.ninja.documentController._showCurrentDocument(); |
135 | 131 | ||
136 | var documentController = this.application.ninja.documentController; | 132 | //focus current document |
137 | |||
138 | //restore editor cursor position | ||
139 | if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ | 133 | 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(); | 134 | document.getElementById("codeMirror_"+this.application.ninja.documentController.activeDocument.uuid).getElementsByClassName("CodeMirror")[0].focus(); |
142 | } | 135 | } |
143 | 136 | ||
144 | if(this.application.ninja.documentController.activeDocument.currentView === "design") { | 137 | 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 | 138 | 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; | 139 | this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; |
140 | |||
141 | this.application.ninja.stage.snapManager._isCacheInvalid=true; | ||
142 | this.application.ninja.stage.drawUtils.initializeFromDocument(); | ||
147 | 143 | ||
148 | // TODO dispatch event here | 144 | // TODO dispatch event here |
149 | // appDelegateModule.MyAppDelegate.onSetActiveDocument(); | 145 | // appDelegateModule.MyAppDelegate.onSetActiveDocument(); |
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 44e14827..6bb626c2 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; |