From 2078bfa96afaef40acb4edac99848ba55e808ef1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 3 May 2012 15:15:21 -0700 Subject: Refactor creating elements. Removed makeNJElement and separated the model creation Signed-off-by: Valerio Virgillito --- js/tools/ShapeTool.js | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) (limited to 'js/tools/ShapeTool.js') 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, { } }, - HandleLeftButtonUp: - { - value: function (event) - { - var drawData; - - drawData = this.getDrawingData(); + HandleLeftButtonUp: { + value: function (event) { + var canvas, drawData = this.getDrawingData(); if(drawData) { - var canvas; if(!this._useExistingCanvas()) { - canvas = NJUtils.makeNJElement("canvas", "Canvas", "shape", {"data-RDGE-id": NJUtils.generateRandom()}, true); - var elementModel = TagTool.makeElement(~~drawData.width, ~~drawData.height, - drawData.planeMat, drawData.midPt, canvas, true); + canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); + document.application.njUtils.createModelWithShape(canvas); - canvas.elementModel.isShape = true; - this.application.ninja.elementMediator.addElements(canvas, elementModel.data); + var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData); + this.application.ninja.elementMediator.addElements(canvas, styles); } else { canvas = this._targetedElement; if (!canvas.getAttribute( "data-RDGE-id" )) @@ -193,26 +187,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { } }, - createCanvas: { - value: function (left, top, w, h) - { - //var tmpDiv = document.createElement("canvas"); - var tmpDiv = NJUtils.makeNJElement("canvas", "Canvas", "block"); - var rules = { - 'position': 'absolute', - 'top' : top + 'px', - 'left' : left + 'px', - '-webkit-transform-style' : 'preserve-3d', - '-webkit-transform' : 'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)' - }; - - tmpDiv.width = w; - tmpDiv.height = h; - - return {el: tmpDiv, rules: rules}; - } - }, - // We can draw on an existing canvas unless it has only a single shape object _useExistingCanvas: { value: function() -- cgit v1.2.3