abort preview thumbnail ajax request when leaving the zone (#4731)

This commit is contained in:
Frédéric Péters 2014-06-06 15:05:50 +02:00
parent 2bbe923020
commit 7a9d494995
1 changed files with 6 additions and 2 deletions

View File

@ -42,17 +42,21 @@ $(function() {
}
return false;
});
$('.ResultsTasksTable tr a').hover(function() {
var xhr_preview = null;
$('.ResultsTasksTable tr a, .ResultsTable tr a').hover(function() {
$('#preview-doc').remove();
$.getJSON($(this).attr('href') + '/@@preview',
xhr_preview = $.getJSON($(this).attr('href') + '/@@preview',
function (data) {
xhr_preview = null;
$('#preview-doc').remove();
if (xhr_preview !== null) xhr_preview.abort();
if (data.thumbnail_url) {
$('body').append('<div id="preview-doc">');
$('#preview-doc').append('<img src="' + data.thumbnail_url + '"/>');
}
});
}, function() {
if (xhr_preview !== null) xhr_preview.abort();
$('#preview-doc').remove();
});
});