summaryrefslogtreecommitdiff
path: root/addons/website/static
diff options
context:
space:
mode:
authorBenjamin Vray <bvr@odoo.com>2020-10-12 15:16:00 +0000
committerBenjamin Vray <bvr@odoo.com>2020-10-12 15:16:00 +0000
commitced500e9bcbb5c84033463689d135ad4c7dc4f39 (patch)
tree33b2bb033a18f78fbdf612df75b15b193d799fd6 /addons/website/static
parentfbde9dd183472237f12014315f063af736950b6c (diff)
[FIX] website: fix menu direction of header dropdowns
Before this commit, the menu direction of header dropdowns was related to the window width but it was wrong because of the right panel. We also enable it in editor mode. task-2312878 closes odoo/odoo#59783 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/website/static')
-rw-r--r--addons/website/static/src/js/content/menu.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js
index 88f0dd7b268..34900c380d3 100644
--- a/addons/website/static/src/js/content/menu.js
+++ b/addons/website/static/src/js/content/menu.js
@@ -466,6 +466,7 @@ publicWidget.registry.autohideMenu = publicWidget.Widget.extend({
*/
publicWidget.registry.menuDirection = publicWidget.Widget.extend({
selector: 'header .navbar .nav',
+ disabledInEditableMode: false,
events: {
'show.bs.dropdown': '_onDropdownShow',
},
@@ -488,12 +489,13 @@ publicWidget.registry.menuDirection = publicWidget.Widget.extend({
* @param {integer} liOffset
* @param {integer} liWidth
* @param {integer} menuWidth
+ * @param {integer} pageWidth
* @returns {boolean}
*/
- _checkOpening: function (alignment, liOffset, liWidth, menuWidth, windowWidth) {
+ _checkOpening: function (alignment, liOffset, liWidth, menuWidth, pageWidth) {
if (alignment === 'left') {
// Check if ok to open the dropdown to the right (no window overflow)
- return (liOffset + menuWidth <= windowWidth);
+ return (liOffset + menuWidth <= pageWidth);
} else {
// Check if ok to open the dropdown to the left (no window overflow)
return (liOffset + liWidth - menuWidth >= 0);
@@ -513,7 +515,7 @@ publicWidget.registry.menuDirection = publicWidget.Widget.extend({
var liOffset = $li.offset().left;
var liWidth = $li.outerWidth();
var menuWidth = $menu.outerWidth();
- var windowWidth = $(window).outerWidth();
+ var pageWidth = $('#wrapwrap').outerWidth();
$menu.removeClass('dropdown-menu-left dropdown-menu-right');
@@ -524,10 +526,10 @@ publicWidget.registry.menuDirection = publicWidget.Widget.extend({
}
// If can't open in the current direction because it would overflow the
- // window, change the direction. But if the other direction would do the
+ // page, change the direction. But if the other direction would do the
// same, change back the direction.
for (var i = 0; i < 2; i++) {
- if (!this._checkOpening(alignment, liOffset, liWidth, menuWidth, windowWidth)) {
+ if (!this._checkOpening(alignment, liOffset, liWidth, menuWidth, pageWidth)) {
alignment = (alignment === 'left' ? 'right' : 'left');
}
}