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

m (probably final fix for new navbar)
(fixed moving small buttons)
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
$middle = $(this).position().left + ($(this).width() * 0.5);
+
if (!$(this).hasClass("small")) {
$totalWidth = 0;
+
$middle = $(this).position().left + ($(this).width() * 0.5);
+
$totalWidth = 0;
$('.sub-navbar-item').each(function(i, obj) {
+
if ($($clickItem).hasClass("sub-navbar-item")) {
+
$('.sub-navbar-item').each(function(i, obj) {
$(".test").html("caseA");
+
if ($($clickItem).hasClass("sub-navbar-item")) {
if ($(obj).is(":visible")) {
+
$(".test").html("caseA");
if ($(obj).hasClass("small")) {
+
if ($(obj).is(":visible")) {
 +
if ($(obj).hasClass("small")) {
 +
if ($totalWidth == 0) {
 +
$leftItem = obj;
 +
}
 +
$totalWidth = $totalWidth + $(obj).width();
 +
}
 +
}
 +
} else {
 +
$(".test").html("caseB");
 +
if ($(obj).is(":visible")) {
 
if ($totalWidth == 0) {
 
if ($totalWidth == 0) {
 
$leftItem = obj;
 
$leftItem = obj;
Line 422: Line 432:
 
}
 
}
 
}
 
}
} else {
+
});
$(".test").html("caseB");
+
$newPos = ($middle - ($totalWidth * 0.5));
if ($(obj).is(":visible")) {
+
if ($newPos < 0) {
if ($totalWidth == 0) {
+
$newPos = 0;
$leftItem = obj;
+
}
+
$totalWidth = $totalWidth + $(obj).width();
+
}
+
 
}
 
}
});
+
if ($newPos + $totalWidth > $("body").width()) {
$newPos = ($middle - ($totalWidth * 0.5));
+
$newPos = $("body").width() - $totalWidth;
if ($newPos < 0) {
+
}
$newPos = 0;
+
$newPos = $newPos + "px";
}
+
if ($newPos + $totalWidth > $("body").width()) {
+
$($leftItem).css({'margin-left':$newPos});
$newPos = $("body").width() - $totalWidth;
+
 
}
 
}
$newPos = $newPos + "px";
 
 
$($leftItem).css({'margin-left':$newPos});
 
 
     });
 
     });
 
});
 
});
Line 464: Line 466:
 
resizeNavbar();
 
resizeNavbar();
 
}, 10);
 
}, 10);
 
 
  
  

Revision as of 15:02, 23 September 2017