update slide share widget with flash embed and js slide number control.
authorcavaliet
Wed, 18 Apr 2012 13:37:00 +0200
changeset 869 faae5df935de
parent 867 43f615b4dc48
child 871 a5607fa1ef0b
update slide share widget with flash embed and js slide number control.
src/css/LdtPlayer.css
src/js/defaults.js
src/js/widgets/slideShareWidget.js
--- a/src/css/LdtPlayer.css	Tue Apr 17 15:58:35 2012 +0200
+++ b/src/css/LdtPlayer.css	Wed Apr 18 13:37:00 2012 +0200
@@ -847,10 +847,10 @@
 }
 
 .Ldt-createAnnotation-spinner {
-	display: inline;
-	width: 16px;
-	height: 16px;
-	background-image('imgs/spinner.gif');
+    display: inline;
+    width: 16px;
+    height: 16px;
+    background-image('imgs/spinner.gif');
 }
 
 .Ldt-createAnnotation-endScreen-linkList {
@@ -975,7 +975,6 @@
 
 /* SlideShare Widget css */ 
 .Ldt-SlideShare {
-    font-family: "Arial","Verdana","sans-serif";
     font-size: 14px;
 }
 .Ldt-SlideShare .sync_links{
--- a/src/js/defaults.js	Tue Apr 17 15:58:35 2012 +0200
+++ b/src/js/defaults.js	Wed Apr 18 13:37:00 2012 +0200
@@ -7,7 +7,7 @@
         jQueryUI : "jquery-ui.min.js",
         jQueryToolTip : "jquery.tools.min.js",
         swfObject : "swfobject.js",
-        cssjQueryUI : "jquery-ui.css",
+        //cssjQueryUI : "jquery-ui.css",
         popcorn : "popcorn.js",
         jwplayer : "jwplayer.js",
         raphael : "raphael.js",
--- a/src/js/widgets/slideShareWidget.js	Tue Apr 17 15:58:35 2012 +0200
+++ b/src/js/widgets/slideShareWidget.js	Wed Apr 18 13:37:00 2012 +0200
@@ -21,7 +21,9 @@
   this.zoneLeft = 0;
   this.zoneWidth = 0;
   // global variable to save the last slide url
-  this.lastSlide = "";
+  this.lastSSFullUrl = "";
+  this.lastSSUrl = "";
+  this.lastSSId = "";
   this.containerDiv = this.selector.find('.SlideShareContainer');
   
   // Update the slide from timeupdate event
@@ -66,38 +68,54 @@
     var segment_slide = this.segments_slides[i];
     if(segment_slide.begin<time && time<segment_slide.end){
     	found = true;
-    	if(segment_slide.content.description!=this.lastSlide){
+    	if(segment_slide.content.description!=this.lastSSFullUrl){
 			// The url is like http://stuf.com#X and X is the slide number. So we split and save it.
-    		this.lastSlide = segment_slide.content.description;
-    		var description_ar = this.lastSlide.split("#");
-    		console.log("description_ar = " + description_ar);
-    		var slideUrl = description_ar[0];
-    		var slideNb = description_ar[1];
-    		// We have the slideshare oembed url.
-    		var url = "http://www.slideshare.net/api/oembed/2?format=jsonp&url=" + slideUrl;
-    		
-    		IriSP.jQuery.ajax({
-				url: url,
-				dataType: "jsonp",
-				success: function(data) {
-					ss_id = data["slideshow_id"];
-					embed_code = data["html"];
-					// If slideNb exist, we hack the embed code to add ?startSlide=X
-					if(slideNb){
-						embed_code = embed_code.replace(new RegExp("embed_code/"+ss_id), "embed_code/" + ss_id + "?startSlide=" + slideNb);
+    		this.lastSSFullUrl = segment_slide.content.description;
+    		var description_ar = this.lastSSFullUrl.split("#id=");
+    		var slideNb = 1;
+    		if(description_ar[1]){
+    			slideNb = description_ar[1];
+    		}
+    		if(description_ar[0]!=this.lastSSUrl){
+    			this.lastSSUrl = description_ar[0];
+	    		// We have the slideshare oembed url.
+	    		var url = "http://www.slideshare.net/api/oembed/1?format=jsonp&url=" + this.lastSSUrl;
+	    		
+	    		IriSP.jQuery.ajax({
+					url: url,
+					dataType: "jsonp",
+					success: function(data) {
+						self.lastSSId = data["slideshow_id"];
+						embed_code = data["html"];
+						// If slideNb exist, we hack the embed code to add ?startSlide=X
+						if(slideNb){
+							embed_code = embed_code.replace(new RegExp("ssplayer2.swf\\?","g"), "ssplayer2.swf?startSlide=" + slideNb + "&");
+						}
+						self.containerDiv.html(embed_code);
+					},
+					error: function(jqXHR, textStatus, errorThrown){
+						self.containerDiv.html("Error while downloading the slideshow. jqXHR = " + jqXHR + ", textStatus = " + textStatus + ", errorThrown = " + errorThrown);
 					}
-					self.containerDiv.html(embed_code);
-				},
-				error: function(jqXHR, textStatus, errorThrown){
-					self.containerDiv.html("Error while downloading the slideshow. jqXHR = " + jqXHR + ", textStatus = " + textStatus + ", errorThrown = " + errorThrown);
-				}
-    		});
+	    		});
+    		}
+    		else{
+    			// If the presentation was already loaded, we only use the ss js api to load the wanted slide number
+    			if(this.lastSSId!=""){
+    				// We get the embed flash element
+    				var embed = document.getElementsByName("__sse" + this.lastSSId)[0];
+    				if(embed){
+    					embed.jumpTo(parseInt(slideNb));
+    				}
+    			}
+    		}
     		return;
     	}
     }
   }
   if(found==false){
-  	this.lastSlide = "";
+	this.lastSSFullUrl = "";
+	this.lastSSUrl = "";
+	this.lastSSId = "";
   	this.containerDiv.html("");
   }