# HG changeset patch # User hertzhaft # Date 1480544469 -3600 # Node ID 14a6d8a8a3075ce4a61f6df51257eb9a59a1a0bd # Parent 02446ff6948b05c9a3ad7ed03246a1cc81122381 vector plugin: make a shape editable diff -r 02446ff6948b -r 14a6d8a8a307 webapp/src/main/webapp/jquery/jquery.digilib.vector.js --- a/webapp/src/main/webapp/jquery/jquery.digilib.vector.js Sun Nov 13 18:52:47 2016 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.vector.js Wed Nov 30 23:21:09 2016 +0100 @@ -217,8 +217,9 @@ svgElement: svgElement, svgAttr: svgAttr, createScreenCoords: createScreenCoords, - editShapeBegin: addEditHandles, - editShapeEnd: removeEditHandles, + startEditShape: startEditShape, + undoEditShape: undoEditShape, + finishEditShape: finishEditShape, redrawShape: redrawShape }); }; @@ -602,6 +603,40 @@ }; /** + * make shape editable, add handles and events + * + * @param data + * @param shape + */ + var startEditShape = function (data, shape) { + shape.properties.editable = true; + shape.savecoords = shape.geometry.coordinates.slice(0); // clone coords + redrawShape(data, shape); + }; + + /** + * end editing shape + * + * @param data + * @param shape + */ + var finishEditShape = function (data, shape) { + shape.properties.editable = false; + redrawShape(data, shape); + }; + + /** + * restore edited shape to previous state + * + * @param data + * @param shape + */ + var undoEditShape = function (data, shape) { + shape.geometry.coordinates = shape.savecoords; + finishEditShape(data, shape); + }; + + /** * calculate screen positions from coordinates for a shape. * * @param data