src/js/widgets/segmentsWidget.js
author veltr
Tue, 06 Mar 2012 13:26:51 +0100
branchpopcorn-port
changeset 829 ae16691d183d
parent 827 1dc2f85c3b89
child 834 573c7ca752e0
permissions -rw-r--r--
Corrected segments widget, added excludePattern option to tagcloud widget
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) {
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
     2
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
     3
  var self = this;
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
     4
  IriSP.Widget.call(this, Popcorn, config, Serializer);
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
     5
  this.oldSearchMatches = [];
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
     6
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
     7
  // event handlers
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
     8
  this._Popcorn.listen("IriSP.search", function(searchString) { self.searchHandler.call(self, searchString); });
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
     9
  this._Popcorn.listen("IriSP.search.closed", function() { self.searchFieldClosedHandler.call(self); });
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
    10
  this._Popcorn.listen("IriSP.search.cleared", function() { self.searchFieldClearedHandler.call(self); });
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    11
};
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    12
139
ba2b3c15bd47 fixing prototype bug.
hamidouk
parents: 132
diff changeset
    13
IriSP.SegmentsWidget.prototype = new IriSP.Widget();
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    14
509
756ecd1645a5 defined a func to compute the width in pixels of a segment.
hamidouk
parents: 508
diff changeset
    15
/* Get the width of a segment, in pixels. */
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    16
IriSP.SegmentsWidget.prototype.segmentToPixel = function(annotation) {  
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    17
  var begin = Math.round((+ annotation.begin) / 1000);
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    18
  var end = Math.round((+ annotation.end) / 1000);    
820
7968346b9689 Added compatibility with cinecast format (with get_aliased)
veltr
parents: 771
diff changeset
    19
  var duration = this._serializer.getDuration() / 1000;
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    20
  
509
756ecd1645a5 defined a func to compute the width in pixels of a segment.
hamidouk
parents: 508
diff changeset
    21
  var startPourcent 	= IriSP.timeToPourcent(begin, duration);
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    22
  var startPixel = Math.floor(this.selector.parent().width() * (startPourcent / 100));
509
756ecd1645a5 defined a func to compute the width in pixels of a segment.
hamidouk
parents: 508
diff changeset
    23
  
756ecd1645a5 defined a func to compute the width in pixels of a segment.
hamidouk
parents: 508
diff changeset
    24
  var endPourcent 	= Math.floor(IriSP.timeToPourcent(end, duration) - startPourcent);
756ecd1645a5 defined a func to compute the width in pixels of a segment.
hamidouk
parents: 508
diff changeset
    25
  var endPixel = Math.floor(this.selector.parent().width() * (endPourcent / 100));
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    26
  
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    27
  return endPixel;
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    28
};
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    29
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    30
/* compute the total length of a group of segments */
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    31
IriSP.SegmentsWidget.prototype.segmentsLength = function(segmentsList) {
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    32
  var self = this;
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    33
  var total = 0;
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    34
  
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    35
  for (var i = 0; i < segmentsList.length; i++)
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    36
    total += self.segmentToPixel(segmentsList[i].annotation);
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    37
  
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    38
  return total;  
509
756ecd1645a5 defined a func to compute the width in pixels of a segment.
hamidouk
parents: 508
diff changeset
    39
};
756ecd1645a5 defined a func to compute the width in pixels of a segment.
hamidouk
parents: 508
diff changeset
    40
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    41
IriSP.SegmentsWidget.prototype.draw = function() {
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    42
148
5e877acd85ca added a function to handle search messages.
hamidouk
parents: 139
diff changeset
    43
  var self = this;
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    44
  var annotations = this._serializer._data.annotations;
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
    45
334
e20f97514d44 move the styling of a segment from the templates to the css.
hamidouk
parents: 321
diff changeset
    46
  this.selector.addClass("Ldt-SegmentsWidget");
229
808768eb5930 rewriting the slider-port to not use jquery ui slider.
hamidouk
parents: 223
diff changeset
    47
  this.selector.append(Mustache.to_html(IriSP.overlay_marker_template));
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    48
          
593
a4c63f13f021 adapting the widget to the new convention.
hamidouk
parents: 552
diff changeset
    49
  var view_type = this._serializer.getChapitrage();
637
d6f477188c0a disable changing the default color of a segment.
hamidouk
parents: 593
diff changeset
    50
  if (typeof(view_type) === "undefined") {
d6f477188c0a disable changing the default color of a segment.
hamidouk
parents: 593
diff changeset
    51
    view_type = this._serializer.getNonTweetIds()[0];  
d6f477188c0a disable changing the default color of a segment.
hamidouk
parents: 593
diff changeset
    52
  }
829
ae16691d183d Corrected segments widget, added excludePattern option to tagcloud widget
veltr
parents: 827
diff changeset
    53
  this.positionMarker = this.selector.find(".Ldt-SegmentPositionMarker");
217
ec3e6d34462c fixed css positioning bug.
hamidouk
parents: 214
diff changeset
    54
  
214
50c4609e50f4 WIP - added a div that should move over the widget.
hamidouk
parents: 212
diff changeset
    55
  this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.positionUpdater));
771
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
    56
212
3a6e4089eef0 fixed teh segments display bug and another bug related to float positioning.
hamidouk
parents: 210
diff changeset
    57
  
104
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
    58
  var i = 0;
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    59
  
508
00054959ee92 began working on pixel-precise segmentWidget positioning.
hamidouk
parents: 483
diff changeset
    60
  var segments_annotations = [];
00054959ee92 began working on pixel-precise segmentWidget positioning.
hamidouk
parents: 483
diff changeset
    61
  
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
    62
  for (i = 0; i < annotations.length; i++) {
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
    63
    var annotation = annotations[i];
104
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
    64
300
a50aea26ec89 fixed annotation bug in the segmentswidget - we were displaying every annotation,
hamidouk
parents: 229
diff changeset
    65
    /* filter the annotations whose type is not the one we want */
a50aea26ec89 fixed annotation bug in the segmentswidget - we were displaying every annotation,
hamidouk
parents: 229
diff changeset
    66
    if (view_type != "" && typeof(annotation.meta) !== "undefined" && typeof(annotation.meta["id-ref"]) !== "undefined"
a50aea26ec89 fixed annotation bug in the segmentswidget - we were displaying every annotation,
hamidouk
parents: 229
diff changeset
    67
          && annotation.meta["id-ref"] != view_type) {
a50aea26ec89 fixed annotation bug in the segmentswidget - we were displaying every annotation,
hamidouk
parents: 229
diff changeset
    68
        continue;
a50aea26ec89 fixed annotation bug in the segmentswidget - we were displaying every annotation,
hamidouk
parents: 229
diff changeset
    69
    }
a50aea26ec89 fixed annotation bug in the segmentswidget - we were displaying every annotation,
hamidouk
parents: 229
diff changeset
    70
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    71
    segments_annotations.push(annotation);
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    72
  }
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    73
    
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    74
  var totalWidth = this.selector.width() - segments_annotations.length;
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    75
  var lastSegment = IriSP.underscore.max(segments_annotations, function(annotation) { return annotation.end; });
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    76
  
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    77
  for (i = 0; i < segments_annotations.length; i++) {
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
    78
  
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    79
    var annotation = segments_annotations[i];
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    80
    var begin = (+ annotation.begin);
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    81
    var end = (+ annotation.end);
820
7968346b9689 Added compatibility with cinecast format (with get_aliased)
veltr
parents: 771
diff changeset
    82
    var duration = this._serializer.getDuration();
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
    83
    var id = annotation.id;
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    84
        
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    85
    var startPixel = Math.floor(this.selector.parent().width() * (begin / duration));
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
    86
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    87
    var endPixel = Math.floor(this.selector.parent().width() * (end / duration));
516
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
    88
    
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
    89
    if (annotation.id !== lastSegment.id) 
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
    90
      var pxWidth = endPixel - startPixel -1;
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
    91
    else
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
    92
      /* the last segment has no segment following it */
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
    93
      var pxWidth = endPixel - startPixel;
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
    94
 
687
3583e8b447f5 cleanly the segments title.
hamidouk
parents: 638
diff changeset
    95
    var divTitle = IriSP.clean_substr(annotation.content.title + " -<br>" + annotation.content.description, 0, 132) + "...";
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
    96
473
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
    97
    if (typeof(annotation.content.color) !== "undefined")
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
    98
      var color = annotation.content.color;
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
    99
    else
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
   100
      var color = annotation.color;
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
   101
    
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
   102
    var hexa_color = IriSP.DEC_HEXA_COLOR(color);
479
24308670f1bb fixed the display of colors.
hamidouk
parents: 477
diff changeset
   103
637
d6f477188c0a disable changing the default color of a segment.
hamidouk
parents: 593
diff changeset
   104
    /*
473
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
   105
    if (hexa_color === "FFCC00")
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
   106
      hexa_color = "333";
637
d6f477188c0a disable changing the default color of a segment.
hamidouk
parents: 593
diff changeset
   107
    */
479
24308670f1bb fixed the display of colors.
hamidouk
parents: 477
diff changeset
   108
    if (hexa_color.length == 4)
24308670f1bb fixed the display of colors.
hamidouk
parents: 477
diff changeset
   109
      hexa_color = hexa_color + '00';
473
1a09ab7e7163 fixed display bugs in segmentsWidget
hamidouk
parents: 464
diff changeset
   110
    
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
   111
    var annotationTemplate = Mustache.to_html(IriSP.annotation_template,
514
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
   112
        {"divTitle" : divTitle, "id" : id, "startPixel" : startPixel,
f5865a99be69 WIP - first version of the rounding algorithm.
hamidouk
parents: 509
diff changeset
   113
        "pxWidth" : pxWidth, "hexa_color" : hexa_color,
100
dbd302a995f5 added a new widget and the tests which come with it.
hamidouk
parents:
diff changeset
   114
        "seekPlace" : Math.round(begin/1000)});
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   115
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
   116
        
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   117
    this.selector.append(annotationTemplate);
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
   118
    
516
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
   119
    /* add a special class to the last segment and change its border */
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
   120
    if (annotation.id === lastSegment.id) {
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
   121
        this.selector.find("#" + id).addClass("Ldt-lastSegment");        
516
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
   122
        this.selector.find(".Ldt-lastSegment").css("border-color", "#" + hexa_color);        
515
54324c5d82ab got a more or less correct (+- 1px) version of the segmentsWidget.
hamidouk
parents: 514
diff changeset
   123
    }
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   124
212
3a6e4089eef0 fixed teh segments display bug and another bug related to float positioning.
hamidouk
parents: 210
diff changeset
   125
    IriSP.jQuery("#" + id).fadeTo(0, 0.3);
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   126
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   127
    IriSP.jQuery("#" + id).mouseover(
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   128
    /* we wrap the handler in another function because js's scoping
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   129
       rules are function-based - otherwise, the internal vars like
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   130
       divTitle are preserved but they are looked-up from the draw
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   131
       method scope, so after that the loop is run, so they're not
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   132
       preserved */
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   133
    (function(divTitle) { 
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   134
     return function(event) {
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   135
          IriSP.jQuery(this).animate({opacity: 0.6}, 5);
827
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 820
diff changeset
   136
          var offset_x = IriSP.jQuery(this).position().left + IriSP.jQuery(this).outerWidth() / 2;
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   137
827
1dc2f85c3b89 BUGFIX: Tooltips are now positioned relative to their parent widget.
veltr
parents: 820
diff changeset
   138
          self.TooltipWidget.show(divTitle, color, offset_x, 0);
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   139
    } })(divTitle)).mouseout(function(){
334
e20f97514d44 move the styling of a segment from the templates to the css.
hamidouk
parents: 321
diff changeset
   140
      IriSP.jQuery(this).animate({opacity: 0.3}, 5);
336
8da13562cfea segmentsWidget now uses the TooltipWidget instead of the jQuerytools tooltip.
hamidouk
parents: 334
diff changeset
   141
      self.TooltipWidget.hide();
104
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
   142
    });
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   143
771
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   144
    // react to mediafragment messages.
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   145
    this._Popcorn.listen("IriSP.Mediafragment.showAnnotation", 
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   146
      function(id, divTitle) { 
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   147
      return function(annotation_id) { 
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   148
        if (annotation_id !== id)
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   149
          return;
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   150
        
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   151
          var divObject = IriSP.jQuery("#" + id);
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   152
          divObject.animate({opacity: 0.6}, 5);
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   153
          var offset = divObject.offset();
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   154
          var correction = divObject.outerWidth() / 2;
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   155
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   156
          var offset_x = offset.left + correction - 106;
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   157
          if (offset_x < 0)
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   158
            offset_x = 0;
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   159
          
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   160
          var offset_y = offset.top;          
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   161
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   162
          self.TooltipWidget.show(divTitle, color, offset_x, offset_y - 160);
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   163
          IriSP.jQuery(document).one("mousemove", function() { divObject.animate({opacity: 0.3}, 5);
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   164
                                                                self.TooltipWidget.hide(); });
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   165
      }; }(id, divTitle));
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   166
    
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   167
    IriSP.jQuery("#" + id).click(function(_this, annotation) {
104
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
   168
                                    return function() { _this.clickHandler(annotation)};
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
   169
                                 }(this, annotation));
771
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   170
    }
104
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
   171
};
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
   172
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   173
/* restores the view after a search */
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   174
IriSP.SegmentsWidget.prototype.clear = function() {
516
fe8c9f4791cb added a pixel to the last segment. Made search play nice with the borders.
hamidouk
parents: 515
diff changeset
   175
  this.selector.children(".Ldt-iri-chapter").animate({opacity:0.3}, 100);
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   176
};
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   177
104
d571e9020092 fixed the segments widget.
hamidouk
parents: 100
diff changeset
   178
IriSP.SegmentsWidget.prototype.clickHandler = function(annotation) {
464
dd543fb9d38a trigger a signal when a segment is clicked.
hamidouk
parents: 418
diff changeset
   179
  this._Popcorn.trigger("IriSP.SegmentsWidget.click", annotation.id);
313
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 304
diff changeset
   180
  var begin = (+ annotation.begin) / 1000;
392
ef4e6b0fec17 fixed elusive bug.
hamidouk
parents: 380
diff changeset
   181
  this._Popcorn.currentTime(Math.round(begin));
108
62da43e72e30 broke the serializers across multiple files. added a newline to the end of
hamidouk
parents: 104
diff changeset
   182
};
148
5e877acd85ca added a function to handle search messages.
hamidouk
parents: 139
diff changeset
   183
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   184
IriSP.SegmentsWidget.prototype.searchHandler = function(searchString) {
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   185
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   186
  if (searchString == "")
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   187
    return;
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   188
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   189
  var matches = this._serializer.searchOccurences(searchString);
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   190
355
d8df77c40676 fixed search field coloring.
hamidouk
parents: 353
diff changeset
   191
  if (IriSP.countProperties(matches) > 0) {
398
d1883378b822 renamed search signal.
hamidouk
parents: 397
diff changeset
   192
    this._Popcorn.trigger("IriSP.search.matchFound");
355
d8df77c40676 fixed search field coloring.
hamidouk
parents: 353
diff changeset
   193
  } else {
398
d1883378b822 renamed search signal.
hamidouk
parents: 397
diff changeset
   194
    this._Popcorn.trigger("IriSP.search.noMatchFound");
355
d8df77c40676 fixed search field coloring.
hamidouk
parents: 353
diff changeset
   195
  }
d8df77c40676 fixed search field coloring.
hamidouk
parents: 353
diff changeset
   196
397
eb54152c2cfa fixed search to follow samuel's directives.
hamidouk
parents: 380
diff changeset
   197
  // un-highlight all the blocks
eb54152c2cfa fixed search to follow samuel's directives.
hamidouk
parents: 380
diff changeset
   198
  this.selector.children(".Ldt-iri-chapter").css("opacity", 0.1);
eb54152c2cfa fixed search to follow samuel's directives.
hamidouk
parents: 380
diff changeset
   199
 
eb54152c2cfa fixed search to follow samuel's directives.
hamidouk
parents: 380
diff changeset
   200
  // then highlight the ones with matches.
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   201
  for (var id in matches) {
380
4b74494bd129 fixed highlighting factor. Removed printf.
hamidouk
parents: 355
diff changeset
   202
    var factor = 0.5 + matches[id] * 0.2;
223
f14172bdea28 fixed annoying search clear display bug.
hamidouk
parents: 222
diff changeset
   203
    this.selector.find("#"+id).dequeue();
353
21f3a1d501eb changed the way the segmentsWidget highlights the matching segments.
hamidouk
parents: 336
diff changeset
   204
    this.selector.find("#"+id).animate({opacity:factor}, 200);
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   205
  }
164
d335ee5533c5 cosmetic changes.
hamidouk
parents: 157
diff changeset
   206
397
eb54152c2cfa fixed search to follow samuel's directives.
hamidouk
parents: 380
diff changeset
   207
 
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   208
  this.oldSearchMatches = matches;
148
5e877acd85ca added a function to handle search messages.
hamidouk
parents: 139
diff changeset
   209
};
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   210
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   211
IriSP.SegmentsWidget.prototype.searchFieldClearedHandler = function() {
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   212
  this.clear();
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   213
};
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   214
152
5950ab2855a8 added a comment.
hamidouk
parents: 148
diff changeset
   215
IriSP.SegmentsWidget.prototype.searchFieldClosedHandler = function() {
154
6e115a094858 another tweak to the searchBox : the visualization is cleared when the searchbox
hamidouk
parents: 152
diff changeset
   216
  this.clear();
214
50c4609e50f4 WIP - added a div that should move over the widget.
hamidouk
parents: 212
diff changeset
   217
};
50c4609e50f4 WIP - added a div that should move over the widget.
hamidouk
parents: 212
diff changeset
   218
50c4609e50f4 WIP - added a div that should move over the widget.
hamidouk
parents: 212
diff changeset
   219
IriSP.SegmentsWidget.prototype.positionUpdater = function() {  
820
7968346b9689 Added compatibility with cinecast format (with get_aliased)
veltr
parents: 771
diff changeset
   220
  var duration = this._serializer.getDuration() / 1000;
214
50c4609e50f4 WIP - added a div that should move over the widget.
hamidouk
parents: 212
diff changeset
   221
  var time = this._Popcorn.currentTime();
483
0bb36c79836c fixed positioning bug.
hamidouk
parents: 479
diff changeset
   222
  //var position 	= ((time / duration) * 100).toFixed(2);
217
ec3e6d34462c fixed css positioning bug.
hamidouk
parents: 214
diff changeset
   223
  var position 	= ((time / duration) * 100).toFixed(2);
ec3e6d34462c fixed css positioning bug.
hamidouk
parents: 214
diff changeset
   224
ec3e6d34462c fixed css positioning bug.
hamidouk
parents: 214
diff changeset
   225
  this.positionMarker.css("left", position + "%");  
300
a50aea26ec89 fixed annotation bug in the segmentswidget - we were displaying every annotation,
hamidouk
parents: 229
diff changeset
   226
};
771
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   227
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   228
IriSP.SegmentsWidget.prototype.showAnnotation = function() {
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   229
0a5194b39ffb highlight an annotation when mediafragment tells us so.
hamidouk
parents: 687
diff changeset
   230
};