| author | ymh <ymh.work@gmail.com> |
| Sun, 12 Nov 2017 22:07:33 +0100 | |
| changeset 1071 | 02c04d2c8fd8 |
| parent 1013 | 392ddcd212d7 |
| child 1072 | ac1eacb3aa33 |
| permissions | -rw-r--r-- |
| 924 | 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); |
|
| 1013 | 5 |
}; |
| 924 | 6 |
|
7 |
IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget(); |
|
8 |
||
9 |
IriSP.Widgets.Social.prototype.defaults = { |
|
10 |
text: "", |
|
11 |
url: "", |
|
| 927 | 12 |
show_url: true, |
| 924 | 13 |
show_twitter: true, |
14 |
show_fb: true, |
|
15 |
show_gplus: true, |
|
16 |
show_mail: true |
|
| 1013 | 17 |
}; |
| 924 | 18 |
|
19 |
IriSP.Widgets.Social.prototype.template = |
|
| 993 | 20 |
'<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}}">' |
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
21 |
+ '</a><div class="Ldt-Social-UrlPop"><input class="Ldt-Social-Input"/></div></div>{{/show_url}}' |
| 982 | 22 |
+ '{{#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_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}' |
|
24 |
+ '{{#show_gplus}}<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>{{/show_gplus}}' |
|
| 924 | 25 |
+ '{{#show_mail}}<a href="#" target="_blank" class="Ldt-Social-Mail Ldt-TraceMe" title="{{l10n.share_mail}}"></a>{{/show_mail}}</span>'; |
26 |
||
27 |
IriSP.Widgets.Social.prototype.messages = { |
|
28 |
"fr": { |
|
29 |
share_on: "Partager sur", |
|
| 927 | 30 |
share_mail: "Envoyer par courriel", |
31 |
share_link: "Partager le lien hypertexte", |
|
32 |
copy: "Copier" |
|
| 924 | 33 |
}, |
34 |
"en" : { |
|
35 |
share_on: "Share on", |
|
| 927 | 36 |
share_mail: "Share by e-mail", |
37 |
share_link: "Share hypertext link", |
|
38 |
copy: "Copy" |
|
| 924 | 39 |
} |
| 1013 | 40 |
}; |
| 924 | 41 |
|
42 |
IriSP.Widgets.Social.prototype.draw = function() { |
|
43 |
this.renderTemplate(); |
|
| 927 | 44 |
this.clipId = IriSP._.uniqueId("Ldt-Social-CopyBtn-"); |
45 |
this.$.find(".Ldt-Social-CopyBtn").attr("id", this.clipId); |
|
46 |
var _this = this; |
|
47 |
this.$.find(".Ldt-Social-Url").click(function() { |
|
48 |
_this.toggleCopy(); |
|
49 |
return false; |
|
| 993 | 50 |
}).on("dragstart", function(e) { |
51 |
e.originalEvent.dataTransfer.setData("text/x-iri-title",_this.text); |
|
52 |
e.originalEvent.dataTransfer.setData("text/x-iri-uri",_this.url); |
|
| 927 | 53 |
}); |
54 |
this.$.find(".Ldt-Social-Input").focus(function() { |
|
55 |
this.select(); |
|
56 |
}); |
|
| 982 | 57 |
this.$.find(".Ldt-Social-Ext").click(function() { |
58 |
window.open( |
|
59 |
IriSP.jQuery(this).attr("href"), |
|
60 |
"_blank", |
|
61 |
"height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0"); |
|
62 |
return false; |
|
63 |
}); |
|
| 924 | 64 |
this.updateUrls(this.url, this.text); |
| 1013 | 65 |
}; |
| 924 | 66 |
|
| 927 | 67 |
IriSP.Widgets.Social.prototype.toggleCopy = function() { |
68 |
var _pop = this.$.find(".Ldt-Social-UrlPop"); |
|
69 |
_pop.toggle(); |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
70 |
this.$.find(".Ldt-Social-Input").val(this.url).focus(); |
| 1013 | 71 |
}; |
| 927 | 72 |
|
| 924 | 73 |
IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) { |
| 927 | 74 |
this.url = _url; |
75 |
this.text = _text; |
|
| 924 | 76 |
this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text })); |
77 |
this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text })); |
|
| 982 | 78 |
this.$.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + IriSP.jQuery.param({ url: _url, title: _text })); |
| 924 | 79 |
this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url })); |
| 1013 | 80 |
}; |