Hi,

On 03/04/2015 12:25 PM, King'ori J. Maina wrote:

I’ve been able to get some sample plugin code setup and being used by annotator but I’m struggling to figure out how to add the actual functionality of up-voting and down-voting. Getting exhausted while trying to learn/figure out coffee script. The idea was that I have some sample code to refer to as a base implementation of the fundamentals.

Any ideas as to a plugin that’s written in vanilla JS that I can poke into and learn?

Edge Annotator is in vanilla JS, so everything in https://github.com/openannotation/annotator/tree/master/src should now be JS only, although some of those don't necessarily demonstrate plugin capabilities.

Here's one I'm working on: https://github.com/stephskardal/Annotation-Studio/blob/master/app/assets/javascripts/annotator-category.js. It is compatible with Annotator 1.2.*. I've also worked on Annotator 2.0 and the plugin API is not much different. Here are some important bits: * pluginInit (https://github.com/stephskardal/Annotation-Studio/blob/master/app/assets/javascripts/annotator-category.js#L26): called when a plugin is initialized, but before data loaded. Here's where you would call addField on the viewer or editor. * hook for annotationsLoaded, called after Annotator finishes loading annotations. Here's where you may manipulate annotations / UI after annotations loaded. * hooks for annotationUpdated, annotationCreated, called after annotation updated / created. Here's where you may manipulate the UI based on annotation data. * hook for annotationEditorSubmit, called right after user clicks "save", but before data is sent to the backend. Here's where you would modify the annotation data getting sent to the backend. * __bind calls on various plugin methods to set scope (https://github.com/stephskardal/Annotation-Studio/blob/master/app/assets/javascripts/annotator-category.js#L17-L22)

There are quite a few more hooks, but I think these are likely to be the most popular.

Another option is to use something like http://js2.coffee/ to convert another plugin in CoffeeScript to JS.

Steph
_______________________________________________
annotator-dev mailing list
[email protected]
https://lists.okfn.org/mailman/listinfo/annotator-dev
Unsubscribe: https://lists.okfn.org/mailman/options/annotator-dev

Reply via email to