mirror of
https://github.com/odoo/design-themes.git
synced 2025-10-07 01:18:52 +07:00
7ab07c6ec1
This commit converts all odoo module of this repo by native module. The goal is to depreciate odoo.define in favor of native module and then simplify boot.js by removing the regexp that finds module dependencies. task id: 3162300 closes odoo/design-themes#652 Signed-off-by: Géry Debongnie <ged@odoo.com>
113 lines
3.5 KiB
JavaScript
113 lines
3.5 KiB
JavaScript
/** @odoo-module **/
|
|
|
|
import publicWidget from "web.public.widget";
|
|
import "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);
|