diff options
author | Valerio Virgillito | 2012-05-03 10:58:03 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-05-03 10:58:03 -0700 |
commit | be1806505f4af86c3b5c15454e67cb8cec696554 (patch) | |
tree | 137be320b75d29c295b332d381bd1851241887a6 /js/tools/ShapeTool.js | |
parent | 30bf02869c93072cdb3a3a8b50cf943917f3b026 (diff) | |
parent | 691beb1c39fc0baa683f1fc56cbc519fe58f306d (diff) | |
download | ninja-be1806505f4af86c3b5c15454e67cb8cec696554.tar.gz |
Merge branch 'refs/heads/master' into data-id
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-x | js/tools/ShapeTool.js | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 21a5a025..d2337000 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) { |
@@ -103,6 +106,9 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
103 | if(wasSelected) { | 106 | if(wasSelected) { |
104 | this.AddCustomFeedback(); | 107 | this.AddCustomFeedback(); |
105 | this.application.ninja.elementMediator.addDelegate = this; | 108 | this.application.ninja.elementMediator.addDelegate = this; |
109 | if(this.application.ninja.currentSelectedContainer.nodeName === "CANVAS") { | ||
110 | this._targetedElement = this.application.ninja.currentSelectedContainer; | ||
111 | } | ||
106 | } else { | 112 | } else { |
107 | this.RemoveCustomFeedback(); | 113 | this.RemoveCustomFeedback(); |
108 | this.application.ninja.elementMediator.addDelegate = null; | 114 | this.application.ninja.elementMediator.addDelegate = null; |
@@ -211,7 +217,20 @@ exports.ShapeTool = Montage.create(DrawingTool, { | |||
211 | _useExistingCanvas: { | 217 | _useExistingCanvas: { |
212 | value: function() | 218 | value: function() |
213 | { | 219 | { |
214 | return (this._targetedElement && !ShapesController.isElementAShape(this._targetedElement)); | 220 | var target; |
221 | if (this._targetedElement && (this._targetedElement.nodeName === "CANVAS") && !ShapesController.isElementAShape(this._targetedElement)) | ||
222 | target = this._targetedElement; | ||
223 | else | ||
224 | { | ||
225 | var container = this.application.ninja.currentSelectedContainer; | ||
226 | if (container && (container.nodeName === "CANVAS")) | ||
227 | { | ||
228 | target = container; | ||
229 | this._targetedElement = target; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | return target; | ||
215 | } | 234 | } |
216 | } | 235 | } |
217 | 236 | ||