summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js
diff options
context:
space:
mode:
authorJeremy Kersten <jke@odoo.com>2015-08-11 09:57:16 +0200
committerJeremy Kersten <jke@odoo.com>2015-08-11 13:58:04 +0200
commitc47ea6f8ea707f59fc10b5a3172a056b5ed447da (patch)
treea26a635616317c04999dd97affef080ea7d87b14 /addons/website/static/src/js
parentbf0f43820960d9ca5c023cfb0ea6e140afa7a0f9 (diff)
[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.
Diffstat (limited to 'addons/website/static/src/js')
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js29
1 files changed, 18 insertions, 11 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index 139e77a2e95..eea9ee50c30 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -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