From fc13ef1e806116bb7ece5bb06604fa4f5714a6ed Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 10:55:22 -0700 Subject: Squashed commit of the following: commit 0285afe3d4bd458a51f11241f13ea6ffdb0283ed Merge: 2f9f5e3 16d06ba Author: Nivesh Rajbhandari Date: Thu Jul 19 10:54:25 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit 2f9f5e369eb96f6c81b5e4bcbe09b418825e2864 Author: Nivesh Rajbhandari Date: Wed Jul 18 17:15:19 2012 -0700 Fixed selection bounds not drawing in nested tags. Signed-off-by: Nivesh Rajbhandari commit b0a3507f9d27579ad511c69314a09136d7f7c6a0 Author: Nivesh Rajbhandari Date: Wed Jul 18 11:07:44 2012 -0700 Layout info needs to redraw if stage is updated. Signed-off-by: Nivesh Rajbhandari commit 63c5e0bf52c33706ba597cb69f7794e287bd0f06 Author: Nivesh Rajbhandari Date: Tue Jul 17 15:40:54 2012 -0700 Per feedback from QE, we are still going to draw tool feedback on each mouse move so the selection bounds are not out of sync with the elements. Signed-off-by: Nivesh Rajbhandari commit 0599a742092b985c4002977e501e3b457173f1d9 Author: Nivesh Rajbhandari Date: Tue Jul 17 15:28:25 2012 -0700 Fixed grid not drawing correctly when switching documents and when adding/removing elements. Signed-off-by: Nivesh Rajbhandari commit fd9410606ee6358910d65b2cb5f71812fd44a7c4 Author: Nivesh Rajbhandari Date: Tue Jul 17 11:36:09 2012 -0700 Updated drawing feedback to handle matrix 2d values entered via CSS Panel. Signed-off-by: Nivesh Rajbhandari commit 559c16c7ac8c9f40b94a011a6f932d4f97df66a7 Author: Nivesh Rajbhandari Date: Mon Jul 16 17:14:28 2012 -0700 IKNinja-751 - Selection boundary doesn't follow the transform applied in the CSS Panel. Signed-off-by: Nivesh Rajbhandari commit e2da5340159db5cd6f75bf6c9b7eb9cbf959e5cd Merge: 7cc5de3 5146f22 Author: Nivesh Rajbhandari Date: Mon Jul 16 15:36:28 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit 7cc5de39e41b4220f53c91b15b0cf0ed53e0b0f6 Author: Nivesh Rajbhandari Date: Mon Jul 16 14:52:06 2012 -0700 Check if ownerDocument.defaultValue is null. Signed-off-by: Nivesh Rajbhandari commit 5ae97995a28a4b06fb7f8703eb8090ea16d88acd Merge: d17974d 0ede302 Author: Nivesh Rajbhandari Date: Mon Jul 16 09:27:22 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit d17974d77273bb635311cb6466f4427cf4d9e5d4 Author: Nivesh Rajbhandari Date: Mon Jul 16 08:45:05 2012 -0700 Pass in selectedElements array directly to drawUtils when drawing selection bounds instead of creating a duplicate array. Signed-off-by: Nivesh Rajbhandari commit 0b1ea3144cb3e2c1d272f60da32423d0604ace3b Author: Nivesh Rajbhandari Date: Fri Jul 13 14:03:40 2012 -0700 Fixed line tool not drawing the width and height info. Signed-off-by: Nivesh Rajbhandari commit b9c70e8d9ae324aa21fa5490edc71d8503bcefbc Author: Nivesh Rajbhandari Date: Fri Jul 13 12:42:25 2012 -0700 Used cached offsetWidth and offsetHeight. Signed-off-by: Nivesh Rajbhandari commit 9e17ac7124745ba745014efe149b31dee4fe658f Author: Nivesh Rajbhandari Date: Thu Jul 12 16:25:41 2012 -0700 Converting tabs to spaces … again! Signed-off-by: Nivesh Rajbhandari commit 351726c951bb73c28f0e15ea1ab32e85cc735688 Author: Nivesh Rajbhandari Date: Thu Jul 12 16:14:31 2012 -0700 Tabs should be 4 spaces. Signed-off-by: Nivesh Rajbhandari commit 250c419aa2dbcb10f012817ee7039aca77cb2518 Merge: 3f8d61a 2880e1d Author: Nivesh Rajbhandari Date: Thu Jul 12 16:08:31 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit 3f8d61a676da3992947ed9a2ed0e449780fcfbe0 Author: Nivesh Rajbhandari Date: Thu Jul 12 15:53:44 2012 -0700 Rotate tool was not working immediately after switching selection and selection bounds were not drawing after resizing canvases. Signed-off-by: Nivesh Rajbhandari commit e2e1f81e3b6917e1032e1b99b79c266937f3bb25 Author: Nivesh Rajbhandari Date: Thu Jul 12 12:15:59 2012 -0700 Single draw cycle for stage updates and tool drawings. Signed-off-by: Nivesh Rajbhandari commit 95a90b4c95ee3163c97bea317144366674e49ade Author: Nivesh Rajbhandari Date: Mon Jun 18 11:46:38 2012 -0700 Single draw cycle for the stage and layout. Signed-off-by: Nivesh Rajbhandari commit 21966b1515d80d2161a14e5a19bc66f3f49a92ce Author: Nivesh Rajbhandari Date: Fri Jun 15 13:33:14 2012 -0700 Cache element offsets, including offsetParent. Signed-off-by: Nivesh Rajbhandari commit 80c563c8ba06149691c6c1e754dd9a5e43bc7d4b Author: Nivesh Rajbhandari Date: Mon Jul 9 17:30:00 2012 -0700 Open materials editor popup next to PI button. Signed-off-by: Nivesh Rajbhandari Signed-off-by: Nivesh Rajbhandari --- js/tools/Rotate3DToolBase.js | 1 - js/tools/SelectionTool.js | 2 -- js/tools/Translate3DToolBase.js | 1 - js/tools/modifier-tool-base.js | 3 --- 4 files changed, 7 deletions(-) (limited to 'js/tools') diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index e36e23c4..545aedad 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -485,7 +485,6 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { if(len === 1) { this.target = this.application.ninja.selectedElements[0]; - drawUtils.addElement(this.target); viewUtils.pushViewportObj( this.target ); var eltCtr = viewUtils.getCenterOfProjection(); diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 923ed819..a136113b 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -102,7 +102,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } this.isDrawing = true; - this.application.ninja.stage.showSelectionBounds = false; this._use3DMode = false; @@ -183,7 +182,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.isDrawing = false; - this.application.ninja.stage.showSelectionBounds = true; if(this._escape) { this._escape = false; this._isSelecting = false; diff --git a/js/tools/Translate3DToolBase.js b/js/tools/Translate3DToolBase.js index 57a379e4..b5008666 100755 --- a/js/tools/Translate3DToolBase.js +++ b/js/tools/Translate3DToolBase.js @@ -302,7 +302,6 @@ exports.Translate3DToolBase = Montage.create(ModifierToolBase, if(len) { if(len === 1) { this.target = this.application.ninja.selectedElements[0]; - drawUtils.addElement(this.target); viewUtils.pushViewportObj( this.target ); var eltCtr = viewUtils.getCenterOfProjection(); diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index 9b855e66..c772e36c 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -480,7 +480,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { if(this._target) { this.isDrawing = true; - this.application.ninja.stage.showSelectionBounds = false; this._updateTargets(); if(this._canSnap) @@ -798,7 +797,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { if(len === 1) { this.target = this.application.ninja.selectedElements[0]; - drawUtils.addElement(this.target); } else { @@ -882,7 +880,6 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { new WebKitPoint(event.pageX, event.pageY)); this.isDrawing = false; - this.application.ninja.stage.showSelectionBounds = true; if(this._escape) { this._escape = false; return; -- cgit v1.2.3 From 71795a786342b3d84ef904dc448b4ce840a44810 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 13:37:04 -0700 Subject: IKNINJA-1924 - Hovering over panel resizers after collapsing and expanding panel causes error. Canvas sizes were not updated when using the splitter to toggle collapse/expansion of panels. This was fixed by the StageDrawingFixes pull request. We should also guard agains null value in stage's getElement routine. Signed-off-by: Nivesh Rajbhandari --- js/tools/ShapeTool.js | 34 ---------------------------------- 1 file changed, 34 deletions(-) (limited to 'js/tools') diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 26ed9c6f..ecc0dca3 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -70,7 +70,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { this.doDraw(event); } else { this.doSnap(event); - this._showFeedbackOnMouseMove(event); } this.drawLastSnap(); // Required cleanup for both Draw/Feedbacks @@ -159,39 +158,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { } }, - /** Show a border when mousing - * over existing canvas elements to signal to the user that - * the drawing operation will act on the targeted canvas. - **/ - _showFeedbackOnMouseMove: { - value: function (event) { - // TODO - This call is causing the canvas to redraw 3 times per mouse move - var targetedObject = this.application.ninja.stage.getElement(event, true); - - if (targetedObject) { - if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject)) - { - if (targetedObject !== this._targetedElement) { - if(this._targetedElement) - { - this._targetedElement.classList.remove("active-element-outline"); - } - this._targetedElement = targetedObject; - this._targetedElement.classList.add("active-element-outline"); - } - } - else if (this._targetedElement) { - this._targetedElement.classList.remove("active-element-outline"); - this._targetedElement = null; - } - } - else if (this._targetedElement) { - this._targetedElement.classList.remove("elem-red-outline"); - this._targetedElement = null; - } - } - }, - RenderShape: { value: function (w, h, planeMat, midPt) -- cgit v1.2.3 From e9d08c7af751d75af16371fcac06fd1af8a60fac Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 23 Jul 2012 14:37:51 -0700 Subject: Bugs fixed: 1915 - Data.JSON too large. Reduced mesh size and limited precision of fp numbers 1381 - Background transparency in preview. 1740 - File Save As caused WebGL to stop animating. Crossed RDGE IDs 1954 - Texture change from material popup broke screen rendering. Set correct context on property change. --- js/tools/modifier-tool-base.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/tools') diff --git a/js/tools/modifier-tool-base.js b/js/tools/modifier-tool-base.js index c772e36c..d12ba7d2 100755 --- a/js/tools/modifier-tool-base.js +++ b/js/tools/modifier-tool-base.js @@ -569,7 +569,11 @@ exports.ModifierToolBase = Montage.create(DrawingTool, { var alignArray = new Array(); snapManager.snapAlignToElementBounds( this._clickedObject, delta, alignArray ); if (alignArray.length > 0) + { + alignArray.push( hitRec ); + snapManager.sortHitRecords( alignArray ); hitRec = alignArray[0]; + } } } -- cgit v1.2.3 From 55a69aeb3c66b533d5a2d27d7548471c2c8b5dfc Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 24 Jul 2012 00:24:20 -0700 Subject: jshint cleanup on the tools directory Signed-off-by: Valerio Virgillito --- js/tools/EyedropperTool.js | 26 ++- js/tools/FillTool.js | 7 +- js/tools/InkBottleTool.js | 7 +- js/tools/PanTool.js | 22 ++- js/tools/PenTool.js | 28 ++-- js/tools/Rotate3DToolBase.js | 7 +- js/tools/SelectionTool.js | 103 ++++++------ js/tools/ShapeTool.js | 12 +- js/tools/TextTool.js | 6 +- js/tools/TranslateObject3DTool.js | 11 +- js/tools/ZoomTool.js | 330 +++++++++++++++----------------------- js/tools/drawing-tool-base.js | 7 +- js/tools/modifier-tool-base.js | 8 +- 13 files changed, 251 insertions(+), 323 deletions(-) (limited to 'js/tools') diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 3d0799e0..1d97d11b 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js @@ -95,22 +95,19 @@ exports.EyedropperTool = Montage.create(toolBase, { }, HandleLeftButtonUp: { - value : function (event) { - { - this._isMouseDown = false; + value: function(event) { + this._isMouseDown = false; - if(this._escape) - { - this._escape = false; - } + if(this._escape) { + this._escape = false; + } - this._updateColor(this._color, true); + this._updateColor(this._color, true); - this._color = null; + this._color = null; - this._elementUnderMouse = null; - this._deleteImageDataCanvas(); - } + this._elementUnderMouse = null; + this._deleteImageDataCanvas(); } }, @@ -237,8 +234,7 @@ exports.EyedropperTool = Montage.create(toolBase, { if(color.mode === "gradient") { - this.application.ninja.colorController.colorModel["gradient"] = - {value: color.color, wasSetByCode: true, type: eventType}; + this.application.ninja.colorController.colorModel.gradient = {value: color.color, wasSetByCode: true, type: eventType}; } else { @@ -253,7 +249,7 @@ exports.EyedropperTool = Montage.create(toolBase, { } else { - this.application.ninja.colorController.colorModel["rgb"] = color.color; + this.application.ninja.colorController.colorModel.rgb = color.color; } } diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js index 16a6f464..2c783cb6 100755 --- a/js/tools/FillTool.js +++ b/js/tools/FillTool.js @@ -77,13 +77,12 @@ exports.FillTool = Montage.create(ModifierToolBase, { }, HandleLeftButtonUp: { - value : function () { - //if(this._isDrawing) - { + value: function() { + //if(this._isDrawing) { this.application.ninja.stage.clearDrawingCanvas(); this._hasDraw = false; this._isDrawing = false; - } + //} } }, diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js index c4197e77..68e7d107 100755 --- a/js/tools/InkBottleTool.js +++ b/js/tools/InkBottleTool.js @@ -77,13 +77,12 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, { }, HandleLeftButtonUp: { - value : function () { - //if(this._isDrawing) - { + value: function() { + //if(this._isDrawing) { this.application.ninja.stage.clearDrawingCanvas(); this._hasDraw = false; this._isDrawing = false; - } + //} } }, diff --git a/js/tools/PanTool.js b/js/tools/PanTool.js index 374886e8..cab25726 100755 --- a/js/tools/PanTool.js +++ b/js/tools/PanTool.js @@ -95,12 +95,9 @@ exports.PanTool = Montage.create(toolBase, } }, - HandleLeftButtonUp: - { - value : function ( event ) - { - //if(this._isDrawing) - { + HandleLeftButtonUp: { + value: function(event) { + //if(this._isDrawing) { // do one final mouse move to update the scrollbars this.mouseUp( event ); @@ -108,7 +105,7 @@ exports.PanTool = Montage.create(toolBase, this._hasDraw = false; this._isDrawing = false; this.isDrawing = false; - } + //} } }, @@ -234,11 +231,10 @@ exports.PanTool = Montage.create(toolBase, }, - doMouseDown: - { - value: function( point ) - { + doMouseDown: { + value: function(point) { //var tmpPt, tmpPt2, tmpPt3, tmpPt4, tmpMat, tmpMat2; // DEBUG. (see use of these points below) + var cop; var hitRec = snapManager.snap( point.x, point.y, true ); if (hitRec) { @@ -260,7 +256,7 @@ exports.PanTool = Montage.create(toolBase, { var localPt = hitRec.calculateElementWorldPoint(); viewUtils.pushViewportObj( userContent ); - var cop = viewUtils.getCenterOfProjection(); + cop = viewUtils.getCenterOfProjection(); this._localPt = [cop[0] + localPt[0], cop[1] + localPt[1], localPt[2]]; viewUtils.popViewportObj(); } @@ -284,7 +280,7 @@ exports.PanTool = Montage.create(toolBase, // get a matrix from user content world space to the screen viewUtils.pushViewportObj( userContent ); - var cop = viewUtils.getCenterOfProjection(); + cop = viewUtils.getCenterOfProjection(); var pDist = viewUtils.getPerspectiveDistFromElement(userContent); var projMat = glmat4.scale(Matrix.I(4), [pDist,pDist,pDist], []); projMat[11] = -1; diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 4b4fd227..a44438ac 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -302,6 +302,7 @@ exports.PenTool = Montage.create(ShapeTool, { HandleLeftButtonDown: { value: function (event) { + var newAnchor; //ignore any right or middle clicks if (event.button !== 0) { //todo NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) @@ -427,7 +428,7 @@ exports.PenTool = Montage.create(ShapeTool, { } else { this._selectedSubpath.addAnchor(new AnchorPoint()); - var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); + newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); newAnchor.setPos(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2]); newAnchor.setPrevPos(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2]); newAnchor.setNextPos(stageWorldMousePos[0], stageWorldMousePos[1], stageWorldMousePos[2]); @@ -489,7 +490,7 @@ exports.PenTool = Montage.create(ShapeTool, { if (numAnchors>1 && !this._selectedSubpath.getIsClosed() && this._selectedSubpath.getSelectedAnchorIndex()===0 && prevSelectedAnchorIndex === numAnchors-1){ //insert an anchor temporarily that will get removed in the mouse up handler this._selectedSubpath.addAnchor(new AnchorPoint()); - var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); + newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); newAnchor.setPos(localMousePos[0], localMousePos[1], localMousePos[2]); newAnchor.setPrevPos(localMousePos[0], localMousePos[1], localMousePos[2]); newAnchor.setNextPos(localMousePos[0], localMousePos[1], localMousePos[2]); @@ -534,7 +535,7 @@ exports.PenTool = Montage.create(ShapeTool, { ) { if (!this._selectedSubpath.getIsClosed()) { //todo this test is probably unnecessary, but doing it to be safe this._selectedSubpath.addAnchor(new AnchorPoint()); - var newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); + newAnchor = this._selectedSubpath.getAnchor(this._selectedSubpath.getSelectedAnchorIndex()); newAnchor.setPos(localMousePos[0], localMousePos[1], localMousePos[2]); newAnchor.setPrevPos(localMousePos[0], localMousePos[1], localMousePos[2]); @@ -564,6 +565,7 @@ exports.PenTool = Montage.create(ShapeTool, { HandleMouseMove: { value: function (event) { + var cursor; //ignore any right or middle clicks if (event.button !== 0) { //NOTE: this will work on Webkit only...IE has different codes (left: 1, middle: 4, right: 2) @@ -678,7 +680,7 @@ exports.PenTool = Montage.create(ShapeTool, { { //the anchor was hit this._hoveredAnchorIndex = selAnchorAndParamAndCode[0]; var lastAnchorIndex = this._selectedSubpath.getNumAnchors()-1; - var cursor; + if (this._subtool===this.SUBTOOL_NONE){ cursor = "url('images/cursors/penCursors/Pen_anchorSelect.png') 5 1, default"; if (this._selectedSubpath.getIsClosed()===false){ @@ -697,7 +699,7 @@ exports.PenTool = Montage.create(ShapeTool, { } else if (selAnchorAndParamAndCode[2] & this._selectedSubpath.SEL_PATH) { //change the cursor only if we're not in pen-minus subtool if (this._subtool!==this.SUBTOOL_PENMINUS){ - var cursor = "url('images/cursors/penCursors/Pen_plus.png') 5 1, default"; + cursor = "url('images/cursors/penCursors/Pen_plus.png') 5 1, default"; this.application.ninja.stage.drawingCanvas.style.cursor = cursor; } } @@ -735,6 +737,8 @@ exports.PenTool = Montage.create(ShapeTool, { return; } + var world, subpath; + w = Math.round(w); h = Math.round(h); var left = Math.round(midPt[0] - 0.5 * w); @@ -743,16 +747,16 @@ exports.PenTool = Montage.create(ShapeTool, { if (!canvas) { this._doesSelectionChangeNeedHandling = false; //this will ignore the selection change event triggered by the new canvas var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); - var styles = document.application.njUtils.stylesFromDraw(newCanvas, parseInt(w), parseInt(h), {midPt: midPt, planeMat: planeMat}); + var styles = document.application.njUtils.stylesFromDraw(newCanvas, parseInt(w, 10), parseInt(h, 10), {midPt: midPt, planeMat: planeMat}); this.application.ninja.elementMediator.addElements(newCanvas, styles, false); // create all the GL stuff - var world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); + world = this.getGLWorld(newCanvas, this._useWebGL);//this.options.use3D);//this.CreateGLWorld(planeMat, midPt, newCanvas, this._useWebGL);//fillMaterial, strokeMaterial); //store a reference to this newly created canvas this._selectedSubpathCanvas = newCanvas; this._selectedSubpathPlaneMat = ElementMediator.getMatrix(newCanvas); - var subpath = this._selectedSubpath; //new GLSubpath(); + subpath = this._selectedSubpath; //new GLSubpath(); subpath.setWorld(world); subpath.setCanvas(newCanvas); @@ -791,7 +795,7 @@ exports.PenTool = Montage.create(ShapeTool, { } //if (!canvas) { else { - var world = null; + world = null; if (canvas.elementModel.shapeModel && canvas.elementModel.shapeModel.GLWorld) { world = canvas.elementModel.shapeModel.GLWorld; } else { @@ -815,7 +819,7 @@ exports.PenTool = Montage.create(ShapeTool, { } } - var subpath = this._selectedSubpath; + subpath = this._selectedSubpath; subpath.setDrawingTool(this); subpath.setWorld(world); @@ -1358,7 +1362,7 @@ exports.PenTool = Montage.create(ShapeTool, { ctx.lineWidth = 1; var defFill = "#FFFFFF"; var defStroke = "green"; - var selHandleFill = "#000000" + var selHandleFill = "#000000"; ctx.strokeStyle = defStroke; ctx.fillStyle = defFill; @@ -1608,7 +1612,7 @@ exports.PenTool = Montage.create(ShapeTool, { var world = ElementMediator.getShapeProperty(this._selectedSubpathCanvas, "GLWorld"); if (world === null){ throw("Pen tool handleSelectionChange did not work correctly"); - break; //something bad happened //TODO handle this better + //something bad happened //TODO handle this better } //TODO assuming that we want the first subpath in this world...fix this! diff --git a/js/tools/Rotate3DToolBase.js b/js/tools/Rotate3DToolBase.js index 545aedad..bd735eea 100755 --- a/js/tools/Rotate3DToolBase.js +++ b/js/tools/Rotate3DToolBase.js @@ -245,6 +245,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { value: function(data, event) { var mat, angle, + f, pt0 = data.pt0, pt1 = data.pt1; @@ -291,7 +292,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { angle = this._getAngleToRotate(pt1.x, pt1.y); if(event.shiftKey) { - var f = Math.floor(angle/(Math.PI/4)); + f = Math.floor(angle/(Math.PI/4)); angle = f*Math.PI/4; } this._delta = angle; @@ -324,7 +325,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { } if(event.shiftKey) { - var f = Math.floor(zAngle/(Math.PI/4)); + f = Math.floor(zAngle/(Math.PI/4)); zAngle = f*Math.PI/4; } mat = Matrix.RotationZ(zAngle); @@ -335,7 +336,7 @@ exports.Rotate3DToolBase = Montage.create(ModifierToolBase, { var xAngle = -this._mouseSpeed * (pt1.y - this.downPoint.y) * Math.PI / 180.0; if(event.shiftKey) { - var f = Math.floor(yAngle/(Math.PI/4)); + f = Math.floor(yAngle/(Math.PI/4)); yAngle = f*Math.PI/4; f = Math.floor(xAngle/(Math.PI/4)); xAngle = f*Math.PI/4; diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index a136113b..07ae8cf5 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js @@ -272,7 +272,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { HandleKeyPress: { value: function(event){ - var inc; + var inc, newLeft, leftArr, newTop, topArr; if (!(event.target instanceof HTMLInputElement)) { if(this.application.ninja.selectedElements.length !== 0) { @@ -280,36 +280,36 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { switch(event.keyCode) { case Keyboard.LEFT: - var newLeft = []; - var leftArr = this.application.ninja.selectedElements.map(function(item) { - newLeft.push( (parseInt(ElementsMediator.getProperty(item, "left")) - inc) + "px" ); + newLeft = []; + leftArr = this.application.ninja.selectedElements.map(function(item) { + newLeft.push( (parseInt(ElementsMediator.getProperty(item, "left"), 10) - inc) + "px" ); return ElementsMediator.getProperty(item, "left"); }); ElementsMediator.setProperty(this.application.ninja.selectedElements, "left", newLeft , "Change", "selectionTool", leftArr); break; case Keyboard.UP: - var newTop = []; - var topArr = this.application.ninja.selectedElements.map(function(item) { - newTop.push( (parseInt(ElementsMediator.getProperty(item, "top")) - inc) + "px" ); + newTop = []; + topArr = this.application.ninja.selectedElements.map(function(item) { + newTop.push( (parseInt(ElementsMediator.getProperty(item, "top"), 10) - inc) + "px" ); return ElementsMediator.getProperty(item, "top"); }); ElementsMediator.setProperty(this.application.ninja.selectedElements, "top", newTop , "Change", "selectionTool", topArr); break; case Keyboard.RIGHT: - var newLeft = []; - var leftArr = this.application.ninja.selectedElements.map(function(item) { - newLeft.push( (parseInt(ElementsMediator.getProperty(item, "left")) + inc) + "px" ); + newLeft = []; + leftArr = this.application.ninja.selectedElements.map(function(item) { + newLeft.push( (parseInt(ElementsMediator.getProperty(item, "left"), 10) + inc) + "px" ); return ElementsMediator.getProperty(item, "left"); }); ElementsMediator.setProperty(this.application.ninja.selectedElements, "left", newLeft , "Change", "selectionTool", leftArr); break; case Keyboard.DOWN: - var newTop = []; - var topArr = this.application.ninja.selectedElements.map(function(item) { - newTop.push( (parseInt(ElementsMediator.getProperty(item, "top")) + inc) + "px" ); + newTop = []; + topArr = this.application.ninja.selectedElements.map(function(item) { + newTop.push( (parseInt(ElementsMediator.getProperty(item, "top"), 10) + inc) + "px" ); return ElementsMediator.getProperty(item, "top"); }); @@ -317,7 +317,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { break; default: return false; - break; } @@ -339,17 +338,17 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { var modObject = [], mod3dObject = [], self = this; this.application.ninja.selectedElements.forEach(function(element) { - + var prevW, prevH, w, h; if(addToUndo) { if(!self._use3DMode) { var prevX = element.elementModel.getProperty("x"); var prevY = element.elementModel.getProperty("y"); - var prevW = element.elementModel.getProperty("w"); - var prevH = element.elementModel.getProperty("h"); + prevW = element.elementModel.getProperty("w"); + prevH = element.elementModel.getProperty("h"); var x = ElementsMediator.getProperty(element, "left"); var y = ElementsMediator.getProperty(element, "top"); - var w = ElementsMediator.getProperty(element, "width"); - var h = ElementsMediator.getProperty(element, "height"); + w = ElementsMediator.getProperty(element, "width"); + h = ElementsMediator.getProperty(element, "height"); // if we have a delta, that means the transform handles were used and // we should update the width and height too. Otherwise, just update left and top. @@ -362,10 +361,10 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { } else { // Not using the 3d mode var previousMat = element.elementModel.getProperty("mat").slice(0); - var prevW = element.elementModel.getProperty("w"); - var prevH = element.elementModel.getProperty("h"); - var w = ElementsMediator.getProperty(element, "width"); - var h = ElementsMediator.getProperty(element, "height"); + prevW = element.elementModel.getProperty("w"); + prevH = element.elementModel.getProperty("h"); + w = ElementsMediator.getProperty(element, "width"); + h = ElementsMediator.getProperty(element, "height"); var previousStyleStr = {dist:element.elementModel.getProperty("dist"), mat:MathUtils.scientificToDecimal(previousMat, 5)}; var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(element), mat:MathUtils.scientificToDecimal(viewUtils.getMatrixFromElement(element), 5)}; @@ -421,8 +420,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { viewUtils.setMatrixForElement( element, curMat, true); element.elementModel.setProperty("mat", curMat); } else { - var x = (parseInt(ElementsMediator.getProperty(element, "left")) + transMat[12]) + "px"; - var y = (parseInt(ElementsMediator.getProperty(element, "top")) + transMat[13]) + "px"; + var x = (parseInt(ElementsMediator.getProperty(element, "left"), 10) + transMat[12]) + "px"; + var y = (parseInt(ElementsMediator.getProperty(element, "top"), 10) + transMat[13]) + "px"; targets.push({element:element, properties:{left:x , top:y}}); } @@ -452,21 +451,21 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize North-West this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - width = parseInt(element.elementModel.getProperty("w")) - delta; + width = parseInt(element.elementModel.getProperty("w"), 10) - delta; if(width <= 0) { width = 1; - left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1; + left = parseInt(element.elementModel.getProperty("x"), 10) + parseInt(element.elementModel.getProperty("w"), 10) - 1; } else { - left = parseInt(element.elementModel.getProperty("x")) + delta; + left = parseInt(element.elementModel.getProperty("x"), 10) + delta; } delta = ~~(data.pt1[1] - data.pt0[1]); - height = parseInt(element.elementModel.getProperty("h")) - delta; + height = parseInt(element.elementModel.getProperty("h"), 10) - delta; if(height <= 0) { height = 1; - top = parseInt(element.elementModel.getProperty("y")) + parseInt(element.elementModel.getProperty("h")) - 1; + top = parseInt(element.elementModel.getProperty("y"), 10) + parseInt(element.elementModel.getProperty("h"), 10) - 1; } else { - top = parseInt(element.elementModel.getProperty("y")) + delta; + top = parseInt(element.elementModel.getProperty("y"), 10) + delta; } modObject.push({element:element, properties:{width: width + "px", height: height + "px", left: left + "px", top: top + "px"}}); }); @@ -475,12 +474,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize West this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - width = parseInt(element.elementModel.getProperty("w")) - delta; + width = parseInt(element.elementModel.getProperty("w"), 10) - delta; if(width <= 0) { width = 1; - left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1; + left = parseInt(element.elementModel.getProperty("x"), 10) + parseInt(element.elementModel.getProperty("w"), 10) - 1; } else { - left = parseInt(element.elementModel.getProperty("x")) + delta; + left = parseInt(element.elementModel.getProperty("x"), 10) + delta; } modObject.push({element:element, properties:{left: left + "px", width: width + "px"}}); }); @@ -489,15 +488,15 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize South-West this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - width = parseInt(element.elementModel.getProperty("w")) - delta; + width = parseInt(element.elementModel.getProperty("w"), 10) - delta; if(width <= 0) { width = 1; - left = parseInt(element.elementModel.getProperty("x")) + parseInt(element.elementModel.getProperty("w")) - 1; + left = parseInt(element.elementModel.getProperty("x"), 10) + parseInt(element.elementModel.getProperty("w"), 10) - 1; } else { - left = parseInt(element.elementModel.getProperty("x")) + delta; + left = parseInt(element.elementModel.getProperty("x"), 10) + delta; } delta = ~~(data.pt1[1] - data.pt0[1]); - height = parseInt(element.elementModel.getProperty("h")) + delta; + height = parseInt(element.elementModel.getProperty("h"), 10) + delta; if(height <= 0) { height = 1; } @@ -508,7 +507,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize South this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[1] - data.pt0[1]); - height = parseInt(element.elementModel.getProperty("h")) + delta; + height = parseInt(element.elementModel.getProperty("h"), 10) + delta; if(height <= 0) { height = 1; } @@ -519,12 +518,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize South-East this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - width = parseInt(element.elementModel.getProperty("w")) + delta; + width = parseInt(element.elementModel.getProperty("w"), 10) + delta; if(width <= 0) { width = 1; } delta = ~~(data.pt1[1] - data.pt0[1]); - height = parseInt(element.elementModel.getProperty("h")) + delta; + height = parseInt(element.elementModel.getProperty("h"), 10) + delta; if(height <= 0) { height = 1; } @@ -535,7 +534,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize East this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - width = parseInt(element.elementModel.getProperty("w")) + delta; + width = parseInt(element.elementModel.getProperty("w"), 10) + delta; if(width <= 0) { width = 1; } @@ -546,17 +545,17 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize North-East this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[0] - data.pt0[0]); - width = parseInt(element.elementModel.getProperty("w")) + delta; + width = parseInt(element.elementModel.getProperty("w"), 10) + delta; if(width <= 0) { width = 1; } delta = ~~(data.pt1[1] - data.pt0[1]); - height = parseInt(element.elementModel.getProperty("h")) - delta; + height = parseInt(element.elementModel.getProperty("h"), 10) - delta; if(height <= 0) { height = 1; - top = parseInt(element.elementModel.getProperty("y")) + parseInt(element.elementModel.getProperty("h")) - 1; + top = parseInt(element.elementModel.getProperty("y"), 10) + parseInt(element.elementModel.getProperty("h"), 10) - 1; } else { - top = parseInt(element.elementModel.getProperty("y")) + delta; + top = parseInt(element.elementModel.getProperty("y"), 10) + delta; } modObject.push({element:element, properties:{width: width + "px", height: height + "px", top: top + "px"}}); }); @@ -565,12 +564,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { // Resize North this.application.ninja.selectedElements.forEach(function(element) { delta = ~~(data.pt1[1] - data.pt0[1]); - height = parseInt(element.elementModel.getProperty("h")) - delta; + height = parseInt(element.elementModel.getProperty("h"), 10) - delta; if(height <= 0) { height = 1; - top = parseInt(element.elementModel.getProperty("y")) + parseInt(element.elementModel.getProperty("h")) - 1; + top = parseInt(element.elementModel.getProperty("y"), 10) + parseInt(element.elementModel.getProperty("h"), 10) - 1; } else { - top = parseInt(element.elementModel.getProperty("y")) + delta; + top = parseInt(element.elementModel.getProperty("y"), 10) + delta; } modObject.push({element:element, properties:{height: height + "px", top: top + "px"}}); }); @@ -657,10 +656,12 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { y0 = bounds[0][1], y1 = bounds[1][1]; var dx = x1 - x0, dy = y1 - y0; var u = 0, v = 0; - if (MathUtils.fpSign(dx) != 0) + if (MathUtils.fpSign(dx) !== 0) { u = (scrPt[0] - x0) / dx; - if (MathUtils.fpSign(dy) != 0) + } + if (MathUtils.fpSign(dy) !== 0) { v = (scrPt[1] - y0) / dy; + } paramPt[0] = u; paramPt[1] = v; diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index ecc0dca3..e1ca31e6 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -167,13 +167,13 @@ exports.ShapeTool = Montage.create(DrawingTool, { }, getGLWorld: { - value: function (canvas, use3D) - { - var world = this.application.ninja.elementMediator.getShapeProperty(canvas, "GLWorld"); - if(!world) - { + value: function (canvas, use3D) { + var world; + + world = this.application.ninja.elementMediator.getShapeProperty(canvas, "GLWorld"); + if(!world) { // create all the GL stuff - var world = new World(canvas, use3D); + world = new World(canvas, use3D); this.application.ninja.elementMediator.setShapeProperty(canvas, "GLWorld", world); } diff --git a/js/tools/TextTool.js b/js/tools/TextTool.js index b98da3e6..d04254b0 100755 --- a/js/tools/TextTool.js +++ b/js/tools/TextTool.js @@ -30,8 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. */ var Montage = require("montage/core/core").Montage, - DrawingTool = require("js/tools/drawing-tool").DrawingTool, - ElementsMediator = require("js/mediators/element-mediator").ElementMediator; + DrawingTool = require("js/tools/drawing-tool").DrawingTool; exports.TextTool = Montage.create(DrawingTool, { drawingFeedback: { @@ -175,8 +174,7 @@ exports.TextTool = Montage.create(DrawingTool, { self.applyElementStyles(self.selectedElement, self.application.ninja.stage.textTool.element, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); this.selectAll(); this.didDraw = function() {}; - } - + }; } }, diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 284ba417..a3ece1f9 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js @@ -32,7 +32,6 @@ POSSIBILITY OF SUCH DAMAGE. var Montage = require("montage/core/core").Montage, Translate3DToolBase = require("js/tools/Translate3DToolBase").Translate3DToolBase, drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, - vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager; @@ -48,8 +47,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { }, initializeSnapping : { - value : function(event) - { + value : function(event) { // console.log( "initializeSnapping" ); this._mouseDownHitRec = null; @@ -79,8 +77,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { else { this._delta = null; - //if(this._handleMode === 2) - { + //if(this._handleMode === 2) { this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode); //console.log( "dragPlane: " + this._dragPlane ); snapManager.setupDragPlaneFromPlane(this._dragPlane); @@ -88,7 +85,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { snapManager.enableElementSnap ( false ); snapManager.enableGridSnap ( false ); - } + //} } if(this.application.ninja.selectedElements.length) { @@ -161,7 +158,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { // only do quadrant snapping if the 4 corners of the element are in the drag plane var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); - this._shouldUseQuadPt = (sign == 0); + this._shouldUseQuadPt = (sign === 0); var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); this._mouseDownHitRec = wpHitRec; diff --git a/js/tools/ZoomTool.js b/js/tools/ZoomTool.js index a285db0f..0bcba2a3 100755 --- a/js/tools/ZoomTool.js +++ b/js/tools/ZoomTool.js @@ -34,7 +34,6 @@ var Montage = require("montage/core/core").Montage, snapManager = require("js/helper-classes/3D/snap-manager").SnapManager, viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils, vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils, - drawUtils = require("js/helper-classes/3D/draw-utils").DrawUtils, DrawingTool = require("js/tools/drawing-tool").DrawingTool; exports.ZoomTool = Montage.create(DrawingTool, { @@ -53,13 +52,11 @@ exports.ZoomTool = Montage.create(DrawingTool, { HandleLeftButtonDown: { - value : function (event) { - + value: function(event) { NJevent("enableStageMove"); - this._isDrawing=true; + this._isDrawing = true; - var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, - new WebKitPoint(event.pageX, event.pageY)); + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this.downPoint.x = point.x; this.downPoint.y = point.y; } @@ -67,40 +64,36 @@ exports.ZoomTool = Montage.create(DrawingTool, { HandleAltKeyDown: { value: function(event) { - this.setCursor(); - this._altKeyDown=true; - + this._altKeyDown = true; } }, HandleAltKeyUp: { value: function(event) { - this.setCursor(); - this._altKeyDown=false; + this._altKeyDown = false; } }, HandleEscape: { value: function(event) { this.application.ninja.stage.clearDrawingCanvas(); - this._escPressed=false; + this._escPressed = false; } }, Configure: { value: function(wasSelected) { - - if(this.options.selectedElement==="zoomOutTool"){ + if(this.options.selectedElement === "zoomOutTool") { var cursor = "url('images/cursors/zoom_minus.png'), default"; this.application.ninja.stage.drawingCanvas.style.cursor = cursor; } - if(wasSelected) { + + if(wasSelected) { this.AddCustomFeedback(); - this.eventManager.addEventListener( "toolDoubleClick", this, false); + this.eventManager.addEventListener("toolDoubleClick", this, false); this.application.ninja.stage.drawingCanvas.addEventListener("mousewheel", this, false); - } else { this.RemoveCustomFeedback(); this.eventManager.removeEventListener( "toolDoubleClick", this, false); @@ -110,87 +103,76 @@ exports.ZoomTool = Montage.create(DrawingTool, { }, AddCustomFeedback: { - value: function (event) { - + value: function(event) { this.application.ninja.stage.canvas.addEventListener("mousewheel", this, false); - } }, - handleScrollValue:{ - value:function(){ - + handleScrollValue: { + value: function() { this._mode = "mouseWheelZoom"; - this._zoomFactor= this.application.ninja.documentBar.zoomFactor/100; + this._zoomFactor = this.application.ninja.documentBar.zoomFactor/100; if(this._delta > 0){ this._zoomFactor *= 1.2; - } - else{ + } else{ this._zoomFactor /= 1.2; } + this._zoomFactor = this.checkZoomLimit(this._zoomFactor); this._setZoom(this._mode,this._zoomFactor); - this._mode="modeReset"; - + this._mode = "modeReset"; } }, - handleMousewheel :{ - value:function(event){ - - var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, - new WebKitPoint(event.pageX, event.pageY)); + handleMousewheel: { + value: function(event) { + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); this._layerX = point.x; this._layerY = point.y; - this._delta = 0; + this._delta = 0; - if (event.wheelDelta) { - this._delta = event.wheelDelta/120; - } + if(event.wheelDelta) { + this._delta = event.wheelDelta/120; + } - if (this._delta){ - this.handleScrollValue(this._delta); - } + if(this._delta) { + this.handleScrollValue(this._delta); + } - if (event.preventDefault) - event.preventDefault(); - event.returnValue = false; + if(event.preventDefault) { + event.preventDefault(); + } + event.returnValue = false; } }, - HandleMouseMove: - { - value : function (event) - { - var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, - new WebKitPoint(event.pageX, event.pageY)); + HandleMouseMove: { + value: function(event) { + var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); // check for some reasonable amount of mouse movement var dx = Math.abs(point.x - this.downPoint.x), dy = Math.abs(point.y - this.downPoint.y); - if ((dx >= 10) || (dy >= 10)) - { + if ((dx >= 10) || (dy >= 10)) { // Drawing the Marquee - if(this.options.selectedElement==="zoomInTool") - { - if(this._altKeyDown) + if(this.options.selectedElement === "zoomInTool") { + if(this._altKeyDown) { this._hasDraw=false; - else + } else { this._hasDraw = true; - } - else - { - if(this._altKeyDown) + } + } else { + if(this._altKeyDown) { this._hasDraw=true; - else + } else { this._hasDraw=false; + } } - if(this._hasDraw) - { + if(this._hasDraw) { this.doDraw(event); this._x = this.downPoint.x; this._y = this.downPoint.y; @@ -199,50 +181,36 @@ exports.ZoomTool = Montage.create(DrawingTool, { } }, - handleZoomChange: - { - value: function(event) - { - } - }, - - _setZoom:{ - value:function(mode,zoomFactor) - { + _setZoom: { + value: function(mode,zoomFactor) { var userContent = this.application.ninja.currentDocument.model.documentRoot; this._oldValue = this.application.ninja.documentBar.zoomFactor; - var globalPt; - if(this._mode==="mouseClickZoom") - { - if(this.options.selectedElement==="zoomInTool") - { - if(this._altKeyDown) + var globalPt, localPt, w, h; + if(this._mode === "mouseClickZoom") { + if(this.options.selectedElement === "zoomInTool") { + if(this._altKeyDown) { this._factor = this._oldValue/(zoomFactor*100); - else + } else { this._factor = (zoomFactor*100)/this._oldValue; - } - else - { - if(this._altKeyDown) + } + } else { + if(this._altKeyDown) { this._factor = (zoomFactor*100)/this._oldValue; - else + } else { this._factor = this._oldValue/(zoomFactor*100); + } } var hitRec = snapManager.snap( this._layerX, this._layerY, true ); - if (hitRec) - { + if(hitRec) { var elt = hitRec.getElement(); - if (elt) - { -// console.log( "hit: " + hitRec.getElement().id ); + if(elt) { + // console.log( "hit: " + hitRec.getElement().id ); var localToGlobalMat = viewUtils.getLocalToGlobalMatrix( elt ); - var localPt; - if (elt != userContent) + if (elt != userContent) { localPt = hitRec.calculateElementPreTransformScreenPoint(); - else - { + } else { localPt = hitRec.calculateElementWorldPoint(); viewUtils.pushViewportObj( userContent ); var cop = viewUtils.getCenterOfProjection(); @@ -252,68 +220,57 @@ exports.ZoomTool = Montage.create(DrawingTool, { } globalPt = MathUtils.transformAndDivideHomogeneousPoint( localPt, localToGlobalMat ); - } - else + } else { globalPt = [this._layerX, this._layerY, 0]; - } - else + } + } else { globalPt = [this._layerX, this._layerY, 0]; - } - else if (this._mode==="marqueeZoom") - { + } + } else if(this._mode === "marqueeZoom") { this._factor = (zoomFactor*100)/this._oldValue; var p0 = [this._x, this._y, 0]; var p1 = [this._layerX, this._layerY, 0]; globalPt = vecUtils.vecAdd(3, p0, p1); vecUtils.vecScale(3, globalPt, 0.5); - } - else if (this._mode === "doubleClickReset") - { - if (userContent) - { - var w = userContent.offsetWidth, - h = userContent.offsetHeight; + } else if (this._mode === "doubleClickReset") { + if (userContent) { + w = userContent.offsetWidth; + h = userContent.offsetHeight; if(userContent.width) w = userContent.width; if(userContent.height) h = userContent.height; globalPt = [ w/2, h/2, 0]; - } - else + } else { globalPt = [0,0,0]; + } zoomFactor = 1; - } - else if (this._mode === "mouseWheelZoom") - { - var w = this.application.ninja.stage._canvas.width, - h = this.application.ninja.stage._canvas.height; + } else if (this._mode === "mouseWheelZoom") { + w = this.application.ninja.stage._canvas.width; + h = this.application.ninja.stage._canvas.height; globalPt = [w/2, h/2, 0]; - } - else - { + } else { console.log( "unhandled zoom mode: " + this._mode ); return; } // apply the scale to the matrices - var localPt = viewUtils.globalToLocal( globalPt, userContent ); +