diff options
| author | qsm-odoo <qsm@odoo.com> | 2017-10-31 12:42:23 +0100 |
|---|---|---|
| committer | qsm-odoo <qsm@odoo.com> | 2018-01-08 13:54:25 +0100 |
| commit | 2303dcb2a9547c0a1cb2a176ff2fb398a9752b2d (patch) | |
| tree | 97648b8873e8dc9552cbfd98186eac0f0fd7da71 /addons/website/static | |
| parent | f68d33b6a59fc041d5bbb5fa44755c52537bea03 (diff) | |
[IMP] web_editor, *: change height/margin system to padding system
* web, website, mass_mailing
Before this commit, the editor allowed defining the margin of some
elements and the height of some elements. There were three main
problems with this system:
1) When an user dragged the arrow, he often expected to change the
size of the element while he was in fact changing the margin
2) When changing the margin, you increase the space between two
elements but with a white space (while most users want a space
with the same color of the block they are resizing = padding)
3) When changing the height, the user was able to hide snippet parts
and the height was not consistent accross screen sizes
Now, the only thing you can edit is padding. There is only one arrow
for each direction, which allows increasing spacing and consistent
dimension at the same time.
The only feature that is lost with this change is the ability to
control vertical alignement of colored columns. This is not a problem
as colored columns are rare in our current snippets and there still
have the possibility to add margin classes by hand if necessary (there
are also plans to control vertical alignement another way).
Note: margin classes are kept for compatibility.
Diffstat (limited to 'addons/website/static')
3 files changed, 39 insertions, 19 deletions
diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 3556ebd8fc7..d7c29359b95 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -431,6 +431,23 @@ registry.slider = Animation.extend({ * @override */ start: function () { + if (!this.editableMode) { + var maxHeight = 0; + var $items = this.$('.item'); + _.each($items, function (el) { + var $item = $(el); + var isActive = $item.hasClass('active'); + $item.addClass('active'); + var height = $item.outerHeight(); + if (height > maxHeight) { + maxHeight = height; + } + $item.toggleClass('active', isActive); + }); + _.each($items, function (el) { + $(el).css('min-height', maxHeight); + }); + } this.$target.carousel(); return this._super.apply(this, arguments); }, @@ -441,6 +458,9 @@ registry.slider = Animation.extend({ this._super.apply(this, arguments); this.$target.carousel('pause'); this.$target.removeData('bs.carousel'); + _.each(this.$('.item'), function (el) { + $(el).css('min-height', ''); + }); }, }); diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index e0dced9caa1..7601dea6b6c 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -122,12 +122,11 @@ options.registry.carousel = options.Class.extend({ this.$target.on('slid.bs.carousel', function () { self.$target.carousel('pause'); self.trigger_up('option_update', { - optionNames: ['background', 'background_position', 'colorpicker'], + optionNames: ['background', 'background_position', 'colorpicker', 'sizing_y'], name: 'target', data: self.$target.find('.item.active'), }); }); - this.$target.trigger('slid.bs.carousel'); return def; }, @@ -144,6 +143,14 @@ options.registry.carousel = options.Class.extend({ this._rebindEvents(); }, /** + * @override + */ + onFocus: function () { + // Needs to be done on focus, not on start, as all other options are + // maybe not all initialized in start + this.$target.trigger('slid.bs.carousel'); + }, + /** * Associates unique ID on cloned slider elements. * * @override @@ -161,7 +168,7 @@ options.registry.carousel = options.Class.extend({ this._super.apply(this, arguments); this.$target.find('.item').removeClass('next prev left right active') .first().addClass('active'); - this.$target.find('.carousel-indicators').find('li').removeClass('active') + this.$target.find('.carousel-indicators').find('li').removeClass('active').html('') .first().addClass('active'); this.$target.removeClass('oe_img_bg ' + this._class).css('background-image', ''); }, @@ -262,9 +269,7 @@ options.registry.carousel = options.Class.extend({ }, }); -options.registry['margin-x'] = options.registry.marginAndResize.extend({ - preventChildPropagation: true, - +options.registry.sizing_x = options.registry.sizing.extend({ /** * @override */ @@ -286,15 +291,13 @@ options.registry['margin-x'] = options.registry.marginAndResize.extend({ * @override */ _getSize: function () { - this.grid = this._super(); - var width = this.$target.parents('.row:first').first().outerWidth(); - - var grid = [1,2,3,4,5,6,7,8,9,10,11,12]; - this.grid.e = [_.map(grid, function (v) {return 'col-md-'+v;}), _.map(grid, function (v) {return width/12*v;})]; - - grid = [-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11]; - this.grid.w = [_.map(grid, function (v) {return 'col-md-offset-'+v;}), _.map(grid, function (v) {return width/12*v;}), 12]; - + var width = this.$target.closest('.row').width(); + var gridE = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; + var gridW = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; + this.grid = { + e: [_.map(gridE, function (v) { return 'col-md-' + v; }), _.map(gridE, function (v) { return width/12*v; }), 'width'], + w: [_.map(gridW, function (v) { return 'col-md-offset-' + v; }), _.map(gridW, function (v) { return width/12*v; }), 'margin-left'], + }; return this.grid; }, /** @@ -321,7 +324,7 @@ options.registry['margin-x'] = options.registry.marginAndResize.extend({ this.$target.addClass('col-md-offset-' + offset); } } - this._super(compass, beginClass, current); + this._super.apply(this, arguments); }, }); diff --git a/addons/website/static/src/less/website.snippets.less b/addons/website/static/src/less/website.snippets.less index 59cbc47b9dc..388a7180d96 100644 --- a/addons/website/static/src/less/website.snippets.less +++ b/addons/website/static/src/less/website.snippets.less @@ -436,9 +436,6 @@ div.carousel { background-attachment: fixed; } } -.s_parallax { - min-height: 200px; -} // Company Team |
