[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
* ...
This commit is contained in:
qsm-odoo
2016-09-07 12:30:40 +02:00
parent d94c449547
commit e696def3c5
@@ -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) {