aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAnanya Sen2012-02-23 17:55:59 -0800
committerAnanya Sen2012-02-23 17:55:59 -0800
commit6e66f411ba02eaaeb33471115345ecf3c7ce4ce9 (patch)
tree527a26ece79b0e55dbb9a310007010631614cc0c /js
parentec3d07c2fea4e79c68606234074f43d694982e5b (diff)
downloadninja-6e66f411ba02eaaeb33471115345ecf3c7ce4ce9.tar.gz
refresh draw-utils, snap-manager, view-utils for html document stitching
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js18
-rwxr-xr-xjs/stage/stage-deps.js56
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js9
-rwxr-xr-xjs/stage/stage.reel/stage.js10
4 files changed, 57 insertions, 36 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index d38709e3..c5293386 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -645,7 +645,6 @@ exports.HTMLDocument = Montage.create(TextDocument, {
645 this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing; 645 this.gridHorizontalSpacing = this.application.ninja.stage.drawUtils.gridHorizontalSpacing;
646 this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing; 646 this.gridVerticalSpacing = this.application.ninja.stage.drawUtils.gridVerticalSpacing;
647 647
648 //TODO:selection should be saved as an element state data, to avoid duplicate dom elements store in memory
649 if(typeof this.application.ninja.selectedElements !== 'undefined'){ 648 if(typeof this.application.ninja.selectedElements !== 'undefined'){
650 this.selectionModel = this.application.ninja.selectedElements; 649 this.selectionModel = this.application.ninja.selectedElements;
651 } 650 }
@@ -656,24 +655,21 @@ exports.HTMLDocument = Montage.create(TextDocument, {
656 restoreAppState:{ 655 restoreAppState:{
657 enumerable: false, 656 enumerable: false,
658 value: function () { 657 value: function () {
659 if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){
660 this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll;
661 this.application.ninja.stage._scrollLeft = this.savedLeftScroll;
662 this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll;
663 this.application.ninja.stage._scrollTop = this.savedTopScroll;
664 }
665
666 this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing; 658 this.application.ninja.stage.drawUtils.gridHorizontalSpacing = this.gridHorizontalSpacing;
667 this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing; 659 this.application.ninja.stage.drawUtils.gridVerticalSpacing = this.gridVerticalSpacing;
668 660
669 //TODO:selectionController.initWithDocument should loop over elements in documentRoot to repopulate
670 if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){ 661 if((typeof this.selectionModel !== 'undefined') && (this.selectionModel !== null) && (this.selectionModel.length > 0)){
671 this.application.ninja.selectionController.initWithDocument(this.selectionModel); 662 this.application.ninja.selectionController.initWithDocument(this.selectionModel);
672 } 663 }
673
674 664
665 if((this.savedLeftScroll!== null) && (this.savedTopScroll !== null)){
666 this.application.ninja.stage._iframeContainer.scrollLeft = this.savedLeftScroll;
667 this.application.ninja.stage._scrollLeft = this.savedLeftScroll;
668 this.application.ninja.stage._iframeContainer.scrollTop = this.savedTopScroll;
669 this.application.ninja.stage._scrollLeft = this.savedTopScroll;
670 }
671 this.application.ninja.stage.handleScroll();
675 } 672 }
676 } 673 }
677
678 //////////////////////////////////////////////////////////////////// 674 ////////////////////////////////////////////////////////////////////
679}); \ No newline at end of file 675}); \ No newline at end of file
diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js
index 316a5bb0..16f2c652 100755
--- a/js/stage/stage-deps.js
+++ b/js/stage/stage-deps.js
@@ -123,30 +123,56 @@ exports.StageDeps = Montage.create(Component, {
123 }, 123 },
124 124
125 handleOpenDocument: { 125 handleOpenDocument: {
126 value: function() { 126 value: function() {
127 127
128 workingPlane = Vector.create( [0,0,1,0] ); 128 workingPlane = Vector.create( [0,0,1,0] );
129 129
130 snapManager.setCurrentStage(this.currentStage); 130 snapManager.setCurrentStage(this.currentStage);
131 131
132 viewUtils.setCurrentDocument(this.currentDocument); 132 viewUtils.setCurrentDocument(this.currentDocument);
133 viewUtils.setRootElement(this.currentStage.parentNode); 133 viewUtils.setRootElement(this.currentStage.parentNode);
134 viewUtils.setStageElement(this.currentStage); 134 viewUtils.setStageElement(this.currentStage);
135 135
136 drawUtils.viewUtils = viewUtils; 136 drawUtils.viewUtils = viewUtils;
137 drawUtils.snapManager = snapManager; 137 drawUtils.snapManager = snapManager;
138 drawUtils.ElementPlanes = ElementPlanes; 138 drawUtils.ElementPlanes = ElementPlanes;
139 139
140 snapManager._isCacheInvalid=true; 140 snapManager._isCacheInvalid=true;
141 141
142 snapManager.setupDragPlaneFromPlane ( workingPlane ); 142 snapManager.setupDragPlaneFromPlane ( workingPlane );
143 143
144 DrawingToolBase.stage = this.currentStage; 144 DrawingToolBase.stage = this.currentStage;
145 DrawingToolBase.stageComponent = this.stage; 145 DrawingToolBase.stageComponent = this.stage;
146 146
147 drawUtils.initializeFromDocument(); 147 drawUtils.initializeFromDocument();
148 } 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
168 snapManager.setupDragPlaneFromPlane ( workingPlane );
169
170 DrawingToolBase.stage = this.currentStage;
171 DrawingToolBase.stageComponent = this.stage;
172
173 drawUtils.initializeFromDocument();
149 } 174 }
175 }
150 176
151 177
152 178
diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js
index 0b688c75..ab02661d 100755
--- a/js/stage/stage-view.reel/stage-view.js
+++ b/js/stage/stage-view.reel/stage-view.js
@@ -118,8 +118,7 @@ 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 this.application.ninja.documentController._hideCurrentDocument(); 124 this.application.ninja.documentController._hideCurrentDocument();
@@ -138,8 +137,10 @@ exports.StageView = Montage.create(Component, {
138 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
139 this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; 138 this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument;
140 139
141 this.application.ninja.stage.snapManager._isCacheInvalid=true; 140 //reinitialize draw-util, snapmanager and view-util
142 this.application.ninja.stage.drawUtils.initializeFromDocument(); 141 this.application.ninja.stage.stageDeps.reinitializeForSwitchDocument();
142
143 //this.application.ninja.stage.layout.reinitializeForSwitchDocument();
143 144
144 // TODO dispatch event here 145 // TODO dispatch event here
145 // appDelegateModule.MyAppDelegate.onSetActiveDocument(); 146 // appDelegateModule.MyAppDelegate.onSetActiveDocument();
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 755c7ff1..9784f14d 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -148,12 +148,12 @@ exports.Stage = Montage.create(Component, {
148 148
149 userContentLeft: { 149 userContentLeft: {
150 get: function() { return this._userContentLeft; }, 150 get: function() { return this._userContentLeft; },
151 set: function(value) { this._userContentLeft = value; } 151 set: function(value) { this._userContentLeft = value;}
152 }, 152 },
153 153
154 userContentTop: { 154 userContentTop: {
155 get: function() { return this._userContentTop; }, 155 get: function() { return this._userContentTop; },
156 set: function(value) { this._userContentTop = value; } 156 set: function(value) { this._userContentTop = value;}
157 }, 157 },
158 158
159 userContentBorder: { 159 userContentBorder: {
@@ -439,12 +439,11 @@ exports.Stage = Montage.create(Component, {
439 */ 439 */
440 handleScroll: { 440 handleScroll: {
441 value: function() { 441 value: function() {
442
443 this._scrollLeft = this._iframeContainer.scrollLeft; 442 this._scrollLeft = this._iframeContainer.scrollLeft;
444 this._scrollTop = this._iframeContainer.scrollTop; 443 this._scrollTop = this._iframeContainer.scrollTop;
445 444
446 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; 445 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
447 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; 446 this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
448 447
449 // 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
450 //snapManager.setupDragPlaneFromPlane( workingPlane ); 449 //snapManager.setupDragPlaneFromPlane( workingPlane );
@@ -452,7 +451,6 @@ exports.Stage = Montage.create(Component, {
452 451
453 this.needsDraw = true; 452 this.needsDraw = true;
454 this.layout.draw(); 453 this.layout.draw();
455
456 //this._toolsList.action("DrawHandles"); 454 //this._toolsList.action("DrawHandles");
457 455
458 } 456 }