only prefetch images on update_mode update

This commit is contained in:
Mario Vavti 2016-02-16 20:53:38 +01:00
parent 3be6ef6bfc
commit 45247d1595

View File

@ -617,7 +617,7 @@ function updateConvItems(mode,data) {
/* autocomplete @nicknames */
$(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
/*
var bimgs = $(".wall-item-body img").not(function() { return this.complete; });
var bimgcount = bimgs.length;
@ -631,8 +631,8 @@ function updateConvItems(mode,data) {
} else {
collapseHeight();
}
*/
collapseHeight();
//collapseHeight();
}
@ -648,7 +648,6 @@ function collapseHeight() {
if(! $(this).hasClass('divmore')) {
//var trigger = $(window).scrollTop() < $(this).offset().top ? true : false;
var trigger = true;
// check if we will collapse some content above the visible content and compensate the diff later
if($(window).scrollTop() > $(this).offset().top) {
@ -657,7 +656,7 @@ function collapseHeight() {
i++;
}
if(trigger) {
//if(trigger) {
$(this).readmore({
speed: 0,
heightMargin: 50,
@ -673,7 +672,7 @@ function collapseHeight() {
}
});
$(this).addClass('divmore');
}
//}
}
}
});
@ -683,7 +682,7 @@ function collapseHeight() {
console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px');
if(i){
var sval = position - cDiff + $(".divgrow-showmore").height();
var sval = position - cDiff + ($(".divgrow-showmore").outerHeight() * i);
console.log('collapsed above content count: ' + i);
$(window).scrollTop(sval);
}
@ -739,6 +738,9 @@ function liveUpdate() {
$.get(update_url, function(data) {
var dready = new Date();
console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.');
if(update_mode === 'update') {
console.log('LOADING images...');
$('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() {
@ -751,9 +753,7 @@ function liveUpdate() {
$("#page-spinner").spin(false);
$("#profile-jot-text-loading").spin(false);
if(update_mode === 'update') {
$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
}
in_progress = false;
@ -772,6 +772,31 @@ function liveUpdate() {
timer = setTimeout(NavUpdate,10);
});
}
else {
page_load = false;
scroll_next = false;
updateConvItems(update_mode,data);
$("#page-spinner").spin(false);
$("#profile-jot-text-loading").spin(false);
in_progress = false;
// FIXME - the following lines were added so that almost
// immediately after we update the posts on the page, we
// re-check and update the notification counts.
// As it turns out this causes a bit of an inefficiency
// as we're pinging twice for every update, once before
// and once after. A btter way to do this is to rewrite
// NavUpdate and perhaps LiveUpdate so that we check for
// post updates first and only call the notification ping
// once.
updateCountsOnly = true;
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,10);
}
});
}