diff -r e47ed8eb75cd -r 977a39c4ee80 src/widgets/Social.js --- a/src/widgets/Social.js Wed Jul 11 18:22:57 2012 +0200 +++ b/src/widgets/Social.js Thu Jul 12 15:30:34 2012 +0200 @@ -2,6 +2,7 @@ IriSP.Widgets.Social = function(player, config) { IriSP.Widgets.Widget.call(this, player, config); + ZeroClipboard.setMoviePath( IriSP.getLib('zeroClipboardSwf') ); } IriSP.Widgets.Social.prototype = new IriSP.Widgets.Widget(); @@ -9,6 +10,7 @@ IriSP.Widgets.Social.prototype.defaults = { text: "", url: "", + show_url: true, show_twitter: true, show_fb: true, show_gplus: true, @@ -16,7 +18,9 @@ } IriSP.Widgets.Social.prototype.template = - '{{#show_fb}}{{/show_fb}}' + '{{#show_url}}
' + + '
{{l10n.copy}}
{{/show_url}}' + + '{{#show_fb}}{{/show_fb}}' + '{{#show_twitter}}{{/show_twitter}}' + '{{#show_gplus}}{{/show_gplus}}' + '{{#show_mail}}{{/show_mail}}
'; @@ -24,20 +28,58 @@ IriSP.Widgets.Social.prototype.messages = { "fr": { share_on: "Partager sur", - share_mail: "Envoyer par courriel" + share_mail: "Envoyer par courriel", + share_link: "Partager le lien hypertexte", + copy: "Copier" }, "en" : { share_on: "Share on", - share_mail: "Share by e-mail" + share_mail: "Share by e-mail", + share_link: "Share hypertext link", + copy: "Copy" } } IriSP.Widgets.Social.prototype.draw = function() { this.renderTemplate(); + this.clipId = IriSP._.uniqueId("Ldt-Social-CopyBtn-"); + this.$.find(".Ldt-Social-CopyBtn").attr("id", this.clipId); + var _this = this; + this.$.find(".Ldt-Social-Url").click(function() { + _this.toggleCopy(); + return false; + }); + this.$.find(".Ldt-Social-Input").focus(function() { + this.select(); + }); this.updateUrls(this.url, this.text); } +IriSP.Widgets.Social.prototype.toggleCopy = function() { + var _pop = this.$.find(".Ldt-Social-UrlPop"); + _pop.toggle(); + if (_pop.is(":visible")) { + if (typeof this.clip == "undefined") { + this.clip = new ZeroClipboard.Client(); + this.clip.setHandCursor( true ); + this.clip.glue(this.clipId); + var _this = this; + this.clip.addEventListener( 'onMouseUp', function() { + _pop.hide(); + _this.clip.hide(); + }); + } + this.clip.show(); + this.clip.setText( this.url ); + this.$.find(".Ldt-Social-Input").val(this.url).focus(); + } else { + this.clip.hide(); + } +} + IriSP.Widgets.Social.prototype.updateUrls = function(_url, _text) { + this.url = _url; + this.text = _text; this.$.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + IriSP.jQuery.param({ u: _url, t: _text })); this.$.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + IriSP.jQuery.param({ url: _url, text: _text })); this.$.find(".Ldt-Social-Gplus").attr("href", "https://plusone.google.com/_/+1/confirm?" + IriSP.jQuery.param({ url: _url, title: _text }));