[FIX] website: update links ids in duplicated carousel snippets

(+ gallery snippet in carousel mode)

Part of https://github.com/odoo/odoo/pull/44180
task-2162952

X-original-commit: 6237c59d607389cb0ed57694bb23b253f49805c8
This commit is contained in:
Benjamin Vray
2020-03-12 15:00:38 +00:00
committed by qsm-odoo
parent d944e67b46
commit b339310d31
2 changed files with 30 additions and 4 deletions
@@ -957,7 +957,14 @@ options.registry.Carousel = options.Class.extend({
const id = 'myCarousel' + Date.now();
this.$target.attr('id', id);
this.$target.find('[data-target]').attr('data-target', '#' + id);
this.$target.find('[data-slide]').attr('href', '#' + id);
_.each(this.$target.find('[data-slide], [data-slide-to]'), function (el) {
var $el = $(el);
if ($el.attr('data-target')) {
$el.attr('data-target', '#' + id);
} else if ($el.attr('href')) {
$el.attr('href', '#' + id);
}
});
},
});
@@ -56,9 +56,13 @@ options.registry.gallery = options.Class.extend({
* @override
*/
onBuilt: function () {
var uuid = new Date().getTime();
this.$target.find('.carousel').attr('id', 'slideshow_' + uuid);
this.$target.find('[data-target]').attr('data-target', '#slideshow_' + uuid);
this._adaptNavigationIDs();
},
/**
* @override
*/
onClone: function () {
this._adaptNavigationIDs();
},
/**
* @override
@@ -331,6 +335,21 @@ options.registry.gallery = options.Class.extend({
// Private
//--------------------------------------------------------------------------
/**
* @private
*/
_adaptNavigationIDs: function () {
var uuid = new Date().getTime();
this.$target.find('.carousel').attr('id', 'slideshow_' + uuid);
_.each(this.$target.find('[data-slide], [data-slide-to]'), function (el) {
var $el = $(el);
if ($el.attr('data-target')) {
$el.attr('data-target', '#slideshow_' + uuid);
} else if ($el.attr('href')) {
$el.attr('href', '#slideshow_' + uuid);
}
});
},
/**
* @override
*/