[FIX] website: slide position gallery snippet

Changing position of a slide from the gallery snippet was not working.

saas-6 part of #9284
opw-653061
opw-653167
This commit is contained in:
Nicolas Lempereur
2015-10-29 11:55:53 +01:00
parent 3dafb19c96
commit 7ffc2916ee
@@ -220,7 +220,7 @@
var $container = this.$target.find(".container:first");
var editor = new website.editor.MediaDialog(this.$target.closest('.o_editable'), null, {select_images: true});
editor.appendTo(document.body);
var index = Math.max(_.map(this.$target.find("img").get(), function (img) { return img.dataset.index | 0; })) + 1;
var index = Math.max(0, _.max(_.map(this.$target.find("img").get(), function (img) { return img.dataset.index | 0; })) + 1);
editor.on('saved', this, function (attachments) {
for (var i = 0 ; i < attachments.length; i++) {
var img = $('<img class="img img-responsive mb8 mt8"/>')
@@ -327,7 +327,6 @@
if (type !== "click") return;
var $parent = this.$target.closest("section");
this.BuildingBlock.create_overlay($parent);
var editor = $parent.data('snippet-editor').styles.gallery;
var imgs = $parent.find('img').get();
imgs.sort(function (a,b) { return $(a).data('index')-$(b).data('index'); });