[FIX] website: two sliders or galleries can have the same id

(because the user can edit separate part like footer or using versioning)

Backport of 394a0c8bb40ffa6eb080dd9e3bc9bce16db3d6f1.
This commit is contained in:
Christophe Matthieu 2015-08-21 09:17:27 +02:00 committed by David Monjoie
parent 3b02e3d63d
commit b90c663702
1 changed files with 2 additions and 10 deletions

View File

@ -944,23 +944,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);