Skip to content
Snippets Groups Projects
Commit 0e90afb7 authored by jvm-odoo's avatar jvm-odoo
Browse files

[FIX] website_blog: fix share link on blog posts


Issue

	- Install Blog
	- Go on a Blog post
	- Customize > Enable Share links & Sidebar
	- Click on a social share link

	Redirected to #

Cause

	The website_blog.js has been refactored fron v12
	to v13, it seems that the onShareLink method has
	been forgotten in the event handlers.

Solution

	I added it and make it working with the actual view.

OPW-2170706

closes odoo/odoo#44583

Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
parent 1b2dc6b3
Branches
Tags
No related merge requests found
......@@ -8,6 +8,7 @@ publicWidget.registry.websiteBlog = publicWidget.Widget.extend({
events: {
'click #o_wblog_next_container': '_onNextBlogClick',
'click #o_wblog_post_content_jump': '_onContentAnchorClick',
'click .o_twitter, .o_facebook, .o_linkedin, .o_google, .o_twitter_complete, .o_facebook_complete, .o_linkedin_complete, .o_google_complete': '_onShareArticle',
},
/**
......@@ -62,32 +63,17 @@ publicWidget.registry.websiteBlog = publicWidget.Widget.extend({
* @param {Event} ev
*/
_onShareArticle: function (ev) {
var url = '';
var articleURL;
ev.preventDefault();
var url = '';
var $element = $(ev.currentTarget);
if ($element.is('*[class*="_complete"]')) {
var blogTitleComplete = encodeURIComponent($('#blog_post_name').html() || '');
articleURL = encodeURIComponent(window.location.href);
if ($element.hasClass('o_twitter_complete')) {
url = 'https://twitter.com/intent/tweet?tw_p=tweetbutton&text=Amazing blog article : ' + blogTitleComplete + "! Check it live: " + articleURL;
} else if ($element.hasClass('o_facebook_complete')) {
url = 'https://www.facebook.com/sharer/sharer.php?u=' + articleURL;
} else if ($element.hasClass('o_linkedin_complete')) {
url = 'https://www.linkedin.com/shareArticle?mini=true&url=' + articleURL + '&title=' + blogTitleComplete;
}
} else {
var blogPost = $element.parents('[name="blog_post"]');
var blogPostTitle = encodeURIComponent(blogPost.find('.o_blog_post_title').html() || '');
var blogArticleLink = blogPost.find('.o_blog_post_title').parent('a').attr('href');
articleURL = encodeURIComponent(window.location.host + blogArticleLink);
if ($element.hasClass('o_twitter')) {
url = 'https://twitter.com/intent/tweet?tw_p=tweetbutton&text=Amazing blog article : ' + blogPostTitle + "! " + articleURL;
} else if ($element.hasClass('o_facebook')) {
url = 'https://www.facebook.com/sharer/sharer.php?u=' + articleURL;
} else if ($element.hasClass('o_linkedin')) {
url = 'https://www.linkedin.com/shareArticle?mini=true&url=' + articleURL + '&title=' + blogPostTitle;
}
var blogPostTitle = encodeURIComponent($('#o_wblog_post_name').html() || '');
var articleURL = encodeURIComponent(window.location.href);
if ($element.hasClass('o_twitter')) {
url = 'https://twitter.com/intent/tweet?tw_p=tweetbutton&text=Amazing blog article : ' + blogPostTitle + "! " + articleURL;
} else if ($element.hasClass('o_facebook')) {
url = 'https://www.facebook.com/sharer/sharer.php?u=' + articleURL;
} else if ($element.hasClass('o_linkedin')) {
url = 'https://www.linkedin.com/shareArticle?mini=true&url=' + articleURL + '&title=' + blogPostTitle;
}
window.open(url, '', 'menubar=no, width=500, height=400');
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment