PHRAS-605 fix caption tooltip oversize with vertical scroll

This commit is contained in:
Florian BLOUET
2015-07-20 17:06:53 +02:00
parent 3a768af135
commit efc5bebb4f
3 changed files with 45 additions and 4 deletions

View File

@@ -40,6 +40,7 @@
fade: true, fade: true,
showURL: true, showURL: true,
outside: true, outside: true,
isBrowsable: false,
extraClass: "", extraClass: "",
top: 15, top: 15,
left: 15, left: 15,
@@ -199,7 +200,8 @@
helper.url.hide(); helper.url.hide();
// add an optional class for this tip // add an optional class for this tip
// helper.parent.addClass(settings(this).extraClass); helper.parent.removeClass();
helper.parent.addClass(settings(this).extraClass);
if (this.ajaxLoad) { if (this.ajaxLoad) {
clearTimeout($.tooltip.ajaxTimeout); clearTimeout($.tooltip.ajaxTimeout);
$.tooltip.ajaxTimeout = setTimeout("$.tooltip.delayAjax()", 300); $.tooltip.ajaxTimeout = setTimeout("$.tooltip.delayAjax()", 300);
@@ -470,6 +472,20 @@
} else { } else {
helper.parent.show(); helper.parent.show();
} }
$(helper.parent[0])
.unbind('mouseleave')
.mouseleave(function () {
if (settings($.tooltip.current).isBrowsable) {
// if tooltip has scrollable content or selectionnable text - should be closed on mouseleave:
$.tooltip.currentHover = false;
helper.parent.hide();
} else {
console.log('ok owned')
}
});
update(); update();
} }
@@ -510,11 +526,13 @@
// stop updating when tracking is disabled and the tooltip is visible // stop updating when tracking is disabled and the tooltip is visible
if (!track && helper.parent.is(":visible")) { if (!track && helper.parent.is(":visible")) {
$(document.body).unbind('mousemove', update); $(document.body).unbind('mousemove', update);
$.tooltip.currentHover = true;
} }
// if no current element is available, remove this listener // if no current element is available, remove this listener
if ($.tooltip.current === null) { if ($.tooltip.current === null) {
$(document.body).unbind('mousemove', update); $(document.body).unbind('mousemove', update);
$.tooltip.currentHover = false;
return; return;
} }
@@ -573,8 +591,16 @@
// hide helper and restore added classes and the title // hide helper and restore added classes and the title
function hide(event) { function hide(event) {
if( $.tooltip.currentHover && settings($.tooltip.current).isBrowsable ) {
return;
}
if ($.tooltip.blocked || !$.tooltip.current) if ($.tooltip.blocked || !$.tooltip.current)
return; return;
$(helper.parent[0])
.unbind('mouseleave');
// clear timeout if possible // clear timeout if possible
if (tID) if (tID)
clearTimeout(tID); clearTimeout(tID);

View File

@@ -11,4 +11,15 @@
#answers { #answers {
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
} }
.caption-tooltip-container {
max-width: 500px;
}
.caption-tooltip-container .popover-inner .popover-content {
max-width: 500px;
max-height: 500px;
overflow: auto;
overflow-x: hidden;
}

View File

@@ -390,7 +390,12 @@ function afterSearch() {
answAjaxrunning = false; answAjaxrunning = false;
$('#answers').removeClass('loading'); $('#answers').removeClass('loading');
$('.captionTips, .captionRolloverTips, .infoTips').tooltip({ $('.captionTips, .captionRolloverTips').tooltip({
delay: 0,
isBrowsable: true,
extraClass: 'caption-tooltip-container'
});
$('.infoTips').tooltip({
delay: 0 delay: 0
}); });
$('.previewTips').tooltip({ $('.previewTips').tooltip({
@@ -591,7 +596,6 @@ function getFacetsTree() {
s_closer.click( s_closer.click(
function(event) { function(event) {
console.debug(this);
event.stopPropagation(); event.stopPropagation();
var facetTitle = $(this).data("facetTitle"); var facetTitle = $(this).data("facetTitle");
delete selectedFacetValues[facetTitle]; delete selectedFacetValues[facetTitle];