aboutsummaryrefslogtreecommitdiff
path: root/js/tools/ShapeTool.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-04 15:31:40 -0700
committerValerio Virgillito2012-05-04 15:31:40 -0700
commit3ebed34665fa73b0ce613b400f3029ebf4476439 (patch)
tree09a3c592035030bda7bb62d1f908ce263377d74c /js/tools/ShapeTool.js
parent8dcbac5d4c30e9dfbc543a5f997939111e9c9f89 (diff)
parent526e423e4a2734c2b139af23911e912452a4443f (diff)
downloadninja-3ebed34665fa73b0ce613b400f3029ebf4476439.tar.gz
Merge branch 'refs/heads/master' into dom-architecture
Diffstat (limited to 'js/tools/ShapeTool.js')
-rwxr-xr-xjs/tools/ShapeTool.js40
1 files changed, 7 insertions, 33 deletions
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index d2337000..0562dbc2 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -53,23 +53,17 @@ exports.ShapeTool = Montage.create(DrawingTool, {
53 } 53 }
54 }, 54 },
55 55
56 HandleLeftButtonUp: 56 HandleLeftButtonUp: {
57 { 57 value: function (event) {
58 value: function (event) 58 var canvas, drawData = this.getDrawingData();
59 {
60 var drawData;
61
62 drawData = this.getDrawingData();
63 59
64 if(drawData) { 60 if(drawData) {
65 var canvas;
66 if(!this._useExistingCanvas()) { 61 if(!this._useExistingCanvas()) {
67 canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); 62 canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument);
68 var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, 63 document.application.njUtils.createModelWithShape(canvas);
69 drawData.planeMat, drawData.midPt, canvas, true);
70 64
71 canvas.elementModel.isShape = true; 65 var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData);
72 this.application.ninja.elementMediator.addElements(canvas, elementModel.data); 66 this.application.ninja.elementMediator.addElements(canvas, styles);
73 } else { 67 } else {
74 canvas = this._targetedElement; 68 canvas = this._targetedElement;
75 if (!canvas.getAttribute( "data-RDGE-id" )) 69 if (!canvas.getAttribute( "data-RDGE-id" ))
@@ -193,26 +187,6 @@ exports.ShapeTool = Montage.create(DrawingTool, {
193 } 187 }
194 }, 188 },
195 189
196 createCanvas: {
197 value: function (left, top, w, h)
198 {
199 //var tmpDiv = document.createElement("canvas");
200 var tmpDiv = NJUtils.makeNJElement("canvas", "Canvas", "block");
201 var rules = {
202 'position': 'absolute',
203 'top' : top + 'px',
204 'left' : left + 'px',
205 '-webkit-transform-style' : 'preserve-3d',
206 '-webkit-transform' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
207 };
208
209 tmpDiv.width = w;
210 tmpDiv.height = h;
211
212 return {el: tmpDiv, rules: rules};
213 }
214 },
215
216 // We can draw on an existing canvas unless it has only a single shape object 190 // We can draw on an existing canvas unless it has only a single shape object
217 _useExistingCanvas: { 191 _useExistingCanvas: {
218 value: function() 192 value: function()