diff options
author | Trevor Elliott <trevor@galois.com> | 2013-06-07 16:42:11 -0700 |
---|---|---|
committer | Trevor Elliott <trevor@galois.com> | 2013-06-07 16:48:17 -0700 |
commit | 8b5d3c6b75744cf5938f253d20f367999e92b1a7 (patch) | |
tree | b516a82c5b198fd080d265e56b3edf19d1180f10 /tools/addon-sdk-1.5/examples/annotator/data/matcher.js | |
parent | f37588f9a4c7c6b418c64f03d82d48ecd14da217 (diff) |
Remove the addon-sdk from the repo, and download it on demand
Diffstat (limited to 'tools/addon-sdk-1.5/examples/annotator/data/matcher.js')
-rw-r--r-- | tools/addon-sdk-1.5/examples/annotator/data/matcher.js | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/tools/addon-sdk-1.5/examples/annotator/data/matcher.js b/tools/addon-sdk-1.5/examples/annotator/data/matcher.js deleted file mode 100644 index 86d6bc7..0000000 --- a/tools/addon-sdk-1.5/examples/annotator/data/matcher.js +++ /dev/null @@ -1,50 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* -Locate anchors for annotations and prepare to display the annotations. - -For each annotation, if its URL matches this page, -- get the ancestor whose ID matches the ID in the anchor -- look for a <p> element whose content contains the anchor text - -That's considered a match. Then we: -- highlight the anchor element -- add an 'annotated' class to tell the selector to skip this element -- embed the annottion text as a new attribute - -For all annotated elements: -- bind 'mouseenter' and 'mouseleave' events to the element, to send 'show' - and 'hide' messages back to the add-on. -*/ - -self.on('message', function onMessage(annotations) { - annotations.forEach( - function(annotation) { - if(annotation.url == document.location.toString()) { - createAnchor(annotation); - } - }); - - $('.annotated').css('border', 'solid 3px yellow'); - - $('.annotated').bind('mouseenter', function(event) { - self.port.emit('show', $(this).attr('annotation')); - event.stopPropagation(); - event.preventDefault(); - }); - - $('.annotated').bind('mouseleave', function() { - self.port.emit('hide'); - }); -}); - - -function createAnchor(annotation) { - annotationAnchorAncestor = $('#' + annotation.ancestorId)[0] || document.body; - annotationAnchor = $(annotationAnchorAncestor).parent().find( - ':contains("' + annotation.anchorText + '")').last(); - annotationAnchor.addClass('annotated'); - annotationAnchor.attr('annotation', annotation.annotationText); -} |