metadataplayer/metadataplayer/Segments.js
changeset 5 e27a08b0a037
parent 1 ed19b689de87
child 15 ed7ac7e94090
--- a/metadataplayer/metadataplayer/Segments.js	Fri Jun 29 12:12:38 2012 +0200
+++ b/metadataplayer/metadataplayer/Segments.js	Wed Aug 22 17:29:27 2012 +0200
@@ -9,20 +9,16 @@
 IriSP.Widgets.Segments.prototype.defaults = {
     annotation_type : "chap",
     colors: ["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],
-    requires : [
-        {
-            type: "Tooltip"
-        }
-    ],
     height: 10
 };
 
 IriSP.Widgets.Segments.prototype.template =
     '<div class="Ldt-Segments-List">{{#segments}}'
-    + '<div class="Ldt-Segments-Segment Ldt-TraceMe" trace-info="segment-id:{{id}}" segment-id="{{id}}" segment-text="{{text}}" segment-color="{{color}}" center-pos="{{center}}" begin-seconds="{{beginseconds}}"'
+    + '<div class="Ldt-Segments-Segment Ldt-TraceMe" trace-info="segment-id:{{id}}, media-id:{{media_id}}" segment-id="{{id}}" segment-text="{{text}}" segment-color="{{color}}" center-pos="{{center}}" begin-seconds="{{beginseconds}}"'
     + 'style="left:{{left}}px; width:{{width}}px; background:{{color}}"></div>'
     + '{{/segments}}</div>'
-    + '<div class="Ldt-Segments-Position"></div>';
+    + '<div class="Ldt-Segments-Position"></div>'
+    + '<div class="Ldt-Segments-Tooltip"></div>';
 
 IriSP.Widgets.Segments.prototype.draw = function() {
     this.bindPopcorn("IriSP.search", "onSearch");
@@ -45,16 +41,18 @@
                 _center = _left + _width / 2,
                 _fulltext = _annotation.title + ( _annotation.description ? ( '<br/>' + _annotation.description ) : '' );
             return {
-                text : _fulltext.replace(/(^.{120,140})[\s].+$/,'$1&hellip;'),
+                text : _fulltext.replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{120,140})[\s].+$/m,'$1&hellip;'),
                 color : ( typeof _annotation.color !== "undefined" && _annotation.color ? _annotation.color : _this.colors[_k % _this.colors.length] ),
                 beginseconds : _annotation.begin.getSeconds() ,
                 left : Math.floor( _left ),
                 width : Math.floor( _width ),
                 center : Math.floor( _center ),
-                id : _annotation.id
+                id : _annotation.id,
+                media_id : _annotation.getMedia().id
             }
         })
     }));
+    this.insertSubwidget(this.$.find(".Ldt-Segments-Tooltip"), "tooltip", { type: "Tooltip" });
     this.$segments = this.$.find('.Ldt-Segments-Segment');
     
     this.$segments.mouseover(function() {
@@ -77,7 +75,7 @@
 IriSP.Widgets.Segments.prototype.onSearch = function(searchString) {
     this.searchString = typeof searchString !== "undefined" ? searchString : '';
     var _found = 0,
-        _re = IriSP.Model.regexpFromTextOrArray(searchString);
+        _re = IriSP.Model.regexpFromTextOrArray(searchString, true);
     if (this.searchString) {
         this.$segments.each(function() {
             var _el = IriSP.jQuery(this);