fix tab tooltip issues

pull/402/head
nightwing 2017-02-21 18:28:03 +04:00
rodzic a584efecc8
commit d39a8ac3c8
4 zmienionych plików z 76 dodań i 16 usunięć

Wyświetl plik

@ -206,7 +206,7 @@
color : @gutter-tooltip-color; color : @gutter-tooltip-color;
.font-smoothing(@gutter-tooltip-font-smoothing); .font-smoothing(@gutter-tooltip-font-smoothing);
} }
.ace_dark .ace_tooltip { .ace_dark .ace_tooltip, .ace_dark.ace_tooltip {
box-shadow : @gutter-tooltip-dark-shadow !important; box-shadow : @gutter-tooltip-dark-shadow !important;
background : @gutter-tooltip-dark-background !important; background : @gutter-tooltip-dark-background !important;
border : 1px solid @gutter-tooltip-dark-border; border : 1px solid @gutter-tooltip-dark-border;

Wyświetl plik

@ -204,40 +204,98 @@ define(function(require, module, exports) {
/***** Methods *****/ /***** Methods *****/
function addCustomTooltipHandler(el) { function addCustomTooltipHandler(el) {
el.addEventListener("mousemove", function(e) { var tooltipTimer;
var target = e.target; var tooltipHideTimer;
var amlTab = apf.findHost(target); var currentTarget;
function hide() {
console.log("hide", currentTarget)
if (tooltipTimer) tooltipTimer = clearTimeout(tooltipTimer);
if (tooltipHideTimer) tooltipHideTimer = clearTimeout(tooltipHideTimer);
if (tooltip) tooltip.hide();
currentTarget = null;
}
function findTab(e) {
var amlTab = apf.findHost(e.target);
var tab = amlTab && amlTab.cloud9tab; var tab = amlTab && amlTab.cloud9tab;
if (!tab) return tooltip && tooltip.hide(); return tab;
}
el.addEventListener("mousemove", function(e) {
if (apf.isMousePressed)
return tooltip && tooltip.hide();
var tab = findTab(e);
if (tooltip && tooltip.isOpen) {
tooltipHideTimer = clearTimeout(tooltipHideTimer);
if (currentTarget != tab) {
currentTarget = tab;
updateTooltip();
}
} else {
if (currentTarget != tab || !tooltipTimer) {
tooltipTimer = clearTimeout(tooltipTimer);
tooltipTimer = setTimeout(updateTooltip, 150);
currentTarget = tab;
}
}
});
function updateTooltip() {
console.log("show", currentTarget)
tooltipTimer = clearTimeout(tooltipTimer);
tooltipHideTimer = clearTimeout(tooltipHideTimer);
var tab = currentTarget;
if (!tab) return hide();
var tooltipTitle = tab.tooltip || tab.title; var tooltipTitle = tab.tooltip || tab.title;
if (!tooltipTitle) return tooltip && tooltip.hide(); if (!tooltipTitle) return hide();
if (!tooltip) if (!tooltip)
tooltip = new Tooltip(document.body); tooltip = new Tooltip(document.body);
var activeTab = tab.pane.activeTab || tab;
if (activeTab.classList.contains("dark"))
tooltip.getElement().classList.add("ace_dark");
else
tooltip.getElement().classList.remove("ace_dark");
var rect = tab.aml.$button.getBoundingClientRect(); var rect = tab.aml.$button.getBoundingClientRect();
var style = tooltip.getElement().style; var style = tooltip.getElement().style;
style.top = rect.bottom + 10 + "px"; style.top = rect.bottom + 10 + "px";
style.textAlign = "center"; style.textAlign = "center";
style.minWidth = rect.width + "px";
tooltip.setText(tooltipTitle); style.maxWidth = "40em";
style.whiteSpace = "pre-wrap";
style.wordWrap = "normal";
tooltip.setText(tooltipTitle.replace(/[/.-]/g, "\u200b$&"));
tooltip.show(); tooltip.show();
var tooltipRect = tooltip.getElement().getBoundingClientRect(); var tooltipRect = tooltip.getElement().getBoundingClientRect();
style.minWidth = rect.width + "px";
var left = rect.left + rect.width / 2 - tooltipRect.width / 2; var left = rect.left + rect.width / 2 - tooltipRect.width / 2;
if (left + tooltipRect.width > window.innerWidth) if (left + tooltipRect.width > window.innerWidth - 2)
left = Math.max(0, window.innerWidth - tooltipRect.width); left = Math.max(0, window.innerWidth - 2 - tooltipRect.width);
if (left < 2)
left = 2;
if (tooltipRect.width > window.innerWidth - 4)
style.maxWidth = window.innerWidth - 4 + "px";
style.left = left + "px"; style.left = left + "px";
}); }
el.addEventListener("mouseout", function(e) { el.addEventListener("mouseout", function(e) {
tooltip && tooltip.hide(); if (tooltip && tooltip.isOpen) {
clearTimeout(tooltipHideTimer);
tooltipHideTimer = setTimeout(hide, 100);
}
if (tooltipTimer)
tooltipTimer = clearTimeout(tooltipTimer);
}); });
el.addEventListener("mousedown", hide);
plugin.on("beforeUnload", function() { plugin.on("beforeUnload", function() {
tooltip && tooltip.destroy(); if (tooltip) {
tooltip = null; hide();
tooltip.destroy();
tooltip = null;
}
}); });
} }

Wyświetl plik

@ -792,7 +792,7 @@
@gutter-tooltip-shadow: @language-tooltip-box-shadow; @gutter-tooltip-shadow: @language-tooltip-box-shadow;
@gutter-tooltip-background: @language-tooltip-background; @gutter-tooltip-background: @language-tooltip-background;
@gutter-tooltip-border: @language-tooltip-border-color; @gutter-tooltip-border: @language-tooltip-border-color;
@gutter-tooltip-color: darken(#e0e3e8, @darken-chrome); @gutter-tooltip-color: darken(#333, @darken-chrome);
@gutter-tooltip-font-smoothing: false; @gutter-tooltip-font-smoothing: false;
@gutter-tooltip-dark-shadow: 1px 1px 6px darken(rgba(0, 0, 0, 0.8), @darken-chrome); @gutter-tooltip-dark-shadow: 1px 1px 6px darken(rgba(0, 0, 0, 0.8), @darken-chrome);

Wyświetl plik

@ -50,10 +50,12 @@ define(function(require, module, exports) {
apf.initialize('<a:application xmlns:a="http://ajax.org/2005/aml" />'); apf.initialize('<a:application xmlns:a="http://ajax.org/2005/aml" />');
window.addEventListener("mousedown", function() { window.addEventListener("mousedown", function() {
apf.isMousePressed = true;
document.body.classList.add("disableIframe"); document.body.classList.add("disableIframe");
}, true); }, true);
window.addEventListener("mouseup", function() { window.addEventListener("mouseup", function() {
apf.isMousePressed = false;
document.body.classList.remove("disableIframe"); document.body.classList.remove("disableIframe");
}, true); }, true);
} }