| author | hamidouk |
| Mon, 09 Jan 2012 15:38:54 +0100 | |
| branch | popcorn-port |
| changeset 599 | a5a5e70d46a7 |
| parent 595 | 29d86e6c61a6 |
| child 602 | b35862f9b0b0 |
| permissions | -rw-r--r-- |
| 585 | 1 |
IriSP.AnnotationsListWidget = function(Popcorn, config, Serializer) { |
2 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
3 |
}; |
|
4 |
||
5 |
||
6 |
IriSP.AnnotationsListWidget.prototype = new IriSP.Widget(); |
|
7 |
||
8 |
IriSP.AnnotationsListWidget.prototype.clear = function() { |
|
9 |
}; |
|
10 |
||
| 588 | 11 |
IriSP.AnnotationsListWidget.prototype.clearWidget = function() { |
| 585 | 12 |
}; |
13 |
||
| 599 | 14 |
/** draw the annotation list */ |
15 |
IriSP.AnnotationsListWidget.prototype.drawList = function() { |
|
| 585 | 16 |
var _this = this; |
17 |
||
|
595
29d86e6c61a6
finished going through the widgets to add stricter line checking.
hamidouk
parents:
588
diff
changeset
|
18 |
var view_type = this._serializer.getContributions(); |
| 585 | 19 |
var annotations = this._serializer._data.annotations; |
20 |
var list = []; |
|
| 588 | 21 |
|
| 585 | 22 |
if (typeof(view_type) === "undefined") { |
23 |
console.log("not type suitable for display"); |
|
24 |
return; |
|
25 |
} |
|
| 588 | 26 |
|
| 585 | 27 |
for (i = 0; i < annotations.length; i++) { |
28 |
var annotation = annotations[i]; |
|
29 |
||
30 |
/* filter the annotations whose type is not the one we want */ |
|
31 |
if (typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined" |
|
32 |
&& annotation.meta["id-ref"] != view_type) { |
|
33 |
continue; |
|
34 |
} |
|
35 |
||
36 |
var a = annotation; |
|
37 |
var obj = {}; |
|
| 588 | 38 |
|
| 585 | 39 |
obj["id"] = a.id; |
40 |
obj["title"] = a.content.title; |
|
41 |
obj["desc"] = a.content.description; |
|
42 |
obj["begin"] = IriSP.msToTime(a.begin); |
|
43 |
obj["end"] = IriSP.msToTime(a.end); |
|
| 588 | 44 |
|
| 585 | 45 |
list.push(obj); |
46 |
} |
|
47 |
||
48 |
var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list}); |
|
| 599 | 49 |
this.selector.html(widgetMarkup); |
50 |
}; |
|
51 |
||
52 |
IriSP.AnnotationsListWidget.prototype.draw = function() { |
|
53 |
||
54 |
this.drawList(); |
|
55 |
this._Popcorn.listen("IriSP.createAnnotationWidget.addedAnnotation", IriSP.wrap(this, this.redraw)); |
|
56 |
}; |
|
57 |
||
58 |
IriSP.AnnotationsListWidget.prototype.redraw = function() { |
|
59 |
this.drawList(); |
|
| 585 | 60 |
}; |