Corrected metadataplayer bug V01.92
authorRaphael Velt <raph.velt@gmail.com>
Fri, 06 Jul 2012 18:22:13 +0200
changeset 654 a5977736d2b0
parent 653 c4c876db76fb
child 655 529fbf71f876
Corrected metadataplayer bug
web/player_embed.php
web/polemicaltimeline.php
web/res/metadataplayer/Annotation.css
web/res/metadataplayer/Annotation.js
web/res/metadataplayer/AnnotationsList.css
web/res/metadataplayer/AnnotationsList.js
web/res/metadataplayer/Controller.css
web/res/metadataplayer/Controller.js
web/res/metadataplayer/LdtPlayer-core.css
web/res/metadataplayer/LdtPlayer-core.js
web/res/metadataplayer/Polemic.js
web/res/metadataplayer/Segments.js
web/res/metadataplayer/Social.css
web/res/metadataplayer/Social.js
web/res/metadataplayer/Tagcloud.css
web/res/metadataplayer/Tooltip.css
web/res/metadataplayer/Tweet.js
web/res/metadataplayer/img/slice-handles.png
web/res/metadataplayer/img/socialbuttons.png
web/res/metadataplayer/img/widget-control.png
--- a/web/player_embed.php	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/player_embed.php	Fri Jul 06 18:22:13 2012 +0200
@@ -51,7 +51,15 @@
             },
             css:'<?php echo(registry_url('metadataplayer','css'));?>',
             widgets: [
-                { type: "Polemic" },
+<?php
+    if (!isset($config['protocol_level']) || $config['protocol_level'] > 1) {
+        echo '{ type: "Polemic"';
+        if (isset($config['protocol_level']) && $config['protocol_level'] < 3) {
+            echo ', polemics: []';
+        }
+        echo '},';
+    }
+?>
                 { type: "Slider" },
                 {
                     type: "Controller",
--- a/web/polemicaltimeline.php	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/polemicaltimeline.php	Fri Jul 06 18:22:13 2012 +0200
@@ -99,7 +99,15 @@
             },
             css:'<?php echo(registry_url('metadataplayer','css'));?>',
             widgets: [
-                { type: "Polemic" },
+<?php
+    if (!isset($config['protocol_level']) || $config['protocol_level'] > 1) {
+        echo '{ type: "Polemic"';
+        if (isset($config['protocol_level']) && $config['protocol_level'] < 3) {
+            echo ', polemics: []';
+        }
+        echo '},';
+    }
+?>
                 { type: "Slider" },
                 {
                     type: "Controller",
--- a/web/res/metadataplayer/Annotation.css	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Annotation.css	Fri Jul 06 18:22:13 2012 +0200
@@ -23,6 +23,31 @@
     font-weight: bold;
 }
 
+.Ldt-Annotation-Cleared {
+    clear: both;
+}
+
+.Ldt-Annotation-MaxMinButton {
+    float: right; margin: 5px 5px 0; width: 17px; height: 17px;
+    background: url(img/widget-control.png); background-position: 0 -51px; cursor: pointer;
+}
+
+.Ldt-Annotation-Social {
+    float: right;
+}
+
+.Ldt-Annotation-MaxMinButton:hover {
+    background-position: -17px -51px;
+}
+
+.Ldt-Annotation-Minimized div.Ldt-Annotation-MaxMinButton {
+    background-position: 0 -34px;
+}
+
+.Ldt-Annotation-Minimized div.Ldt-Annotation-MaxMinButton:hover {
+    background-position: -17px -34px;
+}
+
 .Ldt-Annotation-Inner h3.Ldt-Annotation-MashupOrigin {
     font-size: 12px;
 }
@@ -36,55 +61,23 @@
 }
 
 .Ldt-Annotation-Inner p {
-    margin: 5px 0; font-size: 12px;
-}
-
-.Ldt-Annotation-ShareIcons {
-    float: right;
-}
-
-.Ldt-Annotation-Share {
-    display: inline-block; width: 24px; height: 24px; margin: 2px 0 0 2px; background: url(img/socialbuttons.png);
-}
-
-.Ldt-Annotation-Twitter {
-    background-position: 0 0;
+    font-size: 12px;
 }
 
-.Ldt-Annotation-Twitter:hover {
-    background-position: 0 -24px;
-}
-
-.Ldt-Annotation-Fb {
-    background-position: -24px 0;
+.Ldt-Annotation-Label {
+    font-size: 12px; font-weight: bold; max-width: 90px; float: left; clear: left;
 }
 
-.Ldt-Annotation-Fb:hover {
-    background-position: -24px -24px;
-}
-
-.Ldt-Annotation-Gplus {
-    background-position: -48px 0;
-}
-
-.Ldt-Annotation-Gplus:hover {
-    background-position: -48px -24px;
+.Ldt-Annotation-Labelled {
+    margin: 5px 0 0 90px; clear: right;
 }
 
 .Ldt-Annotation-Tags-Block {
     font-size: 12px;
 }
 
-.Ldt-Annotation-NoTags {
-    display: none;
-}
-
-.Ldt-Annotation-TagTitle {
-    margin: 5px 0 2px; font-size: 12px;
-}
-
 ul.Ldt-Annotation-Tags {
-    display: inline; list-style: none; padding: 0; margin: 5px 0;
+    list-style: none; padding: 0;
 }
 
 li.Ldt-Annotation-TagLabel {
@@ -122,3 +115,7 @@
     display: none;
 }
 
+.Ldt-Annotation-EmptyBlock {
+    display: none;
+}
+
--- a/web/res/metadataplayer/Annotation.js	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Annotation.js	Fri Jul 06 18:22:13 2012 +0200
@@ -1,67 +1,73 @@
-// TODO: Open share links in a small window - Migrate Timeupdate functions to Extract
+// TODO: Migrate Timeupdate functions to Extract
 
 IriSP.Widgets.Annotation = function(player, config) {
     IriSP.Widgets.Widget.call(this, player, config);
     this.lastAnnotation = false;
+    this.minimized = this.start_minimized || false;
+    this.bounds = [ 0, 0 ];
 };
 
 IriSP.Widgets.Annotation.prototype = new IriSP.Widgets.Widget();
 
 IriSP.Widgets.Annotation.prototype.messages = {
-    "fr": {
-        share_on: "Partager sur",
+    fr: {
         watching: "Je regarde ",
         on_site: " sur ",
-        tags: "Mots-clés&nbsp;:",
+        tags_: "Mots-clés&nbsp;:",
+        description_: "Description&nbsp;:",
         excerpt_from: "Extrait de&nbsp;:"
     },
-    "en": {
-        share_on: "Share on",
+    en: {
         watching: "I'm watching ",
         on_site: " on ",
-        tags: "Keywords:",
+        tags_: "Keywords:",
+        description_: "Description:",
         excerpt_from: "Excerpt from:"
     }
 }
 
 IriSP.Widgets.Annotation.prototype.template =
     '<div class="Ldt-Annotation-Widget {{#show_top_border}}Ldt-Annotation-ShowTop{{/show_top_border}}">'
-    + '<div class="Ldt-Annotation-Inner Ldt-Annotation-Empty"><div class="Ldt-Annotation-ShareIcons Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty">'
-    + '<a href="#" target="_blank" class="Ldt-Annotation-Share Ldt-Annotation-Fb Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>'
-    + '<a href="#" target="_blank" class="Ldt-Annotation-Share Ldt-Annotation-Twitter Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>'
-    + '<a href="#" target="_blank" class="Ldt-Annotation-Share Ldt-Annotation-Gplus Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>'
-    + '</div><h3 class="Ldt-Annotation-HiddenWhenEmpty"><span class="Ldt-Annotation-Title"></span> <span class="Ldt-Annotation-Time">'
+    + '<div class="Ldt-Annotation-Inner Ldt-Annotation-Empty{{#start_minimized}} Ldt-Annotation-Minimized{{/start_minimized}}">'
+    + '<div class="Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-MaxMinButton"></div>'
+    + '<div class="Ldt-Annotation-Social Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty"></div>'
+    + '<h3 class="Ldt-Annotation-HiddenWhenEmpty"><span class="Ldt-Annotation-Title"></span> <span class="Ldt-Annotation-Time">'
     + '( <span class="Ldt-Annotation-Begin"></span> - <span class="Ldt-Annotation-End"></span> )</span></h3>'
     + '<h3 class="Ldt-Annotation-MashupOrigin Ldt-Annotation-HiddenWhenEmpty">{{l10n.excerpt_from}} <span class="Ldt-Annotation-MashupMedia"></span> <span class="Ldt-Annotation-Time">'
     + '( <span class="Ldt-Annotation-MashupBegin"></span> - <span class="Ldt-Annotation-MashupEnd"></span> )</span></h3>'
-    + '<p class="Ldt-Annotation-Description Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty"></p>'
-    + '<div class="Ldt-Annotation-Tags-Block Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-NoTags"><div class="Ldt-Annotation-TagTitle">{{l10n.tags}}</div><ul class="Ldt-Annotation-Tags"></ul></div></div></div>';
+    + '<div class="Ldt-Annotation-Cleared Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-Description-Block"><div class="Ldt-Annotation-Label">{{l10n.description_}}</div>'
+    + '<p class="Ldt-Annotation-Labelled Ldt-Annotation-Description"></p></div>'
+    + '<div class="Ldt-Annotation-Tags-Block Ldt-Annotation-HiddenWhenMinimized Ldt-Annotation-HiddenWhenEmpty Ldt-Annotation-Cleared">'
+    + '<div class="Ldt-Annotation-Label">{{l10n.tags_}}</div><ul class="Ldt-Annotation-Labelled Ldt-Annotation-Tags"></ul>'
+    + '</div></div></div></div>';
 
 IriSP.Widgets.Annotation.prototype.defaults = {
     annotation_type : "chap",
+    start_minimized: false,
     show_top_border : false,
     site_name : "Lignes de Temps"
 }
 
 IriSP.Widgets.Annotation.prototype.draw = function() {
     this.renderTemplate();
+    this.insertSubwidget(this.$.find(".Ldt-Annotation-Social"), "socialWidget", { type: "Social" });
     this.bindPopcorn("timeupdate","onTimeupdate");
     this.bindPopcorn("IriSP.Annotation.hide","hide");
     this.bindPopcorn("IriSP.Annotation.show","show");
     this.bindPopcorn("IriSP.Annotation.minimize","minimize");
     this.bindPopcorn("IriSP.Annotation.maximize","maximize");
+    this.bindPopcorn("IriSP.Annotation.getBounds","sendBounds");
+    this.$.find(".Ldt-Annotation-MaxMinButton").click(this.functionWrapper("toggleSize"));
     this.onTimeupdate();
 }
 
 IriSP.Widgets.Annotation.prototype.onTimeupdate = function() {
     var _time = Math.floor(this.player.popcorn.currentTime() * 1000),
-        _list = this.getWidgetAnnotations().filter(function(_annotation) {
-            return _annotation.begin <= _time && _annotation.end > _time;
-        });
+        _list = this.getWidgetAnnotationsAtTime();
     if (_list.length) {
         if (_list[0].id !== this.lastAnnotation) {
             this.drawAnnotation(_list[0]);
-            this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",[ _list[0].begin.valueOf(), _list[0].end.valueOf() ]);
+            this.bounds = [ _list[0].begin.valueOf(), _list[0].end.valueOf() ];
         }
         this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: ( _list[0].begin + _list[0].end ) / 2});
     }
@@ -69,8 +75,13 @@
         this.lastAnnotation = false;
         this.$.find(".Ldt-Annotation-Inner").addClass("Ldt-Annotation-Empty");
         this.player.popcorn.trigger("IriSP.Arrow.updatePosition",{widget: this.type, time: _time});
-        this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",[ _time, _time ]);
+        this.bounds = [ _time, _time ];
     }
+    this.sendBounds();
+}
+
+IriSP.Widgets.Annotation.prototype.sendBounds = function() {
+    this.player.popcorn.trigger("IriSP.Annotation.boundsChanged",this.bounds);
 }
 
 IriSP.Widgets.Annotation.prototype.drawAnnotation = function(_annotation) {
@@ -85,7 +96,7 @@
             return '<li class="Ldt-Annotation-TagLabel"><span>' + _tag + '</span></li>';
         }).join("");
         this.$.find(".Ldt-Annotation-Tags").html(_html);
-        this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-NoTags");
+        this.$.find(".Ldt-Annotation-Tags-Block").removeClass("Ldt-Annotation-EmptyBlock");
         
         /* Correct the empty tag bug */
         this.$.find('.Ldt-Annotation-TagLabel').each(function() {
@@ -99,10 +110,16 @@
             _this.player.popcorn.trigger("IriSP.search.triggeredSearch", IriSP.jQuery(this).text().replace(/(^\s+|\s+$)/g,''));
         });
     } else {
-        this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-NoTags");
+        this.$.find(".Ldt-Annotation-Tags-Block").addClass("Ldt-Annotation-EmptyBlock");
     }
     this.$.find(".Ldt-Annotation-Title").html(_annotation.title);
-    this.$.find(".Ldt-Annotation-Description").html(_annotation.description);
+    var _desc = _annotation.description.replace(/(^\s+|\s+$)/g,'');
+    if (_desc) {
+        this.$.find(".Ldt-Annotation-Description-Block").removeClass("Ldt-Annotation-EmptyBlock");
+        this.$.find(".Ldt-Annotation-Description").html(_desc);
+    } else {
+        this.$.find(".Ldt-Annotation-Description-Block").addClass("Ldt-Annotation-EmptyBlock");
+    }
     this.$.find(".Ldt-Annotation-Begin").html(_annotation.begin.toString());
     this.$.find(".Ldt-Annotation-End").html(_annotation.end.toString());
     if (_annotation.elementType === "mashedAnnotation") {
@@ -113,9 +130,9 @@
     } else {
         this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-isMashup");
     }
-    this.$.find(".Ldt-Annotation-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text }));
-    this.$.find(".Ldt-Annotation-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text }));
-    this.$.find(".Ldt-Annotation-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text }));
+    if (typeof this.socialWidget !== "undefined") {
+        this.socialWidget.updateUrls(_url, _text);
+    }
     this.$.find(".Ldt-Annotation-Inner").removeClass("Ldt-Annotation-Empty");
 }
 
@@ -127,10 +144,20 @@
     this.$.slideDown();
 }
 
+IriSP.Widgets.Annotation.prototype.toggleSize = function() {
+    if (this.minimized) {
+        this.maximize();
+    } else {
+        this.minimize();
+    }
+}
+
 IriSP.Widgets.Annotation.prototype.minimize = function() {
+    this.minimized = true;
     this.$.find('.Ldt-Annotation-Inner').addClass("Ldt-Annotation-Minimized");
 }
 
 IriSP.Widgets.Annotation.prototype.maximize = function() {
+    this.minimized = false;
     this.$.find('.Ldt-Annotation-Inner').removeClass("Ldt-Annotation-Minimized");
 }
\ No newline at end of file
--- a/web/res/metadataplayer/AnnotationsList.css	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/AnnotationsList.css	Fri Jul 06 18:22:13 2012 +0200
@@ -18,7 +18,7 @@
     min-height: 60px;
 }
 .Ldt-AnnotationsList-li:hover {
-    background: url(img/pinstripe-grey.png);
+    background: url(img/pinstripe-grey.png) !important;
 }
 .Ldt-AnnotationsList-highlight {
     background: #F7268E;
@@ -44,35 +44,41 @@
     font-size: 12px;
     margin: 2px;
 }
-h3.Ldt-AnnotationsList-Title, #accordeon h3.Ldt-AnnotationsList-Title {
+h3.Ldt-AnnotationsList-Title {
     color: #0068c4;
     font-size: 14px;
-    line-height: 1.2em;
-    margin: 0 2px 0 82px;
+    margin: 2px 2px 0 82px;
     font-weight: bold;
 }
-h3.Ldt-AnnotationsList-Title a, #accordeon h3.Ldt-AnnotationsList-Title a {
-    color: #0068c4 ;
+h3.Ldt-AnnotationsList-Title a {
+    color: #0068c4;
 }
-p.Ldt-AnnotationsList-Description, #accordeon p.Ldt-AnnotationsList-Description {
+p.Ldt-AnnotationsList-Description {
     margin: 2px 0 2px 82px;
-    line-height: 1.2em;
     font-size: 12px;
-    color: #666666;
+    color: #333333;
 }
 ul.Ldt-AnnotationsList-Tags {
     list-style: none;
     padding: 0;
-    margin: 2px 0 8px 82px;
+    margin: 2px 0 0 82px;
 }
+
 li.Ldt-AnnotationsList-Tag-Li {
-    display: inline-block;
-    margin: 2px;
-    background: #0068c4;
-    color: #fff;
-    padding: 2px;
-    font-size: 12px;
+    display: inline-block; border: none; margin: 0 10px 5px 0; height: 23px; padding: 0 0 0 20px;
+    background: url(img/tag.png) left top no-repeat;
+    cursor: pointer;
+}
+
+.Ldt-AnnotationsList-Tag-Li span {
+    display: inline-block; font-size: 12px; height: 19px; padding: 4px 5px 0 0; border: none; margin: 0;
+    background: url(img/tag.png) right top no-repeat;
 }
+
 li.Ldt-AnnotationsList-Tag-Li:hover {
-    background: #F7268E;
+    background-position: left -23px;
 }
+
+.Ldt-AnnotationsList-Tag-Li:hover span {
+    background-position: right -23px;
+}
\ No newline at end of file
--- a/web/res/metadataplayer/AnnotationsList.js	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/AnnotationsList.js	Fri Jul 06 18:22:13 2012 +0200
@@ -19,7 +19,7 @@
     /* number of milliseconds before/after the current timecode when calling the segment API
      */
     ajax_granularity : 300000, 
-    default_thumbnail : "http://ldt.iri.centrepompidou.fr/static/site/ldt/css/imgs/video_sequence.png",
+    default_thumbnail : "",
     /* URL when the annotation is not in the current project,
      * e.g. http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/{{media}}/{{project}}/{{annotationType}}#id={{annotation}}
      */
@@ -27,14 +27,27 @@
     annotation_type : false,
     refresh_interval : 0,
     limit_count : 10,
-    newest_first : false
+    newest_first : false,
+    polemics : [{
+        keyword: "++",
+        background_color: "#c9ecc6"
+    },{
+        keyword: "--",
+        background_color: "#f9c5c6"
+    },{
+        keyword: "??",
+        background_color: "#cec5f9"
+    },{
+        keyword: "==",
+        background_color: "#f9f4c6"
+    }]
 };
 
 IriSP.Widgets.AnnotationsList.prototype.template =
     '<div class="Ldt-AnnotationsListWidget">'
     + '<ul class="Ldt-AnnotationsList-ul">'
     + '{{#annotations}}'
-    + '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}">'
+    + '<li class="Ldt-AnnotationsList-li Ldt-TraceMe" trace-info="annotation-id:{{id}}" style="{{specific_style}}">'
     + '<div class="Ldt-AnnotationsList-ThumbContainer">'
     + '<a href="{{url}}">'
     + '<img class="Ldt-AnnotationsList-Thumbnail" src="{{thumbnail}}" />'
@@ -107,7 +120,6 @@
                 begin : Math.max(0, _currentAnnotation.annotation.begin.milliseconds - this.ajax_granularity),
                 end : Math.min(_currentMedia.duration.milliseconds, _currentAnnotation.annotation.end.milliseconds + this.ajax_granularity)
             });
-        console.log("Getting", _url);
         this.currentSource = this.player.loadMetadata(IriSP._.defaults({
             "url" : _url
         }, this.metadata));
@@ -168,23 +180,40 @@
                                 _this.foreign_url,
                                 {
                                     project : _annotation.project,
-                                    media : _annotation.media.id.replace(/^.*:/,''),
+                                    media : _annotation.media.id,
                                     annotation : _annotation.id,
-                                    annotationType : _annotation.annotationType.id.replace(/^.*:/,'')
+                                    annotationType : _annotation.annotationType.id
                                 }
                             )
                             : '#id=' + _annotation.id
                             )
                     );
+                    var _title = (_annotation.title || "").replace(_annotation.description,''),
+                        _description = _annotation.description;
+                    if (!_annotation.title) {
+                        _title = _annotation.creator;
+                    }
+                    if (!_annotation.description && _annotation.creator) {
+                        _description = _annotation.title;
+                        _title = _annotation.creator;
+                    }
+                    var _bgcolor;
+                    IriSP._(_this.polemics).each(function(_polemic) {
+                        var _rgxp = IriSP.Model.regexpFromTextOrArray(_polemic.keyword, true);
+                        if (_rgxp.test(_title + " " + _description)) {
+                            _bgcolor = _polemic.background_color;
+                        }
+                    });
                     var _res = {
                         id : _annotation.id,
-                        title : _annotation.title.replace(_annotation.description,''),
-                        description : _annotation.description,
+                        title : _title,
+                        description : _description,
                         begin : _annotation.begin.toString(),
                         end : _annotation.end.toString(),
                         thumbnail : typeof _annotation.thumbnail !== "undefined" && _annotation.thumbnail ? _annotation.thumbnail : _this.default_thumbnail,
                         url : _url,
-                        tags : _annotation.getTagTexts()
+                        tags : _annotation.getTagTexts(),
+                        specific_style : (typeof _bgcolor !== "undefined" ? "background: " + _bgcolor : "")
                     }
                     return _res;
             }),
@@ -209,7 +238,7 @@
         })
         
         if(this.searchString) {
-            var _searchRe = new RegExp('(' + this.searchString.replace(/(\W)/gm,'\\$1') + ')','gim');
+            var _searchRe = IriSP.Model.regexpFromTextOrArray(this.searchString);
             this.$.find(".Ldt-AnnotationsList-Title a, .Ldt-AnnotationsList-Description").each(function() {
                 var _$ = IriSP.jQuery(this);
                 _$.html(_$.text().replace(/(^\s+|\s+$)/g,'').replace(_searchRe, '<span class="Ldt-AnnotationsList-highlight">$1</span>'))
--- a/web/res/metadataplayer/Controller.css	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Controller.css	Fri Jul 06 18:22:13 2012 +0200
@@ -2,7 +2,6 @@
 
 .Ldt-Ctrl {
   font-size: 10px;
-  font-family: "Trebuchet MS", "Helvetica", "Arial",  "Verdana", "sans-serif";
   background:url('img/player_gradient.png') repeat-x transparent ;
   height: 25px;
   border: 1px solid #b6b8b8;
--- a/web/res/metadataplayer/Controller.js	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Controller.js	Fri Jul 06 18:22:13 2012 +0200
@@ -92,6 +92,7 @@
     this.bindPopcorn("volumechange","volumeUpdater");
     this.bindPopcorn("timeupdate","timeDisplayUpdater");
     this.bindPopcorn("loadedmetadata","timeDisplayUpdater");
+    this.bindPopcorn("loadedmetadata","volumeUpdater");
     this.bindPopcorn("IriSP.search.matchFound","searchMatch");
     this.bindPopcorn("IriSP.search.noMatchFound","searchNoMatch");
     this.bindPopcorn("IriSP.search.triggeredSearch","triggeredSearch");
@@ -139,8 +140,10 @@
         function() {
             _this.player.popcorn.trigger("IriSP.Player.MouseOut");
         });
-    setTimeout(this.functionWrapper("volumeUpdater"), 1000);
     /* some players - including jwplayer - save the state of the mute button between sessions */
+
+    window.setTimeout(this.functionWrapper("volumeUpdater"), 1000);
+   
 };
 
 /* Update the elasped time div */
--- a/web/res/metadataplayer/LdtPlayer-core.css	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/LdtPlayer-core.css	Fri Jul 06 18:22:13 2012 +0200
@@ -9,7 +9,7 @@
 }
 
 .Ldt-Widget {
-    font-family: Arial, Helvetica, sans-serif;
+/*    font-family: Arial, Helvetica, sans-serif; */
     color: black;
     font-size: 12px;
-}
+}
\ No newline at end of file
--- a/web/res/metadataplayer/LdtPlayer-core.js	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/LdtPlayer-core.js	Fri Jul 06 18:22:13 2012 +0200
@@ -152,9 +152,9 @@
 
 IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() {
     
-    /* Getting video URL from metadata if it's not in the player config options */
+    /* Setting default media from metadata */
    
-    if (typeof this.videoData !== "undefined" && typeof this.config.player.video === "undefined") {
+    if (typeof this.videoData !== "undefined") {
         
         var _media;
         
@@ -180,11 +180,12 @@
         
         this.videoData.currentMedia = _media;
         
-        if (typeof _media !== "undefined" && typeof _media.video !== "undefined") {
+        /* Getting video URL from metadata if it's not in the player config options */
+        
+        if (typeof _media !== "undefined" && typeof _media.video !== "undefined" && typeof this.config.player.video === "undefined") {
             this.config.player.video = _media.video;
-            if (typeof _media.streamer !== "undefined") {
+            if (typeof this.config.player.streamer == "undefined" && typeof _media.streamer !== "undefined") {
                 this.config.player.streamer = _media.streamer;
-                this.config.player.video = _media.video.replace(_media.streamer,'');
             }
         }
         
@@ -257,8 +258,12 @@
             var opts = IriSP.jQuery.extend({}, this.config.player);
             delete opts.container;
             delete opts.type;
+            if (typeof opts.streamer !== "undefined") {
+                opts.video = opts.video.replace(opts.streamer,"");
+            }
             opts.file = opts.video;
             delete opts.video;
+            delete opts.metadata;
 
             if(!opts.hasOwnProperty("flashplayer")) {
                 opts.flashplayer = IriSP.getLib("jwPlayerSWF");
@@ -595,19 +600,20 @@
         }
         return "autoid-" + this._ID_BASE + '-' + _n;
     },
-    regexpFromTextOrArray : function(_textOrArray) {
+    regexpFromTextOrArray : function(_textOrArray, _testOnly) {
+        var _testOnly = _testOnly || false;
         function escapeText(_text) {
             return _text.replace(/([\\\*\+\?\|\{\[\}\]\(\)\^\$\.\#\/])/gm, '\\$1');
         }
-        return new RegExp( '('
-            + (
-                typeof _textOrArray === "string"
-                ? escapeText(_textOrArray)
-                : IriSP._(_textOrArray).map(escapeText).join("|")
-            )
-            + ')',
-            'gim'
-        );
+        var _source = 
+            typeof _textOrArray === "string"
+            ? escapeText(_textOrArray)
+            : IriSP._(_textOrArray).map(escapeText).join("|");
+        if (_testOnly) {
+            return new RegExp( _source, 'im');
+        } else {
+            return new RegExp( '(' + _source + ')', 'gim');
+        }
     },
     isoToDate : function(_str) {
         // http://delete.me.uk/2005/03/iso8601.html
@@ -735,21 +741,21 @@
  * here we can search by these criteria
  */
 IriSP.Model.List.prototype.searchByTitle = function(_text) {
-    var _rgxp = IriSP.Model.regexpFromTextOrArray(_text);
+    var _rgxp = IriSP.Model.regexpFromTextOrArray(_text, true);
     return this.filter(function(_element) {
         return _rgxp.test(_element.title);
     });
 }
 
 IriSP.Model.List.prototype.searchByDescription = function(_text) {
-    var _rgxp = IriSP.Model.regexpFromTextOrArray(_text);
+    var _rgxp = IriSP.Model.regexpFromTextOrArray(_text, true);
     return this.filter(function(_element) {
         return _rgxp.test(_element.description);
     });
 }
 
 IriSP.Model.List.prototype.searchByTextFields = function(_text) {
-    var _rgxp =  IriSP.Model.regexpFromTextOrArray(_text);
+    var _rgxp =  IriSP.Model.regexpFromTextOrArray(_text, true);
     return this.filter(function(_element) {
         return _rgxp.test(_element.description) || _rgxp.test(_element.title);
     });
@@ -1477,18 +1483,6 @@
     this.$ = IriSP.jQuery('#' + this.container);
     this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type);
     
-    /* Does the widget require other widgets ? */
-    if (typeof this.requires !== "undefined") {
-        for (var _i = 0; _i < this.requires.length; _i++) {
-            var _subconfig = this.requires[_i];
-            _subconfig.container = IriSP._.uniqueId(this.container + '_' + _subconfig.type + '_');
-            this.$.append(IriSP.jQuery('<div>').attr("id",_subconfig.container));
-            this.player.loadWidget(_subconfig, function(_widget) {
-                _this[_subconfig.type.replace(/^./,function(_s){return _s.toLowerCase();})] = _widget
-            });
-        }
-    }
-    
     this.l10n = (
         typeof this.messages[IriSP.language] !== "undefined"
         ? this.messages[IriSP.language]
@@ -1543,6 +1537,19 @@
     });
 }
 
+IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _propname, _widgetoptions) {
+    var _id = _selector.attr("id"),
+        _this = this;
+    if (typeof _id == "undefined") {
+        _id = IriSP._.uniqueId(this.container + '_sub_widget_' + _widgetoptions.type);
+        _selector.attr("id", _id);
+    }
+    _widgetoptions.container = _id;
+    _this.player.loadWidget(_widgetoptions, function(_widget) {
+        _this[_propname] = _widget;
+    });
+}
+
 /**
  * This method responsible of drawing a widget on screen.
  */
@@ -1808,18 +1815,25 @@
 IriSP.PopcornReplacement.jwplayer = function(container, options) {
     /* appel du parent pour initialiser les structures communes à tous les players */
     IriSP.PopcornReplacement.player.call(this, container, options);
-  
-    this.media.duration = options.duration; /* optional */
+    
+    if (options.autostart) {
+        this.media.paused = false;
+        this.trigger("play");
+    }
  
     var _player = jwplayer(this.container),
-        _this = this;
+        _this = this,
+        _seekPause = false;
   
   /* Définition des fonctions de l'API -  */
     this.playerFns = {
         play: function() { return _player.play(true); },
         pause: function() { return _player.pause(true); },
         getPosition: function() { return _player.getPosition(); },
-        seek: function(pos) { return _player.seek(pos); },
+        seek: function(pos) {
+            _seekPause = _this.media.paused;
+            return _player.seek(pos);
+        },
         getMute: function() { return _player.getMute() },
         setMute: function(p) { return _player.setMute(p); },
         getVolume: function() { return _player.getVolume() / 100; },
@@ -1831,15 +1845,22 @@
             _this.trigger("loadedmetadata");
         },
         onTime:   function() {
-            if (_this.media.paused && _player.getState() === "PLAYING") {
-                _this.media.paused = false;
-                _this.trigger("play");
+            if (_seekPause) {
+                _player.pause(true);
+                _seekPause = false;
+            } else {
+                if (_this.media.paused && _player.getState() === "PLAYING") {
+                    _this.media.paused = false;
+                    _this.trigger("play");
+                }
             }
             _this.trigger("timeupdate");
         },
         onPlay:   function() {
-            _this.media.paused = false;
-            _this.trigger("play");
+            if (!_seekPause) {
+                _this.media.paused = false;
+                _this.trigger("play");
+            }
         },
         onPause:  function() {
             _this.media.paused = true;
@@ -2438,7 +2459,7 @@
             var _anndata = _data.annotations[0],
                 _ann = new IriSP.Model.Annotation(_anndata.id, _source);
             _ann.description = _anndata.content.data || "";
-            _ann.title = _data.creator;
+            _ann.title = _data.creator || "";
             _ann.created = new Date(_data.meta.created);
             _ann.setMedia(_anndata.media, _source);
             var _anntypes = _source.getAnnotationTypes(true).searchByTitle(_anndata.type_title);
--- a/web/res/metadataplayer/Polemic.js	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Polemic.js	Fri Jul 06 18:22:13 2012 +0200
@@ -40,18 +40,13 @@
             "keywords" : [ "?" ],
             "color" : "#036AAE"
         }
-    ],
-    requires : [
-        {
-            type: "Tooltip"
-        }
     ]
 };
 
 IriSP.Widgets.Polemic.prototype.onSearch = function(searchString) {
     this.searchString = typeof searchString !== "undefined" ? searchString : '';
     var _found = 0,
-        _re = IriSP.Model.regexpFromTextOrArray(searchString),
+        _re = IriSP.Model.regexpFromTextOrArray(searchString, true),
         _this = this;
     this.$tweets.each(function() {
         var _el = IriSP.jQuery(this);
@@ -287,6 +282,10 @@
         var _x = _e.pageX - _this.$zone.offset().left;
         _this.player.popcorn.currentTime(_this.source.getDuration().getSeconds() * _x / _this.width);
     });
+    
+    this.$.append('<div class="Ldt-Polemic-Tooltip"></div>');
+    
+    this.insertSubwidget(this.$.find(".Ldt-Polemic-Tooltip"), "tooltip", { type: "Tooltip" });
 }
 
 IriSP.Widgets.Polemic.prototype.onTimeupdate = function() {
--- a/web/res/metadataplayer/Segments.js	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Segments.js	Fri Jul 06 18:22:13 2012 +0200
@@ -9,11 +9,6 @@
 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
 };
 
@@ -22,7 +17,8 @@
     + '<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}}"'
     + '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");
@@ -55,6 +51,7 @@
             }
         })
     }));
+    this.insertSubwidget(this.$.find(".Ldt-Segments-Tooltip"), "tooltip", { type: "Tooltip" });
     this.$segments = this.$.find('.Ldt-Segments-Segment');
     
     this.$segments.mouseover(function() {
@@ -77,7 +74,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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/res/metadataplayer/Social.css	Fri Jul 06 18:22:13 2012 +0200
@@ -0,0 +1,35 @@
+.Ldt-Social a {
+    display: inline-block; width: 24px; height: 24px; margin: 2px 0 0 2px; background: url(img/socialbuttons.png);
+}
+
+a.Ldt-Social-Twitter {
+    background-position: 0 0;
+}
+
+a.Ldt-Social-Twitter:hover {
+    background-position: 0 -24px;
+}
+
+a.Ldt-Social-Fb {
+    background-position: -24px 0;
+}
+
+a.Ldt-Social-Fb:hover {
+    background-position: -24px -24px;
+}
+
+a.Ldt-Social-Gplus {
+    background-position: -48px 0;
+}
+
+a.Ldt-Social-Gplus:hover {
+    background-position: -48px -24px;
+}
+
+a.Ldt-Social-Mail {
+    background-position: -72px 0;
+}
+
+a.Ldt-Social-Mail:hover {
+    background-position: -72px -24px;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/res/metadataplayer/Social.js	Fri Jul 06 18:22:13 2012 +0200
@@ -0,0 +1,45 @@
+// TODO: Open share links in a small window
+
+IriSP.Widgets.Social = function(player, config) {
+    IriSP.Widgets.Widget.call(this, player, config);
+}
+
+IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget();
+
+IriSP.Widgets.Social.prototype.defaults = {
+    text: "",
+    url: "",
+    show_twitter: true,
+    show_fb: true,
+    show_gplus: true,
+    show_mail: true
+}
+
+IriSP.Widgets.Social.prototype.template =
+    '<span class="Ldt-Social">{{#show_fb}}<a href="#" target="_blank" class="Ldt-Social-Fb Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>{{/show_fb}}'
+    + '{{#show_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}'
+    + '{{#show_gplus}}<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>{{/show_gplus}}'
+    + '{{#show_mail}}<a href="#" target="_blank" class="Ldt-Social-Mail Ldt-TraceMe" title="{{l10n.share_mail}}"></a>{{/show_mail}}</span>';
+
+IriSP.Widgets.Social.prototype.messages = {
+    "fr": {
+        share_on: "Partager sur",
+        share_mail: "Envoyer par courriel"
+    },
+    "en" : {
+        share_on: "Share on",
+        share_mail: "Share by e-mail"
+    }
+}
+
+IriSP.Widgets.Social.prototype.draw = function() {
+    this.renderTemplate();
+    this.updateUrls(this.url, this.text);
+}
+
+IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) {
+    this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text }));
+    this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text }));
+    this.$.find(".Ldt-Social-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text }));
+    this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url }));
+}
--- a/web/res/metadataplayer/Tagcloud.css	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Tagcloud.css	Fri Jul 06 18:22:13 2012 +0200
@@ -2,7 +2,6 @@
  * 
  */
 .Ldt-Tagcloud-Container {
-    font-family: "Open Sans", Arial, Helvetica, sans-serif;
 }
 
 ul.Ldt-Tagcloud-List {
--- a/web/res/metadataplayer/Tooltip.css	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Tooltip.css	Fri Jul 06 18:22:13 2012 +0200
@@ -7,7 +7,7 @@
   font-size: 12px;
   padding: 15px 15px 20px;
   color: black;
-  font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";
+  font-family: Arial, Helvetica, sans-serif;
   overflow:hidden;
 }
 
--- a/web/res/metadataplayer/Tweet.js	Tue Jul 03 18:19:39 2012 +0200
+++ b/web/res/metadataplayer/Tweet.js	Fri Jul 06 18:22:13 2012 +0200
@@ -1,5 +1,3 @@
-/* TODO: Show Twitter Links in a small Window */
-
 IriSP.Widgets.Tweet = function(player, config) {
     IriSP.Widgets.Widget.call(this, player, config);
     this.lastAnnotation = false;
Binary file web/res/metadataplayer/img/slice-handles.png has changed
Binary file web/res/metadataplayer/img/socialbuttons.png has changed
Binary file web/res/metadataplayer/img/widget-control.png has changed