equal
deleted
inserted
replaced
1 // TODO: Open share links in a small window |
1 // TODO: Open share links in a small window |
2 |
2 |
3 IriSP.Widgets.Social = function(player, config) { |
3 IriSP.Widgets.Social = function(player, config) { |
4 IriSP.Widgets.Widget.call(this, player, config); |
4 IriSP.Widgets.Widget.call(this, player, config); |
5 ZeroClipboard.setMoviePath( IriSP.getLib('zeroClipboardSwf') ); |
5 ZeroClipboard.setMoviePath( IriSP.getLib('zeroClipboardSwf') ); |
6 } |
6 }; |
7 |
7 |
8 IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget(); |
8 IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget(); |
9 |
9 |
10 IriSP.Widgets.Social.prototype.defaults = { |
10 IriSP.Widgets.Social.prototype.defaults = { |
11 text: "", |
11 text: "", |
13 show_url: true, |
13 show_url: true, |
14 show_twitter: true, |
14 show_twitter: true, |
15 show_fb: true, |
15 show_fb: true, |
16 show_gplus: true, |
16 show_gplus: true, |
17 show_mail: true |
17 show_mail: true |
18 } |
18 }; |
19 |
19 |
20 IriSP.Widgets.Social.prototype.template = |
20 IriSP.Widgets.Social.prototype.template = |
21 '<span class="Ldt-Social">{{#show_url}}<div class="Ldt-Social-Url-Container"><a href="#" draggable="true" target="_blank" class="Ldt-Social-Square Ldt-Social-Url Ldt-TraceMe" title="{{l10n.share_link}}">' |
21 '<span class="Ldt-Social">{{#show_url}}<div class="Ldt-Social-Url-Container"><a href="#" draggable="true" target="_blank" class="Ldt-Social-Square Ldt-Social-Url Ldt-TraceMe" title="{{l10n.share_link}}">' |
22 + '</a><div class="Ldt-Social-UrlPop"><input class="Ldt-Social-Input"/><div class="Ldt-Social-CopyBtn">{{l10n.copy}}</div></div></div>{{/show_url}}' |
22 + '</a><div class="Ldt-Social-UrlPop"><input class="Ldt-Social-Input"/><div class="Ldt-Social-CopyBtn">{{l10n.copy}}</div></div></div>{{/show_url}}' |
23 + '{{#show_fb}}<a href="#" target="_blank" class="Ldt-Social-Fb Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>{{/show_fb}}' |
23 + '{{#show_fb}}<a href="#" target="_blank" class="Ldt-Social-Fb Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>{{/show_fb}}' |
36 share_on: "Share on", |
36 share_on: "Share on", |
37 share_mail: "Share by e-mail", |
37 share_mail: "Share by e-mail", |
38 share_link: "Share hypertext link", |
38 share_link: "Share hypertext link", |
39 copy: "Copy" |
39 copy: "Copy" |
40 } |
40 } |
41 } |
41 }; |
42 |
42 |
43 IriSP.Widgets.Social.prototype.draw = function() { |
43 IriSP.Widgets.Social.prototype.draw = function() { |
44 this.renderTemplate(); |
44 this.renderTemplate(); |
45 this.clipId = IriSP._.uniqueId("Ldt-Social-CopyBtn-"); |
45 this.clipId = IriSP._.uniqueId("Ldt-Social-CopyBtn-"); |
46 this.$.find(".Ldt-Social-CopyBtn").attr("id", this.clipId); |
46 this.$.find(".Ldt-Social-CopyBtn").attr("id", this.clipId); |
61 "_blank", |
61 "_blank", |
62 "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0"); |
62 "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0"); |
63 return false; |
63 return false; |
64 }); |
64 }); |
65 this.updateUrls(this.url, this.text); |
65 this.updateUrls(this.url, this.text); |
66 } |
66 }; |
67 |
67 |
68 IriSP.Widgets.Social.prototype.toggleCopy = function() { |
68 IriSP.Widgets.Social.prototype.toggleCopy = function() { |
69 var _pop = this.$.find(".Ldt-Social-UrlPop"); |
69 var _pop = this.$.find(".Ldt-Social-UrlPop"); |
70 _pop.toggle(); |
70 _pop.toggle(); |
71 if (_pop.is(":visible")) { |
71 if (_pop.is(":visible")) { |
83 this.clip.setText( this.url ); |
83 this.clip.setText( this.url ); |
84 this.$.find(".Ldt-Social-Input").val(this.url).focus(); |
84 this.$.find(".Ldt-Social-Input").val(this.url).focus(); |
85 } else { |
85 } else { |
86 this.clip.hide(); |
86 this.clip.hide(); |
87 } |
87 } |
88 } |
88 }; |
89 |
89 |
90 IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) { |
90 IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) { |
91 this.url = _url; |
91 this.url = _url; |
92 this.text = _text; |
92 this.text = _text; |
93 this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text })); |
93 this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text })); |
94 this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text })); |
94 this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text })); |
95 this.$.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + IriSP.jQuery.param({ url: _url, title: _text })); |
95 this.$.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + IriSP.jQuery.param({ url: _url, title: _text })); |
96 this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url })); |
96 this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url })); |
97 } |
97 }; |