Commit ba56641e authored by Pierre Dittgen's avatar Pierre Dittgen

Pop-over: Factorize js code and style

parent 680865fd
......@@ -21,3 +21,9 @@ body {
bottom: 0;
width: 100%;
}
/* Pop-over management */
.popover .popover-body h2 {
font-size: 1.2em;
font-weight: bold;
}
// Popovers that stays while on popover bubble
// https://stackoverflow.com/questions/15989591/how-can-i-keep-bootstrap-popover-alive-while-the-popover-is-being-hovered
$('[data-toggle="popover"]')
.popover({
trigger: "manual",
html: true,
animation: false,
placement: "auto"
})
.on("mouseenter", function() {
var _this = this
$(this).popover("show")
$(".popover").on("mouseleave", function() {
$(_this).popover("hide")
})
})
.on("mouseleave", function() {
var _this = this
setTimeout(function() {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100)
})
// Open links found in error description in a new window/tab
$("body").on("mouseover", "div.popover a", function() {
$(this).prop("title", "Ouvrir dans une nouvelle fenêtre")
})
$("body").on("click", "div.popover a", function() {
var url = $(this).prop("href")
window.open(url, "_blank")
return false
})
......@@ -8,10 +8,6 @@
{% block head %}
{{ super() }}
<style>
.popover .popover-body h2 {
font-size: 1.2em;
font-weight: bold;
}
#table-errors td h2 {
font-size: 1em;
font-weight: bold;
......@@ -119,44 +115,12 @@
<h3 class="my-4">Erreurs de contenu</h3>
{{ macros.body_errors(report, source_data, print_mode) }}
{% else %}
{{ macros.preview(source_data) }}
{{ macros.preview(report, source_data) }}
{% endif %}
</div>
{% endblock %}
{% block page_scripts %}
<script>
// Popovers that stays while on popover bubble
// https://stackoverflow.com/questions/15989591/how-can-i-keep-bootstrap-popover-alive-while-the-popover-is-being-hovered
$('[data-toggle="popover"]').popover({
trigger: 'manual',
html: true,
animation: false,
placement: 'auto'
})
.on('mouseenter', function () {
var _this = this;
$(this).popover('show');
$('.popover').on('mouseleave', function () {
$(_this).popover('hide');
});
}).on('mouseleave', function () {
var _this = this;
setTimeout(function () {
if (!$('.popover:hover').length) {
$(_this).popover('hide');
}
}, 100);
});
// Open links found in error description in a new window/tab
$('body').on('mouseover', 'div.popover a', function() {
$(this).prop('title', 'Ouvrir dans une nouvelle fenêtre');
});
$('body').on('click', 'div.popover a', function() {
var url = $(this).prop('href');
window.open(url, '_blank')
return false;
});
<script src="{{ url_for('static', filename='validata_popover.js') }}">
</script>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment