[annotator-dev] changing the annotator-hl class or id
Nick Stenning
nick at whiteink.com
Thu Sep 1 14:22:12 UTC 2011
Hi Ewald,
On Thu, Sep 1, 2011 at 14:37, Ewald Zietsman <ewald at siyavula.com> wrote:
>
> Hi,
> I am trying to assign different colours for different 'categories' of annotations but the mechanics behind the highlighting is a bit over my head.
No problem. The slicing and dicing of the DOM that annotator does is
pretty complicated, so don't worry about it!
> in annotator.coffee I have changed the following code to check whether an annotation has a category attribute and to assign the highlighting accordingly.
> [...snip...]
The code you've provided is a bit confused, as you've guessed. The
`annotation.highlights` array actually contains a list of DOM nodes,
so I think the easiest way to do what you want is add something like
the following after line 242 of annotator.coffee:
annotation.ranges.push normed.serialize(@wrapper[0], '.annotator-hl')
hlElems = this.highlightRange(normed)
if annotation.category?
$(hlElems).addClass(".annotator-hl-#{annotation.category}")
$.merge annotation.highlights, hlElems
Let me know how you get on with that!
Best,
Nick
More information about the annotator-dev
mailing list