the annotationWidget "share" buttons now work correctly. popcorn-port
authorhamidouk
Fri, 16 Dec 2011 10:41:48 +0100
branchpopcorn-port
changeset 470 19389e221722
parent 469 154c049e0c06
child 471 af5b1db6fd0b
the annotationWidget "share" buttons now work correctly.
src/js/site.js.templ
src/js/widgets/annotationsWidget.js
src/templates/annotationWidget.html
--- a/src/js/site.js.templ	Thu Dec 15 16:35:48 2011 +0100
+++ b/src/js/site.js.templ	Fri Dec 16 10:41:48 2011 +0100
@@ -22,7 +22,12 @@
 IriSP.widgetsDefaults = {
   "LayoutManager" : {spacer_div_height : "0px" },
   "PlayerWidget" : {},
-  "AnnotationsWidget": {},
+  "AnnotationsWidget": {
+    "share_text" : "I'm watching ",
+    "fb_link" : "http://www.facebook.com/share.php?u=",
+    "tw_link" : "http://twitter.com/home?status=",
+    "gplus_link" : ""
+    },
   "TweetsWidget" : {
       default_profile_picture : "https://si0.twimg.com/sticky/default_profile_images/default_profile_1_normal.png",
       tweet_display_period: 10000 // how long do we show a tweet ?
--- a/src/js/widgets/annotationsWidget.js	Thu Dec 15 16:35:48 2011 +0100
+++ b/src/js/widgets/annotationsWidget.js	Fri Dec 16 10:41:48 2011 +0100
@@ -12,7 +12,7 @@
     this.selector.find(".Ldt-SaKeywordText").text("");
 };
 
-IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) {
+IriSP.AnnotationsWidget.prototype.displayAnnotation = function(annotation) {   
 
     var title = annotation.content.title;
     var description = annotation.content.description;
@@ -20,12 +20,23 @@
     var begin = +annotation.begin / 1000;
     var end = +annotation.end / 1000;
     var duration = +this._serializer.currentMedia().meta["dc:duration"];
-
+    
     var title_templ = "{{title}} - ( {{begin}} - {{end}} )";
     var endstr = Mustache.to_html(title_templ, {title: title, begin: IriSP.secondsToTime(begin), end: IriSP.secondsToTime(end)});
 
     this.selector.find(".Ldt-SaTitle").text(endstr);
     this.selector.find(".Ldt-SaDescription").text(description);
+    
+    // update sharing buttons
+    var defaults = IriSP.widgetsDefaults.AnnotationsWidget;
+    var text = defaults.share_text;
+    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));
 };
 
 IriSP.AnnotationsWidget.prototype.clearWidget = function() {
--- a/src/templates/annotationWidget.html	Thu Dec 15 16:35:48 2011 +0100
+++ b/src/templates/annotationWidget.html	Fri Dec 16 10:41:48 2011 +0100
@@ -5,9 +5,9 @@
   
     <div class='Ldt-AnnotationContent'>  
       <div class='Ldt-AnnotationShareIcons'>
-         <a href=''><img src='{{img_dir}}/facebook.png' alt='share on facebook'></img></a>
-         <a href=''><img src='{{img_dir}}/twitter.png' alt='share on twitter'></img></a>
-         <a href=''><img src='{{img_dir}}/google.png' alt='share on google+'></img></a>
+         <a class='Ldt-fbShare' href=''><img src='{{img_dir}}/facebook.png' alt='share on facebook'></img></a>
+         <a class='Ldt-TwShare' href=''><img src='{{img_dir}}/twitter.png' alt='share on twitter'></img></a>
+         <a class='Ldt-GplusShare' href=''><img src='{{img_dir}}/google.png' alt='share on google+'></img></a>
       </div>
 
 		  <div class='Ldt-SaTitle'></div>