src/js/widgets/segmentsWidget.js
branchcalage-segmentsWidget
changeset 509 756ecd1645a5
parent 508 00054959ee92
child 514 f5865a99be69
equal deleted inserted replaced
508:00054959ee92 509:756ecd1645a5
     9   this._Popcorn.listen("IriSP.search.closed", function() { self.searchFieldClosedHandler.call(self); });
     9   this._Popcorn.listen("IriSP.search.closed", function() { self.searchFieldClosedHandler.call(self); });
    10   this._Popcorn.listen("IriSP.search.cleared", function() { self.searchFieldClearedHandler.call(self); });
    10   this._Popcorn.listen("IriSP.search.cleared", function() { self.searchFieldClearedHandler.call(self); });
    11 };
    11 };
    12 
    12 
    13 IriSP.SegmentsWidget.prototype = new IriSP.Widget();
    13 IriSP.SegmentsWidget.prototype = new IriSP.Widget();
       
    14 
       
    15 /* Get the width of a segment, in pixels. */
       
    16 IriSP.SegmentsWidget.prototype.segmentToPixel(annotation) {
       
    17   var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
       
    18   var id = annotation.id;
       
    19   var startPourcent 	= IriSP.timeToPourcent(begin, duration);
       
    20   var startPixel = Math.floor(this.selector.parent().width() * (endPourcent / 100));
       
    21   
       
    22   /* surprisingly, the following code doesn't work on webkit - for some reason, most of the 
       
    23      boxes are 3 pixels smaller.
       
    24   */
       
    25   var endPourcent 	= Math.floor(IriSP.timeToPourcent(end, duration) - startPourcent);
       
    26   var endPixel = Math.floor(this.selector.parent().width() * (endPourcent / 100));
       
    27 };
    14 
    28 
    15 IriSP.SegmentsWidget.prototype.draw = function() {
    29 IriSP.SegmentsWidget.prototype.draw = function() {
    16 
    30 
    17   var self = this;
    31   var self = this;
    18   var annotations = this._serializer._data.annotations;
    32   var annotations = this._serializer._data.annotations;
    54     if (view_type != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
    68     if (view_type != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
    55           && annotation.meta["id-ref"] != view_type) {
    69           && annotation.meta["id-ref"] != view_type) {
    56         continue;
    70         continue;
    57     }
    71     }
    58 
    72 
       
    73     segments_annotations.push(annotation);
    59     var begin = Math.round((+ annotation.begin) / 1000);
    74     var begin = Math.round((+ annotation.begin) / 1000);
    60     var end = Math.round((+ annotation.end) / 1000);
    75     var end = Math.round((+ annotation.end) / 1000);
    61     var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
    76     var duration = this._serializer.currentMedia().meta["dc:duration"] / 1000;
    62     var id = annotation.id;
    77     var id = annotation.id;
    63     var startPourcent 	= IriSP.timeToPourcent(begin, duration);
    78     var startPourcent 	= IriSP.timeToPourcent(begin, duration);