[FIX] website: two sliders or galleries can have the same id
(because the user can edit separate part like footer or using versioning)
This commit is contained in:
@@ -1175,23 +1175,15 @@
|
||||
});
|
||||
|
||||
website.snippet.options.slider = website.snippet.Option.extend({
|
||||
unique_id: function () {
|
||||
var id = 0;
|
||||
$(".carousel").each(function () {
|
||||
var cid = 1 + parseInt($(this).attr("id").replace(/[^0123456789]/g, ''),10);
|
||||
if (id < cid) id = cid;
|
||||
});
|
||||
return "myCarousel" + id;
|
||||
},
|
||||
drop_and_build_snippet: function() {
|
||||
this.id = this.unique_id();
|
||||
this.id = "myCarousel_" + new Date().getTime();
|
||||
this.$target.attr("id", this.id);
|
||||
this.$target.find("[data-slide]").attr("data-cke-saved-href", "#" + this.id);
|
||||
this.$target.find("[data-target]").attr("data-target", "#" + this.id);
|
||||
this.rebind_event();
|
||||
},
|
||||
on_clone: function ($clone) {
|
||||
var id = this.unique_id();
|
||||
var id = "myCarousel_" + new Date().getTime();
|
||||
$clone.attr("id", id);
|
||||
$clone.find("[data-slide]").attr("href", "#" + id);
|
||||
$clone.find("[data-slide-to]").attr("data-target", "#" + id);
|
||||
|
||||
@@ -30,13 +30,9 @@
|
||||
this._temp_col = this.$el.find("data-columns").data("columns");
|
||||
},
|
||||
drop_and_build_snippet: function() {
|
||||
var uuid = 0;
|
||||
$(".carousel").each(function () {
|
||||
var id = parseInt(($(this).attr('id') || '0').replace(/[^0-9]/, ''));
|
||||
if (id > uuid) uuid = id;
|
||||
});
|
||||
this.$target.find('.carousel').attr('id', 'slideshow_'+ (uuid+1));
|
||||
this.$target.find('[data-target]').attr('data-target', '#slideshow_'+ (uuid+1));
|
||||
var uuid = new Date().getTime();
|
||||
this.$target.find('.carousel').attr('id', 'slideshow_' + uuid);
|
||||
this.$target.find('[data-target]').attr('data-target', '#slideshow_' + uuid);
|
||||
},
|
||||
styling : function(type, value) {
|
||||
var classes = this.$el.find('li[data-styling]').map(function () {
|
||||
@@ -186,18 +182,13 @@
|
||||
|
||||
var self = this,
|
||||
$imgs = $(this.get_imgs()),
|
||||
urls = $imgs.map(function() { return $(this).attr("src"); } ).get(),
|
||||
uuid = 0;
|
||||
$(".carousel").each(function () {
|
||||
var id = parseInt(($(this).attr('id') || '0').replace(/[^0-9]/, ''));
|
||||
if (id > uuid) uuid = id;
|
||||
});
|
||||
urls = $imgs.map(function() { return $(this).attr("src"); } ).get();
|
||||
var params = {
|
||||
srcs : urls,
|
||||
index: 0,
|
||||
title: "",
|
||||
interval : this.$target.data("interval") || false,
|
||||
id: "slideshow_" + (uuid+1)
|
||||
id: "slideshow_" + new Date().getTime()
|
||||
},
|
||||
$slideshow = $(openerp.qweb.render('website.gallery.slideshow', params));
|
||||
this.replace($slideshow);
|
||||
|
||||
Reference in New Issue
Block a user