| author | hamidouk |
| Thu, 17 Nov 2011 17:34:13 +0100 | |
| branch | tweet-widget |
| changeset 271 | 41258988e132 |
| parent 268 | 576cc32f0688 |
| child 274 | fe02d003c6c4 |
| permissions | -rw-r--r-- |
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
1 |
/* a widget that displays tweet - used in conjunction with the polemicWidget */ |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
2 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
3 |
IriSP.TweetsWidget = function(Popcorn, config, Serializer) { |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
4 |
IriSP.Widget.call(this, Popcorn, config, Serializer); |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
5 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
6 |
}; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
7 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
8 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
9 |
IriSP.TweetsWidget.prototype = new IriSP.Widget(); |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
10 |
|
| 271 | 11 |
IriSP.TweetsWidget.prototype.displayTweet = function(annotation) { |
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
12 |
var title = annotation.content.title; |
| 268 | 13 |
var imageMarkup = Mustache.to_html("<img src='{{src}}' alt='avatar'></img>", |
14 |
{src : annotation.content.img.src}); |
|
15 |
this.selector.find(".Ldt-tweetContents").text(title); |
|
16 |
this.selector.find(".Ldt-tweetAvatar").html(imageMarkup); |
|
| 271 | 17 |
this.selector.show(50); |
18 |
window.setTimeout(IriSP.wrap(this, function() { this.selector.hide(50) }), 10000); |
|
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
19 |
}; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
20 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
21 |
IriSP.TweetsWidget.prototype.draw = function() { |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
22 |
var _this = this; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
23 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
24 |
var tweetMarkup = Mustache.to_html(IriSP.tweetWidget_template, {"share_template" : IriSP.share_template}); |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
25 |
this.selector.append(tweetMarkup); |
| 271 | 26 |
this.selector.hide(); |
27 |
|
|
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
28 |
this._Popcorn.listen("IriSP.PolemicTweet.click", IriSP.wrap(this, this.PolemicTweetClickHandler)); |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
29 |
}; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
30 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
31 |
IriSP.TweetsWidget.prototype.PolemicTweetClickHandler = function(tweet_id) { |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
32 |
var index, annotation; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
33 |
for (index in this._serializer._data.annotations) { |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
34 |
annotation = this._serializer._data.annotations[index]; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
35 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
36 |
if (annotation.id === tweet_id) |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
37 |
break; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
38 |
} |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
39 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
40 |
if (annotation.id !== tweet_id) |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
41 |
/* we haven't found it */ |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
42 |
return; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
43 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
44 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
45 |
this.displayTweet(annotation); |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
46 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
47 |
var time = this._Popcorn.currentTime(); |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
48 |
this._Popcorn = this._Popcorn.code({ start : time + 0.1, end: time + 10, |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
49 |
onEnd: IriSP.wrap(this, this.clearTweet)}); |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
50 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
51 |
return; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
52 |
}; |