| author | hamidouk |
| Fri, 18 Nov 2011 14:33:24 +0100 | |
| branch | tweet-widget |
| changeset 276 | 8a5a34ff1202 |
| parent 275 | a4d2dd99187b |
| child 277 | ff416475397a |
| 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); |
| 276 | 5 |
|
6 |
this._isDisplayingTweet = false; |
|
7 |
this._ignoreClear = false; |
|
|
267
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 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
10 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
11 |
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
|
12 |
|
| 275 | 13 |
|
| 276 | 14 |
IriSP.TweetsWidget.prototype.drawTweet = function(annotation) { |
| 275 | 15 |
|
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
16 |
var title = annotation.content.title; |
|
274
fe02d003c6c4
added support for a default profile picture in case it's not defined.
hamidouk
parents:
271
diff
changeset
|
17 |
var img = annotation.content.img.src; |
|
fe02d003c6c4
added support for a default profile picture in case it's not defined.
hamidouk
parents:
271
diff
changeset
|
18 |
if (typeof(img) === "undefined" || img === "" || img === "None") { |
|
fe02d003c6c4
added support for a default profile picture in case it's not defined.
hamidouk
parents:
271
diff
changeset
|
19 |
img = IriSP.widgetsDefaults.TweetsWidget.default_profile_picture; |
|
fe02d003c6c4
added support for a default profile picture in case it's not defined.
hamidouk
parents:
271
diff
changeset
|
20 |
} |
|
fe02d003c6c4
added support for a default profile picture in case it's not defined.
hamidouk
parents:
271
diff
changeset
|
21 |
|
| 268 | 22 |
var imageMarkup = Mustache.to_html("<img src='{{src}}' alt='avatar'></img>", |
|
274
fe02d003c6c4
added support for a default profile picture in case it's not defined.
hamidouk
parents:
271
diff
changeset
|
23 |
{src : img}); |
|
fe02d003c6c4
added support for a default profile picture in case it's not defined.
hamidouk
parents:
271
diff
changeset
|
24 |
|
| 268 | 25 |
this.selector.find(".Ldt-tweetContents").text(title); |
26 |
this.selector.find(".Ldt-tweetAvatar").html(imageMarkup); |
|
| 271 | 27 |
this.selector.show(50); |
| 275 | 28 |
}; |
29 |
||
| 276 | 30 |
IriSP.TweetsWidget.prototype.displayTweet = function(annotation) { |
31 |
if (this._isDisplayingTweet === false) { |
|
32 |
this._isDisplayingTweet = true; |
|
33 |
} else { /* we're already displaying a tweet */ |
|
34 |
this._ignoreClear = true; |
|
35 |
} |
|
| 275 | 36 |
|
| 276 | 37 |
this.drawTweet(annotation); |
| 275 | 38 |
|
| 276 | 39 |
var time = this._Popcorn.currentTime(); |
40 |
// this._Popcorn.exec(time + 10, IriSP.wrap(this, this.clearPanel)); |
|
41 |
window.setTimeout(IriSP.wrap(this, this.clearPanel), 10000); |
|
| 275 | 42 |
}; |
43 |
||
| 276 | 44 |
|
45 |
IriSP.TweetsWidget.prototype.clearPanel = function() { |
|
46 |
debugger; |
|
47 |
if (this._ignoreClear === true) { |
|
48 |
this._ignoreClear = false; |
|
| 275 | 49 |
return; |
| 276 | 50 |
} else { |
51 |
/* clear the display */ |
|
| 275 | 52 |
this.closePanel(); |
| 276 | 53 |
this._isDisplayingTweet = false; |
54 |
this._ignoreClear = false; |
|
| 275 | 55 |
} |
56 |
}; |
|
57 |
||
58 |
IriSP.TweetsWidget.prototype.closePanel = function() { |
|
59 |
if (this._displayingTweet) |
|
60 |
return; |
|
61 |
else { |
|
62 |
this.selector.hide(50); |
|
63 |
} |
|
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
64 |
}; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
65 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
66 |
IriSP.TweetsWidget.prototype.draw = function() { |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
67 |
var _this = this; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
68 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
69 |
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
|
70 |
this.selector.append(tweetMarkup); |
| 271 | 71 |
this.selector.hide(); |
72 |
|
|
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
73 |
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
|
74 |
}; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
75 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
76 |
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
|
77 |
var index, annotation; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
78 |
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
|
79 |
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
|
80 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
81 |
if (annotation.id === tweet_id) |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
82 |
break; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
83 |
} |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
84 |
|
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
85 |
if (annotation.id !== tweet_id) |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
86 |
/* we haven't found it */ |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
87 |
return; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
88 |
|
| 276 | 89 |
this.displayTweet(annotation); |
|
267
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
90 |
return; |
|
f84013fb19dc
added a new widget, to display the contents of tweets in a separate pane.
hamidouk
parents:
diff
changeset
|
91 |
}; |