});
}
+var tooltipDiv = null, tooltipTimeout = null;
+
+function showTooltip(ev) {
+ if (!matchesElem(ev.target, '[data-tooltip]'))
+ return;
+
+ if (tooltipTimeout !== null) {
+ window.clearTimeout(tooltipTimeout);
+ tooltipTimeout = null;
+ }
+
+ var rect = ev.target.getBoundingClientRect(),
+ x = rect.left + window.pageXOffset,
+ y = rect.top + rect.height + window.pageYOffset;
+
+ tooltipDiv.className = 'cbi-tooltip';
+ tooltipDiv.innerHTML = '▲ ';
+ tooltipDiv.firstChild.data += ev.target.getAttribute('data-tooltip');
+
+ if (ev.target.hasAttribute('data-tooltip-style'))
+ tooltipDiv.classList.add(ev.target.getAttribute('data-tooltip-style'));
+
+ if ((y + tooltipDiv.offsetHeight) > (window.innerHeight + window.pageYOffset)) {
+ y -= (tooltipDiv.offsetHeight + ev.target.offsetHeight);
+ tooltipDiv.firstChild.data = '▼ ' + tooltipDiv.firstChild.data.substr(2);
+ }
+
+ tooltipDiv.style.top = y + 'px';
+ tooltipDiv.style.left = x + 'px';
+ tooltipDiv.style.opacity = 1;
+}
+
+function hideTooltip(ev) {
+ if (ev.target === tooltipDiv || ev.relatedTarget === tooltipDiv)
+ return;
+
+ if (tooltipTimeout !== null) {
+ window.clearTimeout(tooltipTimeout);
+ tooltipTimeout = null;
+ }
+
+ tooltipDiv.style.opacity = 0;
+ tooltipTimeout = window.setTimeout(function() { tooltipDiv.removeAttribute('style'); }, 250);
+}
+
document.addEventListener('DOMContentLoaded', function() {
+ tooltipDiv = document.body.appendChild(E('div', { 'class': 'cbi-tooltip' }));
+
+ document.addEventListener('mouseover', showTooltip, true);
+ document.addEventListener('mouseout', hideTooltip, true);
+ document.addEventListener('focus', showTooltip, true);
+ document.addEventListener('blur', hideTooltip, true);
+
document.querySelectorAll('.table').forEach(cbi_update_table);
});
.btn.info,
.alert-message.info,
.btn.info:hover,
-.alert-message.info:hover {
+.alert-message.info:hover,
+.cbi-tooltip.error, .cbi-tooltip.success, .cbi-tooltip.info {
color: #fff;
}
.btn.danger,
.alert-message.danger,
.btn.error,
-.alert-message.error {
+.alert-message.error,
+.cbi-tooltip.error {
background: linear-gradient(to bottom, #ee5f5b, #c43c35) repeat-x;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}
-.btn.success, .alert-message.success {
+.btn.success, .alert-message.success, .cbi-tooltip.success {
background: linear-gradient(to bottom, #62c462, #57a957) repeat-x;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}
-.btn.info, .alert-message.info {
+.btn.info, .alert-message.info, .cbi-tooltip.info {
background: linear-gradient(to bottom, #5bc0de, #339bb9) repeat-x;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
}
-.alert-message.notice {
+.alert-message.notice, .cbi-tooltip.notice {
background: linear-gradient(to bottom, #efefef, #fefefe) repeat-x;
text-shadow: 0 -1px 0 rgba(255, 255, 255, 0.25);
border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
position: absolute;
z-index: 1000;
left: -1000px;
+ box-shadow: 0 0 2px #ccc;
+ border-radius: 3px;
+ background: #fff;
+ white-space: pre;
+ padding: 2px 5px;
opacity: 0;
- transition: opacity .25s ease-out;
+ transition: opacity .25s ease-in;
}
.cbi-tooltip-container:hover .cbi-tooltip:not(:empty) {