From c5496e57bad43ef7bfb1f422606611536c4876bb Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 18 Nov 2013 17:43:01 +0100 Subject: [FIX] website snippet: banner editor and remove slide method bzr revid: chm@openerp.com-20131118164301-v83knbdib3iirftb --- .../static/src/js/website.snippets.editor.js | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'addons/website/static/src/js/website.snippets.editor.js') diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 07979bfe696..2523c53231f 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -1063,13 +1063,14 @@ on_add: function (e) { e.preventDefault(); var cycle = this.$inner.find('.item').length; - var $active = this.$inner.find('.item.active'); + var $active = this.$inner.find('.item.active, .item.prev, .item.next').first(); var index = $active.index(); this.$target.find('.carousel-control, .carousel-indicators').removeClass("hidden"); this.$indicators.append('
  • '); var $clone = this.$el.find(".item.active").clone(); - var bg = this.$editor.find('ul[name="carousel-background"] li:not([data-value="'+ $active.css("background-image").replace(/.*:\/\/[^\/]+|\)$/g, '') +'"]):first').data("value"); + var avtive_bg = $active.css("background-image").replace(/.*:\/\/[^\/]+|\)$/g, ''); + var bg = this.$editor.find('ul[name="carousel-background"] li:not([data-value="'+ avtive_bg +'"]):first').data("value"); $clone.css("background-image", "url('"+ bg +"')"); $clone.removeClass('active').insertAfter($active); this.$target.carousel().carousel(++index); @@ -1077,21 +1078,29 @@ }, on_remove: function (e) { e.preventDefault(); + if (this.remove_process) { + return; + } var self = this; var new_index = 0; var cycle = this.$inner.find('.item').length - 1; var index = this.$inner.find('.item.active').index(); + if (cycle > 0) { - this.$inner.find('.item.active').fadeOut(1000, function () { - $(this).remove(); - self.$indicators.find('[data-target]:last').remove(); - self.$indicators.find("[data-slide-to]").removeClass("active"); - self.$indicators.find("[data-slide-to='" + new_index + "']").addClass("active"); + this.remove_process = true; + var $el = this.$inner.find('.item.active'); + self.$target.on('slid.bs.carousel', function (event) { + $el.remove(); + self.$indicators.find("li:last").remove(); + self.$target.off('slid.bs.carousel'); + self.rebind_event(); + self.remove_process = false; + if (cycle == 1) { + self.on_remove(e); + } }); setTimeout(function () { - new_index = index % cycle; - self.$target.carousel().carousel( new_index + 1 ); - self.rebind_event(); + self.$target.carousel( index > 0 ? --index : cycle ); }, 500); } else { this.$target.find('.carousel-control, .carousel-indicators').addClass("hidden"); -- cgit v1.2.3 From 6b10be15b245e05adac2a54f0321305c6d5076d9 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Wed, 20 Nov 2013 12:52:50 +0100 Subject: [IMP] website snippet: add group for styles snippets, add custom picture with style snippet, mouseover and mouseout preview, fix dark css class in demo data bzr revid: chm@openerp.com-20131120115250-etqv5ofqguze0zsj --- .../static/src/js/website.snippets.editor.js | 130 ++++++++++++++++----- 1 file changed, 104 insertions(+), 26 deletions(-) (limited to 'addons/website/static/src/js/website.snippets.editor.js') diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js index 2523c53231f..7d7aade081f 100644 --- a/addons/website/static/src/js/website.snippets.editor.js +++ b/addons/website/static/src/js/website.snippets.editor.js @@ -151,11 +151,12 @@ self.style_templates[snipped_id] = { 'snipped-id' : snipped_id, 'selector': $style.data('selector'), - 'class': $style.find(".oe_snippet_class").text(), - 'label': $style.find(".oe_snippet_label").text() + 'class': $style.data("class"), + 'label': $style.find(".oe_snippet_label").text(), + 'group': $style.find(".oe_snippet_group").text() }; }); - $styles.remove(); + $styles.addClass("hidden"); self.$snippets = $html.find(".tab-content > div > div").addClass("oe_snippet"); self.$el.append($html); @@ -530,11 +531,11 @@ website.snippet.editorRegistry = {}; website.snippet.Editor = openerp.Class.extend({ - init: function (parent, dom) { + init: function (parent, dom, force_snippet_id) { this.parent = parent; this.$target = $(dom); this.$overlay = this.$target.data('overlay'); - this.snippet_id = this.$target.data("snippet-id"); + this.snippet_id = force_snippet_id || this.$target.data("snippet-id"); this._readXMLData(); this.load_style_options(); this.get_parent_block(); @@ -651,6 +652,10 @@ }, load_style_options: function () { + if (this.$target.data('snippetStyles')) { + return; + } + var self = this; var $styles = this.$overlay.find('.oe_options'); var $ul = $styles.find('ul:first'); @@ -660,30 +665,77 @@ } var $li = $("
  • ").data(val); $li.append($('').text(val.label)); - $ul.append($li); - if (self.$target.hasClass( "oe_snippet_" + $li.data("snipped-id") )) { + if (self.$target.hasClass( val.class )) { $li.addClass("active"); } - $styles.removeClass("hidden"); + + if (val.group.length) { + var $group = $ul.find("li.dropdown-submenu").filter(function () { + return $("a:first", this).text() === val.group; + }); + if (!$group.length) { + $group = $('