aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorValerio Virgillito2012-06-01 00:16:31 -0700
committerValerio Virgillito2012-06-01 00:16:31 -0700
commit3a3a2351ea2d816bf953cbf76622772f7d64aa8b (patch)
tree0e26399a2bbf4702aeb30de9a8f46442ca8b99ab /js/stage
parent6ae2ff1ce956e518918f65099d052bb42186dc94 (diff)
downloadninja-3a3a2351ea2d816bf953cbf76622772f7d64aa8b.tar.gz
fixing the code editor, closing documents and cleanup of the stage
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/stage.reel/stage.js53
1 files changed, 27 insertions, 26 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 087606d0..ed716541 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -206,7 +206,7 @@ exports.Stage = Montage.create(Component, {
206 this.hideRulers(); 206 this.hideRulers();
207 } 207 }
208 } 208 }
209 }, 209 },
210 210
211 _userPaddingLeft: { value: 0 }, 211 _userPaddingLeft: { value: 0 },
212 _userPaddingTop: { value: 0 }, 212 _userPaddingTop: { value: 0 },
@@ -216,7 +216,7 @@ exports.Stage = Montage.create(Component, {
216 set: function(value) { 216 set: function(value) {
217 this._userPaddingLeft = value; 217 this._userPaddingLeft = value;
218 this._documentOffsetLeft = -value; 218 this._documentOffsetLeft = -value;
219 this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; 219 this.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px";
220 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; 220 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft;
221 this.updatedStage = true; 221 this.updatedStage = true;
222 } 222 }
@@ -227,7 +227,7 @@ exports.Stage = Montage.create(Component, {
227 set: function(value) { 227 set: function(value) {
228 this._userPaddingTop = value; 228 this._userPaddingTop = value;
229 this._documentOffsetTop = -value; 229 this._documentOffsetTop = -value;
230 this.application.ninja.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; 230 this.currentDocument.model.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px";
231 this.userContentTop = this._documentOffsetTop - this._scrollTop; 231 this.userContentTop = this._documentOffsetTop - this._scrollTop;
232 this.updatedStage = true; 232 this.updatedStage = true;
233 } 233 }
@@ -242,7 +242,7 @@ exports.Stage = Montage.create(Component, {
242 242
243 // Hack for now until a full component 243 // Hack for now until a full component
244 this.layout.draw(); 244 this.layout.draw();
245 if(this.application.ninja.currentDocument) { 245 if(this.currentDocument) {
246 this.layout.draw3DInfo(true); 246 this.layout.draw3DInfo(true);
247 } 247 }
248 } else if(this.updatedStage) { 248 } else if(this.updatedStage) {
@@ -347,8 +347,8 @@ exports.Stage = Montage.create(Component, {
347 } 347 }
348 348
349 if(didSwitch) { 349 if(didSwitch) {
350 this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = this.currentDocument.model.scrollLeft; 350 this.currentDocument.model.views.design.document.body.scrollLeft = this.currentDocument.model.scrollLeft;
351 this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = this.currentDocument.model.scrollTop; 351 this.currentDocument.model.views.design.document.body.scrollTop = this.currentDocument.model.scrollTop;
352 this.handleScroll(); 352 this.handleScroll();
353 } else { 353 } else {
354 this.centerStage(); 354 this.centerStage();
@@ -462,9 +462,9 @@ exports.Stage = Montage.create(Component, {
462 handleMousewheel: { 462 handleMousewheel: {
463 value: function(event) { 463 value: function(event) {
464 if(event._event.wheelDelta > 0) { 464 if(event._event.wheelDelta > 0) {
465 this.application.ninja.currentDocument.model.views.design.document.body.scrollTop -= 20; 465 this.currentDocument.model.views.design.document.body.scrollTop -= 20;
466 } else { 466 } else {
467 this.application.ninja.currentDocument.model.views.design.document.body.scrollTop += 20; 467 this.currentDocument.model.views.design.document.body.scrollTop += 20;
468 } 468 }
469 } 469 }
470 }, 470 },
@@ -532,8 +532,8 @@ exports.Stage = Montage.create(Component, {
532 handleScroll: { 532 handleScroll: {
533 value: function() { 533 value: function() {
534 534
535 this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; 535 this._scrollLeft = this.currentDocument.model.views.design.document.body.scrollLeft;
536 this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; 536 this._scrollTop = this.currentDocument.model.views.design.document.body.scrollTop;
537 537
538 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; 538 this.userContentLeft = this._documentOffsetLeft - this._scrollLeft;
539 this.userContentTop = this._documentOffsetTop - this._scrollTop; 539 this.userContentTop = this._documentOffsetTop - this._scrollTop;
@@ -571,7 +571,7 @@ exports.Stage = Montage.create(Component, {
571 */ 571 */
572 centerStage: { 572 centerStage: {
573 value: function() { 573 value: function() {
574 var designView = this.application.ninja.currentDocument.model.views.design; 574 var designView = this.currentDocument.model.views.design;
575 if(designView._template) { 575 if(designView._template) {
576 designView.document.body.scrollLeft = this._documentOffsetLeft - parseInt((this.canvas.width - designView._template.size.width)/2); 576 designView.document.body.scrollLeft = this._documentOffsetLeft - parseInt((this.canvas.width - designView._template.size.width)/2);
577 designView.document.body.scrollTop = this._documentOffsetTop - parseInt((this.canvas.height - designView._template.size.height)/2); 577 designView.document.body.scrollTop = this._documentOffsetTop - parseInt((this.canvas.height - designView._template.size.height)/2);
@@ -630,21 +630,21 @@ exports.Stage = Montage.create(Component, {
630 getElement: { 630 getElement: {
631 value: function(position, selectable) { 631 value: function(position, selectable) {
632 var point, element, 632 var point, element,
633 docView = this.application.ninja.currentDocument.model.views.design; 633 docView = this.currentDocument.model.views.design;
634 634
635 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop)); 635 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop));
636 element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); 636 element = this.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop);
637 637
638 if(!element) debugger; 638 if(!element) debugger;
639 // workaround Chrome 3d bug 639 // workaround Chrome 3d bug
640 if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(element) !== -1) { 640 if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.currentDocument.inExclusion(element) !== -1) {
641 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY)); 641 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY));
642 element = this.getElementUsingSnapping(point); 642 element = this.getElementUsingSnapping(point);
643 } 643 }
644 644
645 if(selectable) { 645 if(selectable) {
646 646
647 if(this.application.ninja.currentDocument.inExclusion(element) !== -1) { 647 if(this.currentDocument.inExclusion(element) !== -1) {
648 return this.application.ninja.currentSelectedContainer; 648 return this.application.ninja.currentSelectedContainer;
649 } 649 }
650 650
@@ -949,7 +949,7 @@ exports.Stage = Montage.create(Component, {
949 949
950 setStageAsViewport: { 950 setStageAsViewport: {
951 value: function() { 951 value: function() {
952 this.stageDeps.viewUtils.setViewportObj(this.application.ninja.currentDocument.model.documentRoot); 952 this.stageDeps.viewUtils.setViewportObj(this.currentDocument.model.documentRoot);
953 } 953 }
954 }, 954 },
955 955
@@ -957,7 +957,7 @@ exports.Stage = Montage.create(Component, {
957 value: function(value) { 957 value: function(value) {
958 if(!this._firstDraw) 958 if(!this._firstDraw)
959 { 959 {
960 var userContent = this.application.ninja.currentDocument.model.documentRoot; 960 var userContent = this.currentDocument.model.documentRoot;
961 if (userContent) 961 if (userContent)
962 { 962 {
963 var w = this._canvas.width, 963 var w = this._canvas.width,
@@ -969,7 +969,7 @@ exports.Stage = Montage.create(Component, {
969 //TODO - Maybe move to mediator. 969 //TODO - Maybe move to mediator.
970 var newVal = value/100.0; 970 var newVal = value/100.0;
971 if (newVal >= 1) 971 if (newVal >= 1)
972 this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = value/100; 972 this.currentDocument.model.views.design.iframe.style.zoom = value/100;
973 973
974 this.updatedStage = true; 974 this.updatedStage = true;
975 975
@@ -988,12 +988,12 @@ exports.Stage = Montage.create(Component, {
988 { 988 {
989 case "top": 989 case "top":
990 plane = [0,1,0,0]; 990 plane = [0,1,0,0];
991 plane[3] = this.application.ninja.currentDocument.model.documentRoot.offsetHeight / 2.0; 991 plane[3] = this.currentDocument.model.documentRoot.offsetHeight / 2.0;
992 break; 992 break;
993 993
994 case "side": 994 case "side":
995 plane = [1,0,0,0]; 995 plane = [1,0,0,0];
996 plane[3] = this.application.ninja.currentDocument.model.documentRoot.offsetWidth / 2.0; 996 plane[3] = this.currentDocument.model.documentRoot.offsetWidth / 2.0;
997 break; 997 break;
998 998
999 case "front": 999 case "front":
@@ -1012,7 +1012,7 @@ exports.Stage = Montage.create(Component, {
1012 setStageView: { 1012 setStageView: {
1013 value: function(side) { 1013 value: function(side) {
1014 var mat, 1014 var mat,
1015 currentDoc = this.application.ninja.currentDocument.model.documentRoot, 1015 currentDoc = this.currentDocument.model.documentRoot,
1016 isDrawingGrid = this.application.ninja.appModel.show3dGrid; 1016 isDrawingGrid = this.application.ninja.appModel.show3dGrid;
1017 // Stage 3d Props. 1017 // Stage 3d Props.
1018 currentDoc.elementModel.props3D.ResetTranslationValues(); 1018 currentDoc.elementModel.props3D.ResetTranslationValues();
@@ -1057,6 +1057,7 @@ exports.Stage = Montage.create(Component, {
1057 this.application.ninja.rulerLeft.style.display = "block"; 1057 this.application.ninja.rulerLeft.style.display = "block";
1058 } 1058 }
1059 }, 1059 },
1060
1060 hideRulers:{ 1061 hideRulers:{
1061 value:function(){ 1062 value:function(){
1062 this.application.ninja.rulerTop.style.display = "none"; 1063 this.application.ninja.rulerTop.style.display = "none";
@@ -1066,11 +1067,11 @@ exports.Stage = Montage.create(Component, {
1066 showCodeViewBar:{ 1067 showCodeViewBar:{
1067 value:function(isCodeView){ 1068 value:function(isCodeView){
1068 if(isCodeView === true) { 1069 if(isCodeView === true) {
1069 this.application.ninja.editorViewOptions.element.style.display = "block"; 1070
1070 this.application.ninja.documentBar.element.style.display = "none"; 1071 this.application.ninja.documentBar.element.style.display = "none";
1071 } else { 1072 } else {
1072 this.application.ninja.documentBar.element.style.display = "block"; 1073 this.application.ninja.documentBar.element.style.display = "block";
1073 this.application.ninja.editorViewOptions.element.style.display = "none"; 1074
1074 } 1075 }
1075 } 1076 }
1076 },