luci-base: ui.js: avoid error tooltips overlapping dropdowns
[project/luci.git] / modules / luci-base / htdocs / luci-static / resources / ui.js
index 9f3e74b93562a912669f6dcb82b527c8da671136..ac158f526075e9963945a47ca3e21d78887ae6f9 100644 (file)
@@ -3250,7 +3250,8 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
 
                var rect = target.getBoundingClientRect(),
                    x = rect.left              + window.pageXOffset,
-                   y = rect.top + rect.height + window.pageYOffset;
+                   y = rect.top + rect.height + window.pageYOffset,
+                   above = false;
 
                tooltipDiv.className = 'cbi-tooltip';
                tooltipDiv.innerHTML = '▲ ';
@@ -3259,7 +3260,15 @@ var UI = baseclass.extend(/** @lends LuCI.ui.prototype */ {
                if (target.hasAttribute('data-tooltip-style'))
                        tooltipDiv.classList.add(target.getAttribute('data-tooltip-style'));
 
-               if ((y + tooltipDiv.offsetHeight) > (window.innerHeight + window.pageYOffset)) {
+               if ((y + tooltipDiv.offsetHeight) > (window.innerHeight + window.pageYOffset))
+                       above = true;
+
+               var dropdown = target.querySelector('ul.dropdown[style]:first-child');
+
+               if (dropdown && dropdown.style.top)
+                       above = true;
+
+               if (above) {
                        y -= (tooltipDiv.offsetHeight + target.offsetHeight);
                        tooltipDiv.firstChild.data = '▼ ' + tooltipDiv.firstChild.data.substr(2);
                }