Bugfixes
authorveltr
Thu, 17 Jan 2013 17:25:46 +0100
changeset 987 7b65bf78873a
parent 986 f9d51dd4a3fe
child 988 eefd336335f9
Bugfixes
src/js/init.js
src/js/model.js
src/widgets/AdaptivePlayer.js
src/widgets/AutoPlayer.js
src/widgets/HtmlPlayer.js
src/widgets/JwpPlayer.js
src/widgets/Mediafragment.js
src/widgets/Polemic.js
src/widgets/PopcornPlayer.js
src/widgets/Tooltip.css
src/widgets/Tooltip.js
src/widgets/Tweet.js
test/youtube.htm
--- a/src/js/init.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/js/init.js	Thu Jan 17 17:25:46 2013 +0100
@@ -104,17 +104,17 @@
     });
     this.$.find('.Ldt-Loader').detach();
     
-    var endload = false;
+    this.widgetsLoaded = false;
     
     this.on("widget-loaded", function() {
-        if (endload) {
+        if (_this.widgetsLoaded) {
             return;
         }
         var isloaded = !IriSP._(_this.widgets).any(function(w) {
             return !(w && w.isLoaded())
         });
         if (isloaded) {
-            endload = true;
+            _this.widgetsLoaded = true;
             _this.trigger("widgets-loaded");
         }
     });   
--- a/src/js/model.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/js/model.js	Thu Jan 17 17:25:46 2013 +0100
@@ -548,6 +548,7 @@
     this.volume = .5;
     this.paused = true;
     this.muted = false;
+    this.loadedMetadata = false;
     var _this = this;
     this.on("play", function() {
         _this.paused = false;
@@ -572,6 +573,9 @@
             _this.trigger("enter-annotation",_a);
         });
     });
+    this.on("loadedmetadata", function() {
+        _this.loadedMetadata = true;
+    })
 }
 
 Model.Playable.prototype = new Model.Element();
--- a/src/widgets/AdaptivePlayer.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/AdaptivePlayer.js	Thu Jan 17 17:25:46 2013 +0100
@@ -6,7 +6,7 @@
 
 IriSP.Widgets.AdaptivePlayer.prototype.defaults = {
     mime_type: "video/mp4",
-    normal_player: "PopcornPlayer",
+    normal_player: "HtmlPlayer",
     fallback_player: "JwpPlayer"
 }
 
--- a/src/widgets/AutoPlayer.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/AutoPlayer.js	Thu Jan 17 17:25:46 2013 +0100
@@ -27,7 +27,7 @@
             },
             {
                 regexp: /\.(ogg|ogv|webm)$/,
-                type: "PopcornPlayer"
+                type: "HtmlPlayer"
             },
             {
                 regexp: /^(https?:\/\/)?(www\.)?youtube\.com/,
@@ -57,7 +57,7 @@
     
     if (_opts.type === "AdaptivePlayer") {
         var _canPlayType = document.createElement('video').canPlayType("video/mp4");
-        _opts.type = (_canPlayType == "maybe" || _canPlayType == "probably") ? "PopcornPlayer" : "JwpPlayer";
+        _opts.type = (_canPlayType == "maybe" || _canPlayType == "probably") ? "HtmlPlayer" : "JwpPlayer";
     }
     
     if (_rtmprgx.test(this.video)) {
--- a/src/widgets/HtmlPlayer.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/HtmlPlayer.js	Thu Jan 17 17:25:46 2013 +0100
@@ -6,7 +6,6 @@
 
 
 IriSP.Widgets.HtmlPlayer.prototype.defaults = {
-    aspect_ratio: 14/9
 }
 
 IriSP.Widgets.HtmlPlayer.prototype.draw = function() {
@@ -19,19 +18,11 @@
     if (this.url_transform) {
         this.video = this.url_transform(this.video);
     }
-    
-    if (!this.height) {
-        this.height = Math.floor(this.width/this.aspect_ratio);
-        this.$.css({
-                height: this.height
-            });
-    }
         
     var videoEl = IriSP.jQuery('<video>');
     videoEl.attr({
-        id : _tmpId,
         width : this.width,
-        height : this.height
+        height : this.height || undefined
     });
     if(typeof this.video === "string"){
         videoEl.attr("src",this.video);
--- a/src/widgets/JwpPlayer.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/JwpPlayer.js	Thu Jan 17 17:25:46 2013 +0100
@@ -36,7 +36,9 @@
     _opts.flashplayer = IriSP.getLib("jwPlayerSWF");
     _opts["controlbar.position"] = "none";
     _opts.width = this.width;
-    _opts.height = this.height || Math.floor(.643*this.width);
+    if (this.height) {
+        _opts.height = this.height;
+    }
     
     for (var i = 0; i < _props.length; i++) {
         if (typeof this[_props[i]] !== "undefined") {
--- a/src/widgets/Mediafragment.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/Mediafragment.js	Thu Jan 17 17:25:46 2013 +0100
@@ -18,16 +18,18 @@
 IriSP.Widgets.Mediafragment.prototype = new IriSP.Widgets.Widget();
 
 IriSP.Widgets.Mediafragment.prototype.draw = function() {
-    this.onMediaEvent("pause","setHashToTime");
+    this.onMediaEvent("setpause","setHashToTime");
     var _this = this;
     this.getWidgetAnnotations().forEach(function(_annotation) {
         _annotation.on("click", function() {
             _this.setHashToAnnotation(_annotation.id);
         })
     });
-    this.player.on("widgets-loaded", function() {
-        _this.goToHash();
-    });
+    if (this.media.loadedMetadata) {
+        this.goToHash();
+    } else {
+        this.onMediaEvent("loadedmetadata","goToHash");
+    }
 }
 
 IriSP.Widgets.Mediafragment.prototype.setWindowHash = function(_hash) {
--- a/src/widgets/Polemic.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/Polemic.js	Thu Jan 17 17:25:46 2013 +0100
@@ -19,7 +19,7 @@
 IriSP.Widgets.Polemic.prototype.defaults = {
     element_width : 5,
     element_height : 5,
-    max_elements : 15,
+    max_elements: 20,
     annotation_type : "tweet",
     defaultcolor : "#585858",
     foundcolor : "#fc00ff",
@@ -137,8 +137,8 @@
                 _annotation.on("select", function() {
                     if (_this.tooltip) {
                         _this.tooltip.show(
-                            Math.floor(_elx + (_this.element_width - 1) / 2),
-                            _ely,
+                            + Math.floor(_elx + (_this.element_width - 1) / 2),
+                            + _ely,
                             _annotation.title,
                             _col
                         );
@@ -272,10 +272,10 @@
                     _html = '<p>' + _this.l10n.from_ + _el.attr("begin-time") + _this.l10n._to_ + _el.attr("end-time") + '</p>';
                 for (var _i = 0; _i <= _this.polemics.length; _i++) {
                     var _color = _i ? _this.polemics[_i - 1].color : _this.defaultcolor;
-                    _html += '<div class="Ldt-Tooltip-Color" style="background: ' + _color + '"></div><p>' + _nums[_i] + _this.l10n._annotations + '</p>'
+                    _html += '<div class="Ldt-Tooltip-AltColor" style="background: ' + _color + '"></div><p>' + _nums[_i] + _this.l10n._annotations + '</p>'
                 }
                 if (_this.tooltip) {
-                    _this.tooltip.show(_el.attr("pos-x"), _el.attr("pos-y"), _html);
+                    _this.tooltip.show(+ _el.attr("pos-x"), + _el.attr("pos-y"), _html);
                 }
             })
             .mouseout(function() {
--- a/src/widgets/PopcornPlayer.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/PopcornPlayer.js	Thu Jan 17 17:25:46 2013 +0100
@@ -7,7 +7,6 @@
 /* A Popcorn-based player for HTML5 Video, Youtube and Vimeo */
 
 IriSP.Widgets.PopcornPlayer.prototype.defaults = {
-    aspect_ratio: 14/9
 }
 
 IriSP.Widgets.PopcornPlayer.prototype.draw = function() {
@@ -21,13 +20,6 @@
         this.video = this.url_transform(this.video);
     }
     
-    if (!this.height) {
-        this.height = Math.floor(this.width/this.aspect_ratio);
-        this.$.css({
-                height: this.height
-            });
-    }
-    
     if (/^(https?:\/\/)?(www\.)?vimeo\.com/.test(this.video)) {
         
         /* VIMEO */
@@ -62,7 +54,7 @@
         _videoEl.attr({
             id : _tmpId,
             width : this.width,
-            height : this.height
+            height : this.height || undefined
         });
         if(typeof this.video === "string"){
             _videoEl.attr("src",this.video);
--- a/src/widgets/Tooltip.css	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/Tooltip.css	Thu Jan 17 17:25:46 2013 +0100
@@ -108,6 +108,10 @@
     float: left; margin: 8px 2px 2px 8px; width: 10px; height: 10px;
 }
 
+.Ldt-Tooltip-AltColor {
+    float: left; margin: 2px 2px 2px 3px; width: 10px; height: 10px;
+}
+
 .Ldt-Tooltip img {
     max-width: 140px; max-height: 80px; margin: 2px 20px;
 }
--- a/src/widgets/Tooltip.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/Tooltip.js	Thu Jan 17 17:25:46 2013 +0100
@@ -56,8 +56,8 @@
         shift = Math.max(x - this.__halfWidth - this.min_x, - this.__maxShift);
     }
     
-    if (typeof this.max_x !== "undefined" && (x + this.__halfWidth > this.max_x)) {
-        shift = Math.min(x + this.__halfWidth - this.max_x, this.__maxShift);
+    if (typeof this.max_x !== "undefined" && (+x + this.__halfWidth > this.max_x)) {
+        shift = Math.min(+ x + this.__halfWidth - this.max_x, this.__maxShift);
     }
     
     this.$tooltip.css({
--- a/src/widgets/Tweet.js	Wed Dec 19 19:02:52 2012 +0100
+++ b/src/widgets/Tweet.js	Thu Jan 17 17:25:46 2013 +0100
@@ -6,7 +6,7 @@
 IriSP.Widgets.Tweet.prototype = new IriSP.Widgets.Widget();
 
 IriSP.Widgets.Tweet.prototype.defaults = {
-    hide_timeout: 5000,
+    hide_timeout: 10000,
     polemics : [
         {
             "keywords" : [ "++" ],
--- a/test/youtube.htm	Wed Dec 19 19:02:52 2012 +0100
+++ b/test/youtube.htm	Thu Jan 17 17:25:46 2013 +0100
@@ -18,7 +18,8 @@
 IriSP.libFiles.defaultDir = "libs/";
 IriSP.widgetsDir = "metadataplayer";
 var _metadata = {
-    url: "json/ldt-youtube.json",
+//    url: "json/ldt-youtube.json",
+    url: "http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/cljson/id/8f7e4b42-4838-11e2-ac61-00145ea4a2be",
     format: 'ldt'
 };
 var _config = {