var $dialogContent = $(event.currentTarget);
$dialogContent.find('.dropdown.dropdownOpen').each(function(index, element) {
var $dropdown = $(element);
- var $scrollTolerance = $(element).height() / 2;
+ var $dropdownID = $dropdown.wcfIdentify();
+ var $dropdownOffset = $dropdown.offset();
+ var $dialogContentOffset = $dialogContent.offset();
+
+ var $verticalScrollTolerance = $(element).height() / 2;
// check if dropdown toggle is still (partially) visible
- if ($dropdown.offset().top + $scrollTolerance <= $dialogContent.offset().top) { // top check
- WCF.Dropdown.toggleDropdown($dropdown.wcfIdentify());
+ if ($dropdownOffset.top + $verticalScrollTolerance <= $dialogContentOffset.top) {
+ // top check
+ WCF.Dropdown.toggleDropdown($dropdownID);
+ }
+ else if ($dropdownOffset.top >= $dialogContentOffset.top + $dialogContent.height()) {
+ // bottom check
+ WCF.Dropdown.toggleDropdown($dropdownID);
+ }
+ else if ($dropdownOffset.left <= $dialogContentOffset.left) {
+ // left check
+ WCF.Dropdown.toggleDropdown($dropdownID);
}
- else if ($dropdown.offset().top >= $dialogContent.offset().top + $dialogContent.height()) { // bottom check
- WCF.Dropdown.toggleDropdown($dropdown.wcfIdentify());
+ else if ($dropdownOffset.left >= $dialogContentOffset.left + $dialogContent.width()) {
+ // right check
+ WCF.Dropdown.toggleDropdown($dropdownID);
}
else {
WCF.Dropdown.setAlignmentByID($dropdown.wcfIdentify());