diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-08-21 09:17:27 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-08-21 15:58:53 +0200 |
| commit | 394a0c8bb40ffa6eb080dd9e3bc9bce16db3d6f1 (patch) | |
| tree | 0b25f1431664d685b3938fbc5aa507fd4e768dcf | |
| parent | a38e5bee18506128773af97c9685c136a72ab137 (diff) | |
[FIX] website: two sliders or galleries can have the same id
(because the user can edit separate part like footer or using versioning)
| -rw-r--r-- | addons/website/static/src/js/website.snippets.editor.js | 12 | ||||
| -rw-r--r-- | addons/website/static/src/js/website.snippets.gallery.js | 19 |
2 files changed, 7 insertions, 24 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index abb4b9e859f..e45feeb590c 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -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); diff --git a/addons/website/static/src/js/website.snippets.gallery.js b/addons/website/static/src/js/website.snippets.gallery.js index 12392c4ef52..dede9e07969 100644 --- a/addons/website/static/src/js/website.snippets.gallery.js +++ b/addons/website/static/src/js/website.snippets.gallery.js @@ -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); |
