From 9530a9f4985953533f9ab24d4635532dac274f9b Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Fri, 13 May 2016 13:32:39 +0200 Subject: [IMP] website: share widget and multi language The lang of the content of the "Share" widget was the one used when inserting it in the view. Thus if someone see a page with it in another language the title and url for sharing is not translated. This commit use the current page language to set the widget data. opw-676062 --- addons/website/static/src/js/website.snippets.animation.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'addons/website/static/src/js/website.snippets.animation.js') diff --git a/addons/website/static/src/js/website.snippets.animation.js b/addons/website/static/src/js/website.snippets.animation.js index fa61feb7ec9..6702448fd58 100644 --- a/addons/website/static/src/js/website.snippets.animation.js +++ b/addons/website/static/src/js/website.snippets.animation.js @@ -105,12 +105,19 @@ animation.registry.parallax = animation.Class.extend({ animation.registry.share = animation.Class.extend({ selector: ".oe_share", start: function () { + var url_regex = /(\?(?:|.*&)(?:u|url|body)=)(.*?)(&|#|$)/; + var title_regex = /(\?(?:|.*&)(?:title|text|subject)=)(.*?)(&|#|$)/; var url = encodeURIComponent(window.location.href); var title = encodeURIComponent($("title").text()); this.$("a").each(function () { var $a = $(this); - var url_regex = /\{url\}|%7Burl%7D/, title_regex = /\{title\}|%7Btitle%7D/; - $a.attr("href", $(this).attr("href").replace(url_regex, url).replace(title_regex, title)); + $a.attr("href", function(i, href) { + return href.replace(url_regex, function (match, a, b, c) { + return a + url + c; + }).replace(title_regex, function (match, a, b, c) { + return a + title + c; + }); + }); if ($a.attr("target") && $a.attr("target").match(/_blank/i) && !$a.closest('.o_editable').length) { $a.on('click', function () { window.open(this.href,'','menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=550,width=600'); -- cgit v1.2.3