1 (function() { |
|
2 |
|
3 var uid = 0; |
|
4 |
|
5 window.social = function(opts) { |
|
6 |
|
7 var opts = opts || {}; |
|
8 opts.sel = opts.sel || $(".Ldt-Social"); |
|
9 opts.url = opts.url || document.location.href; |
|
10 |
|
11 if (opts.swf) { |
|
12 ZeroClipboard.setMoviePath(opts.swf); |
|
13 } |
|
14 |
|
15 var text = opts.sel.find("title").text(), |
|
16 clipId = "Social-Clip-" + (++uid), |
|
17 clip; |
|
18 |
|
19 opts.sel.find(".Ldt-Social-CopyBtn").attr("id", clipId); |
|
20 |
|
21 opts.sel.find(".Ldt-Social-Url").click(function() { |
|
22 var _pop = opts.sel.find(".Ldt-Social-UrlPop"); |
|
23 _pop.toggle(); |
|
24 if (_pop.is(":visible")) { |
|
25 if (typeof clip == "undefined") { |
|
26 clip = new ZeroClipboard.Client(); |
|
27 clip.setHandCursor( true ); |
|
28 clip.glue(clipId); |
|
29 |
|
30 clip.addEventListener( 'onMouseUp', function() { |
|
31 _pop.hide(); |
|
32 clip.hide(); |
|
33 }); |
|
34 } |
|
35 clip.show(); |
|
36 clip.setText( opts.url ); |
|
37 opts.sel.find(".Ldt-Social-Input").val(opts.url).focus(); |
|
38 } else { |
|
39 clip.hide(); |
|
40 } |
|
41 return false; |
|
42 }); |
|
43 opts.sel.find(".Ldt-Social-Input").focus(function() { |
|
44 this.select(); |
|
45 }); |
|
46 opts.sel.find(".Ldt-Social-Ext").click(function() { |
|
47 window.open( |
|
48 opts.sel.find(this).attr("href"), |
|
49 "_blank", |
|
50 "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0"); |
|
51 return false; |
|
52 }); |
|
53 |
|
54 opts.sel.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + $.param({ u: opts.url, t: text })); |
|
55 opts.sel.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + $.param({ url: opts.url, text: text })); |
|
56 opts.sel.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + $.param({ url: opts.url, title: text })); |
|
57 opts.sel.find(".Ldt-Social-Mail").attr("href", "mailto:?" + $.param({ subject: text, body: text + ": " + opts.url })); |
|
58 } |
|
59 }()); |
|
60 /* END social.js */ |
|