|
1 // TODO: Open share links in a small window |
|
2 |
|
3 IriSP.Widgets.Social = function(player, config) { |
|
4 IriSP.Widgets.Widget.call(this, player, config); |
|
5 } |
|
6 |
|
7 IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget(); |
|
8 |
|
9 IriSP.Widgets.Social.prototype.defaults = { |
|
10 text: "", |
|
11 url: "", |
|
12 show_twitter: true, |
|
13 show_fb: true, |
|
14 show_gplus: true, |
|
15 show_mail: true |
|
16 } |
|
17 |
|
18 IriSP.Widgets.Social.prototype.template = |
|
19 '<span class="Ldt-Social">{{#show_fb}}<a href="#" target="_blank" class="Ldt-Social-Fb Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>{{/show_fb}}' |
|
20 + '{{#show_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}' |
|
21 + '{{#show_gplus}}<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>{{/show_gplus}}' |
|
22 + '{{#show_mail}}<a href="#" target="_blank" class="Ldt-Social-Mail Ldt-TraceMe" title="{{l10n.share_mail}}"></a>{{/show_mail}}</span>'; |
|
23 |
|
24 IriSP.Widgets.Social.prototype.messages = { |
|
25 "fr": { |
|
26 share_on: "Partager sur", |
|
27 share_mail: "Envoyer par courriel" |
|
28 }, |
|
29 "en" : { |
|
30 share_on: "Share on", |
|
31 share_mail: "Share by e-mail" |
|
32 } |
|
33 } |
|
34 |
|
35 IriSP.Widgets.Social.prototype.draw = function() { |
|
36 this.renderTemplate(); |
|
37 this.updateUrls(this.url, this.text); |
|
38 } |
|
39 |
|
40 IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) { |
|
41 this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text })); |
|
42 this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text })); |
|
43 this.$.find(".Ldt-Social-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text })); |
|
44 this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url })); |
|
45 } |