1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/examples/annotator/data/list/annotation-list.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,31 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/* 1.9 +Construct the HTML for the annotation list. 1.10 + 1.11 +Bind a function to click events on the link that send a message back to 1.12 +the add-on code, so it can open the link in the main browser. 1.13 +*/ 1.14 + 1.15 +self.on("message", function onMessage(storedAnnotations) { 1.16 + var annotationList = $('#annotation-list'); 1.17 + annotationList.empty(); 1.18 + storedAnnotations.forEach( 1.19 + function(storedAnnotation) { 1.20 + var annotationHtml = $('#template .annotation-details').clone(); 1.21 + annotationHtml.find('.url').text(storedAnnotation.url) 1.22 + .attr('href', storedAnnotation.url); 1.23 + annotationHtml.find('.url').bind('click', function(event) { 1.24 + event.stopPropagation(); 1.25 + event.preventDefault(); 1.26 + self.postMessage(storedAnnotation.url); 1.27 + }); 1.28 + annotationHtml.find('.selection-text') 1.29 + .text(storedAnnotation.anchorText); 1.30 + annotationHtml.find('.annotation-text') 1.31 + .text(storedAnnotation.annotationText); 1.32 + annotationList.append(annotationHtml); 1.33 + }); 1.34 +});