Fix styling (ESLint) on tooltip_helper.js

This commit is contained in:
Luka Murn 2018-10-02 11:25:51 +02:00
parent ada98e9eaf
commit c12f77d1d1

View file

@ -2,10 +2,11 @@
'use strict'; 'use strict';
$.initTooltips = function() { $.initTooltips = function() {
if ($(document.body).data("tooltips-enabled") === true || $(document.body).data("tooltips-enabled") == null) {
var popoversArray = []; var popoversArray = [];
var leaveTimeout; var leaveTimeout;
var enterTimeout; var enterTimeout;
if ($(document.body).data('tooltips-enabled') === true || $(document.body).data('tooltips-enabled') == null) {
$('.tooltip_open').remove(); // Destroy all (if any) old open popovers $('.tooltip_open').remove(); // Destroy all (if any) old open popovers
$('.help_tooltips').each(function(i, obj) { $('.help_tooltips').each(function(i, obj) {
var popoverObject = obj; var popoverObject = obj;
@ -15,61 +16,69 @@
var link = $(obj).data('tooltiplink'); var link = $(obj).data('tooltiplink');
var textData = $(obj).data('tooltipcontent'); var textData = $(obj).data('tooltipcontent');
$(obj).popover({ $(obj)
.popover({
html: true, html: true,
container: 'body', container: 'body',
placement: 'auto right', placement: 'auto right',
trigger: 'manual', trigger: 'manual',
content: 'popovers will not display if empty', content: 'popovers will not display if empty',
template: '<div class="popover tooltip_' + i + '_window tooltip-open" role="tooltip" >' + template: '<div class="popover tooltip_' + i + '_window tooltip-open" role="tooltip" >'
'<div class="popover-body" >' + textData + '</div>' + + '<div class="popover-body" >' + textData + '</div>'
'<br><br><br>' + + '<br><br><br>'
'<div class="popover-footer">' + + '<div class="popover-footer">'
'<a class="btn btn-link text-nowrap" href="' + link + '" target="_blank" rel="noopener noreferrer" >' + + '<a class="btn btn-link text-nowrap" href="' + link + '" target="_blank" rel="noopener noreferrer" >'
'Read more&nbsp;&nbsp;&nbsp;<i class="fas fa-external-link-alt"></i>' + + 'Read more&nbsp;&nbsp;&nbsp;<i class="fas fa-external-link-alt"></i>'
'</a>' + + '</a>'
'</div>' + + '</div>'
'</div>' + '</div>'
}).off("shown.bs.popover").on("shown.bs.popover", function() { })
.off('shown.bs.popover')
.on('shown.bs.popover', function() {
// hide all other popovers // hide all other popovers
popoversArray.forEach(function(arrayItem) { popoversArray.forEach(function(arrayItem) {
if (obj !== arrayItem) { if (obj !== arrayItem) {
$(arrayItem).popover("hide"); $(arrayItem).popover('hide');
} }
}); });
}).off("mouseleave").on("mouseleave", function( ) { })
.off('mouseleave')
.on('mouseleave', function() {
clearTimeout(enterTimeout); clearTimeout(enterTimeout);
leaveTimeout = setTimeout(function() { leaveTimeout = setTimeout(function() {
if (!$(".tooltip_" + i + "_window:hover").length > 0) { if (!$('.tooltip_' + i + '_window:hover').length > 0) {
$(obj).popover("hide"); $(obj).popover('hide');
} }
}, 100); }, 100);
}).off("mouseenter").on("mouseenter", function() { })
.off('mouseenter')
.on('mouseenter', function() {
clearTimeout(leaveTimeout); clearTimeout(leaveTimeout);
enterTimeout = setTimeout(function() { enterTimeout = setTimeout(function() {
var top;
if ($(obj).hover().length > 0) { if ($(obj).hover().length > 0) {
$(obj).popover("show"); $(obj).popover('show');
$(".tooltip_" + i + "_window").removeClass("tooltip-enter"); $('.tooltip_' + i + '_window').removeClass('tooltip-enter');
var top = $(obj).offset().top; top = $(obj).offset().top;
$('.tooltip_' + i + '_window').css({ $('.tooltip_' + i + '_window').css({
top: (top) + 'px' top: (top) + 'px'
}); });
$(".tooltip_" + i + "_window").off("mouseleave").on("mouseleave", function() { $('.tooltip_' + i + '_window').off('mouseleave').on('mouseleave', function() {
$(".tooltip_" + i + "_window").removeClass("tooltip-enter"); $('.tooltip_' + i + '_window').removeClass('tooltip-enter');
$(obj).popover('hide'); $(obj).popover('hide');
}); });
$(".tooltip_" + i + "_window").off("mouseenter").on("mouseenter", function() { $('.tooltip_' + i + '_window').off('mouseenter').on('mouseenter', function() {
$(".tooltip_" + i + "_window").addClass("tooltip-enter"); $('.tooltip_' + i + '_window').addClass('tooltip-enter');
}); });
} }
}, 1000); }, 1000);
}); });
}) });
}
} }
};
$(document).ready(function() { $(document).ready(function() {
$.initTooltips(); $.initTooltips();
}); });
}()); }());