summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.snippets.animation.js
diff options
context:
space:
mode:
authorchm@openerp.com <>2014-03-10 14:54:34 +0100
committerchm@openerp.com <>2014-03-10 14:54:34 +0100
commit7e8b25dbeeec3a8bef5f092fd74cc71da75943ad (patch)
tree7eb7d62affc51ac46f3fa1e22adecb5e4f1679e5 /addons/website/static/src/js/website.snippets.animation.js
parent74bb1d6e9554afd2bd49db3ce4d9a98526c4f0a7 (diff)
[IMP] website: create share snippet. TODO: controller to send mail or mailto href
bzr revid: chm@openerp.com-20140310135434-7xt2sy89if9116l3
Diffstat (limited to 'addons/website/static/src/js/website.snippets.animation.js')
-rw-r--r--addons/website/static/src/js/website.snippets.animation.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/addons/website/static/src/js/website.snippets.animation.js b/addons/website/static/src/js/website.snippets.animation.js
index 933f4b8e6ed..173cdf39a58 100644
--- a/addons/website/static/src/js/website.snippets.animation.js
+++ b/addons/website/static/src/js/website.snippets.animation.js
@@ -127,4 +127,41 @@
}
});
+ website.snippet.animationRegistry.share = website.snippet.Animation.extend({
+ selector: ".oe_share",
+ start: function () {
+ var self = this;
+ var url = encodeURIComponent(window.location.href);
+ var title = encodeURIComponent($("title").text());
+ this.$target.find(".oe_share_facebook").attr("href",
+ "https://www.facebook.com/sharer/sharer.php?u="+url);
+ this.$target.find(".oe_share_twitter").attr("href",
+ "https://twitter.com/intent/tweet?text="+title+"&related=&url="+url);
+ this.$target.find(".oe_share_linkedin").attr("href",
+ "http://www.linkedin.com/shareArticle?mini=true&url="+url+"&title="+title+"&summary=&source=");
+ this.$target.find(".oe_share_google").attr("href",
+ "https://plus.google.com/share?url="+url);
+ this.$target.find("a").click(function () {
+ window.open(this.href,'','menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=550,width=600');
+ });
+
+ var $modal = this.$target.find(".oe_share_mail_modal");
+ var $from = $modal.find("input[name='from']").parent().parent();
+ this.$target.find(".oe_share_mail").off("click").click(function () {
+ // open popover
+ $modal.modal("show");
+ });
+ $modal.find("input[name='url']").attr("value", window.location.href);
+ openerp.jsonRpc('/website/current_user/', 'call', {
+ fields: ["email"]
+ }).then(function (result) {
+ if (result) $from.addClass("hidden");
+ else $from.removeClass("hidden");
+ });
+ $modal.find(".btn-primary").click(function () {
+ $modal.modal("hide");
+ console.log("valid");
+ });
+ },
+ });
})();