diff options
| author | Richard Sassine <richardsassine@tutanota.com> | 2021-05-04 18:00:38 +0300 |
|---|---|---|
| committer | Richard Sassine <richardsassine@tutanota.com> | 2021-05-04 18:00:38 +0300 |
| commit | ad97722b1b35aff50d0adf13a19715f7b8373c07 (patch) | |
| tree | edf36f1114b896a01602e31dafd74efe45736427 /theme_common/static/src/js | |
initial commit
Diffstat (limited to 'theme_common/static/src/js')
| -rw-r--r-- | theme_common/static/src/js/compatibility_editor.js | 19 | ||||
| -rw-r--r-- | theme_common/static/src/js/preheader.js | 115 |
2 files changed, 134 insertions, 0 deletions
diff --git a/theme_common/static/src/js/compatibility_editor.js b/theme_common/static/src/js/compatibility_editor.js new file mode 100644 index 0000000..0f3aeb3 --- /dev/null +++ b/theme_common/static/src/js/compatibility_editor.js @@ -0,0 +1,19 @@ +odoo.define('theme_common.compatibility_editor', function (require) { +'use strict'; + +var sOptions = require('web_editor.snippets.options'); + +sOptions.registry.BackgroundImage.include({ + /** + * @override + */ + background: function (previewMode, widgetValue, params) { + this._super.apply(this, arguments); + + var customClass = this.$target.attr('class').match(/\b(bg-img-\d+)\b/); + if (customClass) { + this.$target.removeClass(customClass[1]); + } + }, +}); +}); diff --git a/theme_common/static/src/js/preheader.js b/theme_common/static/src/js/preheader.js new file mode 100644 index 0000000..7c1e8e2 --- /dev/null +++ b/theme_common/static/src/js/preheader.js @@ -0,0 +1,115 @@ +odoo.define('theme_common.preheader', function (require) { +'use strict'; + +var publicWidget = require('web.public.widget'); +require('website.content.menu'); + +publicWidget.registry.StandardAffixedHeader.include({ + /** + * @override + */ + start: function () { + this.$preheader = this.$el.find('#o_theme_preheader'); + this.preheaderVisible = this.$preheader.css('display') !== 'none'; + return this._super.apply(this, arguments); + }, + /** + * @override + */ + destroy: function () { + this.$el.find('#o_theme_preheader').show(); + return this._super.apply(this, arguments); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @override + */ + _updateHeaderOnScroll: function (scrollTop) { + var def = this._super.apply(this, arguments); + if (this.preheaderVisible) { + if (this.$el.hasClass('o_header_is_scrolled')) { + this.$el.find('#o_theme_preheader').hide(); + } else { + this.$el.find('#o_theme_preheader').show(200); + } + } + return def; + } +}); +publicWidget.registry.FixedHeader.include({ + /** + * @override + */ + start: function () { + this.$preheader = this.$el.find('#o_theme_preheader'); + this.preheaderVisible = this.$preheader.css('display') !== 'none'; + return this._super.apply(this, arguments); + }, + /** + * @override + */ + destroy: function () { + this.$el.css('transform', ''); + return this._super.apply(this, arguments); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @override + */ + _updateHeaderOnScroll: function (scrollTop) { + var def = this._super.apply(this, arguments); + if (this.preheaderVisible) { + if (this.$el.hasClass('o_header_is_scrolled')) { + if (!this.$el.hasClass('o_header_disappears') && !this.$el.hasClass('o_header_fade_out')) { + const preheaderHeight = this.$el.find('#o_theme_preheader').outerHeight(); + this.$el.css('transform', 'translate(0, -' + preheaderHeight + 'px)'); + } + } else { + this.$el.css('transform', ''); + } + } + return def; + } +}); + +const BaseDisappearingPreheader = { + /** + * @override + */ + start: function () { + this.$preheader = this.$el.find('#o_theme_preheader'); + this.preheaderVisible = this.$preheader.css('display') !== 'none'; + return this._super.apply(this, arguments); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @override + */ + _showHeader: function () { + var def = this._super.apply(this, arguments); + if (this.preheaderVisible) { + const preheaderHeight = this.$preheader.outerHeight(); + if (this.$el.hasClass('o_header_is_scrolled')) { + this.$el.css('transform', 'translate(0, -' + preheaderHeight + 'px)'); + } + } + return def; + } +}; + +publicWidget.registry.DisappearingHeader.include(BaseDisappearingPreheader); +publicWidget.registry.FadeOutHeader.include(BaseDisappearingPreheader); + +}); |
