web/res/metadataplayer/Social.js
author Raphael Velt <raph.velt@gmail.com>
Wed, 11 Jul 2012 18:21:43 +0200
changeset 656 635a86f25fe7
parent 654 a5977736d2b0
child 694 e9400c80e1e4
permissions -rw-r--r--
First tests for PT Protocol implementation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
654
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     1
// TODO: Open share links in a small window
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     2
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     3
IriSP.Widgets.Social = function(player, config) {
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     4
    IriSP.Widgets.Widget.call(this, player, config);
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     5
}
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     6
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     7
IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget();
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     8
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
     9
IriSP.Widgets.Social.prototype.defaults = {
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    10
    text: "",
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    11
    url: "",
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    12
    show_twitter: true,
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    13
    show_fb: true,
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    14
    show_gplus: true,
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    15
    show_mail: true
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    16
}
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    17
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    18
IriSP.Widgets.Social.prototype.template =
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
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}}'
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    20
    + '{{#show_twitter}}<a href="#" target="_blank" class="Ldt-Social-Twitter Ldt-TraceMe" title="{{l10n.share_on}} Twitter"></a>{{/show_twitter}}'
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    21
    + '{{#show_gplus}}<a href="#" target="_blank" class="Ldt-Social-Gplus Ldt-TraceMe" title="{{l10n.share_on}} Google+"></a>{{/show_gplus}}'
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    22
    + '{{#show_mail}}<a href="#" target="_blank" class="Ldt-Social-Mail Ldt-TraceMe" title="{{l10n.share_mail}}"></a>{{/show_mail}}</span>';
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    23
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    24
IriSP.Widgets.Social.prototype.messages = {
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    25
    "fr": {
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    26
        share_on: "Partager sur",
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    27
        share_mail: "Envoyer par courriel"
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    28
    },
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    29
    "en" : {
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    30
        share_on: "Share on",
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    31
        share_mail: "Share by e-mail"
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    32
    }
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    33
}
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    34
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    35
IriSP.Widgets.Social.prototype.draw = function() {
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    36
    this.renderTemplate();
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    37
    this.updateUrls(this.url, this.text);
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    38
}
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    39
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    40
IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) {
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    41
    this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text }));
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    42
    this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text }));
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    43
    this.$.find(".Ldt-Social-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text }));
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    44
    this.$.find(".Ldt-Social-Mail").attr("href", "mailto:?" + IriSP.jQuery.param({ subject: _text, body: _text + ": " + _url }));
a5977736d2b0 Corrected metadataplayer bug
Raphael Velt <raph.velt@gmail.com>
parents:
diff changeset
    45
}