(final new navbar fix) |
(final final new navbar fix) |
||
Line 408: | Line 408: | ||
//get center x position of item and place subitems centered to this | //get center x position of item and place subitems centered to this | ||
− | if ( | + | if ($(this).html().indexOf("▼") > -1) { |
$middle = $(this).position().left + ($(this).width() * 0.5); | $middle = $(this).position().left + ($(this).width() * 0.5); | ||
$totalWidth = 0; | $totalWidth = 0; | ||
− | |||
$('.sub-navbar-item').each(function(i, obj) { | $('.sub-navbar-item').each(function(i, obj) { | ||
− | if ($( | + | if ($(obj).is(":visible")) { |
− | if ($( | + | if ($($clickItem).hasClass("sub-navbar-item")) { |
if ($(obj).hasClass("small")) { | if ($(obj).hasClass("small")) { | ||
− | |||
− | |||
− | |||
if ($totalWidth == 0) { | if ($totalWidth == 0) { | ||
$leftItem = obj; | $leftItem = obj; | ||
Line 425: | Line 421: | ||
$totalWidth = $totalWidth + $(obj).width(); | $totalWidth = $totalWidth + $(obj).width(); | ||
} | } | ||
− | + | } else { | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
if ($totalWidth == 0) { | if ($totalWidth == 0) { | ||
$leftItem = obj; | $leftItem = obj; | ||
Line 438: | Line 429: | ||
} | } | ||
}); | }); | ||
− | + | $newPos = ($middle - ($totalWidth * 0.5)); | |
− | + | if ($newPos < 0) { | |
− | + | $newPos = 0; | |
− | + | } | |
− | + | if ($newPos + $totalWidth > $("body").width()) { | |
− | + | $newPos = $("body").width() - $totalWidth; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
+ | $newPos = $newPos + "px"; | ||
+ | |||
+ | $($leftItem).css({'margin-left':$newPos}); | ||
} | } | ||
}); | }); |
Revision as of 16:05, 23 September 2017