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/controllers/document-controller.js | 2 +- js/document/document-html.js | 5 +++-- js/document/models/html.js | 5 +++++ js/ninja.reel/ninja.js | 2 +- js/stage/stage.reel/stage.js | 27 ++++++++++----------------- 5 files changed, 20 insertions(+), 21 deletions(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d99fadbb..7758f346 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -500,7 +500,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if(currentDocument) { if(currentDocument.currentView === "design") { currentDocument.serializeDocument(); - this.application.ninja.selectionController._selectionContainer = null; + this.application.ninja._currentSelectedContainer = this.application.ninja.selectionController._selectionContainer = null; currentDocument.model.views.design.propertiesPanel.clear(); } diff --git a/js/document/document-html.js b/js/document/document-html.js index d6b4ba95..f92a425c 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -147,9 +147,10 @@ exports.HtmlDocument = Montage.create(Component, { this.model.userContentTop = this.application.ninja.stage._userContentTop; - // Serialize the selection + // Serialize the selection, the container and grid //TODO: Move this property to the design view class this.model.selection = this.application.ninja.selectedElements.slice(0); + this.model.selectionContainer = this.application.ninja.currentSelectedContainer; this.draw3DGrid = this.application.ninja.appModel.show3dGrid; // Serialize the undo @@ -177,7 +178,7 @@ exports.HtmlDocument = Montage.create(Component, { //TODO: Move this property to the design view class this.application.ninja.selectedElements = this.model.selection.slice(0); - +// this.application.ninja.currentSelectedContainer = this.model.selectionContainer; this.application.ninja.appModel.show3dGrid = this.draw3DGrid; // Serialize the undo diff --git a/js/document/models/html.js b/js/document/models/html.js index a97b4b5a..9cc8ce92 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -21,6 +21,11 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // selection: { value: [] + }, + //////////////////////////////////////////////////////////////////// + // + selectionContainer: { + value: [] }, //////////////////////////////////////////////////////////////////// // diff --git a/js/ninja.reel/ninja.js b/js/ninja.reel/ninja.js index 80d1b406..9f1d1b3b 100755 --- a/js/ninja.reel/ninja.js +++ b/js/ninja.reel/ninja.js @@ -296,7 +296,7 @@ exports.Ninja = Montage.create(Component, { this.currentDocument = this.documentController.activeDocument; if(this.currentDocument.documentRoot) { - this._currentSelectedContainer = this.selectionController._currentSelectedContainer = this.currentDocument.documentRoot; + this._currentSelectedContainer = this.selectionController._selectionContainer = this.currentDocument.documentRoot; } NJevent("switchDocument"); 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