[FIX] website: editor - duplicate the slide from snippet

Since saas-6, all snippets should start by a s_, so we can know exactly what is
 the current snippet, and retrieve the slide from the drop-snippets bar.

If none snippet match, we use the old method which consists to find the snippet
which have the biggest intersection of class betwwen dropped snippet, and all
snippets in drop-snippets bar.

A other way without update the JS code will be to had many fake class in the
snippet declaration and in the snippet code to be sure that it match the right
snippet.
This commit is contained in:
Jeremy Kersten
2015-08-11 13:58:04 +02:00
parent bf0f438209
commit c47ea6f8ea
@@ -1223,17 +1223,24 @@
this.$indicators.append('<li data-target="#' + this.id + '" data-slide-to="' + cycle + '"></li>');
// clone the best candidate from template to use new features
var $snippets = this.BuildingBlock.$snippets.find('.oe_snippet_body.carousel');
var point = 0;
var selection;
var className = _.compact(this.$target.attr("class").split(" "));
$snippets.each(function () {
var len = _.intersection(_.compact(this.className.split(" ")), className).length;
if (len > point) {
point = len;
selection = this;
}
});
var $snippets = this.BuildingBlock.$snippets;
//since saas-6, all snippets must start by s_
var selection = this.$target.closest('[class*="s_"');
if (_.isUndefined(selection)) {
var point = 0;
var className = _.compact(this.$target.attr("class").split(" "));
$snippets.find('.oe_snippet_body').each(function () {
var len = _.intersection(_.compact(this.className.split(" ")), className).length;
if (len > point) {
point = len;
selection = this;
}
});
}
else {
var s_class = selection.attr('class').split(' ').filter(function(o) { return _.str.startsWith(o, "s_") })[0]
selection = $snippets.find("." + s_class);
}
var $clone = $(selection).find('.item:first').clone();
// insert