src/widgets/Social.js
author veltr
Thu, 05 Jul 2012 19:08:13 +0200
branchnew-model
changeset 924 64c2eaafe5e2
child 927 977a39c4ee80
permissions -rw-r--r--
Modifications for LDT-Platform
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);
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
     5
}
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: "",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    12
    show_twitter: true,
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    13
    show_fb: true,
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    14
    show_gplus: true,
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    15
    show_mail: true
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    16
}
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    17
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    18
IriSP.Widgets.Social.prototype.template =
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    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}}'
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    20
    + '{{#show_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}'
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    21
    + '{{#show_gplus}}<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>{{/show_gplus}}'
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    22
    + '{{#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
    23
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    24
IriSP.Widgets.Social.prototype.messages = {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    25
    "fr": {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    26
        share_on: "Partager sur",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    27
        share_mail: "Envoyer par courriel"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    28
    },
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    29
    "en" : {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    30
        share_on: "Share on",
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    31
        share_mail: "Share by e-mail"
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    32
    }
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    33
}
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    34
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    35
IriSP.Widgets.Social.prototype.draw = function() {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    36
    this.renderTemplate();
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    37
    this.updateUrls(this.url, this.text);
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    38
}
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    39
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    40
IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) {
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    41
    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
    42
    this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text }));
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    43
    this.$.find(".Ldt-Social-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text }));
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    44
    this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url }));
64c2eaafe5e2 Modifications for LDT-Platform
veltr
parents:
diff changeset
    45
}