From 238586be0df568c6804268d97bf9d3ef7cd33fda Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 26 Apr 2012 15:33:48 -0700 Subject: Simplifying the getElement method from stage and adding an exclusion list to the new template Signed-off-by: Valerio Virgillito --- js/stage/stage.reel/stage.js | 73 +++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 8382135d..fb7abf48 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -521,62 +521,59 @@ exports.Stage = Montage.create(Component, { }, /** - * GetSelectableElement: Returns a selectable object (direct child of current container) at clicked point + * GetElement: Returns the element or selectable element under the X,Y coordinates passed as an obj with x,y * - * @param: X,Y - * @return: Returns the current container if the the X,Y hits an element in the exclusion list + * @param position: mouse event + * @param selectable (default == null) if true this will return the current container element + * @return: Returns the element or container or null if the the X,Y hits the exclusion list and tool cannot operate on stage */ - GetSelectableElement: { - value: function(pos) { - var item = this.GetElement(pos); - if(this.application.ninja.currentDocument.inExclusion(item) !== -1) { - return this.application.ninja.currentSelectedContainer; + getElement: { + value: function(position, selectable) { + 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); + + // workaround Chrome 3d bug + if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(element) !== -1) { + element = this.getElementUsingSnapping(point); } - var activeContainerId = this.application.ninja.currentSelectedContainer.uuid; - if(item.parentNode.uuid === activeContainerId) { - return item; - } else { - var outerElement = item.parentNode; - while(outerElement.parentNode && outerElement.parentNode.uuid !== activeContainerId) { - // If element is higher up than current container then return - if(outerElement.id === "UserContent") return; - // else keep going up the chain - outerElement = outerElement.parentNode; + if(selectable) { + + if(this.application.ninja.currentDocument.inExclusion(element) !== -1) { + return this.application.ninja.currentSelectedContainer; } - return outerElement; - } - } - }, + var activeContainerId = this.application.ninja.currentSelectedContainer.uuid; + if(element.parentNode.uuid === activeContainerId) { + return element; + } else { + var outerElement = element.parentNode; - /** - * GetElement: Returns the object under the X,Y coordinates passed as an obj with x,y - * - * @param: X,Y - * @return: Returns the Object or null if the the X,Y hits the exclusion list and tool cannot operate on stage - */ - GetElement: { - value: function(pos) { - var point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(pos.pageX, pos.pageY)), - elt = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop); + while(outerElement.parentNode && outerElement.parentNode.uuid !== activeContainerId) { + // If element is higher up than current container then return + if(outerElement.id === "UserContent") return; + // else keep going up the chain + outerElement = outerElement.parentNode; + } + + return outerElement; + } - // workaround Chrome 3d bug - if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(elt) !== -1) { - return this._getElementUsingSnapping(point); } else { - return elt; + return element; } } }, /** - * _getElementUsingSnapping: Returns the object at point using snap manager + * getElementUsingSnapping: Returns the object at point using snap manager * * @param: point * @return: Returns the Object in the user document under the point */ - _getElementUsingSnapping: { + getElementUsingSnapping: { value: function(point) { this.stageDeps.snapManager.enableElementSnap( true ); var hitRec = this.stageDeps.snapManager.snap(point.x, point.y, true); -- cgit v1.2.3 From bcfb200482c26b2bfc0d6577b1eb0de7a19a6762 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Thu, 26 Apr 2012 16:23:59 -0700 Subject: Removing all "module" declarations and replaced with "prototype" in preparation for montage converting to the new "prototype" format fully --- js/stage/stage-view.reel/stage-view.html | 5 ++--- js/stage/stage.reel/stage.html | 17 ++++++----------- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'js/stage') diff --git a/js/stage/stage-view.reel/stage-view.html b/js/stage/stage-view.reel/stage-view.html index ee8fa315..3680e8b5 100755 --- a/js/stage/stage-view.reel/stage-view.html +++ b/js/stage/stage-view.reel/stage-view.html @@ -1,4 +1,4 @@ - +