mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
Merge branch 'MDL-53678_master' of https://github.com/StudiUM/moodle
This commit is contained in:
commit
e1f9593de4
2
admin/tool/lp/amd/build/menubar.min.js
vendored
2
admin/tool/lp/amd/build/menubar.min.js
vendored
File diff suppressed because one or more lines are too long
@ -258,16 +258,41 @@ define(['jquery'], function($) {
|
||||
Menubar.prototype.setOpenDirection = function() {
|
||||
var pos = this.menuRoot.offset();
|
||||
var isRTL = $(document.body).hasClass('dir-rtl');
|
||||
var menuMinWidth = 160;
|
||||
var openLeft = false;
|
||||
var heightmenuRoot = this.rootMenus.outerHeight();
|
||||
var widthmenuRoot = this.rootMenus.outerWidth();
|
||||
// Sometimes the menuMinWidth is not enough to figure out if menu exceeds the window width.
|
||||
// So we have to calculate the real menu width.
|
||||
var subMenuContainer = this.rootMenus.find('ul.tool-lp-sub-menu');
|
||||
|
||||
// Reset margins.
|
||||
subMenuContainer.css('margin-right', '');
|
||||
subMenuContainer.css('margin-left', '');
|
||||
subMenuContainer.css('margin-top', '');
|
||||
|
||||
subMenuContainer.attr('aria-hidden', false);
|
||||
var menuRealWidth = subMenuContainer.outerWidth(),
|
||||
menuRealHeight = subMenuContainer.outerHeight();
|
||||
|
||||
var margintop = null,
|
||||
marginright = null,
|
||||
marginleft = null;
|
||||
var top = pos.top - $(window).scrollTop();
|
||||
// Top is the same for RTL and LTR.
|
||||
if (top + menuRealHeight > $(window).height()) {
|
||||
margintop = menuRealHeight + heightmenuRoot;
|
||||
subMenuContainer.css('margin-top', '-' + margintop + 'px');
|
||||
}
|
||||
|
||||
if (isRTL) {
|
||||
if (pos.left - menuMinWidth < 0) {
|
||||
openLeft = true;
|
||||
if (pos.left - menuRealWidth < 0) {
|
||||
marginright = menuRealWidth - widthmenuRoot;
|
||||
subMenuContainer.css('margin-right', '-' + marginright + 'px');
|
||||
}
|
||||
} else {
|
||||
if (pos.left + menuMinWidth > $( window ).width()) {
|
||||
openLeft = true;
|
||||
if ( pos.left + menuRealWidth > $(window).width()) {
|
||||
marginleft = menuRealWidth - widthmenuRoot;
|
||||
subMenuContainer.css('margin-left', '-' + marginleft + 'px');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user