Created
May 9, 2014 18:07
-
-
Save tilgovi/fd5c980c89092c58fb72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This is our interaction point | |
| position = null; | |
| $(document.body).on('mouseup', function (event) { | |
| }); | |
| var annotator = Annotator.create({ | |
| onSelection: function (event) { | |
| // We have to trigger this event ourselves. | |
| // Could be as simple as: | |
| // event = $.Event('selection', event); | |
| // target = Util.getGlobal().getSelection().getRangeAt(0).commonAncestor | |
| // $(target).trigger(event); | |
| // Though I'm not certain jQuery will accept clientX, etc in hash passed to $.Event | |
| annotation = null; | |
| position = Util.getMousePosition(event); | |
| adder.show(position); | |
| }, | |
| onCreate: function (annotation) { | |
| position = Util.getMousePosition(event); | |
| editor.show(position); | |
| }.wait() | |
| .then(function () { | |
| annotation = textSelector.describe(selection); | |
| // Fire beforeAnnotationCreated here for legacy plugins? | |
| return editor | |
| .load(selection) | |
| .show(position) | |
| .wait(); | |
| }) | |
| .then(function () { | |
| return store.save(annotation); | |
| }) | |
| .then(function () { | |
| // Fire annotationCreated here for legacy plugins? | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment