summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/content/snippets.animation.js
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2019-10-18 05:38:45 +0000
committerqsm-odoo <qsm@odoo.com>2019-11-06 12:26:27 +0000
commit958c850f9f6ce722b0938331d0df9f873645f467 (patch)
tree5161e58675fafc00a30ed8857b1b16b98f0eb506 /addons/website/static/src/js/content/snippets.animation.js
parentaa62e957183644f67f85c01e2cdd73ac80f1576f (diff)
[REF] website, web_editor: refactor (quotes) carousel snippets
Previously, the carousel and quotes carousel snippets were the only ones that were not enclosed in section blocks. This had a number of undesirable side effects, such as editing the anchor on the carousel breaking the carousel functionality, and the inability to separately choose a background for the carousel itself and individual slides. I also used this opportunity to move controls relative to the entire carousel onto the carousel itself rather than the individual slides. The sizing_y (vertical padding) will however keep targeting individual slides, as the carousel uses the height of its tallest slide, and also because padding on the carousel will not get covered by slide backgrounds and saty blank, which is unwanted. Lastly, most of the snippet options for the carousel were rewritten, as they were quite broken. There was some compatibility code for saas-3 left, some useless events were bound to the controls, even though they were already handled through event-delegation at the document level. Finally, most of the edition features were broken on duplicated carousels since the onClone method wasn't reassigning most of the things it needed to. Part of https://github.com/odoo/odoo/pull/38997 task-2090180
Diffstat (limited to 'addons/website/static/src/js/content/snippets.animation.js')
-rw-r--r--addons/website/static/src/js/content/snippets.animation.js24
1 files changed, 8 insertions, 16 deletions
diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js
index c303d0691d3..e4969f43ce6 100644
--- a/addons/website/static/src/js/content/snippets.animation.js
+++ b/addons/website/static/src/js/content/snippets.animation.js
@@ -430,18 +430,17 @@ registry.slider = publicWidget.Widget.extend({
selector: '.carousel',
disabledInEditableMode: false,
edit_events: {
- 'slid.bs.carousel': '_onEditionSlide',
+ 'content_changed': '_onContentChanged',
},
/**
* @override
*/
start: function () {
- if (!this.editableMode) {
- this.$('img').on('load.slider', this._onImageLoaded.bind(this));
- this._computeHeights();
- }
- this.$target.carousel();
+ this.$('img').on('load.slider', () => this._computeHeights());
+ this._computeHeights();
+ // Initialize carousel and pause if in edit mode.
+ this.$target.carousel(this.editableMode ? 'pause' : undefined);
return this._super.apply(this, arguments);
},
/**
@@ -467,6 +466,7 @@ registry.slider = publicWidget.Widget.extend({
_computeHeights: function () {
var maxHeight = 0;
var $items = this.$('.carousel-item');
+ $items.css('min-height', '');
_.each($items, function (el) {
var $item = $(el);
var isActive = $item.hasClass('active');
@@ -477,9 +477,7 @@ registry.slider = publicWidget.Widget.extend({
}
$item.toggleClass('active', isActive);
});
- _.each($items, function (el) {
- $(el).css('min-height', maxHeight);
- });
+ $items.css('min-height', maxHeight);
},
//--------------------------------------------------------------------------
@@ -489,13 +487,7 @@ registry.slider = publicWidget.Widget.extend({
/**
* @private
*/
- _onEditionSlide: function () {
- this._computeHeights();
- },
- /**
- * @private
- */
- _onImageLoaded: function () {
+ _onContentChanged: function (ev) {
this._computeHeights();
},
});