Difference between revisions of "Template:Team:Bielefeld-CeBiTec/JS"

(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 (!$(this).hasClass("small")) {
+
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;
$noEffect = 0;
 
 
 
 
$('.sub-navbar-item').each(function(i, obj) {
 
$('.sub-navbar-item').each(function(i, obj) {
if ($($clickItem).hasClass("sub-navbar-item")) {
+
if ($(obj).is(":visible")) {
if ($(obj).is(":visible")) {
+
if ($($clickItem).hasClass("sub-navbar-item")) {
 
if ($(obj).hasClass("small")) {
 
if ($(obj).hasClass("small")) {
if (obj == $clickItem) {
 
$noEffect = 1;
 
}
 
 
if ($totalWidth == 0) {
 
if ($totalWidth == 0) {
 
$leftItem = obj;
 
$leftItem = obj;
Line 425: Line 421:
 
$totalWidth = $totalWidth + $(obj).width();
 
$totalWidth = $totalWidth + $(obj).width();
 
}
 
}
}
+
} else {
} else {
+
if ($(obj).is(":visible")) {
+
if (obj == $clickItem) {
+
$noEffect = 1;
+
}
+
 
if ($totalWidth == 0) {
 
if ($totalWidth == 0) {
 
$leftItem = obj;
 
$leftItem = obj;
Line 438: Line 429:
 
}
 
}
 
});
 
});
if ($noEffect == 0) {
+
$newPos = ($middle - ($totalWidth * 0.5));
$newPos = ($middle - ($totalWidth * 0.5));
+
if ($newPos < 0) {
if ($newPos < 0) {
+
$newPos = 0;
$newPos = 0;
+
}
}
+
if ($newPos + $totalWidth > $("body").width()) {
if ($newPos + $totalWidth > $("body").width()) {
+
$newPos = $("body").width() - $totalWidth;
$newPos = $("body").width() - $totalWidth;
+
}
+
$newPos = $newPos + "px";
+
+
$($leftItem).css({'margin-left':$newPos});
+
 
}
 
}
 +
$newPos = $newPos + "px";
 +
 +
$($leftItem).css({'margin-left':$newPos});
 
}
 
}
 
     });
 
     });

Revision as of 16:05, 23 September 2017