addon-sdk/source/examples/annotator/data/list/annotation-list.js

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:3f2460e9279f
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 /*
6 Construct the HTML for the annotation list.
7
8 Bind a function to click events on the link that send a message back to
9 the add-on code, so it can open the link in the main browser.
10 */
11
12 self.on("message", function onMessage(storedAnnotations) {
13 var annotationList = $('#annotation-list');
14 annotationList.empty();
15 storedAnnotations.forEach(
16 function(storedAnnotation) {
17 var annotationHtml = $('#template .annotation-details').clone();
18 annotationHtml.find('.url').text(storedAnnotation.url)
19 .attr('href', storedAnnotation.url);
20 annotationHtml.find('.url').bind('click', function(event) {
21 event.stopPropagation();
22 event.preventDefault();
23 self.postMessage(storedAnnotation.url);
24 });
25 annotationHtml.find('.selection-text')
26 .text(storedAnnotation.anchorText);
27 annotationHtml.find('.annotation-text')
28 .text(storedAnnotation.annotationText);
29 annotationList.append(annotationHtml);
30 });
31 });

mercurial