diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index 0cc3535cd75..1740ee7a72a 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -61,6 +61,7 @@ This module provides the core of the Odoo Web Client. 'web/static/src/boot.js', 'web/static/src/session.js', 'web/static/src/legacy/js/core/cookie_utils.js', + 'web/static/src/legacy/js/core/menu.js', ], 'web.assets_common': [ ('include', 'web._assets_helpers'), @@ -79,6 +80,7 @@ This module provides the core of the Odoo Web Client. ('remove', 'web/static/src/boot.js'), ('remove', 'web/static/src/session.js'), ('remove', 'web/static/src/legacy/js/core/cookie_utils.js'), + ('remove', 'web/static/src/legacy/js/core/menu.js'), ], 'web.assets_backend': [ ('include', 'web._assets_helpers'), diff --git a/addons/web/static/src/legacy/js/core/dom.js b/addons/web/static/src/legacy/js/core/dom.js index 9412fdc1cde..38c1a0c3729 100644 --- a/addons/web/static/src/legacy/js/core/dom.js +++ b/addons/web/static/src/legacy/js/core/dom.js @@ -616,131 +616,6 @@ var dom = { $scrollable.animate({scrollTop: originalScrollTop}, clonedOptions); }); }, - /** - * Creates an automatic 'more' dropdown-menu for a set of navbar items. - * - * @param {jQuery} $el - * @param {Object} [options] - * @param {string} [options.unfoldable='none'] - * @param {function} [options.maxWidth] - * @param {string} [options.sizeClass='SM'] - */ - initAutoMoreMenu: function ($el, options) { - options = _.extend({ - unfoldable: 'none', - maxWidth: false, - sizeClass: 'SM', - }, options || {}); - - var autoMarginLeftRegex = /\bm[lx]?(?:-(?:sm|md|lg|xl))?-auto\b/; - var autoMarginRightRegex = /\bm[rx]?(?:-(?:sm|md|lg|xl))?-auto\b/; - - var $extraItemsToggle = null; - - var debouncedAdapt = _.debounce(_adapt, 250); - core.bus.on('resize', null, debouncedAdapt); - _adapt(); - - $el.data('dom:autoMoreMenu:adapt', _adapt); - $el.data('dom:autoMoreMenu:destroy', function () { - _restore(); - core.bus.off('resize', null, debouncedAdapt); - $el.removeData(['dom:autoMoreMenu:destroy', 'dom:autoMoreMenu:adapt']); - }); - - function _restore() { - if ($extraItemsToggle === null) { - return; - } - var $items = $extraItemsToggle.children('.dropdown-menu').children(); - $items.addClass('nav-item'); - $items.children('.dropdown-item, a').removeClass('dropdown-item').addClass('nav-link'); - $items.insertBefore($extraItemsToggle); - $extraItemsToggle.remove(); - $extraItemsToggle = null; - } - - function _adapt() { - _restore(); - - if (!$el.is(':visible') || $el.closest('.show').length) { - // Never transform the menu when it is not visible yet or if - // it is a toggleable one. - return; - } - if (config.device.size_class <= config.device.SIZES[options.sizeClass]) { - return; - } - - var $allItems = $el.children(); - var $unfoldableItems = $allItems.filter(options.unfoldable); - var $items = $allItems.not($unfoldableItems); - - var maxWidth = 0; - if (options.maxWidth) { - maxWidth = options.maxWidth(); - } else { - maxWidth = computeFloatOuterWidthWithMargins($el[0], true, true, true); - var style = window.getComputedStyle($el[0]); - maxWidth -= (parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth)); - maxWidth -= _.reduce($unfoldableItems, function (sum, el) { - return sum + computeFloatOuterWidthWithMargins(el, true, true, false); - }, 0); - } - - var nbItems = $items.length; - var menuItemsWidth = _.reduce($items, function (sum, el) { - return sum + computeFloatOuterWidthWithMargins(el, true, true, false); - }, 0); - - if (maxWidth - menuItemsWidth >= -0.001) { - return; - } - - var $dropdownMenu = $('