src/js/widgets/tweetsWidget.js
branchtweet-widget
changeset 277 ff416475397a
parent 276 8a5a34ff1202
child 278 ff20c80c6845
equal deleted inserted replaced
276:8a5a34ff1202 277:ff416475397a
     1 /* a widget that displays tweet - used in conjunction with the polemicWidget */
     1 /* a widget that displays tweet - used in conjunction with the polemicWidget */
     2 
     2 
     3 IriSP.TweetsWidget = function(Popcorn, config, Serializer) {
     3 IriSP.TweetsWidget = function(Popcorn, config, Serializer) {
     4   IriSP.Widget.call(this, Popcorn, config, Serializer);
     4   IriSP.Widget.call(this, Popcorn, config, Serializer);
     5  
     5 
     6   this._isDisplayingTweet = false;
     6   this._displayingTweet = false;
     7   this._ignoreClear = false;
     7   this._timeoutId = undefined;
     8 };
     8 };
     9 
     9 
    10 
    10 
    11 IriSP.TweetsWidget.prototype = new IriSP.Widget();
    11 IriSP.TweetsWidget.prototype = new IriSP.Widget();
    12 
    12 
    26     this.selector.find(".Ldt-tweetAvatar").html(imageMarkup);
    26     this.selector.find(".Ldt-tweetAvatar").html(imageMarkup);
    27     this.selector.show(50);
    27     this.selector.show(50);
    28 };
    28 };
    29 
    29 
    30 IriSP.TweetsWidget.prototype.displayTweet = function(annotation) {
    30 IriSP.TweetsWidget.prototype.displayTweet = function(annotation) {
    31   if (this._isDisplayingTweet === false) {
    31   if (this._displayingTweet === false) {
    32     this._isDisplayingTweet = true;
    32     this._displayingTweet = true;
    33   } else { /* we're already displaying a tweet */
    33   } else {
    34     this._ignoreClear = true;
    34     window.clearTimeout(this._timeoutId);
    35   }
    35   }
    36   
    36 
    37   this.drawTweet(annotation);
    37   this.drawTweet(annotation);
    38 
    38 
    39   var time = this._Popcorn.currentTime();  
    39   var time = this._Popcorn.currentTime();  
    40   // this._Popcorn.exec(time + 10, IriSP.wrap(this, this.clearPanel)); 
    40   this._timeoutId = window.setTimeout(IriSP.wrap(this, this.clearPanel), 10000);
    41   window.setTimeout(IriSP.wrap(this, this.clearPanel), 10000);
       
    42 };
    41 };
    43 
    42 
    44 
    43 
    45 IriSP.TweetsWidget.prototype.clearPanel = function() {
    44 IriSP.TweetsWidget.prototype.clearPanel = function() {  
    46   debugger;
    45     this._displayingTweet = false;
    47   if (this._ignoreClear === true) {
       
    48     this._ignoreClear = false;
       
    49     return;
       
    50   } else {
       
    51     /* clear the display */
       
    52     this.closePanel();
    46     this.closePanel();
    53     this._isDisplayingTweet = false;    
       
    54     this._ignoreClear = false;    
       
    55   }
       
    56 };
    47 };
    57 
    48 
    58 IriSP.TweetsWidget.prototype.closePanel = function() {
    49 IriSP.TweetsWidget.prototype.closePanel = function() {
    59   if (this._displayingTweet)
    50   if (this._displayingTweet)
    60     return;
    51     return;
    65 
    56 
    66 IriSP.TweetsWidget.prototype.draw = function() {
    57 IriSP.TweetsWidget.prototype.draw = function() {
    67   var _this = this;
    58   var _this = this;
    68   
    59   
    69   var tweetMarkup = Mustache.to_html(IriSP.tweetWidget_template, {"share_template" : IriSP.share_template});
    60   var tweetMarkup = Mustache.to_html(IriSP.tweetWidget_template, {"share_template" : IriSP.share_template});
    70 	this.selector.append(tweetMarkup);
    61   this.selector.append(tweetMarkup);
    71   this.selector.hide();
    62   this.selector.hide();
    72   
    63   
    73   this._Popcorn.listen("IriSP.PolemicTweet.click", IriSP.wrap(this, this.PolemicTweetClickHandler));
    64   this._Popcorn.listen("IriSP.PolemicTweet.click", IriSP.wrap(this, this.PolemicTweetClickHandler));
    74 };
    65 };
    75 
    66