# HG changeset patch # User hertzhaft # Date 1480810669 -3600 # Node ID 276327b42d76b4e279525fd842896f2326f5b426 # Parent f322ac84adf7ba5752c9dab108c88a0c49c9850e annotator plugin: calculate shape before save, update and render new annotation after save diff -r f322ac84adf7 -r 276327b42d76 webapp/src/main/webapp/jquery/annotator-dl.js --- a/webapp/src/main/webapp/jquery/annotator-dl.js Sat Dec 03 21:42:12 2016 +0100 +++ b/webapp/src/main/webapp/jquery/annotator-dl.js Sun Dec 04 01:17:49 2016 +0100 @@ -2292,12 +2292,12 @@ }; Store.prototype.updateAnnotation = function(annotation, data) { - this.publish("annotationStored", [annotation, data]); if (__indexOf.call(this.annotations, annotation) < 0) { console.error(Annotator._t("Trying to update unregistered annotation!")); } else { $.extend(annotation, data); } + this.publish("annotationStored", [data]); return $(annotation.highlights).data('annotation', annotation); }; diff -r f322ac84adf7 -r 276327b42d76 webapp/src/main/webapp/jquery/jquery.digilib.annotator.js --- a/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js Sat Dec 03 21:42:12 2016 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js Sun Dec 04 01:17:49 2016 +0100 @@ -323,18 +323,22 @@ }; var save = function () { console.log("annotation save"); - // Fire annotationCreated events so that plugins can react to them + cleanup(); + annotator.setupAnnotation(annotation); + // UGLY: depends on data.annotations(side effect of setupAnnotation) + var annoWrapper = data.annotations[data.annotations.length -1]; + // calculate shape coordinates + createShape(data, annoWrapper); + // Fire annotationCreated events so that the Annotator Store plugin saves the annotation in the Db annotator.publish('annotationCreated', [annotation]); }; - var store = function (orig, stored) { + var store = function (stored) { if (stored == null) { console.warn('Annotation Store did not return the stored annotation'); stored = annotation; } console.debug("annotation stored", stored); - cleanup(); renderAnnotations(data); - annotator.setupAnnotation(stored); }; var cancel = function () { console.log("annotation cancel");