src/js/widgets/tweetsWidget.js
branchpopcorn-port
changeset 541 f7667a1dde8e
parent 378 110311d59b2f
child 554 de53cbe1b052
equal deleted inserted replaced
540:b1f3aee23199 541:f7667a1dde8e
     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._displayingTweet = false;
     6   this._displayingTweet = false;
     7   this._timeoutId = undefined;  
     7   this._timeoutId = undefined; 
       
     8   this._hidden = false;
     8 };
     9 };
     9 
    10 
    10 
    11 
    11 IriSP.TweetsWidget.prototype = new IriSP.Widget();
    12 IriSP.TweetsWidget.prototype = new IriSP.Widget();
    12 
    13 
    13 
    14 
    14 IriSP.TweetsWidget.prototype.drawTweet = function(annotation) {
    15 IriSP.TweetsWidget.prototype.drawTweet = function(annotation) {
       
    16     if (this._hidden)
       
    17       return;
    15     
    18     
    16     var title = IriSP.formatTweet(annotation.content.title);
    19     var title = IriSP.formatTweet(annotation.content.title);
    17     var img = annotation.content.img.src;
    20     var img = annotation.content.img.src;
    18     if (typeof(img) === "undefined" || img === "" || img === "None") {
    21     if (typeof(img) === "undefined" || img === "" || img === "None") {
    19       img = IriSP.widgetsDefaults.TweetsWidget.default_profile_picture;
    22       img = IriSP.widgetsDefaults.TweetsWidget.default_profile_picture;
   101   this.selector.hide();
   104   this.selector.hide();
   102   this.selector.find(".Ldt-tweetWidgetMinimize").click(IriSP.wrap(this, this.closePanel));
   105   this.selector.find(".Ldt-tweetWidgetMinimize").click(IriSP.wrap(this, this.closePanel));
   103   this.selector.find(".Ldt-tweetWidgetKeepOpen").click(IriSP.wrap(this, this.keepPanel));
   106   this.selector.find(".Ldt-tweetWidgetKeepOpen").click(IriSP.wrap(this, this.keepPanel));
   104   
   107   
   105   this._Popcorn.listen("IriSP.PolemicTweet.click", IriSP.wrap(this, this.PolemicTweetClickHandler));
   108   this._Popcorn.listen("IriSP.PolemicTweet.click", IriSP.wrap(this, this.PolemicTweetClickHandler));
       
   109   this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", 
       
   110                         IriSP.wrap(this, this.handleAnnotateSignal));  
   106 };
   111 };
   107 
   112 
   108 IriSP.TweetsWidget.prototype.PolemicTweetClickHandler = function(tweet_id) {  
   113 IriSP.TweetsWidget.prototype.PolemicTweetClickHandler = function(tweet_id) {  
   109   var index, annotation;
   114   var index, annotation;
   110   for (index in this._serializer._data.annotations) {
   115   for (index in this._serializer._data.annotations) {
   119       return;
   124       return;
   120   
   125   
   121   this.displayTweet(annotation);
   126   this.displayTweet(annotation);
   122   return;
   127   return;
   123 };
   128 };
       
   129 
       
   130 /** handle clicks on the annotate button by hiding/showing itself */
       
   131 IriSP.TweetsWidget.prototype.handleAnnotateSignal = function() {
       
   132   if (this._hidden == false) {
       
   133     this.selector.hide();
       
   134     this._hidden = true;
       
   135   } else {
       
   136     this.selector.show();
       
   137     this._hidden = false;
       
   138   }
       
   139 };