integration/js/common.js
changeset 104 1b84c7b2aeee
parent 91 a94f5c62e4d7
child 115 e48bb5d43ac2
--- a/integration/js/common.js	Tue Dec 04 13:31:01 2012 +0100
+++ b/integration/js/common.js	Tue Dec 04 18:59:07 2012 +0100
@@ -37,17 +37,46 @@
     
     var opts = opts || {};
     opts.sel = opts.sel || $(".Ldt-Social");
-    opts.url = opts.url || document.location.href;
+    opts.url = opts.url || document.location.href
+    opts.text = opts.text || $("title").text();
+    
+    if (!opts.sel.length) {
+        return;
+    }
+    
+    opts.sel.addClass("Ldt-Social");
     
     if (opts.swf) {
         ZeroClipboard.setMoviePath(opts.swf);
     }
     
-    var text = opts.sel.find("title").text(),
-        clipId = "Social-Clip-" + (++uid),
-        clip;
-
-    opts.sel.find(".Ldt-Social-CopyBtn").attr("id", clipId);
+    var clipId = "Social-Clip-" + (++uid),
+        clip,
+        html = '<div class="Ldt-Social-Url-Container"><a href="#" target="_blank" class="Ldt-Social-Square Ldt-Social-Url" title="'
+            + gettext("Share URL")
+            + '"></a><span class="Ldt-Social-UrlPop"><input class="Ldt-Social-Input"/><div class="Ldt-Social-CopyBtn" id="'
+            + clipId
+            + '">'
+            + gettext("Copy")
+            + '</div></span></div><a href="http://www.facebook.com/share.php?'
+            + $.param({ u: opts.url, t: opts.text })
+            + '" target="_blank" class="Ldt-Social-Fb Ldt-Social-Ext" title="'
+            + gettext("Share on Facebook")
+            + '"></a><a href="https://twitter.com/intent/tweet?'
+            + $.param({ url: opts.url, text: opts.text })
+            + '" target="_blank" class="Ldt-Social-Twitter Ldt-Social-Ext" title="'
+            + gettext("Share on Twitter")
+            + '"></a><a href="https://plus.google.com/share?'
+            + $.param({ url: opts.url, title: opts.text })
+            + '" target="_blank" class="Ldt-Social-Gplus Ldt-Social-Ext" title="'
+            + gettext("Share on Google+")
+            + '"></a><a href="mailto:?'
+            + $.param({ subject: opts.text, body: opts.text + ": " + opts.url })
+            + '" target="_blank" class="Ldt-Social-Mail" title="'
+            + gettext("Share via E-Mail")
+            + '"></a></div>';
+            
+    opts.sel.html(html);
 
     opts.sel.find(".Ldt-Social-Url").click(function() {
         var _pop = opts.sel.find(".Ldt-Social-UrlPop");
@@ -81,10 +110,5 @@
             "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
         return false;
     });
-    
-    opts.sel.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + $.param({ u: opts.url, t: text }));
-    opts.sel.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + $.param({ url: opts.url, text: text }));
-    opts.sel.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + $.param({ url: opts.url, title: text }));
-    opts.sel.find(".Ldt-Social-Mail").attr("href", "mailto:?" + $.param({ subject: text, body: text + ": " + opts.url }));
 }
 }());
\ No newline at end of file