Mercurial > hg > digilib
changeset 1586:276327b42d76
annotator plugin: calculate shape before save, update and render new annotation after save
author | hertzhaft |
---|---|
date | Sun, 04 Dec 2016 01:17:49 +0100 |
parents | f322ac84adf7 |
children | 107159069baf |
files | webapp/src/main/webapp/jquery/annotator-dl.js webapp/src/main/webapp/jquery/jquery.digilib.annotator.js |
diffstat | 2 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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); };
--- 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");