src/js/widgets/annotationsWidget.js
branchpopcorn-port
changeset 98 ed4ac18baf07
child 101 c63f56e4bc21
equal deleted inserted replaced
97:62612c69699f 98:ed4ac18baf07
       
     1 IriSP.AnnotationsWidget = function(Popcorn, config, Serializer) {
       
     2   IriSP.Widget.call(this, Popcorn, config, Serializer);
       
     3   
       
     4 };
       
     5 
       
     6 
       
     7 IriSP.AnnotationsWidget.prototype = new IriSP.Widget;
       
     8 
       
     9 IriSP.AnnotationsWidget.prototype.clear = function() {
       
    10     IriSP.jQuery("#Ldt-SaTitle").text("");
       
    11     IriSP.jQuery("#Ldt-SaDescription").text("");
       
    12     IriSP.jQuery("#Ldt-SaKeywordText").text("");
       
    13 };
       
    14 
       
    15 IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) {
       
    16     var title = annotation.content.title;
       
    17     var description = annotation.content.description;
       
    18     var keywords =  "" // FIXME;
       
    19     var begin = +annotation.begin;
       
    20     var end = +annotation.end;
       
    21     var duration = +this._serializer.currentMedia().meta["dc:duration"];
       
    22 
       
    23     IriSP.jQuery("#Ldt-SaTitle").text(title);
       
    24     IriSP.jQuery("#Ldt-SaDescription").text(description);
       
    25     IriSP.jQuery("#Ldt-SaKeywordText").text("Mots clefs : "+ keywords);
       
    26 		var startPourcent = parseInt(Math.round((begin*1+(end*1-begin*1)/2) / (duration*1)) / 100); 
       
    27 		IriSP.jQuery("#Ldt-Show-Arrow").animate({left:startPourcent+'%'},1000);
       
    28 		//IriSP.jQuery("#"+annotationTempo.id).animate({alpha:'100%'},1000);
       
    29 
       
    30 };
       
    31 
       
    32 IriSP.AnnotationsWidget.prototype.draw = function() {
       
    33   var _this = this;
       
    34 
       
    35   var annotationMarkup = Mustache.to_html(IriSP.annotationWidget_template, {"share_template" : IriSP.share_template});
       
    36 	IriSP.jQuery("#Ldt-Ligne").append(annotationMarkup);
       
    37   console.dir(this._serializer);
       
    38   
       
    39   var annotations = this._serializer._data.annotations;
       
    40 	for (i in annotations) {    
       
    41     var annotation = annotations[i];
       
    42     var begin = Math.round((+ annotation.begin) / 1000);
       
    43     var end = Math.round((+ annotation.end) / 1000);
       
    44 
       
    45     this._Popcorn = this._Popcorn.code({start: begin, end: end, 
       
    46                                         onStart: 
       
    47                                           function(annotation) { return function() { _this.displayAnnotation(annotation); } }(annotation) });                                             
       
    48   }
       
    49 };