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