diff --git a/addons/website/static/src/js/website.snippets.js b/addons/website/static/src/js/website.snippets.js index 99c5ae0d9cf..c0f35950271 100644 --- a/addons/website/static/src/js/website.snippets.js +++ b/addons/website/static/src/js/website.snippets.js @@ -76,7 +76,7 @@ _.each(openerp.qweb.compiled_templates, function (val, key) { if (key.indexOf('website.snippets.') === 0) { var $snippet = $(openerp.qweb.render(key)).addClass("oe_snippet"); - if ($snippet.data("action")) { + if ($snippet.data("snippet-id")) { self.$el.find('#snippet_' + $snippet.data('category')).append($snippet); self.make_snippet_draggable($snippet); } @@ -199,15 +199,24 @@ appendTo: 'body', cursor: "move", start: function(){ - var action = $snippet.data('action'); + var action = $snippet.find('.oe_snippet_body').size() ? 'insert' : 'mutate'; if( action === 'insert'){ + if (!$snippet.data('selector-siblings') && !$snippet.data('selector-childs') && !$snippet.data('selector-vertical-childs')) { + console.debug($snippet.data("snippet-id") + " have oe_snippet_body class and have not for insert action"+ + "data-selector-siblings, data-selector-childs or data-selector-vertical-childs tag for mutate action"); + return; + } self.activate_insertion_zones({ siblings: $snippet.data('selector-siblings'), childs: $snippet.data('selector-childs'), vertical_childs: $snippet.data('selector-vertical-childs') }); - } else if( action === 'mutate' ){ + } else if( action === 'mutate' ){ + if (!$snippet.data('selector')) { + console.debug($snippet.data("snippet-id") + " have not oe_snippet_body class and have not data-selector tag"); + return; + } var $targets = self.activate_overlay_zones($snippet.data('selector')); $targets.each(function(){ var $clone = $(this).data('overlay').clone(); @@ -235,7 +244,7 @@ } var $target = false; - if($snippet.find('.oe_snippet_body').size()){ + if(action === 'insert'){ var $toInsert = $snippet.find('.oe_snippet_body').clone(); $toInsert.removeClass('oe_snippet_body'); $toInsert.attr('data-snippet-id', snipped_id); @@ -278,30 +287,6 @@ return $(this).data('snippet-id') === id; }).first(); }, - // WIP - make_draggable_instance: function($instance){ - var self = this; - var $snippet = get_snippet_from_id($instance.data('snippet-id')); - - $instance.draggable({ - greedy: true, - helper: 'clone', - zIndex: '1000', - appendTo: 'body', - start: function(){ - var action = $snippet.data('action'); - if(action === 'insert'){ - - self.activate_insertion_zones({ - siblings: $snippet.data('selector-siblings'), - child: $snippet.data('selector-childs'), - vertical_childs: $snippet.data('selector-vertical-childs') - }); - - } - } - }); - }, // Create element insertion drop zones. two css selectors can be provided // selector.childs -> will insert drop zones as direct child of the selected elements @@ -385,7 +370,7 @@ activate_overlay_zones: function(selector){ selector = selector || '[data-snippet-id]'; if (typeof selector === 'string') - selector = this.parent_of_editable_box + selector.split(",").join(this.parent_of_editable_box); + selector = this.parent_of_editable_box + selector.split(",").join(", " + this.parent_of_editable_box); var $targets = $(selector); diff --git a/addons/website/static/src/xml/website.snippets.xml b/addons/website/static/src/xml/website.snippets.xml index 37fd6be40a2..4a975fe19b1 100644 --- a/addons/website/static/src/xml/website.snippets.xml +++ b/addons/website/static/src/xml/website.snippets.xml @@ -18,13 +18,13 @@
Margin resize
-
+
Column
-
+
  • @@ -95,11 +95,11 @@
  • -
    +
    Darken
    -
    +
    Well
    Manage your sales funnel with no effort with OpenERP CRM. Attract @@ -108,7 +108,7 @@
    -
    +
    Quote

    @@ -119,7 +119,7 @@

    -
    +
    Panel
    @@ -134,12 +134,12 @@
    -
    +
    Surprise!
    -
    +
    Title
    @@ -151,7 +151,7 @@
    -
    +
    Text-Image
    @@ -178,7 +178,7 @@
    -
    +
    Image-Text
    @@ -204,7 +204,7 @@
    -
    +
    Jumbotron
    @@ -221,7 +221,7 @@
    -
    +
    Text Block
    @@ -250,7 +250,7 @@
    -
    +
    Big Picture
    @@ -281,7 +281,7 @@
    -
    +
    Three Columns
    @@ -333,7 +333,7 @@
    -
    +
    Image Gallery
    @@ -371,7 +371,7 @@
    -
    +
    Comparisons
    @@ -473,7 +473,7 @@
    -
    +
    Call-to-actions