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