From ee54342b5f4fdd41c46543d6402e649e4b3d57cb Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 22 May 2012 17:58:23 -0700 Subject: - don't redraw stage for code document - fixes a switching bug - fix for ctrl+S for code document - disallow opening the panels while in code document Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 5 +++++ js/helper-classes/3D/view-utils.js | 4 ++-- js/mediators/keyboard-mediator.js | 2 +- js/panels/Splitter.js | 7 +++++-- 4 files changed, 13 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d99fadbb..91f4753d 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -524,6 +524,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.hideCanvas(true); this.application.ninja.stage.hideRulers(); } + }else if(!currentDocument && newDocument.currentView === "code"){ + this.application.ninja.stage.showCodeViewBar(true); + this.application.ninja.stage.collapseAllPanels(); + this.application.ninja.stage.hideCanvas(true); + this.application.ninja.stage.hideRulers(); } this.application.ninja.stage.clearAllCanvas(); diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 0080bf90..0a4fe0ac 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -1005,9 +1005,9 @@ exports.ViewUtils = Montage.create(Component, { this.popViewportObj(); if (elt === this.application.ninja.currentDocument.documentRoot) break; - if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; + if (this.application.ninja.currentDocument.documentRoot && elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; elt = elt.offsetParent; - if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; + if (this.application.ninja.currentDocument.documentRoot && elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; } return mat; diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 23a2ce75..2f55edb4 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -88,7 +88,7 @@ exports.KeyboardMediator = Montage.create(Component, { //keyboard controls for html design view // TODO - New template mode doesn't set currentView yet. - if((!!this.application.ninja.currentDocument)){// && (this.application.ninja.currentDocument.model.currentView === "design")){ + if((!!this.application.ninja.currentDocument) && (this.application.ninja.currentDocument.model.currentView === "design")){ // Don't do anything if an input or other control is focused if(document.activeElement.nodeName !== "BODY") { diff --git a/js/panels/Splitter.js b/js/panels/Splitter.js index 0640abb2..8675d314 100755 --- a/js/panels/Splitter.js +++ b/js/panels/Splitter.js @@ -111,8 +111,9 @@ exports.Splitter = Montage.create(Component, { } else { this.panel.removeEventListener("webkitTransitionEnd", this, false); } - - this.application.ninja.stage.resizeCanvases = true; + if(this.application.ninja.currentDocument.currentView === "design"){ + this.application.ninja.stage.resizeCanvases = true; + } } }, @@ -149,6 +150,7 @@ exports.Splitter = Montage.create(Component, { this.panel.addEventListener("webkitTransitionEnd", this, false); } this._collapsed = true; + this.disabled = true; this.needsDraw = true; } } @@ -169,6 +171,7 @@ exports.Splitter = Montage.create(Component, { } else { this.panel.addEventListener("webkitTransitionEnd", this, false); } + this.disabled = false; this.needsDraw = true; } } -- cgit v1.2.3 From f1dbf7c58e91a27c80f3a607e87ad122d803c500 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 23 May 2012 13:29:13 -0700 Subject: Timeline triggerBinding needs to be set to false in the track data. Signed-off-by: Nivesh Rajbhandari --- js/panels/Timeline/Layer.reel/Layer.js | 6 +----- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 9 +++------ js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js | 6 +----- 3 files changed, 5 insertions(+), 16 deletions(-) (limited to 'js') diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js index 6358a0e0..e8619d02 100644 --- a/js/panels/Timeline/Layer.reel/Layer.js +++ b/js/panels/Timeline/Layer.reel/Layer.js @@ -498,11 +498,7 @@ var Layer = exports.Layer = Montage.create(Component, { triggerOutgoingBinding : { value: function() { - if (this.layerData.triggerBinding === true) { - this.layerData.triggerBinding = false; - } else { - this.layerData.triggerBinding = true; - } + this.layerData.triggerBinding = !this.layerData.triggerBinding; } }, /* END: Models */ diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index c382c9a7..80133edf 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -437,6 +437,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { returnObj.layerData.isVisible = true; returnObj.layerData.docUUID = this.application.ninja.currentDocument._uuid; returnObj.layerData.isTrackAnimated = false; + returnObj.layerData.triggerBinding = false; returnObj.parentElementUUID = null; returnObj.parentElement = null; @@ -1402,12 +1403,8 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // Trigger the layer/track data binding triggerLayerBinding : { value: function(intIndex) { - if (this.arrLayers[intIndex].layerData.triggerBinding === true) { - this.arrLayers[intIndex].layerData.triggerBinding = false; - } else { - this.arrLayers[intIndex].layerData.triggerBinding = true; - } - } + this.arrLayers[intIndex].layerData.triggerBinding = !this.arrLayers[intIndex].layerData.triggerBinding; + } }, handleLayerDragStart : { diff --git a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js index 2c15a99c..3d83dc36 100644 --- a/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js +++ b/js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js @@ -405,11 +405,7 @@ var TimelineTrack = exports.TimelineTrack = Montage.create(Component, { triggerOutgoingBinding : { value: function() { - if (this.trackData.triggerBinding === true) { - this.trackData.triggerBinding = false; - } else { - this.trackData.triggerBinding = true; - } + this.trackData.triggerBinding = !this.trackData.triggerBinding; } }, -- cgit v1.2.3 From 26d4cbf0f5c65f60051273f1648a0e8005d8c78a Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 23 May 2012 13:40:56 -0700 Subject: - removed redundant change - fixed js error on click of splitters when no documents are open Signed-off-by: Ananya Sen --- js/helper-classes/3D/view-utils.js | 4 ++-- js/panels/Splitter.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 0a4fe0ac..0080bf90 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -1005,9 +1005,9 @@ exports.ViewUtils = Montage.create(Component, { this.popViewportObj(); if (elt === this.application.ninja.currentDocument.documentRoot) break; - if (this.application.ninja.currentDocument.documentRoot && elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; + if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; elt = elt.offsetParent; - if (this.application.ninja.currentDocument.documentRoot && elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; + if (elt === this.application.ninja.currentDocument.documentRoot.parentNode) break; } return mat; diff --git a/js/panels/Splitter.js b/js/panels/Splitter.js index 8675d314..f0fb1a45 100755 --- a/js/panels/Splitter.js +++ b/js/panels/Splitter.js @@ -111,7 +111,7 @@ exports.Splitter = Montage.create(Component, { } else { this.panel.removeEventListener("webkitTransitionEnd", this, false); } - if(this.application.ninja.currentDocument.currentView === "design"){ + if(this.application.ninja.currentDocument && this.application.ninja.currentDocument.currentView === "design"){ this.application.ninja.stage.resizeCanvases = true; } } -- cgit v1.2.3 From d5b36812ba84e49aa8b597eea9f75bf36ddcb571 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 23 May 2012 15:24:25 -0700 Subject: fixing the styles manager to open code view files and closing the last document. Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 15 ++++++--------- js/controllers/styles-controller.js | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 3e15511d..aa037bd4 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -399,10 +399,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(this._documents.length > 0) { previousFocusedDocument = this._documents[this._documents.length - 1]; - this._activeDocument = previousFocusedDocument; - this.switchDocuments(this.activeDocument, previousFocusedDocument, true); + this.activeDocument = previousFocusedDocument; + this.switchDocuments(this.activeDocument, previousFocusedDocument, false); } else { - this._activeDocument = null; + this.activeDocument = null; this.application.ninja.stage.hideRulers(); this.application.ninja.stage.hideCanvas(true); @@ -524,13 +524,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.restoreAllPanels(); this.application.ninja.stage.hideCanvas(false); this.application.ninja.stage.showRulers(); - } else if(currentDocument.currentView === "design" && newDocument.currentView === "code") { - this.application.ninja.stage.showCodeViewBar(true); - this.application.ninja.stage.collapseAllPanels(); - this.application.ninja.stage.hideCanvas(true); - this.application.ninja.stage.hideRulers(); } - }else if(!currentDocument && newDocument.currentView === "code"){ + } + + if(newDocument.currentView === "code") { this.application.ninja.stage.showCodeViewBar(true); this.application.ninja.stage.collapseAllPanels(); this.application.ninja.stage.hideCanvas(true); diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index dcbe0eaf..8ceb9774 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -81,7 +81,7 @@ var stylesController = exports.StylesController = Montage.create(Component, { set : function(document) { ///// If the document is null set default stylesheets to null - if(!document) { + if(!document || document.currentView === "code") { this._activeDocument = null; this._stageStylesheet = null; this.defaultStylesheet = null; -- cgit v1.2.3 From 0ca1910df1c78116139664bf39a95cf0ec7c8dc8 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 23 May 2012 15:35:15 -0700 Subject: adding document views checks for the timeline and breadcrumb Signed-off-by: Valerio Virgillito --- js/components/layout/bread-crumb.reel/bread-crumb.js | 2 +- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js index d2a6b1e4..aaefd923 100755 --- a/js/components/layout/bread-crumb.reel/bread-crumb.js +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js @@ -21,7 +21,7 @@ exports.Breadcrumb = Montage.create(Component, { handleCloseDocument: { value: function(){ - if(!this.application.ninja.documentController.activeDocument) { + if(!this.application.ninja.documentController.activeDocument && this.application.ninja.currentDocument.currentView !== "code") { this.disabled = true; this.application.ninja.currentSelectedContainer = (this.application.ninja.currentDocument ? this.application.ninja.currentDocument.documentRoot : null); } diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 80133edf..2c02e544 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -596,7 +596,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // That's all we need to do for a brand new file. // But what if we're opening an existing document? - if (!this.application.ninja.documentController.creatingNewFile) { + if (!this.application.ninja.documentController.creatingNewFile && this.application.ninja.currentDocument.currentView !== "code") { // Opening an existing document. If it has DOM elements we need to restore their timeline info if (this.application.ninja.currentDocument.documentRoot.children[0]) { // Yes, it has DOM elements. Loop through them and create a new object for each. -- 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/document/document-html.js | 2 +- js/document/views/design.js | 42 ++++++++++++++++++++++++-- js/helper-classes/3D/draw-utils.js | 19 +++++++----- js/helper-classes/3D/view-utils.js | 13 ++------- js/stage/layout.js | 11 +++---- js/stage/stage-deps.js | 50 ++++--------------------------- js/stage/stage.reel/stage.js | 60 ++++++++++++++++++-------------------- 7 files changed, 95 insertions(+), 102 deletions(-) (limited to 'js') diff --git a/js/document/document-html.js b/js/document/document-html.js index f92a425c..2fc32791 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -98,7 +98,7 @@ exports.HtmlDocument = Montage.create(Component, { this.documentRoot = this.model.views.design.document.body; } //TODO: Why is this needed? - this._liveNodeList = this.documentRoot.getElementsByTagName('*'); + this.model.views.design._liveNodeList = this.documentRoot.getElementsByTagName('*'); //Initiliazing document model document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body"); //Adding observer to know when template is ready diff --git a/js/document/views/design.js b/js/document/views/design.js index b3887fdf..427ef706 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -67,7 +67,43 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { propertiesPanel: { value: null }, + //////////////////////////////////////////////////////////////////// + // + _liveNodeList: { + value: null + }, + + getLiveNodeList: { + value: function(useFilter) { + if(useFilter) { + var filteredNodes = [], + childNodes = Array.prototype.slice.call(this._liveNodeList, 0); + + childNodes.forEach(function(item) { + if( (item.nodeType === 1) && (item.nodeName !== "STYLE") && (item.nodeName !== "SCRIPT")) { + filteredNodes.push(item); + } + }); + return filteredNodes; + } else { + return this._liveNodeList; + } + } + }, + //////////////////////////////////////////////////////////////////// + // + + initialPaddingLeft: { + value: 0 + }, + + initialPaddingTop: { + value: 0 + }, + //////////////////////////////////////////////////////////////////// + // + // initialize: { value: function (parent) { @@ -190,8 +226,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //Calling standard method to finish opening document this.bodyContentLoaded(null); //TODO: Move this to be set via the controller - this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); - this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); +// this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); +// this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); +// this.initialPaddingLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); +// this.initialPaddingTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index bf48a723..79be5c14 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -119,7 +119,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { initializeFromDocument:{ value:function(){ - var documentRootChildren = null, i, stage = this.application.ninja.stage; + var i, + documentRootChildren = this.application.ninja.currentDocument.model.views.design.getLiveNodeList(true), + stage = this.application.ninja.stage, + len = documentRootChildren.length; //initialize with current document this._eltArray = []; this._planesArray = []; @@ -128,11 +131,11 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this.setWorkingPlane( [0,0,1,0] ); //Loop through all the top-level children of the current document and call drawUtils.addElement on them - if(this.application.ninja.currentDocument._liveNodeList.length > 0){ - documentRootChildren = this.application.ninja.currentDocument._liveNodeList; - var len = documentRootChildren.length, - minLeft = stage.userPaddingLeft, - minTop = stage.userPaddingTop, + if(len > 0) { + var initL = 0, + initT = 0, + minLeft = 0, + minTop = 0, docLeft = stage.documentOffsetLeft, docTop = stage.documentOffsetTop, l, @@ -151,10 +154,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { minTop = t; } } - if(minLeft !== stage.userPaddingLeft) { + if(minLeft !== initL) { stage.userPaddingLeft = minLeft; } - if(minTop !== stage.userPaddingTop) { + if(minTop !== initT) { stage.userPaddingTop = minTop; } } diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 0080bf90..24b30298 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js @@ -24,9 +24,6 @@ exports.ViewUtils = Montage.create(Component, { // keep a stack of viewport objects _viewportObjStack: { value: []}, - _userContentLeft: { value: null}, - _userContentTop: { value: null}, - /////////////////////////////////////////////////////////////////////// // Property accessors /////////////////////////////////////////////////////////////////////// @@ -39,9 +36,6 @@ exports.ViewUtils = Montage.create(Component, { }, getViewportObj: { value: function() { return this.m_viewportObj; } }, - setUserContentLeft: { value: function(value) { this._userContentLeft = value; }}, - setUserContentTop: { value: function(value) { this._userContentTop = value; }}, - getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, /////////////////////////////////////////////////////////////////////// @@ -385,7 +379,7 @@ exports.ViewUtils = Montage.create(Component, { // transform the bounds up the tree var parent = child.offsetParent; // TODO - Should have a different way to check for new template mode - if ( parent || ((child === this.application.ninja.currentDocument.documentRoot) && (child.id !== "UserContent")) ) + if ( parent || (child === this.application.ninja.currentDocument.documentRoot) ) { this.setViewportObj( child ); @@ -703,8 +697,8 @@ exports.ViewUtils = Montage.create(Component, { { // TODO - Call a routine from the user document controller to get the offsets/margins // Once we expose the document controller to ViewUtils - offset[0] += this._userContentLeft; - offset[1] += this._userContentTop; + offset[0] += this.application.ninja.stage._userContentLeft; + offset[1] += this.application.ninja.stage._userContentTop; } return offset; @@ -1282,7 +1276,6 @@ exports.ViewUtils = Montage.create(Component, { // stageManager._canvas: this.application.ninja.stage.canvas // stageManager.layoutCanvas: this.application.ninja.stage.layoutCanvas // stageManager.drawingCanvas: this.application.ninja.stage.drawingCanvas -// stageManager.userContentLeft this.application.ninja.stage.userContentLeft // viewUtils: stage.viewUtils; // snapManager stage.snapManager; // 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); - // Setup event listeners this._drawingCanvas.addEventListener("mousedown", this, false); this._drawingCanvas.addEventListener("mouseup", this, false); @@ -269,30 +261,38 @@ exports.Stage = Montage.create(Component, { // Event details will contain the active document prior to opening a new one handleOpenDocument: { value: function(evt) { + var designView = this.application.ninja.currentDocument.model.views.design; + this.hideCanvas(false); // Recalculate the canvas sizes because of splitter resizing 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.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); + designView.iframe.contentWindow.addEventListener("scroll", this, false); this.addPropertyChangeListener("appModel.show3dGrid", this, false); + this.stageDeps.handleOpenDocument(); this.layout.handleOpenDocument(); + + if(designView._template) { + var initialLeft = parseInt((this.canvas.width - designView._template.size.width)/2); + var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2); + if(initialLeft > this.documentOffsetLeft) { + this.userPaddingLeft = -initialLeft; + } + if(initialTop > this.documentOffsetTop) { + this.userPaddingTop = -initialTop; + } + } + + this.centerStage(); + + // TODO - We will need to modify this once we support switching between multiple documents + this.application.ninja.toolsData.selectedToolInstance._configure(true); } }, @@ -485,10 +485,7 @@ exports.Stage = Montage.create(Component, { // Need to clear the snap cache and set up the drag plane //snapManager.setupDragPlaneFromPlane( workingPlane ); this.stageDeps.snapManager._isCacheInvalid = true; - - this.needsDraw = true; - this.layout.draw(); - //this._toolsList.action("DrawHandles"); + this.updatedStage = true; } }, @@ -517,16 +514,15 @@ 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.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; + var designView = this.application.ninja.currentDocument.model.views.design; + if(designView._template) { + designView.document.body.scrollLeft = this._documentOffsetLeft - parseInt((this.canvas.width - designView._template.size.width)/2); + designView.document.body.scrollTop = this._documentOffsetTop - parseInt((this.canvas.height - designView._template.size.height)/2); } 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; + designView.document.body.scrollLeft = this._documentOffsetLeft; + designView.document.body.scrollTop = this._documentOffsetTop; } + this.handleScroll(); } }, -- cgit v1.2.3 From 8fdf7567a7967208f554657c6c6d5665ab55e118 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 24 May 2012 06:10:05 -0700 Subject: Update stage to handle switching between documents. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'js') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index a3903ac7..ad05f1cc 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -248,6 +248,7 @@ exports.Stage = Montage.create(Component, { this.eventManager.addEventListener( "openDocument", this, false); + this.eventManager.addEventListener( "switchDocument", this, false); this.eventManager.addEventListener( "enableStageMove", this, false); this.eventManager.addEventListener( "disableStageMove", this, false); @@ -260,6 +261,18 @@ exports.Stage = Montage.create(Component, { // Event details will contain the active document prior to opening a new one handleOpenDocument: { + value: function(evt) { + this._initFromDocument(evt); + } + }, + + handleSwitchDocument: { + value: function(evt) { + this._initFromDocument(evt); + } + }, + + _initFromDocument: { value: function(evt) { var designView = this.application.ninja.currentDocument.model.views.design; -- cgit v1.2.3 From bf8a79b0ed1593b5b9e3085373dcdab9aeab055e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 24 May 2012 10:46:28 -0700 Subject: Keyboard arrows were not working because some code had not been updated to check updated document model. Signed-off-by: Nivesh Rajbhandari --- js/mediators/keyboard-mediator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 2f55edb4..e2e8e937 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -88,7 +88,7 @@ exports.KeyboardMediator = Montage.create(Component, { //keyboard controls for html design view // TODO - New template mode doesn't set currentView yet. - if((!!this.application.ninja.currentDocument) && (this.application.ninja.currentDocument.model.currentView === "design")){ + if((!!this.application.ninja.currentDocument) && (this.application.ninja.currentDocument.currentView === "design")) { // Don't do anything if an input or other control is focused if(document.activeElement.nodeName !== "BODY") { @@ -252,7 +252,7 @@ exports.KeyboardMediator = Montage.create(Component, { handleKeyup: { value: function(evt) { //keyboard controls for html design view - if((!!this.application.ninja.currentDocument)){// && (this.application.ninja.currentDocument.model.currentView === "design")){ + if((!!this.application.ninja.currentDocument) && (this.application.ninja.currentDocument.currentView === "design")) { if(document.activeElement.nodeName !== "BODY") { // Don't do anything if an input or other control is focused return; -- cgit v1.2.3 From 209ec9524a987a8f8bc20c57e2a76ac55be15fd9 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 24 May 2012 11:11:47 -0700 Subject: Fixed selection bug when switching/opening documents. Also, use saved scroll values when switching between documents. Signed-off-by: Nivesh Rajbhandari --- js/controllers/selection-controller.js | 5 ++--- js/stage/stage-deps.js | 2 -- js/stage/stage.reel/stage.js | 40 +++++++++++++++++++--------------- 3 files changed, 25 insertions(+), 22 deletions(-) (limited to 'js') diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 1092615a..214b9032 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -67,10 +67,9 @@ exports.SelectionController = Montage.create(Component, { this._isDocument = true; if(currentSelectionArray) { - if(currentSelectionArray.length >= 1) { + this.application.ninja.selectedElements = currentSelectionArray; + if(currentSelectionArray.length) { this._isDocument = false; - - this.application.ninja.selectedElements = currentSelectionArray; NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument}); } } diff --git a/js/stage/stage-deps.js b/js/stage/stage-deps.js index d018b03b..64adc01c 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -30,8 +30,6 @@ exports.StageDeps = Montage.create(Component, { value: function() { this.eventManager.addEventListener("appLoaded", this, false); -// this.eventManager.addEventListener("openDocument", this, false); -// this.eventManager.addEventListener("switchDocument", this, false); // Initialize Deps // HACK diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index ad05f1cc..6d421e4b 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -117,9 +117,6 @@ exports.Stage = Montage.create(Component, { _userContentTop: { value: 0 }, _userContentBorder: { value: 0 }, - _maxHorizontalScroll: { value: 0 }, - _maxVerticalScroll: { value: 0 }, - viewport: { get: function () { return this._viewport; }, set: function(value) { this._viewport = value; } @@ -262,18 +259,18 @@ exports.Stage = Montage.create(Component, { // Event details will contain the active document prior to opening a new one handleOpenDocument: { value: function(evt) { - this._initFromDocument(evt); + this.initWithDocument(); } }, handleSwitchDocument: { value: function(evt) { - this._initFromDocument(evt); + this.initWithDocument(true); } }, - _initFromDocument: { - value: function(evt) { + initWithDocument: { + value: function(didSwitch) { var designView = this.application.ninja.currentDocument.model.views.design; this.hideCanvas(false); @@ -282,12 +279,22 @@ 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._maxHorizontalScroll = this.application.ninja.currentDocument.documentRoot.scrollWidth - this._canvas.width - 11; - this._maxVerticalScroll = this.application.ninja.currentDocument.documentRoot.scrollHeight - this._canvas.height - 11; designView.iframe.contentWindow.addEventListener("scroll", this, false); this.addPropertyChangeListener("appModel.show3dGrid", this, false); + this._userPaddingLeft = 0; + this._userPaddingTop = 0; + + this._documentOffsetLeft = 0; + this._documentOffsetTop = 0; + + this._userContentLeft = 0; + this._userContentTop = 0; + + this._scrollLeft = 0; + this._scrollTop = 0; + this.stageDeps.handleOpenDocument(); this.layout.handleOpenDocument(); @@ -302,7 +309,13 @@ exports.Stage = Montage.create(Component, { } } - this.centerStage(); + if(didSwitch) { + this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft = this.application.ninja.currentDocument.model.scrollLeft; + this.application.ninja.currentDocument.model.views.design.document.body.scrollTop = this.application.ninja.currentDocument.model.scrollTop; + this.handleScroll(); + } else { + this.centerStage(); + } // TODO - We will need to modify this once we support switching between multiple documents this.application.ninja.toolsData.selectedToolInstance._configure(true); @@ -488,13 +501,6 @@ exports.Stage = Montage.create(Component, { 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; - - // Need to clear the snap cache and set up the drag plane //snapManager.setupDragPlaneFromPlane( workingPlane ); this.stageDeps.snapManager._isCacheInvalid = true; -- cgit v1.2.3 From 1adc3b050728e393583f94eb2216db813d4a7293 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 24 May 2012 11:20:42 -0700 Subject: Removed unused variables and methods in stage-deps, layout design, and snap-manager. Signed-off-by: Nivesh Rajbhandari --- js/document/views/design.js | 15 --------------- js/helper-classes/3D/snap-manager.js | 7 ------- js/stage/layout.js | 5 ----- js/stage/stage-deps.js | 2 -- 4 files changed, 29 deletions(-) (limited to 'js') diff --git a/js/document/views/design.js b/js/document/views/design.js index 427ef706..4f5f8da9 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -94,16 +94,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //////////////////////////////////////////////////////////////////// // - initialPaddingLeft: { - value: 0 - }, - - initialPaddingTop: { - value: 0 - }, - //////////////////////////////////////////////////////////////////// - // - // initialize: { value: function (parent) { @@ -225,11 +215,6 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this._bodyFragment = null; //Calling standard method to finish opening document this.bodyContentLoaded(null); - //TODO: Move this to be set via the controller -// this.application.ninja.stage.documentOffsetLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); -// this.application.ninja.stage.documentOffsetTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); -// this.initialPaddingLeft = parseInt((this.document.body.scrollWidth - this._template.size.width)/2); -// this.initialPaddingTop = parseInt((this.document.body.scrollHeight - this._template.size.height)/2); } }, //////////////////////////////////////////////////////////////////// diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 0f456e1e..f0f8dbe4 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -470,13 +470,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { } }, - reload2DCache: { - value: function() { - this.clear2DCache(); - this.load2DCache(workingPlane); - } - }, - clear2DCache : { value : function() { // clear the 2D cache flags in the objects diff --git a/js/stage/layout.js b/js/stage/layout.js index 107e8abf..71959f86 100755 --- a/js/stage/layout.js +++ b/js/stage/layout.js @@ -64,10 +64,6 @@ 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); } }, @@ -89,7 +85,6 @@ 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 = 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 64adc01c..896d4a5b 100755 --- a/js/stage/stage-deps.js +++ b/js/stage/stage-deps.js @@ -64,7 +64,6 @@ exports.StageDeps = Montage.create(Component, { workingPlane = [0,0,1,0]; -// snapManager.reload2DCache(); snapManager._isCacheInvalid = true; snapManager.setupDragPlaneFromPlane (workingPlane); @@ -78,7 +77,6 @@ exports.StageDeps = Montage.create(Component, { snapManager._isCacheInvalid = true; snapManager.setupDragPlaneFromPlane (workingPlane); -// snapManager.reload2DCache(); drawUtils.initializeFromDocument(); } -- cgit v1.2.3 From f801708f83aadfc688e69a244eb7cbaeca5d5e8d Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 24 May 2012 11:28:09 -0700 Subject: Getter for _liveNodeList should return a copy. Signed-off-by: Nivesh Rajbhandari --- js/document/views/design.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/document/views/design.js b/js/document/views/design.js index 4f5f8da9..13f89692 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -87,7 +87,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { }); return filteredNodes; } else { - return this._liveNodeList; + return Array.prototype.slice.call(this._liveNodeList, 0); } } }, -- cgit v1.2.3