aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ShapeTool.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-06-06 13:59:37 -0700
committerNivesh Rajbhandari2012-06-06 13:59:37 -0700
commite4e3ee77aa01f9b6e7592306ebfa9f123a60c624 (patch)
treea96013eff3ea3a977baa5daf999777a814afa65d /js/tools/ShapeTool.js
parent18e212dca48066d1ddaca96875a3f40adcc859b6 (diff)
downloadninja-e4e3ee77aa01f9b6e7592306ebfa9f123a60c624.tar.gz
Do not create any tags or shapes with width or height of 0.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-xjs/tools/ShapeTool.js46
1 files changed, 25 insertions, 21 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index 367ab78d..8886285d 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -55,24 +55,30 @@ exports.ShapeTool = Montage.create(DrawingTool, {
55 55
56 HandleLeftButtonUp: { 56 HandleLeftButtonUp: {
57 value: function (event) { 57 value: function (event) {
58 var canvas, drawData = this.getDrawingData(); 58 var canvas, w, h;
59 59 this.drawData = this.getDrawingData();
60 if(drawData) { 60
61 if(!this._useExistingCanvas()) { 61 if(this.drawData) {
62 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); 62 w = Math.floor(this.drawData.width);
63 document.application.njUtils.createModelWithShape(canvas); 63 h = Math.floor(this.drawData.height);
64 64
65 var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData); 65 if( (w > 0) && (h > 0) ) {
66 this.application.ninja.elementMediator.addElements(canvas, styles); 66 if(!this._useExistingCanvas()) {
67 } else { 67 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
68 canvas = this._targetedElement; 68 document.application.njUtils.createModelWithShape(canvas);
69 if (!canvas.getAttribute( "data-RDGE-id" )) 69
70 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() ); 70 var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, this.drawData);
71 canvas.elementModel.controller = ShapesController; 71 this.application.ninja.elementMediator.addElements(canvas, styles);
72 if(!canvas.elementModel.shapeModel) { 72 } else {
73 canvas.elementModel.shapeModel = Montage.create(ShapeModel); 73 canvas = this._targetedElement;
74 if (!canvas.getAttribute( "data-RDGE-id" ))
75 canvas.setAttribute( "data-RDGE-id", NJUtils.generateRandom() );
76 canvas.elementModel.controller = ShapesController;
77 if(!canvas.elementModel.shapeModel) {
78 canvas.elementModel.shapeModel = Montage.create(ShapeModel);
79 }
80 this.RenderShape(w, h, this.drawData.planeMat, this.drawData.midPt, canvas);
74 } 81 }
75 this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, canvas);
76 } 82 }
77 } 83 }
78 84
@@ -87,10 +93,8 @@ exports.ShapeTool = Montage.create(DrawingTool, {
87 93
88 onAddElements: { 94 onAddElements: {
89 value: function(el) { 95 value: function(el) {
90 var drawData; 96 if(this.drawData) {
91 97 this.RenderShape(this.drawData.width, this.drawData.height, this.drawData.planeMat, this.drawData.midPt, el);
92 if(drawData = this.getDrawingData()) {
93 this.RenderShape(drawData.width, drawData.height, drawData.planeMat, drawData.midPt, el);
94 } 98 }
95 } 99 }
96 }, 100 },