diff --git a/addons/website/static/src/css/snippets.css b/addons/website/static/src/css/snippets.css
index a19baa33fd6..4121b70ef2e 100644
--- a/addons/website/static/src/css/snippets.css
+++ b/addons/website/static/src/css/snippets.css
@@ -344,6 +344,12 @@
-moz-box-shadow: 0 0 5px 3px rgba(255, 255, 255, 0.7);
box-shadow: 0 0 5px 3px rgba(255, 255, 255, 0.7);
}
+.oe_overlay .oe_handle.readonly {
+ cursor: auto !important;
+}
+.oe_overlay .oe_handle.readonly:before, .oe_overlay .oe_handle.readonly.size {
+ display: none !important;
+}
.oe_overlay .icon.btn {
display: inline-block;
}
@@ -351,7 +357,7 @@
position: absolute;
left: 50% !important;
text-align: center;
- top: -11px;
+ top: -20px;
z-index: 1002;
}
.oe_overlay .oe_overlay_options > .btn-group {
@@ -618,8 +624,3 @@
height: 16px;
display: inline-block;
}
-
-[data-snippet-id] {
- min-height: 10px;
- min-width: 10px;
-}
diff --git a/addons/website/static/src/css/snippets.sass b/addons/website/static/src/css/snippets.sass
index afdb261a2a5..d7442a5b0f7 100644
--- a/addons/website/static/src/css/snippets.sass
+++ b/addons/website/static/src/css/snippets.sass
@@ -252,6 +252,10 @@
background: rgba(30, 30, 30, .8)
color: #fff
+box-shadow(0 0 5px 3px rgba(255,255,255,.7))
+ &.readonly
+ cursor: auto !important
+ &:before, &.size
+ display: none !important
.icon.btn
display: inline-block
@@ -260,7 +264,7 @@
position: absolute
left: 50% !important
text-align: center
- top: -11px
+ top: -20px
z-index: 1002
> .btn-group
left: -50%
@@ -485,10 +489,6 @@
height: 16px
display: inline-block
-[data-snippet-id]
- min-height: 10px
- min-width: 10px
-
diff --git a/addons/website/static/src/css/website.css b/addons/website/static/src/css/website.css
index 774be6ae09a..310f6b8156e 100644
--- a/addons/website/static/src/css/website.css
+++ b/addons/website/static/src/css/website.css
@@ -119,6 +119,7 @@ header a.navbar-brand img {
.container .container {
padding-left: 0;
padding-right: 0;
+ width: auto;
}
/* ----- BOOTSTRAP HACK FOR HEADER NAV BAR ----- */
@@ -280,12 +281,13 @@ ul.nav-stacked > li > a {
background-size: 100%;
}
-[data-snippet-id], .colmd, .hr, .blockquote {
+section, .carousel, .parallax, .row, .hr, .blockquote {
+ min-height: 30px;
overflow: hidden;
}
@media (max-width: 400px) {
- [data-snippet-id]:not([data-snippet-id="carousel"]) {
+ section, .parallax, .row, .hr, .blockquote {
height: auto !important;
}
}
@@ -380,10 +382,10 @@ ul.nav-stacked > li > a {
}
/* Parallax Theme */
-div.carousel[data-snippet-id="slider"] .carousel-indicators li {
+div.carousel .carousel-indicators li {
border: 1px solid grey;
}
-div.carousel[data-snippet-id="slider"] .carousel-indicators .active {
+div.carousel .carousel-indicators .active {
background-color: grey;
}
diff --git a/addons/website/static/src/css/website.sass b/addons/website/static/src/css/website.sass
index 4796d88cbb8..563dcae95ec 100644
--- a/addons/website/static/src/css/website.sass
+++ b/addons/website/static/src/css/website.sass
@@ -89,6 +89,7 @@ header
.container
padding-left: 0
padding-right: 0
+ width: auto
/* ----- BOOTSTRAP HACK FOR HEADER NAV BAR ----- */
@@ -230,11 +231,12 @@ ul.nav-stacked > li > a
.oe_img_bg
background-size: 100%
-[data-snippet-id],.colmd,.hr,.blockquote
+section, .carousel, .parallax, .row, .hr, .blockquote
+ min-height: 30px
overflow: hidden
@media (max-width: 400px)
- [data-snippet-id]:not([data-snippet-id="carousel"])
+ section, .parallax, .row, .hr, .blockquote
height: auto !important
.carousel-inner
@@ -312,7 +314,7 @@ ul.nav-stacked > li > a
/* Parallax Theme */
-div.carousel[data-snippet-id="slider"]
+div.carousel
.carousel-indicators
li
border: 1px solid grey
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 3965e1c3d1a..c89bf9ec2fb 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -106,6 +106,7 @@
},
canUndo: false,
editorFocus: true,
+ context: 'a',
});
//noinspection JSValidateTypes
editor.addCommand('image', {
@@ -115,6 +116,7 @@
},
canUndo: false,
editorFocus: true,
+ context: 'img',
});
editor.ui.addButton('Link', {
@@ -205,8 +207,9 @@
icon: '/website/static/src/img/bglink.png',
modes: { wysiwyg: true },
editorFocus: true,
+ context: 'a',
panel: {
- css: '/website/static/lib/bootstrap/css/bootstrap.css',
+ css: '/web/static/lib/bootstrap/css/bootstrap.css',
attributes: { 'role': 'listbox', 'aria-label': label },
},
@@ -346,14 +349,40 @@
requires: 'widget',
init: function (editor) {
+ var specials = {
+ // Can't find the correct ACL rule to only allow img tags
+ image: { content: '*' },
+ html: { text: '*' },
+ monetary: {
+ text: {
+ selector: 'span.oe_currency_value',
+ allowedContent: { }
+ }
+ }
+ };
+ _(specials).each(function (editable, type) {
+ editor.widgets.add(type, {
+ draggable: false,
+ editables: editable,
+ upcast: function (el) {
+ return el.attributes['data-oe-type'] === type;
+
+ }
+ });
+ });
editor.widgets.add('oeref', {
- editables: { text: '*' },
draggable: false,
-
+ editables: {
+ text: {
+ selector: '*',
+ allowedContent: { }
+ },
+ },
upcast: function (el) {
- var matches = el.attributes['data-oe-type'] && el.attributes['data-oe-type'] !== 'monetary';
- if (!matches) { return false; }
-
+ var type = el.attributes['data-oe-type'];
+ if (!type || (type in specials)) {
+ return false;
+ }
if (el.attributes['data-oe-original']) {
while (el.children.length) {
el.children[0].remove();
@@ -363,16 +392,9 @@
));
}
return true;
- },
- });
- editor.widgets.add('monetary', {
- editables: { text: 'span.oe_currency_value' },
- draggable: false,
-
- upcast: function (el) {
- return el.attributes['data-oe-type'] === 'monetary';
}
});
+
editor.widgets.add('icons', {
draggable: false,
diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js
index 54ee4689814..249058d91fb 100644
--- a/addons/website/static/src/js/website.js
+++ b/addons/website/static/src/js/website.js
@@ -231,11 +231,13 @@
dialog.on('click', '.btn-primary', function () {
def.resolve(field.val(), field, dialog);
dialog.remove();
+ $('.modal-backdrop').remove();
});
});
dialog.on('hidden.bs.modal', function () {
def.reject();
dialog.remove();
+ $('.modal-backdrop').remove();
});
if (field.is('input[type="text"], select')) {
field.keypress(function (e) {
diff --git a/addons/website/static/src/js/website.snippets.animation.js b/addons/website/static/src/js/website.snippets.animation.js
index f1d19125a0c..56ad596d71a 100644
--- a/addons/website/static/src/js/website.snippets.animation.js
+++ b/addons/website/static/src/js/website.snippets.animation.js
@@ -5,20 +5,26 @@
if (!website.snippet) website.snippet = {};
website.snippet.readyAnimation = [];
- website.snippet.start_animation = function () {
+ website.snippet.start_animation = function (editable_mode, $target) {
for (var k in website.snippet.animationRegistry) {
var Animation = website.snippet.animationRegistry[k];
- var selector = "[data-snippet-id='"+k+"']";
+ var selector = "";
if (Animation.prototype.selector) {
- selector += ", " + Animation.prototype.selector;
+ if (selector != "") selector += ", "
+ selector += Animation.prototype.selector;
}
+ if ($target) {
+ if ($target.is(selector)) selector = $target;
+ else continue;
+ }
+
$(selector).each(function() {
var $snipped_id = $(this);
if ( !$snipped_id.parents("#oe_snippets").length &&
!$snipped_id.parent("body").length &&
!$snipped_id.data("snippet-view")) {
website.snippet.readyAnimation.push($snipped_id);
- $snipped_id.data("snippet-view", new Animation($snipped_id));
+ $snipped_id.data("snippet-view", new Animation($snipped_id, editable_mode));
}
});
}
@@ -32,7 +38,9 @@
}
});
};
- $(document).ready(website.snippet.start_animation);
+ $(document).ready(function () {
+ website.snippet.start_animation();
+ });
website.snippet.animationRegistry = {};
@@ -41,9 +49,9 @@
$: function () {
return this.$el.find.apply(this.$el, arguments);
},
- init: function (dom) {
+ init: function (dom, editable_mode) {
this.$el = this.$target = $(dom);
- this.start();
+ this.start(editable_mode);
},
/*
* start
@@ -71,7 +79,7 @@
});
website.snippet.animationRegistry.parallax = website.snippet.Animation.extend({
- parallax: ".parallax",
+ selector: ".parallax",
start: function () {
var self = this;
setTimeout(function () {self.set_values();});
@@ -108,7 +116,7 @@
img.onload = function () {
var offset = 0;
var padding = parseInt($(document.body).css("padding-top"));
- if (speed < 1) {
+ if (speed > 1) {
var inner_offset = - self.$target.outerHeight() + this.height / this.width * document.body.clientWidth;
var outer_offset = self.$target.offset().top - (document.body.clientHeight - self.$target.outerHeight()) - padding;
offset = - outer_offset * speed + inner_offset;
@@ -123,4 +131,21 @@
}
});
+ website.snippet.animationRegistry.share = website.snippet.Animation.extend({
+ selector: ".oe_share",
+ start: function () {
+ var url = encodeURIComponent(window.location.href);
+ var title = encodeURIComponent($("title").text());
+ this.$target.find("a").each(function () {
+ var $a = $(this);
+ $a.attr("href", $(this).attr("href").replace("{url}", url).replace("{title}", title));
+ if ($a.attr("target") && $a.attr("target").match(/_blank/i)) {
+ $a.click(function () {
+ window.open(this.href,'','menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=550,width=600');
+ return false;
+ });
+ }
+ });
+ },
+ });
})();
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index ee07840b12d..8ff89466368 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -18,7 +18,7 @@
},
edit: function () {
var self = this;
- $("body").off('click');
+ $("[data-oe-model] *, [data-oe-type=html] *").off('click');
website.snippet.stop_animation();
window.snippets = this.snippets = new website.snippet.BuildingBlock(this);
this.snippets.appendTo(this.$el);
@@ -41,12 +41,7 @@
return this._super.apply(this, arguments);
},
save: function () {
- this.snippets.make_active(false);
-
- // FIXME: call clean_for_save on all snippets of the page, not only modified ones
- // important for banner of parallax that changes data automatically.
this.snippets.clean_for_save();
- remove_added_snippet_id();
this._super();
},
});
@@ -59,38 +54,14 @@
})) {
return;
}
- hack_to_add_snippet_id()
- });
-
- // puts $el at the same absolute position as $target
- function hack_to_add_snippet_id () {
- _.each(website.snippet.selector, function (val) {
- $(val[0]).each(function() {
- if (!$(this).is("[data-snippet-id]") && $(this).parents("[data-oe-model]").length) {
- $(this).attr("data-snippet-id", val[1]);
- }
- });
- });
- }
- function remove_added_snippet_id () {
- _.each(website.snippet.selector, function (val) {
- $(val[0]).each(function() {
- if ($(this).data("snippet-id") === val[1]) {
- $(this).removeAttr("data-snippet-id");
- }
- });
- });
- }
-
- $(document).ready(function() {
- hack_to_add_snippet_id();
});
// 'snippet-dropped' is triggered on '#oe_snippets' whith $target as attribute when a snippet is dropped
// 'snippet-activated' is triggered on '#oe_snippets' (and on snippet) when a snippet is activated
if (!website.snippet) website.snippet = {};
- website.snippet.styles = {};
+ website.snippet.templateOptions = {};
+ website.snippet.globalSelector = "";
website.snippet.selector = [];
website.snippet.BuildingBlock = openerp.Widget.extend({
template: 'website.snippets',
@@ -102,7 +73,6 @@
$("
").appendTo('body');
}
this.$active_snipped_id = false;
- hack_to_add_snippet_id();
this.snippets = [];
observer.observe(document.body, {
@@ -169,17 +139,23 @@
.then(function (html) {
var $html = $(html);
- var $styles = $html.find("[data-snippet-style-id]");
+ var selector = [];
+ var $styles = $html.find("[data-snippet-option-id]");
$styles.each(function () {
var $style = $(this);
- var style_id = $style.data('snippet-style-id');
- website.snippet.styles[style_id] = {
- 'snippet-style-id' : style_id,
+ var style_id = $style.data('snippet-option-id');
+ website.snippet.templateOptions[style_id] = {
+ 'snippet-option-id' : style_id,
'selector': $style.data('selector'),
'$el': $style,
+ 'selector-siblings': $style.data('selector-siblings'),
+ 'selector-children': $style.data('selector-children'),
+ 'selector-vertical-children': $style.data('selector-vertical-children')
};
+ selector.push($style.data('selector'));
});
$styles.addClass("hidden");
+ website.snippet.globalSelector = selector.join(",");
self.$snippets = $html.find(".tab-content > div > div").addClass("oe_snippet");
self.$el.append($html);
@@ -204,10 +180,10 @@
'top': pos.top - mt - 5,
'left': pos.left
});
- $el.find(">.e,>.w").css({'height': $target.outerHeight() + mt + mb+1});
- $el.find(">.s").css({'top': $target.outerHeight() + mt + mb});
- $el.find(">.size").css({'top': $target.outerHeight() + mt});
- $el.find(">.s,>.n").css({'width': $target.outerWidth()-2});
+ $el.find(".oe_handle.e,.oe_handle.w").css({'height': $target.outerHeight() + mt + mb+1});
+ $el.find(".oe_handle.s").css({'top': $target.outerHeight() + mt + mb});
+ $el.find(".oe_handle.size").css({'top': $target.outerHeight() + mt});
+ $el.find(".oe_handle.s,.oe_handle.n").css({'width': $target.outerWidth()-2});
},
show: function () {
this.$el.removeClass("hidden");
@@ -224,12 +200,24 @@
bind_snippet_click_editor: function () {
var self = this;
+ var snipped_event_flag;
$("#wrapwrap").on('click', function (event) {
- var $target = $(event.srcElement || event.target);
- if (!$target.attr("data-snippet-id")) {
- $target = $target.parents("[data-snippet-id]:first");
+ if (snipped_event_flag || !event.srcElement) {
+ return;
}
- if (!$target.attr("data-oe-model") && !$target.parents("[data-oe-model]:first").length) {
+ snipped_event_flag = true;
+
+ setTimeout(function () {snipped_event_flag = false;}, 0);
+ var $target = $(event.srcElement);
+
+ if ($target.parents(".oe_overlay").length) {
+ return;
+ }
+
+ if (!$target.is(website.snippet.globalSelector)) {
+ $target = $target.parents(website.snippet.globalSelector).first();
+ }
+ if (!self.dom_filter($target).length) {
$target = false;
}
if (self.$active_snipped_id && self.$active_snipped_id.is($target)) {
@@ -253,13 +241,16 @@
}
},
clean_for_save: function () {
- for (var k in this.snippets) {
- if (!this.snippets.hasOwnProperty(k)) { continue; }
- var editor = $(this.snippets[k]).data("snippet-editor");
+ var self = this;
+ $(website.snippet.globalSelector).each(function () {
+ var $snippet = $(this);
+ self.make_active($snippet);
+ self.make_active(false);
+ var editor = $snippet.data("snippet-editor");
if (editor) {
editor.clean_for_save();
}
- }
+ });
},
make_active: function ($snippet) {
if ($snippet && this.$active_snipped_id && this.$active_snipped_id.get(0) === $snippet.get(0)) {
@@ -286,8 +277,7 @@
if (typeof $snippet.data("snippet-editor") === 'undefined') {
var $targets = this.activate_overlay_zones($snippet);
if (!$targets.length) return;
- var editor = website.snippet.editorRegistry[$snippet.data("snippet-id")] || website.snippet.editorRegistry.resize;
- $snippet.data("snippet-editor", new editor(this, $snippet));
+ $snippet.data("snippet-editor", new website.snippet.Editor(this, $snippet));
}
this.cover_target($snippet.data('overlay'), $snippet);
},
@@ -323,36 +313,47 @@
start: function(){
self.hide();
dropped = false;
+ // snippet_selectors => to get selector-siblings, selector-children, selector-vertical-children
$snippet = $(this);
- snipped_id = $snippet.data('snippet-id');
+ $toInsert = $snippet.find('.oe_snippet_body').clone();
+ $toInsert.removeClass('oe_snippet_body');
+
+ var selector = [];
+ var selector_siblings = [];
+ var selector_children = [];
+ var selector_vertical_children = [];
+ for (var k in website.snippet.templateOptions) {
+ if ($toInsert.is(website.snippet.templateOptions[k].selector)) {
+ selector.push(website.snippet.templateOptions[k].selector);
+ if (website.snippet.templateOptions[k]['selector-siblings'])
+ selector_siblings.push(website.snippet.templateOptions[k]['selector-siblings']);
+ if (website.snippet.templateOptions[k]['selector-children'])
+ selector_children.push(website.snippet.templateOptions[k]['selector-children']);
+ if (website.snippet.templateOptions[k]['selector-vertical-children'])
+ selector_vertical_children.push(website.snippet.templateOptions[k]['selector-vertical-children']);
+ }
+ }
+
action = $snippet.find('.oe_snippet_body').size() ? 'insert' : 'mutate';
+
if( action === 'insert'){
- if (!$snippet.data('selector-siblings') && !$snippet.data('selector-children') && !$snippet.data('selector-vertical-children')) {
+ if (!selector_siblings.length && !selector_children.length && !selector_vertical_children.length) {
console.debug($snippet.data("snippet-id") + " have oe_snippet_body class and have not for insert action"+
"data-selector-siblings, data-selector-children or data-selector-vertical-children tag for mutate action");
return;
}
self.activate_insertion_zones({
- siblings: $snippet.data('selector-siblings'),
- children: $snippet.data('selector-children'),
- vertical_children: $snippet.data('selector-vertical-children')
+ siblings: selector_siblings.join(","),
+ children: selector_children.join(","),
+ vertical_children: selector_vertical_children.join(","),
});
- $toInsert = $snippet.find('.oe_snippet_body').clone();
- $toInsert.removeClass('oe_snippet_body');
- $toInsert.data('src-snippet-id', snipped_id);
- if (!$toInsert.data('snippet-id')) {
- $toInsert.attr('data-snippet-id', snipped_id);
- } else {
- snipped_id = $toInsert.data('snippet-id');
- }
-
} 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'));
+ var $targets = self.activate_overlay_zones(selector_children.join(","));
$targets.each(function(){
var $clone = $(this).data('overlay').clone();
$clone.addClass("oe_drop_zone").data('target', $(this));
@@ -387,38 +388,30 @@
}
$('.oe_drop_zone').droppable('destroy').remove();
+
if (dropped) {
var $target = false;
- if(action === 'insert'){
- $target = $toInsert;
+ $target = $toInsert;
- website.snippet.start_animation();
+ setTimeout(function () {
+ $("#oe_snippets").trigger('snippet-dropped', $target);
+ website.snippet.start_animation(true, $target);
+
+ // drop_and_build_snippet
self.create_overlay($target);
if ($target.data("snippet-editor")) {
$target.data("snippet-editor").drop_and_build_snippet($target);
}
-
- $target.find("[data-snippet-id]").each(function () {
- var $snippet = $(this);
- var snippet_id = $snippet.data("data-snippet-id");
- self.create_overlay($snippet);
- if ($snippet.data("snippet-editor")) {
- $snippet.data("snippet-editor").drop_and_build_snippet($snippet);
- }
- });
-
- } else {
- $target = $(this).data('target');
-
- self.create_overlay($target);
- if (website.snippet.editorRegistry[snipped_id]) {
- var snippet = new website.snippet.editorRegistry[snipped_id](self, $target);
- snippet.drop_and_build_snippet($target);
+ for (var k in website.snippet.templateOptions) {
+ $target.find(website.snippet.templateOptions[k].selector).each(function () {
+ var $snippet = $(this);
+ self.create_overlay($snippet);
+ if ($snippet.data("snippet-editor")) {
+ $snippet.data("snippet-editor").drop_and_build_snippet($snippet);
+ }
+ });
}
- }
- setTimeout(function () {
- $("#oe_snippets").trigger('snippet-dropped', $target);
// reset snippet for rte
$target.removeData("snippet-editor");
@@ -434,9 +427,9 @@
$snippet.removeData("overlay");
}
});
+ self.create_overlay($target);
// end
- self.create_overlay($target);
self.make_active($target);
},0);
} else {
@@ -554,7 +547,7 @@
// generate drop zones covering the elements selected by the selector
// we generate overlay drop zones only to get an idea of where the snippet are, the drop
activate_overlay_zones: function(selector){
- var $targets = this.dom_filter(selector || '[data-snippet-id]');
+ var $targets = this.dom_filter(selector);
var self = this;
if (typeof selector !== 'string' && !$targets.length) {
@@ -613,18 +606,19 @@
});
- website.snippet.styleRegistry = {};
- website.snippet.StyleEditor = openerp.Class.extend({
+ website.snippet.options = {};
+ website.snippet.Option = openerp.Class.extend({
// initialisation (don't overwrite)
- init: function (parent, $target, snippet_id) {
- this.parent = parent;
+ init: function (BuildingBlock, editor, $target, snippet_id) {
+ this.BuildingBlock = BuildingBlock;
+ this.editor = editor;
this.$target = $target;
- var styles = this.$target.data("snippet-style-ids") || {};
+ var styles = this.$target.data("snippet-option-ids") || {};
styles[snippet_id] = this;
- this.$target.data("snippet-style-ids", styles);
+ this.$target.data("snippet-option-ids", styles);
this.$overlay = this.$target.data('overlay');
- this['snippet-style-id'] = snippet_id;
- this.$el = website.snippet.styles[snippet_id].$el.find(">li").clone();
+ this['snippet-option-id'] = snippet_id;
+ this.$el = website.snippet.templateOptions[snippet_id].$el.find(">li").clone();
this.required = this.$el.data("required");
@@ -682,6 +676,13 @@
// start is call just after the init
start: function () {
},
+ /*
+ * drop_and_build_snippet
+ * This method is called just after that a thumbnail is drag and dropped into a drop zone
+ * (after the insertion of this.$body, if this.$body exists)
+ */
+ drop_and_build_snippet: function ($target) {
+ },
/* select
* called when a user select an item
* variables: np = {$next, $prev}
@@ -730,11 +731,15 @@
.first()
.addClass("active");
this.$el.find('li:has(li[data-class].active)').addClass("active");
+ },
+ /* clean_for_save
+ * function called just before save vue
+ */
+ clean_for_save: function () {
}
});
-
- website.snippet.styleRegistry.background = website.snippet.StyleEditor.extend({
+ website.snippet.options.background = website.snippet.Option.extend({
_get_bg: function () {
return this.$target.css("background-image").replace(/url\(['"]*|['"]*\)|^none$/g, "");
},
@@ -800,230 +805,181 @@
}
});
+ website.snippet.options.slider = website.snippet.Option.extend({
+ drop_and_build_snippet: function() {
+ var id = $(".carousel").length;
+ this.id = "myCarousel" + id;
+ this.$target.attr("id", this.id);
+ this.$target.find(".carousel-control").attr("href", "#myCarousel" + id);
+ this.$target.find("[data-target]").attr("data-target", "#myCarousel" + id);
- website.snippet.editorRegistry = {};
- website.snippet.Editor = openerp.Class.extend({
- init: function (parent, dom) {
- this.parent = parent;
- this.$target = $(dom);
- this.$overlay = this.$target.data('overlay');
- this.$overlay.find('a[data-toggle="dropdown"]').dropdown();
- this.snippet_id = this.$target.data("snippet-id");
- this._readXMLData();
- this.load_style_options();
- this.get_parent_block();
- this.start();
+ this.rebind_event();
},
-
- /*
- * _readXMLData
- * Read data XML and set value into:
- * this.$el :
- * all xml data
- * this.$overlay :
- * Dom hover the $target who content options
- * this.$editor :
- * content of .oe_snippet_options
- * Displayed into the overlay options on focus
- */
- _readXMLData: function() {
+ // rebind event to active carousel on edit mode
+ rebind_event: function () {
var self = this;
- this.$el = this.parent.$snippets.filter(function () { return $(this).data("snippet-id") == self.snippet_id; }).clone();
- this.$editor = this.$el.find(".oe_snippet_options");
- var $options = this.$overlay.find(".oe_overlay_options");
- this.$editor.prependTo($options.find(".oe_options ul"));
- if ($options.find(".oe_options ul li").length) {
- $options.find(".oe_options").removeClass("hidden");
- }
+ this.$target.find('.carousel-indicators [data-target]').off('click').on('click', function () {
+ self.$target.carousel(+$(this).data('slide-to')); });
+
+ this.$target.attr('contentEditable', 'false');
+ this.$target.find('.oe_structure, .content>.row').attr('contentEditable', 'true');
},
-
-
- // activate drag and drop for the snippets in the snippet toolbar
- _drag_and_drop: function(){
- var self = this;
- this.dropped = false;
- this.$overlay.draggable({
- greedy: true,
- appendTo: 'body',
- cursor: "move",
- handle: ".oe_snippet_move",
- cursorAt: {
- left: 18,
- top: 14
- },
- helper: function() {
- var $clone = $(this).clone().css({width: "24px", height: "24px", border: 0});
- $clone.find(".oe_overlay_options >:not(:contains(.oe_snippet_move)), .oe_handle").remove();
- $clone.find(":not(.glyphicon)").css({position: 'absolute', top: 0, left: 0});
- $clone.appendTo("body").removeClass("hidden");
- return $clone;
- },
- start: _.bind(self._drag_and_drop_start, self),
- stop: _.bind(self._drag_and_drop_stop, self)
- });
- },
- _drag_and_drop_after_insert_dropzone: function (){},
- _drag_and_drop_active_drop_zone: function ($zones){
- var self = this;
- $zones.droppable({
- over: function(){
- $(".oe_drop_zone.hide").removeClass("hide");
- $(this).addClass("hide").first().after(self.$target);
- self.dropped = true;
- },
- out: function(){
- $(this).removeClass("hide");
- self.$target.detach();
- self.dropped = false;
- },
- });
- },
- _drag_and_drop_start: function (){
- var self = this;
- self.parent.hide();
- self.parent.editor_busy = true;
- self.size = {
- width: self.$target.width(),
- height: self.$target.height()
- };
- self.$target.after("
");
- self.$target.detach();
- self.$overlay.addClass("hidden");
-
- self.parent.activate_insertion_zones({
- siblings: self.$el ? self.$el.data('selector-siblings') : false,
- children: self.$el ? self.$el.data('selector-children') : false,
- vertical_children: self.$el ? self.$el.data('selector-vertical-children') : false,
- });
-
- $("body").addClass('move-important');
-
- self._drag_and_drop_after_insert_dropzone();
- self._drag_and_drop_active_drop_zone($('.oe_drop_zone'));
- },
- _drag_and_drop_stop: function (){
- var self = this;
- if (!self.dropped) {
- $(".oe_drop_clone").after(self.$target);
- }
- self.$overlay.removeClass("hidden");
- $("body").removeClass('move-important');
- $('.oe_drop_zone').droppable('destroy').remove();
- $(".oe_drop_clone, .oe_drop_to_remove").remove();
- self.parent.editor_busy = false;
- self.get_parent_block();
- setTimeout(function () {self.parent.create_overlay(self.$target);},0);
- },
-
- load_style_options: function () {
- var self = this;
- var $styles = this.$overlay.find('.oe_options');
- var $ul = $styles.find('ul:first');
- _.each(website.snippet.styles, function (val) {
- if (!self.parent.dom_filter(val.selector).is(self.$target)) {
- return;
- }
- var Editor = website.snippet.styleRegistry[val['snippet-style-id']] || website.snippet.StyleEditor;
- var editor = new Editor(self, self.$target, val['snippet-style-id']);
- $ul.prepend(editor.$el.addClass("snippet-style-" + val['snippet-style-id']));
- });
-
- if ($ul.find("li").length) {
- $styles.removeClass("hidden");
- }
- },
-
- get_parent_block: function () {
- var self = this;
- var $button = this.$overlay.find('.oe_snippet_parent');
- var $parent = this.$target.parents("[data-snippet-id]:first");
- if ($parent.length) {
- $button.removeClass("hidden");
- $button.off("click").on('click', function (event) {
- event.preventDefault();
- setTimeout(function () {
- self.parent.make_active($parent);
- }, 0);
- });
- } else {
- $button.addClass("hidden");
- }
- },
-
- /*
- * start
- * This method is called after init and _readXMLData
- */
- start: function () {
- var self = this;
- this.$overlay.on('click', '.oe_snippet_clone', _.bind(this.on_clone, this));
- this.$overlay.on('click', '.oe_snippet_remove', _.bind(this.on_remove, this));
- this._drag_and_drop();
- },
-
- on_clone: function () {
- var $clone = this.$target.clone(false);
- this.$target.after($clone);
- return false;
- },
-
- on_remove: function () {
- this.onBlur();
- var index = _.indexOf(this.parent.snippets, this.$target.get(0));
- delete this.parent.snippets[index];
- this.$target.remove();
- this.$overlay.remove();
- return false;
- },
-
- /*
- * drop_and_build_snippet
- * This method is called just after that a thumbnail is drag and dropped into a drop zone
- * (after the insertion of this.$body, if this.$body exists)
- */
- drop_and_build_snippet: function ($target) {
- },
-
- /* onFocus
- * This method is called when the user click inside the snippet in the dom
- */
- onFocus : function () {
- this.$overlay.addClass('oe_active');
- },
-
- /* onFocus
- * This method is called when the user click outside the snippet in the dom, after a focus
- */
- onBlur : function () {
- this.$overlay.removeClass('oe_active');
- },
-
- /* clean_for_save
- * function called just before save vue
- */
clean_for_save: function () {
- this.$target.removeAttr('contentEditable')
- .find('*').removeAttr('contentEditable');
- this.$target.removeAttr('attributeEditable')
- .find('*').removeAttr('attributeEditable');
+ this._super();
+ this.$target.find(".item").removeClass("next prev left right");
+ if(!this.$target.find(".item.active").length) {
+ this.$target.find(".item:first").addClass("active");
+ }
+ },
+ start : function () {
+ var self = this;
+ this._super();
+ this.id = this.$target.attr("id");
+ this.$inner = this.$target.find('.carousel-inner');
+ this.$indicators = this.$target.find('.carousel-indicators');
+
+ this.$el.find(".js_add").on('click', function () {self.on_add_slide(); return false;});
+ this.$el.find(".js_remove").on('click', function () {self.on_remove_slide(); return false;});
+
+ this.$target.carousel('pause');
+ this.rebind_event();
+ },
+ on_add_slide: function () {
+ var self = this;
+ var cycle = this.$inner.find('.item').length;
+ 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.$target.find(".item.active").clone();
+
+ // insert
+ $clone.removeClass('active').insertAfter($active);
+ setTimeout(function() {
+ self.$target.carousel().carousel(++index);
+ self.rebind_event();
+ },0);
+ return $clone;
+ },
+ on_remove_slide: function () {
+ 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.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_slide(event);
+ }
+ });
+ setTimeout(function () {
+ self.$target.carousel( index > 0 ? --index : cycle );
+ }, 500);
+ } else {
+ this.$target.find('.carousel-control, .carousel-indicators').addClass("hidden");
+ }
+ },
+ });
+ website.snippet.options.carousel = website.snippet.options.slider.extend({
+ getSize: function () {
+ this.grid = this._super();
+ this.grid.size = 8;
+ return this.grid;
+ },
+ clean_for_save: function () {
+ this._super();
+ this.$target.css("background-image", "");
+ this.$target.removeClass(this._class);
+ },
+ load_style_options : function () {
+ this._super();
+ $(".snippet-style-size li[data-class='']").remove();
+ },
+ start : function () {
+ var self = this;
+ this._super();
+
+ // set background and prepare to clean for save
+ var add_class = function (c){
+ if (c) self._class = (self._class || "").replace(new RegExp("[ ]+" + c.replace(" ", "|[ ]+")), '') + ' ' + c;
+ return self._class || "";
+ };
+ this.$target.on('snippet-style-change snippet-style-preview', function (event, style, np) {
+ var $active = self.$target.find(".item.active");
+ if (style['snippet-option-id'] === "size") return;
+ if (style['snippet-option-id'] === "background") {
+ $active.css("background-image", self.$target.css("background-image"));
+ }
+ if (np.$prev) {
+ $active.removeClass(np.$prev.data("class"));
+ }
+ if (np.$next) {
+ $active.addClass(np.$next.data("class"));
+ add_class(np.$next.data("class"));
+ }
+ });
+ this.$target.on('slid', function () { // slide.bs.carousel
+ var $active = self.$target.find(".item.active");
+ self.$target
+ .css("background-image", $active.css("background-image"))
+ .removeClass(add_class($active.attr("class")))
+ .addClass($active.attr("class"))
+ .trigger("snippet-style-reset");
+
+ self.$target.carousel("pause");
+ });
+ this.$target.trigger('slid');
+ },
+ on_add_slide: function () {
+ var $clone = this._super();
+
+ // choose an other background
+ var bg = this.$target.data("snippet-option-ids").background;
+ if (!bg) return $clone;
+
+ var $styles = bg.$el.find("li[data-class]:not(.oe_custom_bg)");
+ var styles_index = $styles.index($styles.filter(".active")[0]);
+ var $select = $($styles[styles_index >= $styles.length-1 ? 0 : styles_index+1]);
+ $clone.css("background-image", $select.data("src") ? "url('"+ $select.data("src") +"')" : "");
+ $clone.addClass($select.data("class") || "");
+
+ return $clone;
+ },
+ // rebind event to active carousel on edit mode
+ rebind_event: function () {
+ var self = this;
+ this.$target.find('.carousel-control').off('click').on('click', function () {
+ self.$target.carousel( $(this).data('slide')); });
+
+ this.$target.find('.carousel-inner .content > div').attr('contentEditable', 'true');
+ this.$target.find('.carousel-image').attr('attributeEditable', 'true');
+ this._super();
},
});
-
- website.snippet.editorRegistry.resize = website.snippet.Editor.extend({
+ website.snippet.options.marginAndResize = website.snippet.Option.extend({
start: function () {
var self = this;
this._super();
- var $box = $(openerp.qweb.render("website.snippets.resize"));
var resize_values = this.getSize();
- if (!resize_values.n) $box.find(".oe_handle.n").remove();
- if (!resize_values.s) $box.find(".oe_handle.s").remove();
- if (!resize_values.e) $box.find(".oe_handle.e").remove();
- if (!resize_values.w) $box.find(".oe_handle.w").remove();
- if (!resize_values.size) $box.find(".oe_handle.size").remove();
-
- this.$overlay.append($box.find(".oe_handles").html());
+ if (resize_values.n) this.$overlay.find(".oe_handle.n").removeClass("readonly");
+ if (resize_values.s) this.$overlay.find(".oe_handle.s").removeClass("readonly");
+ if (resize_values.e) this.$overlay.find(".oe_handle.e").removeClass("readonly");
+ if (resize_values.w) this.$overlay.find(".oe_handle.w").removeClass("readonly");
+ if (resize_values.size) this.$overlay.find(".oe_handle.size").removeClass("readonly");
this.$overlay.find(".oe_handle:not(:has(.oe_handle_button)), .oe_handle .oe_handle_button").on('mousedown', function (event){
event.preventDefault();
@@ -1076,7 +1032,7 @@
var regClass = new RegExp("\\s*" + resize[0][begin].replace(/[-]*[0-9]+/, '[-]*[0-9]+'), 'g');
}
- self.parent.editor_busy = true;
+ self.BuildingBlock.editor_busy = true;
var cursor = $handle.css("cursor")+'-important';
var $body = $(document.body);
@@ -1090,7 +1046,7 @@
if (dy <= 0) dy = resize;
self.$target.css("height", dy+"px");
self.on_resize(compass, null, dy);
- self.parent.cover_target(self.$overlay, self.$target);
+ self.BuildingBlock.cover_target(self.$overlay, self.$target);
return;
}
var dd = event['page'+XY] - xy + resize[1][begin];
@@ -1113,7 +1069,7 @@
if (change) {
self.on_resize(compass, beginClass, current);
- self.parent.cover_target(self.$overlay, self.$target);
+ self.BuildingBlock.cover_target(self.$overlay, self.$target);
}
};
@@ -1121,7 +1077,7 @@
$body.unbind('mousemove', body_mousemove);
$body.unbind('mouseup', body_mouseup);
$body.removeClass(cursor);
- self.parent.editor_busy = false;
+ self.BuildingBlock.editor_busy = false;
self.$target.removeClass("resize_editor_busy");
};
$body.mousemove(body_mousemove);
@@ -1129,14 +1085,7 @@
});
},
getSize: function () {
- var grid = [0,4,8,16,32,48,64,92,128];
- this.grid = {
- // list of class (Array), grid (Array), default value (INT)
- n: [_.map(grid, function (v) {return 'mt'+v;}), grid],
- s: [_.map(grid, function (v) {return 'mb'+v;}), grid],
- // INT if the user can resize the snippet (resizing per INT px)
- size: null
- };
+ this.grid = {};
return this.grid;
},
@@ -1182,8 +1131,21 @@
this.change_cursor();
}
});
-
- website.snippet.editorRegistry.colmd = website.snippet.editorRegistry.resize.extend({
+ website.snippet.options["margin-y"] = website.snippet.options.marginAndResize.extend({
+ getSize: function () {
+ this.grid = this._super();
+ var grid = [0,4,8,16,32,48,64,92,128];
+ this.grid = {
+ // list of class (Array), grid (Array), default value (INT)
+ n: [_.map(grid, function (v) {return 'mt'+v;}), grid],
+ s: [_.map(grid, function (v) {return 'mb'+v;}), grid],
+ // INT if the user can resize the snippet (resizing per INT px)
+ size: null
+ };
+ return this.grid;
+ },
+ });
+ website.snippet.options["margin-x"] = website.snippet.options.marginAndResize.extend({
getSize: function () {
this.grid = this._super();
var width = this.$target.parents(".row:first").first().outerWidth();
@@ -1247,7 +1209,7 @@
return false;
} else {
if (!$parent.data("snippet-editor")) {
- this.parent.create_overlay($parent);
+ this.BuildingBlock.create_overlay($parent);
}
$parent.data("snippet-editor").on_remove();
}
@@ -1281,168 +1243,24 @@
},
});
- website.snippet.editorRegistry.slider = website.snippet.editorRegistry.resize.extend({
+ website.snippet.options["resize"] = website.snippet.options.marginAndResize.extend({
getSize: function () {
this.grid = this._super();
this.grid.size = 8;
return this.grid;
},
- drop_and_build_snippet: function() {
- var id = $(".carousel").length;
- this.id = "myCarousel" + id;
- this.$target.attr("id", this.id);
- this.$target.find(".carousel-control").attr("href", "#myCarousel" + id);
- this.$target.find("[data-target]").attr("data-target", "#myCarousel" + id);
-
- this.rebind_event();
- },
- // rebind event to active carousel on edit mode
- rebind_event: function () {
- var self = this;
- this.$target.find('.carousel-indicators [data-target]').off('click').on('click', function () {
- self.$target.carousel(+$(this).data('slide-to')); });
-
- this.$target.attr('contentEditable', 'false');
- this.$target.find('.oe_structure, .content>.row').attr('contentEditable', 'true');
- },
- clean_for_save: function () {
- this._super();
- this.$target.find(".item").removeClass("next prev left right");
- if(!this.$target.find(".item.active").length) {
- this.$target.find(".item:first").addClass("active");
- }
- },
- start : function () {
+ start: function () {
var self = this;
this._super();
- this.id = this.$target.attr("id");
- this.$inner = this.$target.find('.carousel-inner');
- this.$indicators = this.$target.find('.carousel-indicators');
-
- this.$editor.find(".js_add").on('click', function () {self.on_add_slide(); return false;});
- this.$editor.find(".js_remove").on('click', function () {self.on_remove_slide(); return false;});
-
- this.rebind_event();
- },
- on_add_slide: function () {
- var self = this;
- var cycle = this.$inner.find('.item').length;
- 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();
-
- // insert
- $clone.removeClass('active').insertAfter($active);
- setTimeout(function() {
- self.$target.carousel().carousel(++index);
- self.rebind_event();
- },0);
- return $clone;
- },
- on_remove_slide: function () {
- 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.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_slide(event);
- }
- });
- setTimeout(function () {
- self.$target.carousel( index > 0 ? --index : cycle );
- }, 500);
- } else {
- this.$target.find('.carousel-control, .carousel-indicators').addClass("hidden");
- }
+ this.$el.find(".js_size_auto").on('click', function (event){
+ self.$target.css("height", "");
+ self.BuildingBlock.cover_target(self.$overlay, self.$target);
+ return false;
+ });
},
});
- website.snippet.editorRegistry.carousel = website.snippet.editorRegistry.slider.extend({
- clean_for_save: function () {
- this._super();
- this.$target.css("background-image", "");
- this.$target.removeClass(this._class);
- },
- load_style_options : function () {
- this._super();
- $(".snippet-style-size li[data-class='']").remove();
- },
- start : function () {
- var self = this;
- this._super();
-
- // set background and prepare to clean for save
- var add_class = function (c){
- if (c) self._class = (self._class || "").replace(new RegExp("[ ]+" + c.replace(" ", "|[ ]+")), '') + ' ' + c;
- return self._class || "";
- };
- this.$target.on('snippet-style-change snippet-style-preview', function (event, style, np) {
- var $active = self.$target.find(".item.active");
- if (style['snippet-style-id'] === "size") return;
- if (style['snippet-style-id'] === "background") {
- $active.css("background-image", self.$target.css("background-image"));
- }
- if (np.$prev) {
- $active.removeClass(np.$prev.data("class"));
- }
- if (np.$next) {
- $active.addClass(np.$next.data("class"));
- add_class(np.$next.data("class"));
- }
- });
- this.$target.on('slid', function () { // slide.bs.carousel
- var $active = self.$target.find(".item.active");
- self.$target
- .css("background-image", $active.css("background-image"))
- .removeClass(add_class($active.attr("class")))
- .addClass($active.attr("class"))
- .trigger("snippet-style-reset");
-
- self.$target.carousel();
- });
- this.$target.trigger('slid');
- },
- on_add_slide: function () {
- var $clone = this._super();
-
- // choose an other background
- var $styles = this.$target.data("snippet-style-ids").background.$el.find("li[data-class]:not(.oe_custom_bg)");
- var styles_index = $styles.index($styles.filter(".active")[0]);
- var $select = $($styles[styles_index >= $styles.length-1 ? 0 : styles_index+1]);
- $clone.css("background-image", $select.data("src") ? "url('"+ $select.data("src") +"')" : "");
- $clone.addClass($select.data("class") || "");
-
- return $clone;
- },
- // rebind event to active carousel on edit mode
- rebind_event: function () {
- var self = this;
- this.$target.find('.carousel-control').off('click').on('click', function () {
- self.$target.carousel( $(this).data('slide')); });
-
- this.$target.find('.carousel-inner .content > div').attr('contentEditable', 'true');
- this.$target.find('.carousel-image').attr('attributeEditable', 'true');
- this._super();
- },
- });
-
- website.snippet.editorRegistry.parallax = website.snippet.editorRegistry.resize.extend({
+ website.snippet.options.parallax = website.snippet.Option.extend({
getSize: function () {
this.grid = this._super();
this.grid.size = 8;
@@ -1466,7 +1284,7 @@
},
scroll: function () {
var self = this;
- var $ul = this.$editor.find('ul[name="parallax-scroll"]');
+ var $ul = this.$el.find('ul[name="parallax-scroll"]');
var $li = $ul.find("li");
var speed = this.$target.data('scroll-background-ratio') || 0.6 ;
$ul.find('[data-value="' + speed + '"]').addClass('active');
@@ -1488,13 +1306,232 @@
}
});
- /*
- * data-snippet-id automatically setted
- * Don't need to add data-snippet-id="..." into the views
- */
- website.snippet.selector.push([".row > [class*='col-md-']", 'colmd']);
- website.snippet.selector.push(['hr', 'hr']);
- website.snippet.selector.push(['blockquote', 'quote']);
+ website.snippet.Editor = openerp.Class.extend({
+ init: function (BuildingBlock, dom) {
+ this.BuildingBlock = BuildingBlock;
+ this.$target = $(dom);
+ this.$overlay = this.$target.data('overlay');
+ this.snippet_id = this.$target.data("snippet-id");
+ this._readXMLData();
+ this.load_style_options();
+ this.get_parent_block();
+ this.start();
+ },
+
+ /*
+ * _readXMLData
+ * Read data XML and set value into:
+ * this.$el :
+ * all xml data
+ * this.$overlay :
+ * Dom hover the $target who content options
+ */
+ _readXMLData: function() {
+ var self = this;
+ this.$el = this.BuildingBlock.$snippets.filter(function () { return $(this).data("snippet-id") == self.snippet_id; }).clone();
+ var $options = this.$overlay.find(".oe_overlay_options");
+ if ($options.find(".oe_options ul li").length) {
+ $options.find(".oe_options").removeClass("hidden");
+ }
+ },
+
+
+ // activate drag and drop for the snippets in the snippet toolbar
+ _drag_and_drop: function(){
+ var self = this;
+ this.dropped = false;
+ this.$overlay.draggable({
+ greedy: true,
+ appendTo: 'body',
+ cursor: "move",
+ handle: ".oe_snippet_move",
+ cursorAt: {
+ left: 18,
+ top: 14
+ },
+ helper: function() {
+ var $clone = $(this).clone().css({width: "24px", height: "24px", border: 0});
+ $clone.find(".oe_overlay_options >:not(:contains(.oe_snippet_move)), .oe_handle").remove();
+ $clone.find(":not(.glyphicon)").css({position: 'absolute', top: 0, left: 0});
+ $clone.appendTo("body").removeClass("hidden");
+ return $clone;
+ },
+ start: _.bind(self._drag_and_drop_start, self),
+ stop: _.bind(self._drag_and_drop_stop, self)
+ });
+ },
+ _drag_and_drop_after_insert_dropzone: function (){},
+ _drag_and_drop_active_drop_zone: function ($zones){
+ var self = this;
+ $zones.droppable({
+ over: function(){
+ $(".oe_drop_zone.hide").removeClass("hide");
+ $(this).addClass("hide").first().after(self.$target);
+ self.dropped = true;
+ },
+ out: function(){
+ $(this).removeClass("hide");
+ self.$target.detach();
+ self.dropped = false;
+ },
+ });
+ },
+ _drag_and_drop_start: function (){
+ var self = this;
+ self.BuildingBlock.hide();
+ self.BuildingBlock.editor_busy = true;
+ self.size = {
+ width: self.$target.width(),
+ height: self.$target.height()
+ };
+ self.$target.after("
");
+ self.$target.detach();
+ self.$overlay.addClass("hidden");
+
+ self.BuildingBlock.activate_insertion_zones({
+ siblings: self.selector_siblings,
+ children: self.selector_children,
+ vertical_children: self.selector_vertical_children,
+ });
+
+ $("body").addClass('move-important');
+
+ self._drag_and_drop_after_insert_dropzone();
+ self._drag_and_drop_active_drop_zone($('.oe_drop_zone'));
+ },
+ _drag_and_drop_stop: function (){
+ var self = this;
+ if (!self.dropped) {
+ $(".oe_drop_clone").after(self.$target);
+ }
+ self.$overlay.removeClass("hidden");
+ $("body").removeClass('move-important');
+ $('.oe_drop_zone').droppable('destroy').remove();
+ $(".oe_drop_clone, .oe_drop_to_remove").remove();
+ self.BuildingBlock.editor_busy = false;
+ self.get_parent_block();
+ setTimeout(function () {self.BuildingBlock.create_overlay(self.$target);},0);
+ },
+
+ load_style_options: function () {
+ var self = this;
+ var $styles = this.$overlay.find('.oe_options');
+ var $ul = $styles.find('ul:first');
+ this.styles = {};
+ this.selector_siblings = [];
+ this.selector_children = [];
+ this.selector_vertical_children = [];
+ _.each(website.snippet.templateOptions, function (val) {
+ if (!self.$target.is(val.selector)) {
+ return;
+ }
+ if (val['selector-siblings']) self.selector_siblings.push(val['selector-siblings']);
+ if (val['selector-children']) self.selector_children.push(val['selector-children']);
+ if (val['selector-vertical-children']) self.selector_vertical_children.push(val['selector-vertical-children']);
+
+ var style = val['snippet-option-id'];
+ var Editor = website.snippet.options[style] || website.snippet.Option;
+ var editor = self.styles[style] = new Editor(self.BuildingBlock, self, self.$target, style);
+ $ul.append(editor.$el.addClass("snippet-style-" + style));
+ });
+ this.selector_siblings = this.selector_siblings.join(",");
+ if (this.selector_siblings === "")
+ this.selector_siblings = false;
+ this.selector_children = this.selector_children.join(",");
+ if (this.selector_children === "")
+ this.selector_children = false;
+ this.selector_vertical_children = this.selector_vertical_children.join(",");
+ if (this.selector_vertical_children === "")
+ this.selector_vertical_children = false;
+
+
+ if ($ul.find("li").length) {
+ $styles.removeClass("hidden");
+ }
+ this.$overlay.find('[data-toggle="dropdown"]').dropdown();
+ },
+
+ get_parent_block: function () {
+ var self = this;
+ var $button = this.$overlay.find('.oe_snippet_parent');
+ var $parent = this.$target.parents("[data-snippet-id]:first");
+ if ($parent.length) {
+ $button.removeClass("hidden");
+ $button.off("click").on('click', function (event) {
+ event.preventDefault();
+ setTimeout(function () {
+ self.BuildingBlock.make_active($parent);
+ }, 0);
+ });
+ } else {
+ $button.addClass("hidden");
+ }
+ },
+
+ /*
+ * start
+ * This method is called after init and _readXMLData
+ */
+ start: function () {
+ var self = this;
+ this.$overlay.on('click', '.oe_snippet_clone', _.bind(this.on_clone, this));
+ this.$overlay.on('click', '.oe_snippet_remove', _.bind(this.on_remove, this));
+ this._drag_and_drop();
+ },
+
+ on_clone: function () {
+ var $clone = this.$target.clone(false);
+ this.$target.after($clone);
+ return false;
+ },
+
+ on_remove: function () {
+ this.onBlur();
+ var index = _.indexOf(this.BuildingBlock.snippets, this.$target.get(0));
+ delete this.BuildingBlock.snippets[index];
+ this.$target.remove();
+ this.$overlay.remove();
+ return false;
+ },
+
+ /*
+ * drop_and_build_snippet
+ * This method is called just after that a thumbnail is drag and dropped into a drop zone
+ * (after the insertion of this.$body, if this.$body exists)
+ */
+ drop_and_build_snippet: function ($target) {
+ for (var i in this.styles){
+ this.styles[i].drop_and_build_snippet($target);
+ }
+ },
+
+ /* onFocus
+ * This method is called when the user click inside the snippet in the dom
+ */
+ onFocus : function () {
+ this.$overlay.addClass('oe_active');
+ },
+
+ /* onFocus
+ * This method is called when the user click outside the snippet in the dom, after a focus
+ */
+ onBlur : function () {
+ this.$overlay.removeClass('oe_active');
+ },
+
+ /* clean_for_save
+ * function called just before save vue
+ */
+ clean_for_save: function () {
+ for (var i in this.styles){
+ this.styles[i].clean_for_save();
+ }
+ this.$target.removeAttr('contentEditable')
+ .find('*').removeAttr('contentEditable');
+ this.$target.removeAttr('attributeEditable')
+ .find('*').removeAttr('attributeEditable');
+ },
+ });
})();
diff --git a/addons/website/static/src/js/website.tour.banner.js b/addons/website/static/src/js/website.tour.banner.js
index 40730e5dc09..ff3ed030f76 100644
--- a/addons/website/static/src/js/website.tour.banner.js
+++ b/addons/website/static/src/js/website.tour.banner.js
@@ -39,7 +39,7 @@
popover: { fixed: true },
},
{
- snippet: 'carousel',
+ snippet: '#snippet_structure .oe_snippet:first',
placement: 'bottom',
title: _t("Drag & Drop a Banner"),
content: _t("Drag the Banner block and drop it in your page."),
@@ -47,14 +47,14 @@
},
{
waitFor: '.oe_overlay_options .oe_options:visible',
- element: '#wrap [data-snippet-id=carousel]:first .carousel-caption > div',
+ element: '#wrap .carousel:first .carousel-caption > div',
placement: 'top',
title: _t("Customize banner's text"),
content: _t("Click in the text and start editing it."),
popover: { next: _t("Continue") },
},
{
- element: '.oe_overlay_options .oe_options',
+ element: '.oe_overlay_options .oe_options:visible',
placement: 'left',
title: _t("Customize the banner"),
content: _t("Customize any block through this menu. Try to change the background of the banner."),
@@ -69,14 +69,7 @@
popover: { fixed: true },
},
{
- element: 'a[href="#snippet_feature"]',
- placement: 'bottom',
- title: _t("Feature blocks list"),
- content: _t("Click on 'Features' to see the feature blocks list."),
- popover: { fixed: true },
- },
- {
- snippet: 'features',
+ snippet: '#snippet_structure .oe_snippet:eq(6)',
placement: 'bottom',
title: _t("Drag & Drop This Block"),
content: _t("Drag the
'Features' block and drop it below the banner."),
@@ -92,8 +85,8 @@
},
{
waitFor: 'button[data-action=edit]:visible',
- title: _("Good Job!"),
- content: _("Well done, you created your homepage."),
+ title: _t("Good Job!"),
+ content: _t("Well done, you created your homepage."),
popover: { next: _t("Continue") },
},
{
diff --git a/addons/website/static/src/js/website.tour.js b/addons/website/static/src/js/website.tour.js
index 2416cb511f1..a17115d2184 100644
--- a/addons/website/static/src/js/website.tour.js
+++ b/addons/website/static/src/js/website.tour.js
@@ -205,7 +205,7 @@ website.Tour = openerp.Class.extend({
if (!step.element) step.orphan = true;
if (step.snippet) {
- step.element = '#oe_snippets div.oe_snippet[data-snippet-id="'+step.snippet+'"] .oe_snippet_thumbnail';
+ step.element = '#oe_snippets '+step.snippet+' .oe_snippet_thumbnail';
}
}
@@ -377,7 +377,7 @@ website.Tour = openerp.Class.extend({
if (step.snippet) {
- var selector = '#oe_snippets div.oe_snippet[data-snippet-id="'+step.snippet+'"] .oe_snippet_thumbnail';
+ var selector = '#oe_snippets '+step.snippet+' .oe_snippet_thumbnail';
self.autoDragAndDropSnippet(selector);
} else if (step.element.match(/#oe_snippets .* \.oe_snippet_thumbnail/)) {
diff --git a/addons/website/static/src/js/website.tour.test.admin.js b/addons/website/static/src/js/website.tour.test.admin.js
index 787f05beb23..01f4448abb2 100644
--- a/addons/website/static/src/js/website.tour.test.admin.js
+++ b/addons/website/static/src/js/website.tour.test.admin.js
@@ -57,7 +57,7 @@
},
{
title: 'add snippets',
- snippet: 'carousel',
+ snippet: '#snippet_structure .oe_snippet:first',
},
{
title: 'try to save',
diff --git a/addons/website/static/src/xml/website.editor.xml b/addons/website/static/src/xml/website.editor.xml
index 1010ec05127..09aa3783c3f 100644
--- a/addons/website/static/src/xml/website.editor.xml
+++ b/addons/website/static/src/xml/website.editor.xml
@@ -97,7 +97,7 @@
target="fileframe"
class="col-sm-8">
-
+
diff --git a/addons/website/static/src/xml/website.snippets.xml b/addons/website/static/src/xml/website.snippets.xml
index ae109139e3c..511876b116d 100644
--- a/addons/website/static/src/xml/website.snippets.xml
+++ b/addons/website/static/src/xml/website.snippets.xml
@@ -22,7 +22,7 @@
-
+
@@ -45,13 +52,6 @@
diff --git a/addons/website/views/snippets.xml b/addons/website/views/snippets.xml
index eb32feef194..f91bd969c70 100644
--- a/addons/website/views/snippets.xml
+++ b/addons/website/views/snippets.xml
@@ -13,14 +13,7 @@
-
-
-
- Add Slide
-
-
- Remove Slide
-
+
Banner
@@ -51,7 +44,7 @@
-
+
Text-Image
@@ -79,7 +72,7 @@
-
+
Image-Text
@@ -107,7 +100,7 @@
-
+
Big Message
@@ -128,7 +121,7 @@
-
+
Text Block
@@ -166,7 +159,7 @@
-
+
Title
@@ -183,7 +176,7 @@
-
+
Features
@@ -214,7 +207,7 @@
-
+
Big Picture
@@ -246,7 +239,7 @@
-
+
Three Columns
@@ -291,7 +284,7 @@
-
+
Well
@@ -303,7 +296,7 @@
-
+
Quote
@@ -318,7 +311,7 @@
-
+
Panel
@@ -335,7 +328,7 @@
-
+
Separator
@@ -343,11 +336,29 @@
+
+
+
+

+
Share
+
+
+
+
-
+
Portfolio
@@ -380,7 +391,7 @@
-
+
Image Gallery
@@ -422,7 +433,7 @@
-
+
Comparisons
@@ -528,7 +539,7 @@
-
+
Button
@@ -545,7 +556,7 @@
-
+
FAQ
@@ -592,7 +603,7 @@
-
+
References
@@ -609,7 +620,7 @@
-
+
Write a quote here from one of your customers. Quotes are a
great way to build confidence in your products or services.
@@ -618,7 +629,7 @@
-
+
OpenERP provides essential platform for our project management.
Things are better organized and more visible with it.
@@ -646,14 +657,7 @@
-
-
-
- Add Slide
-
-
- Remove Slide
-
+
Quotes Slider
@@ -706,7 +710,7 @@
-
+
Feature Grid
@@ -766,22 +770,11 @@
-
+
Parallax
-
-
+
Parallax Slider
-
-
+
-
-
+
-
-
-

-
Add Column
-
-
-

-
Feature
-
- Delete the above image or replace it with a picture
- that illustrates your message. Click on the picture to
- change it's rounded corner style.
-
-
-
+
-
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/addons/website_blog/static/src/js/website.tour.blog.js b/addons/website_blog/static/src/js/website.tour.blog.js
index e76e793dfda..3470e2e383b 100644
--- a/addons/website_blog/static/src/js/website.tour.blog.js
+++ b/addons/website_blog/static/src/js/website.tour.blog.js
@@ -65,7 +65,7 @@
popover: { fixed: true },
},
{
- snippet: 'image-text',
+ snippet: '#snippet_structure .oe_snippet:eq(2)',
placement: 'bottom',
title: _t("Drag & Drop a Block"),
content: _t("Drag this block and drop it in your page."),
@@ -79,7 +79,7 @@
popover: { fixed: true },
},
{
- snippet: 'text-block',
+ snippet: '#snippet_structure .oe_snippet:eq(4)',
placement: 'bottom',
title: _t("Drag & Drop a block"),
content: _t("Drag this block and drop it below the image block."),
diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py
index af7f77d080f..eb38e2dbe55 100644
--- a/addons/website_event/controllers/main.py
+++ b/addons/website_event/controllers/main.py
@@ -187,7 +187,7 @@ class website_event(http.Controller):
}
return request.website.render("website_event.event_description_full", values)
- @http.route('/event/add_event/', type='http', auth="user", multilang=True, methods=['POST'], website=True)
+ @http.route('/event/add_event', type='http', auth="user", multilang=True, methods=['POST'], website=True)
def add_event(self, event_name="New Event", **kwargs):
return self._add_event(event_name, request.context, **kwargs)
diff --git a/addons/website_event/static/src/js/website.tour.event.js b/addons/website_event/static/src/js/website.tour.event.js
index a9e40a5f65b..ef013398acb 100644
--- a/addons/website_event/static/src/js/website.tour.event.js
+++ b/addons/website_event/static/src/js/website.tour.event.js
@@ -65,7 +65,7 @@
popover: { fixed: true },
},
{
- snippet: 'image-text',
+ snippet: '#snippet_structure .oe_snippet:eq(2)',
placement: 'bottom',
title: _t("Drag & Drop a block"),
content: _t("Drag the 'Image-Text' block and drop it in your page."),
@@ -80,7 +80,7 @@
popover: { fixed: true },
},
{
- snippet: 'text-block',
+ snippet: '#snippet_structure .oe_snippet:eq(4)',
placement: 'bottom',
title: _t("Drag & Drop a block"),
content: _t("Drag the 'Text Block' in your event page."),
diff --git a/addons/website_mail/__openerp__.py b/addons/website_mail/__openerp__.py
index 74fe86c6193..ec10f2268ca 100644
--- a/addons/website_mail/__openerp__.py
+++ b/addons/website_mail/__openerp__.py
@@ -32,14 +32,9 @@
'views/website_mail.xml',
'views/website_email_designer.xml',
'views/email_template_view.xml',
+ 'data/mail_groups.xml',
'security/website_mail.xml',
],
- 'css': [
- 'static/src/css/website_mail.css',
- ],
- 'js': [
- 'static/src/js/website_mail.js',
- ],
'qweb': [
'static/src/xml/website_mail.xml'
],
diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py
index f700fa7dc67..601e1387f0a 100644
--- a/addons/website_mail/controllers/main.py
+++ b/addons/website_mail/controllers/main.py
@@ -56,3 +56,13 @@ class WebsiteMail(http.Controller):
follower_ids = [p.id for p in obj.message_follower_ids]
return partner_ids[0] in follower_ids and 1 or 0
+
+ @http.route(['/website_mail/is_follower/'], type='json', auth="public", website=True)
+ def call(self, model, id, **post):
+ email = request.registry['res.users'].browse(request.cr, request.uid, request.uid, request.context).partner_id.email
+ value = request.registry.get(model).read(request.cr, request.uid, [id], ['message_is_follower'], request.context)
+ return {
+ 'email': email,
+ 'is_follower': value and value[0]['message_is_follower'] or False
+ }
+
diff --git a/addons/website_mail/data/mail_groups.xml b/addons/website_mail/data/mail_groups.xml
new file mode 100644
index 00000000000..0bc8d3e81d1
--- /dev/null
+++ b/addons/website_mail/data/mail_groups.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+ Newsletter
+ public
+ Public Newsletter.
+
+
+
+
diff --git a/addons/website_mail/static/src/css/website_mail.css b/addons/website_mail/static/src/css/website_mail.css
index 5678442416c..25d88ebf191 100644
--- a/addons/website_mail/static/src/css/website_mail.css
+++ b/addons/website_mail/static/src/css/website_mail.css
@@ -1,4 +1,5 @@
.js_follow[data-follow='on'] .js_follow_btn ,
+.js_follow[data-follow='on'] .js_follow_email,
.js_follow[data-follow='off'] .js_unfollow_btn {
display: none;
}
\ No newline at end of file
diff --git a/addons/website_mail/static/src/js/website_mail.editor.js b/addons/website_mail/static/src/js/website_mail.editor.js
new file mode 100644
index 00000000000..7a26920682b
--- /dev/null
+++ b/addons/website_mail/static/src/js/website_mail.editor.js
@@ -0,0 +1,40 @@
+(function () {
+ 'use strict';
+
+ var website = openerp.website;
+ var _t = openerp._t;
+
+ website.snippet.options.subscribe = website.snippet.Option.extend({
+ on_prompt: function () {
+ var self = this;
+ return website.prompt({
+ id: "editor_new_subscribe_button",
+ window_title: _t("Add a Subscribe Button"),
+ select: _t("Mailing List"),
+ init: function (field) {
+ return website.session.model('mail.group')
+ .call('name_search', ['', [['public','=','public']]], { context: website.get_context() });
+ },
+ }).then(function (mail_group_id) {
+ self.$target.attr("data-id", mail_group_id);
+ });
+ },
+ drop_and_build_snippet: function() {
+ var self = this;
+ this._super();
+ this.on_prompt().fail(function () {
+ self.editor.on_remove();
+ });
+ },
+ start : function () {
+ var self = this;
+ this.$el.find(".js_mailing_list").on("click", _.bind(this.on_prompt, this));
+ this._super();
+ },
+ clean_for_save: function () {
+ this.$target.addClass("hidden");
+ },
+ });
+})();
+
+
diff --git a/addons/website_mail/static/src/js/website_mail.js b/addons/website_mail/static/src/js/website_mail.js
index 862e061afd6..672a21324a8 100644
--- a/addons/website_mail/static/src/js/website_mail.js
+++ b/addons/website_mail/static/src/js/website_mail.js
@@ -1,30 +1,56 @@
-$(document).ready(function () {
+(function () {
+ 'use strict';
- $(document).on('click', '.js_follow_btn, .js_unfollow_btn', function (ev) {
- ev.preventDefault();
+ var website = openerp.website;
- var self = this;
- var $data = $(this).parents("div.js_follow");
- var $email = $data.find(".js_follow_email");
+ website.snippet.animationRegistry.follow = website.snippet.Animation.extend({
+ selector: ".js_follow",
+ start: function (editable_mode) {
+ var self = this;
- if ($email.length && !$email.val().match(/.+@.+/)) {
- return false;
- }
+ // set value and display button
+ openerp.jsonRpc('/website_mail/is_follower/', 'call', {
+ model: this.$target.data('object'),
+ id: +this.$target.data('id'),
+ }).always(function (data) {
+ self.$target.find('input.js_follow_email')
+ .val(data.email ? data.email : "")
+ .attr("disabled", data.email.length ? "disabled" : false);
+ self.$target.attr("data-follow", data.is_follower ? 'on' : 'off');
+ self.$target.removeClass("hidden");
+ });
- var message_is_follower = $data.attr("data-follow") || "off";
- $data.attr("data-follow", message_is_follower == 'off' ? 'on' : 'off');
-
- openerp.jsonRpc('/website_mail/follow', 'call', {
- 'id': $data.data('id'),
- 'object': $data.data('object'),
- 'message_is_follower': message_is_follower,
- 'email': $email.length ? $email.val() : false,
- }).then(function (result) {
- if (result) {
- $data.find(" > *").toggleClass("hidden");
+ // not if editable mode to allow designer to edit alert field
+ if (!editable_mode) {
+ $('.js_follow > .alert').addClass("hidden");
+ $('.js_follow > .input-group-btn.hidden').removeClass("hidden");
+ this.$target.find('.js_follow_btn, .js_unfollow_btn').on('click', function (event) {
+ event.preventDefault();
+ self.on_click();
+ });
}
- $data.attr("data-follow", result ? 'on' : 'off');
- });
- });
+ },
+ on_click: function () {
+ var self = this;
+ var $email = this.$target.find(".js_follow_email:visible");
-});
+ if ($email.length && !$email.val().match(/.+@.+/)) {
+ this.$target.addClass('has-error');
+ return false;
+ }
+ this.$target.removeClass('has-error');
+
+ openerp.jsonRpc('/website_mail/follow', 'call', {
+ 'id': +this.$target.data('id'),
+ 'object': this.$target.data('object'),
+ 'message_is_follower': this.$target.attr("data-follow") || "off",
+ 'email': $email.length ? $email.val() : false,
+ }).then(function (follow) {
+ if (follow) {
+ self.$target.find(" > *").toggleClass("hidden");
+ }
+ self.$target.attr("data-follow", follow ? 'on' : 'off');
+ });
+ },
+ });
+})();
diff --git a/addons/website_mail/views/snippets.xml b/addons/website_mail/views/snippets.xml
index 35932f6f7c3..75202fe99fd 100644
--- a/addons/website_mail/views/snippets.xml
+++ b/addons/website_mail/views/snippets.xml
@@ -13,7 +13,7 @@
-
+
Text Block
@@ -63,7 +63,7 @@
-
+
Text-Image
@@ -104,7 +104,7 @@
-
+
Image-Text
@@ -145,7 +145,7 @@
-
+
Two Columns
@@ -185,7 +185,7 @@
-
+
Three Columns
@@ -236,7 +236,7 @@
-
+
Separator
@@ -262,7 +262,7 @@
-
+
Big Picture
@@ -298,7 +298,7 @@
-
+
Comparisons
@@ -389,7 +389,7 @@
-
+
Big Message
@@ -413,7 +413,7 @@
-
+
Button
@@ -478,18 +478,59 @@