|
406
|
1 |
/* a widget that displays tweet - used in conjunction with the polemicWidget */ |
|
|
2 |
|
|
|
3 |
IriSP.TweetsView = function(Popcorn, config, Serializer) { |
|
|
4 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
|
5 |
|
|
|
6 |
this._displayingTweet = false; |
|
|
7 |
this._timeoutId = undefined; |
|
|
8 |
}; |
|
|
9 |
|
|
|
10 |
|
|
|
11 |
IriSP.TweetsView.prototype = new IriSP.Widget(); |
|
|
12 |
|
|
|
13 |
|
|
|
14 |
IriSP.TweetsView.prototype.drawTweet = function(annotation) { |
|
|
15 |
var title = IriSP.formatTweet(annotation.content.title); |
|
|
16 |
var desc = IriSP.formatTweet(annotation.content.description); |
|
|
17 |
|
|
|
18 |
this.selector.find(".Ldt-SaTitle").html(title); |
|
|
19 |
this.selector.find(".Ldt-SaDescription").html(desc); |
|
|
20 |
this.selector.show("blind", 250); |
|
|
21 |
}; |
|
|
22 |
|
|
|
23 |
IriSP.TweetsView.prototype.displayTweet = function(annotation) { |
|
|
24 |
if (this._displayingTweet === false) { |
|
|
25 |
this._displayingTweet = true; |
|
|
26 |
} else { |
|
|
27 |
window.clearTimeout(this._timeoutId); |
|
|
28 |
} |
|
|
29 |
|
|
|
30 |
this.drawTweet(annotation); |
|
|
31 |
|
|
|
32 |
}; |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
IriSP.TweetsView.prototype.draw = function() { |
|
|
36 |
var _this = this; |
|
|
37 |
|
|
|
38 |
this.selector.append(Mustache.to_html(IriSP.polemicAnnotationView_template, {})); |
|
|
39 |
this._Popcorn.listen("IriSP.PolemicTweet.click", IriSP.wrap(this, this.PolemicTweetClickHandler)); |
|
|
40 |
}; |
|
|
41 |
|
|
|
42 |
IriSP.TweetsView.prototype.PolemicTweetClickHandler = function(tweet_id) { |
|
|
43 |
var index, annotation; |
|
|
44 |
for (index in this._serializer._data.annotations) { |
|
|
45 |
annotation = this._serializer._data.annotations[index]; |
|
|
46 |
|
|
|
47 |
if (annotation.id === tweet_id) |
|
|
48 |
break; |
|
|
49 |
} |
|
|
50 |
|
|
|
51 |
if (annotation.id !== tweet_id) |
|
|
52 |
/* we haven't found it */ |
|
|
53 |
return; |
|
|
54 |
|
|
|
55 |
this.displayTweet(annotation); |
|
|
56 |
return; |
|
|
57 |
}; |