summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.snippets.editor.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-09-06 15:45:39 +0200
committerqsm-odoo <qsm@odoo.com>2016-09-07 12:30:40 +0200
commite696def3c58360e8acf8bb1c94e633840f71b7e2 (patch)
treed3f0a3a926bd18c252ac989fc92a74b10b9f1ae9 /addons/website/static/src/js/website.snippets.editor.js
parentd94c449547a2a7a6e270e4602320f588c5b6f896 (diff)
[FIX] website: properly allow to remove slide from banner snippet
Removing a slide was buggy : * Removing the last slide left the slide handles (and the user had to click on remove slide again) * There was an ugly delay before the removal * Changing the bg image of a slide was not possible anymore once one slide was removed * ...
Diffstat (limited to 'addons/website/static/src/js/website.snippets.editor.js')
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js35
1 files changed, 15 insertions, 20 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index aa101feb764..8459e11406a 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -109,35 +109,30 @@ options.registry.slider = options.Class.extend({
},0);
return $clone;
},
- remove_slide: function (type, value) {
- if(type !== "click") return;
-
- if (this.remove_process) {
- return;
- }
+ remove_slide: function (type) {
+ if (type !== "click" || this.remove_process) return;
var self = this;
- var new_index = 0;
- var cycle = this.$inner.find('.item').length - 1;
- var index = this.$inner.find('.item.active').index();
+
+ var $items = this.$inner.find('.item');
+ var cycle = $items.length - 1;
+ var $active = $items.filter('.active');
+ var index = $active.index();
if (cycle > 0) {
this.remove_process = true;
- var $el = this.$inner.find('.item.active');
- self.$target.on('slid.bs.carousel', function (event) {
- $el.remove();
+ this.$target.on('slid.bs.carousel.slide_removal', function (event) {
+ $active.remove();
self.$indicators.find("li:last").remove();
- self.$target.off('slid.bs.carousel');
+ self.$target.off('slid.bs.carousel.slide_removal');
self.rebind_event();
self.remove_process = false;
- if (cycle == 1) {
- self.on_remove_slide(event);
+ if (cycle === 1) {
+ self.$target.find('.carousel-control, .carousel-indicators').addClass("hidden");
}
});
- setTimeout(function () {
- self.$target.carousel( index > 0 ? --index : cycle );
- }, 500);
- } else {
- this.$target.find('.carousel-control, .carousel-indicators').addClass("hidden");
+ _.defer(function () {
+ self.$target.carousel(index > 0 ? --index : cycle);
+ });
}
},
interval : function(type, value) {