Merge with bf65c3364d2db4ab904fe576de1a9d471e9923a2 popcorn-port
authorveltr
Wed, 18 Jan 2012 10:21:53 +0100
branchpopcorn-port
changeset 658 cfaf0986d22b
parent 657 138160f52f14 (current diff)
parent 654 bf65c3364d2d (diff)
child 660 78f392af62db
Merge with bf65c3364d2db4ab904fe576de1a9d471e9923a2
--- a/src/js/modules/mediafragment.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/modules/mediafragment.js	Wed Jan 18 10:21:53 2012 +0100
@@ -28,10 +28,9 @@
                     var offsettime = pageoffset.substring( 2 );
                     this._Popcorn.currentTime( parseFloat( offsettime ) );
                     }
-                  } else if ( pageoffset.substring(0, 2) === "a=") {
+                  } else if ( pageoffset.substring(0, 3) === "id=") {
                     // annotation
-                    var annotationId = pageoffset.substring( 2 );
-
+                    var annotationId = pageoffset.substring( 3 );
                     // there's no better way than that because
                     // of possible race conditions
                     this._serializer.sync(IriSP.wrap(this, function() {
@@ -66,7 +65,7 @@
   }
   
   splitArr = window.location.href.split( "#" )
-  history.replaceState( {}, "", splitArr[0] + "#a=" + annotationId);
+  history.replaceState( {}, "", splitArr[0] + "#id=" + annotationId);
  
   window.setTimeout(function() { _this.mutex = false }, 50);
 };
@@ -89,6 +88,7 @@
 
   if (typeof(annotation) !== "undefined") {
     this._Popcorn.currentTime(annotation.begin / 1000);
+    this._Popcorn.trigger("IriSP.Mediafragment.showAnnotation", annotationId);
   }
   
   window.setTimeout(function() { _this.mutex = false }, 50);
--- a/src/js/pop.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/pop.js	Wed Jan 18 10:21:53 2012 +0100
@@ -83,7 +83,7 @@
      var currentTime = +time;
      jwplayer( IriSP.PopcornReplacement._container ).seek( currentTime );
      IriSP.PopcornReplacement.__delay_seek_signal = true;     
-     //return jwplayer(IriSP.PopcornReplacement._container).getPosition();            
+     IriSP.PopcornReplacement.trigger("seeked");           
      return currentTime;
   }
 };
@@ -181,9 +181,6 @@
      
    }
 
-  if (IriSP.PopcornReplacement.__delay_seek_signal === true) {
-    IriSP.PopcornReplacement.trigger("seeked");
-  }
   IriSP.PopcornReplacement.trigger("timeupdate");
 };
 
--- a/src/js/utils.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/utils.js	Wed Jan 18 10:21:53 2012 +0100
@@ -132,24 +132,39 @@
 };
 
 /** returns an url to share on facebook */
-IriSP.mkFbUrl = function(url) {
-  return "http://www.facebook.com/share.php?u=" + "I'm watching " + url;
+IriSP.mkFbUrl = function(url, text) {
+  if (typeof(text) === "undefined")
+    text = "I'm watching ";
+  
+  return "http://www.facebook.com/share.php?u=" + IriSP.encodeURI(text) + IriSP.shorten_url(url);
 };
 
 /** returns an url to share on twitter */
-IriSP.mkTweetUrl = function(url) {
-  return "http://twitter.com/home?status=" + "I'm sharing " + url;
+IriSP.mkTweetUrl = function(url, text) {
+  if (typeof(text) === "undefined")
+    text = "I'm watching ";
+  
+  return "http://twitter.com/home?status=" + IriSP.encodeURI(text) + IriSP.shorten_url(url);
 };
 
 /** returns an url to share on google + */
-IriSP.mkGplusUrl = function(url) {
+IriSP.mkGplusUrl = function(url, text) {
   return "";
 };
 
 /** test if a value is null or undefined */
 IriSP.null_or_undefined = function(val) {
   return (typeof(val) === "undefined" || val === null);
-}
+};
+
+/** issue a call to an url shortener and return the shortened url */
+IriSP.shorten_url = function(url) {
+  if (IriSP.config.shortener.hasOwnProperty("shortening_function"))
+    return IriSP.config.shortener.shortening_function(url);
+    
+  return url;
+};
+
 /* for ie compatibility
 if (Object.prototype.__defineGetter__&&!Object.defineProperty) {
    Object.defineProperty=function(obj,prop,desc) {
--- a/src/js/widgets/annotationsWidget.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/widgets/annotationsWidget.js	Wed Jan 18 10:21:53 2012 +0100
@@ -33,10 +33,10 @@
     var fb_link = defaults.fb_link;
     var tw_link = defaults.tw_link;
     var gplus_link = defaults.gplus_link;
-    var url = document.location.href + "#a=" + annotation.id;
-    this.selector.find(".Ldt-fbShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
-    this.selector.find(".Ldt-TwShare").attr("href", tw_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
-    this.selector.find(".Ldt-GplusShare").attr("href", fb_link + IriSP.encodeURI(text) + IriSP.encodeURI(url));
+    var url = document.location.href + "#id=" + annotation.id;
+    this.selector.find(".Ldt-fbShare").attr("href", IriSP.mkFbUrl(url, text));
+    this.selector.find(".Ldt-TwShare").attr("href", IriSP.mkTweetUrl(url, text));
+    this.selector.find(".Ldt-GplusShare").attr("href", IriSP.mkGplusUrl(url, text));
 };
 
 IriSP.AnnotationsWidget.prototype.clearWidget = function() {   
--- a/src/js/widgets/createAnnotationWidget.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/widgets/createAnnotationWidget.js	Wed Jan 18 10:21:53 2012 +0100
@@ -196,16 +196,17 @@
   this.selector.find(".Ldt-createAnnotation-waitScreen").show();  
 };
 
-IriSP.createAnnotationWidget.prototype.showEndScreen = function() {
+IriSP.createAnnotationWidget.prototype.showEndScreen = function(annotation) {
   this.selector.find(".Ldt-createAnnotation-DoubleBorder").children().hide();
   
   if (this.cinecast_version) {
     this.selector.find(".Ldt-createAnnotation-Title").parent().show();      
   }
 
-  var twStatus = IriSP.mkTweetUrl(document.location.href);
-  var gpStatus = IriSP.mkGplusUrl(document.location.href);
-  var fbStatus = IriSP.mkFbUrl(document.location.href);
+  var url = document.location.href + "id=" + annotation.id;
+  var twStatus = IriSP.mkTweetUrl(url);
+  var gpStatus = IriSP.mkGplusUrl(url);
+  var fbStatus = IriSP.mkFbUrl(url);
   
   this.selector.find(".Ldt-createAnnotation-endScreen-TweetLink").attr("href", twStatus);
   this.selector.find(".Ldt-createAnnotation-endScreen-FbLink").attr("href", fbStatus);
@@ -271,10 +272,10 @@
     }
   } else {
     var duration = +this._serializer.currentMedia().meta["dc:duration"];    
-    annotation["begin"] = +((duration * (this.sliceLeft / this.selector.width())).toFixed(0));
-    annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / this.selector.width())).toFixed(0));
+    annotation["begin"] = +((duration * (this.sliceLeft / 100)).toFixed(0));
+    annotation["end"] = +((duration * ((this.sliceWidth + this.sliceLeft) / 100)).toFixed(0));
   }
-
+  
   annotation["type"] = this._serializer.getContributions();
   if (typeof(annotation["type"]) === "undefined")
     annotation["type"] = "";
@@ -315,7 +316,7 @@
                       /* set up a basic view */
                       var tmp_view = {"dc:contributor": "perso", "dc:creator": "perso", "dc:title": "Contributions",
                                       "id": json.annotations[0].type}
-                      console.log(tmp_view);
+
                       this._serializer._data["annotation-types"].push(tmp_view);
                     }
                     
@@ -330,9 +331,9 @@
                     
                     // everything is shared so there's no need to propagate the change
                     _this._serializer._data.annotations.push(annotation);
-                    console.log(_this._serializer._data);
+ 
                     _this._Popcorn.trigger("IriSP.createAnnotationWidget.addedAnnotation", annotation);
-                    callback();
+                    callback(annotation);
       }), 
       error: 
               function(jqXHR, textStatus, errorThrown) { 
--- a/src/js/widgets/playerWidget.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/widgets/playerWidget.js	Wed Jan 18 10:21:53 2012 +0100
@@ -161,6 +161,7 @@
       
       this._searchBlockOpen = true;           
       this.selector.find(".LdtSearchInput").bind('keyup', null, function() { self.searchHandler.call(self); } );
+      this.selector.find(".LdtSearchInput").focus();
       
       // we need this variable because some widget can find a match in
       // their data while at the same time other's don't. As we want the
--- a/src/js/widgets/polemicWidget.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/widgets/polemicWidget.js	Wed Jan 18 10:21:53 2012 +0100
@@ -160,6 +160,7 @@
       this._Popcorn.listen("IriSP.search.cleared", IriSP.wrap(this, this.searchFieldClearedHandler));
       this.selector.mouseleave(IriSP.wrap(this, function() { self.TooltipWidget.hide.call(self.TooltipWidget); }));
       this._Popcorn.listen("timeupdate", IriSP.wrap(this, this.sliderUpdater));
+      this._Popcorn.listen("IriSP.Mediafragment.showAnnotation", IriSP.wrap(this, this.showAnnotation));
       
       for(var i = 0; i < json.annotations.length; i++) {
         var item = json.annotations[i];        
@@ -312,11 +313,15 @@
                   
                   addEheight += TweetHeight;
                   
+                  /* stick a lot of things into e because that's the easiest way
+                     to do it */
                   e.color = colors[j];
                   e.time = frames[i].mytweetsID[k].timeframe;
                   e.title = frames[i].mytweetsID[k].title;
                   e.id = frames[i].mytweetsID[k].cinecast_id;
-                  
+                  var pos = IriSP.jQuery(e.node).offset();                  
+                  e.x = pos.left;
+                  e.y = pos.top;
                   this.svgElements[e.id] = e;
                   
                   IriSP.jQuery(e.node).mouseenter(function(element) { return function (event) {                        
@@ -431,3 +436,9 @@
  
 };
    
+IriSP.PolemicWidget.prototype.showAnnotation = function(id) {
+  if (this.svgElements.hasOwnProperty(id)) {
+    var e = this.svgElements[id];
+    this.TooltipWidget.show(e.title, e.attr("fill"), e.x - 103, e.y - 160);
+  }
+};   
--- a/src/js/widgets/sparklineWidget.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/widgets/sparklineWidget.js	Wed Jan 18 10:21:53 2012 +0100
@@ -101,7 +101,7 @@
 IriSP.SparklineWidget.prototype.handleNewAnnotation = function(annotation) {
   var num_columns = (this.selector.width()) / IriSP.widgetsDefaults["SparklineWidget"].column_width;
   var duration = +this._serializer.currentMedia().meta["dc:duration"];
-  var time_step = duration / num_columns; /* the time interval between two columns */
+  var time_step = Math.round(duration / num_columns); /* the time interval between two columns */
   var begin = +annotation.begin;
   
   var index = Math.floor(begin / time_step);
--- a/src/js/widgets/tooltipWidget.js	Wed Jan 18 10:21:23 2012 +0100
+++ b/src/js/widgets/tooltipWidget.js	Wed Jan 18 10:21:53 2012 +0100
@@ -30,7 +30,12 @@
   this.selector.find(".tipcolor").css("background-color", color);
   this._displayedText = text;
 	this.selector.find(".tiptext").text(text);
-  //this.selector.find(".tip").css("left", x).css("top", y);  
+  
+  if (x < 0)
+    x = 0;
+  if (y < 0)
+    y = 0;
+  
   this.selector.find(".tip").css("left", x).css("top", y);
   this.selector.find(".tip").show();
   this._shown = true;