src/widgets/Social.js
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--
Various changes from git version and make autoplayer determine video type on lowercase url
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     1
// TODO: Open share links in a small window
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     2
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     3
IriSP.Widgets.Social = function(player, config) {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     4
    IriSP.Widgets.Widget.call(this, player, config);
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 993
diff changeset
     5
};
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     6
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     7
IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget();
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     8
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     9
IriSP.Widgets.Social.prototype.defaults = {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    10
    text: "",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    11
    url: "",
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    12
    show_url: true,
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    13
    show_twitter: true,
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    14
    show_fb: true,
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    15
    show_gplus: true,
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    16
    show_mail: true
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 993
diff changeset
    17
};
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    18
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    19
IriSP.Widgets.Social.prototype.template =
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 982
diff changeset
    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
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    22
    + '{{#show_fb}}<a href="#" target="_blank" class="Ldt-Social-Fb Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Facebook"></a>{{/show_fb}}'
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    23
    + '{{#show_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-Social-Ext Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}'
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    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
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    25
    + '{{#show_mail}}<a href="#" target="_blank" class="Ldt-Social-Mail Ldt-TraceMe" title="{{l10n.share_mail}}"></a>{{/show_mail}}</span>';
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    26
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    27
IriSP.Widgets.Social.prototype.messages = {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    28
    "fr": {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    29
        share_on: "Partager sur",
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    30
        share_mail: "Envoyer par courriel",
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    31
        share_link: "Partager le lien hypertexte",
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    32
        copy: "Copier"
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    33
    },
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    34
    "en" : {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    35
        share_on: "Share on",
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    36
        share_mail: "Share by e-mail",
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    37
        share_link: "Share hypertext link",
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    38
        copy: "Copy"
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    39
    }
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 993
diff changeset
    40
};
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    41
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    42
IriSP.Widgets.Social.prototype.draw = function() {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    43
    this.renderTemplate();
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    44
    this.clipId = IriSP._.uniqueId("Ldt-Social-CopyBtn-");
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    45
    this.$.find(".Ldt-Social-CopyBtn").attr("id", this.clipId);
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    46
    var _this = this;
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    47
    this.$.find(".Ldt-Social-Url").click(function() {
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    48
        _this.toggleCopy();
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    49
        return false;
993
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 982
diff changeset
    50
    }).on("dragstart", function(e) {
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 982
diff changeset
    51
    	e.originalEvent.dataTransfer.setData("text/x-iri-title",_this.text);
a7efd386872a Drag-and-drop support for Renkan
raph
parents: 982
diff changeset
    52
    	e.originalEvent.dataTransfer.setData("text/x-iri-uri",_this.url);
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    53
    });
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    54
    this.$.find(".Ldt-Social-Input").focus(function() {
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    55
        this.select();
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    56
    });
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    57
    this.$.find(".Ldt-Social-Ext").click(function() {
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    58
        window.open(
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    59
            IriSP.jQuery(this).attr("href"),
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    60
            "_blank",
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    61
            "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    62
        return false;
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    63
    });
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    64
    this.updateUrls(this.url, this.text);
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 993
diff changeset
    65
};
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    66
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    67
IriSP.Widgets.Social.prototype.toggleCopy = function() {
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    68
    var _pop = this.$.find(".Ldt-Social-UrlPop");
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    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
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 993
diff changeset
    71
};
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    72
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    73
IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) {
927
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    74
    this.url = _url;
977a39c4ee80 Added URL Copy function to the Social Widget
veltr
parents: 924
diff changeset
    75
    this.text = _text;
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    76
    this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text }));
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    77
    this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text }));
982
cfcbac34d020 Added Multi Segments Widget
veltr
parents: 927
diff changeset
    78
    this.$.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + IriSP.jQuery.param({ url: _url, title: _text }));
924
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    79
    this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url }));
1013
392ddcd212d7 Throwed in a bunch of semicolons
veltr
parents: 993
diff changeset
    80
};