aboutsummaryrefslogtreecommitdiff
path: root/js/stage/stage.reel/stage.js
diff options
context:
space:
mode:
authorJohn Mayhew2012-05-07 16:30:19 -0700
committerJohn Mayhew2012-05-07 16:30:19 -0700
commitdb4ba95f50148198759dde503ec1c778184d9dbe (patch)
tree8b79ad58108af2f17d15abc8cdc33d35229ab20d /js/stage/stage.reel/stage.js
parent843d8ea8ee58a54bcb71d7b28dbf78fae153b491 (diff)
parent526e423e4a2734c2b139af23911e912452a4443f (diff)
downloadninja-db4ba95f50148198759dde503ec1c778184d9dbe.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts: js/components/layout/tools-list.reel/tools-list.html js/components/layout/tools-properties.reel/tools-properties.html js/components/tools-properties/brush-properties.reel/brush-properties.html js/components/tools-properties/fill-properties.reel/fill-properties.html js/components/tools-properties/pen-properties.reel/pen-properties.html js/components/tools-properties/pencil-properties.reel/pencil-properties.html js/components/tools-properties/selection-properties.reel/selection-properties.html js/components/tools-properties/shape-properties.reel/shape-properties.html js/components/tools-properties/tag-properties.reel/tag-properties.html js/components/tools-properties/text-properties.reel/text-properties.html
Diffstat (limited to 'js/stage/stage.reel/stage.js')
-rwxr-xr-xjs/stage/stage.reel/stage.js84
1 files changed, 53 insertions, 31 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 1ea14d64..b181dc70 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -231,33 +231,43 @@ exports.Stage = Montage.create(Component, {
231 this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; 231 this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11;
232 232
233 this._documentRoot = this.application.ninja.currentDocument.documentRoot; 233 this._documentRoot = this.application.ninja.currentDocument.documentRoot;
234 this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode;
235
236 this.documentOffsetLeft = this._viewport.offsetLeft;
237 this.documentOffsetTop = this._viewport.offsetTop;
238
239 // Center the stage
240 this.centerStage();
241
242 this._scrollLeft = this._iframeContainer.scrollLeft;
243 this._scrollTop = this._iframeContainer.scrollTop;
244 this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft;
245 this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop;
246 234
247 // Hardcode this value so that it does not fail for the new stage architecture 235 // Hardcode this value so that it does not fail for the new stage architecture
248 // TODO: Remove marker for old template: NINJA-STAGE-REWORK 236 // TODO: Remove marker for old template: NINJA-STAGE-REWORK
249 if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { 237 if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") {
250 this.userContentBorder = 1; //parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); 238 this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode;
239
240 this.documentOffsetLeft = this._viewport.offsetLeft;
241 this.documentOffsetTop = this._viewport.offsetTop;
242
243 // Center the stage
244 this.centerStage();
245
246 this._scrollLeft = this._iframeContainer.scrollLeft;
247 this._scrollTop = this._iframeContainer.scrollTop;
248 this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft;
249 this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop;
250
251 this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border"));
252
253 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
254 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
255
256 this._iframeContainer.addEventListener("scroll", this, false);
257
258 this.application.ninja.currentDocument.iframe.style.opacity = 1.0;
251 } else { 259 } else {
252 this.userContentBorder = 0; 260 this.userContentBorder = 0;
253 }
254 261
255 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; 262 this._scrollLeft = 0;
256 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; 263 this._scrollTop = 0;
264 this._userContentLeft = 0;
265 this._userContentTop = 0;
266
267 this.application.ninja.currentDocument._window.addEventListener("scroll", this, false);
268 }
257 269
258 this.application.ninja.currentDocument.iframe.style.opacity = 1.0;
259 270
260 this._iframeContainer.addEventListener("scroll", this, false);
261 271
262 // TODO - We will need to modify this once we support switching between multiple documents 272 // TODO - We will need to modify this once we support switching between multiple documents
263 this.application.ninja.toolsData.selectedToolInstance._configure(true); 273 this.application.ninja.toolsData.selectedToolInstance._configure(true);
@@ -415,13 +425,10 @@ exports.Stage = Montage.create(Component, {
415 handleSelectionChange: { 425 handleSelectionChange: {
416 value: function(event) { 426 value: function(event) {
417 // TODO - this is a hack for now because some tools depend on selectionDrawn event for some logic 427 // TODO - this is a hack for now because some tools depend on selectionDrawn event for some logic
418 if(this.drawNow) 428 if(this.drawNow) {
419 {
420 this.draw(); 429 this.draw();
421 this.drawNow = false; 430 this.drawNow = false;
422 } 431 } else {
423 else
424 {
425 this.needsDraw = true; 432 this.needsDraw = true;
426 } 433 }
427 } 434 }
@@ -444,11 +451,20 @@ exports.Stage = Montage.create(Component, {
444 */ 451 */
445 handleScroll: { 452 handleScroll: {
446 value: function() { 453 value: function() {
447 this._scrollLeft = this._iframeContainer.scrollLeft; 454 // TODO: Remove marker for old template: NINJA-STAGE-REWORK
448 this._scrollTop = this._iframeContainer.scrollTop; 455 if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") {
456 this._scrollLeft = this._iframeContainer.scrollLeft;
457 this._scrollTop = this._iframeContainer.scrollTop;
449 458
450 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; 459 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
451 this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; 460 this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
461 } else {
462 this._scrollLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft;
463 this._scrollTop = this.application.ninja.currentDocument.documentRoot.scrollTop;
464
465 this.userContentLeft = -this._scrollLeft;
466 this.userContentTop = -this._scrollTop;
467 }
452 468
453 // Need to clear the snap cache and set up the drag plane 469 // Need to clear the snap cache and set up the drag plane
454 //snapManager.setupDragPlaneFromPlane( workingPlane ); 470 //snapManager.setupDragPlaneFromPlane( workingPlane );
@@ -457,7 +473,6 @@ exports.Stage = Montage.create(Component, {
457 this.needsDraw = true; 473 this.needsDraw = true;
458 this.layout.draw(); 474 this.layout.draw();
459 //this._toolsList.action("DrawHandles"); 475 //this._toolsList.action("DrawHandles");
460
461 } 476 }
462 }, 477 },
463 478
@@ -687,7 +702,7 @@ exports.Stage = Montage.create(Component, {
687// } 702// }
688 703
689 var zoomFactor = 1; 704 var zoomFactor = 1;
690 if (this._viewport.style && this._viewport.style.zoom) { 705 if (this._viewport && this._viewport.style && this._viewport.style.zoom) {
691 zoomFactor = Number(this._viewport.style.zoom); 706 zoomFactor = Number(this._viewport.style.zoom);
692 } 707 }
693 708
@@ -840,6 +855,12 @@ exports.Stage = Montage.create(Component, {
840 } 855 }
841 }, 856 },
842 857
858 setStageAsViewport: {
859 value: function() {
860 this.stageDeps.viewUtils.setViewportObj(this.application.ninja.currentDocument.documentRoot);
861 }
862 },
863
843 setZoom: { 864 setZoom: {
844 value: function(value) { 865 value: function(value) {
845 if(!this._firstDraw) 866 if(!this._firstDraw)
@@ -943,8 +964,9 @@ exports.Stage = Montage.create(Component, {
943 this.application.ninja.documentController.activeDocument.savedLeftScroll = this._iframeContainer.scrollLeft; 964 this.application.ninja.documentController.activeDocument.savedLeftScroll = this._iframeContainer.scrollLeft;
944 this.application.ninja.documentController.activeDocument.savedTopScroll = this._iframeContainer.scrollTop; 965 this.application.ninja.documentController.activeDocument.savedTopScroll = this._iframeContainer.scrollTop;
945 } 966 }
946 }, 967 },
947 restoreScroll:{ 968
969 restoreScroll:{
948 value: function(){ 970 value: function(){
949 this._iframeContainer.scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll; 971 this._iframeContainer.scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll;
950 this._scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll; 972 this._scrollLeft = this.application.ninja.documentController.activeDocument.savedLeftScroll;