[annotator-dev] New to CoffeeScript and building Annotator source
Nick Stenning
nick at whiteink.com
Fri May 18 11:40:39 UTC 2012
On 15/05/2012 03:52, Brian Long wrote:
> Hi All,
Hey Brian,
> I've had a heck of a time figuring out how to delete my annotator instance, created via
> $(".content-body").annotator();
Ah, sorry about that. I guess it's never been a requirement and so
making it easy to do hasn't really been a priority.
First, get the annotator instance. Then, remove the document-level
events and remove the annotated element. This is untested:
var annotator = $(".content-body").data('annotator');
// Remove document events for this Annotator
$(document).unbind("mouseup", annotator.checkForEndSelection);
$(document).unbind("mousedown", annotator.checkForStartSelection);
// Remove the annotated content element
$(".content-body").remove()
// Just for good measure, kill the Annotator instance from scope
delete annotator;
> I'm hoping to reinitialize my annotator when my document changes.
Right, and if you wish to keep the annotations from the store before,
you'll need to do that manually with `annotator.dumpAnnotations()` and
`annotator.loadAnnotations()`. (See also `loadAnnotations()` on the
Store plugin).
> I really couldn't figure out how to do this from the Wiki documentation, so
> I figured I'd start hacking around in the source. After some issues
> installing NodeJS (v 0.6.12), npm (v 1.1.4), CoffeeScript (v 1.2.0) and
> PhantomJS (v. 1.5) -- all of which on Ubuntu 12.04 x64 -- I was able to
> build and run Jasmine tests like this:
>
> me at home:~/annotator$ ./tools/watch ./test/helpers/phantomjs_helper.coffee
Just for reference, `tools/watch` doesn't expect any arguments. It's a
source watcher which will compile the annotator code from src/ to lib/
as and when it changes.
Also, once you have Node and NPM, you should be able to install all of
Annotator's dev dependencies simply by doing:
npm install .
> Then, I open : http://localhost:8000/test/runner.html and have the
> resulting "411 specs, 0 failures in
> 5.718s<http://localhost:8000/test/runner.html?>
Looks good. You don't need Phantom to run the tests, as you've
discovered. Just running them in the browser should work fine.
> I really couldn't figure out the 'redo' build tool...
Sorry about that. Two things:
1) You don't *ever* need to install redo. A minimal version of redo is
included with Annotator as `tools/do`, as noted in the README.
2) For the most part, you can probably get away with out running the
build. It's only to build the packaged/minified annotator. For day to
day development you only need to run `tools/watch` and open `dev.html`
in your browser.
> Thanks in advance,
> Brian
Thanks for getting in touch. I hope some of the above is helpful.
-N
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 850 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20120518/a310a19a/attachment-0002.sig>
More information about the annotator-dev
mailing list