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.

75 lines
2.9 KiB

  1. /**********************************************************************************
  2. *
  3. * Copyright (C) 2017 MuK IT GmbH
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. **********************************************************************************/
  19. odoo.define('muk_web_theme.Menu', function (require) {
  20. "use strict";
  21. var core = require('web.core');
  22. var config = require("web.config");
  23. var Menu = require("web.Menu");
  24. var AppsBar = require("muk_web_theme.AppsBar");
  25. var _t = core._t;
  26. var QWeb = core.qweb;
  27. Menu.include({
  28. events: _.extend({}, Menu.prototype.events, {
  29. "click .mk_menu_mobile_section": "_onMobileSectionClick",
  30. "click .o_menu_sections [role=menuitem]": "_hideMobileSubmenus",
  31. "show.bs.dropdown .o_menu_systray, .o_menu_apps": "_hideMobileSubmenus",
  32. }),
  33. menusTemplate: config.device.isMobile ?
  34. 'muk_web_theme.MobileMenu.sections' : Menu.prototype.menusTemplate,
  35. start: function () {
  36. this.$menu_toggle = this.$(".mk_menu_sections_toggle");
  37. this.$menu_apps_sidebar = this.$('.mk_apps_sidebar_panel');
  38. this._appsBar = new AppsBar(this, this.menu_data);
  39. this._appsBar.appendTo(this.$menu_apps_sidebar);
  40. this.$menu_apps_sidebar.renderScrollBar();
  41. return this._super.apply(this, arguments);
  42. },
  43. _hideMobileSubmenus: function () {
  44. if (this.$menu_toggle.is(":visible") && this.$section_placeholder.is(":visible")) {
  45. this.$section_placeholder.collapse("hide");
  46. }
  47. },
  48. _updateMenuBrand: function () {
  49. if (!config.device.isMobile) {
  50. return this._super.apply(this, arguments);
  51. }
  52. },
  53. _onMobileSectionClick: function (event) {
  54. event.preventDefault();
  55. event.stopPropagation();
  56. var $section = $(event.currentTarget);
  57. if ($section.hasClass('show')) {
  58. $section.removeClass('show');
  59. $section.find('.show').removeClass('show');
  60. $section.find('.fa-chevron-down').show();
  61. $section.find('.fa-chevron-right').hide();
  62. } else {
  63. $section.addClass('show');
  64. $section.find('ul:first').addClass('show');
  65. $section.find('.fa-chevron-down:first').hide();
  66. $section.find('.fa-chevron-right:first').show();
  67. }
  68. },
  69. });
  70. });