[REF] website: move s_share snippet to dedicated files

This commit is contained in:
qsm-odoo
2019-12-18 01:16:32 +01:00
7 changed files with 101 additions and 77 deletions
+1
View File
@@ -39,6 +39,7 @@
'views/snippets/s_carousel.xml',
'views/snippets/s_alert.xml',
'views/snippets/s_card.xml',
'views/snippets/s_share.xml',
'views/website_views.xml',
'views/website_visitor_views.xml',
'views/res_config_settings_views.xml',
@@ -605,38 +605,6 @@ registry.parallax = Animation.extend({
},
});
registry.share = publicWidget.Widget.extend({
selector: '.s_share, .oe_share', // oe_share for compatibility
/**
* @override
*/
start: function () {
var urlRegex = /(\?(?:|.*&)(?:u|url|body)=)(.*?)(&|#|$)/;
var titleRegex = /(\?(?:|.*&)(?:title|text|subject)=)(.*?)(&|#|$)/;
var url = encodeURIComponent(window.location.href);
var title = encodeURIComponent($('title').text());
this.$('a').each(function () {
var $a = $(this);
$a.attr('href', function (i, href) {
return href.replace(urlRegex, function (match, a, b, c) {
return a + url + c;
}).replace(titleRegex, 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');
return false;
});
}
});
return this._super.apply(this, arguments);
},
});
registry.mediaVideo = publicWidget.Widget.extend({
selector: '.media_iframe_video',
@@ -944,33 +944,6 @@ table.table_desc tr td {
}
// Share
.s_share {
> * {
display: inline-block;
vertical-align: middle;
}
.s_share_title {
margin: 0 .4rem 0 0;
}
> a + a {
margin-left: .4rem;
}
.s_share_facebook {
&, &:hover, &:focus { color: #3b5998; }
}
.s_share_twitter {
&, &:hover, &:focus { color: #1da1f2; }
}
.s_share_linkedin {
&, &:hover, &:focus { color: #0077b5; }
}
.s_share_google {
&, &:hover, &:focus { color: #db4437; }
}
}
// Rating
.s_rating {
$star: "\f005";
@@ -0,0 +1,41 @@
odoo.define('website.s_share', function (require) {
'use strict';
const publicWidget = require('web.public.widget');
const ShareWidget = publicWidget.Widget.extend({
selector: '.s_share, .oe_share', // oe_share for compatibility
/**
* @override
*/
start: function () {
var urlRegex = /(\?(?:|.*&)(?:u|url|body)=)(.*?)(&|#|$)/;
var titleRegex = /(\?(?:|.*&)(?:title|text|subject)=)(.*?)(&|#|$)/;
var url = encodeURIComponent(window.location.href);
var title = encodeURIComponent($('title').text());
this.$('a').each(function () {
var $a = $(this);
$a.attr('href', function (i, href) {
return href.replace(urlRegex, function (match, a, b, c) {
return a + url + c;
}).replace(titleRegex, 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');
return false;
});
}
});
return this._super.apply(this, arguments);
},
});
publicWidget.registry.share = ShareWidget;
return ShareWidget;
});
@@ -0,0 +1,25 @@
.s_share {
> * {
display: inline-block;
vertical-align: middle;
}
.s_share_title {
margin: 0 .4rem 0 0;
}
> a + a {
margin-left: .4rem;
}
.s_share_facebook {
&, &:hover, &:focus { color: #3b5998; }
}
.s_share_twitter {
&, &:hover, &:focus { color: #1da1f2; }
}
.s_share_linkedin {
&, &:hover, &:focus { color: #0077b5; }
}
.s_share_google {
&, &:hover, &:focus { color: #db4437; }
}
}
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="s_share" name="Share">
<div t-attf-class="s_share #{_classes}">
<h4 t-if="not _no_title" class="s_share_title">Share</h4>
<a href="https://www.facebook.com/sharer/sharer.php?u={url}" t-attf-class="s_share_facebook #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-1x fa-facebook #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="https://twitter.com/intent/tweet?text={title}&amp;url={url}" t-attf-class="s_share_twitter #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-1x fa-twitter #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url={url}&amp;title={title}&amp;" t-attf-class="s_share_linkedin #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-1x fa-linkedin #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="mailto:?body={url}&amp;subject={title}" t-attf-class="s_share_email #{_link_classes}">
<i t-attf-class="fa fa-1x fa-envelope #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
</div>
</template>
<template id="assets_snippet_s_share_css_000" inherit_id="website.assets_frontend">
<xpath expr="//link[last()]" position="after">
<link rel="stylesheet" type="text/scss" href="/website/static/src/snippets/s_share/000.scss"/>
</xpath>
</template>
<template id="assets_snippet_s_share_js_000" inherit_id="website.assets_frontend">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/website/static/src/snippets/s_share/000.js"/>
</xpath>
</template>
</odoo>
@@ -1,24 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="s_share" name="Share">
<div t-attf-class="s_share #{_classes}">
<h4 t-if="not _no_title" class="s_share_title">Share</h4>
<a href="https://www.facebook.com/sharer/sharer.php?u={url}" t-attf-class="s_share_facebook #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-1x fa-facebook #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="https://twitter.com/intent/tweet?text={title}&amp;url={url}" t-attf-class="s_share_twitter #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-1x fa-twitter #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url={url}&amp;title={title}&amp;" t-attf-class="s_share_linkedin #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-1x fa-linkedin #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="mailto:?body={url}&amp;subject={title}" t-attf-class="s_share_email #{_link_classes}">
<i t-attf-class="fa fa-1x fa-envelope #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
</div>
</template>
<template id="s_rating" name="Rating">
<div class="s_rating row">
<div class="col-lg-12 s_rating_stars s_rating_3 s_rating_1x pt16 pb16">