summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.snippets.editor.js
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@odoo.com>2015-07-01 08:04:30 +0200
committerChristophe Matthieu <chm@odoo.com>2015-07-08 16:55:09 +0200
commit03174f11496c74814dff56b910ea4cc90886ea7d (patch)
tree1d86d08ad37e1982af8f25e9ca838845e1756b4c /addons/website/static/src/js/website.snippets.editor.js
parent01b1d640f8375b9e1f4ad48b5da6f99895fa6998 (diff)
[IMP] website: split margin-x snippet option and create an preventParentEmpty object. This object can be used by other snippet when the parent can't be empty.
Diffstat (limited to 'addons/website/static/src/js/website.snippets.editor.js')
-rw-r--r--addons/website/static/src/js/website.snippets.editor.js34
1 files changed, 21 insertions, 13 deletions
diff --git a/addons/website/static/src/js/website.snippets.editor.js b/addons/website/static/src/js/website.snippets.editor.js
index 5a83099d9df..f7a37492198 100644
--- a/addons/website/static/src/js/website.snippets.editor.js
+++ b/addons/website/static/src/js/website.snippets.editor.js
@@ -1060,6 +1060,26 @@ var Option = Class.extend({
clean_for_save: dummy
});
+
+var preventParentEmpty = {
+ hide_remove_button: function() {
+ this.$overlay.find('.oe_snippet_remove, .oe_snippet_move').toggleClass("hidden", !this.$target.siblings().length);
+ },
+ on_focus : function () {
+ this._super();
+ this.hide_remove_button();
+ },
+ on_clone: function ($clone) {
+ this._super($clone);
+ this.hide_remove_button();
+ },
+ on_remove: function () {
+ this._super();
+ this.hide_remove_button();
+ },
+};
+
+
options.background = Option.extend({
start: function ($change_target) {
this.$bg = $change_target || this.$target;
@@ -1525,7 +1545,7 @@ options["margin-y"] = options.marginAndResize.extend({
},
});
-options["margin-x"] = options.marginAndResize.extend({
+options["margin-x"] = options.marginAndResize.extend(preventParentEmpty).extend({
getSize: function () {
this.grid = this._super();
var width = this.$target.parents(".row:first").first().outerWidth();
@@ -1566,23 +1586,11 @@ options["margin-x"] = options.marginAndResize.extend({
this.$target.addClass("col-md-offset-" + this.$target.prevAll(".oe_drop_to_remove").length);
this._super();
},
- hide_remove_button: function() {
- this.$overlay.find('.oe_snippet_remove').toggleClass("hidden", !this.$target.siblings().length);
- },
- on_focus : function () {
- this._super();
- this.hide_remove_button();
- },
on_clone: function ($clone) {
var _class = $clone.attr("class").replace(/\s*(col-lg-offset-|col-md-offset-)([0-9-]+)/g, '');
$clone.attr("class", _class);
- this.hide_remove_button();
return false;
},
- on_remove: function () {
- this._super();
- this.hide_remove_button();
- },
on_resize: function (compass, beginClass, current) {
if (compass === 'w') {
// don't change the right border position when we change the offset (replace col size)