Created
July 26, 2012 10:11
-
-
Save maxenglander/3181343 to your computer and use it in GitHub Desktop.
Annotator example
This file contains 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
.my_highlight { | |
text-decoration:underline; | |
background-color:orange; | |
} |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<body> | |
<div id="content"> | |
<header> | |
<h1>Annotate example</h1> | |
</header> | |
<p>Bork bork bork banana smoothie.</p> | |
</div> | |
</body> | |
</html> |
This file contains 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
Annotator.Plugin.CustomHighlighter = function(element) { | |
var myPlugin = {}; | |
myPlugin.pluginInit = function() { | |
myPlugin.annotator.subscribe("annotationsLoaded", function(arrayOfAnnotations) { | |
console.log("annotations loaded"); | |
console.log(arrayOfAnnotations); | |
$.each(arrayOfAnnotations, function(i) { | |
console.log("processing annotation #" + i); | |
var annotation = arrayOfAnnotations[i]; | |
$.each(annotation.highlights, function(j) { | |
console.log("\tprocessing highlight #" +j); | |
var highlight = annotation.highlights[j]; | |
$(highlight).addClass('my_highlight'); | |
}); | |
}); | |
}); | |
myPlugin.annotator.subscribe("annotationCreated", function(annotation) { | |
console.log(annotation); | |
}); | |
}; | |
return myPlugin; | |
}; | |
jQuery(function($) { | |
$("#content").annotator().annotator("addPlugin", "CustomHighlighter").annotator("addPlugin", "Store", { | |
prefix: "/gh/gist/response.json/3181343", | |
urls:{ | |
read:"/" | |
} | |
}); | |
}); |
This file contains 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
name: Annotator Plugin | |
description: Add css class with Annotator Plugin | |
authors: | |
- Max Englander | |
resources: | |
- http://assets.annotateit.org/annotator/v1.1.0/annotator.min.css | |
- http://assets.annotateit.org/annotator/v1.1.0/annotator-full.min.js | |
normalize_css: no |
This file contains 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
[ | |
{ | |
"id":"1", | |
"ranges":[ | |
{ | |
"start":"/p", | |
"startOffset":10, | |
"end":"/p", | |
"endOffset":14 | |
} | |
], | |
"quote":"bork", | |
"text":"So delicious." | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/gh/gist/jquery/1.7.2/3181343