diff options
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-x | js/tools/ShapeTool.js | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 21a5a025..8f45891d 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js | |||
@@ -54,9 +54,9 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
54 | }, | 54 | }, |
55 | 55 | ||
56 | HandleLeftButtonUp: | 56 | HandleLeftButtonUp: |
57 | { | 57 | { |
58 | value: function (event) | 58 | value: function (event) |
59 | { | 59 | { |
60 | var drawData; | 60 | var drawData; |
61 | 61 | ||
62 | drawData = this.getDrawingData(); | 62 | drawData = this.getDrawingData(); |
@@ -69,24 +69,27 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
69 | drawData.planeMat, drawData.midPt, canvas, true); | 69 | drawData.planeMat, drawData.midPt, canvas, true); |
70 | 70 | ||
71 | canvas.elementModel.isShape = true; | 71 | canvas.elementModel.isShape = true; |
72 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); | 72 | this.application.ninja.elementMediator.addElements(canvas, elementModel.data); |
73 | } else { | 73 | } else { |
74 | canvas = this._targetedElement; | 74 | canvas = this._targetedElement; |
75 | if (!canvas.getAttribute( "data-RDGE-id" )) | ||
76 | canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); | ||
75 | canvas.elementModel.controller = ShapesController; | 77 | canvas.elementModel.controller = ShapesController; |
76 | if(!canvas.elementModel.shapeModel) { | 78 | if(!canvas.elementModel.shapeModel) { |
77 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); | 79 | canvas.elementModel.shapeModel = Montage.create(ShapeModel); |
78 | } | 80 | } |
81 | this.application.ninja.elementMediator.addElements(canvas, canvas.elementModel.data); | ||
79 | } | 82 | } |
80 | } | 83 | } |
81 | 84 | ||
82 | this.endDraw(event); | 85 | this.endDraw(event); |
83 | 86 | ||
84 | this._isDrawing = false; | 87 | this._isDrawing = false; |
85 | this._hasDraw=false; | 88 | this._hasDraw=false; |
86 | 89 | ||
87 | this.DrawHandles(); | 90 | this.DrawHandles(); |
88 | } | 91 | } |
89 | }, | 92 | }, |
90 | 93 | ||
91 | onAddElements: { | 94 | onAddElements: { |
92 | value: function(el) { | 95 | value: function(el) { |
@@ -211,7 +214,20 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
211 | _useExistingCanvas: { | 214 | _useExistingCanvas: { |
212 | value: function() | 215 | value: function() |
213 | { | 216 | { |
214 | return (this._targetedElement && !ShapesController.isElementAShape(this._targetedElement)); | 217 | var target; |
218 | if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement)) | ||
219 | target = this._targetedElement; | ||
220 | else | ||
221 | { | ||
222 | var container = this.application.ninja.currentSelectedContainer; | ||
223 | if (container && (container.nodeName === "CANVAS")) | ||
224 | { | ||
225 | target = container; | ||
226 | this._targetedElement = target; | ||
227 | } | ||
228 | } | ||
229 | |||
230 | return target; | ||
215 | } | 231 | } |
216 | } | 232 | } |
217 | 233 | ||