- Repo for opensource odoo website theme (since V13.0)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.0 KiB

5 years ago
  1. odoo.define('theme_anelusia.main', function (require) {
  2. 'use strict';
  3. var publicWidget = require('web.public.widget');
  4. require('website.content.menu');
  5. // FIXME
  6. publicWidget.registry.anelusiaHeader = publicWidget.Widget.extend({
  7. selector: '.navbar-toggler',
  8. events: {
  9. 'click': '_onToggleClick',
  10. },
  11. //--------------------------------------------------------------------------
  12. // Handlers
  13. //--------------------------------------------------------------------------
  14. /**
  15. * @private
  16. */
  17. _onToggleClick: function () {
  18. $('body').toggleClass('no-scroll');
  19. setTimeout(function () { $(window).trigger('scroll'); }, 100);
  20. },
  21. });
  22. publicWidget.registry.affixMenu.include({
  23. /**
  24. * @override
  25. */
  26. start: function () {
  27. var def = this._super.apply(this, arguments);
  28. if (this.$headerClone) {
  29. this.$clonedNavbarHeader = this.$headerClone.find('.navbar-toggler');
  30. }
  31. return def;
  32. },
  33. //--------------------------------------------------------------------------
  34. // Private
  35. //--------------------------------------------------------------------------
  36. /**
  37. * @override
  38. */
  39. _getHeaderHeight: function () {
  40. return Math.max(
  41. this.$headerClone.find('.navbar-brand').outerHeight(true),
  42. this.$headerClone.find('.container').outerHeight(true)
  43. );
  44. },
  45. //--------------------------------------------------------------------------
  46. // Handlers
  47. //--------------------------------------------------------------------------
  48. /**
  49. * @override
  50. */
  51. _onWindowUpdate: function () {
  52. this._super.apply(this, arguments);
  53. var affixed = this.$headerClone.is('.affixed');
  54. var noScroll = $('body').hasClass('no-scroll');
  55. var hasHamburgerMenu = ($(".new-toggle").length > 0);
  56. this.$clonedNavbarHeader.css('background', (affixed && !noScroll && hasHamburgerMenu) ? 'rgba(0, 0, 0, 0.8)' : 'none');
  57. },
  58. });
  59. });