From 4ba680a7e9168d0f505a81e42a287dfbc54b4d7d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Tue, 1 May 2012 15:26:37 -0700 Subject: Preliminary IO to new DOM view --- js/stage/stage.reel/stage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 515165bf..2e49fc04 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -264,7 +264,7 @@ exports.Stage = Montage.create(Component, { this._userContentLeft = 0; this._userContentTop = 0; - this.application.ninja.currentDocument._window.addEventListener("scroll", this, false); + //this.application.ninja.currentDocument._window.addEventListener("scroll", this, false); } @@ -543,7 +543,7 @@ exports.Stage = Montage.create(Component, { var point, element; point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY)); - element = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop); + element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop); // workaround Chrome 3d bug if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(element) !== -1) { -- cgit v1.2.3 From 8f1385d4aa12173fb4d9af695b8e5036f675b621 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 4 May 2012 14:39:33 -0700 Subject: Fixing selection and layout code to exclude SCRIPT and STYLE tags. Signed-off-by: Nivesh Rajbhandari --- js/stage/layout.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 0a76dbe5..9c5e2167 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -156,7 +156,7 @@ exports.Layout = Montage.create(Component, { drawTagOutline: { value: function (item) { - if(!item || (item.nodeType !== 1)) return; + if(!item || !this.application.ninja.selectionController.isNodeTraversable(item)) return; // TODO Bind the layoutview mode to the current document // var mode = this.application.ninja.currentDocument.layoutMode; -- cgit v1.2.3 From 4baed156932f5875755532939a411953fa41c59d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 8 May 2012 09:43:32 -0700 Subject: Stage should update scroll offsets when scrolled. Note that this is not always correct because we don't get a scroll end event. Updating Pan Tool to update scroll bars. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 171c4f36..1f661513 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -118,6 +118,9 @@ exports.Stage = Montage.create(Component, { _userContentTop: { value: 0 }, _userContentBorder: { value: 0 }, + _maxHorizontalScroll: { value: 0 }, + _maxVerticalScroll: { value: 0 }, + documentRoot: { get: function () { return this._documentRoot; }, set: function(value) { this._documentRoot = value; } @@ -264,7 +267,9 @@ exports.Stage = Montage.create(Component, { this._userContentLeft = 0; this._userContentTop = 0; - //this.application.ninja.currentDocument._window.addEventListener("scroll", this, false); + this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; + this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; + this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addEventListener("scroll", this, false); } @@ -464,6 +469,12 @@ exports.Stage = Montage.create(Component, { this.userContentLeft = -this._scrollLeft; this.userContentTop = -this._scrollTop; + + // TODO - scroll events are not dependable. We may need to use a timer to simulate + // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values + // on mouse down. +// this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; +// this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; } // Need to clear the snap cache and set up the drag plane @@ -543,7 +554,7 @@ exports.Stage = Montage.create(Component, { var point, element; point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY)); - element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop); + element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x + this.userContentLeft,point.y + this.userContentTop); // workaround Chrome 3d bug if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(element) !== -1) { -- cgit v1.2.3 From c79814664f3002613b3f12106edffc64932fa4ac Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 8 May 2012 16:27:50 -0700 Subject: Get clicked element when body is scrolled. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 1f661513..dc6444ff 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -551,13 +551,16 @@ exports.Stage = Montage.create(Component, { */ getElement: { value: function(position, selectable) { - var point, element; + var point, element, + docView = this.application.ninja.currentDocument.model.views.design; - point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY)); - element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x + this.userContentLeft,point.y + this.userContentTop); + point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset, position.pageY - docView.iframe.contentWindow.pageYOffset)); + element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); + if(!element) debugger; // workaround Chrome 3d bug if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(element) !== -1) { + point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY)); element = this.getElementUsingSnapping(point); } @@ -888,7 +891,7 @@ exports.Stage = Montage.create(Component, { //TODO - Maybe move to mediator. var newVal = value/100.0; if (newVal >= 1) - this.application.ninja.currentDocument.iframe.style.zoom = value/100; + this.application.ninja.currentDocument.model.views.design.iframe.style.zoom = value/100; this.updatedStage = true; -- cgit v1.2.3 From 7ad96123fcc61f613c199faa3b98bff5d352ceee Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 14 May 2012 17:17:17 -0700 Subject: userContentLeft and userContentTop need to set scroll offsets for 0 also. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage-deps.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index a71b77be..33ba2359 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -52,7 +52,7 @@ exports.StageDeps = Montage.create(Component, { userContentLeft: { get: function() { return this._userContentLeft; }, set: function(value) { - if(value) { + if(value != null) { viewUtils.setUserContentLeft(value); } } @@ -65,7 +65,7 @@ exports.StageDeps = Montage.create(Component, { userContentTop: { get: function() { return this._userContentTop; }, set: function(value) { - if(value) { + if(value != null) { viewUtils.setUserContentTop(value); } } -- cgit v1.2.3 From 253b8803c71c88a6f87fb1caccd42fa081fc6eca Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 15 May 2012 14:17:41 -0700 Subject: Fixing scrollbar syncing, including pan tool, for banner templates. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index dc6444ff..e66c5b7b 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -464,8 +464,8 @@ exports.Stage = Montage.create(Component, { this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; } else { - this._scrollLeft = this.application.ninja.currentDocument.documentRoot.scrollLeft; - this._scrollTop = this.application.ninja.currentDocument.documentRoot.scrollTop; + this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; + this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; this.userContentLeft = -this._scrollLeft; this.userContentTop = -this._scrollTop; @@ -512,11 +512,16 @@ exports.Stage = Montage.create(Component, { */ centerStage: { value: function() { - this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this._documentRoot.parentNode.offsetWidth)/2; - this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this._documentRoot.parentNode.offsetHeight)/2; + if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { + this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this._documentRoot.parentNode.offsetWidth)/2; + this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this._documentRoot.parentNode.offsetHeight)/2; - this._scrollLeft = this._iframeContainer.scrollLeft; - this._scrollTop = this._iframeContainer.scrollTop; + this._scrollLeft = this._iframeContainer.scrollLeft; + this._scrollTop = this._iframeContainer.scrollTop; + } else { + this._scrollLeft = this._userContentLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = 0; + this._scrollTop = this._userContentTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = 0; + } } }, -- cgit v1.2.3 From 94855a2c1074f67f158b94ca0d61c51ee46c51b5 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 15 May 2012 16:08:37 -0700 Subject: fixed the mouse wheel scroll Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index e66c5b7b..deed4112 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -387,9 +387,9 @@ exports.Stage = Montage.create(Component, { handleMousewheel: { value: function(event) { if(event._event.wheelDelta > 0) { - this._iframeContainer.scrollTop -= 20; + this.application.ninja.currentDocument.model.views.design.document.body.scrollTop -= 20; } else { - this._iframeContainer.scrollTop += 20; + this.application.ninja.currentDocument.model.views.design.document.body.scrollTop += 20; } } }, -- cgit v1.2.3 From 0ebb822b0535bf1bb100b3f3cb396c8b6d3383f1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 11:23:12 -0700 Subject: fixing some of the document bindings. Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 6 ------ js/stage/stage.reel/stage.html | 3 +++ js/stage/stage.reel/stage.js | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 33ba2359..1825eb06 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -95,12 +95,6 @@ exports.StageDeps = Montage.create(Component, { handleAppLoaded: { value: function() { - Object.defineBinding(this, "currentDocument", { - boundObject: this.application.ninja, - boundObjectPropertyPath: "currentDocument", - oneway: true - }); - Object.defineBinding(this, "userContentLeft", { boundObject: this.stage, boundObjectPropertyPath: "_userContentLeft", diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 30c3d231..88cd6149 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -22,6 +22,9 @@ "prototype": "js/stage/stage-deps", "properties": { "stage": {"@": "owner"} + }, + "bindings": { + "currentDocument": {"<-": "@owner.activeDocument"} } }, diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index deed4112..125155d8 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -164,6 +164,29 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userContentBorder = value; } }, + _activeDocument : { + value : null, + enumerable : false + }, + + activeDocument : { + get : function() { + return this._activeDocument; + }, + set : function(document) { + ///// If the document is null set default stylesheets to null + + if(!document) { + return false; + } + + ///// setting document via binding + this._activeDocument = document; + + }, + enumerable : false + }, + willDraw: { value: function() { if(this.resizeCanvases) { -- cgit v1.2.3 From 4f46850b376b2d428a3d9415b1dc69b36b875a2c Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 13:06:34 -0700 Subject: Automatically add scrollbars when moving content to negative space. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 125155d8..05376527 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -187,6 +187,33 @@ exports.Stage = Montage.create(Component, { enumerable : false }, + _userPaddingLeft: { value: 0 }, + _userPaddingTop: { value: 0 }, + + userPaddingLeft: { + get: function() { return this._userPaddingLeft; }, + set: function(value) { + this._userPaddingLeft = value; + this._documentOffsetLeft = -value; + this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], + "padding-left", -value + "px", true); + this.userContentLeft = this._documentOffsetLeft; + this.updatedStage = true; + } + }, + + userPaddingTop: { + get: function() { return this._userPaddingTop; }, + set: function(value) { + this._userPaddingTop = value; + this._documentOffsetTop = -value; + this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], + "padding-top", -value + "px", true); + this.userContentTop = this._documentOffsetTop; + this.updatedStage = true; + } + }, + willDraw: { value: function() { if(this.resizeCanvases) { @@ -490,8 +517,8 @@ exports.Stage = Montage.create(Component, { this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; - this.userContentLeft = -this._scrollLeft; - this.userContentTop = -this._scrollTop; + this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; + this.userContentTop = this._documentOffsetTop - this._scrollTop; // TODO - scroll events are not dependable. We may need to use a timer to simulate // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values -- cgit v1.2.3 From 96c92ab93bdb6eb2dd42ef275b84d83aef8254bf Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 14:36:47 -0700 Subject: Fixing selection bugs in new templates. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 05376527..854b5a2d 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -609,7 +609,7 @@ exports.Stage = Montage.create(Component, { var point, element, docView = this.application.ninja.currentDocument.model.views.design; - point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset, position.pageY - docView.iframe.contentWindow.pageYOffset)); + point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop)); element = this.application.ninja.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); if(!element) debugger; -- cgit v1.2.3 From fd54dabad7cbc27a0efb0957155c00d578912909 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 15:32:36 -0700 Subject: changing @change to propertyChangeListener Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 125155d8..93270561 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -300,7 +300,7 @@ exports.Stage = Montage.create(Component, { // TODO - We will need to modify this once we support switching between multiple documents this.application.ninja.toolsData.selectedToolInstance._configure(true); - this.addEventListener("change@appModel.show3dGrid", this, false); + this.addPropertyChangeListener("appModel.show3dGrid", this, false); this.layout.handleOpenDocument(); } @@ -309,10 +309,9 @@ exports.Stage = Montage.create(Component, { /** * Event handler for the change @ 3DGrid */ - handleEvent: { - value: function(e) { - if(e.type === "change@appModel.show3dGrid") { - + handleChange: { + value: function(notification) { + if("appModel.show3dGrid" === notification.currentPropertyPath) { if(this.appModel.show3dGrid) { drawUtils.drawXY = true; -- cgit v1.2.3 From 727ad95f6828821f0682aa98104783e4bbda78b4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 16 May 2012 15:56:54 -0700 Subject: Inline style for html's padding for content in negative space to guarantee highest specificity. Also, set up scrollbars when opening files with content in negative space. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 854b5a2d..28356d1a 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -195,8 +195,10 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingLeft = value; this._documentOffsetLeft = -value; - this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], - "padding-left", -value + "px", true); + if(!this._documentRoot) { + this._documentRoot = this.application.ninja.currentDocument.documentRoot; + } + this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; this.userContentLeft = this._documentOffsetLeft; this.updatedStage = true; } @@ -207,8 +209,10 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingTop = value; this._documentOffsetTop = -value; - this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], - "padding-top", -value + "px", true); + if(!this._documentRoot) { + this._documentRoot = this.application.ninja.currentDocument.documentRoot; + } + this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; this.userContentTop = this._documentOffsetTop; this.updatedStage = true; } @@ -314,8 +318,8 @@ exports.Stage = Montage.create(Component, { this._scrollLeft = 0; this._scrollTop = 0; - this._userContentLeft = 0; - this._userContentTop = 0; + this._userContentLeft = this._documentOffsetLeft; + this._userContentTop = this._documentOffsetTop; this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; -- cgit v1.2.3 From c26de5fa7b909a53b103b72027b5cbe7c3e1c49f Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 22:48:39 -0700 Subject: code cleanup and refactoring of the document controller and stage view Signed-off-by: Valerio Virgillito --- js/stage/stage-view.reel/stage-view.js | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 518c3bdd..7680103d 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -25,32 +25,12 @@ exports.StageView = Montage.create(Component, { } }, - templateDidLoad: { - value: function() { - this.eventManager.addEventListener("appLoaded", this, false); - } - }, - didDraw:{ value: function() { if(!this.application.ninja.documentController._textHolder) this.application.ninja.documentController._textHolder = this.element; } }, - handleAppLoaded: { - value: function() { - - // Don't bind for now - /* - Object.defineBinding(this, "docs", { - boundObject: this.application.ninja.documentController, - boundObjectPropertyPath: "_documents" - }); - */ - - } - }, - /** * Public method * Creates a textarea element which will contain the content of the opened text document. @@ -172,17 +152,6 @@ exports.StageView = Montage.create(Component, { } }, - hideOtherDocuments:{ - value:function(docUuid){ - this.application.ninja.documentController._documents.forEach(function(aDoc){ - if(aDoc.currentView === "design"){ - aDoc.container.parentNode.style["display"] = "none"; - }else if((aDoc.currentView === "code") && (aDoc.uuid !== docUuid)){ - aDoc.container.style["display"] = "none"; - } - }, this); - } - }, showRulers:{ value:function(){ this.application.ninja.rulerTop.style.display = "block"; @@ -200,7 +169,7 @@ exports.StageView = Montage.create(Component, { if(isCodeView === true) { this.application.ninja.editorViewOptions.element.style.display = "block"; this.application.ninja.documentBar.element.style.display = "none"; - }else{ + } else { this.application.ninja.documentBar.element.style.display = "block"; this.application.ninja.editorViewOptions.element.style.display = "none"; } -- cgit v1.2.3 From 402a369c7bf164c3c6686be3a33f5e36f25e4130 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 16 May 2012 23:19:32 -0700 Subject: document controller and stage view code cleanup Signed-off-by: Valerio Virgillito --- js/stage/stage-view.reel/stage-view.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 7680103d..ba94fadf 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -120,7 +120,22 @@ exports.StageView = Montage.create(Component, { } this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - this.application.ninja.documentController._showCurrentDocument(); + + +// this.application.ninja.documentController._showCurrentDocument(); + // Inline function below + if(this.activeDocument) { + this.activeDocument.container.style["display"] = "block"; + if(this.activeDocument.currentView === "design"){ + this.activeDocument.container.parentNode.style["display"] = "block"; + this.activeDocument.restoreAppState(); + } else { + //hide the iframe when switching to code view + document.getElementById("iframeContainer").style.display = "none"; + } + } + + //focus editor if(!!this.application.ninja.documentController.activeDocument && !!this.application.ninja.documentController.activeDocument.editor){ this.application.ninja.documentController.activeDocument.editor.focus(); -- cgit v1.2.3 From b72c5f72ea5df4aa164350e1ba66fd1b4e23369d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 17 May 2012 23:07:48 -0700 Subject: removing all stageDeps for drawing classes. Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 61 ++++++------------------------------------ js/stage/stage.reel/stage.html | 3 --- 2 files changed, 8 insertions(+), 56 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 1825eb06..17039438 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -11,8 +11,7 @@ var Montage = require("montage/core/core").Montage, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, ElementPlanes = require("js/helper-classes/3D/element-planes").ElementPlanes, MathUtilsClass = require("js/helper-classes/3D/math-utils").MathUtilsClass, - VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, - DrawingToolBase = require("js/tools/drawing-tool-base").DrawingToolBase; + VecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; exports.StageDeps = Montage.create(Component, { viewUtils: { @@ -27,24 +26,6 @@ exports.StageDeps = Montage.create(Component, { value: drawUtils }, - currentStage: { - value: null - }, - - _currentDocument: { - value: null - }, - - currentDocument: { - get: function() { return this._currentDocument; }, - set: function(value) { - if(value) { - this._currentDocument = value; - this.currentStage = value.documentRoot; - } - } - }, - _userContentLeft: { value: null }, @@ -112,7 +93,9 @@ exports.StageDeps = Montage.create(Component, { // bind the snap properties to the snap manager snapManager.bindSnap(); - + drawUtils.viewUtils = viewUtils; + drawUtils.snapManager = snapManager; + drawUtils.ElementPlanes = ElementPlanes; } }, @@ -121,22 +104,8 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; - snapManager.setCurrentStage(this.currentStage); - - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); - - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; - - snapManager._isCacheInvalid=true; - - snapManager.setupDragPlaneFromPlane ( workingPlane ); - - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + snapManager._isCacheInvalid = true; + snapManager.setupDragPlaneFromPlane (workingPlane); drawUtils.initializeFromDocument(); } @@ -147,22 +116,8 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; - snapManager.setCurrentStage(this.currentStage); - - viewUtils.setCurrentDocument(this.currentDocument); - viewUtils.setRootElement(this.currentStage.parentNode); - viewUtils.setStageElement(this.currentStage); - - drawUtils.viewUtils = viewUtils; - drawUtils.snapManager = snapManager; - drawUtils.ElementPlanes = ElementPlanes; - - snapManager._isCacheInvalid=true; - - snapManager.setupDragPlaneFromPlane ( workingPlane ); - - DrawingToolBase.stage = this.currentStage; - DrawingToolBase.stageComponent = this.stage; + snapManager._isCacheInvalid = true; + snapManager.setupDragPlaneFromPlane (workingPlane); drawUtils.initializeFromDocument(); } diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 88cd6149..30c3d231 100755 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -22,9 +22,6 @@ "prototype": "js/stage/stage-deps", "properties": { "stage": {"@": "owner"} - }, - "bindings": { - "currentDocument": {"<-": "@owner.activeDocument"} } }, -- cgit v1.2.3 From 7a94696e19b14e15261df516e2ba75e693b1313d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:21:56 -0700 Subject: enabling basic document switching Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 13 +++++-------- js/stage/stage-view.reel/stage-view.js | 22 ---------------------- 2 files changed, 5 insertions(+), 30 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 17039438..84f04249 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -55,8 +55,9 @@ exports.StageDeps = Montage.create(Component, { deserializedFromTemplate: { value: function() { - this.eventManager.addEventListener( "appLoaded", this, false); - this.eventManager.addEventListener( "openDocument", this, false); + this.eventManager.addEventListener("appLoaded", this, false); + this.eventManager.addEventListener("openDocument", this, false); + this.eventManager.addEventListener("switchDocument", this, false); // Initialize Deps // HACK @@ -111,9 +112,8 @@ exports.StageDeps = Montage.create(Component, { } }, - reinitializeForSwitchDocument: { - value: function() { - + handleSwitchDocument: { + value: function(){ workingPlane = [0,0,1,0]; snapManager._isCacheInvalid = true; @@ -122,7 +122,4 @@ exports.StageDeps = Montage.create(Component, { drawUtils.initializeFromDocument(); } } - - - }); \ 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 ba94fadf..757c5e51 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -112,28 +112,6 @@ exports.StageView = Montage.create(Component, { */ switchDocument:{ value: function(doc){ - this.application.ninja.documentController._hideCurrentDocument(); - this.application.ninja.documentController.activeDocument = doc; - - if(this.application.ninja.documentController.activeDocument.currentView === "design") { - this.application.ninja.currentDocument = this.application.ninja.documentController.activeDocument; - } - - this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - - -// this.application.ninja.documentController._showCurrentDocument(); - // Inline function below - if(this.activeDocument) { - this.activeDocument.container.style["display"] = "block"; - if(this.activeDocument.currentView === "design"){ - this.activeDocument.container.parentNode.style["display"] = "block"; - this.activeDocument.restoreAppState(); - } else { - //hide the iframe when switching to code view - document.getElementById("iframeContainer").style.display = "none"; - } - } //focus editor -- cgit v1.2.3 From 084bb924bc3c3a6ad1e2e21099399bba4d473fed Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 00:41:31 -0700 Subject: fixing some snapping bugs Signed-off-by: Valerio Virgillito --- js/stage/stage-deps.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 84f04249..0d53696b 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -105,7 +105,7 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; - snapManager._isCacheInvalid = true; + snapManager.reload2DCache(); snapManager.setupDragPlaneFromPlane (workingPlane); drawUtils.initializeFromDocument(); @@ -116,8 +116,9 @@ exports.StageDeps = Montage.create(Component, { value: function(){ workingPlane = [0,0,1,0]; - snapManager._isCacheInvalid = true; snapManager.setupDragPlaneFromPlane (workingPlane); + snapManager.reload2DCache(); + drawUtils.initializeFromDocument(); } -- cgit v1.2.3 From 24d1873302b2fffc25d254e15e8aa36f59eedb88 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 01:36:05 -0700 Subject: fixed a switch documents bug where the layout was getting called before setting the container. Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index cac99326..8da89fb9 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -593,6 +593,14 @@ exports.Stage = Montage.create(Component, { } }, + clearAllCanvas: { + value: function() { + this._drawingContext.clearRect(0, 0, this._drawingCanvas.width, this._drawingCanvas.height); + this.context.clearRect(0, 0, this.canvas.width, this.canvas.height); + this.layout.clearCanvas(); + } + }, + SelectTool: { value: function(cursor) { this._drawingCanvas.style.cursor = cursor; -- cgit v1.2.3 From 66edf78c7e5df11218ef733686965beab05c7c7d Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 18 May 2012 14:01:00 -0700 Subject: fixing a scrolling issue when multiple documents are switched Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 69 +++++++++----------------------------------- 1 file changed, 14 insertions(+), 55 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 8da89fb9..73d3aaf4 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -108,7 +108,6 @@ exports.Stage = Montage.create(Component, { // We will set this to false while moving objects to improve performance showSelectionBounds: { value: true }, - _documentRoot: { value: null }, _viewport: { value: null }, _documentOffsetLeft: { value: 0 }, _documentOffsetTop: { value: 0 }, @@ -121,11 +120,6 @@ exports.Stage = Montage.create(Component, { _maxHorizontalScroll: { value: 0 }, _maxVerticalScroll: { value: 0 }, - documentRoot: { - get: function () { return this._documentRoot; }, - set: function(value) { this._documentRoot = value; } - }, - viewport: { get: function () { return this._viewport; }, set: function(value) { this._viewport = value; } @@ -195,10 +189,7 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingLeft = value; this._documentOffsetLeft = -value; - if(!this._documentRoot) { - this._documentRoot = this.application.ninja.currentDocument.documentRoot; - } - this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; + this.application.ninja.currentDocument.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-left"] = -value + "px"; this.userContentLeft = this._documentOffsetLeft; this.updatedStage = true; } @@ -209,10 +200,7 @@ exports.Stage = Montage.create(Component, { set: function(value) { this._userPaddingTop = value; this._documentOffsetTop = -value; - if(!this._documentRoot) { - this._documentRoot = this.application.ninja.currentDocument.documentRoot; - } - this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; + this.application.ninja.currentDocument.documentRoot.ownerDocument.getElementsByTagName("HTML")[0].style["padding-top"] = -value + "px"; this.userContentTop = this._documentOffsetTop; this.updatedStage = true; } @@ -287,46 +275,17 @@ exports.Stage = Montage.create(Component, { this._canvas.width = this._layoutCanvas.width = this._drawingCanvas.width = this.element.offsetWidth - 11 ; this._canvas.height = this._layoutCanvas.height = this._drawingCanvas.height = this.element.offsetHeight - 11; - this._documentRoot = this.application.ninja.currentDocument.documentRoot; - - // Hardcode this value so that it does not fail for the new stage architecture - // TODO: Remove marker for old template: NINJA-STAGE-REWORK - if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { - this._viewport = this.application.ninja.currentDocument.documentRoot.parentNode; - - this.documentOffsetLeft = this._viewport.offsetLeft; - this.documentOffsetTop = this._viewport.offsetTop; - - // Center the stage - this.centerStage(); - - this._scrollLeft = this._iframeContainer.scrollLeft; - this._scrollTop = this._iframeContainer.scrollTop; - this.application.ninja.currentDocument.savedLeftScroll = this._iframeContainer.scrollLeft; - this.application.ninja.currentDocument.savedTopScroll = this._iframeContainer.scrollTop; - - this.userContentBorder = parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); - - this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; - this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; - - this._iframeContainer.addEventListener("scroll", this, false); - this.application.ninja.currentDocument.iframe.style.opacity = 1.0; - } else { - this.userContentBorder = 0; - - this._scrollLeft = 0; - this._scrollTop = 0; - this._userContentLeft = this._documentOffsetLeft; - this._userContentTop = this._documentOffsetTop; - - this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; - this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; - this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addEventListener("scroll", this, false); - } + this.userContentBorder = 0; + this._scrollLeft = 0; + this._scrollTop = 0; + this._userContentLeft = this._documentOffsetLeft; + this._userContentTop = this._documentOffsetTop; + this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; + this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; + this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addEventListener("scroll", this, false); // TODO - We will need to modify this once we support switching between multiple documents this.application.ninja.toolsData.selectedToolInstance._configure(true); @@ -526,8 +485,8 @@ exports.Stage = Montage.create(Component, { // TODO - scroll events are not dependable. We may need to use a timer to simulate // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values // on mouse down. -// this._maxHorizontalScroll = this._documentRoot.scrollWidth - this._canvas.width - 11; -// this._maxVerticalScroll = this._documentRoot.scrollHeight - this._canvas.height - 11; +// this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; +// this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; } // Need to clear the snap cache and set up the drag plane @@ -566,8 +525,8 @@ exports.Stage = Montage.create(Component, { centerStage: { value: function() { if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { - this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this._documentRoot.parentNode.offsetWidth)/2; - this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this._documentRoot.parentNode.offsetHeight)/2; + this._iframeContainer.scrollLeft = this._documentOffsetLeft - (this._iframeContainer.offsetWidth - this.application.ninja.currentDocument.documentRoot.parentNode.offsetWidth)/2; + this._iframeContainer.scrollTop = this._documentOffsetTop - (this._iframeContainer.offsetHeight - this.application.ninja.currentDocument.documentRoot.parentNode.offsetHeight)/2; this._scrollLeft = this._iframeContainer.scrollLeft; this._scrollTop = this._iframeContainer.scrollTop; -- cgit v1.2.3 From 7a22f7b368ef549a5b30c58a0f3900685b764bdb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 18 May 2012 16:56:16 -0700 Subject: integrated open code view document in new dom architecture Signed-off-by: Ananya Sen --- js/stage/stage-view.reel/stage-view.js | 120 +-------------------------------- 1 file changed, 1 insertion(+), 119 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index ba94fadf..e8f29306 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -31,81 +31,6 @@ exports.StageView = Montage.create(Component, { } }, - /** - * Public method - * Creates a textarea element which will contain the content of the opened text document. - */ - createTextAreaElement: { - value: function(uuid) { - var codeMirrorDiv = document.createElement("div"); - codeMirrorDiv.id = "codeMirror_" + uuid; - codeMirrorDiv.style.display = "block"; - this.element.appendChild(codeMirrorDiv); - - var textArea = document.createElement("textarea"); - textArea.id = "code"; - textArea.name = "code"; - codeMirrorDiv.appendChild(textArea); - - return textArea; - } - }, - - /** - * Public method - * Creates a new instance of a code editor - */ - createTextView: { - value: function(doc) { - var type; - this.application.ninja.documentController._hideCurrentDocument(); - this.hideOtherDocuments(doc.uuid); - - switch(doc.documentType) { - case "css" : - type = "css"; - break; - case "js" : - type = "javascript"; - break; - case "html" : - type = "htmlmixed"; - break; - case "json" : - type = "javascript"; - break; - case "php" : - type = "php"; - break; - case "pl" : - type = "perl"; - break; - case "py" : - type = "python"; - break; - case "rb" : - type = "ruby"; - break; - case "xml" : - type = "xml"; - break; - } - document.getElementById("codeMirror_"+doc.uuid).style.display="block"; - - doc.editor = this.application.ninja.codeEditorController.createEditor(doc, type, doc.documentType); - doc.editor.hline = doc.editor.setLineClass(0, "activeline"); - - this.application.ninja.stage._scrollFlag = false; // TODO HACK to prevent type error on Hide/Show Iframe - this.application.ninja.documentController.activeDocument = doc; - this.application.ninja.stage.hideCanvas(true); - document.getElementById("iframeContainer").style.display="none";//hide the iframe when switching to code view - - this.showCodeViewBar(true); - this.application.ninja.codeEditorController.applySettings(); - this.collapseAllPanels(); - } - }, - /** * Public method * Switches between documents. Document state data is saved and restored whereever applicable @@ -157,16 +82,6 @@ exports.StageView = Montage.create(Component, { } }, - /** - * Public method - * Switches between different views of a design document, like HTML design view, HTML code view - */ - switchDesignDocViews: { - value: function() { - //TODO - } - }, - showRulers:{ value:function(){ this.application.ninja.rulerTop.style.display = "block"; @@ -178,39 +93,6 @@ exports.StageView = Montage.create(Component, { this.application.ninja.rulerTop.style.display = "none"; this.application.ninja.rulerLeft.style.display = "none"; } - }, - showCodeViewBar:{ - value:function(isCodeView){ - if(isCodeView === true) { - this.application.ninja.editorViewOptions.element.style.display = "block"; - this.application.ninja.documentBar.element.style.display = "none"; - } else { - this.application.ninja.documentBar.element.style.display = "block"; - this.application.ninja.editorViewOptions.element.style.display = "none"; - } - } - }, - - collapseAllPanels:{ - value:function(){ - this.application.ninja.panelSplitter.collapse(); - this.application.ninja.timelineSplitter.collapse(); - this.application.ninja.toolsSplitter.collapse(); - this.application.ninja.optionsSplitter.collapse(); - } - }, - restoreAllPanels:{ - value:function(){ - this.application.ninja.panelSplitter.restore(); - this.application.ninja.timelineSplitter.restore(); - this.application.ninja.toolsSplitter.restore(); - this.application.ninja.optionsSplitter.restore(); - } - }, - - applyTheme:{ - value:function(themeClass){ - this.element.className = "codeViewContainer "+themeClass; - } } + }); \ No newline at end of file -- cgit v1.2.3 From 2cc8e58f6bb9f64a7473e62aecd013fa55167231 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 21 May 2012 16:42:26 -0700 Subject: - added opening multiple code and design view documents - switching between multiple code and design view documents - Note: closing of documents, when multiple documents are open, is not yet implemented Signed-off-by: Ananya Sen --- js/stage/stage-view.reel/stage-view.js | 14 ----------- js/stage/stage.reel/stage.js | 44 +++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 15 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.js b/js/stage/stage-view.reel/stage-view.js index 139fa032..2c129ee2 100755 --- a/js/stage/stage-view.reel/stage-view.js +++ b/js/stage/stage-view.reel/stage-view.js @@ -58,19 +58,5 @@ exports.StageView = Montage.create(Component, { NJevent("switchDocument"); } - }, - - showRulers:{ - value:function(){ - this.application.ninja.rulerTop.style.display = "block"; - this.application.ninja.rulerLeft.style.display = "block"; - } - }, - hideRulers:{ - value:function(){ - this.application.ninja.rulerTop.style.display = "none"; - this.application.ninja.rulerLeft.style.display = "none"; - } } - }); \ No newline at end of file diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 73d3aaf4..f768f03a 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -1012,5 +1012,47 @@ exports.Stage = Montage.create(Component, { this._iframeContainer.scrollTop = this.application.ninja.documentController.activeDocument.savedTopScroll; this._scrollTop = this.application.ninja.documentController.activeDocument.savedTopScroll; } - } + }, + + showRulers:{ + value:function(){ + this.application.ninja.rulerTop.style.display = "block"; + this.application.ninja.rulerLeft.style.display = "block"; + } + }, + hideRulers:{ + value:function(){ + this.application.ninja.rulerTop.style.display = "none"; + this.application.ninja.rulerLeft.style.display = "none"; + } + }, + showCodeViewBar:{ + value:function(isCodeView){ + if(isCodeView === true) { + this.application.ninja.editorViewOptions.element.style.display = "block"; + this.application.ninja.documentBar.element.style.display = "none"; + } else { + this.application.ninja.documentBar.element.style.display = "block"; + this.application.ninja.editorViewOptions.element.style.display = "none"; + } + } + }, + + collapseAllPanels:{ + value:function(){ + this.application.ninja.panelSplitter.collapse(); + this.application.ninja.timelineSplitter.collapse(); + this.application.ninja.toolsSplitter.collapse(); + this.application.ninja.optionsSplitter.collapse(); + } + }, + restoreAllPanels:{ + value:function(){ + this.application.ninja.panelSplitter.restore(); + this.application.ninja.timelineSplitter.restore(); + this.application.ninja.toolsSplitter.restore(); + this.application.ninja.optionsSplitter.restore(); + } + } + }); \ No newline at end of file -- cgit v1.2.3 From 2b207ef8b2594927f8cd6cd63a8483d205cb86c4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 22 May 2012 15:41:51 -0700 Subject: fixing the selection in multiple documents and some code cleanup Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index f768f03a..69cfa7ba 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -468,26 +468,19 @@ exports.Stage = Montage.create(Component, { */ handleScroll: { value: function() { - // TODO: Remove marker for old template: NINJA-STAGE-REWORK - if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") { - this._scrollLeft = this._iframeContainer.scrollLeft; - this._scrollTop = this._iframeContainer.scrollTop; - this.userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; - this.userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; - } else { - this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; - this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; + this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; + this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; - this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; - this.userContentTop = this._documentOffsetTop - this._scrollTop; + this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; + this.userContentTop = this._documentOffsetTop - this._scrollTop; + + // TODO - scroll events are not dependable. We may need to use a timer to simulate + // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values + // on mouse down. + // this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; + // this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; - // TODO - scroll events are not dependable. We may need to use a timer to simulate - // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values - // on mouse down. -// this._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; -// this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; - } // Need to clear the snap cache and set up the drag plane //snapManager.setupDragPlaneFromPlane( workingPlane ); -- cgit v1.2.3 From f97590388467b5a3316f6f155162fc293915fddc Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 23 May 2012 16:09:22 -0700 Subject: Fixed scrolling and centering stage code. Also, moved liveNodeList into the design view and added an option to exclude styles and text nodes when retrieving the live nodes. Signed-off-by: Nivesh Rajbhandari --- js/stage/layout.js | 11 ++++---- js/stage/stage-deps.js | 50 +++++------------------------------- js/stage/stage.reel/stage.js | 60 +++++++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 81 deletions(-) (limited to 'js/stage') diff --git a/js/stage/layout.js b/js/stage/layout.js index 9c5e2167..107e8abf 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -64,10 +64,10 @@ exports.Layout = Montage.create(Component, { if(this.application.ninja.documentController.activeDocument.currentView === "design") { this.elementsToDraw = this.application.ninja.documentController.activeDocument.documentRoot.childNodes; } - - // Draw the elements and the 3d info - this.draw(); - this.draw3DInfo(false); +// +// // Draw the elements and the 3d info +// this.draw(); +// this.draw3DInfo(false); } }, @@ -89,7 +89,8 @@ exports.Layout = Montage.create(Component, { if(this.application.ninja.documentController.activeDocument.currentView === "design"){ // Make an array copy of the line node list which is not an array like object - this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); +// this.domTree = Array.prototype.slice.call(this.application.ninja.documentController.activeDocument._liveNodeList, 0); + this.domTree = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true); // Index of the current container containerIndex = this.domTree.indexOf(this.application.ninja.currentSelectedContainer); diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index 0d53696b..d018b03b 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -26,38 +26,12 @@ exports.StageDeps = Montage.create(Component, { value: drawUtils }, - _userContentLeft: { - value: null - }, - - userContentLeft: { - get: function() { return this._userContentLeft; }, - set: function(value) { - if(value != null) { - viewUtils.setUserContentLeft(value); - } - } - }, - - _userContentTop: { - value: null - }, - - userContentTop: { - get: function() { return this._userContentTop; }, - set: function(value) { - if(value != null) { - viewUtils.setUserContentTop(value); - } - } - }, - deserializedFromTemplate: { value: function() { this.eventManager.addEventListener("appLoaded", this, false); - this.eventManager.addEventListener("openDocument", this, false); - this.eventManager.addEventListener("switchDocument", this, false); +// this.eventManager.addEventListener("openDocument", this, false); +// this.eventManager.addEventListener("switchDocument", this, false); // Initialize Deps // HACK @@ -76,19 +50,6 @@ exports.StageDeps = Montage.create(Component, { handleAppLoaded: { value: function() { - - Object.defineBinding(this, "userContentLeft", { - boundObject: this.stage, - boundObjectPropertyPath: "_userContentLeft", - oneway: true - }); - - Object.defineBinding(this, "userContentTop", { - boundObject: this.stage, - boundObjectPropertyPath: "_userContentTop", - oneway: true - }); - // Setup the snap manager pointer to the app model snapManager.appModel = this.application.ninja.appModel; // bind the snap properties to the snap manager @@ -105,7 +66,8 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; - snapManager.reload2DCache(); +// snapManager.reload2DCache(); + snapManager._isCacheInvalid = true; snapManager.setupDragPlaneFromPlane (workingPlane); drawUtils.initializeFromDocument(); @@ -116,9 +78,9 @@ exports.StageDeps = Montage.create(Component, { value: function(){ workingPlane = [0,0,1,0]; + snapManager._isCacheInvalid = true; snapManager.setupDragPlaneFromPlane (workingPlane); - snapManager.reload2DCache(); - +// snapManager.reload2DCache(); drawUtils.initializeFromDocument(); } diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 69cfa7ba..a3903ac7 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -235,14 +235,6 @@ exports.Stage = Montage.create(Component, { this._context = this._canvas.getContext("2d"); this._drawingContext= this._drawingCanvas.getContext("2d"); - this._scrollLeft = this._iframeContainer.scrollLeft; - this._scrollTop = this._iframeContainer.scrollTop; - this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; - this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; - - // TODO: Fix the mouse wheel scroll - // this._canvas.addEventListener("mousewheel", this, false); - /