integration/js/social.js
changeset 43 5a5024bc74e6
child 49 a21b851538b2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/integration/js/social.js	Fri Nov 16 19:23:20 2012 +0100
@@ -0,0 +1,47 @@
+$(function() {
+    
+    var url = document.location.href,
+        text = $("title").text(),
+        clipId = IriSP.Model.getUID(),
+        clip;
+
+    $(".Ldt-Social-CopyBtn").attr("id", this.clipId);
+
+    $(".Ldt-Social-Url").click(function() {
+        var _pop = $(".Ldt-Social-UrlPop");
+        _pop.toggle();
+        if (_pop.is(":visible")) {
+            if (typeof clip == "undefined") {
+                clip = new ZeroClipboard.Client();
+                clip.setHandCursor( true );
+                clip.glue(clipId);
+                
+                clip.addEventListener( 'onMouseUp', function() {
+                    _pop.hide();
+                    clip.hide();
+                });
+            }
+            clip.show();
+            clip.setText( url );
+            $(".Ldt-Social-Input").val(url).focus();
+        } else {
+            clip.hide();
+        }
+        return false;
+    });
+    $(".Ldt-Social-Input").focus(function() {
+        this.select();
+    });
+    $(".Ldt-Social-Ext").click(function() {
+        window.open(
+            $(this).attr("href"),
+            "_blank",
+            "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
+        return false;
+    });
+    
+    $(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + $.param({ u: url, t: text }));
+    $(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + $.param({ url: url, text: text }));
+    $(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + $.param({ url: url, title: text }));
+    $(".Ldt-Social-Mail").attr("href", "mailto:?" + $.param({ subject: text, body: text + ": " + url }));
+});