[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.

This commit is contained in:
Christophe Matthieu
2015-07-08 16:55:09 +02:00
parent 01b1d640f8
commit 03174f1149
@@ -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)