src/js/widgets/annotationsWidget.js
branchpopcorn-port
changeset 541 f7667a1dde8e
parent 538 b778b2f93ef4
child 595 29d86e6c61a6
equal deleted inserted replaced
540:b1f3aee23199 541:f7667a1dde8e
     1 IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) {
     1 IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) {
     2   IriSP.Widget.call(this, Popcorn, config, Serializer);
     2   IriSP.Widget.call(this, Popcorn, config, Serializer);
     3   
     3   /* flag used when we're creating an annotation */
       
     4   this._hidden = false;
     4 };
     5 };
     5 
     6 
     6 
     7 
     7 IriSP.AnnotationsWidget.prototype = new IriSP.Widget();
     8 IriSP.AnnotationsWidget.prototype = new IriSP.Widget();
     8 
     9 
    10     this.selector.find(".Ldt-SaTitle").text("");
    11     this.selector.find(".Ldt-SaTitle").text("");
    11     this.selector.find(".Ldt-SaDescription").text("");
    12     this.selector.find(".Ldt-SaDescription").text("");
    12     this.selector.find(".Ldt-SaKeywordText").text("");
    13     this.selector.find(".Ldt-SaKeywordText").text("");
    13 };
    14 };
    14 
    15 
    15 IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) {   
    16 IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) {       
    16 
       
    17     var title = annotation.content.title;
    17     var title = annotation.content.title;
    18     var description = annotation.content.description;
    18     var description = annotation.content.description;
    19     var keywords =  "" // FIXME;
    19     var keywords =  "" // FIXME;
    20     var begin = +annotation.begin / 1000;
    20     var begin = +annotation.begin / 1000;
    21     var end = +annotation.end / 1000;
    21     var end = +annotation.end / 1000;
    37     this.selector.find(".Ldt-fbShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
    37     this.selector.find(".Ldt-fbShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
    38     this.selector.find(".Ldt-TwShare").attr("href", tw_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
    38     this.selector.find(".Ldt-TwShare").attr("href", tw_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
    39     this.selector.find(".Ldt-GplusShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
    39     this.selector.find(".Ldt-GplusShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
    40 };
    40 };
    41 
    41 
    42 IriSP.AnnotationsWidget.prototype.clearWidget = function() {
    42 IriSP.AnnotationsWidget.prototype.clearWidget = function() {   
    43 
       
    44     
       
    45     /* retract the pane between two annotations */
    43     /* retract the pane between two annotations */
    46     this.selector.find(".Ldt-SaTitle").text("");
    44     this.selector.find(".Ldt-SaTitle").text("");
    47     this.selector.find(".Ldt-SaDescription").text("");
    45     this.selector.find(".Ldt-SaDescription").text("");
    48     this.selector.find(".Ldt-SaKeywordText").html("");
    46     this.selector.find(".Ldt-SaKeywordText").html("");
    49     this.selector.find(".Ldt-ShowAnnotation").slideUp();
    47     this.selector.find(".Ldt-ShowAnnotation").slideUp();
    52 IriSP.AnnotationsWidget.prototype.draw = function() {
    50 IriSP.AnnotationsWidget.prototype.draw = function() {
    53   var _this = this;
    51   var _this = this;
    54 
    52 
    55   var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template);
    53   var annotationMarkup = IriSP.templToHTML(IriSP.annotationWidget_template);
    56 	this.selector.append(annotationMarkup);
    54 	this.selector.append(annotationMarkup);
    57   
    55 
       
    56   this._Popcorn.listen("IriSP.PlayerWidget.AnnotateButton.clicked", 
       
    57                         IriSP.wrap(this, this.handleAnnotateSignal));  
    58   var legal_ids = this._serializer.getNonTweetIds();
    58   var legal_ids = this._serializer.getNonTweetIds();
    59   
    59   
    60   var annotations = this._serializer._data.annotations;
    60   var annotations = this._serializer._data.annotations;
    61   var i;
    61   var i;
    62   
    62   
    83                 };
    83                 };
    84     this._Popcorn = this._Popcorn.code(conf);                                             
    84     this._Popcorn = this._Popcorn.code(conf);                                             
    85   }
    85   }
    86 
    86 
    87 };
    87 };
       
    88 
       
    89 IriSP.AnnotationsWidget.prototype.handleAnnotateSignal = function() {
       
    90   if (this._hidden == false) {
       
    91     this.selector.hide();
       
    92     this._hidden = true;
       
    93   } else {
       
    94     this.selector.show();
       
    95     this._hidden = false;
       
    96   }
       
    97 };