src/js/widgets/segmentsWidget.js
author hamidouk
Thu, 20 Oct 2011 10:19:36 +0200
branchpopcorn-port
changeset 100 dbd302a995f5
child 104 d571e9020092
permissions -rw-r--r--
added a new widget and the tests which come with it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     1
IriSP.SegmentsWidget = function(Popcorn, config, Serializer) {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     2
  IriSP.Widget.call(this, Popcorn, config, Serializer);  
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     3
};
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     4
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     5
IriSP.SegmentsWidget.prototype = new IriSP.Widget;
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     6
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     7
IriSP.SegmentsWidget.prototype.draw = function() {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     8
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
     9
  var annotations = this._serializer._data.annotations;
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    10
  
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    11
	for (i in annotations) {    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    12
    var annotation = annotations[i];
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    13
    console.log(annotation);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    14
    var begin = Math.round((+ annotation.begin) / 1000);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    15
    var end = Math.round((+ annotation.end) / 1000);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    16
    var duration = (annotation.end - annotation.begin);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    17
    var id = annotation.id;    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    18
    var startPourcent 	= IriSP.timeToPourcent(begin, duration);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    19
    var endPourcent 	= IriSP.timeToPourcent(end, duration) - startPourcent;
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    20
    var divTitle		= annotation.content.title.substr(0,55);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    21
    var color = annotation.content.color
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    22
      
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    23
    var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    24
        {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    25
        "endPourcent" : endPourcent, "hexa_color" : IriSP.DEC_HEXA_COLOR(color),
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    26
        "seekPlace" : Math.round(begin/1000)});
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    27
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    28
    var toolTipTemplate = Mustache.to_html(IriSP.tooltip_template, 
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    29
          {"title" : divTitle, "begin" : begin, "end" : end,
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    30
          "description": annotation.content.description});
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    31
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    32
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    33
    IriSP.jQuery("<div>" + annotationTemplate + "</div>").appendTo("#Ldt-Annotations");
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    34
    // TOOLTIP BUG ! 
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    35
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    36
    IriSP.jQuery("#" + id).tooltip({ effect: 'slide'});
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    37
    
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    38
    IriSP.jQuery("#" + id).fadeTo(0,0.3);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    39
    IriSP.jQuery("#" + id).mouseover(function() {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    40
      IriSP.jQuery("#" + id).animate({opacity: 0.6}, 5);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    41
    }).mouseout(function(){		
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    42
      IriSP.jQuery("#" + id).animate({opacity: 0.3}, 5);
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    43
    });  
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    44
  }
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    45
};