src/js/widgets/segmentsWidget.js
branchpopcorn-port
changeset 483 0bb36c79836c
parent 479 24308670f1bb
child 508 00054959ee92
equal deleted inserted replaced
482:1c225a39a3b1 483:0bb36c79836c
    56 
    56 
    57     var begin = Math.round((+ annotation.begin) / 1000);
    57     var begin = Math.round((+ annotation.begin) / 1000);
    58     var end = Math.round((+ annotation.end) / 1000);
    58     var end = Math.round((+ annotation.end) / 1000);
    59     var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
    59     var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
    60     var id = annotation.id;
    60     var id = annotation.id;
    61     var startPourcent 	= IriSP.timeToPourcent(begin, duration) + onePxPercent;
    61     var startPourcent 	= IriSP.timeToPourcent(begin, duration);
    62     
    62     
    63     /* some sort of collapsing occurs, so we only have to substract one pixel to each box instead of
    63     /* surprisingly, the following code doesn't work on webkit - for some reason, most of the 
    64        two
    64        boxes are 3 pixels smaller.
    65     */
    65     */
    66     var endPourcent 	= IriSP.timeToPourcent(end, duration) - startPourcent - onePxPercent * 1.5;
    66     var endPourcent 	= Math.floor(IriSP.timeToPourcent(end, duration) - startPourcent);
    67     
    67     var endPixel = Math.floor(this.selector.parent().width() * (endPourcent / 100)) - 2;
    68     /* on the other hand, we have to substract one pixel from the first box because it's the only
    68         
    69        one to have to effective 1px margins */
       
    70     if (i == 0) {
    69     if (i == 0) {
    71 
    70 
    72       endPourcent -= onePxPercent;
    71       endPourcent -= onePxPercent;
    73     }
    72     }
    74     
    73     
    86     if (hexa_color.length == 4)
    85     if (hexa_color.length == 4)
    87       hexa_color = hexa_color + '00';
    86       hexa_color = hexa_color + '00';
    88     
    87     
    89     var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
    88     var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
    90         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
    89         {"divTitle" : divTitle, "id" : id, "startPourcent" : startPourcent,
    91         "endPourcent" : endPourcent, "hexa_color" : hexa_color,
    90         "endPixel" : endPixel, "hexa_color" : hexa_color,
    92         "seekPlace" : Math.round(begin/1000)});
    91         "seekPlace" : Math.round(begin/1000)});
    93 
       
    94 
    92 
    95     this.selector.append(annotationTemplate);
    93     this.selector.append(annotationTemplate);
    96 
    94 
    97 //    IriSP.jQuery("#" + id).tooltip({ effect: 'slide'});
    95 //    IriSP.jQuery("#" + id).tooltip({ effect: 'slide'});
    98 
    96 
   174 };
   172 };
   175 
   173 
   176 IriSP.SegmentsWidget.prototype.positionUpdater = function() {  
   174 IriSP.SegmentsWidget.prototype.positionUpdater = function() {  
   177   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
   175   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
   178   var time = this._Popcorn.currentTime();
   176   var time = this._Popcorn.currentTime();
       
   177   //var position 	= ((time / duration) * 100).toFixed(2);
   179   var position 	= ((time / duration) * 100).toFixed(2);
   178   var position 	= ((time / duration) * 100).toFixed(2);
   180 
   179 
   181   this.positionMarker.css("left", position + "%");  
   180   this.positionMarker.css("left", position + "%");  
   182 };
   181 };