aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ShapeTool.js
diff options
context:
space:
mode:
authorhwc4872012-05-01 11:03:56 -0700
committerhwc4872012-05-01 11:03:56 -0700
commitf6983a69649b1c274ce6fe2d278a325994d092b6 (patch)
treea360297930c35f3097af16e9f6714ec501bd5894 /js/tools/ShapeTool.js
parent80715f4f0c45d29926184fa02e0a01b4e7642a79 (diff)
parentfb47c04b0a4d65f53d975311754aa0dd8a8a3f69 (diff)
downloadninja-f6983a69649b1c274ce6fe2d278a325994d092b6.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into Textures
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-xjs/tools/ShapeTool.js38
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