Fix popover positioning after window resize

Signed-off-by: Julius Haertl <jus@bitgrid.net>
This commit is contained in:
Julius Haertl 2017-03-03 02:09:49 +01:00 committed by Julius Härtl
parent 267b89f5c7
commit f58f8f6f47
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -1370,8 +1370,9 @@ function initCore() {
*/
function setupMainMenu() {
// init the more-apps menu
OC.registerMenu($('#more-apps'), $('#navigation'));
// init the more-apps menu
OC.registerMenu($('#more-apps'), $('#navigation'));
// toggle the navigation
var $toggle = $('#header .header-appname-container');
var $navigation = $('#navigation');
@ -1441,13 +1442,20 @@ function initCore() {
// move triangle of apps dropdown to align with app name triangle
// 2 is the additional offset between the triangles
if($('#navigation').length) {
$('#header #nextcloud + .menutoggle').one('click', function(){
var caretPosition = $('#more-apps').offset().left - 2;
$('#header #nextcloud + .menutoggle').on('click', function(){
$('#menu-css-helper').remove();
var caretPosition = $('.header-appname + .icon-caret').offset().left - 2;
if(caretPosition > 255) {
// if the app name is longer than the menu, just put the triangle in the middle
return;
} else {
$('head').append('<style>#navigation:after { left: '+ caretPosition +'px; }</style>');
$('head').append('<style id="menu-css-helper">#navigation:after { left: '+ caretPosition +'px; }</style>');
}
});
$('#header #appmenu .menutoggle').on('click', function() {
$('#appmenu').toggleClass('menu-open');
if($('#appmenu').is(':visible')) {
$('#menu-css-helper').remove();
}
});
}